📄 netstoreejbfromfactorydelegate.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.businessobjects.*;
import netstore.framework.exceptions.*;
import netstore.service.INetstoreService;
import netstore.service.HibernateUtil;
/**
* This class is a business delegate that supports the implementation of the
* INetstoreService interface using the Netstore session bean.
*/
public class NetstoreEJBFromFactoryDelegate implements INetstoreService {
private INetstore netstore;
ServletContext servletContext = null;
public NetstoreEJBFromFactoryDelegate( ) {
init( );
}
private void init( ) {
try {
NetstoreEJBHome home = (NetstoreEJBHome)EJBHomeFactory.getInstance( ).
lookupHome("java:comp/env/ejb/NetstoreEJB",
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 Customer authenticate(String email, String password) throws
InvalidLoginException,ExpiredPasswordException,AccountLockedException,DatastoreException{
try {
return netstore.authenticate(email, password);
}
catch (RemoteException e) {
throw DatastoreException.datastoreError(e);
}
}
public Customer getCustomerById(Long id) throws DatastoreException{
try {
return netstore.getCustomerById( id );
}
catch (RemoteException e) {
throw DatastoreException.datastoreError(e);
}
}
public Item getItemById( Long id)throws DatastoreException{
try {
return netstore.getItemById( id );
}
catch (RemoteException e) {
throw DatastoreException.datastoreError(e);
}
}
public List getItems(int beginIndex,int length) throws DatastoreException {
try {
return netstore.getItems( beginIndex,length);
}
catch (RemoteException e) {
throw DatastoreException.datastoreError(e);
}
}
public void saveOrder(Order order) throws DatastoreException{
try {
netstore.saveOrder( order);
}
catch (RemoteException e) {
throw DatastoreException.datastoreError(e);
}
}
public void saveOrUpdateCustomer(Customer customer) throws
DatastoreException{
try {
netstore.saveOrUpdateCustomer( customer);
}
catch (RemoteException e) {
throw DatastoreException.datastoreError(e);
}
}
public void logout( String email ) {
// Do nothing for this example
}
public void destroy() {
try {
netstore.destroy();
}
catch (RemoteException e) {
e.printStackTrace();
}
}
public void setServletContext( ServletContext ctx ){
this.servletContext = ctx;
}
public ServletContext getServletContext(){
return servletContext;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -