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

📄 catalogbean.java~6~

📁 Java源码 Java源码
💻 JAVA~6~
字号:
package cmp2image;import javax.ejb.*;import javax.naming.*;import java.util.*;import javax.rmi.PortableRemoteObject;public class CatalogBean implements SessionBean {  SessionContext sessionContext;  public void ejbCreate() throws CreateException {    /**@todo Complete this method*/  }  public void ejbRemove() {    /**@todo Complete this method*/  }  public void ejbActivate() {    /**@todo Complete this method*/  }  public void ejbPassivate() {    /**@todo Complete this method*/  }  public void setSessionContext(SessionContext sessionContext) {    this.sessionContext = sessionContext;  }  public HashSet findOne(String name) {    HashSet collection=new HashSet();    try {      Context context = getInitialContext();      //look up jndi name      Object ref = context.lookup("Inventory");      //look up jndi name and cast to Home interface      FlowerHome flowerHome = (FlowerHome) PortableRemoteObject.narrow(          ref, FlowerHome.class);      Flower flower = flowerHome.findByPrimaryKey(name);      System.out.println("Name: " + flower.getName());      collection.add(flower);    }    catch (Exception ex) {      ex.printStackTrace();    }    return collection;  }  private Context getInitialContext() throws Exception {    String url = "t3://localhost:7001";    String user = null;    String password = null;    Properties properties = null;    try {      properties = new Properties();      properties.put(Context.INITIAL_CONTEXT_FACTORY,                     "weblogic.jndi.WLInitialContextFactory");      properties.put(Context.PROVIDER_URL, url);      if (user != null) {        properties.put(Context.SECURITY_PRINCIPAL, user);        properties.put(Context.SECURITY_CREDENTIALS,                       password == null ? "" : password);      }      return new InitialContext(properties);    }    catch (Exception e) {      System.out.println("Unable to connect to WebLogic server at " + url);      System.out.println("Please make sure that the server is running.");      throw e;    }  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -