[jboss-cvs] JBossAS SVN: r65464 - in projects/ejb3/trunk/servicelocator: lib and 7 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Sep 19 01:06:36 EDT 2007


Author: ALRubinger
Date: 2007-09-19 01:06:35 -0400 (Wed, 19 Sep 2007)
New Revision: 65464

Added:
   projects/ejb3/trunk/servicelocator/.classpath
   projects/ejb3/trunk/servicelocator/.project
   projects/ejb3/trunk/servicelocator/lib/
   projects/ejb3/trunk/servicelocator/lib/commons-digester-1.8.jar
   projects/ejb3/trunk/servicelocator/lib/commons-logging-1.1.jar
   projects/ejb3/trunk/servicelocator/lib/commons-validator-1.3.1.jar
   projects/ejb3/trunk/servicelocator/src/
   projects/ejb3/trunk/servicelocator/src/legacy/
   projects/ejb3/trunk/servicelocator/src/legacy/JndiHost.java
   projects/ejb3/trunk/servicelocator/src/legacy/JndiHostNotBoundException.java
   projects/ejb3/trunk/servicelocator/src/legacy/ServiceContextProximityBindManagerOld.java
   projects/ejb3/trunk/servicelocator/src/legacy/ServiceHostProximityBinding.java
   projects/ejb3/trunk/servicelocator/src/legacy/ServiceLocatorOldImpl.java
   projects/ejb3/trunk/servicelocator/src/main/
   projects/ejb3/trunk/servicelocator/src/main/org/
   projects/ejb3/trunk/servicelocator/src/main/org/jboss/
   projects/ejb3/trunk/servicelocator/src/main/org/jboss/ejb3/
   projects/ejb3/trunk/servicelocator/src/main/org/jboss/ejb3/servicelocator/
   projects/ejb3/trunk/servicelocator/src/main/org/jboss/ejb3/servicelocator/CachingServiceLocator.java
   projects/ejb3/trunk/servicelocator/src/main/org/jboss/ejb3/servicelocator/Ejb3NotFoundException.java
   projects/ejb3/trunk/servicelocator/src/main/org/jboss/ejb3/servicelocator/JndiCachingServiceLocator.java
   projects/ejb3/trunk/servicelocator/src/main/org/jboss/ejb3/servicelocator/ServiceLocator.java
   projects/ejb3/trunk/servicelocator/src/main/org/jboss/ejb3/servicelocator/ServiceLocatorException.java
   projects/ejb3/trunk/servicelocator/src/test/
Log:
Initial Commit of ServiceLocator; contains no formal build, currently in migration from legacy personal code to rearchitected module for public use

Added: projects/ejb3/trunk/servicelocator/.classpath
===================================================================
--- projects/ejb3/trunk/servicelocator/.classpath	                        (rev 0)
+++ projects/ejb3/trunk/servicelocator/.classpath	2007-09-19 05:06:35 UTC (rev 65464)
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src/main"/>
+	<classpathentry kind="src" path="src/test"/>
+	<classpathentry kind="src" path="src/legacy"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="lib" path="lib/commons-logging-1.1.jar"/>
+	<classpathentry kind="lib" path="lib/commons-validator-1.3.1.jar"/>
+	<classpathentry kind="lib" path="lib/commons-digester-1.8.jar"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/ejb3"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>


Property changes on: projects/ejb3/trunk/servicelocator/.classpath
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: projects/ejb3/trunk/servicelocator/.project
===================================================================
--- projects/ejb3/trunk/servicelocator/.project	                        (rev 0)
+++ projects/ejb3/trunk/servicelocator/.project	2007-09-19 05:06:35 UTC (rev 65464)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>servicelocator</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>


Property changes on: projects/ejb3/trunk/servicelocator/.project
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: projects/ejb3/trunk/servicelocator/lib/commons-digester-1.8.jar
===================================================================
(Binary files differ)


Property changes on: projects/ejb3/trunk/servicelocator/lib/commons-digester-1.8.jar
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: projects/ejb3/trunk/servicelocator/lib/commons-logging-1.1.jar
===================================================================
(Binary files differ)


Property changes on: projects/ejb3/trunk/servicelocator/lib/commons-logging-1.1.jar
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: projects/ejb3/trunk/servicelocator/lib/commons-validator-1.3.1.jar
===================================================================
(Binary files differ)


Property changes on: projects/ejb3/trunk/servicelocator/lib/commons-validator-1.3.1.jar
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: projects/ejb3/trunk/servicelocator/src/legacy/JndiHost.java
===================================================================
--- projects/ejb3/trunk/servicelocator/src/legacy/JndiHost.java	                        (rev 0)
+++ projects/ejb3/trunk/servicelocator/src/legacy/JndiHost.java	2007-09-19 05:06:35 UTC (rev 65464)
@@ -0,0 +1,66 @@
+
+
+import java.io.Serializable;
+
+/**
+ * Represents a JNDI Host location on which remote and local services may be
+ * deployed.
+ * 
+ * @author ALR
+ */
+public class JndiHost implements Serializable
+{
+   // Class Members
+   private static final long serialVersionUID = 4367726854123681529L;
+
+   // Instance Members
+   private String id;
+
+   private String address;
+
+   private int port;
+
+   // Constructors
+   public JndiHost()
+   {
+   }
+
+   public JndiHost(String name, String address, int port)
+   {
+      this.setId(name);
+      this.setAddress(address);
+      this.setPort(port);
+   }
+
+   // Accessors/Mutators
+   public String getAddress()
+   {
+      return address;
+   }
+
+   public void setAddress(String address)
+   {
+      this.address = address;
+   }
+
+   public String getId()
+   {
+      return id;
+   }
+
+   public void setId(String id)
+   {
+      this.id = id;
+   }
+
+   public int getPort()
+   {
+      return port;
+   }
+
+   public void setPort(int port)
+   {
+      this.port = port;
+   }
+
+}


Property changes on: projects/ejb3/trunk/servicelocator/src/legacy/JndiHost.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: projects/ejb3/trunk/servicelocator/src/legacy/JndiHostNotBoundException.java
===================================================================
--- projects/ejb3/trunk/servicelocator/src/legacy/JndiHostNotBoundException.java	                        (rev 0)
+++ projects/ejb3/trunk/servicelocator/src/legacy/JndiHostNotBoundException.java	2007-09-19 05:06:35 UTC (rev 65464)
@@ -0,0 +1,22 @@
+
+public class JndiHostNotBoundException extends RuntimeException
+{
+   // Class Members
+   private static final long serialVersionUID = 4258388112362714557L;
+
+   // Constructors
+   public JndiHostNotBoundException(String arg0)
+   {
+      super(arg0);
+   }
+
+   public JndiHostNotBoundException(String arg0, Throwable arg1)
+   {
+      super(arg0, arg1);
+   }
+
+   public JndiHostNotBoundException(Throwable arg0)
+   {
+      super(arg0);
+   }
+}


