[jboss-cvs] JBossAS SVN: r66558 - in trunk: ejb3/src/main/org/jboss/annotation/ejb and 19 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Oct 30 05:07:08 EDT 2007
Author: wolfc
Date: 2007-10-30 05:07:07 -0400 (Tue, 30 Oct 2007)
New Revision: 66558
Added:
trunk/ejb3/src/main/org/jboss/ejb3/deployers/Ejb3Deployer.java
trunk/ejb3/src/main/org/jboss/injection/EJBRemoteHandler.java
trunk/ejb3/src/main/org/jboss/injection/InjectorFactory.java
Removed:
trunk/ejb3/src/resources/schema/
Modified:
trunk/ejb3/.classpath
trunk/ejb3/build-test.xml
trunk/ejb3/build.xml
trunk/ejb3/src/main/org/jboss/annotation/ejb/LocalHomeImpl.java
trunk/ejb3/src/main/org/jboss/annotation/ejb/RemoteHomeImpl.java
trunk/ejb3/src/main/org/jboss/annotation/security/RunAsPrincipalImpl.java
trunk/ejb3/src/main/org/jboss/annotation/security/SecurityDomainImpl.java
trunk/ejb3/src/main/org/jboss/ejb/RunAsImpl.java
trunk/ejb3/src/main/org/jboss/ejb3/EJBContainer.java
trunk/ejb3/src/main/org/jboss/ejb3/EJBContextImpl.java
trunk/ejb3/src/main/org/jboss/ejb3/Ejb3Deployment.java
trunk/ejb3/src/main/org/jboss/ejb3/Ejb3DescriptorHandler.java
trunk/ejb3/src/main/org/jboss/ejb3/Ejb3HandlerFactory.java
trunk/ejb3/src/main/org/jboss/ejb3/client/ClientContainer.java
trunk/ejb3/src/main/org/jboss/ejb3/client/ClientLauncher.java
trunk/ejb3/src/main/org/jboss/ejb3/clientmodule/ClientENCInjectionContainer.java
trunk/ejb3/src/main/org/jboss/ejb3/deployers/EJBRegistrationDeployer.java
trunk/ejb3/src/main/org/jboss/ejb3/deployers/EJBStage2Deployer.java
trunk/ejb3/src/main/org/jboss/ejb3/deployers/Ejb3JBoss5Deployment.java
trunk/ejb3/src/main/org/jboss/ejb3/interceptor/InterceptorInfo.java
trunk/ejb3/src/main/org/jboss/ejb3/interceptor/InterceptorInfoRepository.java
trunk/ejb3/src/main/org/jboss/ejb3/interceptor/InterceptorInjector.java
trunk/ejb3/src/main/org/jboss/ejb3/security/Ejb3AuthenticationInterceptor.java
trunk/ejb3/src/main/org/jboss/ejb3/security/Ejb3AuthenticationInterceptorv2.java
trunk/ejb3/src/main/org/jboss/ejb3/security/RunAsSecurityInterceptorFactory.java
trunk/ejb3/src/main/org/jboss/ejb3/session/BaseSessionProxyFactory.java
trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulInstanceInterceptor.java
trunk/ejb3/src/main/org/jboss/ejb3/tx/TxUtil.java
trunk/ejb3/src/main/org/jboss/injection/AbstractHandler.java
trunk/ejb3/src/main/org/jboss/injection/DependsHandler.java
trunk/ejb3/src/main/org/jboss/injection/EJBHandler.java
trunk/ejb3/src/main/org/jboss/injection/EJBInjectionHandler.java
trunk/ejb3/src/main/org/jboss/injection/InjectionContainer.java
trunk/ejb3/src/main/org/jboss/injection/InjectionHandler.java
trunk/ejb3/src/main/org/jboss/injection/InjectionUtil.java
trunk/ejb3/src/main/org/jboss/injection/JndiInjectHandler.java
trunk/ejb3/src/main/org/jboss/injection/PersistenceContextHandler.java
trunk/ejb3/src/main/org/jboss/injection/PersistenceUnitHandler.java
trunk/ejb3/src/main/org/jboss/injection/ResourceHandler.java
trunk/ejb3/src/main/org/jboss/injection/ServiceRefInjector.java
trunk/ejb3/src/main/org/jboss/injection/WebServiceRefHandler.java
trunk/ejb3/src/resources/META-INF/ejb3-deployers-beans.xml
trunk/ejb3/src/test/org/jboss/ejb3/test/appclient/unit/AppClientUnitTestCase.java
trunk/ejb3/src/test/org/jboss/ejb3/test/appclient/unit/SimpleResourceEarUnitTestCase.java
trunk/ejb3/src/test/org/jboss/ejb3/test/appclient/unit/SimpleResourceUnitTestCase.java
trunk/server/src/main/org/jboss/deployment/JBossEjbParsingDeployer.java
trunk/tomcat/.classpath
trunk/tomcat/src/main/org/jboss/web/tomcat/service/TomcatInjectionContainer.java
trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/TomcatDeployment.java
Log:
EJBTHREE-1067: refactored EJB 3 onto the new metadata
Modified: trunk/ejb3/.classpath
===================================================================
--- trunk/ejb3/.classpath 2007-10-30 06:40:04 UTC (rev 66557)
+++ trunk/ejb3/.classpath 2007-10-30 09:07:07 UTC (rev 66558)
@@ -23,7 +23,6 @@
<classpathentry kind="lib" path="/thirdparty/jboss/remoting/lib/jboss-remoting.jar"/>
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/security"/>
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/server"/>
- <classpathentry kind="lib" path="/thirdparty/hibernate-entitymanager/lib/ejb3-persistence.jar"/>
<classpathentry kind="lib" path="/thirdparty/sun-servlet/lib/servlet-api.jar"/>
<classpathentry kind="lib" path="/thirdparty/apache-httpclient/lib/commons-httpclient.jar"/>
<classpathentry kind="lib" path="/thirdparty/hibernate-entitymanager/lib/hibernate-entitymanager.jar"/>
@@ -62,6 +61,11 @@
<classpathentry kind="lib" path="/thirdparty/jboss/jboss-ejb3-cache/lib/jboss-ejb3-cache-0.11-SNAPSHOT.jar" sourcepath="/thirdparty/jboss/jboss-ejb3-cache/lib/jboss-ejb3-cache-0.11-SNAPSHOT-sources.jar"/>
<classpathentry kind="lib" path="/thirdparty/jboss/microcontainer/lib/jboss-managed.jar" sourcepath="/thirdparty/jboss/microcontainer/lib/jboss-managed-sources.jar"/>
<classpathentry kind="lib" path="/thirdparty/jboss/microcontainer/lib/jboss-metatype.jar" sourcepath="/thirdparty/jboss/microcontainer/lib/jboss-metatype-sources.jar"/>
- <classpathentry kind="lib" path="/thirdparty/jboss/metadata/lib/jboss-metadata.jar" sourcepath="/thirdparty/jboss/metadata/lib/jboss-metadata-sources.jar"/>
+ <classpathentry kind="lib" path="/thirdparty/jboss/metadata/lib/jboss-metadata.jar" sourcepath="/thirdparty/jboss/metadata/lib/jboss-metadata-sources.jar">
+ <accessrules>
+ <accessrule kind="discouraged" pattern="org/jboss/ejb3/**"/>
+ <accessrule kind="discouraged" pattern="org/jboss/metamodel/**"/>
+ </accessrules>
+ </classpathentry>
<classpathentry kind="output" path="output/eclipse-classes"/>
</classpath>
Modified: trunk/ejb3/build-test.xml
===================================================================
--- trunk/ejb3/build-test.xml 2007-10-30 06:40:04 UTC (rev 66557)
+++ trunk/ejb3/build-test.xml 2007-10-30 09:07:07 UTC (rev 66558)
@@ -159,6 +159,7 @@
<path refid="jboss.integration.classpath"/>
<path refid="jboss.jboss.ejb3.cache.classpath"/>
<path refid="jboss.metadata.classpath"/>
+ <path refid="sun.jaxb.classpath"/>
</path>
<!-- ======= -->
@@ -3856,7 +3857,6 @@
<path refid="hsqldb.hsqldb.classpath"/>
<!-- For JBossWS testing -->
- <path refid="sun.jaxb.classpath"/>
<pathelement path="${sun.jaxb.lib}/jaxb-impl.jar"/>
<path refid="ibm.wsdl4j.classpath"/>
</classpath>
Modified: trunk/ejb3/build.xml
===================================================================
--- trunk/ejb3/build.xml 2007-10-30 06:40:04 UTC (rev 66557)
+++ trunk/ejb3/build.xml 2007-10-30 09:07:07 UTC (rev 66558)
@@ -297,9 +297,6 @@
<exclude name="org/jboss/ejb3/test/**"/>
<exclude name="org/jboss/annotation/**"/>
</fileset>
- <fileset dir="${resources}">
- <include name="schema/*.xsd"/>
- </fileset>
</jar>
<!-- build hibernate-client.jar -->
Modified: trunk/ejb3/src/main/org/jboss/annotation/ejb/LocalHomeImpl.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/annotation/ejb/LocalHomeImpl.java 2007-10-30 06:40:04 UTC (rev 66557)
+++ trunk/ejb3/src/main/org/jboss/annotation/ejb/LocalHomeImpl.java 2007-10-30 09:07:07 UTC (rev 66558)
@@ -21,7 +21,6 @@
*/
package org.jboss.annotation.ejb;
-import java.lang.annotation.Annotation;
import javax.ejb.LocalHome;
/**
@@ -32,19 +31,19 @@
*/
public class LocalHomeImpl implements LocalHome
{
- private Class value;
+ private Class<?> value;
- public LocalHomeImpl(Class value)
+ public LocalHomeImpl(Class<?> value)
{
this.value = value;
}
- public Class value()
+ public Class<?> value()
{
return value;
}
- public Class<? extends Annotation> annotationType()
+ public Class<LocalHome> annotationType()
{
return LocalHome.class;
}
Modified: trunk/ejb3/src/main/org/jboss/annotation/ejb/RemoteHomeImpl.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/annotation/ejb/RemoteHomeImpl.java 2007-10-30 06:40:04 UTC (rev 66557)
+++ trunk/ejb3/src/main/org/jboss/annotation/ejb/RemoteHomeImpl.java 2007-10-30 09:07:07 UTC (rev 66558)
@@ -21,7 +21,6 @@
*/
package org.jboss.annotation.ejb;
-import java.lang.annotation.Annotation;
import javax.ejb.RemoteHome;
/**
@@ -32,19 +31,19 @@
*/
public class RemoteHomeImpl implements RemoteHome
{
- private Class value;
+ private Class<?> value;
- public RemoteHomeImpl(Class value)
+ public RemoteHomeImpl(Class<?> value)
{
this.value = value;
}
- public Class value()
+ public Class<?> value()
{
return value;
}
- public Class<? extends Annotation> annotationType()
+ public Class<RemoteHome> annotationType()
{
return RemoteHome.class;
}
Modified: trunk/ejb3/src/main/org/jboss/annotation/security/RunAsPrincipalImpl.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/annotation/security/RunAsPrincipalImpl.java 2007-10-30 06:40:04 UTC (rev 66557)
+++ trunk/ejb3/src/main/org/jboss/annotation/security/RunAsPrincipalImpl.java 2007-10-30 09:07:07 UTC (rev 66558)
@@ -21,8 +21,6 @@
*/
package org.jboss.annotation.security;
-import org.jboss.annotation.security.SecurityDomain;
-
/**
* // *
*
@@ -42,7 +40,7 @@
return value;
}
- public Class annotationType()
+ public Class<RunAsPrincipal> annotationType()
{
return org.jboss.annotation.security.RunAsPrincipal.class;
}
Modified: trunk/ejb3/src/main/org/jboss/annotation/security/SecurityDomainImpl.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/annotation/security/SecurityDomainImpl.java 2007-10-30 06:40:04 UTC (rev 66557)
+++ trunk/ejb3/src/main/org/jboss/annotation/security/SecurityDomainImpl.java 2007-10-30 09:07:07 UTC (rev 66558)
@@ -61,7 +61,7 @@
this.unauthenticatedPrincipal = unauthenticatedPrincipal;
}
- public Class<? extends Annotation> annotationType()
+ public Class<SecurityDomain> annotationType()
{
return org.jboss.annotation.security.SecurityDomain.class;
}
Modified: trunk/ejb3/src/main/org/jboss/ejb/RunAsImpl.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb/RunAsImpl.java 2007-10-30 06:40:04 UTC (rev 66557)
+++ trunk/ejb3/src/main/org/jboss/ejb/RunAsImpl.java 2007-10-30 09:07:07 UTC (rev 66558)
@@ -21,6 +21,8 @@
*/
package org.jboss.ejb;
+import javax.annotation.security.RunAs;
+
/**
* // *
*
@@ -41,7 +43,7 @@
return value;
}
- public Class annotationType()
+ public Class<RunAs> annotationType()
{
return javax.annotation.security.RunAs.class;
}
Modified: trunk/ejb3/src/main/org/jboss/ejb3/EJBContainer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/EJBContainer.java 2007-10-30 06:40:04 UTC (rev 66557)
+++ trunk/ejb3/src/main/org/jboss/ejb3/EJBContainer.java 2007-10-30 09:07:07 UTC (rev 66558)
@@ -74,8 +74,6 @@
import org.jboss.ejb3.javaee.JavaEEComponent;
import org.jboss.ejb3.javaee.JavaEEComponentHelper;
import org.jboss.ejb3.javaee.JavaEEModule;
-import org.jboss.ejb3.metamodel.AssemblyDescriptor;
-import org.jboss.ejb3.metamodel.EnterpriseBean;
import org.jboss.ejb3.security.JaccHelper;
import org.jboss.ejb3.security.SecurityDomainManager;
import org.jboss.ejb3.statistics.InvocationStatistics;
@@ -88,20 +86,18 @@
import org.jboss.injection.InjectionHandler;
import org.jboss.injection.InjectionUtil;
import org.jboss.injection.Injector;
-import org.jboss.injection.JndiInjectHandler;
import org.jboss.injection.PersistenceContextHandler;
import org.jboss.injection.PersistenceUnitHandler;
import org.jboss.injection.ResourceHandler;
import org.jboss.injection.WebServiceRefHandler;
import org.jboss.logging.Logger;
-import org.jboss.metadata.serviceref.VirtualFileAdaptor;
-import org.jboss.metamodel.descriptor.EnvironmentRefGroup;
-import org.jboss.metamodel.descriptor.ServiceRefDelegate;
+import org.jboss.metadata.ejb.jboss.JBossAssemblyDescriptorMetaData;
+import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
+import org.jboss.metadata.javaee.spec.Environment;
+import org.jboss.metadata.javaee.spec.ServiceReferenceMetaData;
import org.jboss.naming.Util;
import org.jboss.util.StringPropertyReplacer;
import org.jboss.virtual.VirtualFile;
-import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
-import org.jboss.wsf.spi.serviceref.ServiceRefMetaData;
/**
* Comment
@@ -140,8 +136,8 @@
protected Map<String, EncInjector> encInjectors = new HashMap<String, EncInjector>();
- protected EnterpriseBean xml;
- protected AssemblyDescriptor assembly;
+ protected JBossEnterpriseBeanMetaData xml;
+ protected JBossAssemblyDescriptorMetaData assembly;
protected Map<String, Map<AccessibleObject, Injector>> encInjections = new HashMap<String, Map<AccessibleObject, Injector>>();
@@ -306,7 +302,7 @@
encFactory.popEnc(this);
}
- public EnvironmentRefGroup getEnvironmentRefGroup()
+ public Environment getEnvironmentRefGroup()
{
return xml;
}
@@ -434,21 +430,21 @@
// XML must be done first so that any annotation overrides are initialized
// todo injection handlers should be pluggable from XML
- Collection<InjectionHandler> handlers = new ArrayList<InjectionHandler>();
- handlers.add(new EJBHandler());
- handlers.add(new DependsHandler());
- handlers.add(new JndiInjectHandler());
- handlers.add(new PersistenceContextHandler());
- handlers.add(new PersistenceUnitHandler());
- handlers.add(new ResourceHandler());
- handlers.add(new WebServiceRefHandler());
+ Collection<InjectionHandler<Environment>> handlers = new ArrayList<InjectionHandler<Environment>>();
+ handlers.add(new EJBHandler<Environment>());
+ handlers.add(new DependsHandler<Environment>());
+ //handlers.add(new JndiInjectHandler<JBossEnterpriseBeanMetaData>());
+ handlers.add(new PersistenceContextHandler<Environment>());
+ handlers.add(new PersistenceUnitHandler<Environment>());
+ handlers.add(new ResourceHandler<Environment>());
+ handlers.add(new WebServiceRefHandler<Environment>());
ClassLoader old = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(classloader);
try
{
// EJB container's XML must be processed before interceptor's as it may override interceptor's references
- for (InjectionHandler handler : handlers) handler.loadXml(xml, this);
+ for (InjectionHandler<Environment> handler : handlers) handler.loadXml(xml, this);
Map<AccessibleObject, Injector> tmp = InjectionUtil.processAnnotations(this, handlers, getBeanClass());
injectors.addAll(tmp.values());
@@ -456,7 +452,7 @@
initialiseInterceptors();
for (InterceptorInfo interceptorInfo : applicableInterceptors)
{
- for (InjectionHandler handler : handlers)
+ for (InjectionHandler<Environment> handler : handlers)
{
handler.loadXml(interceptorInfo.getXml(), this);
}
@@ -472,8 +468,10 @@
// In this case we process them late
if(xml!=null)
{
- for(ServiceRefMetaData sref : xml.getServiceRefs())
+ for(ServiceReferenceMetaData sref : xml.getServiceReferences())
{
+ // FIXME: fix WS metadata
+ /*
if(!sref.isProcessed())
{
try
@@ -491,6 +489,7 @@
log.error("Failed to bind service-ref", e);
}
}
+ */
}
}
@@ -555,22 +554,22 @@
}
}
- public EnterpriseBean getXml()
+ public JBossEnterpriseBeanMetaData getXml()
{
return xml;
}
- public void setXml(EnterpriseBean xml)
+ public void setXml(JBossEnterpriseBeanMetaData xml)
{
this.xml = xml;
}
- public AssemblyDescriptor getAssemblyDescriptor()
+ public JBossAssemblyDescriptorMetaData getAssemblyDescriptor()
{
return assembly;
}
- public void setAssemblyDescriptor(AssemblyDescriptor assembly)
+ public void setAssemblyDescriptor(JBossAssemblyDescriptorMetaData assembly)
{
this.assembly = assembly;
}
@@ -657,7 +656,7 @@
return beanClassName;
}
- public Class getBeanClass()
+ public Class<?> getBeanClass()
{
return clazz;
}
Modified: trunk/ejb3/src/main/org/jboss/ejb3/EJBContextImpl.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/EJBContextImpl.java 2007-10-30 06:40:04 UTC (rev 66557)
+++ trunk/ejb3/src/main/org/jboss/ejb3/EJBContextImpl.java 2007-10-30 09:07:07 UTC (rev 66558)
@@ -46,6 +46,8 @@
import org.jboss.ejb3.tx.TxUtil;
import org.jboss.ejb3.tx.UserTransactionImpl;
import org.jboss.logging.Logger;
+import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
+import org.jboss.metadata.javaee.spec.SecurityRoleRefMetaData;
import org.jboss.security.RealmMapping;
import org.jboss.security.RunAsIdentity;
import org.jboss.security.SecurityAssociation;
@@ -189,11 +191,12 @@
public boolean isCallerInRole(String roleName)
{
EJBContainer ejbc = (EJBContainer)container;
- Set roleRefs = new HashSet();
- EnterpriseBean eb = ejbc.getXml();
+ // TODO: this is to slow
+ Set<SecurityRoleRefMetaData> roleRefs = new HashSet<SecurityRoleRefMetaData>();
+ JBossEnterpriseBeanMetaData eb = ejbc.getXml();
if(eb != null)
{
- Collection srf = eb.getSecurityRoleRefs();
+ Collection<SecurityRoleRefMetaData> srf = eb.getSecurityRoleRefs();
if(srf != null)
roleRefs.addAll(srf);
}
Modified: trunk/ejb3/src/main/org/jboss/ejb3/Ejb3Deployment.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/Ejb3Deployment.java 2007-10-30 06:40:04 UTC (rev 66557)
+++ trunk/ejb3/src/main/org/jboss/ejb3/Ejb3Deployment.java 2007-10-30 09:07:07 UTC (rev 66558)
@@ -62,6 +62,7 @@
import org.jboss.ejb3.metamodel.JBossDDObjectFactory;
import org.jboss.ejb3.metamodel.MessageDestination;
import org.jboss.logging.Logger;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
import org.jboss.virtual.VirtualFile;
import org.jboss.xb.binding.JBossXBException;
@@ -462,7 +463,7 @@
protected void deployBeansFromLib(InitialContext ctx) throws Exception
{
- EjbJarDD dd = getMetaDataFomLib();
+ JBossMetaData dd = getMetaDataFomLib();
if (dd != null)
{
Ejb3DescriptorHandler handler = new Ejb3DescriptorHandler(this, dd);
@@ -489,11 +490,14 @@
}
}
- protected EjbJarDD getMetaDataFomLib() throws JBossXBException, IOException
+ protected JBossMetaData getMetaDataFomLib() throws JBossXBException, IOException
{
+ /*
EjbJarDD dd = EjbJarDDObjectFactory.parse(getDeploymentUnit().getEjbJarXml());
dd = JBossDDObjectFactory.parse(this.getDeploymentUnit().getJbossXml(), dd);
return dd;
+ */
+ throw new RuntimeException("NYI");
}
protected void deployElement(Ejb3HandlerFactory factory, ClassFile cf, InitialContext ctx) throws Exception
Modified: trunk/ejb3/src/main/org/jboss/ejb3/Ejb3DescriptorHandler.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/Ejb3DescriptorHandler.java 2007-10-30 06:40:04 UTC (rev 66557)
+++ trunk/ejb3/src/main/org/jboss/ejb3/Ejb3DescriptorHandler.java 2007-10-30 09:07:07 UTC (rev 66558)
@@ -24,6 +24,7 @@
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.lang.reflect.Member;
+import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
@@ -54,6 +55,7 @@
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;
import javax.ejb.TransactionManagement;
+import javax.ejb.TransactionManagementType;
import javax.interceptor.AroundInvoke;
import javax.interceptor.ExcludeClassInterceptors;
import javax.interceptor.ExcludeDefaultInterceptors;
@@ -132,44 +134,76 @@
import org.jboss.ejb.StatelessImpl;
import org.jboss.ejb.TransactionAttributeImpl;
import org.jboss.ejb.TransactionManagementImpl;
+import org.jboss.ejb3.cache.StatefulCache;
import org.jboss.ejb3.interceptor.InterceptorInfoRepository;
import org.jboss.ejb3.mdb.ConsumerContainer;
import org.jboss.ejb3.mdb.MDB;
import org.jboss.ejb3.mdb.ProducerImpl;
import org.jboss.ejb3.mdb.ProducersImpl;
-import org.jboss.ejb3.metamodel.ActivationConfig;
-import org.jboss.ejb3.metamodel.AssemblyDescriptor;
-import org.jboss.ejb3.metamodel.CacheConfig;
-import org.jboss.ejb3.metamodel.ClusterConfig;
-import org.jboss.ejb3.metamodel.ContainerTransaction;
-import org.jboss.ejb3.metamodel.EjbJarDD;
-import org.jboss.ejb3.metamodel.EnterpriseBean;
-import org.jboss.ejb3.metamodel.EnterpriseBeans;
-import org.jboss.ejb3.metamodel.ExcludeList;
-import org.jboss.ejb3.metamodel.GenericBean;
-import org.jboss.ejb3.metamodel.InitMethod;
-import org.jboss.ejb3.metamodel.InterceptorBinding;
-import org.jboss.ejb3.metamodel.MessageDestination;
-import org.jboss.ejb3.metamodel.MessageDrivenBean;
-import org.jboss.ejb3.metamodel.MessageDrivenDestination;
-import org.jboss.ejb3.metamodel.Method;
-import org.jboss.ejb3.metamodel.MethodAttributes;
-import org.jboss.ejb3.metamodel.MethodPermission;
-import org.jboss.ejb3.metamodel.PoolConfig;
-import org.jboss.ejb3.metamodel.RemoveMethod;
-import org.jboss.ejb3.metamodel.SecurityIdentity;
-import org.jboss.ejb3.metamodel.SessionEnterpriseBean;
-import org.jboss.ejb3.metamodel.XmlAnnotation;
import org.jboss.ejb3.remoting.RemoteProxyFactory;
import org.jboss.ejb3.service.ServiceContainer;
import org.jboss.ejb3.stateful.StatefulContainer;
import org.jboss.logging.Logger;
-import org.jboss.metamodel.descriptor.InjectionTarget;
-import org.jboss.metamodel.descriptor.MessageDestinationRef;
-import org.jboss.metamodel.descriptor.NameValuePair;
-import org.jboss.metamodel.descriptor.ResourceRef;
-import org.jboss.metamodel.descriptor.RunAs;
-import org.jboss.metamodel.descriptor.SecurityRole;
+import org.jboss.metadata.common.ejb.IEnterpriseBeanMetaData;
+import org.jboss.metadata.common.ejb.IEnterpriseBeansMetaData;
+import org.jboss.metadata.ejb.jboss.CacheConfigMetaData;
+import org.jboss.metadata.ejb.jboss.ClusterConfigMetaData;
+import org.jboss.metadata.ejb.jboss.CurrentMessageMetaData;
+import org.jboss.metadata.ejb.jboss.JBossAssemblyDescriptorMetaData;
+import org.jboss.metadata.ejb.jboss.JBossConsumerBeanMetaData;
+import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
+import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeansMetaData;
+import org.jboss.metadata.ejb.jboss.JBossGenericBeanMetaData;
+import org.jboss.metadata.ejb.jboss.JBossMessageDrivenBeanMetaData;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
+import org.jboss.metadata.ejb.jboss.JBossServiceBeanMetaData;
+import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
+import org.jboss.metadata.ejb.jboss.MessagePropertiesMetaData;
+import org.jboss.metadata.ejb.jboss.MethodAttributeMetaData;
+import org.jboss.metadata.ejb.jboss.MethodAttributesMetaData;
+import org.jboss.metadata.ejb.jboss.PoolConfigMetaData;
+import org.jboss.metadata.ejb.jboss.ProducerMetaData;
+import org.jboss.metadata.ejb.jboss.RemoteBindingMetaData;
+import org.jboss.metadata.ejb.jboss.ResourceManagerMetaData;
+import org.jboss.metadata.ejb.spec.ActivationConfigMetaData;
+import org.jboss.metadata.ejb.spec.ActivationConfigPropertyMetaData;
+import org.jboss.metadata.ejb.spec.AroundInvokeMetaData;
+import org.jboss.metadata.ejb.spec.AroundInvokesMetaData;
+import org.jboss.metadata.ejb.spec.AssemblyDescriptorMetaData;
+import org.jboss.metadata.ejb.spec.ContainerTransactionMetaData;
+import org.jboss.metadata.ejb.spec.EnterpriseBeanMetaData;
+import org.jboss.metadata.ejb.spec.EnterpriseBeansMetaData;
+import org.jboss.metadata.ejb.spec.ExcludeListMetaData;
+import org.jboss.metadata.ejb.spec.InitMethodMetaData;
+import org.jboss.metadata.ejb.spec.InitMethodsMetaData;
+import org.jboss.metadata.ejb.spec.InterceptorBindingMetaData;
+import org.jboss.metadata.ejb.spec.InterceptorBindingsMetaData;
+import org.jboss.metadata.ejb.spec.MessageDrivenBeanMetaData;
+import org.jboss.metadata.ejb.spec.MethodMetaData;
+import org.jboss.metadata.ejb.spec.MethodParametersMetaData;
+import org.jboss.metadata.ejb.spec.MethodPermissionMetaData;
+import org.jboss.metadata.ejb.spec.MethodPermissionsMetaData;
+import org.jboss.metadata.ejb.spec.NamedMethodMetaData;
+import org.jboss.metadata.ejb.spec.RemoveMethodMetaData;
+import org.jboss.metadata.ejb.spec.RemoveMethodsMetaData;
+import org.jboss.metadata.ejb.spec.SecurityIdentityMetaData;
+import org.jboss.metadata.ejb.spec.SessionBeanMetaData;
+import org.jboss.metadata.ejb.spec.SubscriptionDurability;
+import org.jboss.metadata.ejb.spec.TransAttributeType;
+import org.jboss.metadata.ejb.spec.TransactionType;
+import org.jboss.metadata.javaee.jboss.AnnotationMetaData;
+import org.jboss.metadata.javaee.jboss.AnnotationPropertyMetaData;
+import org.jboss.metadata.javaee.spec.LifecycleCallbackMetaData;
+import org.jboss.metadata.javaee.spec.LifecycleCallbacksMetaData;
+import org.jboss.metadata.javaee.spec.MessageDestinationMetaData;
+import org.jboss.metadata.javaee.spec.MessageDestinationReferenceMetaData;
+import org.jboss.metadata.javaee.spec.MessageDestinationReferencesMetaData;
+import org.jboss.metadata.javaee.spec.ResourceInjectionTargetMetaData;
+import org.jboss.metadata.javaee.spec.ResourceReferenceMetaData;
+import org.jboss.metadata.javaee.spec.ResourceReferencesMetaData;
+import org.jboss.metadata.javaee.spec.RunAsMetaData;
+import org.jboss.metadata.javaee.spec.SecurityRoleMetaData;
+import org.jboss.metadata.javaee.spec.SecurityRolesMetaData;
/**
* @version <tt>$Revision$</tt>
@@ -181,61 +215,81 @@
private static final Logger log = Logger
.getLogger(Ejb3DescriptorHandler.class);
- protected EjbJarDD dd;
+ protected JBossMetaData dd;
- protected List<EnterpriseBean> ejbs = new ArrayList<EnterpriseBean>();
+ protected List<JBossEnterpriseBeanMetaData> ejbs = new ArrayList<JBossEnterpriseBeanMetaData>();
- private static Class clazz;
-
- public Ejb3DescriptorHandler(Ejb3Deployment deployment, ClassFile cf,
- EjbJarDD dd)
+ public Ejb3DescriptorHandler(Ejb3Deployment deployment, ClassFile cf, JBossMetaData dd)
{
super(deployment, cf);
+ assert dd != null : "dd is null";
this.dd = dd;
}
- public Ejb3DescriptorHandler(Ejb3Deployment deployment, EjbJarDD dd)
+ public Ejb3DescriptorHandler(Ejb3Deployment deployment, JBossMetaData dd)
{
super(deployment);
+ assert dd != null : "dd is null";
this.dd = dd;
}
+ /**
+ * Find all enterprise beans using the given ejb class.
+ *
+ * @param dd the dd to search in
+ * @param className the ejb class to find
+ * @return a list of enterprise beans, never null
+ */
+ private List<JBossEnterpriseBeanMetaData> findEjbsByClass(JBossMetaData dd, String className)
+ {
+ assert dd != null : "dd is null";
+ assert className != null : "className is null";
+
+ List<JBossEnterpriseBeanMetaData> result = new ArrayList<JBossEnterpriseBeanMetaData>();
+
+ JBossEnterpriseBeansMetaData enterpriseBeans = dd.getEnterpriseBeans();
+ if(enterpriseBeans == null)
+ return result;
+
+ for(JBossEnterpriseBeanMetaData bean : enterpriseBeans)
+ {
+ if(bean.getEjbClass().equals(className))
+ result.add(bean);
+ }
+
+ return result;
+ }
+
public boolean isEjb()
{
if (super.isEjb())
return true;
- EnterpriseBeans enterpriseBeans = dd.getEnterpriseBeans();
-
+
+ JBossEnterpriseBeansMetaData enterpriseBeans = dd.getEnterpriseBeans();
if (enterpriseBeans == null)
{
return false;
}
- return enterpriseBeans.findEjbsByClass(cf.getName()).size() > 0;
-
+
+ return findEjbsByClass(dd, cf.getName()).size() > 0;
}
protected void populateBaseInfo() throws Exception
{
super.populateBaseInfo();
- EnterpriseBeans enterpriseBeans = (dd.getEnterpriseBeans() != null) ? dd
- .getEnterpriseBeans() : new EnterpriseBeans();
+ List<JBossEnterpriseBeanMetaData> ejbsByClass = findEjbsByClass(dd, cf.getName());
- List<EnterpriseBean> ejbsByClass = enterpriseBeans.findEjbsByClass(cf
- .getName());
-
for (int i = 0; i < ejbNames.size(); ++i)
{
String ejbNameFromAnnotation = ejbNames.get(i);
- EnterpriseBean enterpriseBean = enterpriseBeans
- .findEjbByEjbName(ejbNameFromAnnotation);
- ejbs.add(enterpriseBean);
+ ejbs.add(dd.getEnterpriseBean(ejbNameFromAnnotation));
boolean removed = false;
int j = 0;
while (!removed && j < ejbsByClass.size())
{
- EnterpriseBean ejbByClass = ejbsByClass.get(j);
+ JBossEnterpriseBeanMetaData ejbByClass = ejbsByClass.get(j);
if (ejbByClass.getEjbName().equals(ejbNameFromAnnotation))
{
ejbsByClass.remove(j);
@@ -244,58 +298,45 @@
}
}
- for (EnterpriseBean enterpriseBean : ejbsByClass)
+ for (JBossEnterpriseBeanMetaData enterpriseBean : ejbsByClass)
{
String ejbName = enterpriseBean.getEjbName();
ejbs.add(enterpriseBean);
ejbNames.add(ejbName);
-
- if (enterpriseBean.isSessionBean())
- {
- if (((SessionEnterpriseBean) enterpriseBean).isStateless())
- ejbType = EJB_TYPE.STATELESS;
- else
- ejbType = EJB_TYPE.STATEFUL;
- } else if (enterpriseBean.isEntityBean())
- ejbType = EJB_TYPE.ENTITY;
- else if (enterpriseBean.isMessageDrivenBean())
- ejbType = EJB_TYPE.MESSAGE_DRIVEN;
- else if (enterpriseBean.isService())
- ejbType = EJB_TYPE.SERVICE;
- else if (enterpriseBean.isConsumer())
- ejbType = EJB_TYPE.CONSUMER;
+
+ ejbType = getEjbType(enterpriseBean);
}
}
- protected EJB_TYPE getEjbType(EnterpriseBean enterpriseBean)
+ protected EJB_TYPE getEjbType(JBossEnterpriseBeanMetaData enterpriseBean)
{
- if (enterpriseBean.isSessionBean())
+ if (enterpriseBean.isSession())
{
- if (((SessionEnterpriseBean) enterpriseBean).isStateless())
+ if (((JBossSessionBeanMetaData) enterpriseBean).isStateless())
return EJB_TYPE.STATELESS;
else
return EJB_TYPE.STATEFUL;
- } else if (enterpriseBean.isEntityBean())
+ } else if (enterpriseBean.isEntity())
return EJB_TYPE.ENTITY;
- else if (enterpriseBean.isMessageDrivenBean())
+ else if (enterpriseBean.isMessageDriven())
return EJB_TYPE.MESSAGE_DRIVEN;
else if (enterpriseBean.isService())
return EJB_TYPE.SERVICE;
- else //if (enterpriseBean.isConsumer())
+ else if (enterpriseBean.isConsumer())
return EJB_TYPE.CONSUMER;
+ else
+ throw new IllegalStateException("unknown bean type encountered " + enterpriseBean);
}
- public List getContainers(Ejb3Deployment deployment, Map<String, Container> preexistingContainers) throws Exception
+ public List<Container> getContainers(Ejb3Deployment deployment, Map<String, Container> preexistingContainers) throws Exception
{
- List containers = new ArrayList();
+ List<Container> containers = new ArrayList<Container>();
- EnterpriseBeans enterpriseBeans = (dd.getEnterpriseBeans() != null) ? dd
- .getEnterpriseBeans() : new EnterpriseBeans();
-
- Collection<EnterpriseBean> allXmlEjbs = enterpriseBeans.getEnterpriseBeans();
+ JBossEnterpriseBeansMetaData allXmlEjbs = (dd.getEnterpriseBeans() != null) ? dd.getEnterpriseBeans() : new JBossEnterpriseBeansMetaData();
+
ejbNames = new ArrayList<String>();
- for (EnterpriseBean ejb : allXmlEjbs)
+ for (JBossEnterpriseBeanMetaData ejb : allXmlEjbs)
{
String ejbName = ejb.getEjbName();
if (preexistingContainers.get(ejbName) == null)
@@ -308,7 +349,7 @@
for (int ejbIndex = 0; ejbIndex < ejbNames.size(); ++ejbIndex)
{
String ejbName = ejbNames.get(ejbIndex);
- EnterpriseBean enterpriseBean = ejbs.get(ejbIndex);
+ JBossEnterpriseBeanMetaData enterpriseBean = ejbs.get(ejbIndex);
ejbType = getEjbType(enterpriseBean);
className = enterpriseBean.getEjbClass();
@@ -359,13 +400,13 @@
{
String ejbName = ejbNames.get(ejbIndex);
- EnterpriseBean enterpriseBean = ejbs.get(ejbIndex);
+ JBossEnterpriseBeanMetaData enterpriseBean = ejbs.get(ejbIndex);
StatefulContainer container = super.getStatefulContainer(ejbIndex);
container.setAssemblyDescriptor(dd.getAssemblyDescriptor());
- addInterfaces(container, enterpriseBean);
+ addInterfaces(container, (JBossSessionBeanMetaData) enterpriseBean);
addDescriptorAnnotations(container, enterpriseBean, ejbName, true);
@@ -373,19 +414,19 @@
}
private void addHomeAnnotations(EJBContainer container,
- EnterpriseBean enterpriseBean) throws Exception
+ JBossSessionBeanMetaData sessionBean) throws Exception
{
- if (enterpriseBean.getHome() != null)
+ if (sessionBean.getHome() != null)
{
- RemoteHome annotation = new RemoteHomeImpl(di.getClassLoader()
- .loadClass(enterpriseBean.getHome()));
+ RemoteHomeImpl annotation = new RemoteHomeImpl(di.getClassLoader()
+ .loadClass(sessionBean.getHome()));
addClassAnnotation(container, annotation.annotationType(), annotation);
}
- if (enterpriseBean.getLocalHome() != null)
+ if (sessionBean.getLocalHome() != null)
{
- LocalHome annotation = new LocalHomeImpl(di.getClassLoader()
- .loadClass(enterpriseBean.getLocalHome()));
+ LocalHomeImpl annotation = new LocalHomeImpl(di.getClassLoader()
+ .loadClass(sessionBean.getLocalHome()));
addClassAnnotation(container, annotation.annotationType(), annotation);
}
}
@@ -395,7 +436,7 @@
{
String ejbName = ejbNames.get(ejbIndex);
- EnterpriseBean enterpriseBean = ejbs.get(ejbIndex);
+ JBossEnterpriseBeanMetaData enterpriseBean = ejbs.get(ejbIndex);
EJBContainer container = super.getStatelessContainer(ejbIndex);
@@ -407,7 +448,7 @@
addClassAnnotation(container, Stateless.class, annotation);
}
- addInterfaces(container, enterpriseBean);
+ addInterfaces(container, (JBossSessionBeanMetaData) enterpriseBean);
addDescriptorAnnotations(container, enterpriseBean, ejbName);
@@ -419,8 +460,7 @@
{
String ejbName = ejbNames.get(ejbIndex);
- org.jboss.ejb3.metamodel.Service service = (org.jboss.ejb3.metamodel.Service) ejbs
- .get(ejbIndex);
+ JBossServiceBeanMetaData service = (JBossServiceBeanMetaData) ejbs.get(ejbIndex);
ServiceContainer container = super.getServiceContainer(ejbIndex);
ServiceImpl annotation = new ServiceImpl((Service) container
@@ -434,8 +474,8 @@
annotation.setObjectName(service.getObjectName());
if (service.getEjbName() != null)
annotation.setName(service.getEjbName());
- if (service.getXMBean() != null)
- annotation.setXMBean(service.getXMBean());
+ if (service.getXmbean() != null)
+ annotation.setXMBean(service.getXmbean());
addClassAnnotation(container, Service.class, annotation);
}
@@ -453,8 +493,7 @@
{
String ejbName = ejbNames.get(ejbIndex);
- org.jboss.ejb3.metamodel.Consumer consumer = (org.jboss.ejb3.metamodel.Consumer) ejbs
- .get(ejbIndex);
+ JBossConsumerBeanMetaData consumer = (JBossConsumerBeanMetaData) ejbs.get(ejbIndex);
ConsumerContainer container = super.getConsumerContainer(ejbIndex);
ConsumerImpl annotation = new ConsumerImpl((Consumer) container
@@ -464,24 +503,25 @@
if (consumer != null && !isAnnotatedBean())
{
- if (consumer.getDestination() != null)
+ if (consumer.getMessageDestination() != null)
{
ActivationConfigPropertyImpl property = new ActivationConfigPropertyImpl(
- "destination", consumer.getDestination());
+ "destination", consumer.getMessageDestination());
annotation.addActivationConfig(property);
}
- if (consumer.getDestinationType() != null)
+ if (consumer.getMessageDestinationType() != null)
{
ActivationConfigPropertyImpl property = new ActivationConfigPropertyImpl(
- "destinationType", consumer.getDestinationType());
+ "destinationType", consumer.getMessageDestinationType());
annotation.addActivationConfig(property);
}
addClassAnnotation(container, Consumer.class, annotation);
}
- addInterfaces(container, consumer);
+ // A consumer bean doesn't have any business interfaces
+ //addInterfaces(container, consumer);
addDescriptorAnnotations(container, consumer, ejbName);
@@ -499,24 +539,25 @@
{
String ejbName = ejbNames.get(ejbIndex);
- EnterpriseBean enterpriseBean = ejbs.get(ejbIndex);
+ JBossEnterpriseBeanMetaData enterpriseBean = ejbs.get(ejbIndex);
MDB container = super.getMDB(ejbIndex);
container.setAssemblyDescriptor(dd.getAssemblyDescriptor());
- if(enterpriseBean instanceof MessageDrivenBean)
- addMDBAnnotations(container, ejbName, (MessageDrivenBean) enterpriseBean);
- else if(enterpriseBean instanceof GenericBean)
+ if(enterpriseBean instanceof JBossMessageDrivenBeanMetaData)
+ addMDBAnnotations(container, ejbName, (JBossMessageDrivenBeanMetaData) enterpriseBean);
+ else if(enterpriseBean instanceof JBossGenericBeanMetaData)
{
// EJBTHREE-936: TODO: unsupported wickedness starts here
- MessageDrivenBean mdb = new MessageDrivenBean();
- mdb.setDestinationJndiName(enterpriseBean.getJndiName());
+ JBossMessageDrivenBeanMetaData mdb = new JBossMessageDrivenBeanMetaData();
+ mdb.setDestinationJndiName(enterpriseBean.getMappedName());
addMDBAnnotations(container, ejbName, mdb);
}
- addInterfaces(container, enterpriseBean);
+ // An MDB doesn't have business interfaces, or does it?
+ //addInterfaces(container, enterpriseBean);
addDescriptorAnnotations(container, enterpriseBean, ejbName);
@@ -525,7 +566,7 @@
protected String getAspectDomain(int ejbIndex, String defaultDomain)
{
- EnterpriseBean enterpriseBean = ejbs.get(ejbIndex);
+ JBossEnterpriseBeanMetaData enterpriseBean = ejbs.get(ejbIndex);
if (enterpriseBean != null)
{
String aopDomainName = enterpriseBean.getAopDomainName();
@@ -546,50 +587,40 @@
return super.isEjb() || super.isJBossBeanType();
}
- private void addMDBAnnotations(MDB container, String ejbName,
- MessageDrivenBean mdb)
+ private void addMDBAnnotations(MDB container, String ejbName, JBossMessageDrivenBeanMetaData mdb)
{
if (mdb != null)
{
ArrayList<ActivationConfigProperty> properties = new ArrayList<ActivationConfigProperty>();
if (mdb.getAcknowledgeMode() != null)
- properties.add(new ActivationConfigPropertyImpl("acknowledgeMode",
- mdb.getAcknowledgeMode()));
+ properties.add(new ActivationConfigPropertyImpl("acknowledgeMode", mdb.getAcknowledgeMode()));
- if (mdb.getMessageDrivenDestination() != null)
+ if(mdb.getMessageDestinationType() != null)
{
- MessageDrivenDestination destination = mdb
- .getMessageDrivenDestination();
- if (destination.getDestinationType() != null)
- properties.add(new ActivationConfigPropertyImpl(
- "destinationType", destination.getDestinationType()));
- if (destination.getSubscriptionDurability() != null)
- {
- String durable = "false";
- if (destination.getSubscriptionDurability().equals("Durable"))
- durable = "true";
- properties.add(new ActivationConfigPropertyImpl("subscriptionDurability",
- durable));
- if (destination.getSubscriptionDurability().equals("Durable"))
- properties.add(new ActivationConfigPropertyImpl(
- "subscriptionName", "subscriptionName"));
-
- }
+ properties.add(new ActivationConfigPropertyImpl("destinationType", mdb.getMessageDestinationType()));
}
-
- if (mdb.getResourceAdaptorName() != null)
+ SubscriptionDurability subscriptionDurability = mdb.getSubscriptionDurability();
+ if(subscriptionDurability != null)
{
- ResourceAdapter adapter = new ResourceAdapterImpl(mdb
- .getResourceAdaptorName());
+ String durable = "false";
+ if (subscriptionDurability.equals(SubscriptionDurability.Durable))
+ durable = "true";
+ properties.add(new ActivationConfigPropertyImpl("subscriptionDurability", durable));
+ if (subscriptionDurability.equals(SubscriptionDurability.Durable))
+ properties.add(new ActivationConfigPropertyImpl("subscriptionName", "subscriptionName"));
+ }
+
+ if (mdb.getResourceAdapterName() != null)
+ {
+ ResourceAdapter adapter = new ResourceAdapterImpl(mdb.getResourceAdapterName());
addClassAnnotation(container, ResourceAdapter.class, adapter);
}
- ActivationConfig activationConfig = mdb.getActivationConfig();
+ ActivationConfigMetaData activationConfig = mdb.getActivationConfig();
if (activationConfig != null)
{
- for (Object o : activationConfig.getActivationConfigProperties())
+ for (ActivationConfigPropertyMetaData property : activationConfig.getActivationConfigProperties())
{
- NameValuePair property = (NameValuePair) o;
properties.add(new ActivationConfigPropertyImpl(property
.getName(), property.getValue()));
}
@@ -659,15 +690,14 @@
}
}
- private void addDefaultActivationConfig(MDB container, MessageDrivenBean mdb)
+ private void addDefaultActivationConfig(MDB container, JBossMessageDrivenBeanMetaData mdb)
{
- ActivationConfig defaultActivationConfig = mdb.getDefaultActivationConfig();
+ ActivationConfigMetaData defaultActivationConfig = mdb.getDefaultActivationConfig();
if (defaultActivationConfig != null)
{
DefaultActivationSpecsImpl activationAnnotation = new DefaultActivationSpecsImpl();
- for (Object o : defaultActivationConfig.getActivationConfigProperties())
+ for (ActivationConfigPropertyMetaData property : defaultActivationConfig.getActivationConfigProperties())
{
- NameValuePair property = (NameValuePair) o;
activationAnnotation.addActivationConfigProperty(new ActivationConfigPropertyImpl(property
.getName(), property.getValue()));
}
@@ -680,8 +710,7 @@
}
}
- private void addInterfaces(EJBContainer container,
- EnterpriseBean enterpriseBean) throws ClassNotFoundException
+ private void addInterfaces(EJBContainer container, JBossSessionBeanMetaData enterpriseBean) throws ClassNotFoundException
{
if (enterpriseBean != null)
{
@@ -691,7 +720,7 @@
if (remote != null)
{
StringTokenizer classes = new StringTokenizer(remote, ",");
- ArrayList<Class> remoteClasses = new ArrayList<Class>();
+ List<Class<?>> remoteClasses = new ArrayList<Class<?>>();
while (classes.hasMoreTokens())
{
String token = classes.nextToken();
@@ -699,7 +728,7 @@
remoteClasses.add(di.getClassLoader().loadClass(classname));
}
- Class[] intfs = new Class[remoteClasses.size()];
+ Class<?>[] intfs = new Class[remoteClasses.size()];
intfs = remoteClasses.toArray(intfs);
addClassAnnotation(container, Remote.class, new RemoteImpl(intfs));
}
@@ -707,7 +736,7 @@
if (local != null)
{
StringTokenizer classes = new StringTokenizer(local, ",");
- ArrayList<Class> localClasses = new ArrayList<Class>();
+ List<Class<?>> localClasses = new ArrayList<Class<?>>();
while (classes.hasMoreTokens())
{
String token = classes.nextToken();
@@ -715,7 +744,7 @@
localClasses.add(di.getClassLoader().loadClass(classname));
}
- Class[] intfs = new Class[localClasses.size()];
+ Class<?>[] intfs = new Class[localClasses.size()];
intfs = localClasses.toArray(intfs);
addClassAnnotation(container, Local.class, new LocalImpl(intfs));
}
@@ -730,23 +759,22 @@
* @param ejbName
* @throws Exception
*/
- private void addDescriptorAnnotations(EJBContainer container, EnterpriseBean enterpriseBean, String ejbName) throws Exception
+ private void addDescriptorAnnotations(EJBContainer container, JBossEnterpriseBeanMetaData enterpriseBean, String ejbName) throws Exception
{
addDescriptorAnnotations(container, enterpriseBean, ejbName, false);
}
- private void addDescriptorAnnotations(EJBContainer container,
- EnterpriseBean enterpriseBean, String ejbName, boolean isStateful) throws Exception
+ private void addDescriptorAnnotations(EJBContainer container, JBossEnterpriseBeanMetaData enterpriseBean, String ejbName, boolean isStateful) throws Exception
{
// EJBTHREE-936: TODO: another wicked patch: jndi-name might mean local-jndi-name
// TODO: Make sure this is done after addInterfaces!
- if(enterpriseBean instanceof GenericBean)
+ if(enterpriseBean instanceof JBossGenericBeanMetaData)
{
Class<?>[] remoteAndBusinessRemoteInterfaces = ProxyFactoryHelper.getRemoteAndBusinessRemoteInterfaces(container);
if(remoteAndBusinessRemoteInterfaces.length == 0)
{
- enterpriseBean.setLocalJndiName(enterpriseBean.getJndiName());
- enterpriseBean.setJndiName(null);
+ enterpriseBean.setLocalJndiName(enterpriseBean.getMappedName());
+ enterpriseBean.setMappedName(null);
}
}
@@ -775,12 +803,12 @@
*/
private void addEjb21Annotations(EJBContainer container, boolean isStateful) throws Exception
{
- Class[] interfaces = ejbClass.getInterfaces();
- for (Class beanInterface : interfaces)
+ Class<?>[] interfaces = ejbClass.getInterfaces();
+ for (Class<?> beanInterface : interfaces)
{
if (beanInterface.equals(javax.ejb.SessionBean.class))
{
- Method method = new Method();
+ MethodMetaData method = new MethodMetaData();
method.setEjbName(container.getEjbName());
Annotation annotation;
@@ -826,9 +854,9 @@
}
private void addAssemblyAnnotations(EJBContainer container,
- EnterpriseBean enterpriseBean, String ejbName) throws Exception
+ JBossEnterpriseBeanMetaData enterpriseBean, String ejbName) throws Exception
{
- AssemblyDescriptor assembly = dd.getAssemblyDescriptor();
+ JBossAssemblyDescriptorMetaData assembly = dd.getAssemblyDescriptor();
if (assembly != null)
{
addExcludeAnnotations(container, assembly.getExcludeList(), ejbName);
@@ -836,25 +864,21 @@
addInterceptorBindingAnnotations(container, enterpriseBean, ejbName);
}
- if (enterpriseBean instanceof SessionEnterpriseBean)
+ if (enterpriseBean instanceof JBossSessionBeanMetaData)
{
- addInitAnnotations(container, ((SessionEnterpriseBean) enterpriseBean)
- .getInitMethods(), ejbName);
- addRemoveAnnotations(container,
- ((SessionEnterpriseBean) enterpriseBean).getRemoveMethods(),
- ejbName);
+ JBossSessionBeanMetaData sessionBean = (JBossSessionBeanMetaData) enterpriseBean;
+ addInitAnnotations(container, sessionBean.getInitMethods(), ejbName);
+ addRemoveAnnotations(container, sessionBean.getRemoveMethods(), ejbName);
}
}
- private void addExcludeAnnotations(EJBContainer container, ExcludeList list,
- String ejbName) throws ClassNotFoundException, NoSuchMethodException,
- NoSuchFieldException
+ private void addExcludeAnnotations(EJBContainer container, ExcludeListMetaData list, String ejbName)
+ throws ClassNotFoundException, NoSuchMethodException, NoSuchFieldException
{
if (list != null)
{
- for (Object o : list.getMethods())
+ for(MethodMetaData method : list.getMethods())
{
- Method method = (Method) o;
if (method.getEjbName().equals(ejbName))
{
DenyAllImpl annotation = new DenyAllImpl();
@@ -864,55 +888,49 @@
}
}
- private void addInitAnnotations(EJBContainer container,
- List<InitMethod> list, String ejbName) throws ClassNotFoundException,
- NoSuchMethodException, NoSuchFieldException
+ private void addInitAnnotations(EJBContainer container, InitMethodsMetaData list, String ejbName)
+ throws ClassNotFoundException, NoSuchMethodException, NoSuchFieldException
{
if (list != null)
{
- for (InitMethod initMethod : list)
+ for (InitMethodMetaData initMethod : list)
{
- Method method = initMethod.getBeanMethod();
+ NamedMethodMetaData method = initMethod.getBeanMethod();
InitImpl annotation = new InitImpl();
addAnnotations(Init.class, annotation, container, method);
}
}
}
- private void addRemoveAnnotations(EJBContainer container,
- List<RemoveMethod> list, String ejbName)
+ private void addRemoveAnnotations(EJBContainer container, RemoveMethodsMetaData list, String ejbName)
throws ClassNotFoundException, NoSuchMethodException,
NoSuchFieldException
{
if (list != null)
{
- for (RemoveMethod removeMethod : list)
+ for (RemoveMethodMetaData removeMethod : list)
{
- Method method = removeMethod.getBeanMethod();
- RemoveImpl annotation = new RemoveImpl(removeMethod
- .isRetainIfException());
+ NamedMethodMetaData method = removeMethod.getBeanMethod();
+ RemoveImpl annotation = new RemoveImpl(removeMethod.isRetainIfException());
addAnnotations(Remove.class, annotation, container, method);
}
}
}
- private void addSecurityAnnotations(EJBContainer container,
- EnterpriseBean enterpriseBean, String ejbName)
- throws ClassNotFoundException, NoSuchMethodException,
- NoSuchFieldException
+ private void addSecurityAnnotations(EJBContainer container, JBossEnterpriseBeanMetaData enterpriseBean, String ejbName)
+ throws ClassNotFoundException, NoSuchMethodException, NoSuchFieldException
{
- AssemblyDescriptor assembly = dd.getAssemblyDescriptor();
+ JBossAssemblyDescriptorMetaData assembly = dd.getAssemblyDescriptor();
if (assembly != null)
{
- List securityRoles = assembly.getSecurityRoles();
+ SecurityRolesMetaData securityRoles = assembly.getSecurityRoles();
if (securityRoles.size() > 0)
{
- ArrayList roleList = new ArrayList();
- for (Object securityRole : securityRoles)
+ List<String> roleList = new ArrayList<String>();
+ for (SecurityRoleMetaData securityRole : securityRoles)
{
- SecurityRole role = (SecurityRole) securityRole;
- roleList.add(role.getRoleName());
+ roleList.add(securityRole.getRoleName());
}
DeclareRolesImpl annotation = new DeclareRolesImpl(
@@ -920,30 +938,26 @@
addClassAnnotation(container, DeclareRoles.class, annotation);
}
- List methodPermissions = assembly.getMethodPermissions();
- for (Object methodPermission : methodPermissions)
+ MethodPermissionsMetaData methodPermissions = assembly.getMethodPermissions();
+ for (MethodPermissionMetaData permission : methodPermissions)
{
- MethodPermission permission = (MethodPermission) methodPermission;
- for (Method method : permission.getMethods())
+ for (MethodMetaData method : permission.getMethods())
{
if (method.getEjbName().equals(ejbName))
{
- if (permission.isUnchecked())
+ if (permission.isNotChecked())
{
PermitAllImpl annotation = new PermitAllImpl();
- addAnnotations(PermitAll.class, annotation, container,
- method);
+ addAnnotations(PermitAll.class, annotation, container, method);
} else
{
RolesAllowedImpl annotation = new RolesAllowedImpl();
- for (Object o : permission.getRoleNames())
+ for (String roleName : permission.getRoles())
{
- String roleName = (String) o;
annotation.addValue(roleName);
}
- addAnnotations(RolesAllowed.class, annotation, container,
- method);
+ addAnnotations(RolesAllowed.class, annotation, container, method);
}
}
}
@@ -992,67 +1006,43 @@
}
}
- private void addTransactionAnnotations(EJBContainer container,
- EnterpriseBean enterpriseBean, String ejbName)
- throws ClassNotFoundException, NoSuchMethodException,
- NoSuchFieldException
+ private void addTransactionAnnotations(EJBContainer container, JBossEnterpriseBeanMetaData enterpriseBean, String ejbName)
+ throws ClassNotFoundException, NoSuchMethodException, NoSuchFieldException
{
if (enterpriseBean != null)
{
- if (enterpriseBean.getTransactionManagementType() != null)
+ TransactionType transactionType = enterpriseBean.getTransactionType();
+ if (transactionType != null)
{
TransactionManagementImpl annotation = new TransactionManagementImpl();
- annotation.setValue(enterpriseBean.getTransactionManagementType());
- addClassAnnotation(container, TransactionManagement.class,
- annotation);
+ annotation.setValue(toSpec(transactionType));
+ addClassAnnotation(container, TransactionManagement.class, annotation);
}
- MethodAttributes attributes = enterpriseBean.getMethodAttributes();
+ MethodAttributesMetaData attributes = enterpriseBean.getMethodAttributes();
if (attributes != null)
{
- Iterator methods = attributes.getMethods().iterator();
- while (methods.hasNext())
+ for(MethodAttributeMetaData method : attributes)
{
- Method method = (Method) methods.next();
- if (method.getTransactionTimeout() != null)
- {
- TransactionTimeout timeoutAnnotation = new TransactionTimeoutImpl(
- Integer.parseInt(method.getTransactionTimeout()));
- addAnnotations(TransactionTimeout.class, timeoutAnnotation,
- container, method);
- }
+ TransactionTimeout timeoutAnnotation = new TransactionTimeoutImpl(method.getTransactionTimeout());
+ addAnnotations(TransactionTimeout.class, timeoutAnnotation, container, method.getMethodName(), null);
}
}
}
- AssemblyDescriptor descriptor = dd.getAssemblyDescriptor();
+ JBossAssemblyDescriptorMetaData descriptor = dd.getAssemblyDescriptor();
if (descriptor != null)
{
- Iterator transactions = descriptor.getContainerTransactions()
- .iterator();
- while (transactions.hasNext())
+ for(ContainerTransactionMetaData transaction : descriptor.getContainerTransactions())
{
- ContainerTransaction transaction = (ContainerTransaction) transactions
- .next();
- if (transaction.getMethod().getEjbName().equals(ejbName))
+ for(MethodMetaData method : transaction.getMethods())
{
- String transAttribute = transaction.getTransAttribute();
- TransactionAttributeImpl annotation = new TransactionAttributeImpl();
- if (transAttribute.equals("Mandatory"))
- annotation.setType(TransactionAttributeType.MANDATORY);
- else if (transAttribute.equals("Required"))
- annotation.setType(TransactionAttributeType.REQUIRED);
- else if (transAttribute.equals("RequiresNew"))
- annotation.setType(TransactionAttributeType.REQUIRES_NEW);
- else if (transAttribute.equals("Supports"))
- annotation.setType(TransactionAttributeType.SUPPORTS);
- else if (transAttribute.equals("NotSupported"))
- annotation.setType(TransactionAttributeType.NOT_SUPPORTED);
- else if (transAttribute.equals("Never"))
- annotation.setType(TransactionAttributeType.NEVER);
-
- addAnnotations(TransactionAttribute.class, annotation,
- container, transaction.getMethod());
+ if (method.getEjbName().equals(ejbName))
+ {
+ TransactionAttributeImpl annotation = new TransactionAttributeImpl();
+ annotation.setType(toSpec(transaction.getTransAttribute()));
+ addAnnotations(TransactionAttribute.class, annotation, container, method);
+ }
}
}
}
@@ -1063,15 +1053,14 @@
* merged
*/
private void addInterceptorBindingAnnotations(EJBContainer container,
- EnterpriseBean enterpriseBean, String ejbName)
+ JBossEnterpriseBeanMetaData enterpriseBean, String ejbName)
throws ClassNotFoundException, NoSuchMethodException,
NoSuchFieldException
{
boolean definesInterceptors = false;
- List<InterceptorBinding> interceptorBindings = dd.getAssemblyDescriptor()
- .getInterceptorBindings();
- for (InterceptorBinding binding : interceptorBindings)
+ InterceptorBindingsMetaData interceptorBindings = dd.getAssemblyDescriptor().getInterceptorBindings();
+ for (InterceptorBindingMetaData binding : interceptorBindings)
{
// Wolf: why ignore ordered binding?
/*
@@ -1082,12 +1071,12 @@
*/
if (binding.getEjbName().equals(ejbName))
{
- if (binding.getMethodName() == null
- || binding.getMethodName().trim().length() == 0)
+ if(binding.getMethod() == null)
{
addClassLevelInterceptorBindingAnnotations(container, binding);
definesInterceptors = true;
- } else
+ }
+ else
{
definesInterceptors = addMethodLevelInterceptorBindingAnnotations(
container, binding);
@@ -1109,7 +1098,7 @@
* merged
*/
private void addClassLevelInterceptorBindingAnnotations(
- EJBContainer container, InterceptorBinding binding)
+ EJBContainer container, InterceptorBindingMetaData binding)
throws ClassNotFoundException
{
Interceptors interceptors = (Interceptors) container
@@ -1117,13 +1106,13 @@
InterceptorsImpl impl = InterceptorsImpl.getImpl(interceptors);
for (String name : binding.getInterceptorClasses())
{
- Class clazz = di.getClassLoader().loadClass(name);
+ Class<?> clazz = di.getClassLoader().loadClass(name);
impl.addValue(clazz);
}
addClassAnnotation(container, impl.annotationType(), impl);
- boolean exclude = binding.getExcludeDefaultInterceptors();
+ boolean exclude = binding.isExcludeDefaultInterceptors();
if (exclude
&& container.resolveAnnotation(ExcludeDefaultInterceptors.class) == null)
{
@@ -1138,7 +1127,7 @@
* merged
*/
private boolean addMethodLevelInterceptorBindingAnnotations(
- EJBContainer container, InterceptorBinding binding)
+ EJBContainer container, InterceptorBindingMetaData binding)
throws ClassNotFoundException
{
boolean addedAnnotations = false;
@@ -1146,15 +1135,15 @@
.getMethods())
{
boolean matches = false;
- if (method.getName().equals(binding.getMethodName()))
+ if (method.getName().equals(binding.getMethod().getMethodName()))
{
- if (binding.getMethodParams() == null)
+ if (binding.getMethod().getMethodParams() == null)
{
matches = true;
} else
{
- Class[] methodParams = method.getParameterTypes();
- List<String> bindingParams = binding.getMethodParams();
+ Class<?>[] methodParams = method.getParameterTypes();
+ MethodParametersMetaData bindingParams = binding.getMethod().getMethodParams();
if (methodParams.length == bindingParams.size())
{
@@ -1181,7 +1170,7 @@
InterceptorsImpl impl = InterceptorsImpl.getImpl(interceptors);
for (String name : binding.getInterceptorClasses())
{
- Class clazz = di.getClassLoader().loadClass(name);
+ Class<?> clazz = di.getClassLoader().loadClass(name);
impl.addValue(clazz);
}
log.debug("adding " + Interceptors.class.getName()
@@ -1190,7 +1179,7 @@
container.getAnnotations().addAnnotation(method,
Interceptors.class, impl);
- boolean excludeDefault = binding.getExcludeDefaultInterceptors();
+ boolean excludeDefault = binding.isExcludeDefaultInterceptors();
if (excludeDefault
&& container.resolveAnnotation(method,
ExcludeDefaultInterceptors.class) == null)
@@ -1203,7 +1192,7 @@
new ExcludeDefaultInterceptorsImpl());
}
- boolean excludeClass = binding.getExcludeClassInterceptors();
+ boolean excludeClass = binding.isExcludeClassInterceptors();
if (excludeClass
&& container.resolveAnnotation(method,
ExcludeClassInterceptors.class) == null)
@@ -1224,22 +1213,24 @@
}
private void addEjbAnnotations(EJBContainer container,
- EnterpriseBean enterpriseBean) throws Exception
+ JBossEnterpriseBeanMetaData enterpriseBean) throws Exception
{
if (enterpriseBean != null)
{
- addHomeAnnotations(container, enterpriseBean);
+ if (enterpriseBean instanceof JBossSessionBeanMetaData)
+ {
+ addHomeAnnotations(container, (JBossSessionBeanMetaData) enterpriseBean);
+
+ addJndiAnnotations(container, (JBossSessionBeanMetaData) enterpriseBean);
+ }
- addJndiAnnotations(container, enterpriseBean);
-
addInterceptorMethodAnnotations(container, enterpriseBean);
- handleResourceRefs(container, enterpriseBean.getResourceRefs());
+ handleResourceRefs(container, enterpriseBean.getResourceReferences());
- addMessageDestinationAnnotations(container, enterpriseBean.getMessageDestinationRefs());
+ addMessageDestinationAnnotations(container, enterpriseBean.getMessageDestinationReferences());
- addSecurityIdentityAnnotation(container, enterpriseBean
- .getSecurityIdentity());
+ addSecurityIdentityAnnotation(container, enterpriseBean.getSecurityIdentity());
addDependencies(container, enterpriseBean);
@@ -1247,22 +1238,21 @@
addXmlAnnotations(container, enterpriseBean);
- if (enterpriseBean instanceof SessionEnterpriseBean)
+ if (enterpriseBean instanceof JBossSessionBeanMetaData)
{
- addConcurrentAnnotations(container, (SessionEnterpriseBean)enterpriseBean);
- addClusterAnnotations(container, (SessionEnterpriseBean)enterpriseBean);
- addCacheAnnotations(container, (SessionEnterpriseBean)enterpriseBean);
+ addConcurrentAnnotations(container, (JBossSessionBeanMetaData)enterpriseBean);
+ addClusterAnnotations(container, (JBossSessionBeanMetaData)enterpriseBean);
+ addCacheAnnotations(container, (JBossSessionBeanMetaData)enterpriseBean);
}
}
}
private void addConcurrentAnnotations(EJBContainer container,
- SessionEnterpriseBean enterpriseBean) throws Exception
+ JBossSessionBeanMetaData enterpriseBean) throws Exception
{
- if (enterpriseBean.getConcurrent() != null)
+ if (enterpriseBean.isConcurrent() != null)
{
- boolean concurrent = Boolean.getBoolean(enterpriseBean.getConcurrent());
- if (concurrent)
+ if (enterpriseBean.isConcurrent())
{
SerializedConcurrentAccessImpl annotation = new SerializedConcurrentAccessImpl();
addClassAnnotation(container, SerializedConcurrentAccess.class, annotation);
@@ -1275,11 +1265,11 @@
}
private void addPoolAnnotations(EJBContainer container,
- EnterpriseBean enterpriseBean) throws Exception
+ JBossEnterpriseBeanMetaData enterpriseBean) throws Exception
{
if (enterpriseBean.getPoolConfig() != null)
{
- PoolConfig config = enterpriseBean.getPoolConfig();
+ PoolConfigMetaData config = enterpriseBean.getPoolConfig();
PoolClassImpl poolAnnotation = new PoolClassImpl();
@@ -1287,33 +1277,30 @@
poolAnnotation.setValue(di.getClassLoader().loadClass(config.getPoolClass()));
if (config.getMaxSize() != null)
- poolAnnotation.setMaxSize(Integer.parseInt(config.getMaxSize()));
+ poolAnnotation.setMaxSize(config.getMaxSize());
if (config.getTimeout() != null)
- poolAnnotation.setTimeout(Long.parseLong(config.getTimeout()));
+ poolAnnotation.setTimeout(config.getTimeout());
addClassAnnotation(container, PoolClass.class, poolAnnotation);
}
}
private void addXmlAnnotations(EJBContainer container,
- EnterpriseBean enterpriseBean) throws Exception
+ JBossEnterpriseBeanMetaData enterpriseBean) throws Exception
{
- Iterator xmlAnnotations = enterpriseBean.getXmlAnnotations().iterator();
- while (xmlAnnotations.hasNext())
+ for(AnnotationMetaData xmlAnnotation: enterpriseBean.getAnnotations())
{
- XmlAnnotation xmlAnnotation = (XmlAnnotation)xmlAnnotations.next();
-
- Class annotationClass = di.getClassLoader().loadClass(xmlAnnotation.getAnnotationClass());
- Class annotationImplementationClass = di.getClassLoader().loadClass(xmlAnnotation.getAnnotationImplementationClass());
- Object annotation = annotationImplementationClass.newInstance();
+ Class<? extends Annotation> annotationClass = (Class<? extends Annotation>) di.getClassLoader().loadClass(xmlAnnotation.getAnnotationClass());
+ Class<? extends Annotation> annotationImplementationClass = (Class<? extends Annotation>) di.getClassLoader().loadClass(xmlAnnotation.getAnnotationImplementationClass());
+ Annotation annotation = annotationImplementationClass.newInstance();
- Iterator properties = xmlAnnotation.getProperties().iterator();
+ Iterator<AnnotationPropertyMetaData> properties = xmlAnnotation.getProperties().iterator();
while (properties.hasNext())
{
- NameValuePair property = (NameValuePair)properties.next();
+ AnnotationPropertyMetaData property = properties.next();
Field field = annotationImplementationClass.getDeclaredField(property.getName());
- setAnnotationPropertyField(field, annotation, property.getValue());
+ setAnnotationPropertyField(field, annotation, property.getPropertyValue());
}
if (xmlAnnotation.getInjectionTarget() == null)
@@ -1322,8 +1309,8 @@
}
else
{
- Method method = new Method();
- method.setMethodName(xmlAnnotation.getInjectionTarget().getTargetName());
+ MethodMetaData method = new MethodMetaData();
+ method.setMethodName(xmlAnnotation.getInjectionTarget().getInjectionTargetName());
addAnnotations(annotationClass, annotation, container, method);
}
}
@@ -1341,20 +1328,23 @@
field.set(annotation, di.getClassLoader().loadClass(value));
else if (field.getType() == Boolean.class)
field.setBoolean(annotation, Boolean.parseBoolean(value));
+ else
+ throw new IllegalArgumentException("unsupported field type " + field.getType() + " on field " + field);
}
private void addCacheAnnotations(EJBContainer container,
- SessionEnterpriseBean enterpriseBean) throws Exception
+ JBossSessionBeanMetaData enterpriseBean) throws Exception
{
if (enterpriseBean.getCacheConfig() != null)
{
- CacheConfig config = enterpriseBean.getCacheConfig();
+ CacheConfigMetaData config = enterpriseBean.getCacheConfig();
if (config.getCacheClass() != null)
{
- Class cacheClass = di.getClassLoader().loadClass(config.getCacheClass());
+ Class<? extends StatefulCache> cacheClass = (Class<? extends StatefulCache>) di.getClassLoader().loadClass(config.getCacheClass());
CacheImpl cacheAnnotation = new CacheImpl(cacheClass);
addClassAnnotation(container, Cache.class, cacheAnnotation);
+ // FIXME: Wolf: what the hell is this?
if (cacheClass == org.jboss.ejb3.cache.simple.SimpleStatefulCache.class)
{
if (!ejbClass.isAnnotationPresent(PersistenceManager.class))
@@ -1374,16 +1364,16 @@
configAnnotation.setName(config.getName());
if (config.getMaxSize() != null)
- configAnnotation.setMaxSize(Integer.parseInt(config.getMaxSize()));
+ configAnnotation.setMaxSize(config.getMaxSize());
if (config.getIdleTimeoutSeconds() != null)
- configAnnotation.setIdleTimeoutSeconds(Long.parseLong(config.getIdleTimeoutSeconds()));
+ configAnnotation.setIdleTimeoutSeconds(config.getIdleTimeoutSeconds());
if (config.getReplicationIsPassivation() != null)
configAnnotation.setReplicationIsPassivation(Boolean.parseBoolean(config.getReplicationIsPassivation()));
if (config.getRemoveTimeoutSeconds() != null)
- configAnnotation.setRemovalTimeoutSeconds(Long.parseLong(config.getRemoveTimeoutSeconds()));
+ configAnnotation.setRemovalTimeoutSeconds(config.getRemoveTimeoutSeconds());
org.jboss.annotation.ejb.cache.tree.CacheConfig existingConfig = (org.jboss.annotation.ejb.cache.tree.CacheConfig)ejbClass.getAnnotation(org.jboss.annotation.ejb.cache.tree.CacheConfig.class);
if (existingConfig != null)
@@ -1396,13 +1386,13 @@
org.jboss.annotation.ejb.cache.simple.CacheConfigImpl configAnnotation = new org.jboss.annotation.ejb.cache.simple.CacheConfigImpl();
if (config.getMaxSize() != null)
- configAnnotation.setMaxSize(Integer.parseInt(config.getMaxSize()));
+ configAnnotation.setMaxSize(config.getMaxSize());
if (config.getIdleTimeoutSeconds() != null)
- configAnnotation.setIdleTimeoutSeconds(Long.parseLong(config.getIdleTimeoutSeconds()));
+ configAnnotation.setIdleTimeoutSeconds(config.getIdleTimeoutSeconds());
if (config.getRemoveTimeoutSeconds() != null)
- configAnnotation.setRemovalTimeoutSeconds(Long.parseLong(config.getRemoveTimeoutSeconds()));
+ configAnnotation.setRemovalTimeoutSeconds(config.getRemoveTimeoutSeconds());
org.jboss.annotation.ejb.cache.simple.CacheConfig existingConfig = (org.jboss.annotation.ejb.cache.simple.CacheConfig)ejbClass.getAnnotation(org.jboss.annotation.ejb.cache.simple.CacheConfig.class);
if (existingConfig != null)
@@ -1415,60 +1405,44 @@
}
private void addClusterAnnotations(EJBContainer container,
- SessionEnterpriseBean enterpriseBean) throws Exception
+ JBossSessionBeanMetaData enterpriseBean) throws Exception
{
- ClusteredImpl clusteredAnnotation = null;
-
- if (enterpriseBean.getClustered() != null)
+ if (!enterpriseBean.isClustered())
{
- Clustered existingAnnotation = (Clustered)ejbClass.getAnnotation(Clustered.class);
-
- boolean clustered = Boolean.parseBoolean(enterpriseBean.getClustered());
- if (!clustered)
- {
- if (existingAnnotation != null)
- container.getAnnotations().disableAnnotation(Clustered.class.getName());
-
- return;
- }
- else
- {
- if (existingAnnotation == null)
- clusteredAnnotation = new ClusteredImpl();
- }
+ // ask directly, not the container (metadata setup in progress)
+ Clustered existingAnnotation = (Clustered) ejbClass.getAnnotation(Clustered.class);
+ if (existingAnnotation != null)
+ container.getAnnotations().disableAnnotation(Clustered.class.getName());
+ return;
}
- ClusterConfig config = enterpriseBean.getClusterConfig();
+ ClusterConfigMetaData config = enterpriseBean.getClusterConfig();
if (config != null)
{
- if (clusteredAnnotation == null)
- clusteredAnnotation = new ClusteredImpl();
-
- if (config.getLoadBalancePolicy() != null)
+ ClusteredImpl clusteredAnnotation = new ClusteredImpl();;
+
+ if (config.getBeanLoadBalancingPolicy() != null)
{
- Class policy = di.getClassLoader().loadClass(config.getLoadBalancePolicy());
+ Class<?> policy = di.getClassLoader().loadClass(config.getBeanLoadBalancingPolicy());
clusteredAnnotation.setLoadBalancePolicy(policy);
}
- if (config.getPartition() != null)
+ if (config.getPartitionName() != null)
{
- clusteredAnnotation.setPartition(config.getPartition());
+ clusteredAnnotation.setPartition(config.getPartitionName());
}
- }
-
- if (clusteredAnnotation != null)
- {
+
addClassAnnotation(container, Clustered.class, clusteredAnnotation);
}
}
private void addDependencies(EJBContainer container,
- EnterpriseBean enterpriseBean) throws Exception
+ JBossEnterpriseBeanMetaData enterpriseBean) throws Exception
{
- if (enterpriseBean.getDependencies().size() > 0)
+ if (enterpriseBean.getDepends().size() > 0)
{
DependsImpl annotation = new DependsImpl();
- Iterator<String> dependencies = enterpriseBean.getDependencies()
+ Iterator<String> dependencies = enterpriseBean.getDepends()
.iterator();
while (dependencies.hasNext())
{
@@ -1478,27 +1452,23 @@
addClassAnnotation(container, Depends.class, annotation);
}
- if (enterpriseBean.getIgnoreDependencies().size() > 0)
+ if (enterpriseBean.getIgnoreDependency() != null)
{
- Iterator<InjectionTarget> ignores = enterpriseBean.getIgnoreDependencies().iterator();
- while (ignores.hasNext())
+ for(ResourceInjectionTargetMetaData ignore : enterpriseBean.getIgnoreDependency().getInjectionTargets())
{
- InjectionTarget ignore = ignores.next();
IgnoreDependencyImpl annotation = new IgnoreDependencyImpl();
- Method method = new Method();
- method.setMethodName(ignore.getTargetName());
+ MethodMetaData method = new MethodMetaData();
+ method.setMethodName(ignore.getInjectionTargetName());
addAnnotations(IgnoreDependency.class, annotation, container, method);
}
}
}
- private void addServiceAnnotations(EJBContainer container, EnterpriseBean ejb)
+ private void addServiceAnnotations(EJBContainer container, JBossServiceBeanMetaData service)
throws ClassNotFoundException
{
- org.jboss.ejb3.metamodel.Service service = (org.jboss.ejb3.metamodel.Service) ejb;
-
if (service == null)
return;
@@ -1506,18 +1476,15 @@
if (management != null)
{
- ManagementImpl annotation = new ManagementImpl(di.getClassLoader()
- .loadClass(management));
+ ManagementImpl annotation = new ManagementImpl(di.getClassLoader().loadClass(management));
addClassAnnotation(container, Management.class, annotation);
}
}
private void addConsumerAnnotations(EJBContainer container,
- EnterpriseBean ejb) throws ClassNotFoundException,
+ JBossConsumerBeanMetaData consumer) throws ClassNotFoundException,
NoSuchFieldException, NoSuchMethodException
{
- org.jboss.ejb3.metamodel.Consumer consumer = (org.jboss.ejb3.metamodel.Consumer) ejb;
-
if (consumer == null)
return;
@@ -1526,11 +1493,8 @@
{
ProducersImpl producersAnnotation = new ProducersImpl();
- Iterator producers = consumer.getProducers().iterator();
- while (producers.hasNext())
+ for(ProducerMetaData producer : consumer.getProducers())
{
- org.jboss.ejb3.metamodel.Producer producer = (org.jboss.ejb3.metamodel.Producer) producers
- .next();
ProducerImpl annotation = new ProducerImpl(di.getClassLoader()
.loadClass(producer.getClassName()));
if (producer.getConnectionFactory() != null)
@@ -1538,11 +1502,8 @@
producersAnnotation.addProducer(annotation);
}
- producers = consumer.getLocalProducers().iterator();
- while (producers.hasNext())
+ for(ProducerMetaData producer : consumer.getLocalProducers())
{
- org.jboss.ejb3.metamodel.Producer producer = (org.jboss.ejb3.metamodel.Producer) producers
- .next();
ProducerImpl annotation = new ProducerImpl(di.getClassLoader()
.loadClass(producer.getClassName()));
if (producer.getConnectionFactory() != null)
@@ -1552,62 +1513,56 @@
addClassAnnotation(container, Producers.class, producersAnnotation);
}
- org.jboss.ejb3.metamodel.CurrentMessage currentMessage = consumer
+ MethodAttributesMetaData currentMessage = consumer
.getCurrentMessage();
if (currentMessage != null)
{
- List methods = currentMessage.getMethods();
CurrentMessageImpl annotation = new CurrentMessageImpl();
- for (int i = 0; i < methods.size(); ++i)
+ for(MethodAttributeMetaData method : currentMessage)
{
- Method method = (Method) methods.get(i);
addAnnotations(CurrentMessage.class, annotation, container, method);
}
}
- org.jboss.ejb3.metamodel.MessageProperties properties = consumer
- .getMessageProperties();
- if (properties != null)
+ List<MessagePropertiesMetaData> propertiesList = consumer.getMessageProperties();
+ if (propertiesList != null)
{
- List methods = properties.getMethods();
-
- MessagePropertiesImpl annotation = new MessagePropertiesImpl();
-
- String delivery = properties.getDelivery();
- if (delivery != null && delivery.equals("Persistent"))
- annotation.setDelivery(DeliveryMode.PERSISTENT);
- else
- annotation.setDelivery(DeliveryMode.NON_PERSISTENT);
-
- String priority = properties.getPriority();
- if (priority != null)
- annotation.setDelivery(DeliveryMode.PERSISTENT);
-
- String interfac = properties.getClassName();
- if (interfac != null)
+ for(MessagePropertiesMetaData properties : propertiesList)
{
- Class clazz = di.getClassLoader().loadClass(interfac);
- annotation.setInterface(clazz);
+ MessagePropertiesImpl annotation = new MessagePropertiesImpl();
+
+ String delivery = properties.getDelivery();
+ if (delivery != null && delivery.equals("Persistent"))
+ annotation.setDelivery(DeliveryMode.PERSISTENT);
+ else
+ annotation.setDelivery(DeliveryMode.NON_PERSISTENT);
+
+ Integer priority = properties.getPriority();
+ if (priority != null)
+ annotation.setDelivery(DeliveryMode.PERSISTENT);
+
+ String interfac = properties.getClassName();
+ if (interfac != null)
+ {
+ Class clazz = di.getClassLoader().loadClass(interfac);
+ annotation.setInterface(clazz);
+ }
+
+ MethodAttributeMetaData method = properties.getMethod();
+ addAnnotations(MessageProperties.class, annotation, container, method);
}
-
- for (int i = 0; i < methods.size(); ++i)
- {
- Method method = (Method) methods.get(i);
- addAnnotations(MessageProperties.class, annotation, container,
- method);
- }
}
}
private void addJndiAnnotations(EJBContainer container,
- EnterpriseBean enterpriseBean) throws ClassNotFoundException
+ JBossSessionBeanMetaData enterpriseBean) throws ClassNotFoundException
{
addLocalJndiAnnotations(container, enterpriseBean);
addRemoteJndiAnnotations(container, enterpriseBean);
}
private void addLocalJndiAnnotations(EJBContainer container,
- EnterpriseBean enterpriseBean) throws ClassNotFoundException
+ JBossSessionBeanMetaData enterpriseBean) throws ClassNotFoundException
{
String localJndiName = enterpriseBean.getLocalJndiName();
if (localJndiName != null)
@@ -1625,16 +1580,16 @@
}
private void addRemoteJndiAnnotations(EJBContainer container,
- EnterpriseBean enterpriseBean) throws ClassNotFoundException
+ JBossSessionBeanMetaData enterpriseBean) throws ClassNotFoundException
{
- String homeJndiName = enterpriseBean.getHomeJndiName();
- if (homeJndiName != null)
+ String homeJndiName = enterpriseBean.getHomeJndiName();
+ if (homeJndiName != null)
{
RemoteHomeBindingImpl homeBinding = new RemoteHomeBindingImpl(homeJndiName);
addClassAnnotation(container, RemoteHomeBinding.class, homeBinding);
}
-
- List<org.jboss.ejb3.metamodel.RemoteBinding> bindingsList = enterpriseBean.getRemoteBindings();
+
+ List<RemoteBindingMetaData> bindingsList = enterpriseBean.getRemoteBindings();
if (bindingsList.size() == 0)
{
addSimpleJndiAnnotations(container, enterpriseBean);
@@ -1645,12 +1600,10 @@
annotations.disableAnnotation(RemoteBinding.class.getName());
- List<RemoteBindingImpl> bindingAnnotationsList = new ArrayList();
+ List<RemoteBindingImpl> bindingAnnotationsList = new ArrayList<RemoteBindingImpl>();
- Iterator bindings = bindingsList.iterator();
- while(bindings.hasNext())
+ for(RemoteBindingMetaData binding : bindingsList)
{
- org.jboss.ejb3.metamodel.RemoteBinding binding = (org.jboss.ejb3.metamodel.RemoteBinding)bindings.next();
RemoteBindingImpl bindingAnnotation = new RemoteBindingImpl();
if (binding.getJndiName() != null)
@@ -1674,11 +1627,11 @@
}
private void addSimpleJndiAnnotations(EJBContainer container,
- EnterpriseBean enterpriseBean) throws ClassNotFoundException
+ JBossEnterpriseBeanMetaData enterpriseBean) throws ClassNotFoundException
{
RemoteBindingImpl remoteBinding = null;
- String jndiName = enterpriseBean.getJndiName();
+ String jndiName = enterpriseBean.getMappedName();
if (jndiName != null)
{
remoteBinding = new RemoteBindingImpl();
@@ -1696,39 +1649,34 @@
}
}
- private void handleResourceRefs(EJBContainer container,
- Collection<ResourceRef> resourceRefList)
+ private void handleResourceRefs(EJBContainer container, ResourceReferencesMetaData resourceRefList)
{
- Iterator refs = resourceRefList.iterator();
- while (refs.hasNext())
+ for(ResourceReferenceMetaData ref : resourceRefList)
{
- ResourceRef ref = (ResourceRef) refs.next();
-
if (ref.getResourceName() != null)
{
// for <resource-manager>
- ref.setJndiName(dd.resolveResourceManager(ref.getResourceName()));
- ref.setMappedName(dd.resolveResourceManager(ref.getResourceName()));
+ ResourceManagerMetaData resourceManager = dd.getResourceManager(ref.getResourceName());
+ if(resourceManager != null)
+ {
+ ref.setJndiName(resourceManager.getResJndiName());
+ ref.setMappedName(resourceManager.getResJndiName());
+ }
}
}
}
- private void addMessageDestinationAnnotations(EJBContainer container,
- Collection destinationRefList)
+ private void addMessageDestinationAnnotations(EJBContainer container, MessageDestinationReferencesMetaData refs)
{
- Iterator refs = destinationRefList.iterator();
- while (refs.hasNext())
+ for(MessageDestinationReferenceMetaData ref : refs)
{
- MessageDestinationRef ref = (MessageDestinationRef) refs.next();
-
if (ref.getMappedName() == null || ref.getMappedName().equals(""))
{
- AssemblyDescriptor descriptor = dd.getAssemblyDescriptor();
+ JBossAssemblyDescriptorMetaData descriptor = dd.getAssemblyDescriptor();
if (descriptor != null)
{
- MessageDestination destination = descriptor
- .findMessageDestination(ref.getMessageDestinationLink());
+ MessageDestinationMetaData destination = descriptor.getMessageDestination(ref.getLink());
if (destination != null)
{
ref.setMappedName(destination.getJndiName());
@@ -1739,50 +1687,48 @@
}
private void addInterceptorMethodAnnotations(EJBContainer container,
- EnterpriseBean enterpriseBean)
+ JBossEnterpriseBeanMetaData enterpriseBean)
{
- if (enterpriseBean instanceof SessionEnterpriseBean)
+ if (enterpriseBean instanceof JBossSessionBeanMetaData)
{
+ JBossSessionBeanMetaData sessionBean = (JBossSessionBeanMetaData) enterpriseBean;
addInterceptorMethodAnnotation(container, enterpriseBean,
- ((SessionEnterpriseBean) enterpriseBean).getAroundInvoke(),
+ sessionBean.getAroundInvokes(),
AroundInvoke.class, "around-invoke-method");
addInterceptorMethodAnnotation(container, enterpriseBean,
- ((SessionEnterpriseBean) enterpriseBean).getPostConstruct(),
+ sessionBean.getPostConstructs(),
PostConstruct.class, "post-construct-method");
addInterceptorMethodAnnotation(container, enterpriseBean,
- ((SessionEnterpriseBean) enterpriseBean).getPostActivate(),
+ sessionBean.getPostActivates(),
PostActivate.class, "post-activate-method");
addInterceptorMethodAnnotation(container, enterpriseBean,
- ((SessionEnterpriseBean) enterpriseBean).getPrePassivate(),
+ sessionBean.getPrePassivates(),
PrePassivate.class, "pre-passivate-method");
addInterceptorMethodAnnotation(container, enterpriseBean,
- ((SessionEnterpriseBean) enterpriseBean).getPreDestroy(),
+ sessionBean.getPreDestroys(),
PreDestroy.class, "pre-destroy-method");
- } else if (enterpriseBean instanceof MessageDrivenBean)
+ }
+ else if (enterpriseBean instanceof JBossMessageDrivenBeanMetaData)
{
+ JBossMessageDrivenBeanMetaData messageDriven = (JBossMessageDrivenBeanMetaData) enterpriseBean;
addInterceptorMethodAnnotation(container, enterpriseBean,
- ((MessageDrivenBean) enterpriseBean).getAroundInvoke(),
+ messageDriven.getAroundInvokes(),
AroundInvoke.class, "around-invoke-method");
addInterceptorMethodAnnotation(container, enterpriseBean,
- ((MessageDrivenBean) enterpriseBean).getPostConstruct(),
+ messageDriven.getPostConstructs(),
PostConstruct.class, "post-construct-method");
addInterceptorMethodAnnotation(container, enterpriseBean,
- ((MessageDrivenBean) enterpriseBean).getPreDestroy(),
+ messageDriven.getPreDestroys(),
PreDestroy.class, "pre-destroy-method");
}
}
- private void addInterceptorMethodAnnotation(EJBContainer container,
- EnterpriseBean enterpriseBean, Method method, Class ann, String xmlName)
+ private void addInterceptorMethodAnnotation(EJBContainer container, String methodName, Class<? extends Annotation> ann, String xmlName)
{
- if (method == null)
- return;
-
- java.lang.reflect.Method found = null;
- for (java.lang.reflect.Method rm : container.getBeanClass()
- .getDeclaredMethods())
+ Method found = null;
+ for (Method rm : container.getBeanClass().getDeclaredMethods())
{
- if (rm.getName().equals(method.getMethodName()))
+ if (rm.getName().equals(methodName))
{
if (ann == AroundInvoke.class)
{
@@ -1806,7 +1752,7 @@
if (found == null)
{
log.warn("No method found within " + container.getBeanClassName()
- + " with name " + method.getMethodName()
+ + " with name " + methodName
+ " with the right signature for " + xmlName + "was found");
return;
}
@@ -1818,10 +1764,39 @@
container.getAnnotations().addAnnotation(found, ann,
getInterceptorImpl(ann));
+ }
+ }
+
+ private void addInterceptorMethodAnnotation(EJBContainer container, JBossEnterpriseBeanMetaData enterpriseBean, AroundInvokesMetaData callbacks, Class<? extends Annotation> ann, String xmlName)
+ {
+ if (callbacks == null)
+ return;
+
+ for(AroundInvokeMetaData callback : callbacks)
+ {
+ if(callback.getClassName() != null)
+ throw new RuntimeException("around invoke with a class name is NYI");
+
+ addInterceptorMethodAnnotation(container, callback.getMethodName(), ann, xmlName);
}
}
+
+ private void addInterceptorMethodAnnotation(EJBContainer container,
+ JBossEnterpriseBeanMetaData enterpriseBean, LifecycleCallbacksMetaData callbacks, Class<? extends Annotation> ann, String xmlName)
+ {
+ if (callbacks == null)
+ return;
- private Object getInterceptorImpl(Class ann)
+ for(LifecycleCallbackMetaData callback : callbacks)
+ {
+ if(callback.getClassName() != null)
+ throw new RuntimeException("lifecycle callback with a class name is NYI");
+
+ addInterceptorMethodAnnotation(container, callback.getMethodName(), ann, xmlName);
+ }
+ }
+
+ private Object getInterceptorImpl(Class<?> ann)
{
if (ann == AroundInvoke.class)
{
@@ -1844,11 +1819,11 @@
}
private void addSecurityIdentityAnnotation(EJBContainer container,
- SecurityIdentity identity)
+ SecurityIdentityMetaData identity)
{
- if (identity != null && !identity.isUseCallerIdentity())
+ if (identity != null && !identity.isUseCallerId())
{
- RunAs runAs = identity.getRunAs();
+ RunAsMetaData runAs = identity.getRunAs();
RunAsImpl annotation = null;
if (runAs != null)
{
@@ -1893,8 +1868,7 @@
}
}
- private void addClassAnnotation(EJBContainer container,
- Class annotationClass, Object annotation)
+ private void addClassAnnotation(EJBContainer container, Class<? extends Annotation> annotationClass, Annotation annotation)
{
log.debug("adding class annotation " + annotationClass.getName() + " to "
+ container + " " + annotation);
@@ -1902,12 +1876,13 @@
.addClassAnnotation(annotationClass, annotation);
}
- private void addAnnotations(Class annotationClass, Object annotation,
- EJBContainer container, Method method) throws ClassNotFoundException,
- NoSuchMethodException, NoSuchFieldException
+ private <A extends Annotation> void addAnnotations(Class<A> annotationClass, A annotation, EJBContainer container, MethodAttributeMetaData method)
{
- String methodName = method.getMethodName();
-
+ addAnnotations(annotationClass, annotation, container, method.getMethodName(), null);
+ }
+
+ private void addAnnotations(Class<? extends Annotation> annotationClass, Annotation annotation, EJBContainer container, String methodName, MethodParametersMetaData params)
+ {
try
{
AnnotationRepository annotations = container.getAnnotations();
@@ -1926,7 +1901,6 @@
}
} else
{
- List params = method.getMethodParams();
if (params == null)
{
java.lang.reflect.Method[] methods = ejbClass.getMethods();
@@ -1984,13 +1958,11 @@
}
} else
{
- Class[] methodSignature = new Class[params.size()];
- Iterator paramIterator = params.iterator();
+ Class<?>[] methodSignature = new Class[params.size()];
int paramIndex = 0;
- while (paramIterator.hasNext())
+ for(String param : params)
{
- String param = (String) paramIterator.next();
- Class paramClass = null;
+ Class<?> paramClass = null;
if (param.equals("boolean"))
paramClass = boolean.class;
else if (param.equals("int"))
@@ -2020,9 +1992,21 @@
}
catch (Exception e)
{
- throw new RuntimeException("Unable to create annotation from method/field " + method.getMethodName() + " for EJB " + container.getEjbName(), e);
+ throw new RuntimeException("Unable to create annotation from method/field " + methodName + " for EJB " + container.getEjbName(), e);
}
}
+
+ private void addAnnotations(Class<? extends Annotation> annotationClass, Annotation annotation, EJBContainer container, NamedMethodMetaData method)
+ {
+ addAnnotations(annotationClass, annotation, container, method.getMethodName(), method.getMethodParams());
+ }
+
+ private void addAnnotations(Class<? extends Annotation> annotationClass, Annotation annotation,
+ EJBContainer container, MethodMetaData method) throws ClassNotFoundException,
+ NoSuchMethodException, NoSuchFieldException
+ {
+ addAnnotations(annotationClass, annotation, container, method.getMethodName(), method.getMethodParams());
+ }
private static String getParameters(java.lang.reflect.Method m)
{
@@ -2032,7 +2016,7 @@
}
StringBuffer sb = new StringBuffer();
boolean first = true;
- for (Class param : m.getParameterTypes())
+ for (Class<?> param : m.getParameterTypes())
{
if (!first)
{
@@ -2069,4 +2053,38 @@
return false;
}
+
+ private TransactionAttributeType toSpec(TransAttributeType transactionAttributeType)
+ {
+ switch(transactionAttributeType)
+ {
+ case Mandatory:
+ return TransactionAttributeType.MANDATORY;
+ case Never:
+ return TransactionAttributeType.NEVER;
+ case NotSupported:
+ return TransactionAttributeType.NOT_SUPPORTED;
+ case Required:
+ return TransactionAttributeType.REQUIRED;
+ case RequiresNew:
+ return TransactionAttributeType.REQUIRES_NEW;
+ case Supports:
+ return TransactionAttributeType.SUPPORTS;
+ default:
+ throw new IllegalArgumentException("unknown transaction attribute type " + transactionAttributeType);
+ }
+ }
+
+ private TransactionManagementType toSpec(TransactionType transactionType)
+ {
+ switch(transactionType)
+ {
+ case Bean:
+ return TransactionManagementType.BEAN;
+ case Container:
+ return TransactionManagementType.CONTAINER;
+ default:
+ throw new IllegalArgumentException("unknown transaction type " + transactionType);
+ }
+ }
}
Modified: trunk/ejb3/src/main/org/jboss/ejb3/Ejb3HandlerFactory.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/Ejb3HandlerFactory.java 2007-10-30 06:40:04 UTC (rev 66557)
+++ trunk/ejb3/src/main/org/jboss/ejb3/Ejb3HandlerFactory.java 2007-10-30 09:07:07 UTC (rev 66558)
@@ -26,6 +26,7 @@
import org.jboss.ejb3.metamodel.EjbJarDDObjectFactory;
import org.jboss.ejb3.metamodel.JBossDDObjectFactory;
import org.jboss.ejb3.interceptor.InterceptorInfoRepository;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
import javassist.bytecode.ClassFile;
@@ -35,17 +36,20 @@
private static class DDFactory extends Ejb3HandlerFactory
{
- private EjbJarDD dd;
+ private JBossMetaData dd;
private Ejb3Deployment di;
public DDFactory(Ejb3Deployment di) throws Exception
{
this.di = di;
+ if(true) throw new RuntimeException("NYI");
+ /*
this.dd = EjbJarDDObjectFactory.parse(di.getDeploymentUnit().getEjbJarXml());
this.dd = JBossDDObjectFactory.parse(di.getDeploymentUnit().getJbossXml(), dd);
InterceptorInfoRepository repository = this.di.getDeploymentUnit().getInterceptorInfoRepository();
repository.initialise(dd);
+ */
}
Modified: trunk/ejb3/src/main/org/jboss/ejb3/client/ClientContainer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/client/ClientContainer.java 2007-10-30 06:40:04 UTC (rev 66557)
+++ trunk/ejb3/src/main/org/jboss/ejb3/client/ClientContainer.java 2007-10-30 09:07:07 UTC (rev 66558)
@@ -58,6 +58,10 @@
import org.jboss.injection.ResourceHandler;
import org.jboss.injection.WebServiceRefHandler;
import org.jboss.logging.Logger;
+import org.jboss.metadata.client.jboss.JBossClientMetaData;
+import org.jboss.metadata.client.spec.ApplicationClientMetaData;
+import org.jboss.metadata.javaee.spec.LifecycleCallbackMetaData;
+import org.jboss.metadata.javaee.spec.RemoteEnvironment;
import org.jboss.metamodel.descriptor.EnvironmentRefGroup;
import org.jboss.util.NotImplementedException;
import org.jboss.virtual.VirtualFile;
@@ -66,14 +70,14 @@
* Injection of the application client main class is handled from here.
*
* @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @version $Revision: $
+ * @version $Revision$
*/
public class ClientContainer implements InjectionContainer
{
private static final Logger log = Logger.getLogger(ClientContainer.class);
private Class<?> mainClass;
- private ApplicationClientDD xml;
+ private JBossClientMetaData xml;
private String applicationClientName;
// for performance there is an array.
@@ -86,7 +90,7 @@
private List<Method> postConstructs = new ArrayList<Method>();
- public ClientContainer(ApplicationClientDD xml, Class<?> mainClass, String applicationClientName) throws Exception
+ public ClientContainer(JBossClientMetaData xml, Class<?> mainClass, String applicationClientName) throws Exception
{
this.xml = xml;
this.mainClass = mainClass;
@@ -235,7 +239,7 @@
/* (non-Javadoc)
* @see org.jboss.injection.InjectionContainer#getEnvironmentRefGroup()
*/
- public EnvironmentRefGroup getEnvironmentRefGroup()
+ public RemoteEnvironment getEnvironmentRefGroup()
{
return xml;
}
@@ -314,7 +318,7 @@
processPostConstructs();
// TODO: check which handlers a client container should support
- Collection<InjectionHandler> handlers = new ArrayList<InjectionHandler>();
+ Collection<InjectionHandler<RemoteEnvironment>> handlers = new ArrayList<InjectionHandler<RemoteEnvironment>>();
handlers.add(new EJBInjectionHandler());
//handlers.add(new ClientEJBHandler());
handlers.add(new DependsHandler());
@@ -368,16 +372,16 @@
{
processPostConstructs(mainClass);
- for(LifecycleCallback callback : xml.getPostConstructs())
+ for(LifecycleCallbackMetaData callback : xml.getPostConstructs())
{
- String className = callback.getLifecycleCallbackClass();
- String methodName = callback.getLifecycleCallbackMethod();
- Class lifecycleClass;
+ String className = callback.getClassName();
+ String methodName = callback.getMethodName();
+ Class<?> lifecycleClass;
if(className == null)
lifecycleClass = mainClass;
else
lifecycleClass = Thread.currentThread().getContextClassLoader().loadClass(className);
- Class parameterTypes[] = new Class[0];
+ Class<?> parameterTypes[] = new Class[0];
Method method = lifecycleClass.getDeclaredMethod(methodName, parameterTypes);
postConstructs.add(method);
}
Modified: trunk/ejb3/src/main/org/jboss/ejb3/client/ClientLauncher.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/client/ClientLauncher.java 2007-10-30 06:40:04 UTC (rev 66557)
+++ trunk/ejb3/src/main/org/jboss/ejb3/client/ClientLauncher.java 2007-10-30 09:07:07 UTC (rev 66558)
@@ -32,6 +32,7 @@
import org.jboss.ejb3.metamodel.ApplicationClientDDObjectFactory;
import org.jboss.ejb3.metamodel.JBossClientDDObjectFactory;
import org.jboss.logging.Logger;
+import org.jboss.metadata.client.jboss.JBossClientMetaData;
import org.jboss.util.NotImplementedException;
import org.jboss.xb.binding.JBossXBException;
@@ -69,9 +70,9 @@
* @param args
* @throws Exception
*/
- public static void launch(ApplicationClientDD xml, String mainClassName, String applicationClientName, String args[]) throws Exception
+ public static void launch(JBossClientMetaData xml, String mainClassName, String applicationClientName, String args[]) throws Exception
{
- Class mainClass = Class.forName(mainClassName);
+ Class<?> mainClass = Class.forName(mainClassName);
ClientContainer container = new ClientContainer(xml, mainClass, applicationClientName);
@@ -89,7 +90,7 @@
* @throws IOException
* @throws JBossXBException
*/
- public static ApplicationClientDD loadXML() throws JBossXBException, IOException
+ public static JBossClientMetaData loadXML() throws JBossXBException, IOException
{
URL url = findResource("META-INF/application-client.xml");
log.trace("application-client.xml found at " + url);
@@ -99,17 +100,20 @@
}
@Deprecated
- public static ApplicationClientDD loadXML(String urlSpec) throws JBossXBException, IOException
+ public static JBossClientMetaData loadXML(String urlSpec) throws JBossXBException, IOException
{
URL url = new URL(urlSpec);
return loadXML(url, null);
}
- public static ApplicationClientDD loadXML(URL url, URL jbossClientURL) throws JBossXBException, IOException
+ public static JBossClientMetaData loadXML(URL url, URL jbossClientURL) throws JBossXBException, IOException
{
+ /*
ApplicationClientDD dd = ApplicationClientDDObjectFactory.parse(url);
dd = JBossClientDDObjectFactory.parse(jbossClientURL, dd);
return dd;
+ */
+ throw new RuntimeException("NYI");
}
/**
@@ -142,7 +146,11 @@
if(appXmlURL == null)
throw new RuntimeException("Can't find META-INF/application-client.xml");
- ApplicationClientDD xml = ApplicationClientDDObjectFactory.parse(appXmlURL);
+ // FIXME: client metadata
+ JBossClientMetaData xml = null;
+ //JBossClientMetaData xml = ApplicationClientDDObjectFactory.parse(appXmlURL);
+ if(true)
+ throw new RuntimeException("NYI");
// FIXME: j2ee.clientName
@@ -175,7 +183,7 @@
public void launch(String mainClassName, String clientName, String args[])
throws Throwable
{
- ApplicationClientDD xml = loadXML();
+ JBossClientMetaData xml = loadXML();
launch(xml, mainClassName, clientName, args);
}
Modified: trunk/ejb3/src/main/org/jboss/ejb3/clientmodule/ClientENCInjectionContainer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/clientmodule/ClientENCInjectionContainer.java 2007-10-30 06:40:04 UTC (rev 66557)
+++ trunk/ejb3/src/main/org/jboss/ejb3/clientmodule/ClientENCInjectionContainer.java 2007-10-30 09:07:07 UTC (rev 66558)
@@ -53,25 +53,22 @@
import org.jboss.ejb3.javaee.AbstractJavaEEComponent;
import org.jboss.ejb3.javaee.SimpleJavaEEModule;
import org.jboss.injection.DependsHandler;
-import org.jboss.injection.EJBHandler;
+import org.jboss.injection.EJBRemoteHandler;
import org.jboss.injection.EncInjector;
import org.jboss.injection.InjectionContainer;
import org.jboss.injection.InjectionHandler;
import org.jboss.injection.InjectionUtil;
import org.jboss.injection.Injector;
-import org.jboss.injection.JndiInjectHandler;
-import org.jboss.injection.PersistenceContextHandler;
import org.jboss.injection.PersistenceUnitHandler;
import org.jboss.injection.ResourceHandler;
import org.jboss.injection.WebServiceRefHandler;
import org.jboss.logging.Logger;
import org.jboss.metadata.client.jboss.JBossClientMetaData;
+import org.jboss.metadata.javaee.spec.RemoteEnvironment;
import org.jboss.metadata.javaee.spec.ServiceReferenceMetaData;
import org.jboss.metadata.javaee.spec.ServiceReferencesMetaData;
import org.jboss.metadata.serviceref.ServiceReferenceHandler;
import org.jboss.metadata.serviceref.VirtualFileAdaptor;
-import org.jboss.metamodel.descriptor.EnvironmentRefGroup;
-import org.jboss.metamodel.descriptor.ServiceRefDelegate;
import org.jboss.virtual.VirtualFile;
import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
@@ -248,9 +245,9 @@
return encInjectors;
}
- public EnvironmentRefGroup getEnvironmentRefGroup()
+ public RemoteEnvironment getEnvironmentRefGroup()
{
- return new EnvironmentRefGroupConveter(clientMetaData.getJndiEnvironmentRefsGroup());
+ return clientMetaData;
}
public String getIdentifier()
@@ -306,23 +303,22 @@
}
// TODO: check which handlers an application client should support
- Collection<InjectionHandler> handlers = new ArrayList<InjectionHandler>();
- handlers.add(new EJBHandler());
- handlers.add(new DependsHandler());
- handlers.add(new JndiInjectHandler());
- handlers.add(new PersistenceContextHandler());
- handlers.add(new PersistenceUnitHandler());
- handlers.add(new ResourceHandler());
- handlers.add(new WebServiceRefHandler());
+ Collection<InjectionHandler<JBossClientMetaData>> handlers = new ArrayList<InjectionHandler<JBossClientMetaData>>();
+ handlers.add(new EJBRemoteHandler<JBossClientMetaData>());
+ handlers.add(new DependsHandler<JBossClientMetaData>());
+ //handlers.add(new JndiInjectHandler<JBossClientMetaData>());
+ //handlers.add(new PersistenceContextHandler<JBossClientMetaData>());
+ handlers.add(new PersistenceUnitHandler<JBossClientMetaData>());
+ handlers.add(new ResourceHandler<JBossClientMetaData>());
+ handlers.add(new WebServiceRefHandler<JBossClientMetaData>());
ClassLoader old = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(classLoader);
try
{
// EJB container's XML must be processed before interceptor's as it may override interceptor's references
- EnvironmentRefGroupConveter refs = new EnvironmentRefGroupConveter(clientMetaData.getJndiEnvironmentRefsGroup());
- for (InjectionHandler handler : handlers)
- handler.loadXml(refs, this);
+ for (InjectionHandler<JBossClientMetaData> handler : handlers)
+ handler.loadXml(clientMetaData, this);
Map<AccessibleObject, Injector> tmp = InjectionUtil.processAnnotations(this, handlers, getMainClass());
injectors.addAll(tmp.values());
Modified: trunk/ejb3/src/main/org/jboss/ejb3/deployers/EJBRegistrationDeployer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/deployers/EJBRegistrationDeployer.java 2007-10-30 06:40:04 UTC (rev 66557)
+++ trunk/ejb3/src/main/org/jboss/ejb3/deployers/EJBRegistrationDeployer.java 2007-10-30 09:07:07 UTC (rev 66558)
@@ -46,7 +46,9 @@
* @author <a href="mailto:bill at jboss.org">Bill Burke</a>
* @author adrian at jboss.org
* @version $Revision: 57082 $
+ * @deprecated use Ejb3Deployer
*/
+ at Deprecated
public class EJBRegistrationDeployer extends AbstractVFSRealDeployer
{
private static final Logger log = Logger.getLogger(EJBRegistrationDeployer.class);
@@ -189,7 +191,7 @@
}
JBoss5DeploymentUnit du = new JBoss5DeploymentUnit(unit);
du.setDefaultPersistenceProperties(defaultPersistenceProperties);
- Ejb3JBoss5Deployment deployment = new Ejb3JBoss5Deployment(du, kernel, mbeanServer, unit, scope);
+ Ejb3JBoss5Deployment deployment = new Ejb3JBoss5Deployment(du, kernel, mbeanServer, unit, scope, null);
if (scope != null) scope.register(deployment);
// create() creates initial EJB containers and initializes metadata.
deployment.create();
Modified: trunk/ejb3/src/main/org/jboss/ejb3/deployers/EJBStage2Deployer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/deployers/EJBStage2Deployer.java 2007-10-30 06:40:04 UTC (rev 66557)
+++ trunk/ejb3/src/main/org/jboss/ejb3/deployers/EJBStage2Deployer.java 2007-10-30 09:07:07 UTC (rev 66558)
@@ -44,6 +44,7 @@
super(Ejb3Deployment.class);
}
+ @Override
public void deploy(DeploymentUnit unit, Ejb3Deployment deployment) throws DeploymentException
{
try
@@ -57,4 +58,16 @@
}
}
+ @Override
+ public void undeploy(DeploymentUnit unit, Ejb3Deployment deployment)
+ {
+ try
+ {
+ deployment.stop();
+ }
+ catch(Exception e)
+ {
+ log.warn("Failed to stop deployment " + deployment, e);
+ }
+ }
}
Added: trunk/ejb3/src/main/org/jboss/ejb3/deployers/Ejb3Deployer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/deployers/Ejb3Deployer.java (rev 0)
+++ trunk/ejb3/src/main/org/jboss/ejb3/deployers/Ejb3Deployer.java 2007-10-30 09:07:07 UTC (rev 66558)
@@ -0,0 +1,212 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, 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.deployers;
+
+import java.util.Properties;
+import java.util.Set;
+
+import javax.management.MBeanServer;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.vfs.spi.deployer.AbstractVFSRealDeployer;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.deployment.security.JaccPolicyUtil;
+import org.jboss.ejb3.DeploymentScope;
+import org.jboss.ejb3.Ejb3Deployment;
+import org.jboss.kernel.Kernel;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * Deployes EJB 3 components based on meta data coming from JBossEjbParsingDeployer.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class Ejb3Deployer //extends AbstractSimpleVFSRealDeployer<JBossMetaData>
+ extends AbstractVFSRealDeployer
+{
+ private Set<String> allowedSuffixes;
+
+ private Properties defaultPersistenceProperties;
+
+ /** EJBTHREE-1040: mandate a deployment descriptor to actually deploy */
+ private boolean deploymentDescriptorRequired;
+
+ private Set<String> ignoredJarsSet;
+
+ private Kernel kernel;
+
+ private MBeanServer mbeanServer;
+
+ public Ejb3Deployer()
+ {
+ // TODO: when the annotation scanner deployer comes on, we will always have JBossMetaData
+ //super(JBossMetaData.class);
+ addInput(JBossMetaData.class);
+ // TODO: should we really output this
+ setOutput(Ejb3Deployment.class);
+ }
+
+ @Override
+ public void deploy(VFSDeploymentUnit unit) throws DeploymentException
+ {
+ deploy(unit, unit.getAttachment(JBossMetaData.class));
+ }
+
+ public void deploy(VFSDeploymentUnit unit, JBossMetaData metaData) throws DeploymentException
+ {
+ try
+ {
+ if(metaData != null && !metaData.isEJB3x())
+ {
+ log.trace("Ignoring legacy EJB deployment " + unit);
+ return;
+ }
+
+ VirtualFile jar = unit.getRoot();
+ if (jar.isLeaf() || ignoredJarsSet.contains(jar.getName()))
+ {
+ log.trace("EJBRegistrationDeployer ignoring: " + jar.getName());
+ return;
+ }
+ if(!hasAllowedSuffix(jar.getName()))
+ {
+ log.trace("EJBRegistrationDeployer suffix not allowed: " + jar.getName());
+ return;
+ }
+
+ // If DDs are required and none are present, skip deployment
+ // EJBTHREE-1040
+ if (this.isDeploymentDescriptorRequired() && (metaData == null))
+ {
+ log.trace(EJBRegistrationDeployer.class.getSimpleName() + " skipping deployment \"" + unit.getSimpleName()
+ + "\", jar: \"" + jar.getName()
+ + "\" - either EJB3 Deployment Descriptor or \"jboss.xml\" is required and neither were found.");
+ return;
+ }
+
+ log.debug("********* EJBRegistrationDepoyer Begin Unit: " + unit.getSimpleName() + " jar: " + jar.getName());
+ DeploymentScope scope = null;
+ VFSDeploymentUnit parent = unit.getParent();
+ if (parent != null && parent.getSimpleName().endsWith(".ear")) // todo should look for metadata instead of ".ear"
+ {
+ scope = parent.getAttachment(DeploymentScope.class);
+ if (scope == null)
+ {
+ scope = new JBoss5DeploymentScope(unit.getParent());
+ parent.addAttachment(DeploymentScope.class, scope);
+ }
+ }
+ JBoss5DeploymentUnit du = new JBoss5DeploymentUnit(unit);
+ du.setDefaultPersistenceProperties(defaultPersistenceProperties);
+ Ejb3JBoss5Deployment deployment = new Ejb3JBoss5Deployment(du, kernel, mbeanServer, unit, scope, metaData);
+ if (scope != null) scope.register(deployment);
+ // create() creates initial EJB containers and initializes metadata.
+ deployment.create();
+ if (deployment.getEjbContainers().size() == 0 && deployment.getPersistenceUnitDeployments().size() == 0)
+ {
+ log.trace("EJBRegistrationDeployer no containers in scanned jar, consider adding it to the ignore list: " + jar.getName() + " url: " + jar.toURL() + " unit: " + unit.getSimpleName());
+ deployment.destroy();
+ return;
+ }
+ unit.addAttachment(Ejb3Deployment.class, deployment);
+ // TODO: temporarily disable the security deployment
+ unit.addAttachment(JaccPolicyUtil.IGNORE_ME_NAME, true, Boolean.class);
+ }
+ catch (Exception e)
+ {
+ throw new DeploymentException(e);
+ }
+ }
+
+ public Set<String> getAllowedSuffixes()
+ {
+ return allowedSuffixes;
+ }
+
+ private boolean hasAllowedSuffix(String name)
+ {
+ if(allowedSuffixes == null)
+ return true;
+
+ for (String suffix : allowedSuffixes)
+ {
+ if (name.endsWith(suffix))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public boolean isDeploymentDescriptorRequired()
+ {
+ return deploymentDescriptorRequired;
+ }
+
+ public void setAllowedSuffixes(Set<String> s)
+ {
+ this.allowedSuffixes = s;
+ }
+
+ public void setDefaultPersistenceProperties(Properties p)
+ {
+ this.defaultPersistenceProperties = p;
+ }
+
+ public void setDeploymentDescriptorRequired(boolean b)
+ {
+ this.deploymentDescriptorRequired = b;
+ }
+
+ public void setIgnoredJarsSet(Set<String> s)
+ {
+ this.ignoredJarsSet = s;
+ }
+
+ public void setKernel(Kernel kernel)
+ {
+ this.kernel = kernel;
+ }
+
+ public void setMbeanServer(MBeanServer server)
+ {
+ this.mbeanServer = server;
+ }
+
+ @Override
+ public void undeploy(VFSDeploymentUnit unit)
+ {
+ Ejb3Deployment deployment = unit.getAttachment(Ejb3Deployment.class);
+ if(deployment == null) return;
+
+ try
+ {
+ deployment.destroy();
+ }
+ catch(Exception e)
+ {
+ log.warn("Failed to destroy deployment " + deployment, e);
+ }
+ }
+}
Property changes on: trunk/ejb3/src/main/org/jboss/ejb3/deployers/Ejb3Deployer.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: trunk/ejb3/src/main/org/jboss/ejb3/deployers/Ejb3JBoss5Deployment.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/deployers/Ejb3JBoss5Deployment.java 2007-10-30 06:40:04 UTC (rev 66557)
+++ trunk/ejb3/src/main/org/jboss/ejb3/deployers/Ejb3JBoss5Deployment.java 2007-10-30 09:07:07 UTC (rev 66558)
@@ -32,10 +32,10 @@
import org.jboss.ejb3.Ejb3Deployment;
import org.jboss.ejb3.MCKernelAbstraction;
import org.jboss.ejb3.javaee.JavaEEComponent;
-import org.jboss.ejb3.metamodel.EjbJarDD;
import org.jboss.ejb3.security.JaccHelper;
import org.jboss.kernel.Kernel;
import org.jboss.logging.Logger;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
import org.jboss.xb.binding.JBossXBException;
/**
@@ -47,11 +47,12 @@
*/
public class Ejb3JBoss5Deployment extends Ejb3Deployment
{
- private org.jboss.deployers.structure.spi.DeploymentUnit jbossUnit;
-
private static final Logger log = Logger.getLogger(Ejb3JBoss5Deployment.class);
- public Ejb3JBoss5Deployment(DeploymentUnit ejb3Unit, Kernel kernel, MBeanServer mbeanServer, org.jboss.deployers.structure.spi.DeploymentUnit jbossUnit, DeploymentScope deploymentScope)
+ private org.jboss.deployers.structure.spi.DeploymentUnit jbossUnit;
+ private JBossMetaData metaData;
+
+ public Ejb3JBoss5Deployment(DeploymentUnit ejb3Unit, Kernel kernel, MBeanServer mbeanServer, org.jboss.deployers.structure.spi.DeploymentUnit jbossUnit, DeploymentScope deploymentScope, JBossMetaData metaData)
{
super(ejb3Unit, deploymentScope);
this.jbossUnit = jbossUnit;
@@ -59,14 +60,12 @@
// todo maybe mbeanServer should be injected?
this.mbeanServer = mbeanServer;
+ this.metaData = metaData;
}
- protected EjbJarDD getMetaDataFomLib() throws JBossXBException, IOException
+ protected JBossMetaData getMetaDataFomLib() throws JBossXBException, IOException
{
- EjbJarDD jarDD = super.getMetaDataFomLib();
- if (jarDD != null)
- jbossUnit.addAttachment(EjbJarDD.class, jarDD);
- return jarDD;
+ return metaData;
}
protected PolicyConfiguration createPolicyConfiguration() throws Exception
Modified: trunk/ejb3/src/main/org/jboss/ejb3/interceptor/InterceptorInfo.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/interceptor/InterceptorInfo.java 2007-10-30 06:40:04 UTC (rev 66557)
+++ trunk/ejb3/src/main/org/jboss/ejb3/interceptor/InterceptorInfo.java 2007-10-30 09:07:07 UTC (rev 66558)
@@ -27,7 +27,7 @@
import java.security.PrivilegedExceptionAction;
import java.util.ArrayList;
-import org.jboss.ejb3.metamodel.Interceptor;
+import org.jboss.metadata.ejb.spec.InterceptorMetaData;
/**
* We cannot use annotation overrides for the interceptor stuff since they do not have a
@@ -38,8 +38,8 @@
*/
public class InterceptorInfo
{
- Class clazz;
- Interceptor xml;
+ Class<?> clazz;
+ InterceptorMetaData xml;
//interceptor methods defined by this class
protected Method aroundInvoke;
@@ -61,7 +61,7 @@
{
}
- public InterceptorInfo(Class clazz)
+ public InterceptorInfo(Class<?> clazz)
{
this.clazz = clazz;
}
@@ -81,12 +81,12 @@
this.prePassivateHierarchy = interceptorInfo.prePassivateHierarchy;
}
- protected void setXml(Interceptor xml)
+ protected void setXml(InterceptorMetaData xml)
{
this.xml = xml;
}
- public Interceptor getXml()
+ public InterceptorMetaData getXml()
{
return xml;
}
Modified: trunk/ejb3/src/main/org/jboss/ejb3/interceptor/InterceptorInfoRepository.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/interceptor/InterceptorInfoRepository.java 2007-10-30 06:40:04 UTC (rev 66557)
+++ trunk/ejb3/src/main/org/jboss/ejb3/interceptor/InterceptorInfoRepository.java 2007-10-30 09:07:07 UTC (rev 66558)
@@ -22,11 +22,19 @@
package org.jboss.ejb3.interceptor;
import org.jboss.ejb3.EJBContainer;
-import org.jboss.ejb3.metamodel.EjbJarDD;
-import org.jboss.ejb3.metamodel.Interceptor;
-import org.jboss.ejb3.metamodel.InterceptorBinding;
-import org.jboss.ejb3.metamodel.Interceptors;
import org.jboss.logging.Logger;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
+import org.jboss.metadata.ejb.spec.AroundInvokeMetaData;
+import org.jboss.metadata.ejb.spec.AroundInvokesMetaData;
+import org.jboss.metadata.ejb.spec.InterceptorBindingMetaData;
+import org.jboss.metadata.ejb.spec.InterceptorBindingsMetaData;
+import org.jboss.metadata.ejb.spec.InterceptorMetaData;
+import org.jboss.metadata.ejb.spec.InterceptorOrderMetaData;
+import org.jboss.metadata.ejb.spec.InterceptorsMetaData;
+import org.jboss.metadata.ejb.spec.MethodParametersMetaData;
+import org.jboss.metadata.ejb.spec.NamedMethodMetaData;
+import org.jboss.metadata.javaee.spec.LifecycleCallbackMetaData;
+import org.jboss.metadata.javaee.spec.LifecycleCallbacksMetaData;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
@@ -63,11 +71,11 @@
private Set<String> beanClasses = new HashSet<String>();
- private Interceptors interceptorsXml;
+ private InterceptorsMetaData interceptorsXml;
- private List<InterceptorBinding> bindingsXml;
+ private InterceptorBindingsMetaData bindingsXml;
- private ConcurrentMap<Class, InterceptorInfo> infos = new ConcurrentHashMap<Class, InterceptorInfo>();
+ private ConcurrentMap<Class<?>, InterceptorInfo> infos = new ConcurrentHashMap<Class<?>, InterceptorInfo>();
private ConcurrentMap<String, InterceptorInfo> ejbInfos = new ConcurrentHashMap<String, InterceptorInfo>();
@@ -79,7 +87,7 @@
{
}
- public void initialise(EjbJarDD dd)
+ public void initialise(JBossMetaData dd)
{
this.interceptorsXml = dd.getInterceptors();
@@ -345,14 +353,14 @@
{
//Initialise all interceptor entries so we know which classes we have xml for
HashMap<String, AnnotationInitialiser> initialisers = new HashMap<String, AnnotationInitialiser>();
- for (Interceptor xml : interceptorsXml.getInterceptors())
+ for (InterceptorMetaData xml : interceptorsXml)
{
XmlInitialiser init = new XmlInitialiser(xml);
initialisers.put(xml.getInterceptorClass(), init);
}
//Create entries recursively, top classes first so we get the method hierarchies
- for (Interceptor xml : interceptorsXml.getInterceptors())
+ for (InterceptorMetaData xml : interceptorsXml)
{
String clazz = xml.getInterceptorClass();
initialiseSuperClassesFirstFromXmlOrAnnotations(initialisers, clazz);
@@ -393,10 +401,9 @@
if (bindingsXml != null)
{
- for (InterceptorBinding bindingXml : bindingsXml)
+ for (InterceptorBindingMetaData bindingXml : bindingsXml)
{
- if (bindingXml.getEjbName().equals("*")
- && (bindingXml.getMethodName() == null || bindingXml.getMethodName().length() == 0))
+ if (bindingXml.getEjbName().equals("*") && bindingXml.getMethod() == null)
{
for (String classname : bindingXml.getInterceptorClasses())
{
@@ -790,9 +797,9 @@
private class XmlInitialiser extends AnnotationInitialiser
{
- Interceptor xml;
+ InterceptorMetaData xml;
- XmlInitialiser(Interceptor xml)
+ XmlInitialiser(InterceptorMetaData xml)
{
super(xml.getInterceptorClass(), InterceptorSignatureValidator.instance);
this.xml = xml;
@@ -800,34 +807,48 @@
InterceptorInfo getInfo()
{
- info.setAroundInvoke(findInterceptorMethodFromXml(clazz, "around-invoke-method", xml.getAroundInvoke()));
- info.setPostConstruct(findInterceptorMethodFromXml(clazz, "post-construct-method", xml.getPostConstruct()));
- info.setPostActivate(findInterceptorMethodFromXml(clazz, "post-activate-method", xml.getPostActivate()));
- info.setPreDestroy(findInterceptorMethodFromXml(clazz, "pre-destroy-method", xml.getPreDestroy()));
- info.setPrePassivate(findInterceptorMethodFromXml(clazz, "pre-passivate-method", xml.getPrePassivate()));
+ info.setAroundInvoke(findInterceptorMethodFromXml(clazz, "around-invoke-method", xml.getAroundInvokes()));
+ info.setPostConstruct(findInterceptorMethodFromXml(clazz, "post-construct-method", xml.getPostConstructs()));
+ info.setPostActivate(findInterceptorMethodFromXml(clazz, "post-activate-method", xml.getPostActivates()));
+ info.setPreDestroy(findInterceptorMethodFromXml(clazz, "pre-destroy-method", xml.getPreDestroys()));
+ info.setPrePassivate(findInterceptorMethodFromXml(clazz, "pre-passivate-method", xml.getPrePassivates()));
super.getInfo();
info.setXml(xml);
return info;
}
- java.lang.reflect.Method findInterceptorMethodFromXml(Class clazz, String lookingFor, org.jboss.ejb3.metamodel.Method xml)
+ Method findInterceptorMethodFromXml(Class<?> clazz, String lookingFor, AroundInvokesMetaData aroundInvokes)
{
+ if(aroundInvokes.size() != 1)
+ throw new RuntimeException("NYI");
+
+ AroundInvokeMetaData aroundInvoke = aroundInvokes.get(0);
+ return findInterceptorMethodFromXml(clazz, lookingFor, aroundInvoke.getMethodName());
+ }
+
+ Method findInterceptorMethodFromXml(Class<?> clazz, String lookingFor, LifecycleCallbacksMetaData lifecycleCallbacks)
+ {
+ if(lifecycleCallbacks.size() != 1)
+ throw new RuntimeException("NYI");
+
+ LifecycleCallbackMetaData lifecycleCallback = lifecycleCallbacks.get(0);
+ return findInterceptorMethodFromXml(clazz, lookingFor, lifecycleCallback.getMethodName());
+ }
+
+ Method findInterceptorMethodFromXml(Class<?> clazz, String lookingFor, String methodName)
+ {
if (xml == null)
return null;
- if (xml.getMethodName() == null || xml.getMethodName().trim().equals(""))
+ if (methodName == null || methodName.trim().equals(""))
{
throw new RuntimeException(lookingFor + " must contain a valid method name for interceptor "
+ clazz.getName());
}
- if (xml.getMethodParams() != null)
- {
- log.debug("Ignoring method parameters for " + lookingFor + " in interceptor " + clazz.getName());
- }
- ArrayList<Method> possible = new ArrayList<Method>();
+ List<Method> possible = new ArrayList<Method>();
for (java.lang.reflect.Method method : clazz.getDeclaredMethods())
{
- if (xml.getMethodName().equals(method.getName()))
+ if (methodName.equals(method.getName()))
{
possible.add(method);
}
@@ -843,6 +864,7 @@
for (Method method : possible)
{
+ // TODO: barf, use a validator as parameter
if (lookingFor.equals("around-invoke-method"))
{
if (signatureValidator.checkValidAround(method))
@@ -872,7 +894,7 @@
private class InterceptorSorter
{
boolean initialised;
- List<InterceptorBinding> orderedBindings;
+ List<InterceptorBindingMetaData> orderedBindings;
private void initialise()
{
@@ -882,15 +904,14 @@
{
if (bindingsXml != null)
{
- for (InterceptorBinding binding : bindingsXml)
+ for (InterceptorBindingMetaData binding : bindingsXml)
{
- if (binding.isOrdered())
+ if (binding.isTotalOrdering())
{
//Validate each interceptor only occurs once
HashSet<String> names = new HashSet<String>();
- for (Iterator it = binding.getInterceptorClasses().iterator() ; it.hasNext() ; )
+ for(String className : binding.getInterceptorOrder())
{
- String className = (String)it.next();
if (names.contains(className))
{
throw new RuntimeException(className + " occurs more than once in ordered binding " +
@@ -901,7 +922,7 @@
if (orderedBindings == null)
{
- orderedBindings = new ArrayList<InterceptorBinding>();
+ orderedBindings = new ArrayList<InterceptorBindingMetaData>();
}
orderedBindings.add(binding);
}
@@ -917,8 +938,8 @@
{
initialise();
if (orderedBindings == null) return;
- ArrayList<String> bindingOrder = null;
- for (InterceptorBinding binding : orderedBindings)
+ InterceptorOrderMetaData bindingOrder = null;
+ for (InterceptorBindingMetaData binding : orderedBindings)
{
if (binding.getEjbName().equals("*"))
{
@@ -927,7 +948,7 @@
throw new RuntimeException("There should only be one interceptor-binding specifying " +
"the order of default interceptors " + getInterceptorBindingString(binding));
}
- bindingOrder = binding.getInterceptorClasses();
+ bindingOrder = binding.getInterceptorOrder();
}
}
sortInterceptors(infos, bindingOrder);
@@ -937,13 +958,11 @@
{
initialise();
if (orderedBindings == null) return;
- ArrayList<String> bindingOrder = null;
- for (InterceptorBinding binding : orderedBindings)
+ InterceptorOrderMetaData bindingOrder = null;
+ for (InterceptorBindingMetaData binding : orderedBindings)
{
- if (binding.getMethodName() != null && binding.getMethodName().trim().length() > 0)
- {
+ if(binding.getMethod() != null)
continue;
- }
if (binding.getEjbName().equals(container.getEjbName()))
{
if (bindingOrder != null)
@@ -951,7 +970,7 @@
throw new RuntimeException("There should only be one interceptor-binding specifying " +
"the order of class interceptors: " + getInterceptorBindingString(binding));
}
- bindingOrder = binding.getInterceptorClasses();
+ bindingOrder = binding.getInterceptorOrder();
}
}
sortInterceptors(infos, bindingOrder);
@@ -961,27 +980,28 @@
{
initialise();
if (orderedBindings == null) return;
- ArrayList<String> methodNoParamsOrder = null;
- ArrayList<String> methodParamsOrder = null;
- for (InterceptorBinding binding : orderedBindings)
+ InterceptorOrderMetaData methodNoParamsOrder = null;
+ InterceptorOrderMetaData methodParamsOrder = null;
+ for (InterceptorBindingMetaData binding : orderedBindings)
{
if (binding.getEjbName().equals(container.getEjbName()))
{
- if (binding.getMethodName() != null && binding.getMethodName().equals(method.getName()))
+ NamedMethodMetaData bindingMethod = binding.getMethod();
+ if (bindingMethod != null)
{
- if (binding.getMethodParams() == null)
+ if (bindingMethod.getMethodParams() == null)
{
if (methodNoParamsOrder != null)
{
throw new RuntimeException("There should only be one interceptor-binding specifying " +
"the order of method interceptors: " + getInterceptorBindingString(binding));
}
- methodNoParamsOrder = binding.getInterceptorClasses();
+ methodNoParamsOrder = binding.getInterceptorOrder();
}
else
{
- Class[] params = method.getParameterTypes();
- List<String> methodParams = binding.getMethodParams();
+ Class<?>[] params = method.getParameterTypes();
+ List<String> methodParams = bindingMethod.getMethodParams();
if (methodParams.size() == params.length)
{
boolean matches = true;
@@ -1011,7 +1031,7 @@
"the order of method interceptors: " + getInterceptorBindingString(binding));
}
- methodParamsOrder = binding.getInterceptorClasses();
+ methodParamsOrder = binding.getInterceptorOrder();
}
}
}
@@ -1030,28 +1050,29 @@
}
}
- void sortInterceptors(ArrayList<InterceptorInfo> infos, ArrayList<String> interceptorOrder)
+ void sortInterceptors(ArrayList<InterceptorInfo> infos, InterceptorOrderMetaData interceptorOrder)
{
if (interceptorOrder == null) return;
Collections.sort(infos, new InterceptorComparator(interceptorOrder));
}
- String getInterceptorBindingString(InterceptorBinding binding)
+ String getInterceptorBindingString(InterceptorBindingMetaData binding)
{
StringBuffer buf = new StringBuffer();
- List methodParams = binding.getMethodParams();
buf.append(binding.getEjbName());
- if (binding.getMethodName() != null)
+ NamedMethodMetaData method = binding.getMethod();
+ if(method != null)
{
- buf.append("." + binding.getMethodName());
+ buf.append("." + method.getMethodName());
+ MethodParametersMetaData methodParams = method.getMethodParams();
if (methodParams != null)
{
buf.append("(");
for (int i = 0 ; i < methodParams.size() ; )
{
if (i == 0) buf.append(",");
- buf.append((String)methodParams.get(i));
+ buf.append(methodParams.get(i));
}
buf.append(")");
}
@@ -1063,11 +1084,13 @@
private class InterceptorComparator implements Comparator<InterceptorInfo>
{
- ArrayList<String> ordered;
+ List<String> ordered;
- InterceptorComparator(ArrayList<String> ordered)
+ InterceptorComparator(InterceptorOrderMetaData ordered)
{
- this.ordered = ordered;
+ assert ordered != null : "ordered is null";
+
+ this.ordered = new ArrayList<String>(ordered);
}
public int compare(InterceptorInfo o1, InterceptorInfo o2)
Modified: trunk/ejb3/src/main/org/jboss/ejb3/interceptor/InterceptorInjector.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/interceptor/InterceptorInjector.java 2007-10-30 06:40:04 UTC (rev 66557)
+++ trunk/ejb3/src/main/org/jboss/ejb3/interceptor/InterceptorInjector.java 2007-10-30 09:07:07 UTC (rev 66558)
@@ -26,8 +26,7 @@
import org.jboss.ejb3.EJBContainer;
import org.jboss.injection.Injector;
import org.jboss.injection.PojoInjector;
-import org.jboss.ejb3.metamodel.Interceptor;
-
+import org.jboss.metadata.ejb.spec.InterceptorMetaData;
import java.lang.reflect.AccessibleObject;
import java.util.Map;
@@ -50,12 +49,12 @@
injectors = injections.values().toArray(new PojoInjector[injections.size()]);
}
- public Interceptor getXml()
+ public InterceptorMetaData getXml()
{
return info.getXml();
}
- public Class getClazz()
+ public Class<?> getClazz()
{
return info.getClazz();
}
Modified: trunk/ejb3/src/main/org/jboss/ejb3/security/Ejb3AuthenticationInterceptor.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/security/Ejb3AuthenticationInterceptor.java 2007-10-30 06:40:04 UTC (rev 66557)
+++ trunk/ejb3/src/main/org/jboss/ejb3/security/Ejb3AuthenticationInterceptor.java 2007-10-30 09:07:07 UTC (rev 66558)
@@ -23,6 +23,8 @@
import java.security.GeneralSecurityException;
import java.security.Principal;
+import java.util.Map;
+import java.util.Set;
import javax.ejb.EJBAccessException;
import javax.security.auth.Subject;
@@ -124,7 +126,9 @@
//Set a map of principal-roles that may be configured at deployment level
if(container.getAssemblyDescriptor() != null)
{
- SecurityRolesAssociation.setSecurityRoles(container.getAssemblyDescriptor().getPrincipalVersusRolesMap());
+ Map<String, Set<String>> securityRoles = null;
+ //SecurityRolesAssociation.setSecurityRoles(container.getAssemblyDescriptor().getPrincipalVersusRolesMap());
+ SecurityRolesAssociation.setSecurityRoles(securityRoles);
}
return super.invoke(invocation);
}
Modified: trunk/ejb3/src/main/org/jboss/ejb3/security/Ejb3AuthenticationInterceptorv2.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/security/Ejb3AuthenticationInterceptorv2.java 2007-10-30 06:40:04 UTC (rev 66557)
+++ trunk/ejb3/src/main/org/jboss/ejb3/security/Ejb3AuthenticationInterceptorv2.java 2007-10-30 09:07:07 UTC (rev 66558)
@@ -36,7 +36,6 @@
import org.jboss.logging.Logger;
import org.jboss.security.SecurityContext;
import org.jboss.security.SecurityIdentity;
-import org.jboss.security.SecurityRolesAssociation;
import org.jboss.security.SecurityUtil;
import org.jboss.security.SimplePrincipal;
import org.jboss.security.integration.JNDIBasedSecurityManagement;
@@ -176,7 +175,9 @@
//Set a map of principal-roles that may be configured at deployment level
if(container.getAssemblyDescriptor() != null)
{
- SecurityRolesAssociation.setSecurityRoles(container.getAssemblyDescriptor().getPrincipalVersusRolesMap());
+ // FIXME:
+ throw new RuntimeException("NYI");
+ //SecurityRolesAssociation.setSecurityRoles(container.getAssemblyDescriptor().getPrincipalVersusRolesMap());
}
return invocation.invokeNext();
}
Modified: trunk/ejb3/src/main/org/jboss/ejb3/security/RunAsSecurityInterceptorFactory.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/security/RunAsSecurityInterceptorFactory.java 2007-10-30 06:40:04 UTC (rev 66557)
+++ trunk/ejb3/src/main/org/jboss/ejb3/security/RunAsSecurityInterceptorFactory.java 2007-10-30 09:07:07 UTC (rev 66558)
@@ -22,6 +22,7 @@
package org.jboss.ejb3.security;
import java.util.HashSet;
+import java.util.Set;
import javax.annotation.security.RunAs;
import javax.naming.InitialContext;
@@ -36,6 +37,8 @@
import org.jboss.ejb3.metamodel.AssemblyDescriptor;
import org.jboss.ejb3.tx.NullInterceptor;
import org.jboss.logging.Logger;
+import org.jboss.metadata.ejb.jboss.JBossAssemblyDescriptorMetaData;
+import org.jboss.metadata.javaee.spec.SecurityRoleMetaData;
import org.jboss.security.AuthenticationManager;
import org.jboss.security.RealmMapping;
import org.jboss.security.RunAsIdentity;
@@ -49,6 +52,7 @@
public class RunAsSecurityInterceptorFactory extends PerClassAspectFactoryAdaptor
implements AspectFactory
{
+ @SuppressWarnings("unused")
private static final Logger log = Logger.getLogger(RunAsSecurityInterceptorFactory.class);
protected RunAsIdentity getRunAsIdentity(EJBContainer container)
@@ -62,10 +66,10 @@
if (rap != null)
runAsPrincipal = rap.value();
- HashSet extraRoles = new HashSet();
- AssemblyDescriptor ad = container.getAssemblyDescriptor();
+ Set<SecurityRoleMetaData> extraRoles = new HashSet<SecurityRoleMetaData>();
+ JBossAssemblyDescriptorMetaData ad = container.getAssemblyDescriptor();
if(ad != null)
- extraRoles.addAll(ad.getSecurityRolesGivenPrincipal(runAsPrincipal));
+ extraRoles.addAll(ad.getSecurityRolesByPrincipal(runAsPrincipal));
return new RunAsIdentity(runAs.value(), runAsPrincipal, extraRoles);
}
Modified: trunk/ejb3/src/main/org/jboss/ejb3/session/BaseSessionProxyFactory.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/session/BaseSessionProxyFactory.java 2007-10-30 06:40:04 UTC (rev 66557)
+++ trunk/ejb3/src/main/org/jboss/ejb3/session/BaseSessionProxyFactory.java 2007-10-30 09:07:07 UTC (rev 66558)
@@ -123,16 +123,16 @@
*/
protected void ensureEjb21ViewComplete(Object home,Class<?>[] localOrRemoteInterfaces) throws RuntimeException
{
- // Ensure specified home is EJBHome or EJBLocalHome
- assert(home instanceof EJBHome || home instanceof EJBLocalHome);
+// // Ensure specified home is EJBHome or EJBLocalHome
+// assert(home instanceof EJBHome || home instanceof EJBLocalHome);
+//
+// // Ensure all interfaces passed are either EJBObject or EJBLocalObject
+// for(Class<?> localOrRemoteInterface : localOrRemoteInterfaces)
+// {
+// assert (EJBObject.class.isAssignableFrom(localOrRemoteInterface) || EJBLocalObject.class
+// .isAssignableFrom(localOrRemoteInterface));
+// }
- // Ensure all interfaces passed are either EJBObject or EJBLocalObject
- for(Class<?> localOrRemoteInterface : localOrRemoteInterfaces)
- {
- assert (EJBObject.class.isAssignableFrom(localOrRemoteInterface) || EJBLocalObject.class
- .isAssignableFrom(localOrRemoteInterface));
- }
-
// If home is defined and there are no local/remote interfaces
if (home != null && localOrRemoteInterfaces.length == 0)
{
Modified: trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulInstanceInterceptor.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulInstanceInterceptor.java 2007-10-30 06:40:04 UTC (rev 66557)
+++ trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulInstanceInterceptor.java 2007-10-30 09:07:07 UTC (rev 66558)
@@ -21,19 +21,19 @@
*/
package org.jboss.ejb3.stateful;
-import java.util.Iterator;
-import java.util.List;
-
import java.rmi.RemoteException;
+import javax.ejb.ApplicationException;
import javax.ejb.ConcurrentAccessException;
import javax.ejb.EJBException;
-import javax.ejb.ApplicationException;
-import org.jboss.ejb3.EJBContainer;
-import org.jboss.ejb3.metamodel.AssemblyDescriptor;
+
import org.jboss.annotation.ejb.SerializedConcurrentAccess;
import org.jboss.aop.advice.Interceptor;
import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.ejb3.EJBContainer;
+import org.jboss.metadata.ejb.jboss.JBossAssemblyDescriptorMetaData;
+import org.jboss.metadata.ejb.spec.ApplicationExceptionMetaData;
+import org.jboss.metadata.ejb.spec.ApplicationExceptionsMetaData;
/**
* Comment
@@ -112,16 +112,15 @@
if (exceptionClass.isAnnotationPresent(ApplicationException.class))
return true;
- AssemblyDescriptor assembly = container.getAssemblyDescriptor();
+ // FIXME: use annotation only. Duplicate of TxUtil.getApplicationException, must move to EJBContainer.
+ JBossAssemblyDescriptorMetaData assembly = container.getAssemblyDescriptor();
if (assembly != null)
{
- List exceptions = assembly.getApplicationExceptions();
+ ApplicationExceptionsMetaData exceptions = assembly.getApplicationExceptions();
if (exceptions.size() > 0)
{
- Iterator exceptionIterator = exceptions.iterator();
- while (exceptionIterator.hasNext())
+ for(ApplicationExceptionMetaData exception : exceptions)
{
- org.jboss.ejb3.metamodel.ApplicationException exception = (org.jboss.ejb3.metamodel.ApplicationException)exceptionIterator.next();
if (exception.getExceptionClass().equals(exceptionClass.getName()))
return true;
}
Modified: trunk/ejb3/src/main/org/jboss/ejb3/tx/TxUtil.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/tx/TxUtil.java 2007-10-30 06:40:04 UTC (rev 66557)
+++ trunk/ejb3/src/main/org/jboss/ejb3/tx/TxUtil.java 2007-10-30 09:07:07 UTC (rev 66558)
@@ -21,26 +21,24 @@
*/
package org.jboss.ejb3.tx;
+import javax.ejb.ApplicationException;
import javax.ejb.TransactionManagement;
import javax.ejb.TransactionManagementType;
-import javax.ejb.ApplicationException;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.transaction.TransactionManager;
+
import org.jboss.aop.Advisor;
import org.jboss.aop.joinpoint.Invocation;
import org.jboss.aop.joinpoint.MethodInvocation;
-
-import org.jboss.ejb3.InitialContextFactory;
-import org.jboss.ejb3.EJBContainer;
-import org.jboss.ejb3.metamodel.AssemblyDescriptor;
import org.jboss.ejb.ApplicationExceptionImpl;
-
+import org.jboss.ejb3.EJBContainer;
+import org.jboss.ejb3.InitialContextFactory;
+import org.jboss.metadata.ejb.jboss.JBossAssemblyDescriptorMetaData;
+import org.jboss.metadata.ejb.spec.ApplicationExceptionMetaData;
+import org.jboss.metadata.ejb.spec.ApplicationExceptionsMetaData;
import org.jboss.tm.TransactionManagerLocator;
-import java.util.List;
-import java.util.Iterator;
-
/**
* Comment
*
@@ -71,7 +69,7 @@
return transactionManagement.value();
}
- public static ApplicationException getApplicationException(Class exceptionClass, Invocation invocation)
+ public static ApplicationException getApplicationException(Class<?> exceptionClass, Invocation invocation)
{
MethodInvocation ejb = (MethodInvocation) invocation;
EJBContainer container = (EJBContainer) ejb.getAdvisor();
@@ -79,19 +77,17 @@
if (exceptionClass.isAnnotationPresent(ApplicationException.class))
return (ApplicationException)exceptionClass.getAnnotation(ApplicationException.class);
- AssemblyDescriptor assembly = container.getAssemblyDescriptor();
+ JBossAssemblyDescriptorMetaData assembly = container.getAssemblyDescriptor();
if (assembly != null)
{
- List exceptions = assembly.getApplicationExceptions();
+ ApplicationExceptionsMetaData exceptions = assembly.getApplicationExceptions();
if (exceptions.size() > 0)
{
- Iterator exceptionIterator = exceptions.iterator();
- while (exceptionIterator.hasNext())
+ for(ApplicationExceptionMetaData exception : exceptions)
{
- org.jboss.ejb3.metamodel.ApplicationException exception = (org.jboss.ejb3.metamodel.ApplicationException)exceptionIterator.next();
if (exception.getExceptionClass().equals(exceptionClass.getName()))
- return new ApplicationExceptionImpl(exception.getRollback());
+ return new ApplicationExceptionImpl(exception.isRollback());
}
}
Modified: trunk/ejb3/src/main/org/jboss/injection/AbstractHandler.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/injection/AbstractHandler.java 2007-10-30 06:40:04 UTC (rev 66557)
+++ trunk/ejb3/src/main/org/jboss/injection/AbstractHandler.java 2007-10-30 09:07:07 UTC (rev 66558)
@@ -25,6 +25,7 @@
import org.jboss.ejb3.EJBContainer;
import org.jboss.ejb3.deployers.JBoss5DependencyPolicy;
+import org.jboss.metadata.javaee.spec.RemoteEnvironment;
/**
* Common base for annotation/xml handlers.
@@ -32,7 +33,7 @@
* @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
* @version $Revision: $
*/
-public abstract class AbstractHandler implements InjectionHandler
+public abstract class AbstractHandler<X extends RemoteEnvironment> implements InjectionHandler<X>
{
// protected void addDependency(String refName, EJBContainer refcon, InjectionContainer container)
// {
@@ -59,7 +60,7 @@
((JBoss5DependencyPolicy) container.getDependencyPolicy()).addDependency(businessIntf);
}
- protected void addDependency(InjectionContainer container, String link, Class businessIntf)
+ protected void addDependency(InjectionContainer container, String link, Class<?> businessIntf)
{
EJBContainer refCon = (EJBContainer) container.resolveEjbContainer(link, businessIntf);
Modified: trunk/ejb3/src/main/org/jboss/injection/DependsHandler.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/injection/DependsHandler.java 2007-10-30 06:40:04 UTC (rev 66557)
+++ trunk/ejb3/src/main/org/jboss/injection/DependsHandler.java 2007-10-30 09:07:07 UTC (rev 66558)
@@ -30,17 +30,18 @@
import org.jboss.annotation.ejb.Depends;
import org.jboss.logging.Logger;
-import org.jboss.metamodel.descriptor.EnvironmentRefGroup;
+import org.jboss.metadata.javaee.spec.RemoteEnvironment;
/**
* @author <a href="mailto:kabir.khan at jboss.org">Kabir Khan</a>
* @version $Revision$
*/
-public class DependsHandler implements InjectionHandler
+public class DependsHandler<X extends RemoteEnvironment> implements InjectionHandler<X>
{
+ @SuppressWarnings("unused")
private static final Logger log = Logger.getLogger(DependsHandler.class);
- public void loadXml(EnvironmentRefGroup xml, InjectionContainer container)
+ public void loadXml(X xml, InjectionContainer container)
{
}
@@ -98,9 +99,9 @@
}
}
- public void handleClassAnnotations(Class clazz, InjectionContainer container)
+ public void handleClassAnnotations(Class<?> clazz, InjectionContainer container)
{
- Depends dep = (Depends)container.getAnnotation(Depends.class, clazz);
+ Depends dep = container.getAnnotation(Depends.class, clazz);
if (dep == null) return;
for (String dependency : dep.value())
{
Modified: trunk/ejb3/src/main/org/jboss/injection/EJBHandler.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/injection/EJBHandler.java 2007-10-30 06:40:04 UTC (rev 66557)
+++ trunk/ejb3/src/main/org/jboss/injection/EJBHandler.java 2007-10-30 09:07:07 UTC (rev 66558)
@@ -21,47 +21,36 @@
*/
package org.jboss.injection;
-import org.jboss.annotation.IgnoreDependency;
-import org.jboss.ejb3.EJBContainer;
-import org.jboss.logging.Logger;
-import org.jboss.metamodel.descriptor.BaseEjbRef;
-import org.jboss.metamodel.descriptor.EjbLocalRef;
-import org.jboss.metamodel.descriptor.EjbRef;
-import org.jboss.metamodel.descriptor.EnvironmentRefGroup;
-
-import javax.ejb.EJB;
-import javax.ejb.EJBs;
-import javax.naming.NameNotFoundException;
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
import java.util.Collection;
-import java.util.Iterator;
-import java.util.Map;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.javaee.spec.EJBLocalReferenceMetaData;
+import org.jboss.metadata.javaee.spec.Environment;
+
/**
- * Searches bean class for all @Inject and create Injectors
+ * Process all ejb references. The non local references are processed
+ * by inheritance.
*
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
* @version $Revision$
*/
-public class EJBHandler extends EJBInjectionHandler
+public class EJBHandler<X extends Environment> extends EJBRemoteHandler<X>
{
+ @SuppressWarnings("unused")
private static final Logger log = Logger.getLogger(EJBHandler.class);
- public void loadXml(EnvironmentRefGroup xml, InjectionContainer container)
+ public void loadXml(X xml, InjectionContainer container)
{
+ super.loadXml(xml, container);
if (xml != null)
{
- if (xml.getEjbLocalRefs() != null) loadEjbLocalXml(xml.getEjbLocalRefs(), container);
- log.trace("ejbRefs = " + xml.getEjbRefs());
- if (xml.getEjbRefs() != null) loadEjbRefXml(xml.getEjbRefs(), container);
+ if (xml.getEjbLocalReferences() != null) loadEjbLocalXml(xml.getEjbLocalReferences(), container);
}
}
- protected void loadEjbLocalXml(Collection<EjbLocalRef> refs, InjectionContainer container)
+ protected void loadEjbLocalXml(Collection<EJBLocalReferenceMetaData> refs, InjectionContainer container)
{
- for (EjbLocalRef ref : refs)
+ for (EJBLocalReferenceMetaData ref : refs)
{
String interfaceName = ref.getLocal();
String errorType = "<ejb-local-ref>";
@@ -69,297 +58,4 @@
ejbRefXml(ref, interfaceName, container, errorType);
}
}
-
- protected void loadEjbRefXml(Collection<EjbRef> refs, InjectionContainer container)
- {
- for (EjbRef ref : refs)
- {
- String interfaceName = ref.getRemote();
- String errorType = "<ejb-ref>";
-
- ejbRefXml(ref, interfaceName, container, errorType);
- }
- }
-
- protected void ejbRefXml(BaseEjbRef ref, String interfaceName, InjectionContainer container, String errorType)
- {
- String encName = "env/" + ref.getEjbRefName();
- InjectionUtil.injectionTarget(encName, ref, container, container.getEncInjections());
- if (container.getEncInjectors().containsKey(encName))
- return;
-
- String mappedName = ref.getMappedName();
- if (mappedName != null && mappedName.equals("")) mappedName = null;
-
- String link = ref.getEjbLink();
- if (link != null && link.trim().equals("")) link = null;
-
- Class refClass = null;
-
- if (interfaceName != null)
- {
- try
- {
- refClass = container.getClassloader().loadClass(interfaceName);
- }
- catch (ClassNotFoundException e)
- {
- throw new RuntimeException("could not find " + errorType + "'s local interface " + interfaceName + " in " + container.getDeploymentDescriptorType() + " of " + container.getIdentifier());
- }
- }
-
- //----- injectors
-
- if (mappedName == null && refClass == null && link == null)
- {
- // must be jboss.xml only with @EJB used to define reference. jboss.xml used to tag for ignore dependency
- // i think it is ok to assume this because the ejb-jar.xml schema should handle any missing elements
- }
- else
- {
- ejbRefEncInjector(mappedName, encName, refClass, link, errorType, container);
- if (ref.isIgnoreDependency())
- {
- log.debug("IGNORING <ejb-ref> DEPENDENCY: " + encName);
- return;
- }
-
- ejbRefDependency(mappedName, link, container, refClass, errorType, encName);
- }
- }
-
- protected void ejbRefDependency(String mappedName, String link, InjectionContainer container, Class refClass, String errorType, String encName)
- {
- if(mappedName != null && mappedName.length() == 0) mappedName = null;
- if (refClass != null && (refClass.equals(Object.class) || refClass.equals(void.class))) refClass = null;
-
- if(mappedName != null)
- {
- addJNDIDependency(container, mappedName);
- return;
- }
-
- if (refClass != null)
- {
- if (link != null && !link.trim().equals(""))
- {
- addDependency(container, link, refClass);
- }
- else
- {
- addDependency(container, refClass);
- }
- }
- else
- {
- String msg = "IGNORING DEPENDENCY: unable to resolve dependency of EJB, there is too little information";
- log.warn(msg);
- }
- }
-
- protected void ejbRefEncInjector(String mappedName, String encName, Class refClass, String link, String errorType, InjectionContainer container)
- {
- if (refClass != null && (refClass.equals(Object.class) || refClass.equals(void.class))) refClass = null;
- if (mappedName != null && mappedName.trim().equals("")) mappedName = null;
-
- EncInjector injector = null;
-
- if (mappedName == null)
- {
- injector = new EjbEncInjector(encName, refClass, link, errorType);
- }
- else
- {
- injector = new EjbEncInjector(encName, mappedName, errorType);
- }
-
- container.getEncInjectors().put(encName, injector);
- }
-
- public static EJBContainer getEjbContainer(EJB ref, InjectionContainer container, Class memberType)
- {
- EJBContainer rtn = null;
-
- if (ref.mappedName() != null && !"".equals(ref.mappedName()))
- {
- return null;
- }
-
- if (ref.beanName().equals("") && memberType == null)
- throw new RuntimeException("For deployment " + container.getIdentifier() + "not enough information for @EJB. Please fill out the beanName and/or businessInterface attributes");
-
- Class businessInterface = memberType;
- if (!ref.beanInterface().getName().equals(Object.class.getName()))
- {
- businessInterface = ref.beanInterface();
- }
-
- if (ref.beanName().equals(""))
- {
- try
- {
- rtn = (EJBContainer) container.resolveEjbContainer(businessInterface);
- }
- catch (NameNotFoundException e)
- {
- log.warn("For deployment " + container.getIdentifier() + " could not find jndi binding based on interface only for @EJB(" + businessInterface.getName() + ") " + e.getMessage());
- }
- }
- else
- {
- rtn = (EJBContainer) container.resolveEjbContainer(ref.beanName(), businessInterface);
- }
-
- return rtn;
- }
-
- public static String getJndiName(EJB ref, InjectionContainer container, Class memberType)
- {
- String jndiName;
-
- if (ref.mappedName() != null && !"".equals(ref.mappedName()))
- {
- return ref.mappedName();
- }
-
- if (ref.beanName().equals("") && memberType == null)
- throw new RuntimeException("For deployment " + container.getIdentifier() + "not enough information for @EJB. Please fill out the beanName and/or businessInterface attributes");
-
- Class businessInterface = memberType;
- if (!ref.beanInterface().getName().equals(Object.class.getName()))
- {
- businessInterface = ref.beanInterface();
- }
-
- if (ref.beanName().equals(""))
- {
- try
- {
- jndiName = container.getEjbJndiName(businessInterface);
- }
- catch (NameNotFoundException e)
- {
- throw new RuntimeException("For deployment " + container.getIdentifier() + " could not find jndi binding based on interface only for @EJB(" + businessInterface.getName() + ") " + e.getMessage());
- }
- if (jndiName == null)
- {
- throw new RuntimeException("For deployment " + container.getIdentifier() + " could not find jndi binding based on interface only for @EJB(" + businessInterface.getName() + ")");
- }
- }
- else
- {
- jndiName = container.getEjbJndiName(ref.beanName(), businessInterface);
- if (jndiName == null)
- {
- throw new RuntimeException("For EJB " + container.getIdentifier() + "could not find jndi binding based on beanName and business interface for @EJB(" + ref.beanName() + ", " + businessInterface.getName() + ")");
- }
- }
-
- return jndiName;
- }
-
- public void handleClassAnnotations(Class clazz, InjectionContainer container)
- {
- EJBs ref = container.getAnnotation(EJBs.class, clazz);
- if (ref != null)
- {
- EJB[] ejbs = ref.value();
-
- for (EJB ejb : ejbs)
- {
- handleClassAnnotation(ejb, clazz, container);
- }
- }
- EJB ejbref = container.getAnnotation(EJB.class, clazz);
- if (ejbref != null) handleClassAnnotation(ejbref, clazz, container);
- }
-
- protected void handleClassAnnotation(EJB ejb, Class clazz, InjectionContainer container)
- {
- String encName = ejb.name();
- if (encName == null || encName.equals(""))
- {
- throw new RuntimeException("JBoss requires the name of the @EJB in the @EJBs: " + clazz);
- }
- encName = "env/" + encName;
-
- if (container.getEncInjectors().containsKey(encName)) return;
- ejbRefEncInjector(ejb.mappedName(), encName, ejb.beanInterface(), ejb.beanName(), "@EJB", container);
-
- // handle dependencies
-
- if (isIgnoreDependency(container, ejb))
- log.debug("IGNORING <ejb-ref> DEPENDENCY: " + encName);
- else
- ejbRefDependency(ejb.mappedName(), ejb.beanName(), container, ejb.beanInterface(), "@EJB", encName);
- }
-
- public void handleMethodAnnotations(Method method, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
- {
- EJB ref = container.getAnnotation(EJB.class, method);
- if (ref != null)
- {
- if (!method.getName().startsWith("set"))
- throw new RuntimeException("@EJB can only be used with a set method: " + method);
- String encName = getEncName(ref, method);
- if (!container.getEncInjectors().containsKey(encName))
- {
- ejbRefEncInjector(ref.mappedName(), encName, method.getParameterTypes()[0], ref.beanName(), "@EJB", container);
-
- if (container.getAnnotation(IgnoreDependency.class, method) == null)
- {
- if (isIgnoreDependency(container, ref))
- log.debug("IGNORING <ejb-ref> DEPENDENCY: " + encName);
- else
- ejbRefDependency(ref.mappedName(), ref.beanName(), container, method.getParameterTypes()[0], "@EJB", encName);
- }
- }
-
- super.handleMethodAnnotations(method, container, injectors);
- }
- }
-
- public void handleFieldAnnotations(Field field, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
- {
- EJB ref = container.getAnnotation(EJB.class, field);
- if (ref != null)
- {
- String encName = getEncName(ref, field);
- if (!container.getEncInjectors().containsKey(encName))
- {
- if (container.getAnnotation(IgnoreDependency.class, field) == null)
- {
- if (isIgnoreDependency(container, ref))
- log.debug("IGNORING <ejb-ref> DEPENDENCY: " + encName);
- else
- ejbRefDependency(ref.mappedName(), ref.beanName(), container, field.getType(), "@EJB", encName);
- }
- ejbRefEncInjector(ref.mappedName(), encName, field.getType(), ref.beanName(), "@EJB", container);
- }
- super.handleFieldAnnotations(field, container, injectors);
- }
- }
-
- protected boolean isIgnoreDependency(InjectionContainer container, EJB ref)
- {
- EnvironmentRefGroup refGroup = (EnvironmentRefGroup)container.getEnvironmentRefGroup();
-
- if (refGroup != null)
- {
- Iterator<EjbRef> ejbRefs = refGroup.getEjbRefs().iterator();
- while (ejbRefs.hasNext())
- {
- EjbRef ejbRef = ejbRefs.next();
- if (ejbRef.getEjbRefName().equals(ref.name()))
- {
- if (ejbRef.isIgnoreDependency())
- return true;
- else
- return false;
- }
- }
- }
-
- return false;
- }
}
Modified: trunk/ejb3/src/main/org/jboss/injection/EJBInjectionHandler.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/injection/EJBInjectionHandler.java 2007-10-30 06:40:04 UTC (rev 66557)
+++ trunk/ejb3/src/main/org/jboss/injection/EJBInjectionHandler.java 2007-10-30 09:07:07 UTC (rev 66558)
@@ -28,15 +28,15 @@
import javax.ejb.EJB;
-import org.jboss.metamodel.descriptor.EnvironmentRefGroup;
+import org.jboss.metadata.javaee.spec.RemoteEnvironment;
/**
* Only does the injection side of an @EJB, not the enc setup.
*
* @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @version $Revision: $
+ * @version $Revision$
*/
-public class EJBInjectionHandler extends AbstractHandler
+public class EJBInjectionHandler<X extends RemoteEnvironment> extends AbstractHandler<X>
{
protected String getEncName(EJB ref, Field field)
{
@@ -66,7 +66,7 @@
return encName;
}
- public void handleClassAnnotations(Class clazz, InjectionContainer container)
+ public void handleClassAnnotations(Class<?> clazz, InjectionContainer container)
{
// do nothing, all class level @EJB are for seting up the enc
}
@@ -91,8 +91,9 @@
injectors.put(method, new JndiMethodInjector(method, encName, container.getEnc()));
}
- public void loadXml(EnvironmentRefGroup xml, InjectionContainer container)
+ public void loadXml(X xml, InjectionContainer container)
{
// TODO: inventorize
+ // Process injection targets?
}
}
Copied: trunk/ejb3/src/main/org/jboss/injection/EJBRemoteHandler.java (from rev 66417, trunk/ejb3/src/main/org/jboss/injection/EJBHandler.java)
===================================================================
--- trunk/ejb3/src/main/org/jboss/injection/EJBRemoteHandler.java (rev 0)
+++ trunk/ejb3/src/main/org/jboss/injection/EJBRemoteHandler.java 2007-10-30 09:07:07 UTC (rev 66558)
@@ -0,0 +1,350 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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.injection;
+
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.Collection;
+import java.util.Map;
+
+import javax.ejb.EJB;
+import javax.ejb.EJBs;
+import javax.naming.NameNotFoundException;
+
+import org.jboss.annotation.IgnoreDependency;
+import org.jboss.ejb3.EJBContainer;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.javaee.spec.AbstractEJBReferenceMetaData;
+import org.jboss.metadata.javaee.spec.EJBReferenceMetaData;
+import org.jboss.metadata.javaee.spec.RemoteEnvironment;
+
+/**
+ * Searches bean class for all @Inject and create Injectors
+ * for a remote environment.
+ *
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @version $Revision$
+ */
+public class EJBRemoteHandler<X extends RemoteEnvironment> extends EJBInjectionHandler<X>
+{
+ private static final Logger log = Logger.getLogger(EJBRemoteHandler.class);
+
+ public void loadXml(X xml, InjectionContainer container)
+ {
+ if (xml != null)
+ {
+ log.trace("ejbRefs = " + xml.getEjbReferences());
+ if (xml.getEjbReferences() != null) loadEjbRefXml(xml.getEjbReferences(), container);
+ }
+ }
+
+ protected void loadEjbRefXml(Collection<EJBReferenceMetaData> refs, InjectionContainer container)
+ {
+ for (EJBReferenceMetaData ref : refs)
+ {
+ String interfaceName = ref.getRemote();
+ String errorType = "<ejb-ref>";
+
+ ejbRefXml(ref, interfaceName, container, errorType);
+ }
+ }
+
+ protected void ejbRefXml(AbstractEJBReferenceMetaData ref, String interfaceName, InjectionContainer container, String errorType)
+ {
+ String encName = "env/" + ref.getEjbRefName();
+ InjectionUtil.injectionTarget(encName, ref, container, container.getEncInjections());
+ if (container.getEncInjectors().containsKey(encName))
+ return;
+
+ String mappedName = ref.getMappedName();
+ if (mappedName != null && mappedName.equals("")) mappedName = null;
+
+ String link = ref.getLink();
+ if (link != null && link.trim().equals("")) link = null;
+
+ Class<?> refClass = null;
+
+ if (interfaceName != null)
+ {
+ try
+ {
+ refClass = container.getClassloader().loadClass(interfaceName);
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new RuntimeException("could not find " + errorType + "'s local interface " + interfaceName + " in " + container.getDeploymentDescriptorType() + " of " + container.getIdentifier());
+ }
+ }
+
+ //----- injectors
+
+ if (mappedName == null && refClass == null && link == null)
+ {
+ // must be jboss.xml only with @EJB used to define reference. jboss.xml used to tag for ignore dependency
+ // i think it is ok to assume this because the ejb-jar.xml schema should handle any missing elements
+ }
+ else
+ {
+ ejbRefEncInjector(mappedName, encName, refClass, link, errorType, container);
+ if (ref.getIgnoreDependency() != null)
+ {
+ log.debug("IGNORING <ejb-ref> DEPENDENCY: " + encName);
+ return;
+ }
+
+ ejbRefDependency(mappedName, link, container, refClass, errorType, encName);
+ }
+ }
+
+ protected void ejbRefDependency(String mappedName, String link, InjectionContainer container, Class<?> refClass, String errorType, String encName)
+ {
+ if(mappedName != null && mappedName.length() == 0) mappedName = null;
+ if (refClass != null && (refClass.equals(Object.class) || refClass.equals(void.class))) refClass = null;
+
+ if(mappedName != null)
+ {
+ addJNDIDependency(container, mappedName);
+ return;
+ }
+
+ if (refClass != null)
+ {
+ if (link != null && !link.trim().equals(""))
+ {
+ addDependency(container, link, refClass);
+ }
+ else
+ {
+ addDependency(container, refClass);
+ }
+ }
+ else
+ {
+ String msg = "IGNORING DEPENDENCY: unable to resolve dependency of EJB, there is too little information";
+ log.warn(msg);
+ }
+ }
+
+ protected void ejbRefEncInjector(String mappedName, String encName, Class refClass, String link, String errorType, InjectionContainer container)
+ {
+ if (refClass != null && (refClass.equals(Object.class) || refClass.equals(void.class))) refClass = null;
+ if (mappedName != null && mappedName.trim().equals("")) mappedName = null;
+
+ EncInjector injector = null;
+
+ if (mappedName == null)
+ {
+ injector = new EjbEncInjector(encName, refClass, link, errorType);
+ }
+ else
+ {
+ injector = new EjbEncInjector(encName, mappedName, errorType);
+ }
+
+ container.getEncInjectors().put(encName, injector);
+ }
+
+ public static EJBContainer getEjbContainer(EJB ref, InjectionContainer container, Class<?> memberType)
+ {
+ EJBContainer rtn = null;
+
+ if (ref.mappedName() != null && !"".equals(ref.mappedName()))
+ {
+ return null;
+ }
+
+ if (ref.beanName().equals("") && memberType == null)
+ throw new RuntimeException("For deployment " + container.getIdentifier() + "not enough information for @EJB. Please fill out the beanName and/or businessInterface attributes");
+
+ Class<?> businessInterface = memberType;
+ if (!ref.beanInterface().getName().equals(Object.class.getName()))
+ {
+ businessInterface = ref.beanInterface();
+ }
+
+ if (ref.beanName().equals(""))
+ {
+ try
+ {
+ rtn = (EJBContainer) container.resolveEjbContainer(businessInterface);
+ }
+ catch (NameNotFoundException e)
+ {
+ log.warn("For deployment " + container.getIdentifier() + " could not find jndi binding based on interface only for @EJB(" + businessInterface.getName() + ") " + e.getMessage());
+ }
+ }
+ else
+ {
+ rtn = (EJBContainer) container.resolveEjbContainer(ref.beanName(), businessInterface);
+ }
+
+ return rtn;
+ }
+
+ public static String getJndiName(EJB ref, InjectionContainer container, Class<?> memberType)
+ {
+ String jndiName;
+
+ if (ref.mappedName() != null && !"".equals(ref.mappedName()))
+ {
+ return ref.mappedName();
+ }
+
+ if (ref.beanName().equals("") && memberType == null)
+ throw new RuntimeException("For deployment " + container.getIdentifier() + "not enough information for @EJB. Please fill out the beanName and/or businessInterface attributes");
+
+ Class<?> businessInterface = memberType;
+ if (!ref.beanInterface().getName().equals(Object.class.getName()))
+ {
+ businessInterface = ref.beanInterface();
+ }
+
+ if (ref.beanName().equals(""))
+ {
+ try
+ {
+ jndiName = container.getEjbJndiName(businessInterface);
+ }
+ catch (NameNotFoundException e)
+ {
+ throw new RuntimeException("For deployment " + container.getIdentifier() + " could not find jndi binding based on interface only for @EJB(" + businessInterface.getName() + ") " + e.getMessage());
+ }
+ if (jndiName == null)
+ {
+ throw new RuntimeException("For deployment " + container.getIdentifier() + " could not find jndi binding based on interface only for @EJB(" + businessInterface.getName() + ")");
+ }
+ }
+ else
+ {
+ jndiName = container.getEjbJndiName(ref.beanName(), businessInterface);
+ if (jndiName == null)
+ {
+ throw new RuntimeException("For EJB " + container.getIdentifier() + "could not find jndi binding based on beanName and business interface for @EJB(" + ref.beanName() + ", " + businessInterface.getName() + ")");
+ }
+ }
+
+ return jndiName;
+ }
+
+ public void handleClassAnnotations(Class<?> clazz, InjectionContainer container)
+ {
+ EJBs ref = container.getAnnotation(EJBs.class, clazz);
+ if (ref != null)
+ {
+ EJB[] ejbs = ref.value();
+
+ for (EJB ejb : ejbs)
+ {
+ handleClassAnnotation(ejb, clazz, container);
+ }
+ }
+ EJB ejbref = container.getAnnotation(EJB.class, clazz);
+ if (ejbref != null) handleClassAnnotation(ejbref, clazz, container);
+ }
+
+ protected void handleClassAnnotation(EJB ejb, Class<?> clazz, InjectionContainer container)
+ {
+ String encName = ejb.name();
+ if (encName == null || encName.equals(""))
+ {
+ throw new RuntimeException("JBoss requires the name of the @EJB in the @EJBs: " + clazz);
+ }
+ encName = "env/" + encName;
+
+ if (container.getEncInjectors().containsKey(encName)) return;
+ ejbRefEncInjector(ejb.mappedName(), encName, ejb.beanInterface(), ejb.beanName(), "@EJB", container);
+
+ // handle dependencies
+
+ if (isIgnoreDependency(container, ejb))
+ log.debug("IGNORING <ejb-ref> DEPENDENCY: " + encName);
+ else
+ ejbRefDependency(ejb.mappedName(), ejb.beanName(), container, ejb.beanInterface(), "@EJB", encName);
+ }
+
+ public void handleMethodAnnotations(Method method, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
+ {
+ EJB ref = container.getAnnotation(EJB.class, method);
+ if (ref != null)
+ {
+ if (!method.getName().startsWith("set"))
+ throw new RuntimeException("@EJB can only be used with a set method: " + method);
+ String encName = getEncName(ref, method);
+ if (!container.getEncInjectors().containsKey(encName))
+ {
+ ejbRefEncInjector(ref.mappedName(), encName, method.getParameterTypes()[0], ref.beanName(), "@EJB", container);
+
+ if (container.getAnnotation(IgnoreDependency.class, method) == null)
+ {
+ if (isIgnoreDependency(container, ref))
+ log.debug("IGNORING <ejb-ref> DEPENDENCY: " + encName);
+ else
+ ejbRefDependency(ref.mappedName(), ref.beanName(), container, method.getParameterTypes()[0], "@EJB", encName);
+ }
+ }
+
+ super.handleMethodAnnotations(method, container, injectors);
+ }
+ }
+
+ public void handleFieldAnnotations(Field field, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
+ {
+ EJB ref = container.getAnnotation(EJB.class, field);
+ if (ref != null)
+ {
+ String encName = getEncName(ref, field);
+ if (!container.getEncInjectors().containsKey(encName))
+ {
+ if (container.getAnnotation(IgnoreDependency.class, field) == null)
+ {
+ if (isIgnoreDependency(container, ref))
+ log.debug("IGNORING <ejb-ref> DEPENDENCY: " + encName);
+ else
+ ejbRefDependency(ref.mappedName(), ref.beanName(), container, field.getType(), "@EJB", encName);
+ }
+ ejbRefEncInjector(ref.mappedName(), encName, field.getType(), ref.beanName(), "@EJB", container);
+ }
+ super.handleFieldAnnotations(field, container, injectors);
+ }
+ }
+
+ protected boolean isIgnoreDependency(InjectionContainer container, EJB ref)
+ {
+ RemoteEnvironment refGroup = container.getEnvironmentRefGroup();
+
+ if (refGroup != null)
+ {
+ for(EJBReferenceMetaData ejbRef : refGroup.getEjbReferences())
+ {
+ if (ejbRef.getEjbRefName().equals(ref.name()))
+ {
+ return ejbRef.getIgnoreDependency() != null;
+ }
+ }
+ }
+
+ // TODO: shouldn't we scan local ejb refs as well?
+
+ return false;
+ }
+}
Modified: trunk/ejb3/src/main/org/jboss/injection/InjectionContainer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/injection/InjectionContainer.java 2007-10-30 06:40:04 UTC (rev 66557)
+++ trunk/ejb3/src/main/org/jboss/injection/InjectionContainer.java 2007-10-30 09:07:07 UTC (rev 66558)
@@ -34,7 +34,8 @@
import org.jboss.ejb3.Container;
import org.jboss.ejb3.DependencyPolicy;
import org.jboss.ejb3.entity.PersistenceUnitDeployment;
-import org.jboss.metamodel.descriptor.EnvironmentRefGroup;
+import org.jboss.metadata.javaee.spec.Environment;
+import org.jboss.metadata.javaee.spec.RemoteEnvironment;
import org.jboss.virtual.VirtualFile;
/**
@@ -69,10 +70,10 @@
PersistenceUnitDeployment getPersistenceUnitDeployment(String unitName) throws NameNotFoundException;
- Container resolveEjbContainer(String link, Class businessIntf);
- Container resolveEjbContainer(Class businessIntf) throws NameNotFoundException;
- String getEjbJndiName(Class businessInterface) throws NameNotFoundException;
- String getEjbJndiName(String link, Class businessInterface);
+ Container resolveEjbContainer(String link, Class<?> businessIntf);
+ Container resolveEjbContainer(Class<?> businessIntf) throws NameNotFoundException;
+ String getEjbJndiName(Class<?> businessInterface) throws NameNotFoundException;
+ String getEjbJndiName(String link, Class<?> businessInterface);
/**
* Find a message destination in a deployment.
@@ -106,7 +107,7 @@
DependencyPolicy getDependencyPolicy();
- EnvironmentRefGroup getEnvironmentRefGroup();
+ RemoteEnvironment getEnvironmentRefGroup();
boolean hasJNDIBinding(String jndiName);
}
Modified: trunk/ejb3/src/main/org/jboss/injection/InjectionHandler.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/injection/InjectionHandler.java 2007-10-30 06:40:04 UTC (rev 66557)
+++ trunk/ejb3/src/main/org/jboss/injection/InjectionHandler.java 2007-10-30 09:07:07 UTC (rev 66558)
@@ -21,7 +21,7 @@
*/
package org.jboss.injection;
-import org.jboss.metamodel.descriptor.EnvironmentRefGroup;
+import org.jboss.metadata.javaee.spec.RemoteEnvironment;
import java.lang.reflect.AccessibleObject;
import java.lang.reflect.Field;
@@ -34,10 +34,10 @@
* @author <a href="mailto:bill at jboss.org">Bill Burke</a>
* @version $Revision$
*/
-public interface InjectionHandler
+public interface InjectionHandler<X extends RemoteEnvironment>
{
- public void loadXml(EnvironmentRefGroup xml, InjectionContainer container);
- public void handleClassAnnotations(Class clazz, InjectionContainer container);
+ public void loadXml(X xml, InjectionContainer container);
+ public void handleClassAnnotations(Class<?> clazz, InjectionContainer container);
public void handleMethodAnnotations(Method method, InjectionContainer container, Map<AccessibleObject, Injector> injectors);
public void handleFieldAnnotations(Field field, InjectionContainer container, Map<AccessibleObject, Injector> injectors);
}
Modified: trunk/ejb3/src/main/org/jboss/injection/InjectionUtil.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/injection/InjectionUtil.java 2007-10-30 06:40:04 UTC (rev 66557)
+++ trunk/ejb3/src/main/org/jboss/injection/InjectionUtil.java 2007-10-30 09:07:07 UTC (rev 66558)
@@ -22,10 +22,16 @@
package org.jboss.injection;
import org.jboss.ejb3.EJBContainer;
+import org.jboss.injection.lang.reflect.BeanProperty;
+import org.jboss.injection.lang.reflect.BeanPropertyFactory;
import org.jboss.logging.Logger;
+import org.jboss.metadata.javaee.spec.RemoteEnvironment;
+import org.jboss.metadata.javaee.spec.ResourceInjectionMetaData;
+import org.jboss.metadata.javaee.spec.ResourceInjectionTargetMetaData;
import org.jboss.metamodel.descriptor.InjectionTarget;
import org.jboss.metamodel.descriptor.Ref;
+import java.lang.annotation.Annotation;
import java.lang.reflect.AccessibleObject;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
@@ -33,6 +39,7 @@
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -87,8 +94,26 @@
collapseXmlMethodInjectors(visitedMethods, clazz.getSuperclass(), xmlDefinedInjectors, classInjectors);
}
- public static void processMethodAnnotations(InjectionContainer container, Collection<InjectionHandler> handlers, Set<String> visitedMethods, Class clazz, Map<AccessibleObject, Injector> classInjectors)
+ /**
+ * Create and add multiple injectors for injection targets.
+ *
+ * @param injectors the list on which to add injectors
+ * @param classLoader the class loader to resolve an injection target
+ * @param factory the injector factory
+ * @param injectionTargets the injection targets
+ */
+ public static void createInjectors(List<Injector> injectors, ClassLoader classLoader, InjectorFactory<?> factory, Collection<ResourceInjectionTargetMetaData> injectionTargets)
{
+ for(ResourceInjectionTargetMetaData injectionTarget : injectionTargets)
+ {
+ AccessibleObject ao = findInjectionTarget(classLoader, injectionTarget);
+ BeanProperty property = BeanPropertyFactory.create(ao);
+ injectors.add(factory.create(property));
+ }
+ }
+
+ public static <X extends RemoteEnvironment> void processMethodAnnotations(InjectionContainer container, Collection<InjectionHandler<X>> handlers, Set<String> visitedMethods, Class<?> clazz, Map<AccessibleObject, Injector> classInjectors)
+ {
if (clazz == null || clazz.equals(Object.class))
{
return;
@@ -109,7 +134,7 @@
if (handlers != null)
{
- for (InjectionHandler handler : handlers)
+ for (InjectionHandler<?> handler : handlers)
{
handler.handleMethodAnnotations(method, container, classInjectors);
}
@@ -119,7 +144,7 @@
processMethodAnnotations(container, handlers, visitedMethods, clazz.getSuperclass(), classInjectors);
}
- public static void processFieldAnnotations(InjectionContainer container, Collection<InjectionHandler> handlers, Class clazz, Map<AccessibleObject, Injector> classInjectors)
+ public static <X extends RemoteEnvironment> void processFieldAnnotations(InjectionContainer container, Collection<InjectionHandler<X>> handlers, Class<?> clazz, Map<AccessibleObject, Injector> classInjectors)
{
if (clazz == null || clazz.equals(Object.class))
{
@@ -132,7 +157,7 @@
for (Field field : fields)
{
log.trace("process field annotation for " + field.toGenericString());
- for (InjectionHandler handler : handlers)
+ for (InjectionHandler<?> handler : handlers)
{
handler.handleFieldAnnotations(field, container, classInjectors);
}
@@ -143,7 +168,7 @@
processFieldAnnotations(container, handlers, clazz.getSuperclass(), classInjectors);
}
- public static void processClassAnnotations(InjectionContainer container, Collection<InjectionHandler> handlers, Class clazz)
+ public static <X extends RemoteEnvironment> void processClassAnnotations(InjectionContainer container, Collection<InjectionHandler<X>> handlers, Class<?> clazz)
{
if (clazz == null || clazz.equals(Object.class))
{
@@ -152,7 +177,7 @@
if (handlers != null)
{
- for (InjectionHandler handler : handlers)
+ for (InjectionHandler<?> handler : handlers)
{
handler.handleClassAnnotations(clazz, container);
}
@@ -162,7 +187,7 @@
processClassAnnotations(container, handlers, clazz.getSuperclass());
}
- public static Map<AccessibleObject, Injector> processAnnotations(InjectionContainer container, Collection<InjectionHandler> handlers, Class clazz)
+ public static <X extends RemoteEnvironment> Map<AccessibleObject, Injector> processAnnotations(InjectionContainer container, Collection<InjectionHandler<X>> handlers, Class<?> clazz)
{
Map<AccessibleObject, Injector> classInjectors = new HashMap<AccessibleObject, Injector>();
HashSet<String> visitedMethods = new HashSet<String>();
@@ -175,29 +200,29 @@
return classInjectors;
}
- public static AccessibleObject findInjectionTarget(ClassLoader loader, InjectionTarget target)
+ public static AccessibleObject findInjectionTarget(ClassLoader loader, ResourceInjectionTargetMetaData target)
{
- Class clazz = null;
+ Class<?> clazz = null;
try
{
- clazz = loader.loadClass(target.getTargetClass());
+ clazz = loader.loadClass(target.getInjectionTargetClass());
}
catch (ClassNotFoundException e)
{
- throw new RuntimeException("<injection-target> class: " + target.getTargetClass() + " was not found nin deployment");
+ throw new RuntimeException("<injection-target> class: " + target.getInjectionTargetClass() + " was not found in deployment");
}
for (Field field : clazz.getDeclaredFields())
{
- if (target.getTargetName().equals(field.getName())) return field;
+ if (target.getInjectionTargetName().equals(field.getName())) return field;
}
for (java.lang.reflect.Method method : clazz.getDeclaredMethods())
{
- if (method.getName().equals(target.getTargetName())) return method;
+ if (method.getName().equals(target.getInjectionTargetName())) return method;
}
- throw new RuntimeException("<injection-target> could not be found: " + target.getTargetClass() + "." + target.getTargetName());
+ throw new RuntimeException("<injection-target> could not be found: " + target.getInjectionTargetClass() + "." + target.getInjectionTargetName());
}
@@ -227,7 +252,7 @@
return getEncName(field.getDeclaringClass()) + "/" + field.getName();
}
- public static Object getAnnotation(Class annotation, EJBContainer container, Class annotatedClass, boolean isContainer)
+ public static Object getAnnotation(Class<? extends Annotation> annotation, EJBContainer container, Class<?> annotatedClass, boolean isContainer)
{
if (isContainer)
{
@@ -239,7 +264,7 @@
}
}
- public static Object getAnnotation(Class annotation, EJBContainer container, Method method, boolean isContainer)
+ public static Object getAnnotation(Class<? extends Annotation> annotation, EJBContainer container, Method method, boolean isContainer)
{
if (isContainer)
{
@@ -251,7 +276,7 @@
}
}
- public static Object getAnnotation(Class annotation, EJBContainer container, Field field, boolean isContainer)
+ public static Object getAnnotation(Class<? extends Annotation> annotation, EJBContainer container, Field field, boolean isContainer)
{
if (isContainer)
{
@@ -263,35 +288,43 @@
}
}
- public static Class injectionTarget(String encName, Ref ref, InjectionContainer container, Map<String, Map<AccessibleObject, Injector>> classInjectors)
+ public static Class<?> injectionTarget(String encName, ResourceInjectionMetaData ref, InjectionContainer container, Map<String, Map<AccessibleObject, Injector>> classInjectors)
{
- if (ref.getInjectionTarget() != null)
+ Class<?> injectionType = null;
+
+ if(ref.getInjectionTargets() == null)
+ return injectionType;
+
+ for(ResourceInjectionTargetMetaData injectionTarget : ref.getInjectionTargets())
{
- Class injectionType;
// todo, get injection target class
- AccessibleObject ao = findInjectionTarget(container.getClassloader(), ref.getInjectionTarget());
- Map<AccessibleObject, Injector> injectors = classInjectors.get(ref.getInjectionTarget().getTargetClass());
+ AccessibleObject ao = findInjectionTarget(container.getClassloader(), injectionTarget);
+ Map<AccessibleObject, Injector> injectors = classInjectors.get(injectionTarget.getInjectionTargetClass());
if (injectors == null)
{
injectors = new HashMap<AccessibleObject, Injector>();
- classInjectors.put(ref.getInjectionTarget().getTargetClass().trim(), injectors);
+ classInjectors.put(injectionTarget.getInjectionTargetClass(), injectors);
}
+ Class<?> type;
if (ao instanceof Field)
{
- injectionType = ((Field) ao).getType();
+ type = ((Field) ao).getType();
injectors.put(ao, new JndiFieldInjector((Field) ao, encName, container.getEnc()));
}
else
{
- injectionType = ((Method) ao).getParameterTypes()[0];
+ type = ((Method) ao).getParameterTypes()[0];
injectors.put(ao, new JndiMethodInjector((Method) ao, encName, container.getEnc()));
}
- return injectionType;
+ if(injectionType == null)
+ injectionType = type;
+ else
+ {
+ if(!injectionType.equals(type))
+ throw new IllegalStateException("Found multiple injection targets with different types");
+ }
}
- else
- {
- return null;
- }
-
+
+ return injectionType;
}
}
Added: trunk/ejb3/src/main/org/jboss/injection/InjectorFactory.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/injection/InjectorFactory.java (rev 0)
+++ trunk/ejb3/src/main/org/jboss/injection/InjectorFactory.java 2007-10-30 09:07:07 UTC (rev 66558)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, 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.injection;
+
+import org.jboss.injection.lang.reflect.BeanProperty;
+
+/**
+ * Allows the creation of injectors.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public interface InjectorFactory<I extends Injector>
+{
+ I create(BeanProperty property);
+}
Property changes on: trunk/ejb3/src/main/org/jboss/injection/InjectorFactory.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: trunk/ejb3/src/main/org/jboss/injection/JndiInjectHandler.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/injection/JndiInjectHandler.java 2007-10-30 06:40:04 UTC (rev 66557)
+++ trunk/ejb3/src/main/org/jboss/injection/JndiInjectHandler.java 2007-10-30 09:07:07 UTC (rev 66558)
@@ -21,31 +21,32 @@
*/
package org.jboss.injection;
-import org.jboss.annotation.JndiInject;
-import org.jboss.logging.Logger;
-import org.jboss.metamodel.descriptor.EnvironmentRefGroup;
-import org.jboss.metamodel.descriptor.JndiRef;
-
import java.lang.reflect.AccessibleObject;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Map;
+import org.jboss.annotation.JndiInject;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
+import org.jboss.metadata.javaee.jboss.JndiRefMetaData;
+
/**
* Searches bean class for all @Inject and create Injectors
*
* @author <a href="mailto:bill at jboss.org">Bill Burke</a>
* @version $Revision$
*/
-public class JndiInjectHandler implements InjectionHandler
+public class JndiInjectHandler<X extends JBossEnterpriseBeanMetaData> implements InjectionHandler<X>
{
+ @SuppressWarnings("unused")
private static final Logger log = Logger.getLogger(JndiInjectHandler.class);
- public void loadXml(EnvironmentRefGroup xml, InjectionContainer container)
+ public void loadXml(X xml, InjectionContainer container)
{
if (xml == null) return;
if (xml.getJndiRefs() == null) return;
- for (JndiRef ref : xml.getJndiRefs())
+ for (JndiRefMetaData ref : xml.getJndiRefs())
{
if (ref.getMappedName() == null || ref.getMappedName().equals(""))
throw new RuntimeException("mapped-name is required for " + ref.getJndiRefName() + " of container " + container.getIdentifier());
@@ -59,7 +60,7 @@
}
}
- public void handleClassAnnotations(Class clazz, InjectionContainer container)
+ public void handleClassAnnotations(Class<?> clazz, InjectionContainer container)
{
// complete
}
Modified: trunk/ejb3/src/main/org/jboss/injection/PersistenceContextHandler.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/injection/PersistenceContextHandler.java 2007-10-30 06:40:04 UTC (rev 66557)
+++ trunk/ejb3/src/main/org/jboss/injection/PersistenceContextHandler.java 2007-10-30 09:07:07 UTC (rev 66558)
@@ -21,10 +21,10 @@
*/
package org.jboss.injection;
-import org.jboss.metamodel.descriptor.PersistenceContextRef;
+import org.jboss.metadata.javaee.spec.Environment;
+import org.jboss.metadata.javaee.spec.PersistenceContextReferenceMetaData;
import org.jboss.logging.Logger;
import org.jboss.annotation.IgnoreDependency;
-import org.jboss.metamodel.descriptor.EnvironmentRefGroup;
import javax.naming.NameNotFoundException;
import javax.persistence.PersistenceContext;
@@ -42,42 +42,43 @@
* @version $Revision$
* @Inject and create Injectors
*/
-public class PersistenceContextHandler implements InjectionHandler
+public class PersistenceContextHandler<X extends Environment> implements InjectionHandler<X>
{
+ @SuppressWarnings("unused")
private static final Logger log = Logger
.getLogger(PersistenceContextHandler.class);
- public void loadXml(EnvironmentRefGroup xml, InjectionContainer container)
+ public void loadXml(X xml, InjectionContainer container)
{
if (xml == null) return;
if (xml.getPersistenceContextRefs() == null) return;
- for (PersistenceContextRef ref : xml.getPersistenceContextRefs())
+ for (PersistenceContextReferenceMetaData ref : xml.getPersistenceContextRefs())
{
- String encName = "env/" + ref.getRefName();
+ String encName = "env/" + ref.getPersistenceContextRefName();
// we add injection target no matter what. enc injection might be overridden but
// XML injection cannot be overriden
- Class injectionType = InjectionUtil.injectionTarget(encName, ref, container, container.getEncInjections());
+ Class<?> injectionType = InjectionUtil.injectionTarget(encName, ref, container, container.getEncInjections());
if (container.getEncInjectors().containsKey(encName))
continue;
// add it to list of
String error = "unable to load <persistence-context-ref> for unitName: "
- + ref.getUnitName() + " <ref-name>: " + ref.getRefName();
- PersistenceContextType type = ref.getPersistenceContextType();
- String unitName = ref.getUnitName();
+ + ref.getPersistenceUnitName() + " <ref-name>: " + ref.getPersistenceContextRefName();
+ PersistenceContextType type = toSpec(ref.getPersistenceContextType());
+ String unitName = ref.getPersistenceUnitName();
container.getEncInjectors().put(encName, new PcEncInjector(encName, unitName, type, injectionType, error));
try
{
- PersistenceUnitHandler.addPUDependency(ref.getUnitName(), container);
+ PersistenceUnitHandler.addPUDependency(ref.getPersistenceUnitName(), container);
}
catch (NameNotFoundException e)
{
- throw new RuntimeException("Illegal <persistence-context-ref> of " + ref.getRefName() + " :" + e.getMessage());
+ throw new RuntimeException("Illegal <persistence-context-ref> of " + ref.getPersistenceContextRefName() + " :" + e.getMessage());
}
}
}
- public void handleClassAnnotations(Class clazz, InjectionContainer container)
+ public void handleClassAnnotations(Class<?> clazz, InjectionContainer container)
{
PersistenceContexts resources = container.getAnnotation(PersistenceContexts.class, clazz);
if (resources != null)
@@ -97,7 +98,7 @@
}
private static void loadPersistenceContextClassAnnotation(
- PersistenceContext ref, InjectionContainer container, Class clazz)
+ PersistenceContext ref, InjectionContainer container, Class<?> clazz)
{
String encName = ref.name();
if (encName == null || encName.equals(""))
@@ -190,4 +191,17 @@
injectors.put(field, new JndiFieldInjector(field,
encName, container.getEnc()));
}
+
+ private static PersistenceContextType toSpec(org.jboss.metadata.javaee.spec.PersistenceContextType p)
+ {
+ switch(p)
+ {
+ case Extended:
+ return PersistenceContextType.EXTENDED;
+ case Transaction:
+ return PersistenceContextType.TRANSACTION;
+ default:
+ throw new IllegalArgumentException("Unknown persistence context type " + p);
+ }
+ }
}
Modified: trunk/ejb3/src/main/org/jboss/injection/PersistenceUnitHandler.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/injection/PersistenceUnitHandler.java 2007-10-30 06:40:04 UTC (rev 66557)
+++ trunk/ejb3/src/main/org/jboss/injection/PersistenceUnitHandler.java 2007-10-30 09:07:07 UTC (rev 66558)
@@ -25,6 +25,7 @@
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Map;
+
import javax.naming.NameNotFoundException;
import javax.persistence.EntityManagerFactory;
import javax.persistence.PersistenceUnit;
@@ -37,8 +38,8 @@
import org.jboss.ejb3.entity.ManagedEntityManagerFactory;
import org.jboss.ejb3.entity.PersistenceUnitDeployment;
import org.jboss.logging.Logger;
-import org.jboss.metamodel.descriptor.EnvironmentRefGroup;
-import org.jboss.metamodel.descriptor.PersistenceUnitRef;
+import org.jboss.metadata.javaee.spec.PersistenceUnitReferenceMetaData;
+import org.jboss.metadata.javaee.spec.RemoteEnvironment;
/**
* Searches bean class for all @Inject and create Injectors
@@ -46,37 +47,37 @@
* @author <a href="mailto:bill at jboss.org">Bill Burke</a>
* @version $Revision$
*/
-public class PersistenceUnitHandler implements InjectionHandler
+public class PersistenceUnitHandler<X extends RemoteEnvironment> implements InjectionHandler<X>
{
private static final Logger log = Logger.getLogger(PersistenceUnitHandler.class);
- public void loadXml(EnvironmentRefGroup xml, InjectionContainer container)
+ public void loadXml(X xml, InjectionContainer container)
{
if (xml == null) return;
if (xml.getPersistenceUnitRefs() == null) return;
- for (PersistenceUnitRef ref : xml.getPersistenceUnitRefs())
+ for (PersistenceUnitReferenceMetaData ref : xml.getPersistenceUnitRefs())
{
- String encName = "env/" + ref.getRefName();
+ String encName = "env/" + ref.getPersistenceUnitRefName();
// we add injection target no matter what. enc injection might be overridden but
// XML injection cannot be overriden
- Class injectionType = InjectionUtil.injectionTarget(encName, ref, container, container.getEncInjections());
+ Class<?> injectionType = InjectionUtil.injectionTarget(encName, ref, container, container.getEncInjections());
if (container.getEncInjectors().containsKey(encName))
return;
- container.getEncInjectors().put(encName, new PuEncInjector(encName, injectionType, ref.getUnitName(), "<persistence-unit-ref>"));
+ container.getEncInjectors().put(encName, new PuEncInjector(encName, injectionType, ref.getPersistenceUnitName(), "<persistence-unit-ref>"));
try
{
- addPUDependency(ref.getUnitName(), container);
+ addPUDependency(ref.getPersistenceUnitName(), container);
}
catch (NameNotFoundException e)
{
- throw new RuntimeException("Illegal <persistence-unit-ref> of " + ref.getRefName() + " :" + e.getMessage());
+ throw new RuntimeException("Illegal <persistence-unit-ref> of " + ref.getPersistenceUnitRefName() + " :" + e.getMessage());
}
}
}
- public void handleClassAnnotations(Class clazz, InjectionContainer container)
+ public void handleClassAnnotations(Class<?> clazz, InjectionContainer container)
{
PersistenceUnits resources = container.getAnnotation(
PersistenceUnits.class, clazz);
@@ -94,7 +95,7 @@
}
}
- private static void handleClassAnnotation(PersistenceUnit ref, InjectionContainer container, Class clazz)
+ private static void handleClassAnnotation(PersistenceUnit ref, InjectionContainer container, Class<?> clazz)
{
String encName = ref.name();
if (encName == null || encName.equals(""))
@@ -153,7 +154,7 @@
return getEntityManagerFactory(ref.unitName(), container);
}
- public static Object getFactory(Class type, String unitName, InjectionContainer container) throws NameNotFoundException
+ public static Object getFactory(Class<?> type, String unitName, InjectionContainer container) throws NameNotFoundException
{
if (type != null && type.getName().equals(SessionFactory.class.getName()))
return getSessionFactory(unitName, container);
Modified: trunk/ejb3/src/main/org/jboss/injection/ResourceHandler.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/injection/ResourceHandler.java 2007-10-30 06:40:04 UTC (rev 66557)
+++ trunk/ejb3/src/main/org/jboss/injection/ResourceHandler.java 2007-10-30 09:07:07 UTC (rev 66558)
@@ -21,19 +21,13 @@
*/
package org.jboss.injection;
-import org.jboss.ejb3.Container;
-import org.jboss.injection.lang.reflect.BeanProperty;
-import org.jboss.injection.lang.reflect.BeanPropertyFactory;
-import org.jboss.injection.lang.reflect.FieldBeanProperty;
-import org.jboss.injection.lang.reflect.MethodBeanProperty;
-import org.jboss.logging.Logger;
-import org.jboss.metamodel.descriptor.EnvEntry;
-import org.jboss.metamodel.descriptor.EnvironmentRefGroup;
-import org.jboss.metamodel.descriptor.MessageDestinationRef;
-import org.jboss.metamodel.descriptor.ResourceEnvRef;
-import org.jboss.metamodel.descriptor.ResourceRef;
-import org.jboss.reflect.plugins.ValueConvertor;
-import org.omg.CORBA.ORB;
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Collection;
+import java.util.Map;
import javax.annotation.Resource;
import javax.annotation.Resources;
@@ -43,19 +37,24 @@
import javax.transaction.UserTransaction;
import javax.xml.ws.WebServiceContext;
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.Collection;
-import java.util.Map;
-import java.net.URL;
-import java.net.MalformedURLException;
+import org.jboss.ejb3.Container;
+import org.jboss.injection.lang.reflect.BeanProperty;
+import org.jboss.injection.lang.reflect.FieldBeanProperty;
+import org.jboss.injection.lang.reflect.MethodBeanProperty;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.javaee.spec.EnvironmentEntryMetaData;
+import org.jboss.metadata.javaee.spec.MessageDestinationReferenceMetaData;
+import org.jboss.metadata.javaee.spec.RemoteEnvironment;
+import org.jboss.metadata.javaee.spec.ResourceEnvironmentReferenceMetaData;
+import org.jboss.metadata.javaee.spec.ResourceReferenceMetaData;
+import org.jboss.reflect.plugins.ValueConvertor;
+import org.omg.CORBA.ORB;
/**
* @author <a href="mailto:bill at jboss.org">Bill Burke</a>
* @version $Revision$
*/
-public class ResourceHandler implements InjectionHandler
+public class ResourceHandler<X extends RemoteEnvironment> implements InjectionHandler<X>
{
private static final Logger log = Logger.getLogger(ResourceHandler.class);
@@ -88,14 +87,14 @@
}
}
- private static void loadEnvEntry(InjectionContainer container, Collection<EnvEntry> envEntries)
+ private static void loadEnvEntry(InjectionContainer container, Collection<EnvironmentEntryMetaData> envEntries)
{
- for (EnvEntry envEntry : envEntries)
+ for (EnvironmentEntryMetaData envEntry : envEntries)
{
String encName = "env/" + envEntry.getEnvEntryName();
// 16.4.1.3: If the env-entry-value is not specified, no value will be injected and it
// will not be initialized into the naming context.
- if(envEntry.getEnvEntryValue() == null)
+ if(envEntry.getValue() == null)
{
log.debug("ignoring env-entry " + envEntry);
continue;
@@ -103,15 +102,15 @@
InjectionUtil.injectionTarget(encName, envEntry, container, container.getEncInjections());
if (container.getEncInjectors().containsKey(encName)) continue;
log.trace("adding env-entry injector " + encName);
- container.getEncInjectors().put(encName, new EnvEntryEncInjector(encName, envEntry.getEnvEntryType(), envEntry.getEnvEntryValue()));
+ container.getEncInjectors().put(encName, new EnvEntryEncInjector(encName, envEntry.getType(), envEntry.getValue()));
}
}
- private static void loadXmlResourceRefs(InjectionContainer container, Collection<ResourceRef> refs)
+ private static void loadXmlResourceRefs(InjectionContainer container, Collection<ResourceReferenceMetaData> refs)
{
- for (ResourceRef envRef : refs)
+ for (ResourceReferenceMetaData envRef : refs)
{
- String encName = "env/" + envRef.getResRefName();
+ String encName = "env/" + envRef.getResourceRefName();
if (container.getEncInjectors().containsKey(encName)) continue;
if (envRef.getMappedName() == null || envRef.getMappedName().equals(""))
{
@@ -128,7 +127,7 @@
}
else
{
- throw new RuntimeException("mapped-name is required for " + envRef.getResRefName() + " of deployment " + container.getIdentifier());
+ throw new RuntimeException("mapped-name is required for " + envRef.getResourceRefName() + " of deployment " + container.getIdentifier());
}
}
else
@@ -139,13 +138,13 @@
}
}
- private static void loadXmlResourceEnvRefs(InjectionContainer container, Collection<ResourceEnvRef> refs)
+ private static void loadXmlResourceEnvRefs(InjectionContainer container, Collection<ResourceEnvironmentReferenceMetaData> refs)
{
- for (ResourceEnvRef envRef : refs)
+ for (ResourceEnvironmentReferenceMetaData envRef : refs)
{
// EJBTHREE-712
// TODO: refactor with handlePropertyAnnotation
- String resTypeName = envRef.getResType();
+ String resTypeName = envRef.getType();
try
{
if(resTypeName != null)
@@ -153,8 +152,14 @@
Class<?> resType = Class.forName(resTypeName);
if(EJBContext.class.isAssignableFrom(resType))
{
- AccessibleObject ao = InjectionUtil.findInjectionTarget(container.getClassloader(), envRef.getInjectionTarget());
- container.getInjectors().add(new EJBContextPropertyInjector(BeanPropertyFactory.create(ao)));
+ InjectorFactory<?> factory = new InjectorFactory<EJBContextPropertyInjector>()
+ {
+ public EJBContextPropertyInjector create(BeanProperty property)
+ {
+ return new EJBContextPropertyInjector(property);
+ }
+ };
+ InjectionUtil.createInjectors(container.getInjectors(), container.getClassloader(), factory, envRef.getInjectionTargets());
continue;
}
}
@@ -164,20 +169,20 @@
throw new EJBException(e);
}
- String encName = "env/" + envRef.getResRefName();
+ String encName = "env/" + envRef.getResourceEnvRefName();
if (container.getEncInjectors().containsKey(encName)) continue;
if (envRef.getMappedName() == null || envRef.getMappedName().equals(""))
{
- throw new RuntimeException("mapped-name is required for " + envRef.getResRefName() + " of deployment " + container.getIdentifier());
+ throw new RuntimeException("mapped-name is required for " + envRef.getResourceEnvRefName() + " of deployment " + container.getIdentifier());
}
container.getEncInjectors().put(encName, new LinkRefEncInjector(encName, envRef.getMappedName(), "<resource-ref>"));
InjectionUtil.injectionTarget(encName, envRef, container, container.getEncInjections());
}
}
- private static void loadXmlMessageDestinationRefs(InjectionContainer container, Collection<MessageDestinationRef> refs)
+ private static void loadXmlMessageDestinationRefs(InjectionContainer container, Collection<MessageDestinationReferenceMetaData> refs)
{
- for (MessageDestinationRef envRef : refs)
+ for (MessageDestinationReferenceMetaData envRef : refs)
{
String encName = "env/" + envRef.getMessageDestinationRefName();
if (container.getEncInjectors().containsKey(encName)) continue;
@@ -185,7 +190,7 @@
if (jndiName == null || jndiName.equals(""))
{
// Look for a message-destination-link
- String link = envRef.getMessageDestinationLink();
+ String link = envRef.getLink();
if( link != null )
{
jndiName = container.resolveMessageDestination(link);
@@ -199,16 +204,16 @@
}
}
- public void loadXml(EnvironmentRefGroup xml, InjectionContainer container)
+ public void loadXml(X xml, InjectionContainer container)
{
if (xml == null) return;
- if (xml.getMessageDestinationRefs() != null) loadXmlMessageDestinationRefs(container, xml.getMessageDestinationRefs());
- if (xml.getResourceEnvRefs() != null) loadXmlResourceEnvRefs(container, xml.getResourceEnvRefs());
- if (xml.getResourceRefs() != null) loadXmlResourceRefs(container, xml.getResourceRefs());
- if (xml.getEnvEntries() != null) loadEnvEntry(container, xml.getEnvEntries());
+ if (xml.getMessageDestinationReferences() != null) loadXmlMessageDestinationRefs(container, xml.getMessageDestinationReferences());
+ if (xml.getResourceEnvironmentReferences() != null) loadXmlResourceEnvRefs(container, xml.getResourceEnvironmentReferences());
+ if (xml.getResourceReferences() != null) loadXmlResourceRefs(container, xml.getResourceReferences());
+ if (xml.getEnvironmentEntries() != null) loadEnvEntry(container, xml.getEnvironmentEntries());
}
- public void handleClassAnnotations(Class clazz, InjectionContainer container)
+ public void handleClassAnnotations(Class<?> clazz, InjectionContainer container)
{
Resources resources = container.getAnnotation(Resources.class, clazz);
if (resources != null)
@@ -222,7 +227,7 @@
if (res != null) handleClassAnnotation(res, container, clazz);
}
- private void handleClassAnnotation(Resource ref, InjectionContainer container, Class clazz)
+ private void handleClassAnnotation(Resource ref, InjectionContainer container, Class<?> clazz)
{
String encName = ref.name();
if (encName == null || encName.equals(""))
Modified: trunk/ejb3/src/main/org/jboss/injection/ServiceRefInjector.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/injection/ServiceRefInjector.java 2007-10-30 06:40:04 UTC (rev 66557)
+++ trunk/ejb3/src/main/org/jboss/injection/ServiceRefInjector.java 2007-10-30 09:07:07 UTC (rev 66558)
@@ -29,10 +29,9 @@
import javax.xml.ws.WebServiceException;
import org.jboss.logging.Logger;
+import org.jboss.metadata.javaee.spec.ServiceReferenceMetaData;
import org.jboss.metadata.serviceref.VirtualFileAdaptor;
-import org.jboss.metamodel.descriptor.ServiceRefDelegate;
import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
-import org.jboss.wsf.spi.serviceref.ServiceRefMetaData;
/**
* Inject a web service ref.
@@ -45,13 +44,14 @@
private static final Logger log = Logger.getLogger(ServiceRefInjector.class);
private String name;
- private ServiceRefMetaData sref;
+ private ServiceReferenceMetaData sref;
- public ServiceRefInjector(String name, AnnotatedElement anElement, ServiceRefMetaData sref)
+ public ServiceRefInjector(String name, AnnotatedElement anElement, ServiceReferenceMetaData sref)
{
this.name = name;
this.sref = sref;
- sref.setAnnotatedElement(anElement);
+ // FIXME: fix WS metadata
+ //sref.setAnnotatedElement(anElement);
}
public void inject(InjectionContainer container)
@@ -61,7 +61,8 @@
Context envCtx = container.getEnc();
ClassLoader loader = container.getClassloader();
UnifiedVirtualFile vfsRoot = new VirtualFileAdaptor(container.getRootFile());
- new ServiceRefDelegate().bindServiceRef(envCtx, name, vfsRoot, loader, sref);
+ // FIXME: fix WS metadata
+ //new ServiceRefDelegate().bindServiceRef(envCtx, name, vfsRoot, loader, sref);
}
catch (Exception e)
{
Modified: trunk/ejb3/src/main/org/jboss/injection/WebServiceRefHandler.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/injection/WebServiceRefHandler.java 2007-10-30 06:40:04 UTC (rev 66557)
+++ trunk/ejb3/src/main/org/jboss/injection/WebServiceRefHandler.java 2007-10-30 09:07:07 UTC (rev 66558)
@@ -34,25 +34,26 @@
import javax.xml.ws.WebServiceRefs;
import org.jboss.logging.Logger;
-import org.jboss.metamodel.descriptor.EnvironmentRefGroup;
-import org.jboss.metamodel.descriptor.ServiceRefDelegate;
-import org.jboss.wsf.spi.serviceref.ServiceRefMetaData;
+import org.jboss.metadata.javaee.spec.RemoteEnvironment;
+import org.jboss.metadata.javaee.spec.ServiceReferenceMetaData;
+import org.jboss.metadata.javaee.spec.ServiceReferencesMetaData;
/**
* Handle @WebServiceRef annotations
*
* @author Thomas.Diesler at jboss.com
*/
-public class WebServiceRefHandler implements InjectionHandler
+public class WebServiceRefHandler<X extends RemoteEnvironment> implements InjectionHandler<X>
{
private static final Logger log = Logger.getLogger(WebServiceRefHandler.class);
- private Map<String, ServiceRefMetaData> srefMap = new HashMap<String, ServiceRefMetaData>();
+ private Map<String, ServiceReferenceMetaData> srefMap = new HashMap<String, ServiceReferenceMetaData>();
- public void loadXml(EnvironmentRefGroup xml, InjectionContainer container)
+ public void loadXml(X xml, InjectionContainer container)
{
if (xml == null) return;
- if (xml.getServiceRefs() == null) return;
- for (ServiceRefMetaData sref : xml.getServiceRefs())
+ ServiceReferencesMetaData serviceRefs = xml.getServiceReferences();
+ if (serviceRefs == null) return;
+ for (ServiceReferenceMetaData sref : serviceRefs)
{
log.debug("service-ref: " + sref);
if (srefMap.get(sref.getServiceRefName()) != null)
@@ -62,7 +63,7 @@
}
}
- public void handleClassAnnotations(Class type, InjectionContainer container)
+ public void handleClassAnnotations(Class<?> type, InjectionContainer container)
{
WebServiceRef wsref = container.getAnnotation(WebServiceRef.class, type);
if (wsref != null)
@@ -80,7 +81,7 @@
}
}
- private void bindRefOnType(Class type, InjectionContainer container, WebServiceRef wsref)
+ private void bindRefOnType(Class<?> type, InjectionContainer container, WebServiceRef wsref)
{
String name = wsref.name();
if (name.equals(""))
@@ -89,7 +90,7 @@
if (!container.getEncInjectors().containsKey(name))
{
String encName = "env/" + name;
- ServiceRefMetaData sref = getServiceRef(name);
+ ServiceReferenceMetaData sref = getServiceRef(name);
container.getEncInjectors().put(name, new ServiceRefInjector(encName, type, sref));
}
}
@@ -110,7 +111,7 @@
Context encCtx = container.getEnc();
if (!container.getEncInjectors().containsKey(name))
{
- ServiceRefMetaData sref = getServiceRef(name);
+ ServiceReferenceMetaData sref = getServiceRef(name);
container.getEncInjectors().put(name, new ServiceRefInjector(encName, method, sref));
}
@@ -130,21 +131,22 @@
Context encCtx = container.getEnc();
if (!container.getEncInjectors().containsKey(name))
{
- ServiceRefMetaData sref = getServiceRef(name);
+ ServiceReferenceMetaData sref = getServiceRef(name);
container.getEncInjectors().put(name, new ServiceRefInjector(encName, field, sref));
}
injectors.put(field, new JndiFieldInjector(field, encName, encCtx));
}
- private ServiceRefMetaData getServiceRef(String name)
+ private ServiceReferenceMetaData getServiceRef(String name)
{
- ServiceRefMetaData sref = srefMap.get(name);
+ ServiceReferenceMetaData sref = srefMap.get(name);
if (sref == null)
{
log.debug("No override for @WebServiceRef.name: " + name);
- sref = new ServiceRefDelegate().newServiceRefMetaData();
- sref.setServiceRefName(name);
+ // FIXME: fix WS metadata
+ //sref = new ServiceRefDelegate().newServiceRefMetaData();
+ //sref.setServiceRefName(name);
}
return sref;
}
Modified: trunk/ejb3/src/resources/META-INF/ejb3-deployers-beans.xml
===================================================================
--- trunk/ejb3/src/resources/META-INF/ejb3-deployers-beans.xml 2007-10-30 06:40:04 UTC (rev 66557)
+++ trunk/ejb3/src/resources/META-INF/ejb3-deployers-beans.xml 2007-10-30 09:07:07 UTC (rev 66558)
@@ -9,7 +9,7 @@
<bean name="java:comp/Initializer" class="org.jboss.ejb3.embedded.JavaCompInitializer"/>
<bean name="DefaultPersistenceProperties" class="org.jboss.ejb3.DefaultPersistenceProperties"/>
- <bean name="EJBRegistrationDeployer" class="org.jboss.ejb3.deployers.EJBRegistrationDeployer">
+ <bean name="Ejb3Deployer" class="org.jboss.ejb3.deployers.Ejb3Deployer">
<property name="type">ejb3x</property>
<property name="kernel"><inject bean="jboss.kernel:service=Kernel"/></property>
<property name="mbeanServer"><inject bean="JMXKernel" property="mbeanServer"/></property>
@@ -26,7 +26,7 @@
Default for this value is "false".
-->
- <property name="requireDeploymentDescriptor">false</property>
+ <property name="deploymentDescriptorRequired">false</property>
<property name="ignoredJarsSet">
<set elementClass="java.lang.String">
Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/appclient/unit/AppClientUnitTestCase.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/appclient/unit/AppClientUnitTestCase.java 2007-10-30 06:40:04 UTC (rev 66557)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/appclient/unit/AppClientUnitTestCase.java 2007-10-30 09:07:07 UTC (rev 66558)
@@ -29,6 +29,7 @@
import org.jboss.ejb3.client.ClientLauncher;
import org.jboss.ejb3.metamodel.ApplicationClientDD;
import org.jboss.ejb3.test.appclient.client.HelloWorldClient;
+import org.jboss.metadata.client.jboss.JBossClientMetaData;
import org.jboss.test.JBossTestCase;
/**
@@ -48,7 +49,7 @@
{
URL url = Thread.currentThread().getContextClassLoader().getResource("appclient/application-client.xml");
URL jbossClientURL = Thread.currentThread().getContextClassLoader().getResource("appclient/jboss-client.xml");
- ApplicationClientDD xml = ClientLauncher.loadXML(url, jbossClientURL);
+ JBossClientMetaData xml = ClientLauncher.loadXML(url, jbossClientURL);
String mainClassName = HelloWorldClient.class.getName();
String applicationClientName = "applicationclient_test"; // must match JNDI name in jboss-client.xml or display-name in application-client.xml
Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/appclient/unit/SimpleResourceEarUnitTestCase.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/appclient/unit/SimpleResourceEarUnitTestCase.java 2007-10-30 06:40:04 UTC (rev 66557)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/appclient/unit/SimpleResourceEarUnitTestCase.java 2007-10-30 09:07:07 UTC (rev 66558)
@@ -31,6 +31,7 @@
import org.jboss.ejb3.client.ClientLauncher;
import org.jboss.ejb3.metamodel.ApplicationClientDD;
import org.jboss.ejb3.test.appclient.client.SimpleResourceClient;
+import org.jboss.metadata.client.jboss.JBossClientMetaData;
import org.jboss.test.JBossTestCase;
/**
@@ -98,7 +99,7 @@
URL url = Thread.currentThread().getContextClassLoader().getResource("appclient/simpleresource/application-client.xml");
//URL jbossClientURL = Thread.currentThread().getContextClassLoader().getResource("appclient/jboss-client.xml");
URL jbossClientURL = null;
- ApplicationClientDD xml = ClientLauncher.loadXML(url, jbossClientURL);
+ JBossClientMetaData xml = ClientLauncher.loadXML(url, jbossClientURL);
String mainClassName = SimpleResourceClient.class.getName();
String applicationClientName = "appclient-simpleresource-client"; // must match JNDI name in jboss-client.xml or display-name in application-client.xml
Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/appclient/unit/SimpleResourceUnitTestCase.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/appclient/unit/SimpleResourceUnitTestCase.java 2007-10-30 06:40:04 UTC (rev 66557)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/appclient/unit/SimpleResourceUnitTestCase.java 2007-10-30 09:07:07 UTC (rev 66558)
@@ -31,6 +31,7 @@
import org.jboss.ejb3.client.ClientLauncher;
import org.jboss.ejb3.metamodel.ApplicationClientDD;
import org.jboss.ejb3.test.appclient.client.SimpleResourceClient;
+import org.jboss.metadata.client.jboss.JBossClientMetaData;
import org.jboss.test.JBossTestCase;
/**
@@ -98,7 +99,7 @@
URL url = Thread.currentThread().getContextClassLoader().getResource("appclient/simpleresource/application-client.xml");
//URL jbossClientURL = Thread.currentThread().getContextClassLoader().getResource("appclient/jboss-client.xml");
URL jbossClientURL = null;
- ApplicationClientDD xml = ClientLauncher.loadXML(url, jbossClientURL);
+ JBossClientMetaData xml = ClientLauncher.loadXML(url, jbossClientURL);
String mainClassName = SimpleResourceClient.class.getName();
String applicationClientName = "appclient-simpleresource-client"; // must match JNDI name in jboss-client.xml or display-name in application-client.xml
Modified: trunk/server/src/main/org/jboss/deployment/JBossEjbParsingDeployer.java
===================================================================
--- trunk/server/src/main/org/jboss/deployment/JBossEjbParsingDeployer.java 2007-10-30 06:40:04 UTC (rev 66557)
+++ trunk/server/src/main/org/jboss/deployment/JBossEjbParsingDeployer.java 2007-10-30 09:07:07 UTC (rev 66558)
@@ -73,15 +73,6 @@
@Override
protected JBossMetaData parse(VFSDeploymentUnit unit, VirtualFile file, JBossMetaData root) throws Exception
{
- // Wolf: hack to get to old EJB3 deployer, once that one is gone
- // this should be removed.
- // FIXME: unify the deployers (JBAS-4506)
- {
- EjbJarMetaData ejbJar = unit.getAttachment(EjbJarMetaData.class);
- if (ejbJar == null || ejbJar.isEJB3x())
- return null;
- }
-
JBossMetaData metaData = super.parse(unit, file, root);
return metaData;
}
Modified: trunk/tomcat/.classpath
===================================================================
--- trunk/tomcat/.classpath 2007-10-30 06:40:04 UTC (rev 66557)
+++ trunk/tomcat/.classpath 2007-10-30 09:07:07 UTC (rev 66558)
@@ -57,7 +57,12 @@
<classpathentry combineaccessrules="false" kind="src" path="/main"/>
<classpathentry combineaccessrules="false" kind="src" path="/iiop"/>
<classpathentry kind="lib" path="/thirdparty/jboss/jbossws/lib/jboss-jaxws.jar"/>
- <classpathentry kind="lib" path="/thirdparty/jboss/metadata/lib/jboss-metadata.jar" sourcepath="/thirdparty/jboss/metadata/lib/jboss-metadata-sources.jar"/>
+ <classpathentry kind="lib" path="/thirdparty/jboss/metadata/lib/jboss-metadata.jar" sourcepath="/thirdparty/jboss/metadata/lib/jboss-metadata-sources.jar">
+ <accessrules>
+ <accessrule kind="discouraged" pattern="org/jboss/ejb3/**"/>
+ <accessrule kind="discouraged" pattern="org/jboss/metamodel/**"/>
+ </accessrules>
+ </classpathentry>
<classpathentry kind="lib" path="/thirdparty/sun-jaxb/lib/jaxb-api.jar"/>
<classpathentry kind="output" path="output/eclipse-classes"/>
</classpath>
Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/TomcatInjectionContainer.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/TomcatInjectionContainer.java 2007-10-30 06:40:04 UTC (rev 66557)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/TomcatInjectionContainer.java 2007-10-30 09:07:07 UTC (rev 66558)
@@ -23,8 +23,6 @@
// $Id: $
-import java.io.IOException;
-import java.io.InputStream;
import java.lang.annotation.Annotation;
import java.lang.reflect.AccessibleObject;
import java.lang.reflect.Field;
@@ -43,7 +41,6 @@
import javax.naming.NamingException;
import org.apache.InstanceManager;
-import org.apache.catalina.core.StandardContext;
import org.jboss.deployers.structure.spi.main.MainDeployerStructure;
import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
import org.jboss.ejb3.Container;
@@ -61,23 +58,22 @@
import org.jboss.injection.InjectionHandler;
import org.jboss.injection.InjectionUtil;
import org.jboss.injection.Injector;
-import org.jboss.injection.JndiInjectHandler;
import org.jboss.injection.PersistenceContextHandler;
import org.jboss.injection.PersistenceUnitHandler;
import org.jboss.injection.ResourceHandler;
import org.jboss.injection.WebServiceRefHandler;
import org.jboss.logging.Logger;
-import org.jboss.metamodel.descriptor.EnvironmentRefGroup;
-import org.jboss.metamodel.descriptor.Listener;
+import org.jboss.metadata.javaee.spec.Environment;
+import org.jboss.metadata.web.spec.FilterMetaData;
+import org.jboss.metadata.web.spec.FiltersMetaData;
+import org.jboss.metadata.web.spec.ListenerMetaData;
+import org.jboss.metadata.web.spec.ServletMetaData;
+import org.jboss.metadata.web.spec.ServletsMetaData;
+import org.jboss.metadata.web.spec.WebMetaData;
import org.jboss.util.NotImplementedException;
import org.jboss.virtual.VirtualFile;
import org.jboss.web.WebApplication;
import org.jboss.web.metamodel.descriptor.Filter;
-import org.jboss.web.metamodel.descriptor.JBossWebDDObjectFactory;
-import org.jboss.web.metamodel.descriptor.Servlet;
-import org.jboss.web.metamodel.descriptor.WebDD;
-import org.jboss.web.metamodel.descriptor.WebDDObjectFactory;
-import org.jboss.xb.binding.JBossXBException;
/**
* Comment
@@ -135,11 +131,11 @@
protected DeploymentPersistenceUnitResolver persistenceUnitResolver;
protected WarEjbResolver ejbResolver;
protected DependencyPolicy dependencyPolicy = new JBoss5DependencyPolicy(this);
- protected Collection<InjectionHandler> handlers;
+ protected Collection<InjectionHandler<Environment>> handlers;
protected VFSDeploymentUnit unit;
protected ClassLoader webLoader;
protected WebApplication appInfo;
- protected WebDD webDD;
+ protected WebMetaData webDD;
protected org.apache.catalina.Context catalinaContext;
public TomcatInjectionContainer(WebApplication appInfo, VFSDeploymentUnit unit, org.apache.catalina.Context catalinaContext, MainDeployerStructure mainDeployer)
@@ -153,15 +149,18 @@
persistenceUnitResolver = new DeploymentPersistenceUnitResolver(persistenceUnitDeployments, deploymentScope, ejbContainers);
ejbResolver = new WarEjbResolver(deploymentScope, unit, mainDeployer);
+
+ this.webDD = unit.getAttachment(WebMetaData.class);
+ assert this.webDD != null : "webDD is null (no WebMetaData attachment in VFSDeploymentUnit)";
}
- public EnvironmentRefGroup getEnvironmentRefGroup()
+ public Environment getEnvironmentRefGroup()
{
return webDD;
}
public Object newInstance(String className) throws IllegalAccessException, InvocationTargetException, NamingException, InstantiationException, ClassNotFoundException {
- Class clazz = catalinaContext.getLoader().getClassLoader().loadClass(className);
+ Class<?> clazz = catalinaContext.getLoader().getClassLoader().loadClass(className);
Object instance = clazz.newInstance();
if (!catalinaContext.getIgnoreAnnotations())
{
@@ -172,7 +171,7 @@
}
public Object newInstance(String className, ClassLoader classLoader) throws IllegalAccessException, InvocationTargetException, NamingException, InstantiationException, ClassNotFoundException {
- Class clazz = classLoader.loadClass(className);
+ Class<?> clazz = classLoader.loadClass(className);
Object instance = clazz.newInstance();
if (!catalinaContext.getIgnoreAnnotations())
{
@@ -271,36 +270,47 @@
}
}
- private InputStream[] getInputStreams()
+ private void processClass(String className, ClassLoader webLoader) throws ClassNotFoundException
{
- InputStream jbossWebIS = null;
- InputStream webIS = null;
-
- try
+ if (resolvedClassInjections.containsKey(className))
+ return;
+ Class<?> cls = webLoader.loadClass(className);
+ Map<AccessibleObject, Injector> tmp = InjectionUtil.processAnnotations(this, handlers, cls);
+ resolvedClassInjections.put(className, tmp);
+ }
+
+ private void processFilters(FiltersMetaData filters, ClassLoader webLoader)
+ {
+ if(filters == null) return;
+ for (FilterMetaData filter : filters)
{
- VirtualFile webDD = unit.getMetaDataFile("web.xml");
- if (webDD != null)
- webIS = webDD.openStream();
+ try
+ {
+ processClass(filter.getFilterClass(), webLoader);
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new RuntimeException("could not find filter class in classpath", e);
+ }
}
- catch (IOException e)
+ }
+
+ private void processListeners(List<ListenerMetaData> listeners, ClassLoader webLoader)
+ {
+ if(listeners == null) return;
+ for (ListenerMetaData listener : listeners)
{
- log.debug("Failed to find web.xml");
+ try
+ {
+ processClass(listener.getListenerClass(), webLoader);
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new RuntimeException("could not find listener class in classpath", e);
+ }
}
- try
- {
- VirtualFile webDD = unit.getMetaDataFile("jboss-web.xml");
- if (webDD != null)
- jbossWebIS = webDD.openStream();
- }
- catch (IOException e)
- {
- log.debug("Failed to find jboss-web.xml");
- }
-
- InputStream[] streams = { webIS, jbossWebIS };
- return streams;
}
-
+
/**
* introspects EJB container to find all dependencies
* and initialize any extra metadata.
@@ -311,98 +321,30 @@
*/
public void processMetadata()
{
- InputStream[] streams = getInputStreams();
- if (streams[0] != null)
- {
- try
- {
- webDD = WebDDObjectFactory.parse(streams[0]);
- if (streams[1] != null)
- {
- webDD = JBossWebDDObjectFactory.parse(webDD, streams[1]);
- }
- }
- catch (JBossXBException e)
- {
- throw new RuntimeException(e);
- }
- }
- else
- {
- throw new RuntimeException("web.xml is required");
- }
-
// XML must be done first so that any annotation overrides are initialized
// todo injection handlers should be pluggable from XML
- handlers = new ArrayList<InjectionHandler>();
- handlers.add(new EJBHandler());
- handlers.add(new DependsHandler());
- handlers.add(new JndiInjectHandler());
- handlers.add(new PersistenceContextHandler());
- handlers.add(new PersistenceUnitHandler());
- handlers.add(new ResourceHandler());
- handlers.add(new WebServiceRefHandler());
+ handlers = new ArrayList<InjectionHandler<Environment>>();
+ handlers.add(new EJBHandler<Environment>());
+ handlers.add(new DependsHandler<Environment>());
+ // FIXME: is this allowed in servlets?
+ //handlers.add(new JndiInjectHandler<Environment>());
+ handlers.add(new PersistenceContextHandler<Environment>());
+ handlers.add(new PersistenceUnitHandler<Environment>());
+ handlers.add(new ResourceHandler<Environment>());
+ handlers.add(new WebServiceRefHandler<Environment>());
ClassLoader old = Thread.currentThread().getContextClassLoader();
ClassLoader webLoader = getClassloader();
Thread.currentThread().setContextClassLoader(webLoader);
try
{
- for (InjectionHandler handler : handlers)
+ for (InjectionHandler<Environment> handler : handlers)
handler.loadXml(webDD, this);
- for (Object obj : webDD.getServlets())
- {
- Servlet servlet = (Servlet)obj;
- try
- {
- if (servlet.getServletClass() == null)
- continue; // jsp
- if (resolvedClassInjections.containsKey(servlet.getServletClass()))
- continue;
- Class servletClass = webLoader.loadClass(servlet.getServletClass());
- Map<AccessibleObject, Injector> tmp = InjectionUtil.processAnnotations(this, handlers, servletClass);
- resolvedClassInjections.put(servlet.getServletClass(), tmp);
- }
- catch (ClassNotFoundException e)
- {
- log.warn("could not find servlet class " + servlet.getServletClass() + " in classpath when processing annotations.");
- }
-
- }
- for (Object obj : webDD.getFilters())
- {
- Filter filter = (Filter)obj;
- try
- {
- if (resolvedClassInjections.containsKey(filter.getFilterClass()))
- continue;
- Class servletClass = webLoader.loadClass(filter.getFilterClass());
- Map<AccessibleObject, Injector> tmp = InjectionUtil.processAnnotations(this, handlers, servletClass);
- resolvedClassInjections.put(filter.getFilterClass(), tmp);
- }
- catch (ClassNotFoundException e)
- {
- throw new RuntimeException("could not find filter class in classpath", e);
- }
- }
- for (Object obj : webDD.getListeners())
- {
- Listener listener = (Listener)obj;
- try
- {
- if (resolvedClassInjections.containsKey(listener.getListenerClass()))
- continue;
- Class servletClass = webLoader.loadClass(listener.getListenerClass());
- Map<AccessibleObject, Injector> tmp = InjectionUtil.processAnnotations(this, handlers, servletClass);
- resolvedClassInjections.put(listener.getListenerClass(), tmp);
- }
- catch (ClassNotFoundException e)
- {
- throw new RuntimeException("could not find listener class in classpath", e);
- }
- }
+ processServlets(webDD.getServlets(), webLoader);
+ processFilters(webDD.getFilters(), webLoader);
+ processListeners(webDD.getListeners(), webLoader);
}
finally
{
@@ -410,6 +352,24 @@
}
}
+ private void processServlets(ServletsMetaData servlets, ClassLoader webLoader)
+ {
+ if(servlets == null) return;
+ for (ServletMetaData servlet : servlets)
+ {
+ try
+ {
+ if (servlet.getServletClass() == null)
+ continue; // jsp
+ processClass(servlet.getServletClass(), webLoader);
+ }
+ catch (ClassNotFoundException e)
+ {
+ log.warn("could not find servlet class " + servlet.getServletClass() + " in classpath when processing annotations.");
+ }
+ }
+ }
+
public Map<String, EncInjector> getEncInjectors()
{
return encInjectors;
@@ -482,22 +442,22 @@
return false;
}
- public Container resolveEjbContainer(String link, Class businessIntf)
+ public Container resolveEjbContainer(String link, Class<?> businessIntf)
{
return ejbResolver.getEjbContainer(link, businessIntf);
}
- public Container resolveEjbContainer(Class businessIntf) throws NameNotFoundException
+ public Container resolveEjbContainer(Class<?> businessIntf) throws NameNotFoundException
{
return ejbResolver.getEjbContainer(businessIntf);
}
- public String getEjbJndiName(Class businessInterface) throws NameNotFoundException
+ public String getEjbJndiName(Class<?> businessInterface) throws NameNotFoundException
{
return ejbResolver.getEjbJndiName(businessInterface);
}
- public String getEjbJndiName(String link, Class businessInterface)
+ public String getEjbJndiName(String link, Class<?> businessInterface)
{
return ejbResolver.getEjbJndiName(link, businessInterface);
}
Modified: trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/TomcatDeployment.java
===================================================================
--- trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/TomcatDeployment.java 2007-10-30 06:40:04 UTC (rev 66557)
+++ trunk/tomcat/src/main/org/jboss/web/tomcat/service/deployers/TomcatDeployment.java 2007-10-30 09:07:07 UTC (rev 66558)
@@ -53,6 +53,7 @@
import org.apache.tomcat.util.modeler.Registry;
import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
import org.jboss.logging.Logger;
+import org.jboss.metadata.javaee.spec.Environment;
import org.jboss.metadata.javaee.spec.ServiceReferenceMetaData;
import org.jboss.metadata.javaee.spec.ServiceReferencesMetaData;
import org.jboss.metadata.serviceref.ServiceReferenceHandler;
@@ -489,18 +490,19 @@
// Bind <service-ref> elements
UnifiedVirtualFile vfsRoot = new VirtualFileAdaptor(unit.getRoot());
- EnvironmentRefGroup envRefGroup = injectionContainer.getEnvironmentRefGroup();
+ Environment envRefGroup = injectionContainer.getEnvironmentRefGroup();
ServiceReferencesMetaData serviceRefs = metaData.getServiceReferences();
if (serviceRefs != null)
{
for (ServiceReferenceMetaData sref : serviceRefs)
{
String refName = sref.getServiceRefName();
- ServiceRefMetaData injectedRef = envRefGroup.getServiceRef(refName);
- if (injectedRef == null || injectedRef.isProcessed() == false)
- {
- new ServiceReferenceHandler().bindServiceRef(envCtx, refName, vfsRoot, loader, sref);
- }
+ ServiceReferenceMetaData injectedRef = envRefGroup.getServiceReferenceByName(refName);
+ throw new RuntimeException("NYI");
+// if (injectedRef == null || injectedRef.isProcessed() == false)
+// {
+// new ServiceReferenceHandler().bindServiceRef(envCtx, refName, vfsRoot, loader, sref);
+// }
}
}
}
More information about the jboss-cvs-commits
mailing list