[jboss-cvs] JBossAS SVN: r95935 - in projects/weld-int/trunk: deployer/src/main/java/org/jboss/weld/integration/deployer/env and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Nov 2 18:50:58 EST 2009
Author: pete.muir at jboss.org
Date: 2009-11-02 18:50:57 -0500 (Mon, 02 Nov 2009)
New Revision: 95935
Added:
projects/weld-int/trunk/deployer/src/main/java/org/jboss/weld/integration/deployer/env/WeldJndiBinder.java
Modified:
projects/weld-int/trunk/assembly/src/main/assembly/resources/META-INF/weld-deployers-jboss-beans.xml
Log:
readd WeldJndiBinder for now, until we have a way to bind to java:comp
Modified: projects/weld-int/trunk/assembly/src/main/assembly/resources/META-INF/weld-deployers-jboss-beans.xml
===================================================================
--- projects/weld-int/trunk/assembly/src/main/assembly/resources/META-INF/weld-deployers-jboss-beans.xml 2009-11-02 23:00:26 UTC (rev 95934)
+++ projects/weld-int/trunk/assembly/src/main/assembly/resources/META-INF/weld-deployers-jboss-beans.xml 2009-11-02 23:50:57 UTC (rev 95935)
@@ -29,13 +29,12 @@
<!-- Responsible for booting Weld -->
<bean name="WeldBootstrapDeployer" class="org.jboss.weld.integration.deployer.env.WeldBootstrapDeployer"/>
- <!-- Responsible for binding bean managers -->
- <bean name="JndiBinderDeployer" class="org.jboss.weld.integration.deployer.jndi.JndiBinderDeployer"/>
-
- <!-- Responsible for pushing the JSF faces-config.xml onto the application classpath -->
+ <!-- Responsible for pushing the JSF faces-config.xml onto the application classpath
+-->
<bean name="WeldFacesIntegrationDeployer" class="org.jboss.weld.integration.deployer.cl.WeldFacesIntegrationDeployer"/>
- <!-- Responsible for pushing the webtier integration jar onto the application classpath -->
+ <!-- Responsible for pushing the webtier integration jar onto the application classpath
+-->
<!-- <bean name="WeldWenTierIntegrationDeployer" class="org.jboss.weld.integration.deployer.cl.WeldWebTierIntegrationDeployer"/>-->
<!-- Responsible for pushing Weld onto the application classpath -->
@@ -52,5 +51,18 @@
<!-- Responsible for adding the Weld listener to the Servlet -->
<bean name="PostWebMetadataDeployer" class="org.jboss.weld.integration.deployer.metadata.PostWebMetadataDeployer"/>
+
+ <!-- Responsible for adding the Weld Manager object factory to JNDI -->
+ <bean name="WeldJndiBinder" class="org.jboss.weld.integration.deployer.env.WeldJndiBinder">
+ <start method="startService">
+ <parameter>java:app/BeanManager</parameter>
+ <parameter>org.jboss.weld.resources.ManagerObjectFactory</parameter>
+ </start>
+ <stop method="stopService"/>
+ </bean>
+ <!-- Responsible for binding bean managers -->
+ <!--<bean name="JndiBinderDeployer" class="org.jboss.weld.integration.deployer.jndi.JndiBinderDeployer"/>-->
+
+
</deployment>
Added: projects/weld-int/trunk/deployer/src/main/java/org/jboss/weld/integration/deployer/env/WeldJndiBinder.java
===================================================================
--- projects/weld-int/trunk/deployer/src/main/java/org/jboss/weld/integration/deployer/env/WeldJndiBinder.java (rev 0)
+++ projects/weld-int/trunk/deployer/src/main/java/org/jboss/weld/integration/deployer/env/WeldJndiBinder.java 2009-11-02 23:50:57 UTC (rev 95935)
@@ -0,0 +1,98 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jboss.weld.integration.deployer.env;
+
+import javax.enterprise.inject.spi.BeanManager;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.naming.Reference;
+
+/**
+ * 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.
+ *
+ * @author David Allen
+ *
+ */
+public class WeldJndiBinder
+{
+ 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(BeanManager.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
+ {
+ String[] parts = key.split("/");
+ int length = parts.length;
+ Context context = initialContext;
+ Context nextContext;
+ for (int i = 0; i < length - 1; i++)
+ {
+ try
+ {
+ nextContext = (Context) context.lookup(parts[i]);
+ }
+ catch (NamingException e)
+ {
+ nextContext = context.createSubcontext(parts[i]);
+ }
+ context = nextContext;
+ }
+ context.bind(parts[length - 1], binding);
+ }
+ catch (NamingException e)
+ {
+ throw new RuntimeException("Cannot bind " + binding + " to " + key, e);
+ }
+ }
+}
Property changes on: projects/weld-int/trunk/deployer/src/main/java/org/jboss/weld/integration/deployer/env/WeldJndiBinder.java
___________________________________________________________________
Name: svn:eol-style
+ native
More information about the jboss-cvs-commits
mailing list