[jboss-cvs] JBossAS SVN: r57464 - in branches/JEE5_TCK/ejb3: . src/main/org/jboss/ejb3 src/main/org/jboss/ejb3/client src/main/org/jboss/ejb3/clientmodule src/main/org/jboss/ejb3/deployment src/main/org/jboss/ejb3/metamodel src/main/org/jboss/injection src/resources/META-INF
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Oct 6 04:38:05 EDT 2006
Author: wolfc
Date: 2006-10-06 04:37:48 -0400 (Fri, 06 Oct 2006)
New Revision: 57464
Added:
branches/JEE5_TCK/ejb3/src/main/org/jboss/ejb3/client/
branches/JEE5_TCK/ejb3/src/main/org/jboss/ejb3/client/ClientContainer.java
branches/JEE5_TCK/ejb3/src/main/org/jboss/ejb3/client/ClientLauncher.java
branches/JEE5_TCK/ejb3/src/main/org/jboss/ejb3/client/package.html
branches/JEE5_TCK/ejb3/src/main/org/jboss/ejb3/clientmodule/
branches/JEE5_TCK/ejb3/src/main/org/jboss/ejb3/clientmodule/ClientENCInjectionContainer.java
branches/JEE5_TCK/ejb3/src/main/org/jboss/ejb3/clientmodule/ClientEjbResolver.java
branches/JEE5_TCK/ejb3/src/main/org/jboss/ejb3/clientmodule/package.html
branches/JEE5_TCK/ejb3/src/main/org/jboss/ejb3/deployment/
branches/JEE5_TCK/ejb3/src/main/org/jboss/ejb3/deployment/EJB3ClientDeployer.java
branches/JEE5_TCK/ejb3/src/main/org/jboss/ejb3/deployment/EJB3ClientDeployerMBean.java
branches/JEE5_TCK/ejb3/src/main/org/jboss/injection/ClientEJBHandler.java
Modified:
branches/JEE5_TCK/ejb3/build.xml
branches/JEE5_TCK/ejb3/src/main/org/jboss/ejb3/metamodel/ApplicationClientDD.java
branches/JEE5_TCK/ejb3/src/main/org/jboss/injection/EjbEncInjector.java
branches/JEE5_TCK/ejb3/src/resources/META-INF/jboss-service.xml
Log:
JBCTS-329: prototype client container
Modified: branches/JEE5_TCK/ejb3/build.xml
===================================================================
--- branches/JEE5_TCK/ejb3/build.xml 2006-10-06 07:07:17 UTC (rev 57463)
+++ branches/JEE5_TCK/ejb3/build.xml 2006-10-06 08:37:48 UTC (rev 57464)
@@ -400,6 +400,10 @@
<!-- EJBTHREE-667: include object factory -->
<include name="org/jboss/ejb3/naming/client/**/*.class"/>
<include name="org/jboss/ejb3/naming/BrainlessContext.class"/>
+
+ <include name="org/jboss/ejb3/client/**/*.class"/>
+ <include name="org/jboss/injection/**/*.class"/>
+ <include name="org/jboss/ejb3/ThreadLocalENCFactory.class"/>
</fileset>
</jar>
Added: branches/JEE5_TCK/ejb3/src/main/org/jboss/ejb3/client/ClientContainer.java
===================================================================
--- branches/JEE5_TCK/ejb3/src/main/org/jboss/ejb3/client/ClientContainer.java 2006-10-06 07:07:17 UTC (rev 57463)
+++ branches/JEE5_TCK/ejb3/src/main/org/jboss/ejb3/client/ClientContainer.java 2006-10-06 08:37:48 UTC (rev 57464)
@@ -0,0 +1,354 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, 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.client;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NameClassPair;
+import javax.naming.NameNotFoundException;
+import javax.naming.NamingEnumeration;
+
+import org.jboss.ejb3.Container;
+import org.jboss.ejb3.DependencyPolicy;
+import org.jboss.ejb3.entity.PersistenceUnitDeployment;
+import org.jboss.ejb3.metamodel.ApplicationClientDD;
+import org.jboss.injection.DependsHandler;
+import org.jboss.injection.EJBHandler;
+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.WebServiceHandler;
+import org.jboss.logging.Logger;
+import org.jboss.metamodel.descriptor.EnvironmentRefGroup;
+
+/**
+ * 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: $
+ */
+public class ClientContainer implements InjectionContainer
+{
+ private static final Logger log = Logger.getLogger(ClientContainer.class);
+
+ private Class<?> mainClass;
+ private ApplicationClientDD xml;
+ private String applicationClientName;
+
+ // for performance there is an array.
+ private List<Injector> injectors = new ArrayList<Injector>();
+ private Map<String, Map<AccessibleObject, Injector>> encInjections = new HashMap<String, Map<AccessibleObject, Injector>>();
+ private Map<String, EncInjector> encInjectors = new HashMap<String, EncInjector>();
+
+ private Context enc;
+ private Context encEnv;
+
+ /**
+ * This constructor is temporary.
+ *
+ * @param mainClass
+ * @param applicationClientName
+ * @throws Exception
+ */
+ public ClientContainer(Class<?> mainClass, String applicationClientName) throws Exception
+ {
+ this(null, mainClass, applicationClientName);
+ }
+
+ public ClientContainer(ApplicationClientDD xml, Class<?> mainClass, String applicationClientName) throws Exception
+ {
+ this.xml = xml;
+ this.mainClass = mainClass;
+ this.applicationClientName = applicationClientName;
+
+ //Context ctx = getInitialContext();
+ Context ctx = new InitialContext();
+ enc = (Context) ctx.lookup(applicationClientName);
+ NamingEnumeration<NameClassPair> e = enc.list("");
+ while(e.hasMore())
+ {
+ NameClassPair ncp = e.next();
+ log.info(" " + ncp);
+ }
+ encEnv = (Context) enc.lookup("env");
+// enc = ThreadLocalENCFactory.create(ctx);
+// encEnv = Util.createSubcontext(enc, "env");
+
+ processMetadata(null);
+
+// for (EncInjector injector : encInjectors.values())
+// {
+// log.trace("encInjector: " + injector);
+// injector.inject(this);
+// }
+
+ for(Injector injector : injectors)
+ {
+ log.trace("injector: " + injector);
+ injector.inject((Object) null);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.injection.InjectionContainer#getAnnotation(java.lang.Class, java.lang.Class)
+ */
+ public <T extends Annotation> T getAnnotation(Class<T> annotationClass, Class<?> clazz)
+ {
+ return clazz.getAnnotation(annotationClass);
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.injection.InjectionContainer#getAnnotation(java.lang.Class, java.lang.Class, java.lang.reflect.Method)
+ */
+ public <T extends Annotation> T getAnnotation(Class<T> annotationClass, Class<?> clazz, Method method)
+ {
+ return method.getAnnotation(annotationClass);
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.injection.InjectionContainer#getAnnotation(java.lang.Class, java.lang.reflect.Method)
+ */
+ public <T extends Annotation> T getAnnotation(Class<T> annotationClass, Method method)
+ {
+ return method.getAnnotation(annotationClass);
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.injection.InjectionContainer#getAnnotation(java.lang.Class, java.lang.Class, java.lang.reflect.Field)
+ */
+ public <T extends Annotation> T getAnnotation(Class<T> annotationClass, Class<?> clazz, Field field)
+ {
+ return field.getAnnotation(annotationClass);
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.injection.InjectionContainer#getAnnotation(java.lang.Class, java.lang.reflect.Field)
+ */
+ public <T extends Annotation> T getAnnotation(Class<T> annotationClass, Field field)
+ {
+ return field.getAnnotation(annotationClass);
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.injection.InjectionContainer#getClassloader()
+ */
+ public ClassLoader getClassloader()
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.injection.InjectionContainer#getDependencyPolicy()
+ */
+ public DependencyPolicy getDependencyPolicy()
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.injection.InjectionContainer#getDeploymentDescriptorType()
+ */
+ public String getDeploymentDescriptorType()
+ {
+ return "application-client.xml";
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.injection.InjectionContainer#getEjbJndiName(java.lang.Class)
+ */
+ public String getEjbJndiName(Class businessInterface) throws NameNotFoundException
+ {
+ throw new RuntimeException("NYI");
+ //return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.injection.InjectionContainer#getEjbJndiName(java.lang.String, java.lang.Class)
+ */
+ public String getEjbJndiName(String link, Class businessInterface)
+ {
+ throw new RuntimeException("NYI");
+ //return "java:comp/env/" + link + "/remote";
+ //return applicationClientName + "/" + link + "/remote";
+ //return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.injection.InjectionContainer#getEnc()
+ */
+ public Context getEnc()
+ {
+ return enc;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.injection.InjectionContainer#getEncEnv()
+ */
+ public Context getEncEnv()
+ {
+ return encEnv;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.injection.InjectionContainer#getEncInjections()
+ */
+ public Map<String, Map<AccessibleObject, Injector>> getEncInjections()
+ {
+ return encInjections;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.injection.InjectionContainer#getEncInjectors()
+ */
+ public Map<String, EncInjector> getEncInjectors()
+ {
+ return encInjectors;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.injection.InjectionContainer#getEnvironmentRefGroup()
+ */
+ public EnvironmentRefGroup getEnvironmentRefGroup()
+ {
+ return xml;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.injection.InjectionContainer#getIdentifier()
+ */
+ public String getIdentifier()
+ {
+// throw new RuntimeException("NYI");
+ // FIXME: return the real identifier
+ //return "client-identifier";
+ return applicationClientName;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.injection.InjectionContainer#getInjectors()
+ */
+ public List<Injector> getInjectors()
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ public Class<?> getMainClass()
+ {
+ return mainClass;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.injection.InjectionContainer#getPersistenceUnitDeployment(java.lang.String)
+ */
+ public PersistenceUnitDeployment getPersistenceUnitDeployment(String unitName) throws NameNotFoundException
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ public void invokeMain(String args[]) throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException
+ {
+ Class parameterTypes[] = { args.getClass() };
+ Method method = mainClass.getDeclaredMethod("main", parameterTypes);
+ method.invoke(null, (Object) args);
+ }
+
+ private void processMetadata(DependencyPolicy dependencyPolicy)
+ {
+ // TODO: check which handlers a client container should support
+ Collection<InjectionHandler> handlers = new ArrayList<InjectionHandler>();
+ handlers.add(new EJBHandler());
+ //handlers.add(new ClientEJBHandler());
+ handlers.add(new DependsHandler());
+ handlers.add(new JndiInjectHandler());
+ handlers.add(new PersistenceContextHandler());
+ handlers.add(new PersistenceUnitHandler());
+ handlers.add(new ResourceHandler());
+ handlers.add(new WebServiceHandler());
+
+ // TODO: we're going to use a jar class loader
+// 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);
+
+ Map<AccessibleObject, Injector> tmp = InjectionUtil.processAnnotations(this, handlers, getMainClass());
+ injectors.addAll(tmp.values());
+
+// initialiseInterceptors();
+// for (InterceptorInfo interceptorInfo : applicableInterceptors)
+// {
+// for (InjectionHandler handler : handlers)
+// {
+// handler.loadXml(interceptorInfo.getXml(), this);
+// }
+// }
+// for (InterceptorInfo interceptorInfo : applicableInterceptors)
+// {
+// Map<AccessibleObject, Injector> tmpInterceptor = InjectionUtil.processAnnotations(this, handlers, interceptorInfo.getClazz());
+// InterceptorInjector injector = new InterceptorInjector(this, interceptorInfo, tmpInterceptor);
+// interceptorInjectors.put(interceptorInfo.getClazz(), injector);
+// }
+ }
+ finally
+ {
+// Thread.currentThread().setContextClassLoader(old);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.injection.InjectionContainer#resolveEjbContainer(java.lang.String, java.lang.Class)
+ */
+ public Container resolveEjbContainer(String link, Class businessIntf)
+ {
+// throw new RuntimeException("NYI");
+ log.warn("resolveEjbContainer(" + link + ", " + businessIntf + ") not implemented");
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.injection.InjectionContainer#resolveEjbContainer(java.lang.Class)
+ */
+ public Container resolveEjbContainer(Class businessIntf) throws NameNotFoundException
+ {
+// throw new RuntimeException("NYI");
+ return null;
+ }
+}
Added: branches/JEE5_TCK/ejb3/src/main/org/jboss/ejb3/client/ClientLauncher.java
===================================================================
--- branches/JEE5_TCK/ejb3/src/main/org/jboss/ejb3/client/ClientLauncher.java 2006-10-06 07:07:17 UTC (rev 57463)
+++ branches/JEE5_TCK/ejb3/src/main/org/jboss/ejb3/client/ClientLauncher.java 2006-10-06 08:37:48 UTC (rev 57464)
@@ -0,0 +1,117 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, 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.client;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.ejb3.metamodel.ApplicationClientDD;
+import org.jboss.ejb3.metamodel.ApplicationClientDDObjectFactory;
+
+/**
+ * This class launches a JavaEE 5 application client.
+ *
+ * The first argument is either a jar file containing the client deployment files or a the application client class name.
+ * The manifest file Main-Class attribute must point to the application client class.
+ * It may also contain an application client deployment descriptor file (META-INF/application-client.xml).
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class ClientLauncher
+{
+ /**
+ * Convenience method for launching a client container.
+ *
+ * @param mainClassName
+ * @param applicationClientName
+ * @param args
+ * @throws Exception
+ */
+ public static void launch(String mainClassName, String applicationClientName, String args[]) throws Exception
+ {
+ Class mainClass = Class.forName(mainClassName);
+
+ ClientContainer container = new ClientContainer(mainClass, applicationClientName);
+
+ // TODO: postContruct
+
+ container.invokeMain(args);
+
+ // TODO: preDestroy
+ }
+
+ /**
+ * @param args the arguments for the launcher
+ */
+ public static void main(String[] args)
+ {
+ try
+ {
+ if(args.length < 1)
+ throw new IllegalArgumentException("expected a jar filename as argument");
+
+ Class<?> mainClass;
+
+ String name = args[0];
+ if(name.endsWith(".jar"))
+ {
+ throw new RuntimeException("NYI");
+// JarFile jarFile = new JarFile(jarName);
+ }
+ else
+ {
+ String mainClassName = name;
+ mainClass = Class.forName(mainClassName);
+ }
+
+ URL appXmlURL = mainClass.getClassLoader().getResource("META-INF/application-client.xml");
+ if(appXmlURL == null)
+ throw new RuntimeException("Can't find META-INF/application-client.xml");
+
+ ApplicationClientDD xml = ApplicationClientDDObjectFactory.parse(appXmlURL);
+
+ // FIXME: j2ee.clientName
+ ClientContainer container = new ClientContainer(xml, mainClass, "FIXME");
+
+ List<String> newArgs = new ArrayList<String>();
+ for(int i = 1; i < args.length; i++)
+ {
+ newArgs.add(args[i]);
+ }
+ args = newArgs.toArray(args);
+
+ // TODO: postContruct
+
+ container.invokeMain(args);
+
+ // TODO: preDestroy
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ System.exit(1);
+ }
+ }
+
+}
Added: branches/JEE5_TCK/ejb3/src/main/org/jboss/ejb3/client/package.html
===================================================================
--- branches/JEE5_TCK/ejb3/src/main/org/jboss/ejb3/client/package.html 2006-10-06 07:07:17 UTC (rev 57463)
+++ branches/JEE5_TCK/ejb3/src/main/org/jboss/ejb3/client/package.html 2006-10-06 08:37:48 UTC (rev 57464)
@@ -0,0 +1,9 @@
+<html>
+ <head>
+ <title>org.jboss.ejb3.client</title>
+ </head>
+ <body>
+ This package contains all classes needed for running a client container.
+ (Java EE 5 Chapter 9, EJB3 Chapter 15)
+ </body>
+</html>
\ No newline at end of file
Added: branches/JEE5_TCK/ejb3/src/main/org/jboss/ejb3/clientmodule/ClientENCInjectionContainer.java
===================================================================
--- branches/JEE5_TCK/ejb3/src/main/org/jboss/ejb3/clientmodule/ClientENCInjectionContainer.java 2006-10-06 07:07:17 UTC (rev 57463)
+++ branches/JEE5_TCK/ejb3/src/main/org/jboss/ejb3/clientmodule/ClientENCInjectionContainer.java 2006-10-06 08:37:48 UTC (rev 57464)
@@ -0,0 +1,287 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, 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.clientmodule;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.naming.Context;
+import javax.naming.NameNotFoundException;
+import javax.naming.NamingException;
+
+import org.jboss.deployment.DeploymentInfo;
+import org.jboss.ejb3.Container;
+import org.jboss.ejb3.DependencyPolicy;
+import org.jboss.ejb3.EAR;
+import org.jboss.ejb3.JmxDependencyPolicy;
+import org.jboss.ejb3.JmxEARImpl;
+import org.jboss.ejb3.enc.DeploymentEjbResolver;
+import org.jboss.ejb3.entity.PersistenceUnitDeployment;
+import org.jboss.ejb3.metamodel.ApplicationClientDD;
+import org.jboss.injection.DependsHandler;
+import org.jboss.injection.EJBHandler;
+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.WebServiceHandler;
+import org.jboss.logging.Logger;
+import org.jboss.metamodel.descriptor.EnvironmentRefGroup;
+import org.jboss.naming.Util;
+
+/**
+ * This class builds up the java:comp namespace for JavaEE 5 application clients.
+ * It uses the existing injection framework to get this done.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class ClientENCInjectionContainer implements InjectionContainer
+{
+ private static final Logger log = Logger.getLogger(ClientENCInjectionContainer.class);
+
+ private ApplicationClientDD xml;
+ private Class<?> mainClass;
+ private ClassLoader classLoader;
+
+ // TODO: remove injectors, these are not supported
+ private List<Injector> injectors = new ArrayList<Injector>();
+ private Map<String, Map<AccessibleObject, Injector>> encInjections = new HashMap<String, Map<AccessibleObject, Injector>>();
+ private Map<String, EncInjector> encInjectors = new HashMap<String, EncInjector>();
+
+ private Context enc;
+ private Context encEnv;
+
+ private DeploymentEjbResolver ejbResolver;
+ private DependencyPolicy dependencyPolicy = new JmxDependencyPolicy();
+
+ public ClientENCInjectionContainer(DeploymentInfo di, ApplicationClientDD xml, Class<?> mainClass, String applicationClientName, ClassLoader cl, Context encCtx) throws NamingException
+ {
+ this.xml = xml;
+ this.mainClass = mainClass;
+ this.classLoader = cl;
+
+ this.enc = encCtx;
+
+ encEnv = Util.createSubcontext(enc, "env");
+
+ EAR ear = null;
+
+ if (di.parent != null)
+ {
+ if (di.parent.shortName.endsWith(".ear") || di.parent.shortName.endsWith(".ear/"))
+ {
+ synchronized (di.parent.context)
+ {
+ ear = (EAR) di.parent.context.get("EJB3_EAR_METADATA");
+ if (ear == null)
+ {
+ ear = new JmxEARImpl(di.parent.shortName);
+ di.parent.context.put("EJB3_EAR_METADATA", ear);
+ }
+ }
+ }
+ }
+ ejbResolver = new ClientEjbResolver(ear, di.shortName);
+
+ processMetaData();
+
+ populateEnc();
+
+ // Don't run any injectors, they must be run client side
+ }
+
+ public <T extends Annotation> T getAnnotation(Class<T> annotationType, Class<?> clazz)
+ {
+ return clazz.getAnnotation(annotationType);
+ }
+
+ public <T extends Annotation> T getAnnotation(Class<T> annotationType, Class<?> clazz, Method method)
+ {
+ return method.getAnnotation(annotationType);
+ }
+
+ public <T extends Annotation> T getAnnotation(Class<T> annotationType, Method method)
+ {
+ return method.getAnnotation(annotationType);
+ }
+
+ public <T extends Annotation> T getAnnotation(Class<T> annotationType, Class<?> clazz, Field field)
+ {
+ return field.getAnnotation(annotationType);
+ }
+
+ public <T extends Annotation> T getAnnotation(Class<T> annotationType, Field field)
+ {
+ return field.getAnnotation(annotationType);
+ }
+
+ public ClassLoader getClassloader()
+ {
+ return classLoader;
+ }
+
+ public DependencyPolicy getDependencyPolicy()
+ {
+ return dependencyPolicy;
+ }
+
+ public String getDeploymentDescriptorType()
+ {
+ return "application-client.xml";
+ }
+
+ public String getEjbJndiName(Class businessInterface) throws NameNotFoundException
+ {
+ return ejbResolver.getEjbJndiName(businessInterface);
+ }
+
+ public String getEjbJndiName(String link, Class businessInterface)
+ {
+ return ejbResolver.getEjbJndiName(link, businessInterface);
+ }
+
+ public Context getEnc()
+ {
+ return enc;
+ }
+
+ public Context getEncEnv()
+ {
+ return encEnv;
+ }
+
+ public Map<String, Map<AccessibleObject, Injector>> getEncInjections()
+ {
+ return encInjections;
+ }
+
+ public Map<String, EncInjector> getEncInjectors()
+ {
+ return encInjectors;
+ }
+
+ public EnvironmentRefGroup getEnvironmentRefGroup()
+ {
+ return xml;
+ }
+
+ public String getIdentifier()
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ /**
+ * A client enc injection container doesn't support injectors, because
+ * these must be run client side.
+ */
+ public List<Injector> getInjectors()
+ {
+ //throw new RuntimeException("not supported");
+ return injectors;
+ }
+
+ public Class<?> getMainClass()
+ {
+ return mainClass;
+ }
+
+ public PersistenceUnitDeployment getPersistenceUnitDeployment(String unitName) throws NameNotFoundException
+ {
+ throw new RuntimeException("NYI");
+ }
+
+ private void populateEnc()
+ {
+ for (EncInjector injector : encInjectors.values())
+ {
+ log.trace("encInjector: " + injector);
+ injector.inject(this);
+ }
+ }
+
+ private void processMetaData()
+ {
+ // 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 WebServiceHandler());
+
+ 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);
+
+ Map<AccessibleObject, Injector> tmp = InjectionUtil.processAnnotations(this, handlers, getMainClass());
+ injectors.addAll(tmp.values());
+
+// initialiseInterceptors();
+// for (InterceptorInfo interceptorInfo : applicableInterceptors)
+// {
+// for (InjectionHandler handler : handlers)
+// {
+// handler.loadXml(interceptorInfo.getXml(), this);
+// }
+// }
+// for (InterceptorInfo interceptorInfo : applicableInterceptors)
+// {
+// Map<AccessibleObject, Injector> tmpInterceptor = InjectionUtil.processAnnotations(this, handlers, interceptorInfo.getClazz());
+// InterceptorInjector injector = new InterceptorInjector(this, interceptorInfo, tmpInterceptor);
+// interceptorInjectors.put(interceptorInfo.getClazz(), injector);
+// }
+ }
+ finally
+ {
+ Thread.currentThread().setContextClassLoader(old);
+ }
+ }
+
+ public Container resolveEjbContainer(String link, Class businessIntf)
+ {
+ return ejbResolver.getEjbContainer(link, businessIntf);
+ }
+
+ public Container resolveEjbContainer(Class businessIntf) throws NameNotFoundException
+ {
+ return ejbResolver.getEjbContainer(businessIntf);
+ }
+
+}
Added: branches/JEE5_TCK/ejb3/src/main/org/jboss/ejb3/clientmodule/ClientEjbResolver.java
===================================================================
--- branches/JEE5_TCK/ejb3/src/main/org/jboss/ejb3/clientmodule/ClientEjbResolver.java 2006-10-06 07:07:17 UTC (rev 57463)
+++ branches/JEE5_TCK/ejb3/src/main/org/jboss/ejb3/clientmodule/ClientEjbResolver.java 2006-10-06 08:37:48 UTC (rev 57464)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, 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.clientmodule;
+
+import javax.naming.NameNotFoundException;
+
+import org.jboss.ejb3.EAR;
+import org.jboss.ejb3.EJBContainer;
+import org.jboss.ejb3.enc.DeploymentEjbResolver;
+
+// based on WarEjbResolver
+/**
+ * Resolves ejb references within an application client.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class ClientEjbResolver extends DeploymentEjbResolver
+{
+
+ protected ClientEjbResolver(EAR ear, String errorName)
+ {
+ super(ear, errorName);
+ }
+
+ @Override
+ protected EJBContainer searchDeploymentInternally(String ejbLink, Class businessIntf)
+ {
+ return null;
+ }
+
+ @Override
+ protected EJBContainer searchForEjbContainerInternally(Class businessIntf) throws NameNotFoundException
+ {
+ return null;
+ }
+
+}
Added: branches/JEE5_TCK/ejb3/src/main/org/jboss/ejb3/clientmodule/package.html
===================================================================
--- branches/JEE5_TCK/ejb3/src/main/org/jboss/ejb3/clientmodule/package.html 2006-10-06 07:07:17 UTC (rev 57463)
+++ branches/JEE5_TCK/ejb3/src/main/org/jboss/ejb3/clientmodule/package.html 2006-10-06 08:37:48 UTC (rev 57464)
@@ -0,0 +1,12 @@
+<html>
+ <head>
+ <title>org.jboss.ejb3.clientmodule</title>
+ </head>
+ <body>
+ The client module is a deployment container which supports injection. All injected
+ attributes are made available in JNDI under a context with the application client jndi name.
+ This jndi name can be configured in META-INF/jboss-client.xml.
+ The package forms a connector with the org.jboss.ejb3.client which runs in the client JVM.
+ (Java EE 5 Chapter 9, EJB3 Chapter 15)
+ </body>
+</html>
\ No newline at end of file
Added: branches/JEE5_TCK/ejb3/src/main/org/jboss/ejb3/deployment/EJB3ClientDeployer.java
===================================================================
--- branches/JEE5_TCK/ejb3/src/main/org/jboss/ejb3/deployment/EJB3ClientDeployer.java 2006-10-06 07:07:17 UTC (rev 57463)
+++ branches/JEE5_TCK/ejb3/src/main/org/jboss/ejb3/deployment/EJB3ClientDeployer.java 2006-10-06 08:37:48 UTC (rev 57464)
@@ -0,0 +1,294 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, 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.deployment;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.jar.Attributes;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.jboss.deployment.DeploymentException;
+import org.jboss.deployment.DeploymentInfo;
+import org.jboss.deployment.SubDeployer;
+import org.jboss.deployment.SubDeployerSupport;
+import org.jboss.ejb3.clientmodule.ClientENCInjectionContainer;
+import org.jboss.ejb3.metamodel.ApplicationClientDD;
+import org.jboss.ejb3.metamodel.ApplicationClientDDObjectFactory;
+import org.jboss.metadata.MetaData;
+import org.jboss.metadata.XmlFileLoader;
+import org.jboss.naming.Util;
+import org.w3c.dom.Element;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class EJB3ClientDeployer extends SubDeployerSupport
+ implements SubDeployer, EJB3ClientDeployerMBean
+{
+ public EJB3ClientDeployer()
+ {
+ setSuffixes(new String[]{".jar"});
+ setRelativeOrder(400);
+ }
+
+ /**
+ * @jmx:managed-operation
+ */
+ @Override
+ public boolean accepts(DeploymentInfo di)
+ {
+ log.debug("accepts " + di.shortName);
+
+ String urlStr = di.url.getFile();
+ // To be accepted the deployment's root name must end in jar
+ if (!urlStr.endsWith(".jar") && !urlStr.endsWith(".jar/"))
+ {
+ // TODO: isn't this an illegal state, because we've specified suffixes?
+ return false;
+ }
+
+ if(has50ApplicationClientXml(di))
+ {
+ log.info("accepted " + di.shortName);
+ return true;
+ }
+
+ return false;
+ }
+
+ @Override
+ public synchronized void create(DeploymentInfo di) throws DeploymentException
+ {
+ log.debug("create " + di.shortName);
+
+ // initialize the annotations loader
+ URL loaderURL = (di.localUrl != null ? di.localUrl : di.url);
+ di.annotationsCl = new URLClassLoader(new URL[]{loaderURL}, di.ucl);
+
+ super.create(di);
+ }
+
+ @Override
+ public void destroy(DeploymentInfo di) throws DeploymentException
+ {
+ log.debug("destroy " + di.shortName);
+ // TODO Auto-generated method stub
+ super.destroy(di);
+ }
+
+ protected boolean has50ApplicationClientXml(DeploymentInfo di)
+ {
+ try
+ {
+ if(!hasFile(di, "META-INF/application-client.xml"))
+ return false;
+
+ InputStream in = di.localCl.getResourceAsStream("META-INF/application-client.xml");
+ try
+ {
+ XmlFileLoader xfl = new XmlFileLoader(true);
+ Element appClient = xfl.getDocument(in, "META-INF/application-client.xml").getDocumentElement();
+ String version = appClient.getAttribute("version");
+ if(!version.equals("5"))
+ {
+ log.debug("wrong version application-client.xml in " + di.shortName);
+ // it will be picked up by the normal client deployer
+ return false;
+ }
+ return true;
+ }
+ finally
+ {
+ in.close();
+ }
+ }
+ catch(DeploymentException e)
+ {
+ log.warn("Parsing META-INF/application-client.xml failed", e);
+ return false;
+ }
+ catch(IOException e)
+ {
+ log.warn("Can't read META-INF/application-client.xml", e);
+ return false;
+ }
+ }
+
+ // TODO: integrate with EJB3Deployer.hasFile
+ protected boolean hasFile(DeploymentInfo di, String filePath)
+ {
+ String urlStr = di.url.getFile();
+ try
+ {
+ URL dd = di.localCl.findResource(filePath);
+ if (dd != null)
+ {
+
+ // If the DD url is not a subset of the urlStr then this is coming
+ // from a jar referenced by the deployment jar manifest and the
+ // this deployment jar it should not be treated as persistence
+ if (di.localUrl != null)
+ {
+ urlStr = di.localUrl.toString();
+ }
+
+ String ddStr = dd.toString();
+ if (ddStr.indexOf(urlStr) >= 0)
+ {
+ return true;
+ }
+ }
+ }
+ catch (Exception ignore)
+ {
+ log.trace("hasFile failed", ignore);
+ }
+ return false;
+ }
+
+ private Class<?> loadClass(DeploymentInfo di, String className) throws ClassNotFoundException
+ {
+ ClassLoader old = Thread.currentThread().getContextClassLoader();
+ try
+ {
+ Thread.currentThread().setContextClassLoader(di.ucl);
+ return Thread.currentThread().getContextClassLoader().loadClass(className);
+ }
+ finally
+ {
+ Thread.currentThread().setContextClassLoader(old);
+ }
+ }
+
+ @Override
+ public synchronized void start(DeploymentInfo di) throws DeploymentException
+ {
+ log.debug("start " + di.shortName);
+
+ try
+ {
+ URL ddResource = di.localCl.findResource("META-INF/application-client.xml");
+ ApplicationClientDD xml = ApplicationClientDDObjectFactory.parse(ddResource);
+
+ // Look for a jboss-client.xml descriptor
+ URL jbossClientURL = di.localCl.findResource("META-INF/jboss-client.xml");
+ if(jbossClientURL != null)
+ {
+ InputStream in = jbossClientURL.openStream();
+ try
+ {
+ XmlFileLoader xfl = new XmlFileLoader(true);
+ Element jbossClient = xfl.getDocument(in, "META-INF/jboss-client.xml").getDocumentElement();
+
+ String jndiName = MetaData.getOptionalChildContent(jbossClient, "jndi-name");
+ xml.setJndiName(jndiName);
+ }
+ finally
+ {
+ in.close();
+ }
+ }
+
+ di.metaData = xml;
+
+ String appClientName = xml.getJndiName();
+ // I create the namespace here, because I destroy it in stop
+ InitialContext iniCtx = new InitialContext();
+ Context encCtx = Util.createSubcontext(iniCtx, appClientName);
+ log.debug("Creating client ENC binding under: " + appClientName);
+
+ log.trace("parsing " + di.localCl.findResource(JarFile.MANIFEST_NAME));
+
+ URL url = di.localCl.findResource(JarFile.MANIFEST_NAME);
+ InputStream is = url.openStream();
+ if(is == null)
+ throw new DeploymentException("Can't find " + JarFile.MANIFEST_NAME);
+ Manifest mf;
+ try
+ {
+ mf = new Manifest(is);
+ }
+ finally
+ {
+ is.close();
+ }
+ Attributes attrs = mf.getMainAttributes();
+ String mainClassName = attrs.getValue("Main-Class");
+ // TODO: workaround: TCK uses main-class as key
+ if(mainClassName == null)
+ mainClassName = attrs.getValue("main-class");
+ if(mainClassName == null)
+ throw new Exception("Main-Class is null");
+
+ //Class<?> mainClass = di.ucl.loadClass(mainClassName);
+ //Class<?> mainClass = di.annotationsCl.loadClass(mainClassName);
+ Class<?> mainClass = loadClass(di, mainClassName);
+
+ @SuppressWarnings("unused")
+ ClientENCInjectionContainer container = new ClientENCInjectionContainer(di, xml, mainClass, appClientName, di.ucl, encCtx);
+ }
+ catch(Exception e)
+ {
+ log.error("Could not deploy " + di.url, e);
+ stop(di);
+ destroy(di);
+ throw new DeploymentException("Could not deploy " + di.url, e);
+ }
+
+ super.start(di);
+ }
+
+ @Override
+ public void stop(DeploymentInfo di) throws DeploymentException
+ {
+ log.debug("stop " + di.shortName);
+
+ // Teardown the JNDI context
+ ApplicationClientDD metaData = (ApplicationClientDD) di.metaData;
+ if (metaData != null)
+ {
+ String appClientName = metaData.getJndiName();
+ log.info("Removing client ENC from: " + appClientName);
+ try
+ {
+ InitialContext iniCtx = new InitialContext();
+ Util.unbind(iniCtx, appClientName);
+ }
+ catch (NamingException e)
+ {
+ throw new DeploymentException("Failed to remove client ENC", e);
+ }
+ }
+
+ super.stop(di);
+ }
+}
Added: branches/JEE5_TCK/ejb3/src/main/org/jboss/ejb3/deployment/EJB3ClientDeployerMBean.java
===================================================================
--- branches/JEE5_TCK/ejb3/src/main/org/jboss/ejb3/deployment/EJB3ClientDeployerMBean.java 2006-10-06 07:07:17 UTC (rev 57463)
+++ branches/JEE5_TCK/ejb3/src/main/org/jboss/ejb3/deployment/EJB3ClientDeployerMBean.java 2006-10-06 08:37:48 UTC (rev 57464)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, 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.deployment;
+
+import javax.management.ObjectName;
+
+import org.jboss.deployment.SubDeployerMBean;
+import org.jboss.mx.util.ObjectNameFactory;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public interface EJB3ClientDeployerMBean extends SubDeployerMBean
+{
+ /** The default ObjectName */
+ ObjectName OBJECT_NAME = ObjectNameFactory.create("jboss.ejb3:service=EJB3ClientDeployer");
+}
Modified: branches/JEE5_TCK/ejb3/src/main/org/jboss/ejb3/metamodel/ApplicationClientDD.java
===================================================================
--- branches/JEE5_TCK/ejb3/src/main/org/jboss/ejb3/metamodel/ApplicationClientDD.java 2006-10-06 07:07:17 UTC (rev 57463)
+++ branches/JEE5_TCK/ejb3/src/main/org/jboss/ejb3/metamodel/ApplicationClientDD.java 2006-10-06 08:37:48 UTC (rev 57464)
@@ -22,19 +22,10 @@
package org.jboss.ejb3.metamodel;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
-import javax.security.auth.callback.CallbackHandler;
-
import org.jboss.logging.Logger;
-import org.jboss.metamodel.descriptor.EjbRef;
-import org.jboss.metamodel.descriptor.EnvEntry;
import org.jboss.metamodel.descriptor.EnvironmentRefGroup;
-import org.jboss.metamodel.descriptor.MessageDestinationRef;
-import org.jboss.metamodel.descriptor.PersistenceUnitRef;
-import org.jboss.metamodel.descriptor.ResourceEnvRef;
-import org.jboss.metamodel.descriptor.ResourceRef;
/**
* This represents a application client deployment descriptor.
@@ -46,6 +37,7 @@
*/
public class ApplicationClientDD extends EnvironmentRefGroup
{
+ @SuppressWarnings("unused")
private static final Logger log = Logger.getLogger(ApplicationClientDD.class);
private String displayName;
@@ -65,6 +57,10 @@
private int version = 5;
private boolean metadataComplete = false;
+ // from jboss-client.xml
+
+ private String jndiName;
+
public String getDisplayName()
{
return displayName;
@@ -75,6 +71,18 @@
this.displayName = displayName;
}
+ public String getJndiName()
+ {
+ if(jndiName == null)
+ return getDisplayName();
+ return jndiName;
+ }
+
+ public void setJndiName(String jndiName)
+ {
+ this.jndiName = jndiName;
+ }
+
public boolean isMetaDataComplete()
{
return metadataComplete;
Added: branches/JEE5_TCK/ejb3/src/main/org/jboss/injection/ClientEJBHandler.java
===================================================================
--- branches/JEE5_TCK/ejb3/src/main/org/jboss/injection/ClientEJBHandler.java 2006-10-06 07:07:17 UTC (rev 57463)
+++ branches/JEE5_TCK/ejb3/src/main/org/jboss/injection/ClientEJBHandler.java 2006-10-06 08:37:48 UTC (rev 57464)
@@ -0,0 +1,96 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, 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 javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.jboss.logging.Logger;
+import org.jboss.metamodel.descriptor.EnvironmentRefGroup;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class ClientEJBHandler implements InjectionHandler
+{
+ private static final Logger log = Logger.getLogger(ClientEJBHandler.class);
+
+ public void handleClassAnnotations(Class clazz, InjectionContainer container)
+ {
+ // TODO Auto-generated method stub
+ log.warn("NYI");
+
+ }
+
+ public void handleFieldAnnotations(Field field, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
+ {
+ EJB ref = field.getAnnotation(EJB.class);
+ if(ref != null)
+ {
+// String encName = ref.name();
+// if (encName == null || encName.equals(""))
+// {
+// encName = InjectionUtil.getEncName(field);
+// }
+// else
+// {
+// encName = "env/" + encName;
+// }
+ String jndiName = ref.mappedName();
+ if(jndiName == null || jndiName.equals(""))
+ {
+ jndiName = container.getEjbJndiName(ref.beanName(), field.getType());
+ }
+ try
+ {
+ InitialContext ctx = new InitialContext();
+ injectors.put(field, new JndiFieldInjector(field, jndiName, ctx));
+ }
+ catch(NamingException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
+ public void handleMethodAnnotations(Method method, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
+ {
+ // TODO Auto-generated method stub
+ log.warn("NYI");
+ }
+
+ public void loadXml(EnvironmentRefGroup xml, InjectionContainer container)
+ {
+ // TODO Auto-generated method stub
+ log.warn("NYI");
+ }
+
+}
Modified: branches/JEE5_TCK/ejb3/src/main/org/jboss/injection/EjbEncInjector.java
===================================================================
--- branches/JEE5_TCK/ejb3/src/main/org/jboss/injection/EjbEncInjector.java 2006-10-06 07:07:17 UTC (rev 57463)
+++ branches/JEE5_TCK/ejb3/src/main/org/jboss/injection/EjbEncInjector.java 2006-10-06 08:37:48 UTC (rev 57464)
@@ -92,6 +92,7 @@
try
{
if (jndiName == null) throw new RuntimeException("Failed to populate ENC: " + encName + " global jndi name was null");
+ log.debug(" " + encName + " --> " + jndiName);
Util.rebind(container.getEnc(), encName, new LinkRef(jndiName));
}
catch (NamingException e)
Modified: branches/JEE5_TCK/ejb3/src/resources/META-INF/jboss-service.xml
===================================================================
--- branches/JEE5_TCK/ejb3/src/resources/META-INF/jboss-service.xml 2006-10-06 07:07:17 UTC (rev 57463)
+++ branches/JEE5_TCK/ejb3/src/resources/META-INF/jboss-service.xml 2006-10-06 08:37:48 UTC (rev 57464)
@@ -279,5 +279,11 @@
<depends>jboss.ejb:service=EJBDeployer</depends>
<depends optional-attribute-name="JarsIgnoredForScanning" proxy-type="org.jboss.ejb3.JarsIgnoredForScanningMBean">jboss.ejb3:service=JarsIgnoredForScanning</depends>
</mbean>
-
+
+ <!-- The EJB3 equivalent of the client-service -->
+ <mbean code="org.jboss.ejb3.deployment.EJB3ClientDeployer" name="jboss.ejb3:service=EJB3ClientDeployer">
+ <depends>jboss.ejb3:service=EJB3Deployer</depends>
+ <!-- Make sure we get started after the regular client deployer, so we're first in line in the main deployer -->
+ <depends>jboss.j2ee:service=ClientDeployer</depends>
+ </mbean>
</server>
More information about the jboss-cvs-commits
mailing list