w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Application layer references data layer directly
If you have a valid reason for calling the data layer directly, then do it. If you add a pass-through function in the business layer, then all you've done is added more code for no apparent benefit. Now, if your business layer is exposed via an interface, IBusinessLayer for example, then adding a ProcessAllPersons() function to it and having it pass the call directly to the data layer makes more sense and consistency. This is what I would recommend.

Categories : Vb.Net

How to add an application as Firewall exception in WiX installer
heat accepts an XSL transform argument to modify its output in any way you need. A simple XSL stylesheet can add an element to a particular File element selected via XPath. This assumes that there is only test.exe in your heat run. If that's not the case, modify the XPath in the match attribute: <?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:wix='http://schemas.microsoft.com/wix/2006/wi' xmlns:fire='http://schemas.microsoft.com/wix/FirewallExtension' xmlns='http://schemas.microsoft.com/wix/2006/wi' exclude-result-prefixes='wix' > <xsl:output method="xml" indent="yes" /> <xsl:template match="//wix:File[contains(@Source,' est.exe')]"> <wix:File>

Categories : Wix

Authenticating Hybrid Mobile Application with ADFS behind firewall
I assume your API (WebApi based) is hosted on Azure, right? Obtaining a token from an STS in a mobile client, usually involves delegating the authentication to a web browser (using passive profile) and then extracting the token with then it becomes available. This is often the case with STSs that don't support "Active Profile" (an endpoint where you can send client credentials and receive a security token in exchange). ADFS supports this (through WS-Trust), but you don't want ADFS exposed to the internet (you could though, and ADFS has a specific role for this without the need for a VPN). This technique is illustrated in this sample. PhoneGap will likely have an equivalent. A (simpler?) way in your case might be to get a Windows Azure AD (WAAD) account, and use DirSync to synch your AD

Categories : Authentication

Using AFIncrementalStore with a WebSockets Application
I think I may have found the answer to this. In my XIB I have an array controller with the "prepares content" checkbox on. That would have triggered the data store and loaded up all the Core Data stack. When I uncheck that box it doesn't load, and my ADN delegate is free to pull the ID. So if anyone else runs into this, the answer is the CD stack doesn't load until you try to hit it.

Categories : Objective C

WSO2 Application Server 5.1.0 - JSR356 Websockets API
WSO2 AS 5.1.0 is based on Tomcat 7.0.34 version and it has some web socket support. Please take a look on following samples to check whether are those fulfill your requirements https://svn.wso2.org/repos/wso2/carbon/platform/tags/4.1.0/products/as/5.1.0/modules/samples/common/webapp/src/main/java/websocket/. FYI above samples are available with WSO2 AS 5.1.0 distribution.

Categories : Tomcat

Can a .NET application's domain layer be self aware of what type of application it is?
You can try to analyze the current process context in order to guess what executable launched it, or the properties of the parent process perhaps. For example, if Process.GetCurrentProcess().ProcessName is YourWinformProject, it was launched from a Winforms context, but if it's the name of the executable of IIS/Apache, it's running as a web page. Neither are 100% reliable though. Just curious, why does it matters at all? I think that both domain logic and persistence should be the same, no matter from where it's being called. If it really needs to behave different, why not just pass an additional piece of data to the service/model/repository/whatever to tell how to act, based on the current context.

Categories : C#

Which layer should I test in an n-tier application
Generally you need end to end tests as well as unit tests. I don't want to explain the basic concept but I just want to list some best practice from my own experience. For doing the unit tests, only test one layer at a time by mocking the layer it based on. For example, when you test Business layer, you should mock the Data access layer. By mocking the layer below, you can logically isolate the code stub you want to test without touching other layers. This approach not only is easy to work with, but also you can prevent testing too much things and get false alarms. You can also prepare test fixture to make sure every time you run test, you actually do the dry run. Here are some popular technology you can use to do the unit testing: To test Javascipt in the View Layer you can use Jasmin

Categories : C#

