[jboss-cvs] JBossAS SVN: r109337 - in trunk: weld-int/assembly and 4 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Nov 15 05:37:39 EST 2010
Author: marius.bogoevici
Date: 2010-11-15 05:37:38 -0500 (Mon, 15 Nov 2010)
New Revision: 109337
Added:
trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/instantiator/
trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/instantiator/Jsr299BeanInstantiator.java
trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/instantiator/Jsr299BeanInstantiatorDeployer.java
trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/instantiator/RedirectingBeanInstantiatorDeployer.java
Removed:
trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/instantiator/Jsr299BeanInstantiator.java
trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/instantiator/Jsr299BeanInstantiatorDeployer.java
trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/instantiator/RedirectingBeanInstantiatorDeployer.java
Modified:
trunk/ejb3/src/resources/META-INF/ejb3-as-deployers-jboss-beans.xml
trunk/weld-int/assembly/pom.xml
trunk/weld-int/assembly/src/main/assembly/resources/META-INF/weld-deployers-jboss-beans.xml
trunk/weld-int/deployer/pom.xml
Log:
JBAS-8279 Constructor injection into EJBs
Modified: trunk/ejb3/src/resources/META-INF/ejb3-as-deployers-jboss-beans.xml
===================================================================
--- trunk/ejb3/src/resources/META-INF/ejb3-as-deployers-jboss-beans.xml 2010-11-15 10:27:45 UTC (rev 109336)
+++ trunk/ejb3/src/resources/META-INF/ejb3-as-deployers-jboss-beans.xml 2010-11-15 10:37:38 UTC (rev 109337)
@@ -311,11 +311,13 @@
<!-- Responsible for creating the piece used to create EJB3 Bean Instances -->
<bean name="org.jboss.ejb3.BeanInstantiator" class="org.jboss.ejb3.instantiator.impl.Ejb31SpecBeanInstantiator" />
- <bean name="org.jboss.ejb3.BeanInstantiatorDeployer" class="org.jboss.ejb3.instantiator.deployer.SingletonBeanInstantiatorDeployer">
- <constructor>
- <parameter class="org.jboss.ejb3.instantiator.spi.BeanInstantiator"><inject bean="org.jboss.ejb3.BeanInstantiator"/></parameter>
- </constructor>
- <property name="kernel"><inject bean="jboss.kernel:service=Kernel"/></property>
- </bean>
+ <!-- Registers the default (EJB31) BeanInstantiatorDeployer -->
+ <!--<bean name="org.jboss.ejb3.BeanInstantiatorDeployer" class="org.jboss.ejb3.instantiator.deployer.SingletonBeanInstantiatorDeployer">-->
+ <!--<constructor>-->
+ <!--<parameter class="org.jboss.ejb3.instantiator.spi.BeanInstantiator"><inject bean="org.jboss.ejb3.BeanInstantiator"/></parameter>-->
+ <!--</constructor>-->
+ <!--<property name="kernel"><inject bean="jboss.kernel:service=Kernel"/></property>-->
+ <!--</bean>-->
+
</deployment>
Modified: trunk/weld-int/assembly/pom.xml
===================================================================
--- trunk/weld-int/assembly/pom.xml 2010-11-15 10:27:45 UTC (rev 109336)
+++ trunk/weld-int/assembly/pom.xml 2010-11-15 10:37:38 UTC (rev 109337)
@@ -23,6 +23,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
+ <version>1.4</version>
<executions>
<execution>
<id>core-no-jsf</id>
Modified: trunk/weld-int/assembly/src/main/assembly/resources/META-INF/weld-deployers-jboss-beans.xml
===================================================================
--- trunk/weld-int/assembly/src/main/assembly/resources/META-INF/weld-deployers-jboss-beans.xml 2010-11-15 10:27:45 UTC (rev 109336)
+++ trunk/weld-int/assembly/src/main/assembly/resources/META-INF/weld-deployers-jboss-beans.xml 2010-11-15 10:37:38 UTC (rev 109337)
@@ -121,4 +121,12 @@
<!-- Adds plugin to BeanMetaDataDeployer that installs WeldKernelControllerContexts -->
<!-- bean name="WeldBeanMetaDataDeployerPlugin" class="org.jboss.weld.integration.deployer.mc.WeldBeanMetaDataDeployerPlugin"/ -->
+ <!-- BeanInstantiatorDeployer supporting CDI constructor injection -->
+ <bean name="org.jboss.ejb3.BeanInstantiatorDeployer" class="org.jboss.weld.integration.instantiator.RedirectingBeanInstantiatorDeployer">
+ <constructor>
+ <parameter class="org.jboss.ejb3.instantiator.spi.BeanInstantiator"><inject bean="org.jboss.ejb3.BeanInstantiator"/></parameter>
+ <parameter class="org.jboss.kernel.Kernel"><inject bean="jboss.kernel:service=Kernel"/></parameter>
+ <parameter class="org.jboss.reloaded.naming.deployers.javaee.JavaEEComponentInformer"><inject bean="NamingJavaEEComponentInformer"/></parameter>
+ </constructor>
+ </bean>
</deployment>
Modified: trunk/weld-int/deployer/pom.xml
===================================================================
--- trunk/weld-int/deployer/pom.xml 2010-11-15 10:27:45 UTC (rev 109336)
+++ trunk/weld-int/deployer/pom.xml 2010-11-15 10:37:38 UTC (rev 109337)
@@ -464,6 +464,16 @@
</exclusion>
</exclusions>
</dependency>
+
+ <dependency>
+ <groupId>org.jboss.ejb3.instantiator</groupId>
+ <artifactId>jboss-ejb3-instantiator-deployer</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.ejb3.instantiator</groupId>
+ <artifactId>jboss-ejb3-instantiator-impl</artifactId>
+ </dependency>
</dependencies>
Copied: trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/instantiator (from rev 109332, branches/cdi-instantiator/weld-int/deployer/src/main/java/org/jboss/weld/integration/instantiator)
Deleted: trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/instantiator/Jsr299BeanInstantiator.java
===================================================================
--- branches/cdi-instantiator/weld-int/deployer/src/main/java/org/jboss/weld/integration/instantiator/Jsr299BeanInstantiator.java 2010-11-15 08:01:22 UTC (rev 109332)
+++ trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/instantiator/Jsr299BeanInstantiator.java 2010-11-15 10:37:38 UTC (rev 109337)
@@ -1,97 +0,0 @@
-package org.jboss.weld.integration.instantiator;
-
-import org.jboss.ejb3.instantiator.impl.Ejb31SpecBeanInstantiator;
-import org.jboss.ejb3.instantiator.spi.BeanInstantiationException;
-import org.jboss.ejb3.instantiator.spi.InvalidConstructionParamsException;
-import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
-import org.jboss.weld.bean.SessionBean;
-import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
-import org.jboss.weld.ejb.spi.EjbDescriptor;
-import org.jboss.weld.integration.deployer.env.helpers.BootstrapBean;
-import org.jboss.weld.manager.api.WeldManager;
-
-import javax.enterprise.inject.spi.InjectionTarget;
-import java.util.concurrent.atomic.AtomicReference;
-
-public class Jsr299BeanInstantiator extends Ejb31SpecBeanInstantiator
-{
-
- private BootstrapBean bootstrapBean;
-
- private String bdaId;
-
- private JBossEnterpriseBeanMetaData enterpriseBeanMetaData;
-
- private AtomicReference<WeldManager> weldManagerRef = new AtomicReference<WeldManager>();
-
- public Jsr299BeanInstantiator(JBossEnterpriseBeanMetaData enterpriseBeanMetaData)
- {
- if (enterpriseBeanMetaData == null)
- {
- throw new RuntimeException("EnterpriseBeanMetadata cannot be null");
- }
- this.enterpriseBeanMetaData = enterpriseBeanMetaData;
- }
-
- public void setBdaId(String bdaId)
- {
- this.bdaId = bdaId;
- }
-
- public void setBootstrapBean(BootstrapBean bootstrapBean)
- {
- this.bootstrapBean = bootstrapBean;
- }
-
- public <T> T create(Class<T> clazz, Object[] objects) throws IllegalArgumentException, InvalidConstructionParamsException, BeanInstantiationException
- {
- WeldManager weldManager = getWeldManager();
- EjbDescriptor<Object> ejbDescriptor = weldManager.getEjbDescriptor(enterpriseBeanMetaData.getEjbName());
- if (ejbDescriptor.getBeanClass().equals(clazz))
- {
- SessionBean<Object> bean = (SessionBean) weldManager.getBean(ejbDescriptor);
- InjectionTarget<Object> injectionTarget = weldManager.createInjectionTarget(ejbDescriptor);
- return (T)injectionTarget.produce(weldManager.createCreationalContext(bean));
- }
- else
- {
- return super.create(clazz, objects);
- }
- }
-
- private WeldManager getWeldManager()
- {
- WeldManager weldManager = weldManagerRef.get();
- if (weldManager == null)
- {
- weldManager = locateWeldManager();
- }
- weldManagerRef.compareAndSet(null, weldManager);
- return weldManager;
- }
-
- private WeldManager locateWeldManager()
- {
- BeanDeploymentArchive foundBeanDeploymentArchive = null;
- for (BeanDeploymentArchive beanDeploymentArchive : bootstrapBean.getDeployment().getBeanDeploymentArchives())
- {
- if (beanDeploymentArchive.getId().equals(bdaId))
- {
- foundBeanDeploymentArchive = beanDeploymentArchive;
- }
- }
- if (foundBeanDeploymentArchive == null)
- {
- throw new IllegalStateException("Cannot find BeanManager for BeanDeploymentArchive with id=" + bdaId);
- }
- return bootstrapBean.getBootstrap().getManager(foundBeanDeploymentArchive);
- }
-
- public void uninstall()
- {
- weldManagerRef.set(null);
- enterpriseBeanMetaData = null;
- }
-
-
-}
Copied: trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/instantiator/Jsr299BeanInstantiator.java (from rev 109332, branches/cdi-instantiator/weld-int/deployer/src/main/java/org/jboss/weld/integration/instantiator/Jsr299BeanInstantiator.java)
===================================================================
--- trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/instantiator/Jsr299BeanInstantiator.java (rev 0)
+++ trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/instantiator/Jsr299BeanInstantiator.java 2010-11-15 10:37:38 UTC (rev 109337)
@@ -0,0 +1,123 @@
+/*
+ *
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.weld.integration.instantiator;
+
+import org.jboss.ejb3.instantiator.impl.Ejb31SpecBeanInstantiator;
+import org.jboss.ejb3.instantiator.spi.BeanInstantiationException;
+import org.jboss.ejb3.instantiator.spi.InvalidConstructionParamsException;
+import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
+import org.jboss.weld.bean.SessionBean;
+import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
+import org.jboss.weld.ejb.spi.EjbDescriptor;
+import org.jboss.weld.integration.deployer.env.helpers.BootstrapBean;
+import org.jboss.weld.manager.api.WeldManager;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.InjectionTarget;
+import java.util.concurrent.atomic.AtomicReference;
+
+public class Jsr299BeanInstantiator extends Ejb31SpecBeanInstantiator
+{
+
+ private BootstrapBean bootstrapBean;
+
+ private String bdaId;
+
+ private JBossEnterpriseBeanMetaData enterpriseBeanMetaData;
+
+ private AtomicReference<WeldManager> weldManagerRef = new AtomicReference<WeldManager>();
+
+ public Jsr299BeanInstantiator(JBossEnterpriseBeanMetaData enterpriseBeanMetaData)
+ {
+ if (enterpriseBeanMetaData == null)
+ {
+ throw new RuntimeException("EnterpriseBeanMetadata cannot be null");
+ }
+ this.enterpriseBeanMetaData = enterpriseBeanMetaData;
+ }
+
+ public void setBdaId(String bdaId)
+ {
+ this.bdaId = bdaId;
+ }
+
+ public void setBootstrapBean(BootstrapBean bootstrapBean)
+ {
+ this.bootstrapBean = bootstrapBean;
+ }
+
+ public <T> T create(Class<T> clazz, Object[] objects) throws IllegalArgumentException, InvalidConstructionParamsException, BeanInstantiationException
+ {
+ WeldManager weldManager = getWeldManager();
+ EjbDescriptor<Object> ejbDescriptor = weldManager.getEjbDescriptor(enterpriseBeanMetaData.getEjbName());
+ if (ejbDescriptor.getBeanClass().equals(clazz))
+ {
+ SessionBean<Object> bean = (SessionBean) weldManager.getBean(ejbDescriptor);
+ InjectionTarget<Object> injectionTarget = weldManager.createInjectionTarget(ejbDescriptor);
+ CreationalContext<Object> creationalContext = weldManager.createCreationalContext(bean);
+ T instance = (T) injectionTarget.produce(creationalContext);
+ return instance;
+ }
+ else
+ {
+ return super.create(clazz, objects);
+ }
+ }
+
+ private WeldManager getWeldManager()
+ {
+ WeldManager weldManager = weldManagerRef.get();
+ if (weldManager == null)
+ {
+ weldManager = locateWeldManager();
+ }
+ weldManagerRef.compareAndSet(null, weldManager);
+ return weldManager;
+ }
+
+ private WeldManager locateWeldManager()
+ {
+ BeanDeploymentArchive foundBeanDeploymentArchive = null;
+ for (BeanDeploymentArchive beanDeploymentArchive : bootstrapBean.getDeployment().getBeanDeploymentArchives())
+ {
+ if (beanDeploymentArchive.getId().equals(bdaId))
+ {
+ foundBeanDeploymentArchive = beanDeploymentArchive;
+ }
+ }
+ if (foundBeanDeploymentArchive == null)
+ {
+ throw new IllegalStateException("Cannot find BeanManager for BeanDeploymentArchive with id=" + bdaId);
+ }
+ return bootstrapBean.getBootstrap().getManager(foundBeanDeploymentArchive);
+ }
+
+ public void uninstall()
+ {
+ weldManagerRef.set(null);
+ enterpriseBeanMetaData = null;
+ }
+
+
+}
Deleted: trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/instantiator/Jsr299BeanInstantiatorDeployer.java
===================================================================
--- branches/cdi-instantiator/weld-int/deployer/src/main/java/org/jboss/weld/integration/instantiator/Jsr299BeanInstantiatorDeployer.java 2010-11-15 08:01:22 UTC (rev 109332)
+++ trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/instantiator/Jsr299BeanInstantiatorDeployer.java 2010-11-15 10:37:38 UTC (rev 109337)
@@ -1,59 +0,0 @@
-/*
- *
- * JBoss, Home of Professional Open Source.
- * Copyright 2010, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.weld.integration.instantiator;
-
-import org.jboss.beans.metadata.api.model.InjectOption;
-import org.jboss.beans.metadata.plugins.AbstractInjectionValueMetaData;
-import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.ejb3.instantiator.deployer.BeanInstantiatorDeployerBase;
-import org.jboss.ejb3.instantiator.spi.BeanInstantiator;
-import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
-import org.jboss.weld.integration.deployer.DeployersUtils;
-import org.jboss.weld.integration.util.IdFactory;
-
-public class Jsr299BeanInstantiatorDeployer extends BeanInstantiatorDeployerBase
-{
-
- protected BeanInstantiator getBeanInstantiator(JBossEnterpriseBeanMetaData ebmd)
- {
- return new Jsr299BeanInstantiator(ebmd);
- }
-
- protected BeanInstantiator getBeanInstantiator(JBossEnterpriseBeanMetaData ebmd, DeploymentUnit unit)
- {
- return getBeanInstantiator(ebmd);
- }
-
- @Override
- protected void processMetadata(BeanMetaDataBuilder beanMetaDataBuilder, DeploymentUnit unit, JBossEnterpriseBeanMetaData ejb)
- {
- beanMetaDataBuilder.setBean(Jsr299BeanInstantiator.class.getName());
- beanMetaDataBuilder.addPropertyMetaData("bdaId", IdFactory.getIdFromClassLoader(unit.getClassLoader()));
- AbstractInjectionValueMetaData bootstrapBean = new AbstractInjectionValueMetaData(DeployersUtils.getBootstrapBeanName(unit));
- bootstrapBean.setInjectionOption(InjectOption.CALLBACK);
- beanMetaDataBuilder.addPropertyMetaData("bootstrapBean", bootstrapBean);
- }
-}
Copied: trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/instantiator/Jsr299BeanInstantiatorDeployer.java (from rev 109332, branches/cdi-instantiator/weld-int/deployer/src/main/java/org/jboss/weld/integration/instantiator/Jsr299BeanInstantiatorDeployer.java)
===================================================================
--- trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/instantiator/Jsr299BeanInstantiatorDeployer.java (rev 0)
+++ trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/instantiator/Jsr299BeanInstantiatorDeployer.java 2010-11-15 10:37:38 UTC (rev 109337)
@@ -0,0 +1,59 @@
+/*
+ *
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.weld.integration.instantiator;
+
+import org.jboss.beans.metadata.api.model.InjectOption;
+import org.jboss.beans.metadata.plugins.AbstractInjectionValueMetaData;
+import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.ejb3.instantiator.deployer.BeanInstantiatorDeployerBase;
+import org.jboss.ejb3.instantiator.spi.BeanInstantiator;
+import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
+import org.jboss.weld.integration.deployer.DeployersUtils;
+import org.jboss.weld.integration.util.IdFactory;
+
+public class Jsr299BeanInstantiatorDeployer extends BeanInstantiatorDeployerBase
+{
+
+ protected BeanInstantiator getBeanInstantiator(JBossEnterpriseBeanMetaData ebmd)
+ {
+ return new Jsr299BeanInstantiator(ebmd);
+ }
+
+ protected BeanInstantiator getBeanInstantiator(JBossEnterpriseBeanMetaData ebmd, DeploymentUnit unit)
+ {
+ return getBeanInstantiator(ebmd);
+ }
+
+ @Override
+ protected void processMetadata(BeanMetaDataBuilder beanMetaDataBuilder, DeploymentUnit unit, JBossEnterpriseBeanMetaData ejb)
+ {
+ beanMetaDataBuilder.setBean(Jsr299BeanInstantiator.class.getName());
+ beanMetaDataBuilder.addPropertyMetaData("bdaId", IdFactory.getIdFromClassLoader(unit.getClassLoader()));
+ AbstractInjectionValueMetaData bootstrapBean = new AbstractInjectionValueMetaData(DeployersUtils.getBootstrapBeanName(unit));
+ bootstrapBean.setInjectionOption(InjectOption.CALLBACK);
+ beanMetaDataBuilder.addPropertyMetaData("bootstrapBean", bootstrapBean);
+ }
+}
Deleted: trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/instantiator/RedirectingBeanInstantiatorDeployer.java
===================================================================
--- branches/cdi-instantiator/weld-int/deployer/src/main/java/org/jboss/weld/integration/instantiator/RedirectingBeanInstantiatorDeployer.java 2010-11-15 08:01:22 UTC (rev 109332)
+++ trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/instantiator/RedirectingBeanInstantiatorDeployer.java 2010-11-15 10:37:38 UTC (rev 109337)
@@ -1,83 +0,0 @@
-/*
- *
- * JBoss, Home of Professional Open Source.
- * Copyright 2010, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.weld.integration.instantiator;
-
-import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.spi.deployer.helpers.AbstractDeployer;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.ejb3.instantiator.deployer.BeanInstantiatorDeployerBase;
-import org.jboss.ejb3.instantiator.deployer.SingletonBeanInstantiatorDeployer;
-import org.jboss.ejb3.instantiator.spi.BeanInstantiator;
-import org.jboss.kernel.Kernel;
-import org.jboss.metadata.ejb.jboss.JBossMetaData;
-import org.jboss.reloaded.naming.deployers.javaee.JavaEEComponentInformer;
-import org.jboss.weld.integration.deployer.DeployersUtils;
-
-/**
- * @author Marius Bogoevici
- */
-//TODO: remove this class after updating BeanInstantiatorDeployerBase
-public class RedirectingBeanInstantiatorDeployer extends AbstractDeployer
-{
-
- private Jsr299BeanInstantiatorDeployer jsr299BeanInstantiatorDeployer;
- private SingletonBeanInstantiatorDeployer singletonBeanInstantiatorDeployer;
-
- public RedirectingBeanInstantiatorDeployer(BeanInstantiator defaultBeanInstantiator, Kernel kernel, JavaEEComponentInformer javaEEComponentInformer)
- {
- super();
- this.addInput(JBossMetaData.class);
- this.addOutput(BeanInstantiator.class);
- jsr299BeanInstantiatorDeployer = new Jsr299BeanInstantiatorDeployer();
- jsr299BeanInstantiatorDeployer.setKernel(kernel);
- jsr299BeanInstantiatorDeployer.setJavaEEComponentInformer(javaEEComponentInformer);
- singletonBeanInstantiatorDeployer = new SingletonBeanInstantiatorDeployer(defaultBeanInstantiator);
- singletonBeanInstantiatorDeployer.setKernel(kernel);
- singletonBeanInstantiatorDeployer.setJavaEEComponentInformer(javaEEComponentInformer);
- }
-
- public void deploy(DeploymentUnit unit) throws DeploymentException
- {
- getApplicableBeanInstantiatorDeployer(unit).deploy(unit);
- }
-
- @Override
- public void undeploy(DeploymentUnit unit)
- {
- getApplicableBeanInstantiatorDeployer(unit).undeploy(unit);
- }
-
- public BeanInstantiatorDeployerBase getApplicableBeanInstantiatorDeployer(DeploymentUnit unit)
- {
- if (DeployersUtils.checkForWeldFiles(unit, false))
- {
- return jsr299BeanInstantiatorDeployer;
- }
- else
- {
- return singletonBeanInstantiatorDeployer;
- }
- }
-}
Copied: trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/instantiator/RedirectingBeanInstantiatorDeployer.java (from rev 109332, branches/cdi-instantiator/weld-int/deployer/src/main/java/org/jboss/weld/integration/instantiator/RedirectingBeanInstantiatorDeployer.java)
===================================================================
--- trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/instantiator/RedirectingBeanInstantiatorDeployer.java (rev 0)
+++ trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/instantiator/RedirectingBeanInstantiatorDeployer.java 2010-11-15 10:37:38 UTC (rev 109337)
@@ -0,0 +1,88 @@
+/*
+ *
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.weld.integration.instantiator;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.helpers.AbstractDeployer;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.ejb3.instantiator.deployer.BeanInstantiatorDeployerBase;
+import org.jboss.ejb3.instantiator.deployer.SingletonBeanInstantiatorDeployer;
+import org.jboss.ejb3.instantiator.spi.BeanInstantiator;
+import org.jboss.kernel.Kernel;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
+import org.jboss.reloaded.naming.deployers.javaee.JavaEEComponentInformer;
+import org.jboss.weld.integration.deployer.DeployersUtils;
+
+/**
+ * A deployer that redirects to one of the two supported BeanInstantiator deployers.
+ * To be replace with a simpler implementation once the signature to getBeanInstantiator()
+ * is modified to pass on the DeploymentUnit - we need it to decide whether this is a
+ * CDI deployment or not
+ *
+ * @author Marius Bogoevici
+ */
+//TODO: remove this class after updating BeanInstantiatorDeployerBase and register a single deployer
+public class RedirectingBeanInstantiatorDeployer extends AbstractDeployer
+{
+
+ private Jsr299BeanInstantiatorDeployer jsr299BeanInstantiatorDeployer;
+ private SingletonBeanInstantiatorDeployer singletonBeanInstantiatorDeployer;
+
+ public RedirectingBeanInstantiatorDeployer(BeanInstantiator defaultBeanInstantiator, Kernel kernel, JavaEEComponentInformer javaEEComponentInformer)
+ {
+ super();
+ this.addInput(JBossMetaData.class);
+ this.addOutput(BeanInstantiator.class);
+ jsr299BeanInstantiatorDeployer = new Jsr299BeanInstantiatorDeployer();
+ jsr299BeanInstantiatorDeployer.setKernel(kernel);
+ jsr299BeanInstantiatorDeployer.setJavaEEComponentInformer(javaEEComponentInformer);
+ singletonBeanInstantiatorDeployer = new SingletonBeanInstantiatorDeployer(defaultBeanInstantiator);
+ singletonBeanInstantiatorDeployer.setKernel(kernel);
+ singletonBeanInstantiatorDeployer.setJavaEEComponentInformer(javaEEComponentInformer);
+ }
+
+ public void deploy(DeploymentUnit unit) throws DeploymentException
+ {
+ getApplicableBeanInstantiatorDeployer(unit).deploy(unit);
+ }
+
+ @Override
+ public void undeploy(DeploymentUnit unit)
+ {
+ getApplicableBeanInstantiatorDeployer(unit).undeploy(unit);
+ }
+
+ public BeanInstantiatorDeployerBase getApplicableBeanInstantiatorDeployer(DeploymentUnit unit)
+ {
+ if (DeployersUtils.checkForWeldFiles(unit, false))
+ {
+ return jsr299BeanInstantiatorDeployer;
+ }
+ else
+ {
+ return singletonBeanInstantiatorDeployer;
+ }
+ }
+}
More information about the jboss-cvs-commits
mailing list