[jboss-cvs] JBossAS SVN: r58008 - branches/JEE5_TCK/ejb3/src/main/org/jboss/ejb3/clientmodule trunk/ejb3 trunk/ejb3/src/main/org/jboss/ejb3/deployers trunk/ejb3/src/main/org/jboss/ejb3/metamodel trunk/ejb3/src/resources/META-INF trunk/ejb3/src/resources/test/appclient trunk/ejb3/src/resources/test/appclient/simpleresource trunk/ejb3/src/test/org/jboss/ejb3/test/appclient/client trunk/ejb3/src/test/org/jboss/ejb3/test/appclient/unit
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Nov 2 09:15:26 EST 2006
Author: wolfc
Date: 2006-11-02 09:14:58 -0500 (Thu, 02 Nov 2006)
New Revision: 58008
Added:
trunk/ejb3/src/main/org/jboss/ejb3/deployers/AppClientParsingDeployer.java
trunk/ejb3/src/main/org/jboss/ejb3/deployers/Ejb3ClientDeployer.java
trunk/ejb3/src/main/org/jboss/ejb3/deployers/JBossClientParsingDeployer.java
trunk/ejb3/src/resources/test/appclient/simpleresource/
trunk/ejb3/src/resources/test/appclient/simpleresource/application-client.xml
trunk/ejb3/src/test/org/jboss/ejb3/test/appclient/client/SimpleResourceClient.java
trunk/ejb3/src/test/org/jboss/ejb3/test/appclient/unit/SimpleResourceUnitTestCase.java
Modified:
branches/JEE5_TCK/ejb3/src/main/org/jboss/ejb3/clientmodule/ClientENCInjectionContainer.java
branches/JEE5_TCK/ejb3/src/main/org/jboss/ejb3/clientmodule/ClientEjbResolver.java
trunk/ejb3/build-test.xml
trunk/ejb3/src/main/org/jboss/ejb3/metamodel/ApplicationClientDDObjectFactory.java
trunk/ejb3/src/main/org/jboss/ejb3/metamodel/JBossClientDDObjectFactory.java
trunk/ejb3/src/resources/META-INF/ejb3-deployers-beans.xml
trunk/ejb3/src/test/org/jboss/ejb3/test/appclient/unit/AppClientUnitTestCase.java
Log:
EJBTHREE-718: client deployer
Modified: 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-11-02 13:04:21 UTC (rev 58007)
+++ branches/JEE5_TCK/ejb3/src/main/org/jboss/ejb3/clientmodule/ClientENCInjectionContainer.java 2006-11-02 14:14:58 UTC (rev 58008)
@@ -37,13 +37,13 @@
import javax.naming.NameNotFoundException;
import javax.naming.NamingException;
-import org.jboss.deployment.DeploymentInfo;
+import org.jboss.deployers.spi.deployer.DeploymentUnit;
import org.jboss.ejb3.Container;
import org.jboss.ejb3.DependencyPolicy;
-import org.jboss.ejb3.EAR;
+import org.jboss.ejb3.DeploymentScope;
import org.jboss.ejb3.Ejb3Module;
-import org.jboss.ejb3.JmxDependencyPolicy;
-import org.jboss.ejb3.JmxEARImpl;
+import org.jboss.ejb3.deployers.JBoss5DependencyPolicy;
+import org.jboss.ejb3.deployers.JBoss5DeploymentScope;
import org.jboss.ejb3.enc.DeploymentEjbResolver;
import org.jboss.ejb3.entity.PersistenceUnitDeployment;
import org.jboss.ejb3.metamodel.ApplicationClientDD;
@@ -89,9 +89,9 @@
private DeploymentEjbResolver ejbResolver;
private ObjectName objectName;
- private DependencyPolicy dependencyPolicy = new JmxDependencyPolicy();
+ private DependencyPolicy dependencyPolicy = new JBoss5DependencyPolicy();
- public ClientENCInjectionContainer(DeploymentInfo di, ApplicationClientDD xml, Class<?> mainClass, String applicationClientName, ClassLoader classLoader, Context encCtx) throws NamingException
+ public ClientENCInjectionContainer(DeploymentUnit unit, ApplicationClientDD xml, Class<?> mainClass, String applicationClientName, ClassLoader classLoader, Context encCtx) throws NamingException
{
if(mainClass == null)
throw new NullPointerException("mainClass is mandatory");
@@ -109,6 +109,7 @@
encEnv = Util.createSubcontext(enc, "env");
+ /*
EAR ear = null;
if (di.parent != null)
@@ -126,9 +127,17 @@
}
}
}
- ejbResolver = new ClientEjbResolver(ear, di.shortName);
+ */
- String on = Ejb3Module.BASE_EJB3_JMX_NAME + createScopeKernelName(di, ear) + ",name=" + applicationClientName;
+ DeploymentScope scope = null;
+ if (unit.getDeploymentContext().getParent() != null)
+ {
+ scope = new JBoss5DeploymentScope(unit.getDeploymentContext().getParent());
+ }
+
+ ejbResolver = new ClientEjbResolver(scope, unit.getDeploymentContext().getRoot().getName());
+
+ String on = Ejb3Module.BASE_EJB3_JMX_NAME + createScopeKernelName(unit, scope) + ",name=" + applicationClientName;
try
{
this.objectName = new ObjectName(on);
@@ -142,11 +151,11 @@
processMetaData();
}
- private String createScopeKernelName(DeploymentInfo di, EAR ear)
+ private String createScopeKernelName(DeploymentUnit unit, DeploymentScope ear)
{
String scopedKernelName = "";
if (ear != null) scopedKernelName += ",ear=" + ear.getShortName();
- scopedKernelName += ",jar=" + di.shortName;
+ scopedKernelName += ",jar=" + unit.getDeploymentContext().getRoot().getName();
return scopedKernelName;
}
Modified: 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-11-02 13:04:21 UTC (rev 58007)
+++ branches/JEE5_TCK/ejb3/src/main/org/jboss/ejb3/clientmodule/ClientEjbResolver.java 2006-11-02 14:14:58 UTC (rev 58008)
@@ -23,7 +23,8 @@
import javax.naming.NameNotFoundException;
-import org.jboss.ejb3.EAR;
+//import org.jboss.ejb3.EAR;
+import org.jboss.ejb3.DeploymentScope;
import org.jboss.ejb3.EJBContainer;
import org.jboss.ejb3.enc.DeploymentEjbResolver;
@@ -37,7 +38,7 @@
public class ClientEjbResolver extends DeploymentEjbResolver
{
- protected ClientEjbResolver(EAR ear, String errorName)
+ protected ClientEjbResolver(DeploymentScope ear, String errorName)
{
super(ear, errorName);
}
Modified: trunk/ejb3/build-test.xml
===================================================================
--- trunk/ejb3/build-test.xml 2006-11-02 13:04:21 UTC (rev 58007)
+++ trunk/ejb3/build-test.xml 2006-11-02 14:14:58 UTC (rev 58008)
@@ -753,6 +753,18 @@
<include name="appclient-test.jar"/>
</fileset>
</ear>
+
+ <jar jarfile="${build.lib}/appclient-simpleresource-client.jar">
+ <manifest>
+ <attribute name="Main-Class" value="org.jboss.ejb3.test.appclient.client.SimpleResourceClient"/>
+ </manifest>
+ <zipfileset prefix="META-INF" dir="${resources}/test/appclient/simpleresource">
+ <include name="application-client.xml"/>
+ </zipfileset>
+ <fileset dir="${build.classes}">
+ <include name="org/jboss/ejb3/test/appclient/client/SimpleResourceClient.class"/>
+ </fileset>
+ </jar>
</target>
<target name="asynchronous"
Added: trunk/ejb3/src/main/org/jboss/ejb3/deployers/AppClientParsingDeployer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/deployers/AppClientParsingDeployer.java 2006-11-02 13:04:21 UTC (rev 58007)
+++ trunk/ejb3/src/main/org/jboss/ejb3/deployers/AppClientParsingDeployer.java 2006-11-02 14:14:58 UTC (rev 58008)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.deployers;
+
+import org.jboss.deployers.plugins.deployers.helpers.ObjectModelFactoryDeployer;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentUnit;
+import org.jboss.ejb3.metamodel.ApplicationClientDD;
+import org.jboss.ejb3.metamodel.ApplicationClientDDObjectFactory;
+import org.jboss.xb.binding.ObjectModelFactory;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class AppClientParsingDeployer extends ObjectModelFactoryDeployer<ApplicationClientDD>
+{
+ private String appClientXmlPath = "application-client.xml";
+
+ public AppClientParsingDeployer()
+ {
+ super(ApplicationClientDD.class);
+ }
+
+ @Override
+ protected ObjectModelFactory getObjectModelFactory(ApplicationClientDD root)
+ {
+ return new ApplicationClientDDObjectFactory();
+ }
+
+ @Override
+ public void deploy(DeploymentUnit unit) throws DeploymentException
+ {
+ createMetaData(unit, appClientXmlPath, null);
+ }
+}
Added: trunk/ejb3/src/main/org/jboss/ejb3/deployers/Ejb3ClientDeployer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/deployers/Ejb3ClientDeployer.java 2006-11-02 13:04:21 UTC (rev 58007)
+++ trunk/ejb3/src/main/org/jboss/ejb3/deployers/Ejb3ClientDeployer.java 2006-11-02 14:14:58 UTC (rev 58008)
@@ -0,0 +1,228 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.deployers;
+
+import java.io.InputStream;
+import java.util.jar.Attributes;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+
+import javax.management.MBeanServer;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NameNotFoundException;
+import javax.naming.NamingException;
+
+import org.jboss.deployers.plugins.deployers.helpers.AbstractSimpleRealDeployer;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentUnit;
+import org.jboss.ejb3.KernelAbstraction;
+import org.jboss.ejb3.MCKernelAbstraction;
+import org.jboss.ejb3.clientmodule.ClientENCInjectionContainer;
+import org.jboss.ejb3.metamodel.ApplicationClientDD;
+import org.jboss.kernel.Kernel;
+import org.jboss.logging.Logger;
+import org.jboss.naming.Util;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * Deploys a client application jar.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class Ejb3ClientDeployer extends AbstractSimpleRealDeployer<ApplicationClientDD>
+{
+ private static final Logger log = Logger.getLogger(Ejb3ClientDeployer.class);
+
+ private Kernel kernel;
+ private MBeanServer server;
+
+ public Ejb3ClientDeployer()
+ {
+ super(ApplicationClientDD.class);
+ }
+
+ @Override
+ public void deploy(DeploymentUnit unit, ApplicationClientDD metaData) throws DeploymentException
+ {
+ log.info("deploy " + unit.getName());
+
+ String appClientName = getJndiName(unit, metaData);
+
+ try
+ {
+ // I create the namespace here, because I destroy it in undeploy
+ InitialContext iniCtx = new InitialContext();
+ Context encCtx = Util.createSubcontext(iniCtx, appClientName);
+ log.info("Creating client ENC binding under: " + appClientName);
+
+ String mainClassName = getMainClassName(unit, true);
+
+ Class<?> mainClass = loadClass(unit, mainClassName);
+
+ ClientENCInjectionContainer container = new ClientENCInjectionContainer(unit, metaData, mainClass, appClientName, unit.getClassLoader(), encCtx);
+
+ //di.deployedObject = container.getObjectName();
+ unit.addAttachment(ClientENCInjectionContainer.class, container);
+ getKernelAbstraction().install(container.getObjectName().getCanonicalName(), container.getDependencyPolicy(), container);
+ }
+ catch(Exception e)
+ {
+ log.error("Could not deploy " + unit.getName(), e);
+ undeploy(unit, metaData);
+ throw new DeploymentException("Could not deploy " + unit.getName(), e);
+ }
+ }
+
+ /**
+ * If there is no deployment descriptor, or it doesn't specify a JNDI name, then we make up one.
+ * We use the basename from di.shortName.
+ *
+ * @param di
+ * @param dd
+ * @return a good JNDI name
+ */
+ private String getJndiName(DeploymentUnit unit, ApplicationClientDD dd)
+ {
+ String jndiName = dd.getJndiName();
+ if(jndiName != null)
+ return jndiName;
+
+ String shortName = unit.getDeploymentContext().getRoot().getName();
+ if(shortName.endsWith(".jar/"))
+ jndiName = shortName.substring(0, shortName.length() - 5);
+ else if(shortName.endsWith(".jar"))
+ jndiName = shortName.substring(0, shortName.length() - 4);
+ else
+ throw new IllegalStateException("Expected either '.jar' or '.jar/' at the end of " + shortName);
+
+ return jndiName;
+ }
+
+// public Kernel getKernel()
+// {
+// return kernel;
+// }
+
+ private KernelAbstraction getKernelAbstraction()
+ {
+ return new MCKernelAbstraction(kernel, server);
+ }
+
+ protected String getMainClassName(DeploymentUnit unit, boolean fail) throws Exception
+ {
+ VirtualFile file = unit.getMetaDataFile("MANIFEST.MF");
+ log.trace("parsing " + file);
+
+ if(file == null)
+ {
+ if(fail)
+ throw new DeploymentException("Can't find " + JarFile.MANIFEST_NAME);
+ else
+ return null;
+ }
+ try
+ {
+ InputStream is = file.openStream();
+ 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)
+ {
+ if(fail)
+ throw new Exception("Main-Class is null");
+ else
+ return null;
+ }
+
+ return mainClassName;
+ }
+ finally
+ {
+ file.close();
+ }
+ }
+
+ private Class<?> loadClass(DeploymentUnit unit, String className) throws ClassNotFoundException
+ {
+ ClassLoader old = Thread.currentThread().getContextClassLoader();
+ try
+ {
+ Thread.currentThread().setContextClassLoader(unit.getClassLoader());
+ return Thread.currentThread().getContextClassLoader().loadClass(className);
+ }
+ finally
+ {
+ Thread.currentThread().setContextClassLoader(old);
+ }
+ }
+
+ public void setKernel(Kernel kernel)
+ {
+ this.kernel = kernel;
+ }
+
+ public void setMbeanServer(MBeanServer server)
+ {
+ this.server = server;
+ }
+
+ @Override
+ public void undeploy(DeploymentUnit unit, ApplicationClientDD metaData)
+ {
+ log.info("undeploy " + unit.getName());
+
+ ClientENCInjectionContainer container = unit.getAttachment(ClientENCInjectionContainer.class);
+ if(container != null)
+ getKernelAbstraction().uninstall(container.getObjectName().getCanonicalName());
+
+ String jndiName = getJndiName(unit, metaData);
+ log.info("Removing client ENC from: " + jndiName);
+ try
+ {
+ InitialContext iniCtx = new InitialContext();
+ Util.unbind(iniCtx, jndiName);
+ }
+ catch(NameNotFoundException e)
+ {
+ // make sure stop doesn't fail for no reason
+ log.debug("Could not find client ENC");
+ }
+ catch (NamingException e)
+ {
+ log.error("Failed to remove client ENC", e);
+ }
+ }
+
+}
Added: trunk/ejb3/src/main/org/jboss/ejb3/deployers/JBossClientParsingDeployer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/deployers/JBossClientParsingDeployer.java 2006-11-02 13:04:21 UTC (rev 58007)
+++ trunk/ejb3/src/main/org/jboss/ejb3/deployers/JBossClientParsingDeployer.java 2006-11-02 14:14:58 UTC (rev 58008)
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.deployers;
+
+import org.jboss.deployers.plugins.deployers.helpers.ObjectModelFactoryDeployer;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentUnit;
+import org.jboss.ejb3.metamodel.ApplicationClientDD;
+import org.jboss.ejb3.metamodel.JBossClientDDObjectFactory;
+import org.jboss.xb.binding.ObjectModelFactory;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class JBossClientParsingDeployer extends ObjectModelFactoryDeployer<ApplicationClientDD>
+{
+ private String jbossClientXmlPath = "jboss-client.xml";
+
+ public JBossClientParsingDeployer()
+ {
+ super(ApplicationClientDD.class);
+ }
+
+ @Override
+ protected boolean allowsReparse()
+ {
+ return true;
+ }
+
+ @Override
+ public int getRelativeOrder()
+ {
+ return PARSER_DEPLOYER + 1;
+ }
+
+ @Override
+ protected ObjectModelFactory getObjectModelFactory(ApplicationClientDD root)
+ {
+ return new JBossClientDDObjectFactory(root);
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.deployers.plugins.deployer.AbstractSimpleDeployer#deploy(org.jboss.deployers.spi.deployer.DeploymentUnit)
+ */
+ @Override
+ public void deploy(DeploymentUnit unit) throws DeploymentException
+ {
+ log.info("deploy " + unit.getName());
+ createMetaData(unit, jbossClientXmlPath, null);
+ }
+
+}
Modified: trunk/ejb3/src/main/org/jboss/ejb3/metamodel/ApplicationClientDDObjectFactory.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/metamodel/ApplicationClientDDObjectFactory.java 2006-11-02 13:04:21 UTC (rev 58007)
+++ trunk/ejb3/src/main/org/jboss/ejb3/metamodel/ApplicationClientDDObjectFactory.java 2006-11-02 14:14:58 UTC (rev 58008)
@@ -46,7 +46,8 @@
{
private static final Logger log = Logger.getLogger(ApplicationClientDDObjectFactory.class);
- private ApplicationClientDDObjectFactory()
+ // made public for the parsing deployer
+ public ApplicationClientDDObjectFactory()
{
}
Modified: trunk/ejb3/src/main/org/jboss/ejb3/metamodel/JBossClientDDObjectFactory.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/metamodel/JBossClientDDObjectFactory.java 2006-11-02 13:04:21 UTC (rev 58007)
+++ trunk/ejb3/src/main/org/jboss/ejb3/metamodel/JBossClientDDObjectFactory.java 2006-11-02 14:14:58 UTC (rev 58008)
@@ -76,7 +76,7 @@
return dd;
}
- private JBossClientDDObjectFactory(ApplicationClientDD dd)
+ public JBossClientDDObjectFactory(ApplicationClientDD dd)
{
this.dd = dd;
}
Modified: trunk/ejb3/src/resources/META-INF/ejb3-deployers-beans.xml
===================================================================
--- trunk/ejb3/src/resources/META-INF/ejb3-deployers-beans.xml 2006-11-02 13:04:21 UTC (rev 58007)
+++ trunk/ejb3/src/resources/META-INF/ejb3-deployers-beans.xml 2006-11-02 14:14:58 UTC (rev 58008)
@@ -120,4 +120,51 @@
</uninstall>
<depends>AspectDeployer</depends>
</bean>
+
+ <bean name="AppClientParsingDeployer" class="org.jboss.ejb3.deployers.AppClientParsingDeployer">
+ <install bean="MainDeployer" method="addDeployer">
+ <parameter>
+ <this/>
+ </parameter>
+ </install>
+ <uninstall bean="MainDeployer" method="removeDeployer">
+ <parameter>
+ <this/>
+ </parameter>
+ </uninstall>
+ <!-- TODO: check depends -->
+ <depends>AspectDeployer</depends>
+ </bean>
+
+ <bean name="JBossClientParsingDeployer" class="org.jboss.ejb3.deployers.JBossClientParsingDeployer">
+ <install bean="MainDeployer" method="addDeployer">
+ <parameter>
+ <this/>
+ </parameter>
+ </install>
+ <uninstall bean="MainDeployer" method="removeDeployer">
+ <parameter>
+ <this/>
+ </parameter>
+ </uninstall>
+ <depends>AppClientParsingDeployer</depends>
+ </bean>
+
+ <bean name="Ejb3ClientDeployer" class="org.jboss.ejb3.deployers.Ejb3ClientDeployer">
+ <install bean="MainDeployer" method="addDeployer">
+ <parameter>
+ <this/>
+ </parameter>
+ </install>
+ <uninstall bean="MainDeployer" method="removeDeployer">
+ <parameter>
+ <this/>
+ </parameter>
+ </uninstall>
+ <property name="kernel"><inject bean="jboss.kernel:service=Kernel"/></property>
+ <property name="mbeanServer"><inject bean="JMXKernel" property="mbeanServer"/></property>
+ <!-- TODO: check depends -->
+ <depends>AspectDeployer</depends>
+ <depends>JBossClientParsingDeployer</depends>
+ </bean>
</deployment>
Added: trunk/ejb3/src/resources/test/appclient/simpleresource/application-client.xml
===================================================================
--- trunk/ejb3/src/resources/test/appclient/simpleresource/application-client.xml 2006-11-02 13:04:21 UTC (rev 58007)
+++ trunk/ejb3/src/resources/test/appclient/simpleresource/application-client.xml 2006-11-02 14:14:58 UTC (rev 58008)
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<application-client xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
+ http://java.sun.com/xml/ns/javaee/application-client_5.xsd"
+ version="5">
+ <display-name>appclient-simpleresource-client</display-name>
+ <description>application client unit test</description>
+
+ <env-entry>
+ <env-entry-name>msg</env-entry-name>
+ <env-entry-type>java.lang.String</env-entry-type>
+ <env-entry-value>Hello world</env-entry-value>
+ </env-entry>
+</application-client>
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/appclient/client/SimpleResourceClient.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/appclient/client/SimpleResourceClient.java 2006-11-02 13:04:21 UTC (rev 58007)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/appclient/client/SimpleResourceClient.java 2006-11-02 14:14:58 UTC (rev 58008)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.test.appclient.client;
+
+import javax.annotation.Resource;
+
+/**
+ * This client only uses a simple resource.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class SimpleResourceClient
+{
+ @Resource(name="msg")
+ private static String msg;
+
+ /**
+ * @param args
+ */
+ public static void main(String[] args)
+ {
+ if(msg == null)
+ throw new NullPointerException("msg is null");
+
+ System.out.println("msg = " + msg);
+ }
+
+}
Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/appclient/unit/AppClientUnitTestCase.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/appclient/unit/AppClientUnitTestCase.java 2006-11-02 13:04:21 UTC (rev 58007)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/appclient/unit/AppClientUnitTestCase.java 2006-11-02 14:14:58 UTC (rev 58008)
@@ -64,6 +64,7 @@
public static Test suite() throws Exception
{
- return getDeploySetup(AppClientUnitTestCase.class, "appclient-test.ear");
+ //return getDeploySetup(AppClientUnitTestCase.class, "appclient-test.ear");
+ return getDeploySetup(AppClientUnitTestCase.class, "appclient-test.jar,appclient-test-client.jar");
}
}
Added: trunk/ejb3/src/test/org/jboss/ejb3/test/appclient/unit/SimpleResourceUnitTestCase.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/appclient/unit/SimpleResourceUnitTestCase.java 2006-11-02 13:04:21 UTC (rev 58007)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/appclient/unit/SimpleResourceUnitTestCase.java 2006-11-02 14:14:58 UTC (rev 58008)
@@ -0,0 +1,115 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.test.appclient.unit;
+
+import java.net.URL;
+
+import javax.naming.Context;
+import javax.naming.NameNotFoundException;
+
+import junit.framework.Test;
+
+import org.jboss.ejb3.client.ClientLauncher;
+import org.jboss.ejb3.metamodel.ApplicationClientDD;
+import org.jboss.ejb3.test.appclient.client.SimpleResourceClient;
+import org.jboss.test.JBossTestCase;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class SimpleResourceUnitTestCase extends JBossTestCase
+{
+
+ public SimpleResourceUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Test to see if the client deployer has setup enc env correctly.
+ *
+ * @throws Exception
+ */
+ public void testJNDI() throws Exception
+ {
+ String clientName = "appclient-simpleresource-client";
+ Context ctx = getInitialContext();
+ try
+ {
+ ctx = (Context) ctx.lookup(clientName);
+ }
+ catch(NameNotFoundException e)
+ {
+ fail(clientName + " not bound");
+ }
+
+ try
+ {
+ String value = (String) ctx.lookup("env/msg");
+ assertEquals("Hello world", value);
+ }
+ catch(NameNotFoundException e)
+ {
+ fail("env/msg not bound");
+ }
+
+ // TODO: shouldn't org.jboss.ejb3.test.appclient.client.SimpleResourceClient/msg be bound?
+
+// NamingEnumeration<NameClassPair> e = ctx.list("env");
+// while(e.hasMore())
+// {
+// NameClassPair ncp = e.next();
+// System.out.println(ncp.getName());
+// }
+// try
+// {
+//
+// }
+// catch(NameNotFoundException e)
+// {
+//
+// }
+ }
+
+ public void testClientLauncher() throws Exception
+ {
+ URL url = Thread.currentThread().getContextClassLoader().getResource("appclient/simpleresource/application-client.xml");
+ //URL jbossClientURL = Thread.currentThread().getContextClassLoader().getResource("appclient/jboss-client.xml");
+ URL jbossClientURL = null;
+ ApplicationClientDD xml = ClientLauncher.loadXML(url, jbossClientURL);
+
+ String mainClassName = SimpleResourceClient.class.getName();
+ String applicationClientName = "appclient-simpleresource-client"; // must match JNDI name in jboss-client.xml or display-name in application-client.xml
+ String args[] = { };
+
+ ClientLauncher.launch(xml, mainClassName, applicationClientName, args);
+ }
+
+ public static Test suite() throws Exception
+ {
+ return getDeploySetup(SimpleResourceUnitTestCase.class, "appclient-simpleresource-client.jar");
+ }
+
+}
More information about the jboss-cvs-commits
mailing list