📄 netstoreejbdelegate.java
字号:
package netstore.service.ejb;
import java.rmi.RemoteException;
import java.util.Hashtable;
import java.util.List;
import javax.ejb.CreateException;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.rmi.PortableRemoteObject;
import javax.servlet.ServletContext;
import netstore.catalog.view.ItemDetailView;
import netstore.customer.view.UserView;
import netstore.framework.exceptions.*;
import netstore.service.INetstoreService;
/**
* This class is a business delegate that supports the implementation of the
* INetstoreService interface using the Netstore session bean.
*/
public class NetstoreEJBDelegate implements INetstoreService {
private INetstore netstore;
ServletContext servletContext = null;
public NetstoreEJBDelegate( ) {
init( );
}
private void init( ) {
try {
InitialContext ic = new InitialContext();
Object objRef = ic.lookup("java:comp/env/ejb/NetstoreEJB");
NetstoreEJBHome home = (NetstoreEJBHome)PortableRemoteObject.narrow(objRef,
netstore.service.ejb.NetstoreEJBHome.class);
netstore = home.create();
}
catch (NamingException e) {
throw new RuntimeException(e.getMessage( ));
}
catch (CreateException e) {
throw new RuntimeException(e.getMessage( ));
}
catch (RemoteException e) {
throw new RuntimeException(e.getMessage( ));
}
}
public UserView authenticate( String email, String password )
throws InvalidLoginException, ExpiredPasswordException,
AccountLockedException, DatastoreException {
try {
return netstore.authenticate(email, password);
}
catch (RemoteException e) {
throw DatastoreException.datastoreError(e);
}
}
public List getFeaturedItems( ) throws DatastoreException {
try {
return netstore.getFeaturedItems( );
}
catch (RemoteException e) {
throw DatastoreException.datastoreError(e);
}
}
public ItemDetailView getItemDetailView( String itemId )
throws DatastoreException {
try {
return netstore.getItemDetailView(itemId);
}
catch (RemoteException e) {
throw DatastoreException.datastoreError(e);
}
}
public void logout( String email ) {
// Do nothing for this example
}
public void destroy( ) {
// Do nothing for this example
}
public void setServletContext( ServletContext ctx ){
this.servletContext = ctx;
}
public ServletContext getServletContext(){
return servletContext;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -