[jboss-cvs] JBossAS SVN: r65675 - in projects/ejb3/trunk/locator: src/legacy and 6 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Sep 28 00:40:46 EDT 2007


Author: ALRubinger
Date: 2007-09-28 00:40:46 -0400 (Fri, 28 Sep 2007)
New Revision: 65675

Added:
   projects/ejb3/trunk/locator/src/legacy/java/
   projects/ejb3/trunk/locator/src/legacy/java/JndiHostNotBoundException.java
   projects/ejb3/trunk/locator/src/legacy/java/ServiceContextProximityBindManagerOld.java
   projects/ejb3/trunk/locator/src/legacy/java/ServiceHostProximityBinding.java
   projects/ejb3/trunk/locator/src/legacy/java/ServiceLocatorOldImpl.java
   projects/ejb3/trunk/locator/src/main/java/
   projects/ejb3/trunk/locator/src/main/java/org/
   projects/ejb3/trunk/locator/src/test/java/
   projects/ejb3/trunk/locator/src/test/java/org/
   projects/ejb3/trunk/locator/src/test/java/org/jboss/ejb3/test/locator/client/jndihostequality/JndiHostEqualityTestCase.java
Removed:
   projects/ejb3/trunk/locator/src/legacy/JndiHostNotBoundException.java
   projects/ejb3/trunk/locator/src/legacy/ServiceContextProximityBindManagerOld.java
   projects/ejb3/trunk/locator/src/legacy/ServiceHostProximityBinding.java
   projects/ejb3/trunk/locator/src/legacy/ServiceLocatorOldImpl.java
   projects/ejb3/trunk/locator/src/main/org/
   projects/ejb3/trunk/locator/src/test/org/
Modified:
   projects/ejb3/trunk/locator/.classpath
   projects/ejb3/trunk/locator/pom.xml
Log:
Further Mavenization

Modified: projects/ejb3/trunk/locator/.classpath
===================================================================
--- projects/ejb3/trunk/locator/.classpath	2007-09-28 04:15:29 UTC (rev 65674)
+++ projects/ejb3/trunk/locator/.classpath	2007-09-28 04:40:46 UTC (rev 65675)
@@ -1,8 +1,7 @@
 <?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="src" path="src/main/java"/>
+	<classpathentry kind="src" path="src/test/java"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
 	<classpathentry kind="output" path="bin"/>
 </classpath>

Modified: projects/ejb3/trunk/locator/pom.xml
===================================================================
--- projects/ejb3/trunk/locator/pom.xml	2007-09-28 04:15:29 UTC (rev 65674)
+++ projects/ejb3/trunk/locator/pom.xml	2007-09-28 04:40:46 UTC (rev 65675)
@@ -29,6 +29,11 @@
 			<artifactId>commons-digester</artifactId>
 			<version>1.8</version>
 		</dependency>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<scope>test</scope>
+		</dependency>
 	</dependencies>
 </project>
 

Deleted: projects/ejb3/trunk/locator/src/legacy/JndiHostNotBoundException.java
===================================================================
--- projects/ejb3/trunk/locator/src/legacy/JndiHostNotBoundException.java	2007-09-28 04:15:29 UTC (rev 65674)
+++ projects/ejb3/trunk/locator/src/legacy/JndiHostNotBoundException.java	2007-09-28 04:40:46 UTC (rev 65675)
@@ -1,22 +0,0 @@
-
-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);
-   }
-}

Deleted: projects/ejb3/trunk/locator/src/legacy/ServiceContextProximityBindManagerOld.java
===================================================================
--- projects/ejb3/trunk/locator/src/legacy/ServiceContextProximityBindManagerOld.java	2007-09-28 04:15:29 UTC (rev 65674)
+++ projects/ejb3/trunk/locator/src/legacy/ServiceContextProximityBindManagerOld.java	2007-09-28 04:40:46 UTC (rev 65675)
@@ -1,545 +0,0 @@
-
-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.locator.client.Ejb3NotFoundException;
-import org.jboss.ejb3.locator.client.JndiHost;
-import org.jboss.ejb3.locator.client.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() + "\".");
-   }
-}

Deleted: projects/ejb3/trunk/locator/src/legacy/ServiceHostProximityBinding.java
===================================================================
--- projects/ejb3/trunk/locator/src/legacy/ServiceHostProximityBinding.java	2007-09-28 04:15:29 UTC (rev 65674)
+++ projects/ejb3/trunk/locator/src/legacy/ServiceHostProximityBinding.java	2007-09-28 04:40:46 UTC (rev 65675)
@@ -1,59 +0,0 @@
-
-
-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;
-	}
-
-}

Deleted: projects/ejb3/trunk/locator/src/legacy/ServiceLocatorOldImpl.java
===================================================================
--- projects/ejb3/trunk/locator/src/legacy/ServiceLocatorOldImpl.java	2007-09-28 04:15:29 UTC (rev 65674)
+++ projects/ejb3/trunk/locator/src/legacy/ServiceLocatorOldImpl.java	2007-09-28 04:40:46 UTC (rev 65675)
@@ -1,267 +0,0 @@
-
-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.locator.client.Ejb3NotFoundException;
-import org.jboss.ejb3.locator.client.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);
-      }
-   }
-}