Session functionality in application layer?
You would need to register a Filter or HandlerInterceptor that would have a look at the HttpSession and, if the user is logged in, store some kind of User representation in some static ThreadLocal context. Any class could then have access to this static ThreadLocal containing your User object. You would have to remove this object when the user logs out or session expires. Hint: HttpSessionListener.

Categories : Spring

Can we use Data Access Layer in stand alone application?
Yes having a data access layer to consolidate your JDBC code instead of having it scattered throughout the application is beneficial. Also should consider using a db connection pool. An example is Apache DBCP. Just because it is a stand-alone app does not negate the benefit IMO.

Categories : Java

C# Application Architecture - EF5 & understanding the Service Layer
You did present a simple scenario which the Repository itself might be sufficient. Do you have more repositories? Do you expect you application to grow, and have more repositories in use? Having a service layer that abstract the data layer is recommended and in use by most of the applications/examples that I have seen, and the overhead is not that significant. One reason for using services might pop-up when you would like to fetch data from several different repositories, and then perform some kind of aggregation / manipulations on the data. A Service layer would then provide the manipulation logic, while the service consumer would not have to deal with several different repositories. You should also think of situations where you might want to have more then one entity changed in one t

Categories : C#

Reporting errors from the application services layer
I think these are business constraint brokens that cannot be recovered. My current solution is Exception hierachy. public abstract class UncheckedApplicationException extends RuntimeException { //omitted factory methods and constructors public abstract String getStatusCode(); public abstract String getI18nCode();//ignore this if you don't need i18n public abstract String[] getI18nArgs();//ignore this if you don't need i18n } Any custom exception extends this one. I think this could avoid code like this: try { //invoke your application service } catch (InsufficientInventoryException e) { statusCode = INSUFFICIENT_INVENTORY; } catch (ExpriedPriceException e) { statusCode = EXPIRED_PRICE; } catch (NoSuchProductException e) { statusCo

Categories : Spring

Implementing Encryption in application layer in Android
In general, you can use SSL/TLS (for stream-based communications) and DTLS (UDP-based variant of TLS) to secure your communication and avoid reinventing the wheel. Contrary to the popular belief, TLS does not require X.509 certificates -- TLS supports many authentication mechanisms including OpenPGP, shared keys and more. Not many libraries support those mechanisms though (our SecureBlackbox does). Encrypting the data on-the-go without TLS is also possible, of course, but again it's a good idea to avoid implementing your own. In this case OpenPGP encryption would be very handy - it supports password-based as well as key-based encryption.

Categories : Android

Servicestack security over mvc on n-tier layer application
Is it possible to do on servicestack? is it good practice? Within ServiceStack you can apply authentication/authorization attributes at different levels (Request Dto, Service Action, Service class or a Serivce's base class) . You can also create Filter Attributes as well. Is there any example of n-tier architecture example with servicestack? This is not so much an example but the structure of a typical layout of a ServiceStack project.

Categories : Asp Net Mvc

How to use an existing business layer with new .net single page application
You could create web services that expose the arrays, or use the ones you have. Ideally, they would return JSON. then you can create the client anyway you like, and have it talk to the server via those services . if you want breeze, then you could create a dummy project, load in the poco models to EF, then hook breeze's controller to it. Grab the metadata, then copy that metadata to your real web services and return it from there. That way you can use breeze very well on your client. breeze has docs on this too

Categories : Misc

Avoiding global state in DAO layer of a Clojure application
You can use higher order function to represent your DAO layer - that's the crux of functional programming, using functions to represent small to large parts of your system. So you have a higher order function which takes in the DB connection as param and return you another function which you can use to call various operations like save, delete etc on the database. Below is one such example: (defn db-layer [db-connection] (let [db-operations {:save (fn [obj] (save db-connection obj)) :delete (fn [obj] (delete db-connection obj)) :query (fn [query] (query db-connection query))}] (fn [operation & params] (-> (db-operations operation) (apply params))))) Usage of DB layer: (let [my-db (create-database) db-layer-fn (db-la

Categories : Mongodb

What is the best way to connect to Cassandra from application layer? Hector or CQL or Thrift?
Drop the book that you are reading. It is painfully out of the date. Instead, bookmark this page: Datastax Documentation. If you are starting fresh, then don't look at Hector API (unless of course you need to maintain old projects). Datastax Java Driver is the new way and the recommended way to work with Cassandra. Datastax Java Driver is designed for Cassandra CQL. P.s. I don't work for Datastax

Categories : Api

Removing From Super Layer crashes application after some time
It's self.scrollView.layer.sublayers = nil. Indiscriminately removing all sublayers causes nasty crashes in iOS 7, which can occur much later in the program's execution. I have tested this thoroughly using both rootLayer.sublayers = nil and [rootLayer.sublayers makeObjectsPerformSelector:@selector(removeFromSuperlayer)]. There must be a system-created layer that's getting messed up. You have to keep your own array of layers and remove them yourself: [myArrayOfLayersIAddedMyself makeObjectsPerformSelector:@selector(removeFromSuperlayer)];

Categories : IOS

How does TCP/Application layer identifies the destination port number?
The application has to be told. Either the port is a standard port listed in etc/services, in which case the getaddrinfo() API tells you, or else it is provided via the application's configuration, or it's hard-wired into the source code.

Categories : Networking

Is it better to sort data at the application layer, or with an order by clause?
First, if you really want to know on a given set of data, then you should test it. That said, there are several reasons why I think you should sort on the server side. First, the server can take advantage of more hardware -- multiple threads, multiple disks, multiple processors -- for sorting. This can make a big difference on performance. Second, the sorting may not be necessary. There may be cases where the query does not actually have to sort the results, because they are already sorted. For instance, the results may be returned based on an index that is sorted. Third, memory usage issues and memory leaks tend to be more prevalent on the client side. (Okay, you don't say you are using java, so you are a bit safe from this.) The database server knows how to manage memory. Fourt

Categories : SQL

How to send system events from driver to application layer?
Using the plain win32 API, I would create a named event (i.e. supply a name for CreateEvent()). This can be use across process boundaries, including across the kernel/userspace boundary. You would then simply use WaitForSingleObject() and related functions to check the event state. If you have a stream driver, you can also call ReadFile() from the application and simply stall inside the according handler function of the driver. This makes it pretty easy to add data to the event, too. Further, it provides separation between different processes that access the driver, or even different instances within the same process. Compare this with the event above, which is effectively system-wide visible and can also be set by different processes, although you can restrict this to some extent. Anoth

Categories : C++

DDD for web application, should I put a rich domain object into presentation layer?
Domain objects (or any complex object) shouldn't be put in Session for both technical (resource waste) and semantical reasons. Session is not ment to be a Cache, but a holder of tmeporary user data. Store the object id maybe in the Session and then use the Repository to retrieve the actual object. The repository may cache things if required.

Categories : Java

Does each Windows Store application have its own network level/layer that can be accessed?
WebView in 8.1 has mechanism to intercept resource requests and replace them with your own. See http://channel9.msdn.com/Events/Build/2013/3-179 around 42 minutes. Basically you will have to create your own implementation of IUriToStreamResolver.UriToStreamAsync that uses HttpClient to get all of your data through proxy.

Categories : Dotnet

ecommerce application web tier/presentation layer unit testing
A few ideas for unit testing a web tier: Use MVC for doing web development. It is pretty easy to unit test controllers assuming you extract all your dependencies. Make liberal use of interfaces to extract dependencies in your JSP pages. For example, does your JSP make a database call? Consider making an Repository interface and then have implementations like MySQLRepositoryImpl.java that implement the interface. This way, you can also "mock" the interface and create a fake database that will run fast in your unit tests. For very difficult problems where you absolutely need to use a dependency, you can get embedded versions of things like web servers (Grizzly, Jetty) or even databases (H2, SQLite). Make sure you write your code such that each function does one thing and one thing only. T

Categories : Unit Testing

N-Tier Service Layer Validation Show Business Logic Error in Presentation Layer
First, your overall approach to MVC looks good to me :-) Second, you most likely want to use DataAnnotation on your view models for model validation. Have a look this blog post for a good intro on using it in ASP.MVC. In case of custom validation not suitable for data annotation you can do the following in your controller: try { // the following exception could be thown by some nested validation logic // e.g. while processing a post request throw new ValidationException("the error description"); } catch (ValidationException exception) { ModelState.AddModelError("", exception.Message); }

Categories : Asp Net Mvc

Annotating over an NSImageView with CALayers, layer-hosting or layer-backed?
The solution I went for was to not alter the NSImageView subclass's layer at all. Instead I added a subview to the NSImageView subclass, constrained the view such that is has the same bounds as the parent, and then made this subview layer-hosting. It is then possible to add sublayer to this 'annotation' view's layer. In this way I can annotate on top of an NSImageView.

Categories : Xcode

Which pattern to implement on Data access layer and on the business layer?
Build a Service Layer that the Presentation Layer (web app) references. Then in the Service Layer you have a reference to the BLL, EF5 Entities and DAL. The Service Layer can be just a Class Library (ASP.NET Web API for example) or a Web Services layer (WCF for example). Now your web application has no hard reference to the DAL, but rather only knows of the Service Layer and the EF5 Entities.

Categories : Asp Net

How to update a layer property for UIView and keep the layer for it subview?
The problem isn't all of your changes to the layer, its just the shadow. That's because the shadow is applied to the layers composited alpha channel, and that includes its sub layers. You could either: Use a shadow path instead of the standard offset Add a different sub layer on which to specify the shadow (where it is a sibling to the button)

Categories : Iphone

What's the difference between link-layer and e.g. transport-layer reliability?
Link layer reliability provides reliable delivery over a link. However, packet can still be dropped in router for a limited buffer size. Therefore, even all links provide reliable service, it doesn't guarantee an end-to-end reliability.

Categories : Networking

Switch from Terrain layer to Satellite layer using Mapbox
With MapBox there is no concept of "modes", just different maps each with their own Map ID. So create a map at http://tiles.mapbox.com/newmap based on terrain, then another based on satellite imagery. Switch between them with the second argument to L.mapbox.map (see http://www.mapbox.com/mapbox.js/api/v1.0.4/#L.mapbox.map) using their respective IDs.

Categories : Javascript

how to do a fade-in effect for one layer after another layer, CALayer
Tag your image views with e.g. 10, 20, 30. Then, -(void)addAnimationToView:(UIView*)image { CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"opacity"]; animation.fromValue = [NSNumber numberWithFloat:0.0]; animation.toValue = [NSNumber numberWithFloat:1.0]; animation.duration = 4; animation.removedOnCompletion = NO; animation.fillMode = kCAFillModeBoth; [imageView.layer addAnimation:animation forKey:@"opacityAnimation"]; } for (int i=0; i<3; i++) { UIImageView *image = (UIImageView*) [self.view viewWithTag:(i+1)*10]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, i*4 * NSEC_PER_SEC), dispatch_get_current_queue(), ^{ [self addAnimationToView:image]; }); } Maybe you have to prefix the definition of image with __