Property changes on: projects/ejb3/trunk/servicelocator/src/legacy/JndiHostNotBoundException.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: projects/ejb3/trunk/servicelocator/src/legacy/ServiceContextProximityBindManagerOld.java
===================================================================
--- projects/ejb3/trunk/servicelocator/src/legacy/ServiceContextProximityBindManagerOld.java	                        (rev 0)
+++ projects/ejb3/trunk/servicelocator/src/legacy/ServiceContextProximityBindManagerOld.java	2007-09-19 05:06:35 UTC (rev 65464)
@@ -0,0 +1,544 @@
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Map;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.apache.commons.digester.Digester;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.commons.validator.GenericValidator;
+import org.jboss.ejb3.servicelocator.Ejb3NotFoundException;
+import org.jboss.ejb3.servicelocator.ServiceLocatorException;
+import org.xml.sax.SAXException;
+
+/**
+ * The Service Context Bind Manager maintains a list of services available to
+ * the client, as well as the JNP Host (and proximity of this host to the JVM)
+ * asssociated with each service. Service/Context/Proximity mappings are defined
+ * via external XML Configuration files (jnp_hosts.xml and
+ * service_host_proximity_bindings.xml) located (by default, when launched
+ * within the JBoss Application Server) in
+ * ${jboss.home}/server/${jboss.server.name}/conf, or, if specified, in the
+ * System Properties ninem.server.jnp-host-definitions.path &
+ * ninem.server.service-host-proximity-bindings-definitions.path
+ * 
+ * @author ALR
+ */
+public class ServiceContextProximityBindManagerOld
+{
+   // Class Members
+   private static final Log logger = LogFactory.getLog(ServiceContextProximityBindManagerOld.class);
+
+   private static final String DEFAULT_CONFIGURATION_LOCATION_IN_CONTAINER = System
+         .getProperty("jboss.server.config.url");
+
+   private static final boolean RUN_IN_CONTAINER = !GenericValidator
+         .isBlankOrNull(ServiceContextProximityBindManagerOld.DEFAULT_CONFIGURATION_LOCATION_IN_CONTAINER);
+
+   private static final String DEFAULT_JNP_HOST_DEFINITIONS_FILE_PATH = ServiceContextProximityBindManagerOld.DEFAULT_CONFIGURATION_LOCATION_IN_CONTAINER
+         + "jnp_hosts.xml";
+
+   private static final String DEFAULT_SERVICE_HOST_PROXIMITY_BINDINGS_DEFINITIONS_FILE_PATH = ServiceContextProximityBindManagerOld.DEFAULT_CONFIGURATION_LOCATION_IN_CONTAINER
+         + "service_host_proximity_bindings.xml";
+
+   private static final String SYSTEM_PROPERTY_KEY_JNP_HOST_DEFINITIONS_FILE_PATH = "jboss.server.jnp-host-definitions.path";
+
+   private static final String SYSTEM_PROPERTY_KEY_SERVICE_HOST_PROXIMITY_BINDINGS_DEFINITIONS_FILE_PATH = "jboss.server.service-host-proximity-bindings-definitions.path";
+
+   private static final String NAMING_CONTEXT_FACTORY_CLASSNAME = "org.jnp.interfaces.NamingContextFactory";
+
+   private static final String JNP_PROTOCOL = "jnp://";
+
+   private static final String KEY_NAMING_FACTORY_URL_PACKAGES = "java.naming.factory.url.pkgs";
+
+   private static final String VALUE_NAMING_FACTORY_URL_PACKAGES = "org.jboss.naming:org.jnp.interfaces";
+
+   private static final String FILE_URI_PREFIX = "file:/";
+
+   private static final Integer FILE_URI_PREFIX_LENGTH = ServiceContextProximityBindManagerOld.FILE_URI_PREFIX.length();
+
+   private static final String WINDOWS_SPACED_FILE_INDICATOR = " ";
+
+   private static final String DEFAULT_JNP_HOST_CANONICAL_NAME = "default";
+
+   // Instance Members
+   /**
+    * Mapping of JNP Host names to the InitialContext representing the JNP Host
+    */
+   private Map<String, InitialContext> contexts = new HashMap<String, InitialContext>();
+
+   /**
+    * Mapping of services to JNP Host names
+    */
+   private Map<String, String> serviceHosts = new HashMap<String, String>();
+
+   /**
+    * Mapping of services to JNDI Locations
+    */
+   private Map<String, String> jndiLocations = new HashMap<String, String>();
+
+   /**
+    * Singleton instance
+    */
+   private static ServiceContextProximityBindManagerOld serviceContextBinding = null;
+
+   // Constructors
+   private ServiceContextProximityBindManagerOld()
+   {
+      super();
+      this.loadServiceContextBindings();
+   }
+
+   // Singleton
+   public synchronized static ServiceContextProximityBindManagerOld getInstance()
+   {
+      if (serviceContextBinding == null)
+         serviceContextBinding = new ServiceContextProximityBindManagerOld();
+
+      return serviceContextBinding;
+   }
+
+   // Functional Methods
+
+   /**
+    * Returns the InitialContext for the JNP Host bound to the specified
+    * canonical name
+    * 
+    * @param hostCanocialName
+    * @return
+    */
+   public InitialContext getJnpHost(String hostCanocialName)
+   {
+      InitialContext context = null;
+      try
+      {
+         context = this.contexts.get(hostCanocialName);
+      }
+      catch (NullPointerException npe)
+      {
+         this.generateJnpHostNotBoundException(hostCanocialName);
+      }
+      return context;
+   }
+
+   /**
+    * Returns the InitialContext for the Default JNP Host
+    * 
+    * @return
+    */
+   public InitialContext getDefaultJnpHost()
+   {
+      return this.getJnpHost(this.getDefaultJnpHostBindName());
+   }
+
+   public String getDefaultJnpHostBindName()
+   {
+      return ServiceContextProximityBindManagerOld.DEFAULT_JNP_HOST_CANONICAL_NAME;
+   }
+
+   /**
+    * Returns the InitialContext for the proper JNP Host configured to be
+    * contacted for the specified service name
+    * 
+    * @param serviceName
+    * @return
+    */
+   public InitialContext getJnpHostForServiceName(String serviceName)
+   {
+      InitialContext context = null;
+      try
+      {
+         context = this.contexts.get(this.serviceHosts.get(serviceName));
+      }
+      catch (NullPointerException npe)
+      {
+         this.generateServiceNameNotBoundException(serviceName);
+      }
+      return context;
+   }
+
+   /**
+    * Returns the JNDI Location for the specified service name
+    * 
+    * @param serviceName
+    * @return
+    */
+   public String getJndiLocation(String serviceName)
+   {
+      String jndiLocation = this.jndiLocations.get(serviceName);
+      if (GenericValidator.isBlankOrNull(jndiLocation))
+      {
+         this.generateServiceNameNotBoundException(serviceName);
+      }
+      return jndiLocation;
+   }
+
+   /**
+    * Generates a JnpHostNotBoundException with message explaining that the
+    * specified JNP Host canonical name is not bound.
+    * 
+    * @param hostCanocialName
+    */
+   private void generateJnpHostNotBoundException(String hostCanocialName)
+   {
+      throw new ServiceLocatorException("JNP Host with canonical name \"" + hostCanocialName + "\" is not bound.");
+   }
+
+   /**
+    * Generates a ServiceNameNotBoundException with message explaining that the
+    * specified service name is not bound.
+    * 
+    * @param serviceName
+    */
+   private void generateServiceNameNotBoundException(String serviceName)
+   {
+      throw new Ejb3NotFoundException("Service name \"" + serviceName + "\" is not bound.");
+   }
+
+   /**
+    * Returns all bound service names
+    * 
+    * @return
+    */
+   public Collection<String> getBoundServiceNames()
+   {
+      // Return all bound service names
+      return this.jndiLocations.keySet();
+   }
+
+   /**
+    * Loads the JNP Host definitions as well as the named service/host bindings
+    * from the specified resources
+    */
+   @SuppressWarnings(value = "unchecked")
+   private void loadServiceContextBindings()
+   {
+      // Initialize
+      Digester jnpHostDefinitionsDigester = new Digester();
+      Digester serviceBindingsDigester = new Digester();
+      String jnpHostConfigurationLocation = null;
+      String serviceHostProximityBindingsConfigurationLocation = null;
+
+      // If run from container, set default configuration file paths
+      if (ServiceContextProximityBindManagerOld.RUN_IN_CONTAINER)
+      {
+         jnpHostConfigurationLocation = ServiceContextProximityBindManagerOld.DEFAULT_JNP_HOST_DEFINITIONS_FILE_PATH;
+         serviceHostProximityBindingsConfigurationLocation = ServiceContextProximityBindManagerOld.DEFAULT_SERVICE_HOST_PROXIMITY_BINDINGS_DEFINITIONS_FILE_PATH;
+      }
+
+      // If locations for configuration are overridden
+      if (!GenericValidator.isBlankOrNull(System
+            .getProperty(ServiceContextProximityBindManagerOld.SYSTEM_PROPERTY_KEY_JNP_HOST_DEFINITIONS_FILE_PATH)))
+      {
+         jnpHostConfigurationLocation = System
+               .getProperty(ServiceContextProximityBindManagerOld.SYSTEM_PROPERTY_KEY_JNP_HOST_DEFINITIONS_FILE_PATH);
+      }
+      if (!GenericValidator
+            .isBlankOrNull(System
+                  .getProperty(ServiceContextProximityBindManagerOld.SYSTEM_PROPERTY_KEY_SERVICE_HOST_PROXIMITY_BINDINGS_DEFINITIONS_FILE_PATH)))
+      {
+         serviceHostProximityBindingsConfigurationLocation = System
+               .getProperty(ServiceContextProximityBindManagerOld.SYSTEM_PROPERTY_KEY_SERVICE_HOST_PROXIMITY_BINDINGS_DEFINITIONS_FILE_PATH);
+      }
+
+      // If no configuration location is specified
+      if (GenericValidator.isBlankOrNull(jnpHostConfigurationLocation))
+      {
+         throw new RuntimeException("JNP Host Configuration URI is not defined in system variable "
+               + ServiceContextProximityBindManagerOld.SYSTEM_PROPERTY_KEY_JNP_HOST_DEFINITIONS_FILE_PATH);
+      }
+      if (GenericValidator.isBlankOrNull(serviceHostProximityBindingsConfigurationLocation))
+      {
+         throw new RuntimeException(
+               "Service/Host/Proximity Binding Configuration URI is not defined in system variable "
+                     + ServiceContextProximityBindManagerOld.SYSTEM_PROPERTY_KEY_SERVICE_HOST_PROXIMITY_BINDINGS_DEFINITIONS_FILE_PATH);
+      }
+
+      // Add Rules for parsing configuration
+      this.addJnpHostDefinitionsParsingRules(jnpHostDefinitionsDigester);
+      this.addServiceHostProximityBindingDefinitionsParsingRules(serviceBindingsDigester);
+
+      // Ensure appropriate URI path structure
+      jnpHostConfigurationLocation = jnpHostConfigurationLocation.replace(System.getProperty("file.separator")
+            .charAt(0), '/');
+      serviceHostProximityBindingsConfigurationLocation = serviceHostProximityBindingsConfigurationLocation.replace(
+            System.getProperty("file.separator").charAt(0), '/');
+
+      // Parse
+      try
+      {
+         InputStream jnpHostsStream = null;
+         // Check if this is a windows uri. Rule to determine right now is
+         // presence of space character in string.
+         if (jnpHostConfigurationLocation.contains(ServiceContextProximityBindManagerOld.WINDOWS_SPACED_FILE_INDICATOR))
+         {
+
+            // Windows URI, so transform into something we can use.
+            jnpHostConfigurationLocation = jnpHostConfigurationLocation.substring(FILE_URI_PREFIX_LENGTH);
+
+            jnpHostsStream = new FileInputStream(new File(jnpHostConfigurationLocation));
+         }
+         else
+         {
+
+            jnpHostsStream = new FileInputStream(new File(new URI(jnpHostConfigurationLocation)));
+         }
+
+         InputStream serviceContextBindingsStream = null;
+
+         // Same thing here as above...
+         if (serviceHostProximityBindingsConfigurationLocation
+               .contains(ServiceContextProximityBindManagerOld.WINDOWS_SPACED_FILE_INDICATOR))
+         {
+            serviceHostProximityBindingsConfigurationLocation = serviceHostProximityBindingsConfigurationLocation
+                  .substring(FILE_URI_PREFIX_LENGTH);
+
+            serviceContextBindingsStream = new FileInputStream(new File(
+                  serviceHostProximityBindingsConfigurationLocation));
+
+         }
+         else
+         {
+            serviceContextBindingsStream = new FileInputStream(new File(new URI(
+                  serviceHostProximityBindingsConfigurationLocation)));
+         }
+
+         // Create Initial Context object from each of the
+         // configured JNP Hosts
+         this.createInitialContexts((Collection<JndiHost>) jnpHostDefinitionsDigester.parse(jnpHostsStream));
+
+         // Create the default
+         this.createInitialContext(new JndiHost(ServiceContextProximityBindManagerOld.DEFAULT_JNP_HOST_CANONICAL_NAME,
+               null, 0));
+
+         // Parse Service/Host/Proximity Bindings
+         Collection<ServiceHostProximityBinding> serviceHostProximityBindings = (Collection<ServiceHostProximityBinding>) serviceBindingsDigester
+               .parse(serviceContextBindingsStream);
+         // Create Service-Context and Service-Proximity mappings
+         this.bindServices(serviceHostProximityBindings);
+      }
+      catch (IOException ioe)
+      {
+         throw new RuntimeException(ioe);
+      }
+      catch (SAXException saxe)
+      {
+         throw new RuntimeException(saxe);
+      }
+      catch (URISyntaxException urise)
+      {
+         throw new RuntimeException(urise);
+      }
+   }
+
+   /**
+    * Adds parsing rules for reading configuration specifying JNP Hosts
+    * 
+    * @param digester
+    */
+   private void addJnpHostDefinitionsParsingRules(Digester digester)
+   {
+      // When the root is encountered, create a List
+      // to hold the JNP Host Definitions
+      digester.addObjectCreate("jnp-hosts", ArrayList.class);
+
+      // When a new host definition is encountered,
+      // create a new JNP Host
+      digester.addObjectCreate("jnp-hosts/host", JndiHost.class);
+
+      // Set all properties (in this case, "name")
+      // from the "host" entry to the "JnpHost.name"
+      // object
+      digester.addSetProperties("jnp-hosts/host");
+
+      // Set the address
+      digester.addCallMethod("jnp-hosts/host/address", "setAddress", 1);
+      digester.addCallParam("jnp-hosts/host/address", 0);
+
+      // Set the port
+      digester.addCallMethod("jnp-hosts/host/port", "setPort", 1, new Class[]
+      {Integer.class});
+      digester.addCallParam("jnp-hosts/host/port", 0);
+
+      // Add the JNP Host to the List
+      digester.addSetNext("jnp-hosts/host", "add");
+
+   }
+
+   /**
+    * Adds parsing rules for reading configuration binding services to JNP
+    * Hosts
+    * 
+    * @param digester
+    */
+   private void addServiceHostProximityBindingDefinitionsParsingRules(Digester digester)
+   {
+      // When the root is encountered, create a List
+      // to hold the Service Definitions
+      digester.addObjectCreate("services", ArrayList.class);
+
+      // When a new service definition is encountered,
+      // create a new URI object to hold its data
+      digester.addObjectCreate("services/service", ServiceHostProximityBinding.class);
+
+      // Set all properties (in this case, "name")
+      // from the "service" entry to the "ServiceHostProximityBinding.name"
+      // object
+      digester.addSetProperties("services/service");
+
+      // Set the JNP Host
+      digester.addCallMethod("services/service/jnp-host", "setJnpHost", 1);
+      digester.addCallParam("services/service/jnp-host", 0);
+
+      // Set the JNDI Location
+      digester.addCallMethod("services/service/jndi-location", "setJndiLocation", 1);
+      digester.addCallParam("services/service/jndi-location", 0);
+
+      // Set the proximity
+      digester.addCallMethod("services/service/local-jvm", "setLocalToJvm", 1, new Class[]
+      {Boolean.class});
+      digester.addCallParam("services/service/local-jvm", 0);
+
+      // Add the Service to the List
+      digester.addSetNext("services/service", "add");
+
+   }
+
+   /**
+    * Creates and stores InitialContexts for each of the specified JNP Host
+    * configurations
+    * 
+    * @param jnpHosts
+    */
+   private void createInitialContexts(Collection<JndiHost> jnpHosts)
+   {
+      for (JndiHost jnpHost : jnpHosts)
+      {
+         this.createInitialContext(jnpHost);
+      }
+   }
+
+   /**
+    * Creates an InitialContext from the specified JNP Host and stores it for
+    * future use.
+    * 
+    * @param jnpHost
+    * @return
+    */
+   private void createInitialContext(JndiHost jnpHost)
+   {
+
+      // Initialize
+      InitialContext context = null;
+
+      // Assemble URI
+      String jnpProviderUrl = ServiceContextProximityBindManagerOld.JNP_PROTOCOL + jnpHost.getAddress() + ":"
+            + jnpHost.getPort();
+
+      // Create properties
+      Hashtable<String, String> properties = new Hashtable<String, String>();
+
+      // If no address is specified, use all defaults (no properties)
+      boolean useDefaults = false;
+      if (GenericValidator.isBlankOrNull(jnpHost.getAddress()))
+      {
+         useDefaults = true;
+      }
+
+      // Override defaults
+      if (!useDefaults)
+      {
+         properties.put(Context.INITIAL_CONTEXT_FACTORY,
+               ServiceContextProximityBindManagerOld.NAMING_CONTEXT_FACTORY_CLASSNAME);
+         properties.put(Context.PROVIDER_URL, jnpProviderUrl);
+         properties.put(ServiceContextProximityBindManagerOld.KEY_NAMING_FACTORY_URL_PACKAGES,
+               ServiceContextProximityBindManagerOld.VALUE_NAMING_FACTORY_URL_PACKAGES);
+      }
+
+      // Create the Initial Context
+      try
+      {
+         if (!useDefaults)
+         {
+            context = new InitialContext(properties);
+         }
+         else
+         {
+            context = new InitialContext();
+         }
+      }
+      catch (NamingException ne)
+      {
+         throw new RuntimeException(ne);
+      }
+
+      // Cache
+      contexts.put(jnpHost.getId(), context);
+
+      // Log
+      if (!useDefaults)
+      {
+         logger.info("Initial Context created for JNP Host " + jnpHost.getAddress() + ":" + jnpHost.getPort()
+               + " and bound to canonical name \"" + jnpHost.getId() + "\".");
+      }
+      else
+      {
+         logger.info("Default InitialContext Created and bound to canonical name \"" + jnpHost.getId() + "\".");
+      }
+
+   }
+
+   /**
+    * Binds all specified services to JNDI Locations, JNP Hosts, and
+    * Proximities
+    * 
+    * @param serviceContextBindings
+    */
+   private void bindServices(Collection<ServiceHostProximityBinding> serviceContextBindings)
+   {
+      for (ServiceHostProximityBinding serviceContextBinding : serviceContextBindings)
+      {
+         this.bindService(serviceContextBinding);
+      }
+   }
+
+   /**
+    * Binds the specified service to the specified JNDI Location, JNP Host, and
+    * Proximity
+    * 
+    * @param serviceContextBinding
+    */
+   private void bindService(ServiceHostProximityBinding serviceContextBinding)
+   {
+      // Ensure the service can be bound to an existant JNP Host canonical
+      // name
+      if (this.contexts.get(serviceContextBinding.host()) == null)
+      {
+         throw new JndiHostNotBoundException("Cannot bind service \"" + serviceContextBinding.getName()
+               + "\" to JNP canonical name \"" + serviceContextBinding.host()
+               + "\" as that JNP canonical name has not been registered.");
+      }
+
+      // Bind the Service to the JNP Host
+      this.serviceHosts.put(serviceContextBinding.getName(), serviceContextBinding.host());
+      logger.info("Service \"" + serviceContextBinding.getName() + "\" bound to JNP Host with canonical name \""
+            + serviceContextBinding.host() + "\".");
+
+      // Bind the Service to the JNDI Location Prefix
+      this.jndiLocations.put(serviceContextBinding.getName(), serviceContextBinding.getJndiLocation());
+      logger.info("Service \"" + serviceContextBinding.getName() + "\" bound to JNDI location \""
+            + serviceContextBinding.getJndiLocation() + "\".");
+   }
+}


Property changes on: projects/ejb3/trunk/servicelocator/src/legacy/ServiceContextProximityBindManagerOld.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: projects/ejb3/trunk/servicelocator/src/legacy/ServiceHostProximityBinding.java
===================================================================
--- projects/ejb3/trunk/servicelocator/src/legacy/ServiceHostProximityBinding.java	                        (rev 0)
+++ projects/ejb3/trunk/servicelocator/src/legacy/ServiceHostProximityBinding.java	2007-09-19 05:06:35 UTC (rev 65464)
@@ -0,0 +1,59 @@
+
+
+import java.io.Serializable;
+
+/**
+ * Represents a binding between a service name, its location in the JNDI tree
+ * and the JNP host serving the application
+ * 
+ * @author ALR
+ */
+public class ServiceHostProximityBinding implements Serializable {
+
+	// Class Members
+	private static final long serialVersionUID = 3251615680702644132L;
+
+	// Instance Members
+	private String name;
+
+	private String jndiLocation;
+
+	private String host;
+
+	// Constructors
+	public ServiceHostProximityBinding() {
+	}
+
+	public ServiceHostProximityBinding(String name, String jndiLocation,
+			String host, boolean localToJvm) {
+		this.setName(name);
+		this.setJnpHost(host);
+		this.setJndiLocation(jndiLocation);
+	}
+
+	// Accessors/Mutators
+	public String host() {
+		return host;
+	}
+
+	public void setJnpHost(String address) {
+		this.host = address;
+	}
+
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	public String getJndiLocation() {
+		return jndiLocation;
+	}
+
+	public void setJndiLocation(String jndiLocation) {
+		this.jndiLocation = jndiLocation;
+	}
+
+}


Property changes on: projects/ejb3/trunk/servicelocator/src/legacy/ServiceHostProximityBinding.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: projects/ejb3/trunk/servicelocator/src/legacy/ServiceLocatorOldImpl.java
===================================================================
--- projects/ejb3/trunk/servicelocator/src/legacy/ServiceLocatorOldImpl.java	                        (rev 0)
+++ projects/ejb3/trunk/servicelocator/src/legacy/ServiceLocatorOldImpl.java	2007-09-19 05:06:35 UTC (rev 65464)
@@ -0,0 +1,267 @@
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jboss.ejb3.servicelocator.Ejb3NotFoundException;
+import org.jboss.ejb3.servicelocator.ServiceLocatorException;
+
+/**
+ * ServiceLocator
+ * 
+ * 
+ * @version $Revision $
+ * @author <a href="mailto:alr at alrubinger.com">ALR</a>
+ */
+public class ServiceLocatorOldImpl
+{
+
+   // Class Members
+   private static final Log logger = LogFactory.getLog(ServiceLocatorOldImpl.class);
+
+   private static ServiceLocatorOldImpl serviceLocator = null;
+
+   // Instance Members
+
+   private Map<Class, List<Object>> jndiCache = null;
+
+   // Constructors
+   protected ServiceLocatorOldImpl()
+   {
+      super();
+   }
+
+   // Singleton Accessor
+   public static synchronized ServiceLocatorOldImpl getInstance()
+   {
+      if (ServiceLocatorOldImpl.serviceLocator == null)
+      {
+         ServiceLocatorOldImpl.serviceLocator = new ServiceLocatorOldImpl();
+      }
+
+      return ServiceLocatorOldImpl.serviceLocator;
+   }
+
+   // Functional Methods
+
+   /**
+    * Obtains the Object stored in the specified JNDI Address at the location
+    * bound to the specified JNP Host Canonical Name
+    * 
+    * @param jndiAddress
+    * @param jnpHostCanonicalName
+    * @return
+    */
+   public Object getObjectFromJnpHost(String jndiAddress, String jnpHostCanonicalName) throws ServiceLocatorException
+   {
+      // Initialize
+      jnpHostCanonicalName = jnpHostCanonicalName.trim().toLowerCase();
+
+      // Obtain InitialContext associated with JNP Host
+      logger.trace("Obtaining InitialContext for JNP Host Canonical Name '" + jnpHostCanonicalName + "'");
+      InitialContext context = ((InitialContext) ServiceContextProximityBindManagerOld.getInstance().getJnpHost(
+            jnpHostCanonicalName));
+
+      // Ensure the JNP Host was defined
+      if (context == null)
+         throw new RuntimeException("JNP Host with canonical name \"" + jnpHostCanonicalName
+               + "\" is not currently configured and cannot be obtained.");
+
+      try
+      {
+         // Lookup JNDI Location
+         return this.getObjectFromContext(jndiAddress, context);
+      }
+      catch (NamingException ne)
+      {
+         throw new ServiceLocatorException("Error encountered in lookup of JNDI Location '" + jndiAddress
+               + "' for host with canonical name '" + jnpHostCanonicalName + "'.", ne);
+      }
+   }
+
+   /**
+    * Obtains the Object stored in the specified JNDI Address at the specified
+    * Context
+    * 
+    * @param jndiAddress
+    * @param context
+    * @return
+    */
+   public Object getObjectFromContext(String jndiAddress, InitialContext context) throws NamingException
+   {
+      // Lookup JNDI Location
+      return context.lookup(jndiAddress);
+
+   }
+
+   /**
+    * Convenience method to obtain cached, bound object by interface. Should
+    * only be used to obtain cached references to Stateless EJB and JBoss JMX
+    * Service Beans, as each call to this method will return the same proxy
+    * object retrieved from JNDI. Stateful EJBs may NOT be looked up through
+    * here, as every call to this one cached object will execute within the
+    * same session.
+    * 
+    * @param <T>
+    * @param clazz
+    * @throws Ejb3NotFoundException
+    *             If more than one bound class implements the specified
+    *             interface
+    * @throws IllegalArgumentException
+    *             If no bound classes implement the specified interface
+    * @return
+    */
+   @SuppressWarnings(value = "unchecked")
+   public <T> T getBoundObjectForInterface(Class<T> clazz) throws Ejb3NotFoundException, IllegalArgumentException
+   {
+
+      // Ensure an interface
+      if (!clazz.isInterface())
+         throw new IllegalArgumentException("Specified class \"" + clazz.getName() + "\" is not an interface");
+
+      // Ensure cache is initialized
+      this.ensureCacheInitialzedWithInterface(clazz);
+
+      // Obtain all bound classes implementing this interface
+      List implementingObjects = this.jndiCache.get(clazz);
+
+      // Ensure a bound object implements the specified interface
+      if (implementingObjects == null || implementingObjects.size() == 0)
+      {
+         throw new Ejb3NotFoundException("No bound objects exist for specified interface : " + clazz.getName());
+      }
+
+      // Ensure there is only one bound object implementing this interface,
+      // otherwise it will have to be accessed with its bound service name
+      if (implementingObjects.size() > 1)
+      {
+         throw new IllegalArgumentException("More than one bound object implements the specified interface \""
+               + clazz.getName() + "\".  Must be accessed via " + this.getClass().getName() + ".getService(String).");
+      }
+
+      return (T) implementingObjects.get(0);
+
+   }
+
+   /**
+    * Initialized the interface/object cache if not already done
+    */
+   private synchronized <T> void ensureCacheInitialzedWithInterface(Class<T> clazz)
+   {
+      // Ensure Initialized
+      if (jndiCache == null)
+      {
+
+         this.jndiCache = new HashMap<Class, List<Object>>();
+      }
+
+      // Ensure in cache
+      if (this.jndiCache.get(clazz) == null)
+      {
+
+         // For each bound service name, obtain
+         for (String serviceName : ServiceContextProximityBindManagerOld.getInstance().getBoundServiceNames())
+         {
+            // Get object
+            Object obj = null;
+            try
+            {
+               obj = this.getService(serviceName);
+            }
+            // Error in finding service for this configurtion; note and
+            // continue
+            catch (ServiceLocatorException sle)
+            {
+               logger.warn("Service with canonical name " + serviceName
+                     + " could not be found or is not available at this time");
+               continue;
+            }
+
+            // Determine interfaces
+            for (Class interfaze : obj.getClass().getInterfaces())
+            {
+
+               // Bind all interfaces and their superclasses
+               this.addInterfaceAndSuperclassesToBoundObjectsCache(interfaze, obj);
+            }
+         }
+      }
+
+   }
+
+   /**
+    * Adds the specified class and all superclasses to the cache of bound
+    * objects
+    * 
+    * @param interfaze
+    * @param obj
+    */
+   private void addInterfaceAndSuperclassesToBoundObjectsCache(Class interfaze, Object obj)
+   {
+      // Ensure exists in the mapping
+      if (this.jndiCache.get(interfaze) == null)
+      {
+         this.jndiCache.put(interfaze, new ArrayList<Object>());
+      }
+
+      // Add the object to the list of objects implementing this
+      // interface
+      this.jndiCache.get(interfaze).add(obj);
+
+      // Add all superclasses
+      for (Class interfaze2 : interfaze.getInterfaces())
+      {
+         this.addInterfaceAndSuperclassesToBoundObjectsCache(interfaze2, obj);
+      }
+   }
+
+   /**
+    * Obtains the Object stored in the specified JNDI Address at the default
+    * JNP Host
+    * 
+    * @param jndiAddress
+    * @return
+    */
+   public Object getObjectFromDefaultJnpHost(String jndiAddress) throws ServiceLocatorException
+   {
+      try
+      {
+         return this.getObjectFromContext(jndiAddress, ServiceContextProximityBindManagerOld.getInstance()
+               .getDefaultJnpHost());
+      }
+      catch (NamingException ne)
+      {
+         throw new ServiceLocatorException("Error encountered in lookup of JNDI Location '" + jndiAddress
+               + "' for default JNP Host.", ne);
+      }
+   }
+
+   /**
+    * Obtains the stub to the service associated with the specified service
+    * name
+    * 
+    * @param context
+    * @param jndiBinding
+    * @return
+    */
+   public Object getService(String serviceName) throws ServiceLocatorException
+   {
+
+      logger.trace("Obtaining Service '" + serviceName + "'...");
+      try
+      {
+         return this.getObjectFromContext(ServiceContextProximityBindManagerOld.getInstance().getJndiLocation(
+               serviceName), ServiceContextProximityBindManagerOld.getInstance().getJnpHostForServiceName(serviceName));
+      }
+      catch (NamingException ne)
+      {
+         throw new ServiceLocatorException("Error encountered in lookup of service '" + serviceName + "'.", ne);
+      }
+   }
+}


Property changes on: projects/ejb3/trunk/servicelocator/src/legacy/ServiceLocatorOldImpl.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: projects/ejb3/trunk/servicelocator/src/main/org/jboss/ejb3/servicelocator/CachingServiceLocator.java
===================================================================
--- projects/ejb3/trunk/servicelocator/src/main/org/jboss/ejb3/servicelocator/CachingServiceLocator.java	                        (rev 0)
+++ projects/ejb3/trunk/servicelocator/src/main/org/jboss/ejb3/servicelocator/CachingServiceLocator.java	2007-09-19 05:06:35 UTC (rev 65464)
@@ -0,0 +1,267 @@
+package org.jboss.ejb3.servicelocator;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public abstract class CachingServiceLocator implements ServiceLocator
+{
+   // Class Members
+
+   private static final Log logger = LogFactory.getLog(CachingServiceLocator.class);
+
+   // Instance Members
+
+   /**
+    * Object cache used for storing stubs to remote services/beans, indexed by unique business interface
+    */
+   private Map<Class<?>, Object> objectCache = Collections.synchronizedMap(new HashMap<Class<?>, Object>());
+
+   // Required Implementations
+
+   /**
+    * Obtains a stub to the the SLSB service with the specified business 
+    * interface.  If this is the first request for this service, it will 
+    * be obtained from JNDI and placed in a cache such that subsequent 
+    * requests will not require the overhead of a JNDI lookup. 
+    * 
+    * @param <T>
+    * @param clazz The business interface of the desired service
+    * @return
+    * @throws Ejb3NotFoundException 
+    *   If no services implementing the specified business interface 
+    *   could be found on any of the configured local/remote hosts
+    * @throws IllegalArgumentException
+    *   If the specified class is a business interface implemented by more than 
+    *   one service across the configured local/remote hosts, or if the
+    *   specified class is no an interface 
+    */
+   public <T> T getStatelessService(Class<T> clazz) throws Ejb3NotFoundException, IllegalArgumentException
+   {
+      // Log
+      logger.trace("getStatelessService requesting " + clazz.getName());
+
+      // Obtain object, from cache if possible
+      return this.getObject(clazz, true);
+   }
+
+   /**
+    * Obtains a stub to the the SFSB with the specified business 
+    * interface.  This call will always result in a call to JNDI 
+    * for a new stub; no caching will take place
+    * 
+    * @param <T>
+    * @param clazz The business interface of the desired service
+    * @return
+    * @throws Ejb3NotFoundException 
+    *   If no services implementing the specified business interface 
+    *   could be found on any of the configured local/remote hosts
+    * @throws IllegalArgumentException
+    *   If the specified class is a business interface implemented by more than 
+    *   one service across the configured local/remote hosts, or if the
+    *   specified class is no an interface 
+    */
+   public <T> T getStatefulBean(Class<T> clazz) throws Ejb3NotFoundException, IllegalArgumentException
+   {
+      // Log
+      logger.trace("getStatefulBean requesting " + clazz.getName());
+
+      // Obtain object, never from cache (Stateful stubs must be unique)
+      return this.getObject(clazz, false);
+   }
+
+   /**
+    * Obtains a stub to the the JMX (MBean, Singleton) service with 
+    * the specified business interface.  If this is the first 
+    * request for this service, it will be obtained from JNDI and 
+    * placed in a cache such that subsequent requests will not 
+    * require the overhead of a JNDI lookup.  Convenience
+    * method; equivalent to <code>getStatelessService</code>
+    * 
+    * @param <T>
+    * @param clazz The business interface of the desired service
+    * @return
+    * @throws Ejb3NotFoundException 
+    *   If no services implementing the specified business interface 
+    *   could be found on any of the configured local/remote hosts
+    * @throws IllegalArgumentException
+    *   If the specified class is a business interface implemented by more than 
+    *   one service across the configured local/remote hosts, or if the
+    *   specified class is no an interface 
+    */
+   public <T> T getJmxService(Class<T> clazz) throws Ejb3NotFoundException, IllegalArgumentException
+   {
+      // Log
+      logger.trace("getJmxService requesting " + clazz.getName());
+
+      // Obtain object, from cache if possible
+      return this.getObject(clazz, true);
+   }
+
+   // Internal Methods
+
+   /**
+    * Obtains the object associated with the specified business interface.  
+    * This may be obtained from the cache if possible when the "useCache" 
+    * flag is set, otherwise caching will be bypassed and a unique lookup 
+    * will take place on each subsequent request.
+    * 
+    * @param <T>
+    * @param clazz The business interface of the desired service
+    * @param useCache Whether or not to retrieve the object from the cache, if possible.
+    * @return
+    * @throws Ejb3NotFoundException 
+    *   If no services implementing the specified business interface 
+    *   could be found on any of the configured local/remote hosts
+    * @throws IllegalArgumentException
+    *   If the specified class is a business interface implemented by more than 
+    *   one service across the configured local/remote hosts, or if the
+    *   specified class is no an interface 
+    */
+   protected <T> T getObject(Class<T> clazz, boolean useCache) throws Ejb3NotFoundException, IllegalArgumentException
+   {
+      // Ensure specified business interface is an interface
+      if (!clazz.isInterface())
+      {
+         throw new IllegalArgumentException("Specified class \"" + clazz.getName() + "\" is not an interface");
+      }
+
+      // If caching is enabled and the object exists in the cache
+      if (useCache && this.isObjectCached(clazz))
+      {
+         // Obtain from cache
+         T obj = this.getObjectFromCache(clazz);
+
+         // Ensure implements specified interface
+         if (!objectImplementsInterface(obj, clazz))
+         {
+            // Object was placed into cache under incorrect key; integrity of cache broken
+            throw new ServiceLocatorException("Object in cache under key " + clazz.getName()
+                  + " does not implement this interface; cache integrity compromised.");
+         }
+
+         // Return from cache
+         return obj;
+      }
+
+      // Obtain from the remote host
+      T obj = this.getObjectFromRemoteHost(clazz);
+
+      // If caching is enabled 
+      if (useCache)
+      {
+         // Place into the cache
+         this.addInterfaceAndSuperinterfacesToCache(clazz, obj);
+      }
+
+      // Return
+      return obj;
+
+   }
+
+   /**
+    * Determines whether an object with the specified business interface 
+    * is currently cached
+    * 
+    * @param clazz
+    * @return
+    */
+   private boolean isObjectCached(Class<?> clazz)
+   {
+      return this.objectCache.containsKey(clazz);
+   }
+
+   /**
+    * Obtains the specified object from the cache
+    * 
+    * @param <T>
+    * @param clazz
+    * @return
+    */
+   @SuppressWarnings(value = "unchecked")
+   private <T> T getObjectFromCache(Class<T> clazz)
+   {
+      // Obtain
+      T obj = (T) this.objectCache.get(clazz);
+
+      // Ensure present
+      if (obj == null)
+      {
+         throw new ServiceLocatorException("Call to retrieve object implementing " + clazz.getName()
+               + " from cache failed; object is not cached.");
+      }
+
+      // Return
+      return obj;
+   }
+
+   /**
+    * Returns whether the specified object implements the specified interface
+    * 
+    * @param obj
+    * @param interfaze
+    * @return
+    */
+   protected boolean objectImplementsInterface(Object obj, Class<?> interfaze)
+   {
+      // Loop through all implemented interfaces, looking for specified
+      for (Class<?> ifaze : obj.getClass().getInterfaces())
+      {
+         // Specified interface found
+         if (interfaze.equals(ifaze))
+         {
+            return true;
+         }
+      }
+
+      // Specified interface was not found
+      return false;
+   }
+
+   /**
+    * Adds the specified class and all superclasses to the cache of bound
+    * objects
+    * 
+    * @param interfaze
+    * @param obj
+    */
+   private <T> void addInterfaceAndSuperinterfacesToCache(Class<T> interfaze, T obj)
+   {
+      // Ensure not already cached, escape
+      if (!this.isObjectCached(interfaze))
+      {
+         // Add the object to the list of objects implementing this
+         // interface
+         this.objectCache.put(interfaze, obj);
+      }
+
+      // Add all super interfaces recursively
+      for (Class<T> superInterface : interfaze.getInterfaces())
+      {
+         this.addInterfaceAndSuperinterfacesToCache(superInterface, obj);
+      }
+   }
+
+   // Contracts
+
+   /**
+    * Obtains the object associated with the specified business interface 
+    * from one of the configured remote hosts.
+    * 
+    * @param <T>
+    * @param clazz The business interface of the desired service
+    * @return
+    * @throws Ejb3NotFoundException 
+    *   If no services implementing the specified business interface 
+    *   could be found on any of the configured local/remote hosts
+    * @throws IllegalArgumentException
+    *   If the specified class is a business interface implemented by more than 
+    *   one service across the configured local/remote hosts, or if the
+    *   specified class is no an interface 
+    */
+   public abstract <T> T getObjectFromRemoteHost(Class<T> clazz) throws Ejb3NotFoundException, IllegalArgumentException;
+
+}


