| Method from org.jboss.blocks.ejb.EJBHomeFactory Detail: |
public EJBHome create(String name) throws NamingException {
if (prefix != null) name = prefix + name;
EJBHome home = (EJBHome)cache.get(name);
// if the home object is not in cache, then look it up
if (home == null) {
home = lookupHome(name);
// add the home object to the cache
cache.put(name, home);
}
return home;
}
Lookup an EJBHome object and return it.
Returns a cached copy of the home object if there is one,
else a new home object will be looked up from JNDI and added
to the cache. |
public EJBHome create(Class type) throws NamingException {
return create(type.getName(), type);
}
Lookup an EJBHome object and return it. |
public EJBHome create(String name,
Class type) throws NamingException {
// lookup the home object and narrow the interface
EJBHome home = create(name);
return (EJBHome)PortableRemoteObject.narrow(home, type);
}
|
protected InitialContext createInitialContext() throws NamingException {
if (environment != null) {
return new InitialContext(environment);
}
else {
return new InitialContext();
}
}
Create a new InitialContext object for JNDI lookups. |
public static synchronized EJBHomeFactory getInstance() {
if (instance == null) {
instance = makeSynchronized(new EJBHomeFactory());
}
return instance;
}
Returns the global instance of the EJBHome factory.
The instance will be lazily initialized on the first invocation.
Since many different threads may be accessing this object at same
time, a synchronized factory is created. |
public String getPrefix() {
return prefix;
}
Return the JNDI prefix, or null if not used. |
public void invalidate() {
cache.clear();
}
Invalidate all cached home refernces. |
public void invalidate(String name) {
if (prefix != null) name = prefix + name;
cache.remove(name);
}
Invalidate the cached home for the given name, if there is one. |
public void invalidate(Class type) {
invalidate(type.getName());
}
Invalidate the cached home for the given name, if there is one. |
protected EJBHome lookupHome(String name) throws NamingException {
InitialContext ctx = createInitialContext();
try {
return (EJBHome)ctx.lookup(name);
}
finally {
ctx.close();
}
}
Lookup an EJBHome object from JNDI. |
public static EJBHomeFactory makeSynchronized(EJBHomeFactory aFactory) {
return new EJBHomeFactory()
{
private final EJBHomeFactory factory = aFactory;
public synchronized String getPrefix()
{
return factory.getPrefix();
}
public synchronized EJBHome create(final String name)
throws NamingException
{
return factory.create(name);
}
public synchronized EJBHome create(final String name, final Class type)
throws NamingException
{
return factory.create(name, type);
}
public synchronized EJBHome create(final Class type)
throws NamingException
{
return factory.create(type);
}
public synchronized void invalidate(final String name)
{
factory.invalidate(name);
}
public synchronized void invalidate(final Class type)
{
factory.invalidate(type);
}
public synchronized void invalidate()
{
factory.invalidate();
}
};
}
Make a synchronized EJBHomeFactory. |