Categories : IOS

cant add a shape layer into a view's layer
add a path to it, like shapeLayer.path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, 2.0*radius, 2.0*radius) cornerRadius:radius].CGPath; A shaped layer needs a shape… I put this in my View Controller and it works fine: - (void)viewDidLoad { [super viewDidLoad]; CAShapeLayer *shapeLayer = [CAShapeLayer layer]; shapeLayer.frame = CGRectMake(150, 50, 200, 200); shapeLayer.fillColor = [UIColor whiteColor].CGColor; shapeLayer.strokeColor = [UIColor orangeColor].CGColor; NSUInteger radius = 90; shapeLayer.path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, 2.0*radius, 2.0*radius) cornerRadius:radius].CGPath; [self.view.layer addSubl

Categories : IOS

Multiply matrices layer by layer
Haven't benchmarked this (so this is not guaranteed to be faster), but here goes: [L, ma, na] = size(A); [L, mb, nb] = size(B); AX = reshape(permute(A, [2 1 3]), [], na); BX = reshape(permute(B, [2 3 1]), mb, []); CX = reshape(permute(reshape(AX * BX, ma, L, nb, L), [1 3 2 4]), ma, nb, []); C = permute(CX(:, :, 1:L + 1:end), [3 1 2]); Note that you might also run into memory problems if A and B are large (in which case you'll have to resort to loops).