Property changes on: projects/ejb3/trunk/servicelocator/src/main/org/jboss/ejb3/servicelocator/CachingServiceLocator.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: projects/ejb3/trunk/servicelocator/src/main/org/jboss/ejb3/servicelocator/Ejb3NotFoundException.java
===================================================================
--- projects/ejb3/trunk/servicelocator/src/main/org/jboss/ejb3/servicelocator/Ejb3NotFoundException.java	                        (rev 0)
+++ projects/ejb3/trunk/servicelocator/src/main/org/jboss/ejb3/servicelocator/Ejb3NotFoundException.java	2007-09-19 05:06:35 UTC (rev 65464)
@@ -0,0 +1,19 @@
+package org.jboss.ejb3.servicelocator;
+
+public class Ejb3NotFoundException extends RuntimeException {
+	// Class Members
+	private static final long serialVersionUID = 6533428942404073608L;
+
+	// Constructors
+	public Ejb3NotFoundException(String arg0) {
+		super(arg0);
+	}
+
+	public Ejb3NotFoundException(String arg0, Throwable arg1) {
+		super(arg0, arg1);
+	}
+
+	public Ejb3NotFoundException(Throwable arg0) {
+		super(arg0);
+	}
+}


Property changes on: projects/ejb3/trunk/servicelocator/src/main/org/jboss/ejb3/servicelocator/Ejb3NotFoundException.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: projects/ejb3/trunk/servicelocator/src/main/org/jboss/ejb3/servicelocator/JndiCachingServiceLocator.java
===================================================================
--- projects/ejb3/trunk/servicelocator/src/main/org/jboss/ejb3/servicelocator/JndiCachingServiceLocator.java	                        (rev 0)
+++ projects/ejb3/trunk/servicelocator/src/main/org/jboss/ejb3/servicelocator/JndiCachingServiceLocator.java	2007-09-19 05:06:35 UTC (rev 65464)
@@ -0,0 +1,36 @@
+package org.jboss.ejb3.servicelocator;
+
+/**
+ * JndiCachingServiceLocator
+ * 
+ * JNDI-based implementation of the Service Locator; will 
+ * attempt to obtain services from one of a set of configured 
+ * JNDI Directories (Hosts).
+ * 
+ * @version $Revision $
+ * @author <a href="mailto:alr at alrubinger.com">ALR</a>
+ */
+public class JndiCachingServiceLocator extends CachingServiceLocator
+{
+
+   /**
+    * Obtains the object associated with the specified business interface 
+    * from one of the configured remote hosts.
+    * 
+    * @param <T>
+    * @param clazz The business interface of the desired service
+    * @return
+    * @throws Ejb3NotFoundException 
+    *   If no services implementing the specified business interface 
+    *   could be found on any of the configured local/remote hosts
+    * @throws IllegalArgumentException
+    *   If the specified class is a business interface implemented by more than 
+    *   one service across the configured local/remote hosts, or if the
+    *   specified class is no an interface 
+    */
+   public <T> T getObjectFromRemoteHost(Class<T> clazz) throws Ejb3NotFoundException, IllegalArgumentException
+   {
+      throw new RuntimeException("IMPLEMENT");
+   }
+
+}


