[jboss-cvs] JBossAS SVN: r110719 - in trunk/weld-int: deployer/src/main/java/org/jboss/weld/integration/deployer/env and 5 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sat Feb 19 20:21:51 EST 2011
Author: alesj
Date: 2011-02-19 20:21:50 -0500 (Sat, 19 Feb 2011)
New Revision: 110719
Added:
trunk/weld-int/ejb/src/main/java/org/jboss/weld/integration/mock/IMockServices.java
Modified:
trunk/weld-int/assembly/src/main/assembly/resources/META-INF/weld-services-jboss-beans.xml
trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/EjbServicesDeployer.java
trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/JBossDeploymentDeployer.java
trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/DeploymentImpl.java
trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ServiceRegistryFactory.java
trunk/weld-int/deployer/src/test/resources/org/jboss/test/deployers/test/BasicEarJBossDeploymentTestCase.xml
trunk/weld-int/deployer/src/test/resources/org/jboss/test/deployers/test/BootDeployerTestCase.xml
trunk/weld-int/deployer/src/test/resources/org/jboss/test/deployers/test/FlatDeploymentTestCase.xml
trunk/weld-int/ejb/src/main/java/org/jboss/weld/integration/ejb/JBossEjbServices.java
trunk/weld-int/ejb/src/main/java/org/jboss/weld/integration/mock/MockServices.java
trunk/weld-int/ejb/src/main/java/org/jboss/weld/integration/util/AbstractJBossServices.java
Log:
[JBAS-8905]; easy non-EJB config support for Weld-int.
Modified: trunk/weld-int/assembly/src/main/assembly/resources/META-INF/weld-services-jboss-beans.xml
===================================================================
--- trunk/weld-int/assembly/src/main/assembly/resources/META-INF/weld-services-jboss-beans.xml 2011-02-19 19:04:27 UTC (rev 110718)
+++ trunk/weld-int/assembly/src/main/assembly/resources/META-INF/weld-services-jboss-beans.xml 2011-02-20 01:21:50 UTC (rev 110719)
@@ -38,5 +38,27 @@
<!-- Access to the caller context Principal -->
<bean name="JBossSecurityServices" class="org.jboss.weld.integration.security.JBossSecurityServices" />
-
+
+ <!-- Weld Mock Services : disable real services -->
+ <!-- bean name="MockServices" class="org.jboss.weld.integration.mock.MockServices">
+ <constructor>
+ <parameter>
+ <array elementClass="java.lang.Class">
+ <value>org.jboss.weld.ejb.spi.EjbServices</value>
+ <value>org.jboss.weld.injection.spi.EjbInjectionServices</value -->
+ <!-- value>org.jboss.weld.injection.spi.JpaInjectionServices</value -->
+ <!-- value>org.jboss.weld.injection.spi.ResourceInjectionServices</value -->
+ <!-- value>org.jboss.weld.transaction.spi.TransactionServices</value -->
+ <!-- value>org.jboss.weld.security.spi.SecurityServices</value -->
+ <!-- /array>
+ </parameter>
+ </constructor>
+ <alias>JBossEjbServices</alias>
+ <alias>JBossEjbInjectionServices</alias -->
+ <!-- alias>JBossJpaServices</alias -->
+ <!-- alias>JBossResourceServices</alias -->
+ <!-- alias>JBossTransactionServices</alias -->
+ <!-- alias>JBossSecurityServices</alias -->
+ <!-- /bean -->
+
</deployment>
Modified: trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/EjbServicesDeployer.java
===================================================================
--- trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/EjbServicesDeployer.java 2011-02-19 19:04:27 UTC (rev 110718)
+++ trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/EjbServicesDeployer.java 2011-02-20 01:21:50 UTC (rev 110719)
@@ -32,44 +32,19 @@
*/
public class EjbServicesDeployer extends AbstractBootstrapInfoDeployer
{
- /** The ejb services class name */
- private String ejbServicesClassName = "org.jboss.weld.integration.ejb.JBossEjbServices";
-
- /** The ejb injection services class name */
- private String ejbInjectionServicesClassName = "org.jboss.weld.integration.ejb.JBossEjbInjectionServices";
-
public EjbServicesDeployer()
{
super(true);
addOutput(BootstrapInfo.EJB_SERVICES);
}
+ // No need for the actual bean name, we use factory anyway
public void deployInternal(DeploymentUnit unit, BootstrapInfo info) throws DeploymentException
{
- ValueMetaData ejbServicesValue = createServiceConnector("JBossEjbServices", ejbServicesClassName, unit);
+ ValueMetaData ejbServicesValue = createServiceConnector("JBossEjbServices", null, unit);
info.setEjbServices(ejbServicesValue);
- ValueMetaData ejbInjectionServicesValue = createServiceConnector("JBossEjbInjectionServices", ejbInjectionServicesClassName, unit);
+ ValueMetaData ejbInjectionServicesValue = createServiceConnector("JBossEjbInjectionServices", null, unit);
info.setEjbInjectionServices(ejbInjectionServicesValue);
}
-
- /**
- * Set ejb services class name.
- *
- * @param ejbServicesClassName the ejb services classname
- */
- public void setEjbServicesClassName(String ejbServicesClassName)
- {
- this.ejbServicesClassName = ejbServicesClassName;
- }
-
- /**
- * Set ejb injection services class name.
- *
- * @param ejbInjectionServicesClassName the ejb injection services classname
- */
- public void setEjbInjectionServicesClassName(String ejbInjectionServicesClassName)
- {
- this.ejbInjectionServicesClassName = ejbInjectionServicesClassName;
- }
}
\ No newline at end of file
Modified: trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/JBossDeploymentDeployer.java
===================================================================
--- trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/JBossDeploymentDeployer.java 2011-02-19 19:04:27 UTC (rev 110718)
+++ trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/JBossDeploymentDeployer.java 2011-02-20 01:21:50 UTC (rev 110719)
@@ -25,9 +25,9 @@
import java.util.Collection;
import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
-import org.jboss.beans.metadata.spi.factory.BeanFactory;
import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.weld.bootstrap.spi.Deployment;
+import org.jboss.weld.ejb.spi.EjbServices;
import org.jboss.weld.integration.deployer.env.bda.ArchiveInfo;
import org.jboss.weld.integration.deployer.env.bda.DeploymentImpl;
@@ -61,7 +61,7 @@
builder.addConstructorParameter(String.class.getName(), unit.getName());
builder.addConstructorParameter(Collection.class.getName(), getArchiveInfos(unit));
builder.addConstructorParameter(Collection.class.getName(), builder.createInject(info.getEjbServices().getUnderlyingValue(), "ejbs"));
- builder.addConstructorParameter(BeanFactory.class.getName(), builder.createInject("JBossEjbServices"));
+ builder.addConstructorParameter(EjbServices.class.getName(), info.getEjbServices());
builder.addUninstall("undeploy");
}
Modified: trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/DeploymentImpl.java
===================================================================
--- trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/DeploymentImpl.java 2011-02-19 19:04:27 UTC (rev 110718)
+++ trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/DeploymentImpl.java 2011-02-20 01:21:50 UTC (rev 110719)
@@ -27,7 +27,6 @@
import java.util.HashSet;
import java.util.Iterator;
-import org.jboss.beans.metadata.spi.factory.BeanFactory;
import org.jboss.weld.bootstrap.api.Bootstrap;
import org.jboss.weld.bootstrap.api.Service;
import org.jboss.weld.bootstrap.api.ServiceRegistry;
@@ -36,12 +35,13 @@
import org.jboss.weld.bootstrap.spi.Deployment;
import org.jboss.weld.bootstrap.spi.Metadata;
import org.jboss.weld.ejb.spi.EjbDescriptor;
+import org.jboss.weld.ejb.spi.EjbServices;
/**
* {@link Deployment} implementation for JBoss AS.
*
* @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
- * @version $Revision$
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
*/
public class DeploymentImpl implements Deployment
{
@@ -72,12 +72,11 @@
* Constructor.
*
* @param name a name that identifies this deployment
- * @param archiveInfos the information that will be used for creation of the archives
- * contained in this deployment
+ * @param archiveInfos the information that will be used for creation of the archives contained in this deployment
* @param ejbs the ejb descriptors
- * @param ejbServicesFactory the ejb services factory
+ * @param ejbServices the ejb services
*/
- public DeploymentImpl(String name, Collection<ArchiveInfo> archiveInfos, Collection<EjbDescriptor<?>> ejbs, BeanFactory ejbServicesFactory)
+ public DeploymentImpl(String name, Collection<ArchiveInfo> archiveInfos, Collection<EjbDescriptor<?>> ejbs, EjbServices ejbServices)
{
this.name = name;
this.archives = new ArchiveCollection();
@@ -87,7 +86,7 @@
{
archives.add(ArchiveFactory.createArchive(archiveInfo, ejbs));
}
- this.loadedBDAServiceRegistry = new ServiceRegistryFactory(ejbServicesFactory);
+ this.loadedBDAServiceRegistry = new ServiceRegistryFactory(ejbServices);
this.loadedArchives = new HashSet<Archive>();
}
Modified: trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ServiceRegistryFactory.java
===================================================================
--- trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ServiceRegistryFactory.java 2011-02-19 19:04:27 UTC (rev 110718)
+++ trunk/weld-int/deployer/src/main/java/org/jboss/weld/integration/deployer/env/bda/ServiceRegistryFactory.java 2011-02-20 01:21:50 UTC (rev 110719)
@@ -24,7 +24,6 @@
import java.util.HashMap;
import java.util.Map;
-import org.jboss.beans.metadata.spi.factory.BeanFactory;
import org.jboss.weld.bootstrap.api.Service;
import org.jboss.weld.bootstrap.api.ServiceRegistry;
import org.jboss.weld.bootstrap.api.helpers.SimpleServiceRegistry;
@@ -35,16 +34,16 @@
*
* @see DeploymentImpl#loadBeanDeploymentArchive(Class)
* @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
- * @version $Revision$
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
*/
class ServiceRegistryFactory
{
- private BeanFactory ejbServicesFactory;
+ private EjbServices ejbServices;
private Map<Class<? extends Service>, Service> services;
- public ServiceRegistryFactory(BeanFactory ejbServicesFactory)
+ public ServiceRegistryFactory(EjbServices ejbServices)
{
- this.ejbServicesFactory = ejbServicesFactory;
+ this.ejbServices = ejbServices;
services = new HashMap<Class<? extends Service>, Service>();
}
@@ -57,14 +56,6 @@
{
ServiceRegistry serviceRegistry = new SimpleServiceRegistry();
serviceRegistry.addAll(services.entrySet());
- EjbServices ejbServices = null;
- try
- {
- ejbServices = (EjbServices) ejbServicesFactory.createBean();
- } catch (Throwable e)
- {
- throw new RuntimeException(e);
- }
serviceRegistry.add(EjbServices.class, ejbServices);
return serviceRegistry;
}
Modified: trunk/weld-int/deployer/src/test/resources/org/jboss/test/deployers/test/BasicEarJBossDeploymentTestCase.xml
===================================================================
--- trunk/weld-int/deployer/src/test/resources/org/jboss/test/deployers/test/BasicEarJBossDeploymentTestCase.xml 2011-02-19 19:04:27 UTC (rev 110718)
+++ trunk/weld-int/deployer/src/test/resources/org/jboss/test/deployers/test/BasicEarJBossDeploymentTestCase.xml 2011-02-20 01:21:50 UTC (rev 110719)
@@ -12,10 +12,7 @@
<beanfactory name="JBossEjbServices" class="org.jboss.test.deployers.support.MockEmptyEjbServices"/>
<beanfactory name="JBossEjbInjectionServices" class="org.jboss.test.deployers.support.MockEjbInjectionServices"/>
- <bean name="EjbServicesDeployer" class="org.jboss.weld.integration.deployer.env.EjbServicesDeployer">
- <property name="ejbServicesClassName">org.jboss.test.deployers.support.MockEmptyEjbServices</property>
- <property name="ejbInjectionServicesClassName">org.jboss.test.deployers.support.MockEjbInjectionServices</property>
- </bean>
+ <bean name="EjbServicesDeployer" class="org.jboss.weld.integration.deployer.env.EjbServicesDeployer" />
<!-- Target of the Test -->
<bean name="DeploymentDeployer" class="org.jboss.weld.integration.deployer.env.JBossDeploymentDeployer"/>
Modified: trunk/weld-int/deployer/src/test/resources/org/jboss/test/deployers/test/BootDeployerTestCase.xml
===================================================================
--- trunk/weld-int/deployer/src/test/resources/org/jboss/test/deployers/test/BootDeployerTestCase.xml 2011-02-19 19:04:27 UTC (rev 110718)
+++ trunk/weld-int/deployer/src/test/resources/org/jboss/test/deployers/test/BootDeployerTestCase.xml 2011-02-20 01:21:50 UTC (rev 110719)
@@ -17,10 +17,7 @@
<bean name="WarCLDeployer" class="org.jboss.test.deployers.support.deployer.MockWarClassLoaderDeployer"/>
<bean name="MockUrlIntDeployer" class="org.jboss.test.deployers.support.deployer.MockCoreIntegrationDeployer"/>
- <bean name="EjbServicesDeployer" class="org.jboss.weld.integration.deployer.env.EjbServicesDeployer">
- <property name="ejbServicesClassName">org.jboss.test.deployers.support.MockEjbServices</property>
- <property name="ejbInjectionServicesClassName">org.jboss.test.deployers.support.MockEjbInjectionServices</property>
- </bean>
+ <bean name="EjbServicesDeployer" class="org.jboss.weld.integration.deployer.env.EjbServicesDeployer" />
<bean name="DeploymentDeployer" class="org.jboss.weld.integration.deployer.env.FlatDeploymentDeployer"/>
Modified: trunk/weld-int/deployer/src/test/resources/org/jboss/test/deployers/test/FlatDeploymentTestCase.xml
===================================================================
--- trunk/weld-int/deployer/src/test/resources/org/jboss/test/deployers/test/FlatDeploymentTestCase.xml 2011-02-19 19:04:27 UTC (rev 110718)
+++ trunk/weld-int/deployer/src/test/resources/org/jboss/test/deployers/test/FlatDeploymentTestCase.xml 2011-02-20 01:21:50 UTC (rev 110719)
@@ -10,10 +10,7 @@
<beanfactory name="JBossEjbServices" class="org.jboss.test.deployers.support.MockEmptyEjbServices"/>
<beanfactory name="JBossEjbInjectionServices" class="org.jboss.test.deployers.support.MockEjbInjectionServices"/>
- <bean name="EjbServicesDeployer" class="org.jboss.weld.integration.deployer.env.EjbServicesDeployer">
- <property name="ejbServicesClassName">org.jboss.test.deployers.support.MockEmptyEjbServices</property>
- <property name="ejbInjectionServicesClassName">org.jboss.test.deployers.support.MockEjbInjectionServices</property>
- </bean>
+ <bean name="EjbServicesDeployer" class="org.jboss.weld.integration.deployer.env.EjbServicesDeployer" />
<bean name="DeploymentDeployer" class="org.jboss.weld.integration.deployer.env.FlatDeploymentDeployer"/>
Modified: trunk/weld-int/ejb/src/main/java/org/jboss/weld/integration/ejb/JBossEjbServices.java
===================================================================
--- trunk/weld-int/ejb/src/main/java/org/jboss/weld/integration/ejb/JBossEjbServices.java 2011-02-19 19:04:27 UTC (rev 110718)
+++ trunk/weld-int/ejb/src/main/java/org/jboss/weld/integration/ejb/JBossEjbServices.java 2011-02-20 01:21:50 UTC (rev 110719)
@@ -21,7 +21,6 @@
import org.jboss.weld.ejb.spi.EjbServices;
import org.jboss.weld.ejb.spi.InterceptorBindings;
import org.jboss.weld.integration.util.AbstractJBossServices;
-import org.jboss.weld.integration.vdf.DeploymentUnitAware;
/**
* An implementation of EjbServices for JBoss EJB3
@@ -31,7 +30,7 @@
* @author Marius Bogoevici
* @author <a href="mailto:flavia.rainone at jboss.com">Flavia Rainone</a>
*/
-public class JBossEjbServices extends AbstractJBossServices implements EjbServices, DeploymentUnitAware
+public class JBossEjbServices extends AbstractJBossServices implements EjbServices
{
private EjbReferenceResolver resolver;
private final List<EjbDescriptor<?>> ejbs = new ArrayList<EjbDescriptor<?>>();
Copied: trunk/weld-int/ejb/src/main/java/org/jboss/weld/integration/mock/IMockServices.java (from rev 110718, trunk/weld-int/ejb/src/main/java/org/jboss/weld/integration/mock/MockServices.java)
===================================================================
--- trunk/weld-int/ejb/src/main/java/org/jboss/weld/integration/mock/IMockServices.java (rev 0)
+++ trunk/weld-int/ejb/src/main/java/org/jboss/weld/integration/mock/IMockServices.java 2011-02-20 01:21:50 UTC (rev 110719)
@@ -0,0 +1,48 @@
+/*
+ * 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.mock;
+
+import java.util.Collection;
+
+/**
+ * Mock Weld services interface.
+ * Holds impl details, exposing them to other services.
+ *
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public interface IMockServices
+{
+ /**
+ * Impl detail, reflection accessed.
+ *
+ * @return empty collection
+ */
+ Collection getEjbs();
+
+ /**
+ * Impl detail, reflection accessed.
+ *
+ * @return empty collection
+ */
+ Collection getEjbContainerNames();
+}
Modified: trunk/weld-int/ejb/src/main/java/org/jboss/weld/integration/mock/MockServices.java
===================================================================
--- trunk/weld-int/ejb/src/main/java/org/jboss/weld/integration/mock/MockServices.java 2011-02-19 19:04:27 UTC (rev 110718)
+++ trunk/weld-int/ejb/src/main/java/org/jboss/weld/integration/mock/MockServices.java 2011-02-20 01:21:50 UTC (rev 110719)
@@ -26,9 +26,7 @@
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
+import java.util.*;
import org.jboss.beans.metadata.spi.factory.BeanFactory;
import org.jboss.deployers.structure.spi.DeploymentUnit;
@@ -39,7 +37,7 @@
*
* @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
*/
-public class MockServices implements Serializable, BeanFactory, DeploymentUnitAware, InvocationHandler
+public class MockServices implements IMockServices, Serializable, BeanFactory, DeploymentUnitAware, InvocationHandler
{
private static final long serialVersionUID = 1L;
@@ -53,6 +51,7 @@
this.interfaces = new ArrayList<Class<?>>();
this.interfaces.addAll(Arrays.asList(interfaces));
+ this.interfaces.add(IMockServices.class);
this.interfaces.add(Serializable.class);
this.interfaces.add(DeploymentUnitAware.class);
}
@@ -81,6 +80,35 @@
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
{
- return null; // TODO -- mock return values as well?
+ // invoke Object and impl mocks on this mock instance
+ Class<?> declaringClass = method.getDeclaringClass();
+ if (declaringClass.equals(Object.class) || declaringClass.equals(IMockServices.class))
+ return method.invoke(this, args);
+
+ if (Map.class.isAssignableFrom(method.getReturnType()))
+ return Collections.emptyMap();
+ if (Set.class.isAssignableFrom(method.getReturnType()))
+ return Collections.emptySet();
+ if (Collection.class.isAssignableFrom(method.getReturnType()))
+ return Collections.emptyList();
+ else
+ return null; // TODO -- mock return values as well?
}
+
+ public String toString()
+ {
+ return "Weld-Mock-Services::" + proxy;
+ }
+
+ // -- impl details
+
+ public Collection getEjbs()
+ {
+ return Collections.emptyList();
+ }
+
+ public Collection getEjbContainerNames()
+ {
+ return Collections.emptyList();
+ }
}
Modified: trunk/weld-int/ejb/src/main/java/org/jboss/weld/integration/util/AbstractJBossServices.java
===================================================================
--- trunk/weld-int/ejb/src/main/java/org/jboss/weld/integration/util/AbstractJBossServices.java 2011-02-19 19:04:27 UTC (rev 110718)
+++ trunk/weld-int/ejb/src/main/java/org/jboss/weld/integration/util/AbstractJBossServices.java 2011-02-20 01:21:50 UTC (rev 110719)
@@ -6,6 +6,7 @@
import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.weld.bootstrap.api.Service;
+import org.jboss.weld.integration.vdf.DeploymentUnitAware;
/**
* Abstract JBoss Weld services.
@@ -13,7 +14,7 @@
* @author Pete Muir
* @author ales.justin at jboss.org
*/
-public class AbstractJBossServices implements Service
+public class AbstractJBossServices implements Service, DeploymentUnitAware
{
protected DeploymentUnit topLevelDeploymentUnit;
protected JBossEjb jbossEjb;
More information about the jboss-cvs-commits
mailing list