⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 netstoreejbfromfactorydelegate.java

📁 一个netstore的完整代码,他使用了j2ee和webservice技术,并使用ojb o/r管理框架,很不错的
💻 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 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 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 + -