[jboss-cvs] JBossAS SVN: r68724 - projects/ejb3/trunk/locator/src/main/java/org/jboss/ejb3/locator/client.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Jan 9 02:52:06 EST 2008
Author: ALRubinger
Date: 2008-01-09 02:52:06 -0500 (Wed, 09 Jan 2008)
New Revision: 68724
Added:
projects/ejb3/trunk/locator/src/main/java/org/jboss/ejb3/locator/client/ServiceLocator.java
Modified:
projects/ejb3/trunk/locator/src/main/java/org/jboss/ejb3/locator/client/Ejb3ServiceLocator.java
projects/ejb3/trunk/locator/src/main/java/org/jboss/ejb3/locator/client/Ejb3ServiceLocatorImpl.java
projects/ejb3/trunk/locator/src/main/java/org/jboss/ejb3/locator/client/ServiceLocatorFactory.java
Log:
Minor refactoring, commiting before local deletion
Modified: projects/ejb3/trunk/locator/src/main/java/org/jboss/ejb3/locator/client/Ejb3ServiceLocator.java
===================================================================
--- projects/ejb3/trunk/locator/src/main/java/org/jboss/ejb3/locator/client/Ejb3ServiceLocator.java 2008-01-09 07:51:12 UTC (rev 68723)
+++ projects/ejb3/trunk/locator/src/main/java/org/jboss/ejb3/locator/client/Ejb3ServiceLocator.java 2008-01-09 07:52:06 UTC (rev 68724)
@@ -28,7 +28,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-public abstract class Ejb3ServiceLocator implements JndiServiceLocator
+public abstract class Ejb3ServiceLocator implements ServiceLocator
{
// Class Members
@@ -60,7 +60,7 @@
* 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
+ public <T> T getStatelessBean(Class<T> clazz) throws Ejb3NotFoundException, IllegalArgumentException
{
// Log
logger.trace("getStatelessService requesting " + clazz.getName());
Modified: projects/ejb3/trunk/locator/src/main/java/org/jboss/ejb3/locator/client/Ejb3ServiceLocatorImpl.java
===================================================================
--- projects/ejb3/trunk/locator/src/main/java/org/jboss/ejb3/locator/client/Ejb3ServiceLocatorImpl.java 2008-01-09 07:51:12 UTC (rev 68723)
+++ projects/ejb3/trunk/locator/src/main/java/org/jboss/ejb3/locator/client/Ejb3ServiceLocatorImpl.java 2008-01-09 07:52:06 UTC (rev 68724)
@@ -308,7 +308,7 @@
{
Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
- props.put(Context.URL_PKG_PREFIXES, "org.jboss.naming");
+ props.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
return props;
}
@@ -336,6 +336,7 @@
/**
*
*/
+ @SuppressWarnings("unchecked")
private <T> T getObject(JndiHost host, Class<T> clazz) throws Ejb3NotFoundException
{
// Determine JNDI Host providing type
Added: projects/ejb3/trunk/locator/src/main/java/org/jboss/ejb3/locator/client/ServiceLocator.java
===================================================================
--- projects/ejb3/trunk/locator/src/main/java/org/jboss/ejb3/locator/client/ServiceLocator.java (rev 0)
+++ projects/ejb3/trunk/locator/src/main/java/org/jboss/ejb3/locator/client/ServiceLocator.java 2008-01-09 07:52:06 UTC (rev 68724)
@@ -0,0 +1,106 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.locator.client;
+
+import javax.naming.NameNotFoundException;
+
+/**
+ * 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 getStatelessBean(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>getStatelessBean</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;
+
+
+ /**
+ * Fetches the object bound at the specified JNDI Address
+ * from the JNDI Host with the specified ID
+ *
+ * @param hostId
+ * @param jndiName
+ * @return
+ * @throws NameNotFoundException If the specified JNDI Address is
+ * not a valid binding for the specified host
+ */
+ public Object getObject(String hostId,String jndiName) throws NameNotFoundException;
+
+}
Property changes on: projects/ejb3/trunk/locator/src/main/java/org/jboss/ejb3/locator/client/ServiceLocator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: projects/ejb3/trunk/locator/src/main/java/org/jboss/ejb3/locator/client/ServiceLocatorFactory.java
===================================================================
--- projects/ejb3/trunk/locator/src/main/java/org/jboss/ejb3/locator/client/ServiceLocatorFactory.java 2008-01-09 07:51:12 UTC (rev 68723)
+++ projects/ejb3/trunk/locator/src/main/java/org/jboss/ejb3/locator/client/ServiceLocatorFactory.java 2008-01-09 07:52:06 UTC (rev 68724)
@@ -28,14 +28,16 @@
import java.net.URI;
import java.net.URISyntaxException;
+import org.apache.commons.validator.GenericValidator;
+
public class ServiceLocatorFactory
{
// Class Members
- private static JndiServiceLocator serviceLocator = null;
-
+ private static ServiceLocator serviceLocator = null;
+
private static final String CONFIGURATION_FILE_USER_OVERRIDE_FILENAME_SYSTEM_PROPERTY_KEY = "jboss.servicelocator.location";
-
+
private static final String CONFIGURATION_FILE_USER_OVERRIDE_JAR_SYSTEM_PROPERTY_KEY = "jboss.servicelocator.classloader";
private static final String CONFIGURATION_FILE_DEFAULT_FILENAME = "jboss-servicelocator.xml";
@@ -75,11 +77,48 @@
// Not found as default in-container file, attempt for default in-JAR file
configuration = Thread.currentThread().getContextClassLoader().getResourceAsStream(
ServiceLocatorFactory.CONFIGURATION_FILE_DEFAULT_OUTCONTAINER_LOCATION);
-
- // If default in-JAR file is not found
- if(configuration==null)
+
+ // If default in-JAR file is not found
+ if (configuration == null)
{
- //TODO
+ // Obtain in-JAR filename override
+ String inJarFileNameOverride = System
+ .getProperty(ServiceLocatorFactory.CONFIGURATION_FILE_USER_OVERRIDE_JAR_SYSTEM_PROPERTY_KEY);
+
+ // If In-JAR Filename override is specified
+ if (!GenericValidator.isBlankOrNull(inJarFileNameOverride))
+ {
+ // Obtain configuration
+ configuration = Thread.currentThread().getContextClassLoader().getResourceAsStream(inJarFileNameOverride);
+
+ // If configuration is not found
+ if (configuration == null)
+ {
+ throw new ServiceLocatorException(
+ "Could not find configuration file in JAR as specified in in user override at \""
+ + inJarFileNameOverride + "\"");
+ }
+ }
+
+ // Obtain file system filename override
+ String fileSystemFileNameOverride = System
+ .getProperty(ServiceLocatorFactory.CONFIGURATION_FILE_USER_OVERRIDE_FILENAME_SYSTEM_PROPERTY_KEY);
+
+ // If filesystem override is specified
+ if (!GenericValidator.isBlankOrNull(fileSystemFileNameOverride))
+ {
+ // Obtain configuration
+ configuration = Thread.currentThread().getContextClassLoader().getResourceAsStream(
+ fileSystemFileNameOverride);
+
+ // If configuration is not found
+ if (configuration == null)
+ {
+ throw new ServiceLocatorException(
+ "Could not find configuration file in filesystem specified in user override at \""
+ + fileSystemFileNameOverride + "\"");
+ }
+ }
}
// Parse
@@ -92,7 +131,7 @@
*
* @return
*/
- public JndiServiceLocator getServiceLocator()
+ public ServiceLocator getServiceLocator()
{
return ServiceLocatorFactory.serviceLocator;
}
More information about the jboss-cvs-commits
mailing list