Categories : Matlab

How to inject Service Layer into controller when service layer depends upon repository and UnitOfWork
There's a lot opinions on this but this is how I worked it out for myself UnitOfWork public interface IUnitOfWork : IDisposable { FooContext DbContext { get; } void Save(); } public class UnitOfWork : IUnitOfWork { protected string ConnectionString; private FooContext context; public UnitOfWork(string connectionString) { this.ConnectionString = connectionString; } public FooContext DbContext { get { if (context == null) { context = new FooContext(ConnectionString); } return context; } } ... } GenericRepository public class GenericRepository<TEntity> : IGenericRepository<TEntity> where TEntity : class { protected FooContext Db

Categories : Asp Net Mvc

Create service response in web method, service layer or DAO layer?
I would say in your web method. The web service should be the interface for calling the service layer. It should transform the incoming request into something the service layer understands and should transform the result into something the web service can send. The service is, in general, a reusable part of your application and could be reused between your web service and web application (with controllers) or maybe by doing batch inserts. Basically everything calling the service (which contains the business logic) is a interfacing layer to your service. Controllers provide access to the application behavior that you typically define through a service interface. Controllers interpret user input and transform it into a model that is represented to the user by the view. Spring implemen

Categories : Java

firewall: 2-way UDP communication possible?
Yes this is called NAT traversal (or UDP punch through) and works in a similar way to TCP - the stateful NAT device is aware you recently sent a UDP packet from a certain end point internally to a certain end point outside and for a period will accept UDP packets from the same outside endpoint and forward them to the same internal end point. I always prefer the IETF docs than the plethora of conflicting information out there (including on this site): http://tools.ietf.org/html/rfc5128