Copied: projects/ejb3/trunk/locator/src/legacy/java/JndiHostNotBoundException.java (from rev 65640, projects/ejb3/trunk/locator/src/legacy/JndiHostNotBoundException.java)
===================================================================
--- projects/ejb3/trunk/locator/src/legacy/java/JndiHostNotBoundException.java	                        (rev 0)
+++ projects/ejb3/trunk/locator/src/legacy/java/JndiHostNotBoundException.java	2007-09-28 04:40:46 UTC (rev 65675)
@@ -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/locator/src/legacy/java/JndiHostNotBoundException.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Copied: projects/ejb3/trunk/locator/src/legacy/java/ServiceContextProximityBindManagerOld.java (from rev 65640, projects/ejb3/trunk/locator/src/legacy/ServiceContextProximityBindManagerOld.java)
===================================================================
--- projects/ejb3/trunk/locator/src/legacy/java/ServiceContextProximityBindManagerOld.java	                        (rev 0)
+++ projects/ejb3/trunk/locator/src/legacy/java/ServiceContextProximityBindManagerOld.java	2007-09-28 04:40:46 UTC (rev 65675)
@@ -0,0 +1,545 @@
+
+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.locator.client.Ejb3NotFoundException;
+import org.jboss.ejb3.locator.client.JndiHost;
+import org.jboss.ejb3.locator.client.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/locator/src/legacy/java/ServiceContextProximityBindManagerOld.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Copied: projects/ejb3/trunk/locator/src/legacy/java/ServiceHostProximityBinding.java (from rev 65640, projects/ejb3/trunk/locator/src/legacy/ServiceHostProximityBinding.java)
===================================================================
--- projects/ejb3/trunk/locator/src/legacy/java/ServiceHostProximityBinding.java	                        (rev 0)
+++ projects/ejb3/trunk/locator/src/legacy/java/ServiceHostProximityBinding.java	2007-09-28 04:40:46 UTC (rev 65675)
@@ -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/locator/src/legacy/java/ServiceHostProximityBinding.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Copied: projects/ejb3/trunk/locator/src/legacy/java/ServiceLocatorOldImpl.java (from rev 65640, projects/ejb3/trunk/locator/src/legacy/ServiceLocatorOldImpl.java)
===================================================================
--- projects/ejb3/trunk/locator/src/legacy/java/ServiceLocatorOldImpl.java	                        (rev 0)
+++ projects/ejb3/trunk/locator/src/legacy/java/ServiceLocatorOldImpl.java	2007-09-28 04:40:46 UTC (rev 65675)
@@ -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.locator.client.Ejb3NotFoundException;
+import org.jboss.ejb3.locator.client.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/locator/src/legacy/java/ServiceLocatorOldImpl.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Copied: projects/ejb3/trunk/locator/src/main/java/org (from rev 65640, projects/ejb3/trunk/locator/src/main/org)

Copied: projects/ejb3/trunk/locator/src/test/java/org (from rev 65640, projects/ejb3/trunk/locator/src/test/org)

Added: projects/ejb3/trunk/locator/src/test/java/org/jboss/ejb3/test/locator/client/jndihostequality/JndiHostEqualityTestCase.java
===================================================================
--- projects/ejb3/trunk/locator/src/test/java/org/jboss/ejb3/test/locator/client/jndihostequality/JndiHostEqualityTestCase.java	                        (rev 0)
+++ projects/ejb3/trunk/locator/src/test/java/org/jboss/ejb3/test/locator/client/jndihostequality/JndiHostEqualityTestCase.java	2007-09-28 04:40:46 UTC (rev 65675)
@@ -0,0 +1,71 @@
+/*
+ * JBoss, the OpenSource J2EE webOS
+ * 
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.ejb3.test.locator.client.jndihostequality;
+
+import junit.framework.TestCase;
+
+import org.jboss.ejb3.locator.client.JndiHost;
+
+public class JndiHostEqualityTestCase extends TestCase
+{
+   // Overridden Implementations
+   /**
+    * Setup
+    */
+   @Override
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+   }
+
+   // Test Methods
+   public void testEqualByValue()
+   {
+      // Obtain 2 objects of different references, same value
+      JndiHost jndi1 = this.getJndiHost1();
+      JndiHost jndi2 = this.getJndiHost1();
+      // Ensure equal by value
+      TestCase.assertTrue(jndi1.equals(jndi2));
+      // Ensure hashCodes equal
+      TestCase.assertTrue(new Integer(jndi1.hashCode()).equals(jndi2.hashCode()));
+   }
+
+   public void testNotEqualByValue()
+   {
+      // Obtain 2 objects of different values
+      JndiHost jndi1 = this.getJndiHost1();
+      JndiHost jndi2 = this.getJndiHost2();
+      TestCase.assertFalse(jndi1.equals(jndi2));
+   }
+
+   // Internal Helper Methods
+   private JndiHost getJndiHost1()
+   {
+      // Initialize
+      JndiHost host = new JndiHost();
+
+      // Set Properties
+      host.setAddress("localhost");
+      host.setPort(1098);
+
+      // Return
+      return host;
+   }
+
+   private JndiHost getJndiHost2()
+   {
+      // Initialize
+      JndiHost host = new JndiHost();
+
+      // Set Properties
+      host.setAddress("localhost");
+      host.setPort(1198);
+
+      // Return
+      return host;
+   }
+}


Property changes on: projects/ejb3/trunk/locator/src/test/java/org/jboss/ejb3/test/locator/client/jndihostequality/JndiHostEqualityTestCase.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain




More information about the jboss-cvs-commits mailing list