[jboss-cvs] JBossAS SVN: r87387 - in projects/webbeans-ri-int/trunk/deployer/src/main: java/org/jboss/webbeans/integration/deployer/env and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Apr 15 15:47:38 EDT 2009
Author: alesj
Date: 2009-04-15 15:47:38 -0400 (Wed, 15 Apr 2009)
New Revision: 87387
Modified:
projects/webbeans-ri-int/trunk/deployer/src/main/assembly/resources/META-INF/webbeans-deployers-jboss-beans.xml
projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/WebBeansBootstrapDeployer.java
projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/WebBeansJndiBinder.java
Log:
Re-factor wb jndi binder.
Modified: projects/webbeans-ri-int/trunk/deployer/src/main/assembly/resources/META-INF/webbeans-deployers-jboss-beans.xml
===================================================================
--- projects/webbeans-ri-int/trunk/deployer/src/main/assembly/resources/META-INF/webbeans-deployers-jboss-beans.xml 2009-04-15 19:09:25 UTC (rev 87386)
+++ projects/webbeans-ri-int/trunk/deployer/src/main/assembly/resources/META-INF/webbeans-deployers-jboss-beans.xml 2009-04-15 19:47:38 UTC (rev 87387)
@@ -36,11 +36,11 @@
<!-- Responsible for adding the Web Beans Manager object factory to JNDI -->
<bean name="WebBeansJndiBinder" class="org.jboss.webbeans.integration.deployer.env.WebBeansJndiBinder">
- <install method="startService">
+ <start method="startService">
<parameter>java:app/Manager</parameter>
<parameter>org.jboss.webbeans.resources.ManagerObjectFactory</parameter>
- </install>
- <uninstall method="stopService"/>
+ </start>
+ <stop method="stopService"/>
</bean>
</deployment>
Modified: projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/WebBeansBootstrapDeployer.java
===================================================================
--- projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/WebBeansBootstrapDeployer.java 2009-04-15 19:09:25 UTC (rev 87386)
+++ projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/WebBeansBootstrapDeployer.java 2009-04-15 19:47:38 UTC (rev 87387)
@@ -84,8 +84,7 @@
install.addParameterMetaData(String.class.getName(), "Start");
install.addParameterMetaData(String.class.getName(), "Start");
- unit.addAttachment(bootstrapName + "_" + BeanMetaData.class.getSimpleName(), bootstrap.getBeanMetaData());
-
+ unit.addAttachment(bootstrapName + "_" + BeanMetaData.class.getSimpleName(), bootstrap.getBeanMetaData());
}
/**
Modified: projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/WebBeansJndiBinder.java
===================================================================
--- projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/WebBeansJndiBinder.java 2009-04-15 19:09:25 UTC (rev 87386)
+++ projects/webbeans-ri-int/trunk/deployer/src/main/java/org/jboss/webbeans/integration/deployer/env/WebBeansJndiBinder.java 2009-04-15 19:47:38 UTC (rev 87387)
@@ -17,9 +17,6 @@
package org.jboss.webbeans.integration.deployer.env;
-import java.util.ArrayList;
-import java.util.List;
-
import javax.inject.ExecutionException;
import javax.inject.manager.Manager;
import javax.naming.Context;
@@ -30,8 +27,7 @@
/**
* This singleton bean for the deployer is responsible for binding
* an object factory to the required name(s) in JNDI. Once bound,
- * all deployed applications can obtain the Web Beans manager from
- * JNDI.
+ * all deployed applications can obtain the Web Beans manager from JNDI.
*
* @author David Allen
*
@@ -40,56 +36,64 @@
{
private String jndiName = null;
+ /**
+ * Start the service.
+ *
+ * @param jndiContextPath the jndi context path
+ * @param managerObjectFactoryClass the manager object factory
+ * @throws Exception for any error
+ */
public void startService(String jndiContextPath, String managerObjectFactoryClass) throws Exception
{
jndiName = jndiContextPath;
Reference managerReference = new Reference(Manager.class.getName(), managerObjectFactoryClass, null);
bind(jndiContextPath, managerReference);
}
-
+
+ /**
+ * Stop the service.
+ *
+ * @throws Exception for any error
+ */
public void stopService() throws Exception
{
Context initialContext = new InitialContext();
initialContext.unbind(jndiName);
}
-
+
+ /**
+ * Bind object to jndi.
+ *
+ * @param key the key
+ * @param binding the object to bind
+ * @throws Exception for any error
+ */
protected void bind(String key, Object binding) throws Exception
{
Context initialContext = new InitialContext();
try
{
- List<String> parts = splitIntoContexts(key);
+ String[] parts = key.split("/");
+ int length = parts.length;
Context context = initialContext;
- Context nextContext = null;
- for (int i = 0; i < parts.size() - 1; i++)
+ Context nextContext;
+ for (int i = 0; i < length - 1; i++)
{
try
{
- nextContext = (Context) context.lookup(parts.get(i));
+ nextContext = (Context) context.lookup(parts[i]);
}
catch (NamingException e)
{
- nextContext = context.createSubcontext(parts.get(i));
+ nextContext = context.createSubcontext(parts[i]);
}
context = nextContext;
}
- context.bind(parts.get(parts.size() - 1), binding);
+ context.bind(parts[length - 1], binding);
}
catch (NamingException e)
{
throw new ExecutionException("Cannot bind " + binding + " to " + key, e);
}
-
}
-
- private static List<String> splitIntoContexts(String key)
- {
- List<String> parts = new ArrayList<String>();
- for (String part : key.split("/"))
- {
- parts.add(part);
- }
- return parts;
- }
-
}
More information about the jboss-cvs-commits
mailing list