Web design portfolio - public UserView authenticate( String email, String password )
public UserView authenticate( String email, String password ) throws InvalidLoginException, ExpiredPasswordException, AccountLockedException, DatastoreException, RemoteException; public List getFeaturedItems( ) throws DatastoreException, RemoteException; public ItemDetailView getItemDetailView( String itemId ) throws DatastoreException, RemoteException; } The first thing to notice about the IStorefront interface is that its methods don’t exactly match those declared by IStorefrontService. First of all, our business interface doesn’t include the logout( )and destroy( )methods found in the service interface. The reason for this is that those methods represent web-tier functionality, not true business logic that needs to move to the application tier. Also, every method in IStorefront is declared to throw RemoteException, which is not part of the declarations in IStorefrontService. All business methods exposed to a remote client of an EJB must be declared to throw RemoteException, which is used to report communication failures specific to remote method execution. This is the one aspect of a remote interface that can’t be hidden by the business interface. Without this restriction, this interface could be made to look very much like our service interface. Once we cover how our example session bean will be implemented, we’ll discuss how these mismatches between the interfaces can be handled. It’s also important to notice that our business interface is referencing the view classes already created to support the service interface. The same Data Transfer Object (DTO) pattern introduced in Chapter 7 applies to an EJB-based model. Instead of exposing the actual business object implementation classes or many fine-grained methods to access their properties, you can use simple JavaBean classes to communicate the state of the model to the client. We declared our BaseViewsuperclass to be Serializable so that the view classes could be referenced in a remote interface. DTO classes tend to consist of simple data types, so this constraint should be a minor one. With our business interface defined, Example 13-2 shows the trivial remote interface declaration we’ll need to eventually deploy our session bean. Example 13-2. The remote interface for the Storefront session bean package com.oreilly.struts.storefront.service; import javax.ejb.EJBObject; public interface Storefront extends EJBObject, IStorefront { /** * The remote interface for the Storefront session bean. All methods are * declared in the IStorefront business interface. */ }
We highly recommend you visit web and email hosting services if you need stable and cheap web hosting platform for your web applications.