Property changes on: projects/ejb3/trunk/servicelocator/src/main/org/jboss/ejb3/servicelocator/JndiCachingServiceLocator.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: projects/ejb3/trunk/servicelocator/src/main/org/jboss/ejb3/servicelocator/ServiceLocator.java
===================================================================
--- projects/ejb3/trunk/servicelocator/src/main/org/jboss/ejb3/servicelocator/ServiceLocator.java	                        (rev 0)
+++ projects/ejb3/trunk/servicelocator/src/main/org/jboss/ejb3/servicelocator/ServiceLocator.java	2007-09-19 05:06:35 UTC (rev 65464)
@@ -0,0 +1,72 @@
+package org.jboss.ejb3.servicelocator;
+
+/**
+ * ServiceLocator
+ * 
+ * 
+ * 
+ * @version $Revision $
+ * @author <a href="mailto:alr at alrubinger.com">ALR</a>
+ */
+public interface ServiceLocator
+{
+
+   /**
+    * Obtains a stub to the the SLSB service with the specified business 
+    * interface.  If this is the first request for this service, it will 
+    * be obtained from JNDI and placed in a cache such that subsequent 
+    * requests will not require the overhead of a JNDI lookup. 
+    * 
+    * @param <T>
+    * @param clazz The business interface of the desired service
+    * @return
+    * @throws Ejb3NotFoundException 
+    *   If no services implementing the specified business interface 
+    *   could be found on any of the configured local/remote hosts
+    * @throws IllegalArgumentException
+    *   If the specified class is a business interface implemented by more than 
+    *   one service across the configured local/remote hosts, or if the
+    *   specified class is no an interface 
+    */
+   public <T> T getStatelessService(Class<T> clazz) throws Ejb3NotFoundException, IllegalArgumentException;
+
+   /**
+    * Obtains a stub to the the SFSB with the specified business 
+    * interface.  This call will always result in a call to JNDI 
+    * for a new stub; no caching will take place
+    * 
+    * @param <T>
+    * @param clazz The business interface of the desired service
+    * @return
+    * @throws Ejb3NotFoundException 
+    *   If no services implementing the specified business interface 
+    *   could be found on any of the configured local/remote hosts
+    * @throws IllegalArgumentException
+    *   If the specified class is a business interface implemented by more than 
+    *   one service across the configured local/remote hosts, or if the
+    *   specified class is no an interface 
+    */
+   public <T> T getStatefulBean(Class<T> clazz) throws Ejb3NotFoundException, IllegalArgumentException;
+
+   /**
+    * Obtains a stub to the the JMX (MBean, Singleton) service with 
+    * the specified business interface.  If this is the first 
+    * request for this service, it will be obtained from JNDI and 
+    * placed in a cache such that subsequent requests will not 
+    * require the overhead of a JNDI lookup.  Convenience
+    * method; equivalent to <code>getStatelessService</code>
+    * 
+    * @param <T>
+    * @param clazz The business interface of the desired service
+    * @return
+    * @throws Ejb3NotFoundException 
+    *   If no services implementing the specified business interface 
+    *   could be found on any of the configured local/remote hosts
+    * @throws IllegalArgumentException
+    *   If the specified class is a business interface implemented by more than 
+    *   one service across the configured local/remote hosts, or if the
+    *   specified class is no an interface 
+    */
+   public <T> T getJmxService(Class<T> clazz) throws Ejb3NotFoundException, IllegalArgumentException;
+
+}


