org.jboss.txbridge.ba.execute
Class ServiceLocator

java.lang.Object
  extended by org.jboss.txbridge.ba.execute.ServiceLocator

public class ServiceLocator
extends java.lang.Object

The Service Locator component is responsible for locating EJBs. It uses a caching mechanism so that if an EJB has been previously searched for a cached reference can be returned. Based on: http://java.sun.com/blueprints/patterns/ServiceLocator.html

Version:
0.1
Author:
Maciej P. Machulak (mmachulak@redhat.com)

Field Summary
private  java.util.concurrent.ConcurrentMap<java.lang.String,java.lang.Object> beanCache
           
private  javax.naming.InitialContext initialContext
           
private static ServiceLocator localServiceLocator
           
private static org.apache.log4j.Logger log
           
private static java.util.concurrent.ConcurrentMap<java.lang.String,ServiceLocator> serviceLocators
           
 
Constructor Summary
private ServiceLocator()
          Constructor
private ServiceLocator(java.lang.String providerURL)
          Constructor
 
Method Summary
static ServiceLocator getInstance(java.lang.String providerURL)
          Returns the instance of the Service Locator object.
 java.lang.Object getInterface(java.lang.String jndiName, java.lang.Class interfaceName)
          This method returns a reference to the interface of an EJB.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static org.apache.log4j.Logger log

initialContext

private javax.naming.InitialContext initialContext

beanCache

private java.util.concurrent.ConcurrentMap<java.lang.String,java.lang.Object> beanCache

localServiceLocator

private static ServiceLocator localServiceLocator

serviceLocators

private static java.util.concurrent.ConcurrentMap<java.lang.String,ServiceLocator> serviceLocators
Constructor Detail

ServiceLocator

private ServiceLocator()
                throws javax.naming.NamingException
Constructor

Throws:
javax.naming.NamingException - if there was a naming error.

ServiceLocator

private ServiceLocator(java.lang.String providerURL)
                throws javax.naming.NamingException
Constructor

Parameters:
providerURL - is the URL of the provider.
Throws:
javax.naming.NamingException - if there was a naming error.
Method Detail

getInstance

public static ServiceLocator getInstance(java.lang.String providerURL)
                                  throws ServiceLocatorException
Returns the instance of the Service Locator object.

Parameters:
providerURL - is the Provider URL
Returns:
the instance of the Service Locator object.
Throws:
ServiceLocatorException - if it was not possible to create the service locator.

getInterface

public java.lang.Object getInterface(java.lang.String jndiName,
                                     java.lang.Class interfaceName)
                              throws ServiceLocatorException
This method returns a reference to the interface of an EJB.

Parameters:
jndiName - is the name of the bean.
interfaceName - is the class of the remote interface.
Returns:
an object representing an interface of a bean.
Throws:
ServiceLocatorException - if there was an error with the lookup.