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

📄 ejbhomefactory.java

📁 一个netstore的完整代码,他使用了j2ee和webservice技术,并使用ojb o/r管理框架,很不错的
💻 JAVA
字号:
package netstore.service.ejb;

import java.io.InputStream;
import java.io.IOException;
import java.util.*;
import javax.ejb.*;
import javax.naming.*;
import javax.rmi.PortableRemoteObject;

/**
 * This class implements the EJBHomeFactory pattern. It performs JNDI
 * lookups to locate EJB homes and caches the results for subsequent calls.
 */
public class EJBHomeFactory {
  private Map homes;
  private static EJBHomeFactory singleton;
  private InitialContext ctx;

   private EJBHomeFactory(  ) throws NamingException {
    homes = Collections.synchronizedMap(new HashMap(  ));
    ctx = new InitialContext();
  }


  /**
   * Get the Singleton instance of the class.
   */
  public static EJBHomeFactory getInstance(  ) throws NamingException {
    if (singleton == null) {
      singleton = new EJBHomeFactory(  );
    }
    return singleton;
  }

  /**
   * Specify the JNDI name and class for the desired home interface.
   */
  public EJBHome lookupHome(String jndiName, Class homeClass)
   throws NamingException {
    EJBHome home = (EJBHome)homes.get(homeClass);
    if (home == null) {
      home = (EJBHome)PortableRemoteObject.narrow(ctx.lookup(
        jndiName), homeClass);
      // Cache the home for repeated use
      homes.put(homeClass, home);
    }
    return home;
  }
}

⌨️ 快捷键说明

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