Categories : Networking

how the FireWall knows if the transportation is UDP or TCP?
The header of the packets are completely different, TCP is much bigger for example. A stateful firewall needs to intercept the TCP headers to map the packets to its state table, but also stateless firewalls sometimes have techniques implemented to recognize valid TCP or UDP headers. Most home routers (broadband/wireless) make use of this when you are using port forwarding to distinguish between both protocol versions.

Categories : Security

C# HttpListener and Windows Firewall
This is because HttpListener is built on top of http.sys which will listen on the port you specified on behalf of your program. I haven't found a way to allow only a single program using HttpListener through the Windows Firewall, but you might want to limit your inbound rule to system components only by: Entering typing system in the field "This program" in the tab "Program and services" Selecting protocol type TCP in the tab "Protocols and Ports" together with the port you will be listening on

Categories : C#

Symfony2 - Logging out of one firewall
Logging out clears the security-context in the session, therefore you are logged out of your second firewall aswell. You should be using roles instead of two different firewalls. ROLE_ADMIN and ROLE_CLIENT - i don't see the need for a second firewall here :)

Categories : Security

How to handle business logic errors and application exceptions from business logic layer in MVC ASP.NET
I think it is a good idea to look at this sample. When ever an error occurs in Business logic layer you can return false or say -1 for a method of Business class, then show proper error message to user, and in catch part of the business method you can use one of popular error logging libs like Log4NET or elmah. Edited: To redirect user when error occurs you can specify the error controller in custom error section of web config

Categories : Asp Net Mvc

Creating firewall rules using iptables
Yes and no. No because: iptables works by defining how to treat packets based on their categorization into chains (INPUT, OUTPUT, FORWARD, ...) first and only then also on specific characteristics (source or destination address, protocol type, source or destination port, etc). You can never define an iptable rule that does not apply to a specific chain. INPUT, OUTPUT, and FORWARD are the default chains of the iptables system. INPUT addresses everything with destination localhost (i.e. that is addressed to your network device); OUTPUT applies to everything with source localhost (i.e. that comes from your computer). Yes because: You can define custom chains. You can do that like so sudo iptables -N MYCHAIN then you can send packets from both the INPUT and the OUTPUT (and if you like t

Categories : Linux



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.