[jboss-cvs] JBossAS SVN: r64031 - in trunk/ejb3/src: main/org/jboss/ejb3/client and 10 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Jul 13 08:02:52 EDT 2007
Author: wolfc
Date: 2007-07-13 08:02:51 -0400 (Fri, 13 Jul 2007)
New Revision: 64031
Added:
trunk/ejb3/src/main/org/jboss/ejb3/javaee/
trunk/ejb3/src/main/org/jboss/ejb3/javaee/AbstractJavaEEComponent.java
trunk/ejb3/src/main/org/jboss/ejb3/javaee/JavaEEApplication.java
trunk/ejb3/src/main/org/jboss/ejb3/javaee/JavaEEComponent.java
trunk/ejb3/src/main/org/jboss/ejb3/javaee/JavaEEComponentHelper.java
trunk/ejb3/src/main/org/jboss/ejb3/javaee/JavaEEModule.java
trunk/ejb3/src/main/org/jboss/ejb3/javaee/SimpleJavaEEApplication.java
trunk/ejb3/src/main/org/jboss/ejb3/javaee/SimpleJavaEEModule.java
trunk/ejb3/src/main/org/jboss/ejb3/javaee/adapters/
trunk/ejb3/src/main/org/jboss/injection/EJBInjectionHandler.java
Modified:
trunk/ejb3/src/main/org/jboss/ejb3/Container.java
trunk/ejb3/src/main/org/jboss/ejb3/DeploymentScope.java
trunk/ejb3/src/main/org/jboss/ejb3/EJBContainer.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/Ejb3JmxDeployment.java
trunk/ejb3/src/main/org/jboss/ejb3/JmxDeploymentScopeImpl.java
trunk/ejb3/src/main/org/jboss/ejb3/MCDependencyPolicy.java
trunk/ejb3/src/main/org/jboss/ejb3/MCKernelAbstraction.java
trunk/ejb3/src/main/org/jboss/ejb3/ProxyDeployer.java
trunk/ejb3/src/main/org/jboss/ejb3/ProxyFactoryHelper.java
trunk/ejb3/src/main/org/jboss/ejb3/SessionContainer.java
trunk/ejb3/src/main/org/jboss/ejb3/client/ClientContainer.java
trunk/ejb3/src/main/org/jboss/ejb3/clientmodule/ClientENCInjectionContainer.java
trunk/ejb3/src/main/org/jboss/ejb3/deployers/AbstractOptionalVFSRealDeployer.java
trunk/ejb3/src/main/org/jboss/ejb3/deployers/Ejb3JBoss5Deployment.java
trunk/ejb3/src/main/org/jboss/ejb3/deployers/JBoss5DependencyPolicy.java
trunk/ejb3/src/main/org/jboss/ejb3/deployers/JBoss5DeploymentScope.java
trunk/ejb3/src/main/org/jboss/ejb3/deployers/JBossClientParsingDeployer.java
trunk/ejb3/src/main/org/jboss/ejb3/embedded/EJB3StandaloneDeployment.java
trunk/ejb3/src/main/org/jboss/ejb3/entity/PersistenceUnitDeployment.java
trunk/ejb3/src/main/org/jboss/ejb3/interceptor/EJB3InterceptorsFactory.java
trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulContainer.java
trunk/ejb3/src/main/org/jboss/ejb3/stateless/StatelessRemoteProxyFactory.java
trunk/ejb3/src/main/org/jboss/injection/AbstractHandler.java
trunk/ejb3/src/main/org/jboss/injection/EJBHandler.java
trunk/ejb3/src/main/org/jboss/injection/InjectionHandler.java
trunk/ejb3/src/test/org/jboss/ejb3/test/service/ServiceFive.java
Log:
EJBTHREE-718: refactoring deployment
Modified: trunk/ejb3/src/main/org/jboss/ejb3/Container.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/Container.java 2007-07-13 11:58:38 UTC (rev 64030)
+++ trunk/ejb3/src/main/org/jboss/ejb3/Container.java 2007-07-13 12:02:51 UTC (rev 64031)
@@ -86,7 +86,7 @@
Context getEnc();
- void processMetadata(DependencyPolicy dependencyPolicy);
+ void processMetadata();
DependencyPolicy getDependencyPolicy();
Modified: trunk/ejb3/src/main/org/jboss/ejb3/DeploymentScope.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/DeploymentScope.java 2007-07-13 11:58:38 UTC (rev 64030)
+++ trunk/ejb3/src/main/org/jboss/ejb3/DeploymentScope.java 2007-07-13 12:02:51 UTC (rev 64031)
@@ -23,13 +23,15 @@
import java.util.Collection;
+import org.jboss.ejb3.javaee.JavaEEApplication;
+
/**
* Abstraction for accessing contents of an EAR
*
* @author <a href="mailto:bill at jboss.org">Bill Burke</a>
* @version $Revision$
*/
-public interface DeploymentScope
+public interface DeploymentScope extends JavaEEApplication
{
public Collection<Ejb3Deployment> getEjbDeployments();
void register(Ejb3Deployment deployment);
Modified: trunk/ejb3/src/main/org/jboss/ejb3/EJBContainer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/EJBContainer.java 2007-07-13 11:58:38 UTC (rev 64030)
+++ trunk/ejb3/src/main/org/jboss/ejb3/EJBContainer.java 2007-07-13 12:02:51 UTC (rev 64031)
@@ -61,11 +61,14 @@
import org.jboss.aop.annotation.AnnotationElement;
import org.jboss.aop.joinpoint.ConstructorInvocation;
import org.jboss.aop.util.MethodHashing;
+import org.jboss.ejb3.deployers.JBoss5DependencyPolicy;
import org.jboss.ejb3.entity.PersistenceUnitDeployment;
import org.jboss.ejb3.interceptor.InterceptorInfo;
import org.jboss.ejb3.interceptor.InterceptorInfoRepository;
import org.jboss.ejb3.interceptor.InterceptorInjector;
import org.jboss.ejb3.interceptor.LifecycleInterceptorHandler;
+import org.jboss.ejb3.javaee.JavaEEComponent;
+import org.jboss.ejb3.javaee.JavaEEComponentHelper;
import org.jboss.ejb3.metamodel.AssemblyDescriptor;
import org.jboss.ejb3.metamodel.EnterpriseBean;
import org.jboss.ejb3.security.JaccHelper;
@@ -101,7 +104,7 @@
* @author <a href="mailto:bill at jboss.org">Bill Burke</a>
* @version $Revision$
*/
-public abstract class EJBContainer extends ClassContainer implements Container, InjectionContainer
+public abstract class EJBContainer extends ClassContainer implements Container, InjectionContainer, JavaEEComponent
{
private static final Logger log = Logger.getLogger(EJBContainer.class);
@@ -194,7 +197,7 @@
throw new RuntimeException(e);
}
this.ejbName = ejbName;
- String on = Ejb3Module.BASE_EJB3_JMX_NAME + "," + getDeploymentQualifiedName();
+ String on = createObjectName(ejbName);
try
{
objectName = new ObjectName(on);
@@ -215,6 +218,8 @@
this.interceptorRepository = interceptorRepository;
this.interceptorRepository.addBeanClass(clazz.getName());
bindORB();
+
+ this.dependencyPolicy = deployment.createDependencyPolicy(this);
}
private void bindORB()
@@ -229,6 +234,16 @@
}
}
+ public String createObjectName(String ejbName)
+ {
+ return JavaEEComponentHelper.createObjectName(deployment, ejbName);
+ }
+
+ public String createObjectName(String unitName, String ejbName)
+ {
+ return JavaEEComponentHelper.createObjectName(deployment, unitName, ejbName);
+ }
+
public EjbEncFactory getEncFactory()
{
return encFactory;
@@ -296,20 +311,7 @@
*/
public String getDeploymentQualifiedName()
{
- DeploymentScope ear = deployment.getEar();
- DeploymentUnit unit = deployment.getDeploymentUnit();
- StringBuilder sb = new StringBuilder();
- if (ear != null)
- {
- sb.append("ear=");
- sb.append(ear.getShortName());
- sb.append(",");
- }
- sb.append("jar=");
- sb.append(unit.getShortName());
- sb.append(",name=");
- sb.append(getEjbName());
- return sb.toString();
+ return objectName.getCanonicalName();
}
public DeploymentUnit getDeploymentUnit()
@@ -345,9 +347,8 @@
*
* @param dependencyPolicy
*/
- public void processMetadata(DependencyPolicy dependencyPolicy)
+ public void processMetadata()
{
- this.dependencyPolicy = dependencyPolicy;
// XML must be done first so that any annotation overrides are initialized
// todo injection handlers should be pluggable from XML
@@ -410,6 +411,12 @@
}
}
}
+
+ // Do not use getBusinessInterfaces, that one sucks
+ for(Class<?> businessInterface : ProxyFactoryHelper.getLocalInterfaces(this))
+ ((JBoss5DependencyPolicy) getDependencyPolicy()).addSupply(businessInterface);
+ for(Class<?> businessInterface : ProxyFactoryHelper.getRemoteInterfaces(this))
+ ((JBoss5DependencyPolicy) getDependencyPolicy()).addSupply(businessInterface);
}
finally
{
Modified: trunk/ejb3/src/main/org/jboss/ejb3/Ejb3Deployment.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/Ejb3Deployment.java 2007-07-13 11:58:38 UTC (rev 64030)
+++ trunk/ejb3/src/main/org/jboss/ejb3/Ejb3Deployment.java 2007-07-13 12:02:51 UTC (rev 64031)
@@ -54,6 +54,9 @@
import org.jboss.ejb3.entity.PersistenceUnitDeployment;
import org.jboss.ejb3.entity.PersistenceXmlLoader;
import org.jboss.ejb3.entity.SecondLevelCacheUtil;
+import org.jboss.ejb3.javaee.JavaEEApplication;
+import org.jboss.ejb3.javaee.JavaEEComponent;
+import org.jboss.ejb3.javaee.JavaEEModule;
import org.jboss.ejb3.metamodel.EjbJarDD;
import org.jboss.ejb3.metamodel.EjbJarDDObjectFactory;
import org.jboss.ejb3.metamodel.JBossDDObjectFactory;
@@ -69,7 +72,7 @@
* @author adrian at jboss.org
* @version $Revision$
*/
-public abstract class Ejb3Deployment
+public abstract class Ejb3Deployment implements JavaEEModule
{
private static final Logger log = Logger.getLogger(Ejb3Deployment.class);
public static final String ACTUAL_ENTITY_MANAGER_FACTORY_CONTEXT = "java:/ActualEntityManagerFactories";
@@ -141,6 +144,11 @@
messageDestinationResolver = new MessageDestinationResolver(deploymentScope, destinations);
}
+ public JavaEEApplication getApplication()
+ {
+ return deploymentScope;
+ }
+
public DeploymentScope getEar()
{
return deploymentScope;
@@ -305,9 +313,7 @@
{
ObjectName on = container.getObjectName();
ejbContainers.put(on, container);
- DependencyPolicy policy = createDependencyPolicy();
- container.processMetadata(policy);
-
+ container.processMetadata();
}
protected void registerEJBContainer(Container container) throws Exception
@@ -556,7 +562,7 @@
}
}
- public abstract DependencyPolicy createDependencyPolicy();
+ public abstract DependencyPolicy createDependencyPolicy(JavaEEComponent component);
protected void startPersistenceUnits()
{
@@ -567,7 +573,7 @@
{
if (entityDeployment != null)
{
- DependencyPolicy policy = createDependencyPolicy();
+ DependencyPolicy policy = createDependencyPolicy(entityDeployment);
entityDeployment.addDependencies(policy);
kernelAbstraction.install(entityDeployment.getKernelName(), policy, entityDeployment);
}
Modified: trunk/ejb3/src/main/org/jboss/ejb3/Ejb3DescriptorHandler.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/Ejb3DescriptorHandler.java 2007-07-13 11:58:38 UTC (rev 64030)
+++ trunk/ejb3/src/main/org/jboss/ejb3/Ejb3DescriptorHandler.java 2007-07-13 12:02:51 UTC (rev 64031)
@@ -742,7 +742,7 @@
if(enterpriseBean instanceof GenericBean)
{
Class[] remoteInterfaces = ProxyFactoryHelper.getRemoteInterfaces(container);
- if(remoteInterfaces == null)
+ if(remoteInterfaces.length == 0)
{
enterpriseBean.setLocalJndiName(enterpriseBean.getJndiName());
enterpriseBean.setJndiName(null);
Modified: trunk/ejb3/src/main/org/jboss/ejb3/Ejb3JmxDeployment.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/Ejb3JmxDeployment.java 2007-07-13 11:58:38 UTC (rev 64030)
+++ trunk/ejb3/src/main/org/jboss/ejb3/Ejb3JmxDeployment.java 2007-07-13 12:02:51 UTC (rev 64031)
@@ -23,6 +23,7 @@
import javax.security.jacc.PolicyConfiguration;
import org.jboss.deployment.DeploymentInfo;
+import org.jboss.ejb3.javaee.JavaEEComponent;
import org.jboss.ejb3.security.JaccHelper;
import org.jboss.logging.Logger;
@@ -67,7 +68,7 @@
}
- public DependencyPolicy createDependencyPolicy()
+ public DependencyPolicy createDependencyPolicy(JavaEEComponent component)
{
return new JmxDependencyPolicy();
}
Modified: trunk/ejb3/src/main/org/jboss/ejb3/JmxDeploymentScopeImpl.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/JmxDeploymentScopeImpl.java 2007-07-13 11:58:38 UTC (rev 64030)
+++ trunk/ejb3/src/main/org/jboss/ejb3/JmxDeploymentScopeImpl.java 2007-07-13 12:02:51 UTC (rev 64031)
@@ -64,6 +64,11 @@
return deployments.get(relativeShortName);
}
+ public String getName()
+ {
+ return shortName;
+ }
+
public String getShortName()
{
return shortName;
Modified: trunk/ejb3/src/main/org/jboss/ejb3/MCDependencyPolicy.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/MCDependencyPolicy.java 2007-07-13 11:58:38 UTC (rev 64030)
+++ trunk/ejb3/src/main/org/jboss/ejb3/MCDependencyPolicy.java 2007-07-13 12:02:51 UTC (rev 64031)
@@ -22,9 +22,13 @@
package org.jboss.ejb3;
import java.util.HashSet;
+import java.util.Set;
import org.jboss.beans.metadata.plugins.AbstractDemandMetaData;
+import org.jboss.beans.metadata.plugins.AbstractSupplyMetaData;
import org.jboss.beans.metadata.spi.DemandMetaData;
+import org.jboss.beans.metadata.spi.SupplyMetaData;
+import org.jboss.ejb3.javaee.JavaEEComponent;
/**
* dependency registry for Microcontainer
@@ -34,11 +38,20 @@
*/
public class MCDependencyPolicy implements DependencyPolicy
{
- protected HashSet dependencies = new HashSet();
+ private JavaEEComponent module;
+ private Set<DemandMetaData> dependencies = new HashSet<DemandMetaData>();
+ private Set<SupplyMetaData> supplies = new HashSet<SupplyMetaData>();
+ public MCDependencyPolicy(JavaEEComponent module)
+ {
+ assert module != null : "module is null";
+
+ this.module = module;
+ }
+
public void addDependency(String dependency)
{
- dependencies.add(dependency);
+ dependencies.add(new AbstractDemandMetaData(dependency));
}
public void addDatasource(String jndiName)
@@ -56,13 +69,54 @@
addDependency(ds);
}
- public HashSet<DemandMetaData> getDependencies()
+
+ public void addDependency(Class<?> businessInterface)
{
- HashSet<DemandMetaData> set = new HashSet<DemandMetaData>();
- for (Object depends : dependencies)
+ // TODO: more sophisticated
+ addDependency("Class:" + businessInterface.getName());
+ }
+
+ public void addDependency(String ejbLink, Class<?> businessInterface)
+ {
+ assert ejbLink != null : "ejbLink is null";
+
+ // Note that businessInterface is always ignored during resolving.
+
+ // FIXME: less hacky
+ int hashIndex = ejbLink.indexOf('#');
+ if (hashIndex != -1)
{
- set.add(new AbstractDemandMetaData(depends));
+// if (deploymentScope == null)
+// {
+// log.warn("ejb link '" + ejbLink + "' is relative, but no deployment scope found");
+// return null;
+// }
+ String unitName = ejbLink.substring(0, hashIndex);
+// Ejb3Deployment dep = deploymentScope.findRelativeDeployment(relativePath);
+// if (dep == null)
+// {
+// log.warn("can't find a deployment for path '" + relativePath + "' of ejb link '" + ejbLink + "'");
+// return null;
+// }
+ String ejbName = ejbLink.substring(hashIndex + 1);
+ addDependency(module.createObjectName(unitName, ejbName));
}
- return set;
+ else
+ addDependency(module.createObjectName(ejbLink));
}
+
+ public Set<DemandMetaData> getDependencies()
+ {
+ return dependencies;
+ }
+
+ public void addSupply(Class<?> businessInterface)
+ {
+ supplies.add(new AbstractSupplyMetaData("Class:" + businessInterface.getName()));
+ }
+
+ public Set<SupplyMetaData> getSupplies()
+ {
+ return supplies;
+ }
}
Modified: trunk/ejb3/src/main/org/jboss/ejb3/MCKernelAbstraction.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/MCKernelAbstraction.java 2007-07-13 11:58:38 UTC (rev 64030)
+++ trunk/ejb3/src/main/org/jboss/ejb3/MCKernelAbstraction.java 2007-07-13 12:02:51 UTC (rev 64031)
@@ -35,6 +35,7 @@
import org.jboss.beans.metadata.plugins.AbstractConstructorMetaData;
import org.jboss.beans.metadata.plugins.AbstractValueMetaData;
import org.jboss.beans.metadata.plugins.AbstractDemandMetaData;
+import org.jboss.beans.metadata.spi.SupplyMetaData;
import org.jboss.kernel.Kernel;
import org.jboss.kernel.spi.registry.KernelRegistryEntry;
@@ -118,6 +119,7 @@
bean.setConstructor(new AlreadyInstantiated(service));
MCDependencyPolicy policy = (MCDependencyPolicy) dependencies;
bean.setDemands(policy.getDependencies());
+ bean.setSupplies(policy.getSupplies());
log.info("installing bean: " + name + " with dependencies:");
for (Object obj : policy.getDependencies())
{
@@ -132,6 +134,11 @@
}
log.info("\t" + msg);
}
+ log.info(" and supplies:");
+ for(SupplyMetaData smd : policy.getSupplies())
+ {
+ log.info("\t" + smd.getSupply().toString());
+ }
try
{
try
Modified: trunk/ejb3/src/main/org/jboss/ejb3/ProxyDeployer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/ProxyDeployer.java 2007-07-13 11:58:38 UTC (rev 64030)
+++ trunk/ejb3/src/main/org/jboss/ejb3/ProxyDeployer.java 2007-07-13 12:02:51 UTC (rev 64031)
@@ -112,7 +112,7 @@
localBinding = (LocalBinding) advisor.resolveAnnotation(LocalBinding.class);
if (localBinding == null)
{
- if (ProxyFactoryHelper.getLocalInterfaces(container) != null)
+ if (ProxyFactoryHelper.getLocalInterfaces(container).length > 0)
{
localBinding = new LocalBindingImpl(ProxyFactoryHelper.getLocalJndiName(container));
advisor.getAnnotations().addClassAnnotation(LocalBinding.class, localBinding);
@@ -129,7 +129,7 @@
if (binding == null)
{
log.debug("no declared remote bindings for : " + container.getEjbName());
- if (ProxyFactoryHelper.getRemoteInterfaces(container) != null)
+ if (ProxyFactoryHelper.getRemoteInterfaces(container).length > 0)
{
log.debug("there is remote interfaces for " + container.getEjbName());
String jndiName = ProxyFactoryHelper.getDefaultRemoteJndiName(container);
Modified: trunk/ejb3/src/main/org/jboss/ejb3/ProxyFactoryHelper.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/ProxyFactoryHelper.java 2007-07-13 11:58:38 UTC (rev 64030)
+++ trunk/ejb3/src/main/org/jboss/ejb3/ProxyFactoryHelper.java 2007-07-13 12:02:51 UTC (rev 64031)
@@ -80,7 +80,12 @@
}
- public static Class[] getLocalInterfaces(Container container)
+ /**
+ *
+ * @param container
+ * @return the local interfaces of the container or an empty array
+ */
+ public static Class<?>[] getLocalInterfaces(Container container)
{
Local li = (javax.ejb.Local) ((EJBContainer) container).resolveAnnotation(javax.ejb.Local.class);
@@ -105,7 +110,7 @@
String endpoint = getEndpointInterface(container);
Class[] ri = getRemoteInterfaces(container);
- if (li == null && ri == null && endpoint == null && (beanClass.getInterfaces() == null || beanClass.getInterfaces().length == 0))
+ if (li == null && ri.length == 0 && endpoint == null && (beanClass.getInterfaces() == null || beanClass.getInterfaces().length == 0))
throw new RuntimeException("bean class has no local, webservice, or remote interfaces defined and does not implement at least one business interface: " + container.getEjbName());
// introspect implemented interfaces.
@@ -113,7 +118,7 @@
{
Class[] intfs = beanClass.getInterfaces();
ArrayList<Class> locals = new ArrayList<Class>();
- for (Class clazz : intfs)
+ for (Class<?> clazz : intfs)
{
if (clazz.isAnnotationPresent(javax.ejb.Local.class))
{
@@ -133,7 +138,7 @@
{
// search for default
ArrayList<Class> interfaces = getBusinessInterfaces(beanClass);
- if (interfaces.size() != 1) return null; // indeterminate
+ if (interfaces.size() != 1) return new Class[]{}; // indeterminate
Class intf = interfaces.get(0);
if (ri != null)
@@ -142,7 +147,7 @@
{
if (intf.getName().equals(rintf.getName()))
{
- return null;
+ return new Class[]{};
}
}
}
@@ -157,17 +162,14 @@
// Check to ensure @Local and @Remote are not defined on the same interface
// JIRA EJBTHREE-751
- if(ri != null)
+ for (Class remoteInterface : ri)
{
- for (Class remoteInterface : ri)
+ for (Class localInterface : li.value())
{
- for (Class localInterface : li.value())
+ if (localInterface.equals(remoteInterface))
{
- if (localInterface.equals(remoteInterface))
- {
- throw new RuntimeException("@Remote and @Local may not both be specified on the same interface \""
- + remoteInterface.toString() + "\" per EJB3 Spec 4.6.7, Bullet 5.4");
- }
+ throw new RuntimeException("@Remote and @Local may not both be specified on the same interface \""
+ + remoteInterface.toString() + "\" per EJB3 Spec 4.6.7, Bullet 5.4");
}
}
}
@@ -211,12 +213,9 @@
{
if (!(container instanceof SessionContainer)) return false;
Class[] remotes = getRemoteInterfaces(container);
- if (remotes != null)
+ for (Class intf : remotes)
{
- for (Class intf : remotes)
- {
- if (intf.getName().equals(businessInterface.getName())) return true;
- }
+ if (intf.getName().equals(businessInterface.getName())) return true;
}
Class remoteHome = getRemoteHomeInterface(container);
@@ -228,14 +227,11 @@
}
}
Class[] locals = getLocalInterfaces(container);
- if (locals != null)
+ for (Class clazz : locals)
{
- for (Class clazz : locals)
+ if (clazz.getName().equals(businessInterface.getName()))
{
- if (clazz.getName().equals(businessInterface.getName()))
- {
- return true;
- }
+ return true;
}
}
Class localHome = getLocalHomeInterface(container);
@@ -278,23 +274,20 @@
if (!(container instanceof SessionContainer)) return null;
Advisor advisor = (Advisor) container;
Class[] remotes = getRemoteInterfaces(container);
- if (remotes != null)
+ for (Class clazz : remotes)
{
- for (Class clazz : remotes)
+ if (clazz.getName().equals(businessInterface.getName()))
{
- if (clazz.getName().equals(businessInterface.getName()))
+ RemoteBindings bindings = (RemoteBindings) advisor.resolveAnnotation(RemoteBindings.class);
+ if (bindings == null)
{
- RemoteBindings bindings = (RemoteBindings) advisor.resolveAnnotation(RemoteBindings.class);
- if (bindings == null)
- {
- RemoteBinding binding = (RemoteBinding) advisor.resolveAnnotation(RemoteBinding.class);
- if (binding == null)
- throw new RuntimeException("RemoteBindings should not be null: " + container.getEjbName());
+ RemoteBinding binding = (RemoteBinding) advisor.resolveAnnotation(RemoteBinding.class);
+ if (binding == null)
+ throw new RuntimeException("RemoteBindings should not be null: " + container.getEjbName());
- return getRemoteJndiName(container, binding);
- }
- return getRemoteJndiName(container, bindings.value()[0]);
+ return getRemoteJndiName(container, binding);
}
+ return getRemoteJndiName(container, bindings.value()[0]);
}
}
Class remoteHome = getRemoteHomeInterface(container);
@@ -306,14 +299,11 @@
}
}
Class[] locals = getLocalInterfaces(container);
- if (locals != null)
+ for (Class clazz : locals)
{
- for (Class clazz : locals)
+ if (clazz.getName().equals(businessInterface.getName()))
{
- if (clazz.getName().equals(businessInterface.getName()))
- {
- return getLocalJndiName(container);
- }
+ return getLocalJndiName(container);
}
}
Class localHome = getLocalHomeInterface(container);
@@ -366,6 +356,11 @@
}
}
+ /**
+ *
+ * @param container
+ * @return the remote interfaces of the container or an empty array
+ */
public static Class[] getRemoteInterfaces(Container container)
{
Remote ri = (Remote) ((Advisor) container).resolveAnnotation(Remote.class);
@@ -389,7 +384,7 @@
return ri.value();
}
- return null;
+ return new Class[]{};
}
if (ri.value().length > 0) return ri.value();
Modified: trunk/ejb3/src/main/org/jboss/ejb3/SessionContainer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/SessionContainer.java 2007-07-13 11:58:38 UTC (rev 64030)
+++ trunk/ejb3/src/main/org/jboss/ejb3/SessionContainer.java 2007-07-13 12:02:51 UTC (rev 64031)
@@ -38,6 +38,7 @@
import org.jboss.aop.joinpoint.InvocationResponse;
import org.jboss.aop.util.MethodHashing;
import org.jboss.aspects.asynch.FutureHolder;
+import org.jboss.ejb3.deployers.JBoss5DependencyPolicy;
import org.jboss.ejb3.interceptor.InterceptorInfoRepository;
import org.jboss.ejb3.remoting.IsLocalInterceptor;
import org.jboss.ejb3.stateful.StatefulContainerInvocation;
@@ -114,12 +115,6 @@
proxyDeployer.initializeLocalBindingMetadata();
}
- @Override
- public void processMetadata(DependencyPolicy dependencyPolicy)
- {
- super.processMetadata(dependencyPolicy);
- }
-
public void start() throws Exception
{
super.start();
Modified: trunk/ejb3/src/main/org/jboss/ejb3/client/ClientContainer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/client/ClientContainer.java 2007-07-13 11:58:38 UTC (rev 64030)
+++ trunk/ejb3/src/main/org/jboss/ejb3/client/ClientContainer.java 2007-07-13 12:02:51 UTC (rev 64031)
@@ -48,6 +48,7 @@
import org.jboss.ejb3.metamodel.LifecycleCallback;
import org.jboss.injection.DependsHandler;
import org.jboss.injection.EJBHandler;
+import org.jboss.injection.EJBInjectionHandler;
import org.jboss.injection.EncInjector;
import org.jboss.injection.InjectionContainer;
import org.jboss.injection.InjectionHandler;
@@ -309,7 +310,7 @@
// TODO: check which handlers a client container should support
Collection<InjectionHandler> handlers = new ArrayList<InjectionHandler>();
- handlers.add(new EJBHandler());
+ handlers.add(new EJBInjectionHandler());
//handlers.add(new ClientEJBHandler());
handlers.add(new DependsHandler());
handlers.add(new JndiInjectHandler());
Modified: trunk/ejb3/src/main/org/jboss/ejb3/clientmodule/ClientENCInjectionContainer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/clientmodule/ClientENCInjectionContainer.java 2007-07-13 11:58:38 UTC (rev 64030)
+++ trunk/ejb3/src/main/org/jboss/ejb3/clientmodule/ClientENCInjectionContainer.java 2007-07-13 12:02:51 UTC (rev 64031)
@@ -49,6 +49,9 @@
import org.jboss.ejb3.enc.DeploymentEjbResolver;
import org.jboss.ejb3.enc.MessageDestinationResolver;
import org.jboss.ejb3.entity.PersistenceUnitDeployment;
+import org.jboss.ejb3.javaee.AbstractJavaEEComponent;
+import org.jboss.ejb3.javaee.JavaEEComponent;
+import org.jboss.ejb3.javaee.SimpleJavaEEModule;
import org.jboss.ejb3.metamodel.ApplicationClientDD;
import org.jboss.injection.DependsHandler;
import org.jboss.injection.EJBHandler;
@@ -78,7 +81,7 @@
* @author adrian at jboss.org
* @version $Revision$
*/
-public class ClientENCInjectionContainer implements InjectionContainer
+public class ClientENCInjectionContainer extends AbstractJavaEEComponent implements InjectionContainer
{
private static final Logger log = Logger.getLogger(ClientENCInjectionContainer.class);
@@ -98,12 +101,13 @@
private DeploymentEjbResolver ejbResolver;
private DeploymentScope deploymentScope;
private ObjectName objectName;
- private DependencyPolicy dependencyPolicy = new JBoss5DependencyPolicy();
+ private DependencyPolicy dependencyPolicy = new JBoss5DependencyPolicy(this);
private MessageDestinationResolver messageDestinationResolver;
public ClientENCInjectionContainer(VFSDeploymentUnit unit, ApplicationClientDD xml, Class<?> mainClass, String applicationClientName, ClassLoader classLoader, Context encCtx) throws NamingException
{
+ super(new SimpleJavaEEModule((unit.getParent() != null ? unit.getParent().getSimpleName() : null), unit.getSimpleName()));
if(mainClass == null)
throw new NullPointerException("mainClass is mandatory");
if(applicationClientName == null)
@@ -396,15 +400,15 @@
public void start()
{
- log.trace("start");
-
populateEnc();
// Don't run any injectors, they must be run client side
+
+ log.info("STARTED CLIENT ENC CONTAINER: " + applicationClientName);
}
public void stop()
{
- log.trace("stop");
+ log.info("STOPPED CLIENT ENC CONTAINER: " + applicationClientName);
}
}
Modified: trunk/ejb3/src/main/org/jboss/ejb3/deployers/AbstractOptionalVFSRealDeployer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/deployers/AbstractOptionalVFSRealDeployer.java 2007-07-13 11:58:38 UTC (rev 64030)
+++ trunk/ejb3/src/main/org/jboss/ejb3/deployers/AbstractOptionalVFSRealDeployer.java 2007-07-13 12:02:51 UTC (rev 64031)
@@ -68,6 +68,12 @@
*/
public abstract void deploy(VFSDeploymentUnit unit, T deployment) throws DeploymentException;
+ @Override
+ public void undeploy(DeploymentUnit unit)
+ {
+ undeploy(unit, unit.getAttachment(optionalInput));
+ }
+
public void undeploy(DeploymentUnit unit, T deployment)
{
if (unit instanceof VFSDeploymentUnit == false)
Modified: trunk/ejb3/src/main/org/jboss/ejb3/deployers/Ejb3JBoss5Deployment.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/deployers/Ejb3JBoss5Deployment.java 2007-07-13 11:58:38 UTC (rev 64030)
+++ trunk/ejb3/src/main/org/jboss/ejb3/deployers/Ejb3JBoss5Deployment.java 2007-07-13 12:02:51 UTC (rev 64031)
@@ -31,6 +31,7 @@
import org.jboss.ejb3.DeploymentUnit;
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;
@@ -85,8 +86,8 @@
}
}
- public DependencyPolicy createDependencyPolicy()
+ public DependencyPolicy createDependencyPolicy(JavaEEComponent component)
{
- return new JBoss5DependencyPolicy();
+ return new JBoss5DependencyPolicy(component);
}
}
Modified: trunk/ejb3/src/main/org/jboss/ejb3/deployers/JBoss5DependencyPolicy.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/deployers/JBoss5DependencyPolicy.java 2007-07-13 11:58:38 UTC (rev 64030)
+++ trunk/ejb3/src/main/org/jboss/ejb3/deployers/JBoss5DependencyPolicy.java 2007-07-13 12:02:51 UTC (rev 64031)
@@ -22,10 +22,8 @@
package org.jboss.ejb3.deployers;
import org.jboss.ejb3.MCDependencyPolicy;
+import org.jboss.ejb3.javaee.JavaEEComponent;
-import javax.management.ObjectName;
-import javax.management.MalformedObjectNameException;
-
/**
* Comment
*
@@ -34,6 +32,11 @@
*/
public class JBoss5DependencyPolicy extends MCDependencyPolicy
{
+ public JBoss5DependencyPolicy(JavaEEComponent module)
+ {
+ super(module);
+ }
+
public void addDatasource(String jndiName)
{
String ds = jndiName;
@@ -48,6 +51,6 @@
}
//tring onStr = "jboss.jca:name=" + ds + ",service=ManagedConnectionFactory";
String onStr = "jboss.jca:name=" + ds + ",service=DataSourceBinding";
- dependencies.add(onStr);
+ addDependency(onStr);
}
}
Modified: trunk/ejb3/src/main/org/jboss/ejb3/deployers/JBoss5DeploymentScope.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/deployers/JBoss5DeploymentScope.java 2007-07-13 11:58:38 UTC (rev 64030)
+++ trunk/ejb3/src/main/org/jboss/ejb3/deployers/JBoss5DeploymentScope.java 2007-07-13 12:02:51 UTC (rev 64031)
@@ -94,6 +94,11 @@
return deployments.get(relativeName);
}
+ public String getName()
+ {
+ return shortName;
+ }
+
public String getShortName()
{
return shortName;
Modified: trunk/ejb3/src/main/org/jboss/ejb3/deployers/JBossClientParsingDeployer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/deployers/JBossClientParsingDeployer.java 2007-07-13 11:58:38 UTC (rev 64030)
+++ trunk/ejb3/src/main/org/jboss/ejb3/deployers/JBossClientParsingDeployer.java 2007-07-13 12:02:51 UTC (rev 64031)
@@ -46,7 +46,7 @@
public JBossClientParsingDeployer()
{
super(ApplicationClientDD.class);
- setInput(ApplicationClientDD.class);
+ setInputs(ApplicationClientDD.class);
setName("jboss-client.xml");
}
@@ -77,7 +77,7 @@
VirtualFile dd = unit.getMetaDataFile(getName());
if (dd != null)
{
- log.debug("Found application-client.xml file: " + unit.getName());
+ log.debug("Found jboss-client.xml file: " + unit.getName());
try
{
Element root = DOMUtils.parse(dd.openStream());
Modified: trunk/ejb3/src/main/org/jboss/ejb3/embedded/EJB3StandaloneDeployment.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/embedded/EJB3StandaloneDeployment.java 2007-07-13 11:58:38 UTC (rev 64030)
+++ trunk/ejb3/src/main/org/jboss/ejb3/embedded/EJB3StandaloneDeployment.java 2007-07-13 12:02:51 UTC (rev 64031)
@@ -28,6 +28,8 @@
import javax.management.MBeanServer;
import org.jboss.ejb3.DependencyPolicy;
import org.jboss.ejb3.DeploymentUnit;
+import org.jboss.ejb3.javaee.JavaEEApplication;
+import org.jboss.ejb3.javaee.JavaEEComponent;
import org.jboss.ejb3.service.ServiceContainer;
import org.jboss.ejb3.Container;
import org.jboss.ejb3.Ejb3Deployment;
@@ -196,9 +198,9 @@
*/
- public DependencyPolicy createDependencyPolicy()
+ public DependencyPolicy createDependencyPolicy(JavaEEComponent component)
{
- return new MCDependencyPolicy();
+ return new MCDependencyPolicy(component);
}
// @Override
@@ -213,4 +215,9 @@
// con.start();
// }
// }
+
+ public JavaEEApplication getApplication()
+ {
+ return null;
+ }
}
Modified: trunk/ejb3/src/main/org/jboss/ejb3/entity/PersistenceUnitDeployment.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/entity/PersistenceUnitDeployment.java 2007-07-13 11:58:38 UTC (rev 64030)
+++ trunk/ejb3/src/main/org/jboss/ejb3/entity/PersistenceUnitDeployment.java 2007-07-13 12:02:51 UTC (rev 64031)
@@ -36,6 +36,9 @@
import org.jboss.ejb3.DeploymentUnit;
import org.jboss.ejb3.Ejb3Deployment;
import org.jboss.ejb3.NonSerializableFactory;
+import org.jboss.ejb3.javaee.AbstractJavaEEComponent;
+import org.jboss.ejb3.javaee.JavaEEComponent;
+import org.jboss.ejb3.javaee.SimpleJavaEEModule;
import org.jboss.logging.Logger;
/**
@@ -44,7 +47,7 @@
* @author <a href="mailto:bill at jboss.org">Bill Burke</a>
* @version $Revision$
*/
-public class PersistenceUnitDeployment
+public class PersistenceUnitDeployment extends AbstractJavaEEComponent
{
private static final Logger log = Logger.getLogger(PersistenceUnitDeployment.class);
@@ -61,6 +64,8 @@
public PersistenceUnitDeployment(InitialContext initialContext, Ejb3Deployment deployment, List<String> explicitEntityClasses, URL persistenceXmlUrl, PersistenceMetadata metadata, String ear, String jar, boolean isScoped)
{
+ super(new SimpleJavaEEModule((deployment.getEar() != null ? deployment.getEar().getShortName() : null), deployment.getDeploymentUnit().getShortName()));
+
this.scoped = isScoped;
this.deployment = deployment;
this.initialContext = initialContext;
Modified: trunk/ejb3/src/main/org/jboss/ejb3/interceptor/EJB3InterceptorsFactory.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/interceptor/EJB3InterceptorsFactory.java 2007-07-13 11:58:38 UTC (rev 64030)
+++ trunk/ejb3/src/main/org/jboss/ejb3/interceptor/EJB3InterceptorsFactory.java 2007-07-13 12:02:51 UTC (rev 64031)
@@ -170,14 +170,8 @@
{
Class[] remotes = ProxyFactoryHelper.getRemoteInterfaces(container);
Class[] locals = ProxyFactoryHelper.getLocalInterfaces(container);
- if (remotes != null)
- {
- interfaces.addAll(Arrays.asList(remotes));
- }
- if (locals != null)
- {
- interfaces.addAll(Arrays.asList(locals));
- }
+ interfaces.addAll(Arrays.asList(remotes));
+ interfaces.addAll(Arrays.asList(locals));
if (container instanceof ServiceContainer)
{
Added: trunk/ejb3/src/main/org/jboss/ejb3/javaee/AbstractJavaEEComponent.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/javaee/AbstractJavaEEComponent.java (rev 0)
+++ trunk/ejb3/src/main/org/jboss/ejb3/javaee/AbstractJavaEEComponent.java 2007-07-13 12:02:51 UTC (rev 64031)
@@ -0,0 +1,50 @@
+/*
+ * 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.javaee;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public abstract class AbstractJavaEEComponent implements JavaEEComponent
+{
+ private JavaEEModule module;
+
+ protected AbstractJavaEEComponent(JavaEEModule module)
+ {
+ assert module != null : "module is null";
+
+ this.module = module;
+ }
+
+ public String createObjectName(String ejbName)
+ {
+ return JavaEEComponentHelper.createObjectName(module, ejbName);
+ }
+
+ public String createObjectName(String unitName, String ejbName)
+ {
+ return JavaEEComponentHelper.createObjectName(module, unitName, ejbName);
+ }
+}
Property changes on: trunk/ejb3/src/main/org/jboss/ejb3/javaee/AbstractJavaEEComponent.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: trunk/ejb3/src/main/org/jboss/ejb3/javaee/JavaEEApplication.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/javaee/JavaEEApplication.java (rev 0)
+++ trunk/ejb3/src/main/org/jboss/ejb3/javaee/JavaEEApplication.java 2007-07-13 12:02:51 UTC (rev 64031)
@@ -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.ejb3.javaee;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public interface JavaEEApplication
+{
+
+ String getName();
+
+}
Property changes on: trunk/ejb3/src/main/org/jboss/ejb3/javaee/JavaEEApplication.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: trunk/ejb3/src/main/org/jboss/ejb3/javaee/JavaEEComponent.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/javaee/JavaEEComponent.java (rev 0)
+++ trunk/ejb3/src/main/org/jboss/ejb3/javaee/JavaEEComponent.java 2007-07-13 12:02:51 UTC (rev 64031)
@@ -0,0 +1,50 @@
+/*
+ * 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.javaee;
+
+/**
+ * A JavaEE component (could be EJB container, client container etc)
+ *
+ * EE 2.2
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public interface JavaEEComponent
+{
+ /**
+ * Create an object name for the given EJB name in the same JavaEE module.
+ *
+ * @param ejbLink
+ * @return
+ */
+ String createObjectName(String ejbName);
+
+ /**
+ * Create an object name for the given EJB name in another JavaEE module.
+ *
+ * @param unitName
+ * @param ejbName
+ * @return
+ */
+ String createObjectName(String unitName, String ejbName);
+}
Property changes on: trunk/ejb3/src/main/org/jboss/ejb3/javaee/JavaEEComponent.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: trunk/ejb3/src/main/org/jboss/ejb3/javaee/JavaEEComponentHelper.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/javaee/JavaEEComponentHelper.java (rev 0)
+++ trunk/ejb3/src/main/org/jboss/ejb3/javaee/JavaEEComponentHelper.java 2007-07-13 12:02:51 UTC (rev 64031)
@@ -0,0 +1,67 @@
+/*
+ * 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.javaee;
+
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+
+import org.jboss.ejb3.Ejb3Module;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class JavaEEComponentHelper
+{
+ public static String createObjectName(JavaEEModule module, String ejbName)
+ {
+ return createObjectName(module, module.getName(), ejbName);
+ }
+
+ public static String createObjectName(JavaEEModule module, String unitName, String ejbName)
+ {
+ // TODO: currently it's only for EJB3 service
+ StringBuilder sb = new StringBuilder(Ejb3Module.BASE_EJB3_JMX_NAME + ",");
+ JavaEEApplication ear = module.getApplication();
+ if (ear != null)
+ {
+ sb.append("ear=");
+ sb.append(ear.getName());
+ sb.append(",");
+ }
+ sb.append("jar=");
+ sb.append(unitName);
+ sb.append(",name=");
+ sb.append(ejbName);
+ try
+ {
+ ObjectName on = new ObjectName(sb.toString());
+ return on.getCanonicalName();
+ }
+ catch (MalformedObjectNameException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+}
Property changes on: trunk/ejb3/src/main/org/jboss/ejb3/javaee/JavaEEComponentHelper.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: trunk/ejb3/src/main/org/jboss/ejb3/javaee/JavaEEModule.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/javaee/JavaEEModule.java (rev 0)
+++ trunk/ejb3/src/main/org/jboss/ejb3/javaee/JavaEEModule.java 2007-07-13 12:02:51 UTC (rev 64031)
@@ -0,0 +1,39 @@
+/*
+ * 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.javaee;
+
+/**
+ * A Java EE module represents the basic unit of composition of a
+ * Java EE application. Java EE modules consist of one or more
+ * Java EE components and an optional module level deployment descriptor.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public interface JavaEEModule
+{
+
+ JavaEEApplication getApplication();
+
+ String getName();
+
+}
Property changes on: trunk/ejb3/src/main/org/jboss/ejb3/javaee/JavaEEModule.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: trunk/ejb3/src/main/org/jboss/ejb3/javaee/SimpleJavaEEApplication.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/javaee/SimpleJavaEEApplication.java (rev 0)
+++ trunk/ejb3/src/main/org/jboss/ejb3/javaee/SimpleJavaEEApplication.java 2007-07-13 12:02:51 UTC (rev 64031)
@@ -0,0 +1,45 @@
+/*
+ * 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.javaee;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class SimpleJavaEEApplication implements JavaEEApplication
+{
+ private String name;
+
+ public SimpleJavaEEApplication(String name)
+ {
+ assert name != null : "name is null";
+
+ this.name = name;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+}
Property changes on: trunk/ejb3/src/main/org/jboss/ejb3/javaee/SimpleJavaEEApplication.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added: trunk/ejb3/src/main/org/jboss/ejb3/javaee/SimpleJavaEEModule.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/javaee/SimpleJavaEEModule.java (rev 0)
+++ trunk/ejb3/src/main/org/jboss/ejb3/javaee/SimpleJavaEEModule.java 2007-07-13 12:02:51 UTC (rev 64031)
@@ -0,0 +1,53 @@
+/*
+ * 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.javaee;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class SimpleJavaEEModule implements JavaEEModule
+{
+ private JavaEEApplication application;
+ private String name;
+
+ public SimpleJavaEEModule(String applicationName, String moduleName)
+ {
+ assert moduleName != null : "moduleName is null";
+
+ if(applicationName != null)
+ this.application = new SimpleJavaEEApplication(applicationName);
+ this.name = moduleName;
+ }
+
+ public JavaEEApplication getApplication()
+ {
+ return application;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+}
\ No newline at end of file
Property changes on: trunk/ejb3/src/main/org/jboss/ejb3/javaee/SimpleJavaEEModule.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulContainer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulContainer.java 2007-07-13 11:58:38 UTC (rev 64030)
+++ trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulContainer.java 2007-07-13 12:02:51 UTC (rev 64031)
@@ -874,32 +874,25 @@
boolean isRemote = false;
boolean found = false;
Class[] remoteInterfaces = ProxyFactoryHelper.getRemoteInterfaces(this);
- if (remoteInterfaces != null)
+ for (Class intf : remoteInterfaces)
{
- for (Class intf : remoteInterfaces)
+ if (intf.getName().equals(businessInterface.getName()))
{
- if (intf.getName().equals(businessInterface.getName()))
- {
- isRemote = true;
- found = true;
- break;
- }
+ isRemote = true;
+ found = true;
+ break;
}
}
if (found == false)
{
Class[] localInterfaces = ProxyFactoryHelper.getLocalInterfaces(this);
- if (localInterfaces != null)
+ for (Class intf : localInterfaces)
{
- for (Class intf : localInterfaces)
+ if (intf.getName().equals(businessInterface.getName()))
{
- if (intf.getName().equals(businessInterface.getName()))
- {
- found = true;
- break;
- }
+ found = true;
+ break;
}
-
}
}
if (found == false) throw new IllegalStateException(businessInterface.getName() + " is not a business interface");
Modified: trunk/ejb3/src/main/org/jboss/ejb3/stateless/StatelessRemoteProxyFactory.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/stateless/StatelessRemoteProxyFactory.java 2007-07-13 11:58:38 UTC (rev 64030)
+++ trunk/ejb3/src/main/org/jboss/ejb3/stateless/StatelessRemoteProxyFactory.java 2007-07-13 12:02:51 UTC (rev 64031)
@@ -68,7 +68,7 @@
Class[] remoteInterfaces = ProxyFactoryHelper.getRemoteInterfaces(container);
- if(remoteInterfaces!=null)
+ if(remoteInterfaces.length > 0)
{
if (bindTogether)
interfaces = new Class[remoteInterfaces.length + 3];
Modified: trunk/ejb3/src/main/org/jboss/injection/AbstractHandler.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/injection/AbstractHandler.java 2007-07-13 11:58:38 UTC (rev 64030)
+++ trunk/ejb3/src/main/org/jboss/injection/AbstractHandler.java 2007-07-13 12:02:51 UTC (rev 64031)
@@ -21,7 +21,10 @@
*/
package org.jboss.injection;
+import javax.naming.NameNotFoundException;
+
import org.jboss.ejb3.EJBContainer;
+import org.jboss.ejb3.deployers.JBoss5DependencyPolicy;
/**
* Common base for annotation/xml handlers.
@@ -31,10 +34,39 @@
*/
public abstract class AbstractHandler implements InjectionHandler
{
- protected void addDependency(String refName, EJBContainer refcon, InjectionContainer container)
+// protected void addDependency(String refName, EJBContainer refcon, InjectionContainer container)
+// {
+// // Do not depend on myself
+// if(!container.equals(refcon))
+// container.getDependencyPolicy().addDependency(refcon.getObjectName().getCanonicalName());
+// }
+
+ protected void addDependency(InjectionContainer container, Class businessIntf)
{
+ EJBContainer refCon = null;
+ try
+ {
+ refCon = (EJBContainer) container.resolveEjbContainer(businessIntf);
+ }
+ catch(NameNotFoundException e)
+ {
+ // ignore
+ }
// Do not depend on myself
- if(!container.equals(refcon))
- container.getDependencyPolicy().addDependency(refcon.getObjectName().getCanonicalName());
+ if(container.equals(refCon))
+ return;
+
+ ((JBoss5DependencyPolicy) container.getDependencyPolicy()).addDependency(businessIntf);
}
+
+ protected void addDependency(InjectionContainer container, String link, Class businessIntf)
+ {
+ EJBContainer refCon = (EJBContainer) container.resolveEjbContainer(link, businessIntf);
+
+ // Do not depend on myself
+ if(container.equals(refCon))
+ return;
+
+ ((JBoss5DependencyPolicy) container.getDependencyPolicy()).addDependency(link, businessIntf);
+ }
}
Modified: trunk/ejb3/src/main/org/jboss/injection/EJBHandler.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/injection/EJBHandler.java 2007-07-13 11:58:38 UTC (rev 64030)
+++ trunk/ejb3/src/main/org/jboss/injection/EJBHandler.java 2007-07-13 12:02:51 UTC (rev 64031)
@@ -45,7 +45,7 @@
* @author <a href="mailto:bill at jboss.org">Bill Burke</a>
* @version $Revision$
*/
-public class EJBHandler extends AbstractHandler implements InjectionHandler
+public class EJBHandler extends EJBInjectionHandler
{
private static final Logger log = Logger.getLogger(EJBHandler.class);
@@ -130,37 +130,17 @@
protected void ejbRefDependency(String link, InjectionContainer container, Class refClass, String errorType, String encName)
{
- EJBContainer refcon = null;
-
if (refClass != null && (refClass.equals(Object.class) || refClass.equals(void.class))) refClass = null;
if (refClass != null)
{
if (link != null && !link.trim().equals(""))
{
- refcon = (EJBContainer) container.resolveEjbContainer(link, refClass);
- if (refcon == null)
- {
- String msg = "IGNORING DEPENDENCY: unable to find " + errorType + " of interface " + refClass.getName() + " and ejbLink of " + link + " in " + container.getDeploymentDescriptorType() + " of " + container.getIdentifier() + " it might not be deployed yet";
- log.warn(msg);
- }
+ addDependency(container, link, refClass);
}
else
{
- try
- {
- refcon = (EJBContainer) container.resolveEjbContainer(refClass);
- if (refcon == null)
- {
- String msg = "IGNORING DEPENDENCY: unable to find " + errorType + " from interface only " + refClass.getName() + " in " + container.getDeploymentDescriptorType() + " of " + container.getIdentifier();
- log.warn(msg);
- }
- }
- catch (NameNotFoundException e)
- {
- String msg = "IGNORING DEPENDENCY: unable to find " + errorType + " from interface only " + refClass.getName() + " in " + container.getDeploymentDescriptorType() + " of " + container.getIdentifier() + e.getMessage();
- log.warn(msg);
- }
+ addDependency(container, refClass);
}
}
else
@@ -168,11 +148,6 @@
String msg = "IGNORING DEPENDENCY: unable to resolve dependency of EJB, there is too little information";
log.warn(msg);
}
-
- if (refcon != null)
- {
- addDependency(encName, refcon, container);
- }
}
protected void ejbRefEncInjector(String mappedName, String encName, Class refClass, String link, String errorType, InjectionContainer container)
@@ -314,21 +289,12 @@
public void handleMethodAnnotations(Method method, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
{
-
- EJB ref = method.getAnnotation(EJB.class);
+ 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 = ref.name();
- if (encName == null || encName.equals(""))
- {
- encName = InjectionUtil.getEncName(method);
- }
- else
- {
- encName = "env/" + encName;
- }
+ String encName = getEncName(ref, method);
if (!container.getEncInjectors().containsKey(encName))
{
ejbRefEncInjector(ref.mappedName(), encName, method.getParameterTypes()[0], ref.beanName(), "@EJB", container);
@@ -342,24 +308,16 @@
}
}
- injectors.put(method, new JndiMethodInjector(method, encName, container.getEnc()));
+ super.handleMethodAnnotations(method, container, injectors);
}
}
public void handleFieldAnnotations(Field field, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
{
- EJB ref = field.getAnnotation(EJB.class);
+ EJB ref = container.getAnnotation(EJB.class, field);
if (ref != null)
{
- String encName = ref.name();
- if (encName == null || encName.equals(""))
- {
- encName = InjectionUtil.getEncName(field);
- }
- else
- {
- encName = "env/" + encName;
- }
+ String encName = getEncName(ref, field);
if (!container.getEncInjectors().containsKey(encName))
{
if (container.getAnnotation(IgnoreDependency.class, field) == null)
@@ -371,8 +329,7 @@
}
ejbRefEncInjector(ref.mappedName(), encName, field.getType(), ref.beanName(), "@EJB", container);
}
- injectors.put(field, new JndiFieldInjector(field, encName, container.getEnc()));
-
+ super.handleFieldAnnotations(field, container, injectors);
}
}
Added: trunk/ejb3/src/main/org/jboss/injection/EJBInjectionHandler.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/injection/EJBInjectionHandler.java (rev 0)
+++ trunk/ejb3/src/main/org/jboss/injection/EJBInjectionHandler.java 2007-07-13 12:02:51 UTC (rev 64031)
@@ -0,0 +1,98 @@
+/*
+ * 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 java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.Map;
+
+import javax.ejb.EJB;
+
+import org.jboss.metamodel.descriptor.EnvironmentRefGroup;
+
+/**
+ * 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: $
+ */
+public class EJBInjectionHandler extends AbstractHandler
+{
+ protected String getEncName(EJB ref, Field field)
+ {
+ String encName = ref.name();
+ if (encName == null || encName.equals(""))
+ {
+ encName = InjectionUtil.getEncName(field);
+ }
+ else
+ {
+ encName = "env/" + encName;
+ }
+ return encName;
+ }
+
+ protected String getEncName(EJB ref, Method method)
+ {
+ String encName = ref.name();
+ if (encName == null || encName.equals(""))
+ {
+ encName = InjectionUtil.getEncName(method);
+ }
+ else
+ {
+ encName = "env/" + encName;
+ }
+ return encName;
+ }
+
+ public void handleClassAnnotations(Class clazz, InjectionContainer container)
+ {
+ // do nothing, all class level @EJB are for seting up the enc
+ }
+
+ public void handleFieldAnnotations(Field field, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
+ {
+ EJB ref = container.getAnnotation(EJB.class, field);
+ if(ref == null)
+ return;
+
+ String encName = getEncName(ref, field);
+ injectors.put(field, new JndiFieldInjector(field, encName, container.getEnc()));
+ }
+
+ public void handleMethodAnnotations(Method method, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
+ {
+ EJB ref = container.getAnnotation(EJB.class, method);
+ if(ref == null)
+ return;
+
+ String encName = getEncName(ref, method);
+ injectors.put(method, new JndiMethodInjector(method, encName, container.getEnc()));
+ }
+
+ public void loadXml(EnvironmentRefGroup xml, InjectionContainer container)
+ {
+ // TODO: inventorize
+ }
+}
Property changes on: trunk/ejb3/src/main/org/jboss/injection/EJBInjectionHandler.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: trunk/ejb3/src/main/org/jboss/injection/InjectionHandler.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/injection/InjectionHandler.java 2007-07-13 11:58:38 UTC (rev 64030)
+++ trunk/ejb3/src/main/org/jboss/injection/InjectionHandler.java 2007-07-13 12:02:51 UTC (rev 64031)
@@ -39,5 +39,5 @@
public void loadXml(EnvironmentRefGroup 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);
+ public void handleFieldAnnotations(Field field, InjectionContainer container, Map<AccessibleObject, Injector> injectors);
}
Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/service/ServiceFive.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/service/ServiceFive.java 2007-07-13 11:58:38 UTC (rev 64030)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/service/ServiceFive.java 2007-07-13 12:02:51 UTC (rev 64031)
@@ -58,6 +58,7 @@
public void create() throws Exception
{
System.out.println("ServiceFive - CREATE");
+ new Exception().printStackTrace();
Tester.creates.add("5");
}
More information about the jboss-cvs-commits
mailing list