Property changes on: projects/ejb3/trunk/servicelocator/src/main/org/jboss/ejb3/servicelocator/ServiceLocator.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: projects/ejb3/trunk/servicelocator/src/main/org/jboss/ejb3/servicelocator/ServiceLocatorException.java
===================================================================
--- projects/ejb3/trunk/servicelocator/src/main/org/jboss/ejb3/servicelocator/ServiceLocatorException.java	                        (rev 0)
+++ projects/ejb3/trunk/servicelocator/src/main/org/jboss/ejb3/servicelocator/ServiceLocatorException.java	2007-09-19 05:06:35 UTC (rev 65464)
@@ -0,0 +1,20 @@
+package org.jboss.ejb3.servicelocator;
+
+public class ServiceLocatorException extends RuntimeException {
+
+	// Class Members
+	private static final long serialVersionUID = -8470028232704428218L;
+
+	// Constructors
+	public ServiceLocatorException(String arg0) {
+		super(arg0);
+	}
+
+	public ServiceLocatorException(String arg0, Throwable arg1) {
+		super(arg0, arg1);
+	}
+
+	public ServiceLocatorException(Throwable arg0) {
+		super(arg0);
+	}
+}


Property changes on: projects/ejb3/trunk/servicelocator/src/main/org/jboss/ejb3/servicelocator/ServiceLocatorException.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain




More information about the jboss-cvs-commits mailing list