[jboss-cvs] JBossAS SVN: r81053 - in trunk/ejb3: imports and 15 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Nov 14 09:59:40 EST 2008
Author: dimitris at jboss.org
Date: 2008-11-14 09:59:40 -0500 (Fri, 14 Nov 2008)
New Revision: 81053
Modified:
trunk/ejb3/imports/build-simple.xml
trunk/ejb3/pom.xml
trunk/ejb3/src/main/org/jboss/as/javaee/SimpleJavaEEModuleInformer.java
trunk/ejb3/src/main/org/jboss/as/jpa/resolvers/JBossASDataSourceDependencyResolver.java
trunk/ejb3/src/main/org/jboss/ejb3/client/ClientContainer.java
trunk/ejb3/src/main/org/jboss/ejb3/client/ClientEJBHandler.java
trunk/ejb3/src/main/org/jboss/ejb3/client/ClientJavaEEComponent.java
trunk/ejb3/src/main/org/jboss/ejb3/client/ClientLauncher.java
trunk/ejb3/src/main/org/jboss/ejb3/client/ClientResourceHandler.java
trunk/ejb3/src/main/org/jboss/ejb3/client/JndiDependencyItem.java
trunk/ejb3/src/main/org/jboss/ejb3/client/JndiDependencyValueMetaData.java
trunk/ejb3/src/main/org/jboss/ejb3/client/JndiPropertyInjector.java
trunk/ejb3/src/main/org/jboss/ejb3/client/NoopDependencyPolicy.java
trunk/ejb3/src/main/org/jboss/ejb3/client/URLInjectorFactory.java
trunk/ejb3/src/main/org/jboss/ejb3/client/URLPropertyInjector.java
trunk/ejb3/src/main/org/jboss/ejb3/client/Utils.java
trunk/ejb3/src/main/org/jboss/ejb3/client/injection/ClientPersistenceUnitHandler.java
trunk/ejb3/src/main/org/jboss/ejb3/client/package.html
trunk/ejb3/src/main/org/jboss/ejb3/clientmodule/ClientENCInjectionContainer.java
trunk/ejb3/src/main/org/jboss/ejb3/clientmodule/ClientEjbResolver.java
trunk/ejb3/src/main/org/jboss/ejb3/clientmodule/EJBRemoteHandler.java
trunk/ejb3/src/main/org/jboss/ejb3/clientmodule/RemotePersistenceUnitHandler.java
trunk/ejb3/src/main/org/jboss/ejb3/clientmodule/RemotePuEncInjector.java
trunk/ejb3/src/main/org/jboss/ejb3/clientmodule/ResourceHandler.java
trunk/ejb3/src/main/org/jboss/ejb3/deployers/AppClientParsingDeployer.java
trunk/ejb3/src/main/org/jboss/ejb3/deployers/AppClientScanningDeployer.java
trunk/ejb3/src/main/org/jboss/ejb3/deployers/EJBRegistrationDeployer.java
trunk/ejb3/src/main/org/jboss/ejb3/deployers/Ejb3ClientDeployer.java
trunk/ejb3/src/main/org/jboss/ejb3/deployers/Ejb3JBoss5Deployment.java
trunk/ejb3/src/main/org/jboss/ejb3/deployers/JBoss5DeploymentScope.java
trunk/ejb3/src/main/org/jboss/ejb3/deployers/JBoss5DeploymentUnit.java
trunk/ejb3/src/main/org/jboss/ejb3/deployers/JBossASDepdencyPolicy.java
trunk/ejb3/src/main/org/jboss/ejb3/deployers/JBossASKernel.java
trunk/ejb3/src/main/org/jboss/ejb3/deployers/JBossClientParsingDeployer.java
trunk/ejb3/src/main/org/jboss/ejb3/deployers/MergedJBossClientMetaDataDeployer.java
trunk/ejb3/src/resources/test/appclient/application-client.xml
trunk/ejb3/src/resources/test/appclient/application.xml
trunk/ejb3/src/resources/test/appclient/jboss-client.xml
trunk/ejb3/src/resources/test/appclient/simpleresource/application-client.xml
trunk/ejb3/src/resources/test/iiop/custom.jndi.properties
trunk/ejb3/src/resources/test/iiop/jndi.properties
trunk/ejb3/src/test/org/jboss/ejb3/test/CustomJNDIJBossTestCase.java
trunk/ejb3/src/test/org/jboss/ejb3/test/CustomJNDIJBossTestServices.java
trunk/ejb3/src/test/org/jboss/ejb3/test/CustomJNDIJBossTestSetup.java
trunk/ejb3/src/test/org/jboss/ejb3/test/appclient/HelloWorldBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/appclient/HelloWorldService.java
trunk/ejb3/src/test/org/jboss/ejb3/test/appclient/MessageReplierBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/appclient/client/HelloWorldClient.java
trunk/ejb3/src/test/org/jboss/ejb3/test/appclient/client/SimpleResourceClient.java
trunk/ejb3/src/test/org/jboss/ejb3/test/appclient/unit/AppClientUnitTestCase.java
trunk/ejb3/src/test/org/jboss/ejb3/test/appclient/unit/SimpleResourceEarUnitTestCase.java
trunk/ejb3/src/test/org/jboss/ejb3/test/appclient/unit/SimpleResourceUnitTestCase.java
trunk/ejb3/src/test/org/jboss/ejb3/test/common/unit/DBSetup.java
trunk/ejb3/src/test/org/jboss/ejb3/test/iiop/HomedStatelessBean.java
trunk/ejb3/src/test/org/jboss/ejb3/test/iiop/HomedStatelessHome.java
trunk/ejb3/src/test/org/jboss/ejb3/test/iiop/MyServiceBean.java
Log:
fix svn properties
Property changes on: trunk/ejb3/imports/build-simple.xml
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: trunk/ejb3/pom.xml
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/ejb3/src/main/org/jboss/as/javaee/SimpleJavaEEModuleInformer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/as/javaee/SimpleJavaEEModuleInformer.java 2008-11-14 14:58:15 UTC (rev 81052)
+++ trunk/ejb3/src/main/org/jboss/as/javaee/SimpleJavaEEModuleInformer.java 2008-11-14 14:59:40 UTC (rev 81053)
@@ -1,82 +1,82 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.as.javaee;
-
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.jpa.javaee.JavaEEModuleInformer;
-import org.jboss.metadata.client.jboss.JBossClientMetaData;
-import org.jboss.metadata.ear.jboss.JBossAppMetaData;
-import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
-import org.jboss.metadata.ejb.jboss.JBossEntityBeanMetaData;
-import org.jboss.metadata.ejb.jboss.JBossMetaData;
-import org.jboss.metadata.web.jboss.JBossWebMetaData;
-
-/**
- * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
- * @version $Revision: $
- */
-public class SimpleJavaEEModuleInformer implements JavaEEModuleInformer
-{
- public String getApplicationName(DeploymentUnit unit)
- {
- DeploymentUnit topLevel = unit.getTopLevel();
- if(topLevel.isAttachmentPresent(JBossAppMetaData.class))
- return topLevel.getSimpleName();
- return null;
- }
-
- public String getModulePath(DeploymentUnit unit)
- {
- return unit.getRelativePath();
- }
-
- public ModuleType getModuleType(DeploymentUnit unit)
- {
- if(unit.isAttachmentPresent(JBossClientMetaData.class))
- return ModuleType.APP_CLIENT;
- if(unit.isAttachmentPresent(JBossMetaData.class) && isReallyAnEjbDeployment(unit))
- return ModuleType.EJB;
- if(unit.isAttachmentPresent(JBossWebMetaData.class))
- return ModuleType.WEB;
- return ModuleType.JAVA;
- }
-
- /*
- * Some hacks to counter problems.
- */
- private boolean isReallyAnEjbDeployment(DeploymentUnit unit)
- {
- JBossMetaData metaData = unit.getAttachment(JBossMetaData.class);
- // JBMETA-69
- if(metaData.getEnterpriseBeans() == null || metaData.getEnterpriseBeans().size() == 0)
- return false;
- // JBMETA-70
- // The chance of a persistence unit being defined with couple of EJB entity beans is
- // pretty slim.
- for(JBossEnterpriseBeanMetaData bean : metaData.getEnterpriseBeans())
- {
- if(!(bean instanceof JBossEntityBeanMetaData))
- return true;
- }
- return false;
- }
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.as.javaee;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.jpa.javaee.JavaEEModuleInformer;
+import org.jboss.metadata.client.jboss.JBossClientMetaData;
+import org.jboss.metadata.ear.jboss.JBossAppMetaData;
+import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
+import org.jboss.metadata.ejb.jboss.JBossEntityBeanMetaData;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
+import org.jboss.metadata.web.jboss.JBossWebMetaData;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class SimpleJavaEEModuleInformer implements JavaEEModuleInformer
+{
+ public String getApplicationName(DeploymentUnit unit)
+ {
+ DeploymentUnit topLevel = unit.getTopLevel();
+ if(topLevel.isAttachmentPresent(JBossAppMetaData.class))
+ return topLevel.getSimpleName();
+ return null;
+ }
+
+ public String getModulePath(DeploymentUnit unit)
+ {
+ return unit.getRelativePath();
+ }
+
+ public ModuleType getModuleType(DeploymentUnit unit)
+ {
+ if(unit.isAttachmentPresent(JBossClientMetaData.class))
+ return ModuleType.APP_CLIENT;
+ if(unit.isAttachmentPresent(JBossMetaData.class) && isReallyAnEjbDeployment(unit))
+ return ModuleType.EJB;
+ if(unit.isAttachmentPresent(JBossWebMetaData.class))
+ return ModuleType.WEB;
+ return ModuleType.JAVA;
+ }
+
+ /*
+ * Some hacks to counter problems.
+ */
+ private boolean isReallyAnEjbDeployment(DeploymentUnit unit)
+ {
+ JBossMetaData metaData = unit.getAttachment(JBossMetaData.class);
+ // JBMETA-69
+ if(metaData.getEnterpriseBeans() == null || metaData.getEnterpriseBeans().size() == 0)
+ return false;
+ // JBMETA-70
+ // The chance of a persistence unit being defined with couple of EJB entity beans is
+ // pretty slim.
+ for(JBossEnterpriseBeanMetaData bean : metaData.getEnterpriseBeans())
+ {
+ if(!(bean instanceof JBossEntityBeanMetaData))
+ return true;
+ }
+ return false;
+ }
+}
Property changes on: trunk/ejb3/src/main/org/jboss/as/javaee/SimpleJavaEEModuleInformer.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/ejb3/src/main/org/jboss/as/jpa/resolvers/JBossASDataSourceDependencyResolver.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/as/jpa/resolvers/JBossASDataSourceDependencyResolver.java 2008-11-14 14:58:15 UTC (rev 81052)
+++ trunk/ejb3/src/main/org/jboss/as/jpa/resolvers/JBossASDataSourceDependencyResolver.java 2008-11-14 14:59:40 UTC (rev 81053)
@@ -1,37 +1,37 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.as.jpa.resolvers;
-
-import org.jboss.ejb3.deployers.JBossASDepdencyPolicy;
-import org.jboss.jpa.resolvers.DataSourceDependencyResolver;
-
-/**
- * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
- * @version $Revision: $
- */
-public class JBossASDataSourceDependencyResolver implements DataSourceDependencyResolver
-{
- public String resolveDataSourceSupplier(String jndiName)
- {
- return JBossASDepdencyPolicy.createDataSourceKernelName(jndiName);
- }
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.as.jpa.resolvers;
+
+import org.jboss.ejb3.deployers.JBossASDepdencyPolicy;
+import org.jboss.jpa.resolvers.DataSourceDependencyResolver;
+
+/**
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class JBossASDataSourceDependencyResolver implements DataSourceDependencyResolver
+{
+ public String resolveDataSourceSupplier(String jndiName)
+ {
+ return JBossASDepdencyPolicy.createDataSourceKernelName(jndiName);
+ }
+}
Property changes on: trunk/ejb3/src/main/org/jboss/as/jpa/resolvers/JBossASDataSourceDependencyResolver.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/ejb3/src/main/org/jboss/ejb3/client/ClientContainer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/client/ClientContainer.java 2008-11-14 14:58:15 UTC (rev 81052)
+++ trunk/ejb3/src/main/org/jboss/ejb3/client/ClientContainer.java 2008-11-14 14:59:40 UTC (rev 81053)
@@ -1,558 +1,558 @@
-/*
- * 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.io.PrintWriter;
-import java.io.StringWriter;
-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.lang.reflect.Modifier;
-import java.lang.reflect.Proxy;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import javax.naming.Context;
-import javax.naming.LinkRef;
-import javax.naming.NameClassPair;
-import javax.naming.NameNotFoundException;
-import javax.naming.NamingEnumeration;
-import javax.naming.NamingException;
-
-import org.jboss.ejb3.Container;
-import org.jboss.ejb3.DependencyPolicy;
-import org.jboss.ejb3.InitialContextFactory;
-import org.jboss.ejb3.client.injection.ClientPersistenceUnitHandler;
-import org.jboss.injection.DependsHandler;
-import org.jboss.injection.EncInjector;
-import org.jboss.injection.InjectionContainer;
-import org.jboss.injection.InjectionHandler;
-import org.jboss.injection.Injector;
-import org.jboss.injection.WebServiceRefHandler;
-import org.jboss.logging.Logger;
-import org.jboss.metadata.client.jboss.JBossClientMetaData;
-import org.jboss.metadata.javaee.spec.LifecycleCallbacksMetaData;
-import org.jboss.metadata.javaee.spec.RemoteEnvironment;
-import org.jboss.util.NotImplementedException;
-import org.jboss.virtual.VirtualFile;
-
-/**
- * Injection of the application client main class is handled from here.
- *
- * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
-public class ClientContainer implements InjectionContainer
-{
- private static final Logger log = Logger.getLogger(ClientContainer.class);
- private static final String VERSION = "$Revision$";
- private static ThreadLocal<Properties> clientJndiEnv = new ThreadLocal<Properties>();
-
- private Class<?> mainClass;
- private JBossClientMetaData xml;
- private String applicationClientName;
-
- // for performance there is an array.
- private List<Injector> injectors = new ArrayList<Injector>();
- private Context enc;
- private DependencyPolicy dependsPolicy;
-
- private List<Method> postConstructs = new ArrayList<Method>();
-
- public static Properties getJndiEnv()
- {
- return clientJndiEnv.get();
- }
-
- public ClientContainer(JBossClientMetaData xml, Class<?> mainClass, String applicationClientName)
- throws Exception
- {
- this(xml, mainClass, applicationClientName, null);
- }
- public ClientContainer(JBossClientMetaData xml, Class<?> mainClass, String applicationClientName, Properties jndiEnv)
- throws Exception
- {
- log.info("ClientContainer(version="+VERSION+")");
- log.info("DependencyPolicy.CS: "+DependencyPolicy.class.getProtectionDomain().getCodeSource());
- log.info("ClientContainer.CS: "+getClass().getProtectionDomain().getCodeSource());
- ClassLoader mainClassLoader = mainClass.getClassLoader();
- log.info("mainClass.ClassLoader: "+mainClassLoader);
- clientJndiEnv.set(jndiEnv);
- this.xml = xml;
- this.mainClass = mainClass;
- this.applicationClientName = applicationClientName;
- ClientJavaEEComponent client = new ClientJavaEEComponent(applicationClientName);
- this.dependsPolicy = new NoopDependencyPolicy(client);
-
- URL jndiPropertiesURL = mainClassLoader.getResource("jndi.properties");
- log.info("mainClassLoader jndi.properties: "+jndiPropertiesURL);
- Context ctx = InitialContextFactory.getInitialContext(jndiEnv);
- enc = (Context) ctx.lookup(applicationClientName);
- StringBuffer encInfo = new StringBuffer("Client ENC("+applicationClientName+"):\n");
- list(enc, "", encInfo, true);
- log.info(encInfo.toString());
-
- //encEnv = (Context) enc.lookup("env");
-// enc = ThreadLocalENCFactory.create(ctx);
-// encEnv = Util.createSubcontext(enc, "env");
-
- processMetadata(null);
-
- for(Injector injector : injectors)
- {
- log.debug("injector: " + injector);
- injector.inject((Object) null);
- }
-
- postConstruct();
- }
-
- /* (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");
- return Thread.currentThread().getContextClassLoader();
- }
-
- /* (non-Javadoc)
- * @see org.jboss.injection.InjectionContainer#getDependencyPolicy()
- */
- public DependencyPolicy getDependencyPolicy()
- {
- return dependsPolicy;
- }
-
- /* (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 NotImplementedException();
- //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#getEncInjections()
- */
- public Map<String, Map<AccessibleObject, Injector>> getEncInjections()
- {
- throw new IllegalStateException("ENC setup happens on the server");
- }
-
- /* (non-Javadoc)
- * @see org.jboss.injection.InjectionContainer#getEncInjectors()
- */
- public Map<String, EncInjector> getEncInjectors()
- {
- throw new IllegalStateException("ENC setup happens on the server");
- }
-
- /* (non-Javadoc)
- * @see org.jboss.injection.InjectionContainer#getEnvironmentRefGroup()
- */
- public RemoteEnvironment getEnvironmentRefGroup()
- {
- return xml;
- }
-
- /* (non-Javadoc)
- * @see org.jboss.injection.InjectionContainer#getIdentifier()
- */
- public String getIdentifier()
- {
-// throw new NotImplementedException;
- // FIXME: return the real identifier
- //return "client-identifier";
- return applicationClientName;
- }
-
- /* (non-Javadoc)
- * @see org.jboss.injection.InjectionContainer#getInjectors()
- */
- public List<Injector> getInjectors()
- {
- return injectors;
- }
-
- public Class<?> getMainClass()
- {
- return mainClass;
- }
-
- public boolean hasJNDIBinding(String jndiName)
- {
- return false;
- }
-
- public void invokeMain(String args[]) throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException
- {
- Class<?> parameterTypes[] = { args.getClass() };
- Method method = mainClass.getDeclaredMethod("main", parameterTypes);
- try
- {
- log.info("Invoking main: "+method);
- method.invoke(null, (Object) args);
- log.info("Successfully invoked main");
- }
- catch(Throwable e)
- {
- e.printStackTrace();
- log.error("Invocation of client main failed", e);
- }
- }
-
- /**
- * Call post construct methods.
- * @throws IllegalAccessException
- * @throws InstantiationException
- * @throws InvocationTargetException
- * @throws IllegalArgumentException
- *
- */
- private void postConstruct() throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException
- {
- log.info("postConstructs = " + postConstructs);
- for(Method method : postConstructs)
- {
- method.setAccessible(true);
- Object instance;
- if(Modifier.isStatic(method.getModifiers()))
- instance = null;
- else
- instance = method.getDeclaringClass().newInstance();
- Object args[] = null;
- method.invoke(instance, args);
- }
- }
-
- private void processMetadata(DependencyPolicy dependencyPolicy) throws Exception
- {
- log.debug("processMetadata");
- processPostConstructs();
-
- // TODO: check which handlers a client container should support
- Collection<InjectionHandler<RemoteEnvironment>> handlers = new ArrayList<InjectionHandler<RemoteEnvironment>>();
- handlers.add(new ClientEJBHandler<RemoteEnvironment>());
- // This currently has no use in the ClientContainer, maybe in the future when running an mc
- handlers.add(new DependsHandler<RemoteEnvironment>());
- //handlers.add(new JndiInjectHandler<RemoteEnvironment>());
- handlers.add(new ClientPersistenceUnitHandler<RemoteEnvironment>());
- handlers.add(new ClientResourceHandler<RemoteEnvironment>(this.mainClass));
- handlers.add(new WebServiceRefHandler<RemoteEnvironment>());
-
- // 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<RemoteEnvironment> handler : handlers)
- handler.loadXml(xml, this);
-
- /*
- Map<AccessibleObject, Injector> tmp = InjectionUtil.processAnnotations(this, handlers, getMainClass());
- injectors.addAll(tmp.values());
- */
- }
- finally
- {
-// Thread.currentThread().setContextClassLoader(old);
- }
- }
-
- /**
- * Populate the list of the post construct callbacks ordered according to the spec rules defined in
- * 12.4.1 Multiple Callback Interceptor Methods for a Life Cycle Callback Event.
- *
- * @throws ClassNotFoundException
- * @throws NoSuchMethodException
- * @throws SecurityException
- *
- */
- private void processPostConstructs()
- throws ClassNotFoundException, SecurityException, NoSuchMethodException
- {
- LifecycleCallbacksMetaData callbacks = xml.getPostConstructs();
- if(callbacks == null || callbacks.isEmpty())
- return;
-
- List<Method> methods = callbacks.getOrderedCallbacks(mainClass);
- postConstructs.addAll(methods);
- }
-
- /* (non-Javadoc)
- * @see org.jboss.injection.InjectionContainer#resolveEjbContainer(java.lang.String, java.lang.Class)
- */
- public Container resolveEjbContainer(String link, Class businessIntf)
- {
- 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
- {
- return null;
- }
-
- public String resolveMessageDestination(String link)
- {
- // Resolving something here is a nop
- return null;
- }
-
- public VirtualFile getRootFile()
- {
- throw new NotImplementedException();
- }
-
- /**
- * Recursively display the naming context information into the buffer.
- *
- * @param ctx
- * @param indent
- * @param buffer
- * @param verbose
- */
- private static void list(Context ctx, String indent, StringBuffer buffer,
- boolean verbose)
- {
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- try
- {
- NamingEnumeration ne = ctx.list("");
- while (ne.hasMore())
- {
- NameClassPair pair = (NameClassPair) ne.next();
-
- String name = pair.getName();
- String className = pair.getClassName();
- boolean recursive = false;
- boolean isLinkRef = false;
- boolean isProxy = false;
- Class c = null;
- try
- {
- c = loader.loadClass(className);
-
- if (Context.class.isAssignableFrom(c))
- recursive = true;
- if (LinkRef.class.isAssignableFrom(c))
- isLinkRef = true;
-
- isProxy = Proxy.isProxyClass(c);
- }
- catch (ClassNotFoundException cnfe)
- {
- // If this is a $Proxy* class its a proxy
- if (className.startsWith("$Proxy"))
- {
- isProxy = true;
- // We have to get the class from the binding
- try
- {
- Object p = ctx.lookup(name);
- c = p.getClass();
- }
- catch (NamingException e)
- {
- Throwable t = e.getRootCause();
- if (t instanceof ClassNotFoundException)
- {
- // Get the class name from the exception msg
- String msg = t.getMessage();
- if (msg != null)
- {
- // Reset the class name to the CNFE class
- className = msg;
- }
- }
- }
- }
- }
-
- buffer.append(indent + " +- " + name);
-
- // Display reference targets
- if (isLinkRef)
- {
- // Get the
- try
- {
- Object obj = ctx.lookupLink(name);
-
- LinkRef link = (LinkRef) obj;
- buffer.append("[link -> ");
- buffer.append(link.getLinkName());
- buffer.append(']');
- }
- catch (Throwable t)
- {
- buffer.append("invalid]");
- }
- }
-
- // Display proxy interfaces
- if (isProxy)
- {
- buffer.append(" (proxy: " + pair.getClassName());
- if (c != null)
- {
- Class[] ifaces = c.getInterfaces();
- buffer.append(" implements ");
- for (int i = 0; i < ifaces.length; i++)
- {
- buffer.append(ifaces[i]);
- buffer.append(',');
- }
- buffer.setCharAt(buffer.length() - 1, ')');
- }
- else
- {
- buffer.append(" implements " + className + ")");
- }
- }
- else if (verbose)
- {
- buffer.append(" (class: " + pair.getClassName() + ")");
- }
-
- buffer.append('\n');
- if (recursive)
- {
- try
- {
- Object value = ctx.lookup(name);
- if (value instanceof Context)
- {
- Context subctx = (Context) value;
- list(subctx, indent + " | ", buffer, verbose);
- }
- else
- {
- buffer.append(indent + " | NonContext: " + value);
- buffer.append('\n');
- }
- }
- catch (Throwable t)
- {
- buffer.append("Failed to lookup: " + name + ", errmsg=" + t.getMessage());
- buffer.append('\n');
- }
- }
- }
- ne.close();
- }
- catch (NamingException ne)
- {
- buffer.append("error while listing context " + ctx.toString() + ": " + ne.toString(true));
- formatException(buffer, ne);
- }
- }
- private static void formatException(StringBuffer buffer, Throwable t)
- {
- StringWriter sw = new StringWriter();
- PrintWriter pw = new PrintWriter(sw);
- buffer.append("<pre>\n");
- t.printStackTrace(pw);
- buffer.append(sw.toString());
- buffer.append("</pre>\n");
- }
-}
+/*
+ * 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.io.PrintWriter;
+import java.io.StringWriter;
+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.lang.reflect.Modifier;
+import java.lang.reflect.Proxy;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.naming.Context;
+import javax.naming.LinkRef;
+import javax.naming.NameClassPair;
+import javax.naming.NameNotFoundException;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+
+import org.jboss.ejb3.Container;
+import org.jboss.ejb3.DependencyPolicy;
+import org.jboss.ejb3.InitialContextFactory;
+import org.jboss.ejb3.client.injection.ClientPersistenceUnitHandler;
+import org.jboss.injection.DependsHandler;
+import org.jboss.injection.EncInjector;
+import org.jboss.injection.InjectionContainer;
+import org.jboss.injection.InjectionHandler;
+import org.jboss.injection.Injector;
+import org.jboss.injection.WebServiceRefHandler;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.client.jboss.JBossClientMetaData;
+import org.jboss.metadata.javaee.spec.LifecycleCallbacksMetaData;
+import org.jboss.metadata.javaee.spec.RemoteEnvironment;
+import org.jboss.util.NotImplementedException;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * Injection of the application client main class is handled from here.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class ClientContainer implements InjectionContainer
+{
+ private static final Logger log = Logger.getLogger(ClientContainer.class);
+ private static final String VERSION = "$Revision$";
+ private static ThreadLocal<Properties> clientJndiEnv = new ThreadLocal<Properties>();
+
+ private Class<?> mainClass;
+ private JBossClientMetaData xml;
+ private String applicationClientName;
+
+ // for performance there is an array.
+ private List<Injector> injectors = new ArrayList<Injector>();
+ private Context enc;
+ private DependencyPolicy dependsPolicy;
+
+ private List<Method> postConstructs = new ArrayList<Method>();
+
+ public static Properties getJndiEnv()
+ {
+ return clientJndiEnv.get();
+ }
+
+ public ClientContainer(JBossClientMetaData xml, Class<?> mainClass, String applicationClientName)
+ throws Exception
+ {
+ this(xml, mainClass, applicationClientName, null);
+ }
+ public ClientContainer(JBossClientMetaData xml, Class<?> mainClass, String applicationClientName, Properties jndiEnv)
+ throws Exception
+ {
+ log.info("ClientContainer(version="+VERSION+")");
+ log.info("DependencyPolicy.CS: "+DependencyPolicy.class.getProtectionDomain().getCodeSource());
+ log.info("ClientContainer.CS: "+getClass().getProtectionDomain().getCodeSource());
+ ClassLoader mainClassLoader = mainClass.getClassLoader();
+ log.info("mainClass.ClassLoader: "+mainClassLoader);
+ clientJndiEnv.set(jndiEnv);
+ this.xml = xml;
+ this.mainClass = mainClass;
+ this.applicationClientName = applicationClientName;
+ ClientJavaEEComponent client = new ClientJavaEEComponent(applicationClientName);
+ this.dependsPolicy = new NoopDependencyPolicy(client);
+
+ URL jndiPropertiesURL = mainClassLoader.getResource("jndi.properties");
+ log.info("mainClassLoader jndi.properties: "+jndiPropertiesURL);
+ Context ctx = InitialContextFactory.getInitialContext(jndiEnv);
+ enc = (Context) ctx.lookup(applicationClientName);
+ StringBuffer encInfo = new StringBuffer("Client ENC("+applicationClientName+"):\n");
+ list(enc, "", encInfo, true);
+ log.info(encInfo.toString());
+
+ //encEnv = (Context) enc.lookup("env");
+// enc = ThreadLocalENCFactory.create(ctx);
+// encEnv = Util.createSubcontext(enc, "env");
+
+ processMetadata(null);
+
+ for(Injector injector : injectors)
+ {
+ log.debug("injector: " + injector);
+ injector.inject((Object) null);
+ }
+
+ postConstruct();
+ }
+
+ /* (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");
+ return Thread.currentThread().getContextClassLoader();
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.injection.InjectionContainer#getDependencyPolicy()
+ */
+ public DependencyPolicy getDependencyPolicy()
+ {
+ return dependsPolicy;
+ }
+
+ /* (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 NotImplementedException();
+ //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#getEncInjections()
+ */
+ public Map<String, Map<AccessibleObject, Injector>> getEncInjections()
+ {
+ throw new IllegalStateException("ENC setup happens on the server");
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.injection.InjectionContainer#getEncInjectors()
+ */
+ public Map<String, EncInjector> getEncInjectors()
+ {
+ throw new IllegalStateException("ENC setup happens on the server");
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.injection.InjectionContainer#getEnvironmentRefGroup()
+ */
+ public RemoteEnvironment getEnvironmentRefGroup()
+ {
+ return xml;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.injection.InjectionContainer#getIdentifier()
+ */
+ public String getIdentifier()
+ {
+// throw new NotImplementedException;
+ // FIXME: return the real identifier
+ //return "client-identifier";
+ return applicationClientName;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.injection.InjectionContainer#getInjectors()
+ */
+ public List<Injector> getInjectors()
+ {
+ return injectors;
+ }
+
+ public Class<?> getMainClass()
+ {
+ return mainClass;
+ }
+
+ public boolean hasJNDIBinding(String jndiName)
+ {
+ return false;
+ }
+
+ public void invokeMain(String args[]) throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException
+ {
+ Class<?> parameterTypes[] = { args.getClass() };
+ Method method = mainClass.getDeclaredMethod("main", parameterTypes);
+ try
+ {
+ log.info("Invoking main: "+method);
+ method.invoke(null, (Object) args);
+ log.info("Successfully invoked main");
+ }
+ catch(Throwable e)
+ {
+ e.printStackTrace();
+ log.error("Invocation of client main failed", e);
+ }
+ }
+
+ /**
+ * Call post construct methods.
+ * @throws IllegalAccessException
+ * @throws InstantiationException
+ * @throws InvocationTargetException
+ * @throws IllegalArgumentException
+ *
+ */
+ private void postConstruct() throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException
+ {
+ log.info("postConstructs = " + postConstructs);
+ for(Method method : postConstructs)
+ {
+ method.setAccessible(true);
+ Object instance;
+ if(Modifier.isStatic(method.getModifiers()))
+ instance = null;
+ else
+ instance = method.getDeclaringClass().newInstance();
+ Object args[] = null;
+ method.invoke(instance, args);
+ }
+ }
+
+ private void processMetadata(DependencyPolicy dependencyPolicy) throws Exception
+ {
+ log.debug("processMetadata");
+ processPostConstructs();
+
+ // TODO: check which handlers a client container should support
+ Collection<InjectionHandler<RemoteEnvironment>> handlers = new ArrayList<InjectionHandler<RemoteEnvironment>>();
+ handlers.add(new ClientEJBHandler<RemoteEnvironment>());
+ // This currently has no use in the ClientContainer, maybe in the future when running an mc
+ handlers.add(new DependsHandler<RemoteEnvironment>());
+ //handlers.add(new JndiInjectHandler<RemoteEnvironment>());
+ handlers.add(new ClientPersistenceUnitHandler<RemoteEnvironment>());
+ handlers.add(new ClientResourceHandler<RemoteEnvironment>(this.mainClass));
+ handlers.add(new WebServiceRefHandler<RemoteEnvironment>());
+
+ // 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<RemoteEnvironment> handler : handlers)
+ handler.loadXml(xml, this);
+
+ /*
+ Map<AccessibleObject, Injector> tmp = InjectionUtil.processAnnotations(this, handlers, getMainClass());
+ injectors.addAll(tmp.values());
+ */
+ }
+ finally
+ {
+// Thread.currentThread().setContextClassLoader(old);
+ }
+ }
+
+ /**
+ * Populate the list of the post construct callbacks ordered according to the spec rules defined in
+ * 12.4.1 Multiple Callback Interceptor Methods for a Life Cycle Callback Event.
+ *
+ * @throws ClassNotFoundException
+ * @throws NoSuchMethodException
+ * @throws SecurityException
+ *
+ */
+ private void processPostConstructs()
+ throws ClassNotFoundException, SecurityException, NoSuchMethodException
+ {
+ LifecycleCallbacksMetaData callbacks = xml.getPostConstructs();
+ if(callbacks == null || callbacks.isEmpty())
+ return;
+
+ List<Method> methods = callbacks.getOrderedCallbacks(mainClass);
+ postConstructs.addAll(methods);
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.injection.InjectionContainer#resolveEjbContainer(java.lang.String, java.lang.Class)
+ */
+ public Container resolveEjbContainer(String link, Class businessIntf)
+ {
+ 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
+ {
+ return null;
+ }
+
+ public String resolveMessageDestination(String link)
+ {
+ // Resolving something here is a nop
+ return null;
+ }
+
+ public VirtualFile getRootFile()
+ {
+ throw new NotImplementedException();
+ }
+
+ /**
+ * Recursively display the naming context information into the buffer.
+ *
+ * @param ctx
+ * @param indent
+ * @param buffer
+ * @param verbose
+ */
+ private static void list(Context ctx, String indent, StringBuffer buffer,
+ boolean verbose)
+ {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ try
+ {
+ NamingEnumeration ne = ctx.list("");
+ while (ne.hasMore())
+ {
+ NameClassPair pair = (NameClassPair) ne.next();
+
+ String name = pair.getName();
+ String className = pair.getClassName();
+ boolean recursive = false;
+ boolean isLinkRef = false;
+ boolean isProxy = false;
+ Class c = null;
+ try
+ {
+ c = loader.loadClass(className);
+
+ if (Context.class.isAssignableFrom(c))
+ recursive = true;
+ if (LinkRef.class.isAssignableFrom(c))
+ isLinkRef = true;
+
+ isProxy = Proxy.isProxyClass(c);
+ }
+ catch (ClassNotFoundException cnfe)
+ {
+ // If this is a $Proxy* class its a proxy
+ if (className.startsWith("$Proxy"))
+ {
+ isProxy = true;
+ // We have to get the class from the binding
+ try
+ {
+ Object p = ctx.lookup(name);
+ c = p.getClass();
+ }
+ catch (NamingException e)
+ {
+ Throwable t = e.getRootCause();
+ if (t instanceof ClassNotFoundException)
+ {
+ // Get the class name from the exception msg
+ String msg = t.getMessage();
+ if (msg != null)
+ {
+ // Reset the class name to the CNFE class
+ className = msg;
+ }
+ }
+ }
+ }
+ }
+
+ buffer.append(indent + " +- " + name);
+
+ // Display reference targets
+ if (isLinkRef)
+ {
+ // Get the
+ try
+ {
+ Object obj = ctx.lookupLink(name);
+
+ LinkRef link = (LinkRef) obj;
+ buffer.append("[link -> ");
+ buffer.append(link.getLinkName());
+ buffer.append(']');
+ }
+ catch (Throwable t)
+ {
+ buffer.append("invalid]");
+ }
+ }
+
+ // Display proxy interfaces
+ if (isProxy)
+ {
+ buffer.append(" (proxy: " + pair.getClassName());
+ if (c != null)
+ {
+ Class[] ifaces = c.getInterfaces();
+ buffer.append(" implements ");
+ for (int i = 0; i < ifaces.length; i++)
+ {
+ buffer.append(ifaces[i]);
+ buffer.append(',');
+ }
+ buffer.setCharAt(buffer.length() - 1, ')');
+ }
+ else
+ {
+ buffer.append(" implements " + className + ")");
+ }
+ }
+ else if (verbose)
+ {
+ buffer.append(" (class: " + pair.getClassName() + ")");
+ }
+
+ buffer.append('\n');
+ if (recursive)
+ {
+ try
+ {
+ Object value = ctx.lookup(name);
+ if (value instanceof Context)
+ {
+ Context subctx = (Context) value;
+ list(subctx, indent + " | ", buffer, verbose);
+ }
+ else
+ {
+ buffer.append(indent + " | NonContext: " + value);
+ buffer.append('\n');
+ }
+ }
+ catch (Throwable t)
+ {
+ buffer.append("Failed to lookup: " + name + ", errmsg=" + t.getMessage());
+ buffer.append('\n');
+ }
+ }
+ }
+ ne.close();
+ }
+ catch (NamingException ne)
+ {
+ buffer.append("error while listing context " + ctx.toString() + ": " + ne.toString(true));
+ formatException(buffer, ne);
+ }
+ }
+ private static void formatException(StringBuffer buffer, Throwable t)
+ {
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ buffer.append("<pre>\n");
+ t.printStackTrace(pw);
+ buffer.append(sw.toString());
+ buffer.append("</pre>\n");
+ }
+}
Property changes on: trunk/ejb3/src/main/org/jboss/ejb3/client/ClientContainer.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/ejb3/src/main/org/jboss/ejb3/client/ClientEJBHandler.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/client/ClientEJBHandler.java 2008-11-14 14:58:15 UTC (rev 81052)
+++ trunk/ejb3/src/main/org/jboss/ejb3/client/ClientEJBHandler.java 2008-11-14 14:59:40 UTC (rev 81053)
@@ -1,175 +1,175 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * 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.reflect.AccessibleObject;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.Collection;
-import java.util.Map;
-
-import javax.ejb.EJB;
-
-import org.jboss.injection.AbstractHandler;
-import org.jboss.injection.InjectionContainer;
-import org.jboss.injection.Injector;
-
-import org.jboss.logging.Logger;
-import org.jboss.metadata.javaee.spec.AbstractEJBReferenceMetaData;
-import org.jboss.metadata.javaee.spec.AnnotatedEJBReferenceMetaData;
-import org.jboss.metadata.javaee.spec.AnnotatedEJBReferencesMetaData;
-import org.jboss.metadata.javaee.spec.EJBReferenceMetaData;
-import org.jboss.metadata.javaee.spec.RemoteEnvironment;
-
-/**
- * @author Scott.Stark at jboss.org
- * @version $Revision:$
- */
-public class ClientEJBHandler<X extends RemoteEnvironment>
- extends AbstractHandler<X>
-{
- private static final Logger log = Logger.getLogger(ClientEJBHandler.class);
-
- public void loadXml(X xml, InjectionContainer container)
- {
- if (xml != null)
- {
- log.trace("ejbRefs = " + xml.getEjbReferences());
- try
- {
- if (xml.getAnnotatedEjbReferences() != null)
- loadEjbRefXml(xml.getAnnotatedEjbReferences(), container);
- if (xml.getEjbReferences() != null)
- loadEjbRefXml(xml.getEjbReferences(), container);
- }
- catch(Exception e)
- {
- throw new IllegalStateException(e);
- }
- }
- }
-
- public void handleClassAnnotations(Class<?> clazz, InjectionContainer container)
- {
- throw new IllegalStateException("Annotations are not handled");
- }
- public void handleFieldAnnotations(Field field, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
- {
- throw new IllegalStateException("Annotations are not handled");
- }
- public void handleMethodAnnotations(Method method, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
- {
- throw new IllegalStateException("Annotations are not handled");
- }
-
- protected void loadEjbRefXml(AnnotatedEJBReferencesMetaData refs,
- InjectionContainer container)
- throws Exception
- {
- for (AnnotatedEJBReferenceMetaData ref : refs)
- {
- String interfaceName = ref.getBeanInterface().getName();
- String errorType = "@EJB";
-
- ejbRefXml(ref, interfaceName, container, errorType);
- }
- }
-
- protected void loadEjbRefXml(Collection<EJBReferenceMetaData> refs, InjectionContainer container)
- throws Exception
- {
- for (EJBReferenceMetaData ref : refs)
- {
- String interfaceName = ref.getRemote();
- String errorType = "<ejb-ref>";
-
- ejbRefXml(ref, interfaceName, container, errorType);
- }
- }
-
- protected void ejbRefXml(AbstractEJBReferenceMetaData ref, String interfaceName, InjectionContainer container, String errorType)
- throws Exception
- {
- String encName = "env/" + ref.getEjbRefName();
- Utils.injectionTarget(encName, ref, container);
-
- /*
- String mappedName = ref.getMappedName();
- if (mappedName != null && mappedName.equals(""))
- mappedName = null;
- if(mappedName == null && ref.getResolvedJndiName() != null)
- mappedName = ref.getResolvedJndiName();
-
- if(mappedName == null)
- throw new IllegalStateException(ref+" has no mapped name");
- // Handle the injection targets
- ClassLoader loader = container.getClassloader();
- Set<ResourceInjectionTargetMetaData> targets = ref.getInjectionTargets();
- if(targets != null)
- {
- for(ResourceInjectionTargetMetaData target : targets)
- {
- String className = target.getInjectionTargetClass();
- String targetName = target.getInjectionTargetName();
- Class<?> c = loader.loadClass(className);
- AccessibleObject ao = Utils.getAccessibleObject(c, targetName);
- BeanProperty prop = BeanPropertyFactory.create(ao);
- JndiPropertyInjector propInjector = new JndiPropertyInjector(prop, encName, container.getEnc());
- container.getInjectors().add(propInjector);
- }
- }
- else
- {
- log.warn("No injection targets seen for: "+ref);
- }
- */
- }
-
- protected String getEncName(EJB ref, Field field)
- {
- String encName = ref.name();
- if (encName == null || encName.equals(""))
- {
- encName = Utils.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 = Utils.getEncName(method);
- }
- else
- {
- encName = "env/" + encName;
- }
- return encName;
- }
-
-}
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * 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.reflect.AccessibleObject;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.Collection;
+import java.util.Map;
+
+import javax.ejb.EJB;
+
+import org.jboss.injection.AbstractHandler;
+import org.jboss.injection.InjectionContainer;
+import org.jboss.injection.Injector;
+
+import org.jboss.logging.Logger;
+import org.jboss.metadata.javaee.spec.AbstractEJBReferenceMetaData;
+import org.jboss.metadata.javaee.spec.AnnotatedEJBReferenceMetaData;
+import org.jboss.metadata.javaee.spec.AnnotatedEJBReferencesMetaData;
+import org.jboss.metadata.javaee.spec.EJBReferenceMetaData;
+import org.jboss.metadata.javaee.spec.RemoteEnvironment;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class ClientEJBHandler<X extends RemoteEnvironment>
+ extends AbstractHandler<X>
+{
+ private static final Logger log = Logger.getLogger(ClientEJBHandler.class);
+
+ public void loadXml(X xml, InjectionContainer container)
+ {
+ if (xml != null)
+ {
+ log.trace("ejbRefs = " + xml.getEjbReferences());
+ try
+ {
+ if (xml.getAnnotatedEjbReferences() != null)
+ loadEjbRefXml(xml.getAnnotatedEjbReferences(), container);
+ if (xml.getEjbReferences() != null)
+ loadEjbRefXml(xml.getEjbReferences(), container);
+ }
+ catch(Exception e)
+ {
+ throw new IllegalStateException(e);
+ }
+ }
+ }
+
+ public void handleClassAnnotations(Class<?> clazz, InjectionContainer container)
+ {
+ throw new IllegalStateException("Annotations are not handled");
+ }
+ public void handleFieldAnnotations(Field field, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
+ {
+ throw new IllegalStateException("Annotations are not handled");
+ }
+ public void handleMethodAnnotations(Method method, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
+ {
+ throw new IllegalStateException("Annotations are not handled");
+ }
+
+ protected void loadEjbRefXml(AnnotatedEJBReferencesMetaData refs,
+ InjectionContainer container)
+ throws Exception
+ {
+ for (AnnotatedEJBReferenceMetaData ref : refs)
+ {
+ String interfaceName = ref.getBeanInterface().getName();
+ String errorType = "@EJB";
+
+ ejbRefXml(ref, interfaceName, container, errorType);
+ }
+ }
+
+ protected void loadEjbRefXml(Collection<EJBReferenceMetaData> refs, InjectionContainer container)
+ throws Exception
+ {
+ for (EJBReferenceMetaData ref : refs)
+ {
+ String interfaceName = ref.getRemote();
+ String errorType = "<ejb-ref>";
+
+ ejbRefXml(ref, interfaceName, container, errorType);
+ }
+ }
+
+ protected void ejbRefXml(AbstractEJBReferenceMetaData ref, String interfaceName, InjectionContainer container, String errorType)
+ throws Exception
+ {
+ String encName = "env/" + ref.getEjbRefName();
+ Utils.injectionTarget(encName, ref, container);
+
+ /*
+ String mappedName = ref.getMappedName();
+ if (mappedName != null && mappedName.equals(""))
+ mappedName = null;
+ if(mappedName == null && ref.getResolvedJndiName() != null)
+ mappedName = ref.getResolvedJndiName();
+
+ if(mappedName == null)
+ throw new IllegalStateException(ref+" has no mapped name");
+ // Handle the injection targets
+ ClassLoader loader = container.getClassloader();
+ Set<ResourceInjectionTargetMetaData> targets = ref.getInjectionTargets();
+ if(targets != null)
+ {
+ for(ResourceInjectionTargetMetaData target : targets)
+ {
+ String className = target.getInjectionTargetClass();
+ String targetName = target.getInjectionTargetName();
+ Class<?> c = loader.loadClass(className);
+ AccessibleObject ao = Utils.getAccessibleObject(c, targetName);
+ BeanProperty prop = BeanPropertyFactory.create(ao);
+ JndiPropertyInjector propInjector = new JndiPropertyInjector(prop, encName, container.getEnc());
+ container.getInjectors().add(propInjector);
+ }
+ }
+ else
+ {
+ log.warn("No injection targets seen for: "+ref);
+ }
+ */
+ }
+
+ protected String getEncName(EJB ref, Field field)
+ {
+ String encName = ref.name();
+ if (encName == null || encName.equals(""))
+ {
+ encName = Utils.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 = Utils.getEncName(method);
+ }
+ else
+ {
+ encName = "env/" + encName;
+ }
+ return encName;
+ }
+
+}
Property changes on: trunk/ejb3/src/main/org/jboss/ejb3/client/ClientEJBHandler.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/ejb3/src/main/org/jboss/ejb3/client/ClientJavaEEComponent.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/client/ClientJavaEEComponent.java 2008-11-14 14:58:15 UTC (rev 81052)
+++ trunk/ejb3/src/main/org/jboss/ejb3/client/ClientJavaEEComponent.java 2008-11-14 14:59:40 UTC (rev 81053)
@@ -1,51 +1,51 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * 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 org.jboss.ejb3.javaee.AbstractJavaEEComponent;
-import org.jboss.ejb3.javaee.JavaEEModule;
-import org.jboss.ejb3.javaee.SimpleJavaEEModule;
-
-/**
- * @author Scott.Stark at jboss.org
- * @version $Revision:$
- */
-public class ClientJavaEEComponent extends AbstractJavaEEComponent
-{
- public ClientJavaEEComponent(String clientName)
- {
- super(new SimpleJavaEEModule(clientName));
- }
-
- @Override
- public String createObjectName(String unitName, String ejbName)
- {
- return "org.jboss.client:jar="+unitName;
- }
-
- @Override
- public String createObjectName(String ejbName)
- {
- return "org.jboss.client:jar="+ejbName;
- }
-
-}
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * 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 org.jboss.ejb3.javaee.AbstractJavaEEComponent;
+import org.jboss.ejb3.javaee.JavaEEModule;
+import org.jboss.ejb3.javaee.SimpleJavaEEModule;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class ClientJavaEEComponent extends AbstractJavaEEComponent
+{
+ public ClientJavaEEComponent(String clientName)
+ {
+ super(new SimpleJavaEEModule(clientName));
+ }
+
+ @Override
+ public String createObjectName(String unitName, String ejbName)
+ {
+ return "org.jboss.client:jar="+unitName;
+ }
+
+ @Override
+ public String createObjectName(String ejbName)
+ {
+ return "org.jboss.client:jar="+ejbName;
+ }
+
+}
Property changes on: trunk/ejb3/src/main/org/jboss/ejb3/client/ClientJavaEEComponent.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/ejb3/src/main/org/jboss/ejb3/client/ClientLauncher.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/client/ClientLauncher.java 2008-11-14 14:58:15 UTC (rev 81052)
+++ trunk/ejb3/src/main/org/jboss/ejb3/client/ClientLauncher.java 2008-11-14 14:59:40 UTC (rev 81053)
@@ -1,581 +1,581 @@
-/*
- * 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.io.IOException;
-import java.lang.reflect.Method;
-import java.net.MalformedURLException;
-import java.rmi.server.RMIClassLoader;
-import java.rmi.server.RMIClassLoaderSpi;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Properties;
-
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-
-import org.jboss.beans.metadata.plugins.builder.BeanMetaDataBuilderFactory;
-import org.jboss.beans.metadata.spi.BeanMetaData;
-import org.jboss.beans.metadata.spi.BeanMetaDataFactory;
-import org.jboss.beans.metadata.spi.ValueMetaData;
-import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
-import org.jboss.classloader.plugins.system.DefaultClassLoaderSystem;
-import org.jboss.classloader.spi.ClassLoaderDomain;
-import org.jboss.classloader.spi.ClassLoaderSystem;
-import org.jboss.classloader.spi.ParentPolicy;
-import org.jboss.classloading.spi.dependency.ClassLoading;
-import org.jboss.classloading.spi.vfs.dependency.VFSClassLoaderPolicyModule;
-import org.jboss.classloading.spi.vfs.metadata.VFSClassLoaderFactory;
-import org.jboss.classloading.spi.vfs.metadata.VFSClassLoaderFactory10;
-import org.jboss.client.AppClientLauncher;
-import org.jboss.dependency.spi.ControllerMode;
-import org.jboss.dependency.spi.ControllerState;
-import org.jboss.deployment.dependency.JndiDependencyMetaData;
-import org.jboss.kernel.Kernel;
-import org.jboss.kernel.plugins.bootstrap.AbstractBootstrap;
-import org.jboss.kernel.plugins.bootstrap.basic.BasicBootstrap;
-import org.jboss.kernel.plugins.deployment.AbstractKernelDeployment;
-import org.jboss.kernel.plugins.deployment.xml.BasicXMLDeployer;
-import org.jboss.kernel.spi.dependency.KernelController;
-import org.jboss.kernel.spi.dependency.KernelControllerContext;
-import org.jboss.kernel.spi.deployment.KernelDeployment;
-import org.jboss.logging.Logger;
-import org.jboss.metadata.client.jboss.JBossClientMetaData;
-import org.jboss.remoting.Remoting;
-import org.jboss.xb.binding.JBossXBException;
-
-/**
- * This class launches a JavaEE 5 application client.
- *
- * The first argument is either a jar file containing the client deployment files or the application client class name.
- * The manifest file Main-Class attribute must point to the application client class.
- * It must 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>
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
-public class ClientLauncher
- implements AppClientLauncher
-{
- private static final Logger log = Logger.getLogger(ClientLauncher.class);
- private static final String VERSION = "$Revision$";
- private static Throwable exception;
- /** The kernel for the client container */
- private static Kernel kernel;
-
- /** The deployer */
- private static BasicXMLDeployer deployer;
- /** The mainClass used by the ClientContainer */
- private static Class<?> theMainClass;
- /** Should the remoting class loader delegate to the tcl */
- private static boolean remotingDelgatesToTCL = true;
- /** Additional classpath elements to client container classpath */
- private static List<String> extraClassPath = new ArrayList<String>();
-
- /**
- * Access the client main class as loaded by the MC/client container. This
- * class should be used to ensure that any static variable set in the class
- * as a by-product of invoking the client main(String[]) method are seen.
- * @return client main class object
- */
- public static Class<?> getTheMainClass()
- {
- return theMainClass;
- }
-
- /**
- * Convenience method to load the XML descriptor for the given applicationClientName.
- * This does a lookup against the server for the xml metadata the client
- * deployer bound.
- *
- * @return the JBossClientMetaData
- * @throws IOException
- * @throws JBossXBException
- */
- public static JBossClientMetaData loadXML(String applicationClientName) throws NamingException
- {
- log.warn("FIXME: using an unsupported hack to get metadata");
- InitialContext ctx = new InitialContext();
- JBossClientMetaData metaData = (JBossClientMetaData) ctx.lookup(applicationClientName + "/metaData");
- return metaData;
- }
- public static List<String> loadClassPath(String applicationClientName)
- throws NamingException
- {
- InitialContext ctx = new InitialContext();
- List<String> cp = (List<String>) ctx.lookup(applicationClientName + "/classPathEntries");
- return cp;
- }
-
- /**
- * Calls {@link #launch(String, String, String[], Properties)}
- */
- public void launch(String clientClass, String clientName, String[] args)
- throws Throwable
- {
- launch(clientClass, clientName, args, null);
- }
-
- /**
- * Convenience method for launching a client container.
- *
- * @param xml
- * @param mainClassName
- * @param applicationClientName
- * @param args
- * @throws Exception
- */
- public static void launch(JBossClientMetaData xml, String mainClassName, String applicationClientName, String args[])
- throws Throwable
- {
- List<String> cp = Collections.emptyList();
- launch(xml, cp, mainClassName, applicationClientName, args, null);
- }
- /**
- * The AppClientLauncher method for launching a client container.
- *
- * @param mainClassName - the class whose main(String[]) will be invoked
- * @param clientName - the client name that maps to the server side JNDI ENC
- * @param args - the args to pass to main method
- * @param jndiEnv - jndi properties to pass to set as System properties
- * @throws Throwable
- */
- public static void launch(String mainClassName, String clientName, String args[],
- Properties jndiEnv)
- throws Throwable
- {
- // Set the RMIClassLoaderSpi implementation to JBossRMIClassLoader
- System.setProperty("java.rmi.server.RMIClassLoaderSpi", JBossRMIClassLoader.class.getName());
- // This is loaded lazily via a jndi dependency
- JBossClientMetaData xml = null;
- List<String> cp = loadClassPath(clientName);
- launch(xml, cp, mainClassName, clientName, args, jndiEnv);
- }
-
- /**
- * The client launcher entry point that create an mc to launch the client container.
- * @param clientClass
- * @param clientName
- * @param cp
- * @param args
- * @throws Throwable
- */
- public static void launch(JBossClientMetaData xml, List<String> classPath,
- String mainClassName, String applicationClientName, String args[],
- Properties jndiEnv)
- throws Throwable
- {
- log.info("ClientLauncher, version: "+VERSION);
- // Init the kernel and deployers
- args = init(args);
-
- // Pass in the jndi env properties so InitialContext() works
- if(jndiEnv != null)
- {
- for(Object key : jndiEnv.keySet())
- {
- String name = (String) key;
- System.setProperty(name, jndiEnv.getProperty(name));
- }
- }
- // Have the remoting class loader delegate to the tcl
- if(remotingDelgatesToTCL)
- System.setProperty(Remoting.CLASSLOADING_PARENT_FIRST_DELEGATION_PROP, "false");
-
- // Setup the
- ArrayList<BeanMetaDataFactory> beanFactories = new ArrayList<BeanMetaDataFactory>();
- ArrayList<BeanMetaData> beans = new ArrayList<BeanMetaData>();
-
- // Add the common launcher beans, ClassLoaderSystem
- BeanMetaDataBuilder builder = BeanMetaDataBuilderFactory.createBuilder("ClassLoaderSystem", ClassLoaderSystem.class.getName());
- builder.setFactoryClass(ClientLauncher.class.getName());
- builder.setFactoryMethod("getClassLoaderSystem");
- BeanMetaData classLoaderSystemBMD = builder.getBeanMetaData();
- addBeanMetaData(beanFactories, beans, classLoaderSystemBMD);
-
- // ClassLoading
- builder = BeanMetaDataBuilderFactory.createBuilder("ClassLoading", ClassLoading.class.getName());
- builder.addMethodInstallCallback("addModule", ControllerState.CONFIGURED);
- builder.addMethodUninstallCallback("removeModule", ControllerState.CONFIGURED);
- BeanMetaData classLoadingBMD = builder.getBeanMetaData();
- addBeanMetaData(beanFactories, beans, classLoadingBMD);
-
- try
- {
- builder = BeanMetaDataBuilderFactory.createBuilder("ClientContainer",
- "org.jboss.ejb3.client.ClientContainer");
- VFSClassLoaderFactory factory = new VFSClassLoaderFactory("ClientLauncherClassPath");
- ArrayList<String> roots = new ArrayList<String>();
- // Create the classpath
- log.info("Setting up classpath from: ");
- for(String path : classPath)
- {
- log.info(path);
- roots.add(path);
- }
- for(String path : extraClassPath)
- {
- log.info(path);
- roots.add(path);
- }
- log.info("End classpath");
- factory.setRoots(roots);
- beanFactories.add(factory);
- // ClientContainer(xml, mainClass, applicationClientName, jndiEnv);
- String classLoaderName = factory.getContextName();
- if(classLoaderName == null)
- classLoaderName = factory.getName() + ":" + factory.getVersion();
- String metaDataJndiName = applicationClientName + "/metaData";
- ValueMetaData xmlMD = new JndiDependencyValueMetaData(metaDataJndiName, jndiEnv, classLoaderName);
- builder.addConstructorParameter(JBossClientMetaData.class.getName(), xmlMD);
- //builder.addConstructorParameter(JBossClientMetaData.class.getName(), xml);
- builder.addConstructorParameter(Class.class.getName(), mainClassName);
- builder.addConstructorParameter(String.class.getName(), applicationClientName);
- builder.addConstructorParameter(Properties.class.getName(), jndiEnv);
- // Use vfs class loader as the ClientContainer class loader
- ValueMetaData classLoader = builder.createInject(classLoaderName);
- builder.setClassLoader(classLoader);
- BeanMetaData clientContainerMD = builder.getBeanMetaData();
-
- AbstractKernelDeployment deployment = new AbstractKernelDeployment();
- deployment.setName(factory.getName() + ":" + factory.getVersion());
- addBeanMetaData(beanFactories, beans, clientContainerMD);
- deployment.setBeanFactories(beanFactories);
- if(beans.size() > 0)
- deployment.setBeans(beans);
- deploy(deployment);
- validate();
-
- KernelController controller = kernel.getController();
- // ClientContainer
- KernelControllerContext context = (KernelControllerContext) controller.getContext("ClientContainer", ControllerState.INSTALLED);
- if (context == null)
- throw new Exception("ClientContainer bean was not created");
- Object client = context.getTarget();
- KernelControllerContext cclContext = (KernelControllerContext) controller.getContext(classLoaderName, ControllerState.INSTALLED);
- if (cclContext == null)
- throw new Exception(classLoaderName+" bean was not created");
- ClassLoader ccLoader = (ClassLoader) cclContext.getTarget();
- if (ccLoader == null )
- throw new Exception(classLoaderName+" bean was not created");
- if (client.getClass().getClassLoader() != ccLoader)
- log.warn(client.getClass().getClassLoader()+" != "+ccLoader);
- Class<?> clientContainerClass = ccLoader.loadClass("org.jboss.ejb3.client.ClientContainer");
- if (clientContainerClass.getClassLoader() != ccLoader)
- log.warn(clientContainerClass.getClassLoader()+" != "+ccLoader);
-
- // Invoke main on the underlying client main class through the ClientContainer
- ClassLoader prevLoader = Thread.currentThread().getContextClassLoader();
- try
- {
- // Get the mainClass
- Class<?> empty[] = {};
- Method getMainClass = clientContainerClass.getDeclaredMethod("getMainClass", empty);
- theMainClass = (Class<?>) getMainClass.invoke(client, null);
- // Invoke main
- Thread.currentThread().setContextClassLoader(ccLoader);
- Class<?> parameterTypes[] = { args.getClass() };
- Method invokeMain = clientContainerClass.getDeclaredMethod("invokeMain", parameterTypes);
- invokeMain.invoke(client, (Object) args);
- }
- finally
- {
- Thread.currentThread().setContextClassLoader(prevLoader);
- }
-
- //
- undeploy(deployment);
- }
- catch(Throwable e)
- {
- exception = e;
- throw e;
- }
- }
-
- /**
- * Create a ClassLoaderSystem with the default ClassLoaderDomain set to use
- * a AFTER ParentPolicy.
- *
- * @return ClassLoaderSystem instance
- */
- public static ClassLoaderSystem getClassLoaderSystem()
- {
- DefaultClassLoaderSystem system = new DefaultClassLoaderSystem();
- ClassLoaderDomain defaultDomain = system.getDefaultDomain();
- defaultDomain.setParentPolicy(ParentPolicy.AFTER);
- return system;
- }
-
- private static void addBeanMetaData(
- ArrayList<BeanMetaDataFactory> beanFactories,
- ArrayList<BeanMetaData> beans, BeanMetaData bmd)
- {
- // TODO Auto-generated method stub
- if(bmd instanceof BeanMetaDataFactory)
- {
- BeanMetaDataFactory bmdf = (BeanMetaDataFactory) bmd;
- beanFactories.add(bmdf);
- }
- else
- {
- // Have to use the deprecated beans
- beans.add(bmd);
- }
- }
-
- /**
- * Initialize the mc kernel and deployer as well as extract any client
- * launcher specific args from the input arguments.
- *
- * @param args - the input args to both the launcher and the client main. The
- * launcher specific arguments are:
- * -remotingDelgatesToTCL : true if remoting should first delegate to the the tcl based class loader
- * -extraClassPath : comma separated list of vfsurls for additional classpath
- * @return the remaining arguments to pass to the client main.
- * @throws Throwable
- */
- private static String[] init(String[] args) throws Throwable
- {
- // Extract any launcher args from the input
- String[] newArgs = parseArgs(args);
- // Bootstrap the kernel
- AbstractBootstrap bootstrap = new BasicBootstrap();
- bootstrap.run();
- kernel = bootstrap.getKernel();
-
- // Create the deployer
- deployer = createDeployer();
-
- return newArgs;
- }
- /**
- * Extract the launcher specific arguments from the arguments array.
- * @see #init(String[])
- * @param args - the input args to both the launcher and the client main.
- * @return the remaining arguments to pass to the client main.
- */
- private static String[] parseArgs(String[] args)
- {
- ArrayList<String> tmp = new ArrayList<String>();
- for(int n = 0; n < args.length; n ++)
- {
- String arg = args[n];
- if(arg.equalsIgnoreCase("-remotingDelgatesToTCL"))
- {
- remotingDelgatesToTCL = Boolean.parseBoolean(args[++ n]);
- }
- else if(arg.equalsIgnoreCase("-extraClassPath"))
- {
- // Split classpath elements based on ','
- String cparg = args[++ n];
- String[] cp = cparg.split(",");
- for(String path : cp)
- {
- extraClassPath.add(path);
- }
- log.debug("Set extraClassPath to: "+extraClassPath);
- }
- else
- {
- tmp.add(arg);
- }
- }
- String[] newArgs = new String[tmp.size()];
- tmp.toArray(newArgs);
- return newArgs;
- }
-
- private static BasicXMLDeployer createDeployer()
- {
- return new BasicXMLDeployer(kernel, ControllerMode.AUTOMATIC);
- }
-
- /**
- * Deploy a deployment
- *
- * @param deployment the deployment
- * @throws Exception for any error
- */
- private static void deploy(KernelDeployment deployment) throws Exception
- {
- log.debug("Deploying " + deployment);
- try
- {
- deployer.deploy(deployment);
- log.debug("Deployed " + deployment);
- }
- catch (Exception e)
- {
- throw e;
- }
- catch (Error e)
- {
- throw e;
- }
- catch (Throwable t)
- {
- throw new RuntimeException("Error deploying deployment: " + deployment, t);
- }
- }
- /**
- * Undeploy a deployment
- *
- * @param deployment the deployment
- */
- private static void undeploy(KernelDeployment deployment)
- {
- log.debug("Undeploying " + deployment.getName());
- try
- {
- deployer.undeploy(deployment);
- log.trace("Undeployed " + deployment.getName());
- }
- catch (Throwable t)
- {
- log.warn("Error during undeployment: " + deployment.getName(), t);
- }
- }
-
- /**
- * Validate
- *
- * @throws Exception for any error
- */
- private static void validate() throws Exception
- {
- try
- {
- deployer.validate();
- }
- catch (RuntimeException e)
- {
- throw e;
- }
- catch (Exception e)
- {
- throw e;
- }
- catch (Error e)
- {
- throw e;
- }
- catch (Throwable t)
- {
- throw new RuntimeException(t);
- }
- }
-
- public static void main(String[] args)
- {
- String[] roots = {
- "vfszip:/home/svn/JBossHead/jboss-head/build/output/jboss-5.0.0.CR2/server/cts/tmp/jsr88/assembly_classpath_appclient.ear/assembly_classpath_appclient_client.jar",
- "vfszip:/Users/svn/JBossHead/jboss-head/build/output/jboss-5.0.0.CR2/server/cts/tmp/jsr88/assembly_classpath_appclient.ear/libs/direct_classpath_util.jar",
- "vfszip:/Users/svn/JBossHead/jboss-head/build/output/jboss-5.0.0.CR2/server/cts/tmp/jsr88/assembly_classpath_appclient.ear/libs/indirect_classpath_util.jar"
- };
- VFSClassLoaderFactory10 factory = new VFSClassLoaderFactory10();
- factory.setRoots(Arrays.asList(roots));
- VFSClassLoaderPolicyModule module = new VFSClassLoaderPolicyModule(factory, "AppClientLoaderModule");
-
- }
-
- /**
- * RMIClassLoaderSpi that uses the thread context class loader
- *
- * @author <a href="mailto:adrian.brock at happeningtimes.com">Adrian Brock</a>
- * @author Scott.Stark at jboss.org
- * @version $Revision$
- */
- public static class JBossRMIClassLoader
- extends RMIClassLoaderSpi
- {
- // Attributes ----------------------------------------------------
-
- /**
- * The JVM implementation (we delegate most work to it)
- */
- RMIClassLoaderSpi delegate = RMIClassLoader.getDefaultProviderInstance();
-
- // Constructors --------------------------------------------------
-
- /**
- * Required constructor
- */
- public JBossRMIClassLoader()
- {
- }
-
- // RMIClassLoaderSpi Implementation ------------------------------
-
- /*
- * Ignore the JVM, use the thread context classloader for proxy caching
- */
- public Class<?> loadProxyClass(String codebase, String[] interfaces, ClassLoader ignored)
- throws MalformedURLException, ClassNotFoundException
- {
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- return delegate.loadProxyClass(codebase, interfaces, loader);
- }
-
- /*
- * Just delegate
- */
- public Class<?> loadClass(String codebase, String name, ClassLoader ignored)
- throws MalformedURLException, ClassNotFoundException
- {
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
- return delegate.loadClass(codebase, name, loader);
- }
-
- /*
- * Just delegate
- */
- public ClassLoader getClassLoader(String codebase)
- throws MalformedURLException
- {
- return delegate.getClassLoader(codebase);
- }
-
- /*
- * Try to delegate an default to the java.rmi.server.codebase on any
- * failure.
- */
- public String getClassAnnotation(Class<?> cl)
- {
- String annotation = null;
- try
- {
- annotation = delegate.getClassAnnotation(cl);
- }
- catch(Throwable t)
- {
- // Try the java.rmi.server.codebase property
- annotation = System.getProperty("java.rmi.server.codebase");
- }
- return annotation;
- }
- }
-
-}
+/*
+ * 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.io.IOException;
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.rmi.server.RMIClassLoader;
+import java.rmi.server.RMIClassLoaderSpi;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Properties;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.jboss.beans.metadata.plugins.builder.BeanMetaDataBuilderFactory;
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.spi.BeanMetaDataFactory;
+import org.jboss.beans.metadata.spi.ValueMetaData;
+import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
+import org.jboss.classloader.plugins.system.DefaultClassLoaderSystem;
+import org.jboss.classloader.spi.ClassLoaderDomain;
+import org.jboss.classloader.spi.ClassLoaderSystem;
+import org.jboss.classloader.spi.ParentPolicy;
+import org.jboss.classloading.spi.dependency.ClassLoading;
+import org.jboss.classloading.spi.vfs.dependency.VFSClassLoaderPolicyModule;
+import org.jboss.classloading.spi.vfs.metadata.VFSClassLoaderFactory;
+import org.jboss.classloading.spi.vfs.metadata.VFSClassLoaderFactory10;
+import org.jboss.client.AppClientLauncher;
+import org.jboss.dependency.spi.ControllerMode;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.deployment.dependency.JndiDependencyMetaData;
+import org.jboss.kernel.Kernel;
+import org.jboss.kernel.plugins.bootstrap.AbstractBootstrap;
+import org.jboss.kernel.plugins.bootstrap.basic.BasicBootstrap;
+import org.jboss.kernel.plugins.deployment.AbstractKernelDeployment;
+import org.jboss.kernel.plugins.deployment.xml.BasicXMLDeployer;
+import org.jboss.kernel.spi.dependency.KernelController;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.kernel.spi.deployment.KernelDeployment;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.client.jboss.JBossClientMetaData;
+import org.jboss.remoting.Remoting;
+import org.jboss.xb.binding.JBossXBException;
+
+/**
+ * This class launches a JavaEE 5 application client.
+ *
+ * The first argument is either a jar file containing the client deployment files or the application client class name.
+ * The manifest file Main-Class attribute must point to the application client class.
+ * It must 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>
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+public class ClientLauncher
+ implements AppClientLauncher
+{
+ private static final Logger log = Logger.getLogger(ClientLauncher.class);
+ private static final String VERSION = "$Revision$";
+ private static Throwable exception;
+ /** The kernel for the client container */
+ private static Kernel kernel;
+
+ /** The deployer */
+ private static BasicXMLDeployer deployer;
+ /** The mainClass used by the ClientContainer */
+ private static Class<?> theMainClass;
+ /** Should the remoting class loader delegate to the tcl */
+ private static boolean remotingDelgatesToTCL = true;
+ /** Additional classpath elements to client container classpath */
+ private static List<String> extraClassPath = new ArrayList<String>();
+
+ /**
+ * Access the client main class as loaded by the MC/client container. This
+ * class should be used to ensure that any static variable set in the class
+ * as a by-product of invoking the client main(String[]) method are seen.
+ * @return client main class object
+ */
+ public static Class<?> getTheMainClass()
+ {
+ return theMainClass;
+ }
+
+ /**
+ * Convenience method to load the XML descriptor for the given applicationClientName.
+ * This does a lookup against the server for the xml metadata the client
+ * deployer bound.
+ *
+ * @return the JBossClientMetaData
+ * @throws IOException
+ * @throws JBossXBException
+ */
+ public static JBossClientMetaData loadXML(String applicationClientName) throws NamingException
+ {
+ log.warn("FIXME: using an unsupported hack to get metadata");
+ InitialContext ctx = new InitialContext();
+ JBossClientMetaData metaData = (JBossClientMetaData) ctx.lookup(applicationClientName + "/metaData");
+ return metaData;
+ }
+ public static List<String> loadClassPath(String applicationClientName)
+ throws NamingException
+ {
+ InitialContext ctx = new InitialContext();
+ List<String> cp = (List<String>) ctx.lookup(applicationClientName + "/classPathEntries");
+ return cp;
+ }
+
+ /**
+ * Calls {@link #launch(String, String, String[], Properties)}
+ */
+ public void launch(String clientClass, String clientName, String[] args)
+ throws Throwable
+ {
+ launch(clientClass, clientName, args, null);
+ }
+
+ /**
+ * Convenience method for launching a client container.
+ *
+ * @param xml
+ * @param mainClassName
+ * @param applicationClientName
+ * @param args
+ * @throws Exception
+ */
+ public static void launch(JBossClientMetaData xml, String mainClassName, String applicationClientName, String args[])
+ throws Throwable
+ {
+ List<String> cp = Collections.emptyList();
+ launch(xml, cp, mainClassName, applicationClientName, args, null);
+ }
+ /**
+ * The AppClientLauncher method for launching a client container.
+ *
+ * @param mainClassName - the class whose main(String[]) will be invoked
+ * @param clientName - the client name that maps to the server side JNDI ENC
+ * @param args - the args to pass to main method
+ * @param jndiEnv - jndi properties to pass to set as System properties
+ * @throws Throwable
+ */
+ public static void launch(String mainClassName, String clientName, String args[],
+ Properties jndiEnv)
+ throws Throwable
+ {
+ // Set the RMIClassLoaderSpi implementation to JBossRMIClassLoader
+ System.setProperty("java.rmi.server.RMIClassLoaderSpi", JBossRMIClassLoader.class.getName());
+ // This is loaded lazily via a jndi dependency
+ JBossClientMetaData xml = null;
+ List<String> cp = loadClassPath(clientName);
+ launch(xml, cp, mainClassName, clientName, args, jndiEnv);
+ }
+
+ /**
+ * The client launcher entry point that create an mc to launch the client container.
+ * @param clientClass
+ * @param clientName
+ * @param cp
+ * @param args
+ * @throws Throwable
+ */
+ public static void launch(JBossClientMetaData xml, List<String> classPath,
+ String mainClassName, String applicationClientName, String args[],
+ Properties jndiEnv)
+ throws Throwable
+ {
+ log.info("ClientLauncher, version: "+VERSION);
+ // Init the kernel and deployers
+ args = init(args);
+
+ // Pass in the jndi env properties so InitialContext() works
+ if(jndiEnv != null)
+ {
+ for(Object key : jndiEnv.keySet())
+ {
+ String name = (String) key;
+ System.setProperty(name, jndiEnv.getProperty(name));
+ }
+ }
+ // Have the remoting class loader delegate to the tcl
+ if(remotingDelgatesToTCL)
+ System.setProperty(Remoting.CLASSLOADING_PARENT_FIRST_DELEGATION_PROP, "false");
+
+ // Setup the
+ ArrayList<BeanMetaDataFactory> beanFactories = new ArrayList<BeanMetaDataFactory>();
+ ArrayList<BeanMetaData> beans = new ArrayList<BeanMetaData>();
+
+ // Add the common launcher beans, ClassLoaderSystem
+ BeanMetaDataBuilder builder = BeanMetaDataBuilderFactory.createBuilder("ClassLoaderSystem", ClassLoaderSystem.class.getName());
+ builder.setFactoryClass(ClientLauncher.class.getName());
+ builder.setFactoryMethod("getClassLoaderSystem");
+ BeanMetaData classLoaderSystemBMD = builder.getBeanMetaData();
+ addBeanMetaData(beanFactories, beans, classLoaderSystemBMD);
+
+ // ClassLoading
+ builder = BeanMetaDataBuilderFactory.createBuilder("ClassLoading", ClassLoading.class.getName());
+ builder.addMethodInstallCallback("addModule", ControllerState.CONFIGURED);
+ builder.addMethodUninstallCallback("removeModule", ControllerState.CONFIGURED);
+ BeanMetaData classLoadingBMD = builder.getBeanMetaData();
+ addBeanMetaData(beanFactories, beans, classLoadingBMD);
+
+ try
+ {
+ builder = BeanMetaDataBuilderFactory.createBuilder("ClientContainer",
+ "org.jboss.ejb3.client.ClientContainer");
+ VFSClassLoaderFactory factory = new VFSClassLoaderFactory("ClientLauncherClassPath");
+ ArrayList<String> roots = new ArrayList<String>();
+ // Create the classpath
+ log.info("Setting up classpath from: ");
+ for(String path : classPath)
+ {
+ log.info(path);
+ roots.add(path);
+ }
+ for(String path : extraClassPath)
+ {
+ log.info(path);
+ roots.add(path);
+ }
+ log.info("End classpath");
+ factory.setRoots(roots);
+ beanFactories.add(factory);
+ // ClientContainer(xml, mainClass, applicationClientName, jndiEnv);
+ String classLoaderName = factory.getContextName();
+ if(classLoaderName == null)
+ classLoaderName = factory.getName() + ":" + factory.getVersion();
+ String metaDataJndiName = applicationClientName + "/metaData";
+ ValueMetaData xmlMD = new JndiDependencyValueMetaData(metaDataJndiName, jndiEnv, classLoaderName);
+ builder.addConstructorParameter(JBossClientMetaData.class.getName(), xmlMD);
+ //builder.addConstructorParameter(JBossClientMetaData.class.getName(), xml);
+ builder.addConstructorParameter(Class.class.getName(), mainClassName);
+ builder.addConstructorParameter(String.class.getName(), applicationClientName);
+ builder.addConstructorParameter(Properties.class.getName(), jndiEnv);
+ // Use vfs class loader as the ClientContainer class loader
+ ValueMetaData classLoader = builder.createInject(classLoaderName);
+ builder.setClassLoader(classLoader);
+ BeanMetaData clientContainerMD = builder.getBeanMetaData();
+
+ AbstractKernelDeployment deployment = new AbstractKernelDeployment();
+ deployment.setName(factory.getName() + ":" + factory.getVersion());
+ addBeanMetaData(beanFactories, beans, clientContainerMD);
+ deployment.setBeanFactories(beanFactories);
+ if(beans.size() > 0)
+ deployment.setBeans(beans);
+ deploy(deployment);
+ validate();
+
+ KernelController controller = kernel.getController();
+ // ClientContainer
+ KernelControllerContext context = (KernelControllerContext) controller.getContext("ClientContainer", ControllerState.INSTALLED);
+ if (context == null)
+ throw new Exception("ClientContainer bean was not created");
+ Object client = context.getTarget();
+ KernelControllerContext cclContext = (KernelControllerContext) controller.getContext(classLoaderName, ControllerState.INSTALLED);
+ if (cclContext == null)
+ throw new Exception(classLoaderName+" bean was not created");
+ ClassLoader ccLoader = (ClassLoader) cclContext.getTarget();
+ if (ccLoader == null )
+ throw new Exception(classLoaderName+" bean was not created");
+ if (client.getClass().getClassLoader() != ccLoader)
+ log.warn(client.getClass().getClassLoader()+" != "+ccLoader);
+ Class<?> clientContainerClass = ccLoader.loadClass("org.jboss.ejb3.client.ClientContainer");
+ if (clientContainerClass.getClassLoader() != ccLoader)
+ log.warn(clientContainerClass.getClassLoader()+" != "+ccLoader);
+
+ // Invoke main on the underlying client main class through the ClientContainer
+ ClassLoader prevLoader = Thread.currentThread().getContextClassLoader();
+ try
+ {
+ // Get the mainClass
+ Class<?> empty[] = {};
+ Method getMainClass = clientContainerClass.getDeclaredMethod("getMainClass", empty);
+ theMainClass = (Class<?>) getMainClass.invoke(client, null);
+ // Invoke main
+ Thread.currentThread().setContextClassLoader(ccLoader);
+ Class<?> parameterTypes[] = { args.getClass() };
+ Method invokeMain = clientContainerClass.getDeclaredMethod("invokeMain", parameterTypes);
+ invokeMain.invoke(client, (Object) args);
+ }
+ finally
+ {
+ Thread.currentThread().setContextClassLoader(prevLoader);
+ }
+
+ //
+ undeploy(deployment);
+ }
+ catch(Throwable e)
+ {
+ exception = e;
+ throw e;
+ }
+ }
+
+ /**
+ * Create a ClassLoaderSystem with the default ClassLoaderDomain set to use
+ * a AFTER ParentPolicy.
+ *
+ * @return ClassLoaderSystem instance
+ */
+ public static ClassLoaderSystem getClassLoaderSystem()
+ {
+ DefaultClassLoaderSystem system = new DefaultClassLoaderSystem();
+ ClassLoaderDomain defaultDomain = system.getDefaultDomain();
+ defaultDomain.setParentPolicy(ParentPolicy.AFTER);
+ return system;
+ }
+
+ private static void addBeanMetaData(
+ ArrayList<BeanMetaDataFactory> beanFactories,
+ ArrayList<BeanMetaData> beans, BeanMetaData bmd)
+ {
+ // TODO Auto-generated method stub
+ if(bmd instanceof BeanMetaDataFactory)
+ {
+ BeanMetaDataFactory bmdf = (BeanMetaDataFactory) bmd;
+ beanFactories.add(bmdf);
+ }
+ else
+ {
+ // Have to use the deprecated beans
+ beans.add(bmd);
+ }
+ }
+
+ /**
+ * Initialize the mc kernel and deployer as well as extract any client
+ * launcher specific args from the input arguments.
+ *
+ * @param args - the input args to both the launcher and the client main. The
+ * launcher specific arguments are:
+ * -remotingDelgatesToTCL : true if remoting should first delegate to the the tcl based class loader
+ * -extraClassPath : comma separated list of vfsurls for additional classpath
+ * @return the remaining arguments to pass to the client main.
+ * @throws Throwable
+ */
+ private static String[] init(String[] args) throws Throwable
+ {
+ // Extract any launcher args from the input
+ String[] newArgs = parseArgs(args);
+ // Bootstrap the kernel
+ AbstractBootstrap bootstrap = new BasicBootstrap();
+ bootstrap.run();
+ kernel = bootstrap.getKernel();
+
+ // Create the deployer
+ deployer = createDeployer();
+
+ return newArgs;
+ }
+ /**
+ * Extract the launcher specific arguments from the arguments array.
+ * @see #init(String[])
+ * @param args - the input args to both the launcher and the client main.
+ * @return the remaining arguments to pass to the client main.
+ */
+ private static String[] parseArgs(String[] args)
+ {
+ ArrayList<String> tmp = new ArrayList<String>();
+ for(int n = 0; n < args.length; n ++)
+ {
+ String arg = args[n];
+ if(arg.equalsIgnoreCase("-remotingDelgatesToTCL"))
+ {
+ remotingDelgatesToTCL = Boolean.parseBoolean(args[++ n]);
+ }
+ else if(arg.equalsIgnoreCase("-extraClassPath"))
+ {
+ // Split classpath elements based on ','
+ String cparg = args[++ n];
+ String[] cp = cparg.split(",");
+ for(String path : cp)
+ {
+ extraClassPath.add(path);
+ }
+ log.debug("Set extraClassPath to: "+extraClassPath);
+ }
+ else
+ {
+ tmp.add(arg);
+ }
+ }
+ String[] newArgs = new String[tmp.size()];
+ tmp.toArray(newArgs);
+ return newArgs;
+ }
+
+ private static BasicXMLDeployer createDeployer()
+ {
+ return new BasicXMLDeployer(kernel, ControllerMode.AUTOMATIC);
+ }
+
+ /**
+ * Deploy a deployment
+ *
+ * @param deployment the deployment
+ * @throws Exception for any error
+ */
+ private static void deploy(KernelDeployment deployment) throws Exception
+ {
+ log.debug("Deploying " + deployment);
+ try
+ {
+ deployer.deploy(deployment);
+ log.debug("Deployed " + deployment);
+ }
+ catch (Exception e)
+ {
+ throw e;
+ }
+ catch (Error e)
+ {
+ throw e;
+ }
+ catch (Throwable t)
+ {
+ throw new RuntimeException("Error deploying deployment: " + deployment, t);
+ }
+ }
+ /**
+ * Undeploy a deployment
+ *
+ * @param deployment the deployment
+ */
+ private static void undeploy(KernelDeployment deployment)
+ {
+ log.debug("Undeploying " + deployment.getName());
+ try
+ {
+ deployer.undeploy(deployment);
+ log.trace("Undeployed " + deployment.getName());
+ }
+ catch (Throwable t)
+ {
+ log.warn("Error during undeployment: " + deployment.getName(), t);
+ }
+ }
+
+ /**
+ * Validate
+ *
+ * @throws Exception for any error
+ */
+ private static void validate() throws Exception
+ {
+ try
+ {
+ deployer.validate();
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ throw e;
+ }
+ catch (Error e)
+ {
+ throw e;
+ }
+ catch (Throwable t)
+ {
+ throw new RuntimeException(t);
+ }
+ }
+
+ public static void main(String[] args)
+ {
+ String[] roots = {
+ "vfszip:/home/svn/JBossHead/jboss-head/build/output/jboss-5.0.0.CR2/server/cts/tmp/jsr88/assembly_classpath_appclient.ear/assembly_classpath_appclient_client.jar",
+ "vfszip:/Users/svn/JBossHead/jboss-head/build/output/jboss-5.0.0.CR2/server/cts/tmp/jsr88/assembly_classpath_appclient.ear/libs/direct_classpath_util.jar",
+ "vfszip:/Users/svn/JBossHead/jboss-head/build/output/jboss-5.0.0.CR2/server/cts/tmp/jsr88/assembly_classpath_appclient.ear/libs/indirect_classpath_util.jar"
+ };
+ VFSClassLoaderFactory10 factory = new VFSClassLoaderFactory10();
+ factory.setRoots(Arrays.asList(roots));
+ VFSClassLoaderPolicyModule module = new VFSClassLoaderPolicyModule(factory, "AppClientLoaderModule");
+
+ }
+
+ /**
+ * RMIClassLoaderSpi that uses the thread context class loader
+ *
+ * @author <a href="mailto:adrian.brock at happeningtimes.com">Adrian Brock</a>
+ * @author Scott.Stark at jboss.org
+ * @version $Revision$
+ */
+ public static class JBossRMIClassLoader
+ extends RMIClassLoaderSpi
+ {
+ // Attributes ----------------------------------------------------
+
+ /**
+ * The JVM implementation (we delegate most work to it)
+ */
+ RMIClassLoaderSpi delegate = RMIClassLoader.getDefaultProviderInstance();
+
+ // Constructors --------------------------------------------------
+
+ /**
+ * Required constructor
+ */
+ public JBossRMIClassLoader()
+ {
+ }
+
+ // RMIClassLoaderSpi Implementation ------------------------------
+
+ /*
+ * Ignore the JVM, use the thread context classloader for proxy caching
+ */
+ public Class<?> loadProxyClass(String codebase, String[] interfaces, ClassLoader ignored)
+ throws MalformedURLException, ClassNotFoundException
+ {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ return delegate.loadProxyClass(codebase, interfaces, loader);
+ }
+
+ /*
+ * Just delegate
+ */
+ public Class<?> loadClass(String codebase, String name, ClassLoader ignored)
+ throws MalformedURLException, ClassNotFoundException
+ {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ return delegate.loadClass(codebase, name, loader);
+ }
+
+ /*
+ * Just delegate
+ */
+ public ClassLoader getClassLoader(String codebase)
+ throws MalformedURLException
+ {
+ return delegate.getClassLoader(codebase);
+ }
+
+ /*
+ * Try to delegate an default to the java.rmi.server.codebase on any
+ * failure.
+ */
+ public String getClassAnnotation(Class<?> cl)
+ {
+ String annotation = null;
+ try
+ {
+ annotation = delegate.getClassAnnotation(cl);
+ }
+ catch(Throwable t)
+ {
+ // Try the java.rmi.server.codebase property
+ annotation = System.getProperty("java.rmi.server.codebase");
+ }
+ return annotation;
+ }
+ }
+
+}
Property changes on: trunk/ejb3/src/main/org/jboss/ejb3/client/ClientLauncher.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/ejb3/src/main/org/jboss/ejb3/client/ClientResourceHandler.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/client/ClientResourceHandler.java 2008-11-14 14:58:15 UTC (rev 81052)
+++ trunk/ejb3/src/main/org/jboss/ejb3/client/ClientResourceHandler.java 2008-11-14 14:59:40 UTC (rev 81053)
@@ -1,231 +1,231 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * 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.reflect.AccessibleObject;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Collection;
-import java.util.Map;
-
-import javax.ejb.EJBContext;
-import javax.ejb.EJBException;
-import javax.transaction.UserTransaction;
-
-import org.jboss.injection.EJBContextPropertyInjector;
-import org.jboss.injection.InjectionContainer;
-import org.jboss.injection.InjectionHandler;
-import org.jboss.injection.Injector;
-import org.jboss.injection.InjectorFactory;
-import org.jboss.injection.UserTransactionPropertyInjector;
-import org.jboss.injection.lang.reflect.BeanProperty;
-import org.jboss.injection.lang.reflect.BeanPropertyFactory;
-import org.jboss.logging.Logger;
-import org.jboss.metadata.javaee.spec.EnvironmentEntryMetaData;
-import org.jboss.metadata.javaee.spec.MessageDestinationReferenceMetaData;
-import org.jboss.metadata.javaee.spec.RemoteEnvironment;
-import org.jboss.metadata.javaee.spec.ResourceEnvironmentReferenceMetaData;
-import org.jboss.metadata.javaee.spec.ResourceReferenceMetaData;
-import org.omg.CORBA.ORB;
-
-/**
- * Handler for @Resources on the client
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @author Scott.Stark at jboss.org
- * @version $Revision:$
- */
-public class ClientResourceHandler<X extends RemoteEnvironment>
- implements InjectionHandler<X>
-{
- private static final Logger log = Logger.getLogger(ClientResourceHandler.class);
- private Class<?> clientClass;
-
- public ClientResourceHandler(Class<?> clientClass)
- {
- this.clientClass = clientClass;
- }
-
- private void loadEnvEntry(InjectionContainer container, Collection<EnvironmentEntryMetaData> envEntries)
- {
- for (EnvironmentEntryMetaData envEntry : envEntries)
- {
- String encName = "env/" + envEntry.getEnvEntryName();
- // 16.4.1.3: If the env-entry-value is not specified, no value will be injected and it
- // will not be initialized into the naming context.
- if(envEntry.getValue() == null)
- {
- log.debug("ignoring env-entry " + envEntry);
- continue;
- }
- Utils.injectionTarget(encName, envEntry, container);
- }
- }
-
- private void loadXmlResourceRefs(InjectionContainer container, Collection<ResourceReferenceMetaData> refs)
- {
- for (ResourceReferenceMetaData envRef : refs)
- {
- String encName = "env/" + envRef.getResourceRefName();
-
- if (envRef.getMappedName() == null || envRef.getMappedName().equals(""))
- {
- // Handle known injection types
- if (envRef.getResUrl() != null)
- {
- try
- {
- URL resURL = new URL(envRef.getResUrl().trim());
- URLInjectorFactory factory = new URLInjectorFactory(resURL);
- Utils.createInjectors(container.getInjectors(), container.getClassloader(), factory, envRef.getInjectionTargets());
- continue;
- }
- catch (MalformedURLException e)
- {
- throw new RuntimeException(e);
- }
- }
- else if (UserTransaction.class.getName().equals(envRef.getType()))
- {
- final InjectionContainer ic = container;
- InjectorFactory<?> factory = new InjectorFactory<UserTransactionPropertyInjector>()
- {
- public UserTransactionPropertyInjector create(BeanProperty property)
- {
- return new UserTransactionPropertyInjector(property, ic);
- }
- };
- Utils.createInjectors(container.getInjectors(), container.getClassloader(), factory, envRef.getInjectionTargets());
- continue;
- }
- else if (ORB.class.getName().equals(envRef.getType()))
- {
- encName = "java:comp/ORB";
- }
- else
- {
- throw new RuntimeException("mapped-name is required for " + envRef.getResourceRefName() + " of deployment " + container.getIdentifier());
- }
- }
- Utils.injectionTarget(encName, envRef, container);
- }
- }
-
- private static void loadXmlResourceEnvRefs(InjectionContainer container, Collection<ResourceEnvironmentReferenceMetaData> refs)
- {
- for (ResourceEnvironmentReferenceMetaData envRef : refs)
- {
- // EJBTHREE-712
- String resTypeName = envRef.getType();
- String mappedName = envRef.getMappedName();
- try
- {
- if(resTypeName != null)
- {
- Class<?> resType = Class.forName(resTypeName);
- if (resType.equals(UserTransaction.class))
- {
- final InjectionContainer ic = container;
- InjectorFactory<?> factory = new InjectorFactory<UserTransactionPropertyInjector>()
- {
- public UserTransactionPropertyInjector create(BeanProperty property)
- {
- return new UserTransactionPropertyInjector(property, ic);
- }
- };
- if(envRef.getInjectionTargets() != null)
- {
- Utils.createInjectors(container.getInjectors(), container.getClassloader(), factory, envRef.getInjectionTargets());
- continue;
- }
- else
- {
- mappedName = "java:comp/UserTransaction";
- }
- }
- else if (resType.equals(ORB.class))
- {
- mappedName = "java:comp/ORB";
- }
- }
- }
- catch(ClassNotFoundException e)
- {
- throw new EJBException(e);
- }
-
- String encName = "env/" + envRef.getResourceEnvRefName();
- if (mappedName == null || mappedName.equals(""))
- {
- throw new RuntimeException("mapped-name is required for " + envRef.getResourceEnvRefName() + " of deployment " + container.getIdentifier());
- }
- Utils.injectionTarget(encName, envRef, container);
- }
- }
-
- private static void loadXmlMessageDestinationRefs(InjectionContainer container, Collection<MessageDestinationReferenceMetaData> refs)
- {
- for (MessageDestinationReferenceMetaData envRef : refs)
- {
- String encName = "env/" + envRef.getMessageDestinationRefName();
- String jndiName = envRef.getMappedName();
- if (jndiName == null || jndiName.equals(""))
- {
- // Look for a message-destination-link
- jndiName = envRef.getResolvedJndiName();
- if (jndiName == null)
- throw new RuntimeException("message-destination has no jndi-name/resolved-jndi-name " + envRef);
- }
-
- Utils.injectionTarget(encName, envRef, container);
- }
- }
-
- public void loadXml(X xml, InjectionContainer container)
- {
- if (xml == null)
- return;
- if (xml.getMessageDestinationReferences() != null)
- loadXmlMessageDestinationRefs(container, xml.getMessageDestinationReferences());
- if (xml.getResourceEnvironmentReferences() != null)
- loadXmlResourceEnvRefs(container, xml.getResourceEnvironmentReferences());
- if (xml.getResourceReferences() != null)
- loadXmlResourceRefs(container, xml.getResourceReferences());
- if (xml.getEnvironmentEntries() != null)
- loadEnvEntry(container, xml.getEnvironmentEntries());
- }
-
- public void handleClassAnnotations(Class<?> clazz, InjectionContainer container)
- {
- throw new IllegalStateException("Annotations are not handled in the client");
- }
- public void handleMethodAnnotations(Method method, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
- {
- throw new IllegalStateException("Annotations are not handled in the client");
- }
- public void handleFieldAnnotations(Field field, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
- {
- throw new IllegalStateException("Annotations are not handled in the client");
- }
-}
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * 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.reflect.AccessibleObject;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Collection;
+import java.util.Map;
+
+import javax.ejb.EJBContext;
+import javax.ejb.EJBException;
+import javax.transaction.UserTransaction;
+
+import org.jboss.injection.EJBContextPropertyInjector;
+import org.jboss.injection.InjectionContainer;
+import org.jboss.injection.InjectionHandler;
+import org.jboss.injection.Injector;
+import org.jboss.injection.InjectorFactory;
+import org.jboss.injection.UserTransactionPropertyInjector;
+import org.jboss.injection.lang.reflect.BeanProperty;
+import org.jboss.injection.lang.reflect.BeanPropertyFactory;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.javaee.spec.EnvironmentEntryMetaData;
+import org.jboss.metadata.javaee.spec.MessageDestinationReferenceMetaData;
+import org.jboss.metadata.javaee.spec.RemoteEnvironment;
+import org.jboss.metadata.javaee.spec.ResourceEnvironmentReferenceMetaData;
+import org.jboss.metadata.javaee.spec.ResourceReferenceMetaData;
+import org.omg.CORBA.ORB;
+
+/**
+ * Handler for @Resources on the client
+ *
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class ClientResourceHandler<X extends RemoteEnvironment>
+ implements InjectionHandler<X>
+{
+ private static final Logger log = Logger.getLogger(ClientResourceHandler.class);
+ private Class<?> clientClass;
+
+ public ClientResourceHandler(Class<?> clientClass)
+ {
+ this.clientClass = clientClass;
+ }
+
+ private void loadEnvEntry(InjectionContainer container, Collection<EnvironmentEntryMetaData> envEntries)
+ {
+ for (EnvironmentEntryMetaData envEntry : envEntries)
+ {
+ String encName = "env/" + envEntry.getEnvEntryName();
+ // 16.4.1.3: If the env-entry-value is not specified, no value will be injected and it
+ // will not be initialized into the naming context.
+ if(envEntry.getValue() == null)
+ {
+ log.debug("ignoring env-entry " + envEntry);
+ continue;
+ }
+ Utils.injectionTarget(encName, envEntry, container);
+ }
+ }
+
+ private void loadXmlResourceRefs(InjectionContainer container, Collection<ResourceReferenceMetaData> refs)
+ {
+ for (ResourceReferenceMetaData envRef : refs)
+ {
+ String encName = "env/" + envRef.getResourceRefName();
+
+ if (envRef.getMappedName() == null || envRef.getMappedName().equals(""))
+ {
+ // Handle known injection types
+ if (envRef.getResUrl() != null)
+ {
+ try
+ {
+ URL resURL = new URL(envRef.getResUrl().trim());
+ URLInjectorFactory factory = new URLInjectorFactory(resURL);
+ Utils.createInjectors(container.getInjectors(), container.getClassloader(), factory, envRef.getInjectionTargets());
+ continue;
+ }
+ catch (MalformedURLException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+ else if (UserTransaction.class.getName().equals(envRef.getType()))
+ {
+ final InjectionContainer ic = container;
+ InjectorFactory<?> factory = new InjectorFactory<UserTransactionPropertyInjector>()
+ {
+ public UserTransactionPropertyInjector create(BeanProperty property)
+ {
+ return new UserTransactionPropertyInjector(property, ic);
+ }
+ };
+ Utils.createInjectors(container.getInjectors(), container.getClassloader(), factory, envRef.getInjectionTargets());
+ continue;
+ }
+ else if (ORB.class.getName().equals(envRef.getType()))
+ {
+ encName = "java:comp/ORB";
+ }
+ else
+ {
+ throw new RuntimeException("mapped-name is required for " + envRef.getResourceRefName() + " of deployment " + container.getIdentifier());
+ }
+ }
+ Utils.injectionTarget(encName, envRef, container);
+ }
+ }
+
+ private static void loadXmlResourceEnvRefs(InjectionContainer container, Collection<ResourceEnvironmentReferenceMetaData> refs)
+ {
+ for (ResourceEnvironmentReferenceMetaData envRef : refs)
+ {
+ // EJBTHREE-712
+ String resTypeName = envRef.getType();
+ String mappedName = envRef.getMappedName();
+ try
+ {
+ if(resTypeName != null)
+ {
+ Class<?> resType = Class.forName(resTypeName);
+ if (resType.equals(UserTransaction.class))
+ {
+ final InjectionContainer ic = container;
+ InjectorFactory<?> factory = new InjectorFactory<UserTransactionPropertyInjector>()
+ {
+ public UserTransactionPropertyInjector create(BeanProperty property)
+ {
+ return new UserTransactionPropertyInjector(property, ic);
+ }
+ };
+ if(envRef.getInjectionTargets() != null)
+ {
+ Utils.createInjectors(container.getInjectors(), container.getClassloader(), factory, envRef.getInjectionTargets());
+ continue;
+ }
+ else
+ {
+ mappedName = "java:comp/UserTransaction";
+ }
+ }
+ else if (resType.equals(ORB.class))
+ {
+ mappedName = "java:comp/ORB";
+ }
+ }
+ }
+ catch(ClassNotFoundException e)
+ {
+ throw new EJBException(e);
+ }
+
+ String encName = "env/" + envRef.getResourceEnvRefName();
+ if (mappedName == null || mappedName.equals(""))
+ {
+ throw new RuntimeException("mapped-name is required for " + envRef.getResourceEnvRefName() + " of deployment " + container.getIdentifier());
+ }
+ Utils.injectionTarget(encName, envRef, container);
+ }
+ }
+
+ private static void loadXmlMessageDestinationRefs(InjectionContainer container, Collection<MessageDestinationReferenceMetaData> refs)
+ {
+ for (MessageDestinationReferenceMetaData envRef : refs)
+ {
+ String encName = "env/" + envRef.getMessageDestinationRefName();
+ String jndiName = envRef.getMappedName();
+ if (jndiName == null || jndiName.equals(""))
+ {
+ // Look for a message-destination-link
+ jndiName = envRef.getResolvedJndiName();
+ if (jndiName == null)
+ throw new RuntimeException("message-destination has no jndi-name/resolved-jndi-name " + envRef);
+ }
+
+ Utils.injectionTarget(encName, envRef, container);
+ }
+ }
+
+ public void loadXml(X xml, InjectionContainer container)
+ {
+ if (xml == null)
+ return;
+ if (xml.getMessageDestinationReferences() != null)
+ loadXmlMessageDestinationRefs(container, xml.getMessageDestinationReferences());
+ if (xml.getResourceEnvironmentReferences() != null)
+ loadXmlResourceEnvRefs(container, xml.getResourceEnvironmentReferences());
+ if (xml.getResourceReferences() != null)
+ loadXmlResourceRefs(container, xml.getResourceReferences());
+ if (xml.getEnvironmentEntries() != null)
+ loadEnvEntry(container, xml.getEnvironmentEntries());
+ }
+
+ public void handleClassAnnotations(Class<?> clazz, InjectionContainer container)
+ {
+ throw new IllegalStateException("Annotations are not handled in the client");
+ }
+ public void handleMethodAnnotations(Method method, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
+ {
+ throw new IllegalStateException("Annotations are not handled in the client");
+ }
+ public void handleFieldAnnotations(Field field, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
+ {
+ throw new IllegalStateException("Annotations are not handled in the client");
+ }
+}
Property changes on: trunk/ejb3/src/main/org/jboss/ejb3/client/ClientResourceHandler.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/ejb3/src/main/org/jboss/ejb3/client/JndiDependencyItem.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/client/JndiDependencyItem.java 2008-11-14 14:58:15 UTC (rev 81052)
+++ trunk/ejb3/src/main/org/jboss/ejb3/client/JndiDependencyItem.java 2008-11-14 14:59:40 UTC (rev 81053)
@@ -1,116 +1,116 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * 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.util.Properties;
-
-import javax.naming.InitialContext;
-import javax.naming.NameNotFoundException;
-
-import org.jboss.dependency.plugins.AbstractDependencyItem;
-import org.jboss.dependency.spi.Controller;
-import org.jboss.dependency.spi.ControllerContext;
-import org.jboss.dependency.spi.ControllerState;
-import org.jboss.dependency.spi.DependencyItem;
-import org.jboss.logging.Logger;
-import org.jboss.util.JBossStringBuilder;
-
-/**
- * @author Scott.Stark at jboss.org
- * @version $Revision:$
- */
-public class JndiDependencyItem extends AbstractDependencyItem
- implements DependencyItem
-{
-private static final Logger log = Logger.getLogger(JndiDependencyItem.class);
-
- /** The demand jndi name */
- private String jndiName;
- private Properties env;
- private String classLoaderName;
-
- JndiDependencyItem(String jndiName, Properties env, String classLoaderName)
- {
- this.jndiName = jndiName;
- this.env = env;
- this.classLoaderName = classLoaderName;
- }
-
- @Override
- public boolean resolve(Controller controller)
- {
- ClassLoader tcl = Thread.currentThread().getContextClassLoader();
- try
- {
- ControllerContext cc = controller.getContext(classLoaderName, ControllerState.INSTALLED);
- ClassLoader loader = (ClassLoader) cc.getTarget();
- if(loader != null)
- Thread.currentThread().setContextClassLoader(loader);
- Properties jndiEnv = env;
- if(jndiEnv == null)
- jndiEnv = System.getProperties();
- InitialContext ctx = new InitialContext(jndiEnv);
- Object depends = ctx.lookup(jndiName);
- super.setIDependOn(depends);
- log.info("Resolved("+jndiName+")"+depends);
- setResolved(true);
- return isResolved();
- }
- catch(NameNotFoundException e)
- {
- log.debug("Jndi lookup failed", e);
- }
- catch(Throwable ignored)
- {
- log.debug("Unexpected error", ignored);
- }
- finally
- {
- Thread.currentThread().setContextClassLoader(tcl);
- }
- setResolved(false);
- return isResolved();
- }
-
- @Override
- public void toString(JBossStringBuilder buffer)
- {
- super.toString(buffer);
- buffer.append(" depend=").append(jndiName);
- }
-
- @Override
- public void toShortString(JBossStringBuilder buffer)
- {
- buffer.append(getName()).append(" depend ").append(jndiName);
- }
-
- @Override
- public String toHumanReadableString()
- {
- StringBuilder builder = new StringBuilder();
- builder.append("JndiDepends: '");
- builder.append(jndiName);
- builder.append("'");
- return builder.toString();
- }
-}
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * 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.util.Properties;
+
+import javax.naming.InitialContext;
+import javax.naming.NameNotFoundException;
+
+import org.jboss.dependency.plugins.AbstractDependencyItem;
+import org.jboss.dependency.spi.Controller;
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.dependency.spi.DependencyItem;
+import org.jboss.logging.Logger;
+import org.jboss.util.JBossStringBuilder;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class JndiDependencyItem extends AbstractDependencyItem
+ implements DependencyItem
+{
+private static final Logger log = Logger.getLogger(JndiDependencyItem.class);
+
+ /** The demand jndi name */
+ private String jndiName;
+ private Properties env;
+ private String classLoaderName;
+
+ JndiDependencyItem(String jndiName, Properties env, String classLoaderName)
+ {
+ this.jndiName = jndiName;
+ this.env = env;
+ this.classLoaderName = classLoaderName;
+ }
+
+ @Override
+ public boolean resolve(Controller controller)
+ {
+ ClassLoader tcl = Thread.currentThread().getContextClassLoader();
+ try
+ {
+ ControllerContext cc = controller.getContext(classLoaderName, ControllerState.INSTALLED);
+ ClassLoader loader = (ClassLoader) cc.getTarget();
+ if(loader != null)
+ Thread.currentThread().setContextClassLoader(loader);
+ Properties jndiEnv = env;
+ if(jndiEnv == null)
+ jndiEnv = System.getProperties();
+ InitialContext ctx = new InitialContext(jndiEnv);
+ Object depends = ctx.lookup(jndiName);
+ super.setIDependOn(depends);
+ log.info("Resolved("+jndiName+")"+depends);
+ setResolved(true);
+ return isResolved();
+ }
+ catch(NameNotFoundException e)
+ {
+ log.debug("Jndi lookup failed", e);
+ }
+ catch(Throwable ignored)
+ {
+ log.debug("Unexpected error", ignored);
+ }
+ finally
+ {
+ Thread.currentThread().setContextClassLoader(tcl);
+ }
+ setResolved(false);
+ return isResolved();
+ }
+
+ @Override
+ public void toString(JBossStringBuilder buffer)
+ {
+ super.toString(buffer);
+ buffer.append(" depend=").append(jndiName);
+ }
+
+ @Override
+ public void toShortString(JBossStringBuilder buffer)
+ {
+ buffer.append(getName()).append(" depend ").append(jndiName);
+ }
+
+ @Override
+ public String toHumanReadableString()
+ {
+ StringBuilder builder = new StringBuilder();
+ builder.append("JndiDepends: '");
+ builder.append(jndiName);
+ builder.append("'");
+ return builder.toString();
+ }
+}
Property changes on: trunk/ejb3/src/main/org/jboss/ejb3/client/JndiDependencyItem.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/ejb3/src/main/org/jboss/ejb3/client/JndiDependencyValueMetaData.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/client/JndiDependencyValueMetaData.java 2008-11-14 14:58:15 UTC (rev 81052)
+++ trunk/ejb3/src/main/org/jboss/ejb3/client/JndiDependencyValueMetaData.java 2008-11-14 14:59:40 UTC (rev 81053)
@@ -1,66 +1,66 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * 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.util.Properties;
-
-import org.jboss.beans.metadata.plugins.AbstractDependencyValueMetaData;
-import org.jboss.beans.metadata.spi.MetaDataVisitor;
-import org.jboss.kernel.spi.dependency.KernelControllerContext;
-import org.jboss.reflect.spi.TypeInfo;
-
-/**
- * @author Scott.Stark at jboss.org
- * @version $Revision:$
- */
-public class JndiDependencyValueMetaData extends AbstractDependencyValueMetaData
-{
- private static final long serialVersionUID = 1;
-
- /** The demand jndi name */
- private String jndiName;
- private Properties env;
- private String classLoaderName;
- private JndiDependencyItem depends;
-
- public JndiDependencyValueMetaData(String jndiName, Properties env, String classLoaderName)
- {
- this.jndiName = jndiName;
- this.env = env;
- this.classLoaderName = classLoaderName;
- }
-
- @Override
- public void initialVisit(MetaDataVisitor visitor)
- {
- depends = new JndiDependencyItem(jndiName, env, classLoaderName);
- visitor.addDependency(depends);
- visitor.initialVisit(this);
- }
-
- @Override
- public Object getValue(TypeInfo info, ClassLoader cl) throws Throwable
- {
- return depends.getIDependOn();
- }
-
-}
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * 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.util.Properties;
+
+import org.jboss.beans.metadata.plugins.AbstractDependencyValueMetaData;
+import org.jboss.beans.metadata.spi.MetaDataVisitor;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.reflect.spi.TypeInfo;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class JndiDependencyValueMetaData extends AbstractDependencyValueMetaData
+{
+ private static final long serialVersionUID = 1;
+
+ /** The demand jndi name */
+ private String jndiName;
+ private Properties env;
+ private String classLoaderName;
+ private JndiDependencyItem depends;
+
+ public JndiDependencyValueMetaData(String jndiName, Properties env, String classLoaderName)
+ {
+ this.jndiName = jndiName;
+ this.env = env;
+ this.classLoaderName = classLoaderName;
+ }
+
+ @Override
+ public void initialVisit(MetaDataVisitor visitor)
+ {
+ depends = new JndiDependencyItem(jndiName, env, classLoaderName);
+ visitor.addDependency(depends);
+ visitor.initialVisit(this);
+ }
+
+ @Override
+ public Object getValue(TypeInfo info, ClassLoader cl) throws Throwable
+ {
+ return depends.getIDependOn();
+ }
+
+}
Property changes on: trunk/ejb3/src/main/org/jboss/ejb3/client/JndiDependencyValueMetaData.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/ejb3/src/main/org/jboss/ejb3/client/JndiPropertyInjector.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/client/JndiPropertyInjector.java 2008-11-14 14:58:15 UTC (rev 81052)
+++ trunk/ejb3/src/main/org/jboss/ejb3/client/JndiPropertyInjector.java 2008-11-14 14:59:40 UTC (rev 81053)
@@ -1,169 +1,169 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * 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.reflect.Method;
-import java.net.URL;
-import java.security.CodeSource;
-import java.security.ProtectionDomain;
-
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-
-import org.jboss.ejb3.BeanContext;
-import org.jboss.injection.AbstractPropertyInjector;
-import org.jboss.injection.PojoInjector;
-import org.jboss.injection.lang.reflect.BeanProperty;
-import org.jboss.logging.Logger;
-
-/**
- * Injects a jndi dependency into a bean property.
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @author Scott.Stark at jboss.org
- * @version $Revision: $
- */
-public class JndiPropertyInjector extends AbstractPropertyInjector
- implements PojoInjector
-{
- private static final Logger log = Logger.getLogger(JndiPropertyInjector.class);
-
- private String jndiName;
- private Context ctx;
-
- public JndiPropertyInjector(BeanProperty property, String jndiName,
- Context ctx)
- {
- super(property);
- this.jndiName = jndiName;
- this.ctx = ctx;
- }
-
- public void inject(BeanContext bctx)
- {
- }
-
- public Class<?> getInjectionClass()
- {
- return property.getType();
- }
-
- public void inject(BeanContext bctx, Object instance)
- {
- }
-
- public void inject(Object instance)
- {
- Object value = lookup(jndiName);
- log.trace("injecting " + value + " from " + jndiName + " into " + property + " of " + instance);
- try
- {
- property.set(instance, value);
- }
- catch(IllegalArgumentException e)
- {
- Class c1 = value.getClass();
- StringBuffer buffer = new StringBuffer("Jndi value '"+jndiName+"' class info:");
- displayClassInfo(c1, buffer);
- log.debug("Failed to inject jndi property, "+buffer);
- Class c2 = property.getType();
- buffer.setLength(0);
- buffer.append("Field "+property.getName()+" class info:");
- displayClassInfo(c2, buffer);
- log.debug(", "+buffer);
- throw e;
- }
- }
-
- protected Object lookup(String jndiName)
- {
- Object dependency = null;
- boolean trace = log.isTraceEnabled();
- try
- {
- if(trace)
- log.trace("Looking for enc entry: "+jndiName);
- dependency = ctx.lookup(jndiName);
- if(trace)
- log.trace("Success: "+dependency);
- }
- catch (NamingException e)
- {
- // Try as a global jndi name
- if(trace)
- log.trace("Failed enc lookup: "+e.getExplanation());
- try
- {
- if(trace)
- log.trace("Failed trying as global entry: "+jndiName);
- InitialContext ictx = new InitialContext(ctx.getEnvironment());
- dependency = ictx.lookup(jndiName);
- if(trace)
- log.trace("Success: "+dependency);
- }
- catch(NamingException e2)
- {
- if(trace)
- log.trace("Failed global lookup: "+e2.getExplanation());
- }
-
- if(dependency == null)
- {
- Throwable cause = e;
- while(cause.getCause() != null)
- cause = cause.getCause();
- throw new RuntimeException("Unable to inject jndi dependency: " + jndiName + " into property " + property + ": " + cause.getMessage(), e);
- }
- }
- return dependency;
- }
-
- static void displayClassInfo(Class clazz, StringBuffer results)
- {
- // Print out some codebase info for the ProbeHome
- ClassLoader cl = clazz.getClassLoader();
- results.append("\n"+clazz.getName()+".ClassLoader="+cl);
- CodeSource clazzCS = clazz.getProtectionDomain().getCodeSource();
- if( clazzCS != null )
- results.append("\n++++CodeSource: "+clazzCS);
- else
- results.append("\n++++Null CodeSource");
-
- results.append("\nImplemented Interfaces:");
- Class[] ifaces = clazz.getInterfaces();
- for(int i = 0; i < ifaces.length; i ++)
- {
- results.append("\n++"+ifaces[i]);
- ClassLoader loader = ifaces[i].getClassLoader();
- results.append("\n++++ClassLoader: "+loader);
- ProtectionDomain pd = ifaces[i].getProtectionDomain();
- CodeSource cs = pd.getCodeSource();
- if( cs != null )
- results.append("\n++++CodeSource: "+cs);
- else
- results.append("\n++++Null CodeSource");
- }
- }
-
-}
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * 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.reflect.Method;
+import java.net.URL;
+import java.security.CodeSource;
+import java.security.ProtectionDomain;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.jboss.ejb3.BeanContext;
+import org.jboss.injection.AbstractPropertyInjector;
+import org.jboss.injection.PojoInjector;
+import org.jboss.injection.lang.reflect.BeanProperty;
+import org.jboss.logging.Logger;
+
+/**
+ * Injects a jndi dependency into a bean property.
+ *
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: $
+ */
+public class JndiPropertyInjector extends AbstractPropertyInjector
+ implements PojoInjector
+{
+ private static final Logger log = Logger.getLogger(JndiPropertyInjector.class);
+
+ private String jndiName;
+ private Context ctx;
+
+ public JndiPropertyInjector(BeanProperty property, String jndiName,
+ Context ctx)
+ {
+ super(property);
+ this.jndiName = jndiName;
+ this.ctx = ctx;
+ }
+
+ public void inject(BeanContext bctx)
+ {
+ }
+
+ public Class<?> getInjectionClass()
+ {
+ return property.getType();
+ }
+
+ public void inject(BeanContext bctx, Object instance)
+ {
+ }
+
+ public void inject(Object instance)
+ {
+ Object value = lookup(jndiName);
+ log.trace("injecting " + value + " from " + jndiName + " into " + property + " of " + instance);
+ try
+ {
+ property.set(instance, value);
+ }
+ catch(IllegalArgumentException e)
+ {
+ Class c1 = value.getClass();
+ StringBuffer buffer = new StringBuffer("Jndi value '"+jndiName+"' class info:");
+ displayClassInfo(c1, buffer);
+ log.debug("Failed to inject jndi property, "+buffer);
+ Class c2 = property.getType();
+ buffer.setLength(0);
+ buffer.append("Field "+property.getName()+" class info:");
+ displayClassInfo(c2, buffer);
+ log.debug(", "+buffer);
+ throw e;
+ }
+ }
+
+ protected Object lookup(String jndiName)
+ {
+ Object dependency = null;
+ boolean trace = log.isTraceEnabled();
+ try
+ {
+ if(trace)
+ log.trace("Looking for enc entry: "+jndiName);
+ dependency = ctx.lookup(jndiName);
+ if(trace)
+ log.trace("Success: "+dependency);
+ }
+ catch (NamingException e)
+ {
+ // Try as a global jndi name
+ if(trace)
+ log.trace("Failed enc lookup: "+e.getExplanation());
+ try
+ {
+ if(trace)
+ log.trace("Failed trying as global entry: "+jndiName);
+ InitialContext ictx = new InitialContext(ctx.getEnvironment());
+ dependency = ictx.lookup(jndiName);
+ if(trace)
+ log.trace("Success: "+dependency);
+ }
+ catch(NamingException e2)
+ {
+ if(trace)
+ log.trace("Failed global lookup: "+e2.getExplanation());
+ }
+
+ if(dependency == null)
+ {
+ Throwable cause = e;
+ while(cause.getCause() != null)
+ cause = cause.getCause();
+ throw new RuntimeException("Unable to inject jndi dependency: " + jndiName + " into property " + property + ": " + cause.getMessage(), e);
+ }
+ }
+ return dependency;
+ }
+
+ static void displayClassInfo(Class clazz, StringBuffer results)
+ {
+ // Print out some codebase info for the ProbeHome
+ ClassLoader cl = clazz.getClassLoader();
+ results.append("\n"+clazz.getName()+".ClassLoader="+cl);
+ CodeSource clazzCS = clazz.getProtectionDomain().getCodeSource();
+ if( clazzCS != null )
+ results.append("\n++++CodeSource: "+clazzCS);
+ else
+ results.append("\n++++Null CodeSource");
+
+ results.append("\nImplemented Interfaces:");
+ Class[] ifaces = clazz.getInterfaces();
+ for(int i = 0; i < ifaces.length; i ++)
+ {
+ results.append("\n++"+ifaces[i]);
+ ClassLoader loader = ifaces[i].getClassLoader();
+ results.append("\n++++ClassLoader: "+loader);
+ ProtectionDomain pd = ifaces[i].getProtectionDomain();
+ CodeSource cs = pd.getCodeSource();
+ if( cs != null )
+ results.append("\n++++CodeSource: "+cs);
+ else
+ results.append("\n++++Null CodeSource");
+ }
+ }
+
+}
Property changes on: trunk/ejb3/src/main/org/jboss/ejb3/client/JndiPropertyInjector.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/ejb3/src/main/org/jboss/ejb3/client/NoopDependencyPolicy.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/client/NoopDependencyPolicy.java 2008-11-14 14:58:15 UTC (rev 81052)
+++ trunk/ejb3/src/main/org/jboss/ejb3/client/NoopDependencyPolicy.java 2008-11-14 14:59:40 UTC (rev 81053)
@@ -1,99 +1,99 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * 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.util.Collections;
-import java.util.Set;
-
-import org.jboss.beans.metadata.spi.DemandMetaData;
-import org.jboss.beans.metadata.spi.DependencyMetaData;
-import org.jboss.beans.metadata.spi.SupplyMetaData;
-import org.jboss.ejb3.deployers.JBoss5DependencyPolicy;
-import org.jboss.ejb3.javaee.JavaEEComponent;
-
-/**
- * @author Scott.Stark at jboss.org
- * @version $Revision:$
- */
-public class NoopDependencyPolicy
- extends JBoss5DependencyPolicy
-{
-
- public NoopDependencyPolicy(JavaEEComponent component)
- {
- super(component);
- }
-
- @Override
- public void addDependency(Class<?> businessInterface)
- {
- }
-
- @Override
- public void addDependency(DemandMetaData dependency)
- {
- }
-
- @Override
- public void addDependency(DependencyMetaData dependency)
- {
- }
-
- @Override
- public void addDependency(String ejbLink, Class<?> businessInterface)
- {
- }
-
- @Override
- public void addDependency(String dependency)
- {
- }
-
- @Override
- public void addJNDIName(String name)
- {
- }
-
- @Override
- public void addSupply(Class<?> businessInterface)
- {
- }
-
- @Override
- public Set<DemandMetaData> getDemands()
- {
- return Collections.emptySet();
- }
-
- @Override
- public Set<DependencyMetaData> getDependencies()
- {
- return Collections.emptySet();
- }
-
- @Override
- public Set<SupplyMetaData> getSupplies()
- {
- return Collections.emptySet();
- }
-
-}
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * 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.util.Collections;
+import java.util.Set;
+
+import org.jboss.beans.metadata.spi.DemandMetaData;
+import org.jboss.beans.metadata.spi.DependencyMetaData;
+import org.jboss.beans.metadata.spi.SupplyMetaData;
+import org.jboss.ejb3.deployers.JBoss5DependencyPolicy;
+import org.jboss.ejb3.javaee.JavaEEComponent;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class NoopDependencyPolicy
+ extends JBoss5DependencyPolicy
+{
+
+ public NoopDependencyPolicy(JavaEEComponent component)
+ {
+ super(component);
+ }
+
+ @Override
+ public void addDependency(Class<?> businessInterface)
+ {
+ }
+
+ @Override
+ public void addDependency(DemandMetaData dependency)
+ {
+ }
+
+ @Override
+ public void addDependency(DependencyMetaData dependency)
+ {
+ }
+
+ @Override
+ public void addDependency(String ejbLink, Class<?> businessInterface)
+ {
+ }
+
+ @Override
+ public void addDependency(String dependency)
+ {
+ }
+
+ @Override
+ public void addJNDIName(String name)
+ {
+ }
+
+ @Override
+ public void addSupply(Class<?> businessInterface)
+ {
+ }
+
+ @Override
+ public Set<DemandMetaData> getDemands()
+ {
+ return Collections.emptySet();
+ }
+
+ @Override
+ public Set<DependencyMetaData> getDependencies()
+ {
+ return Collections.emptySet();
+ }
+
+ @Override
+ public Set<SupplyMetaData> getSupplies()
+ {
+ return Collections.emptySet();
+ }
+
+}
Property changes on: trunk/ejb3/src/main/org/jboss/ejb3/client/NoopDependencyPolicy.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/ejb3/src/main/org/jboss/ejb3/client/URLInjectorFactory.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/client/URLInjectorFactory.java 2008-11-14 14:58:15 UTC (rev 81052)
+++ trunk/ejb3/src/main/org/jboss/ejb3/client/URLInjectorFactory.java 2008-11-14 14:59:40 UTC (rev 81053)
@@ -1,49 +1,49 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * 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 org.jboss.injection.Injector;
-import org.jboss.injection.InjectorFactory;
-import org.jboss.injection.lang.reflect.BeanProperty;
-
-/**
- * @author Scott.Stark at jboss.org
- * @version $Revision:$
- */
-public class URLInjectorFactory
- implements InjectorFactory<URLPropertyInjector>
-{
- private URL url;
-
- URLInjectorFactory(URL url)
- {
- this.url = url;
- }
-
- public URLPropertyInjector create(BeanProperty property)
- {
- return new URLPropertyInjector(property, url);
- }
-
-}
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * 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 org.jboss.injection.Injector;
+import org.jboss.injection.InjectorFactory;
+import org.jboss.injection.lang.reflect.BeanProperty;
+
+/**
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class URLInjectorFactory
+ implements InjectorFactory<URLPropertyInjector>
+{
+ private URL url;
+
+ URLInjectorFactory(URL url)
+ {
+ this.url = url;
+ }
+
+ public URLPropertyInjector create(BeanProperty property)
+ {
+ return new URLPropertyInjector(property, url);
+ }
+
+}
Property changes on: trunk/ejb3/src/main/org/jboss/ejb3/client/URLInjectorFactory.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/ejb3/src/main/org/jboss/ejb3/client/URLPropertyInjector.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/client/URLPropertyInjector.java 2008-11-14 14:58:15 UTC (rev 81052)
+++ trunk/ejb3/src/main/org/jboss/ejb3/client/URLPropertyInjector.java 2008-11-14 14:59:40 UTC (rev 81053)
@@ -1,49 +1,49 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * 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 org.jboss.injection.AbstractPropertyInjector;
-import org.jboss.injection.lang.reflect.BeanProperty;
-
-/**
- * Injects a URL into a bean property
- *
- * @author Scott.Stark at jboss.org
- * @version $Revision:$
- */
-public class URLPropertyInjector extends AbstractPropertyInjector
-{
- private URL url;
-
- URLPropertyInjector(BeanProperty property, URL url)
- {
- super(property);
- this.url = url;
- }
-
- public void inject(Object instance)
- {
- property.set(instance, url);
- }
-}
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * 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 org.jboss.injection.AbstractPropertyInjector;
+import org.jboss.injection.lang.reflect.BeanProperty;
+
+/**
+ * Injects a URL into a bean property
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class URLPropertyInjector extends AbstractPropertyInjector
+{
+ private URL url;
+
+ URLPropertyInjector(BeanProperty property, URL url)
+ {
+ super(property);
+ this.url = url;
+ }
+
+ public void inject(Object instance)
+ {
+ property.set(instance, url);
+ }
+}
Property changes on: trunk/ejb3/src/main/org/jboss/ejb3/client/URLPropertyInjector.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/ejb3/src/main/org/jboss/ejb3/client/Utils.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/client/Utils.java 2008-11-14 14:58:15 UTC (rev 81052)
+++ trunk/ejb3/src/main/org/jboss/ejb3/client/Utils.java 2008-11-14 14:59:40 UTC (rev 81053)
@@ -1,159 +1,159 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * 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.reflect.AccessibleObject;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.Collection;
-import java.util.List;
-
-import org.jboss.injection.InjectionContainer;
-import org.jboss.injection.Injector;
-import org.jboss.injection.InjectorFactory;
-import org.jboss.injection.lang.reflect.BeanProperty;
-import org.jboss.injection.lang.reflect.BeanPropertyFactory;
-import org.jboss.metadata.javaee.spec.ResourceInjectionMetaData;
-import org.jboss.metadata.javaee.spec.ResourceInjectionTargetMetaData;
-
-/**
- * Injection utilities
- *
- * @author Scott.Stark at jboss.org
- * @version $Revision:$
- */
-public class Utils
-{
- /**
- * Create and add multiple injectors for injection targets.
- *
- * @param injectors the list on which to add injectors
- * @param classLoader the class loader to resolve an injection target
- * @param factory the injector factory
- * @param injectionTargets the injection targets
- */
- public static void createInjectors(List<Injector> injectors,
- ClassLoader classLoader,
- InjectorFactory<?> factory,
- Collection<ResourceInjectionTargetMetaData> injectionTargets)
- {
- if(injectionTargets == null)
- return;
-
- for(ResourceInjectionTargetMetaData injectionTarget : injectionTargets)
- {
- AccessibleObject ao = findInjectionTarget(classLoader, injectionTarget);
- BeanProperty property = BeanPropertyFactory.create(ao);
- injectors.add(factory.create(property));
- }
- }
-
- public static Class<?> injectionTarget(String encName,
- ResourceInjectionMetaData ref,
- InjectionContainer container)
- {
- Class<?> injectionType = null;
-
- if(ref.getInjectionTargets() == null)
- return injectionType;
-
- ClassLoader loader = container.getClassloader();
- for(ResourceInjectionTargetMetaData injectionTarget : ref.getInjectionTargets())
- {
- AccessibleObject ao = findInjectionTarget(loader, injectionTarget);
- BeanProperty prop = BeanPropertyFactory.create(ao);
- JndiPropertyInjector propInjector = new JndiPropertyInjector(prop, encName, container.getEnc());
- container.getInjectors().add(propInjector);
- // Validate all the injection types are consistent
- Class<?> type;
- if (ao instanceof Field)
- {
- type = ((Field) ao).getType();
- }
- else
- {
- type = ((Method) ao).getParameterTypes()[0];
- }
- if(injectionType == null)
- injectionType = type;
- else
- {
- if(!injectionType.equals(type))
- throw new IllegalStateException("Found multiple injection targets with different types");
- }
- }
-
- return injectionType;
- }
- public static AccessibleObject findInjectionTarget(ClassLoader loader, ResourceInjectionTargetMetaData target)
- {
- Class<?> clazz = null;
- try
- {
- clazz = loader.loadClass(target.getInjectionTargetClass());
- }
- catch (ClassNotFoundException e)
- {
- throw new RuntimeException("<injection-target> class: " + target.getInjectionTargetClass() + " was not found in deployment");
- }
-
- for (Field field : clazz.getDeclaredFields())
- {
- if (target.getInjectionTargetName().equals(field.getName()))
- return field;
- }
-
- for (Method method : clazz.getDeclaredMethods())
- {
- if (method.getName().equals(target.getInjectionTargetName()))
- return method;
- }
-
- throw new RuntimeException("<injection-target> could not be found: " + target.getInjectionTargetClass() + "." + target.getInjectionTargetName());
- }
-
- public static String getEncName(Class type)
- {
- return "env/" + type.getName();
- }
-
- public static String getEncName(Method method)
- {
- String encName = method.getName().substring(3);
- if (encName.length() > 1)
- {
- encName = encName.substring(0, 1).toLowerCase() + encName.substring(1);
- }
- else
- {
- encName = encName.toLowerCase();
- }
-
- encName = getEncName(method.getDeclaringClass()) + "/" + encName;
- return encName;
- }
-
- public static String getEncName(Field field)
- {
- return getEncName(field.getDeclaringClass()) + "/" + field.getName();
- }
-}
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * 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.reflect.AccessibleObject;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.Collection;
+import java.util.List;
+
+import org.jboss.injection.InjectionContainer;
+import org.jboss.injection.Injector;
+import org.jboss.injection.InjectorFactory;
+import org.jboss.injection.lang.reflect.BeanProperty;
+import org.jboss.injection.lang.reflect.BeanPropertyFactory;
+import org.jboss.metadata.javaee.spec.ResourceInjectionMetaData;
+import org.jboss.metadata.javaee.spec.ResourceInjectionTargetMetaData;
+
+/**
+ * Injection utilities
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class Utils
+{
+ /**
+ * Create and add multiple injectors for injection targets.
+ *
+ * @param injectors the list on which to add injectors
+ * @param classLoader the class loader to resolve an injection target
+ * @param factory the injector factory
+ * @param injectionTargets the injection targets
+ */
+ public static void createInjectors(List<Injector> injectors,
+ ClassLoader classLoader,
+ InjectorFactory<?> factory,
+ Collection<ResourceInjectionTargetMetaData> injectionTargets)
+ {
+ if(injectionTargets == null)
+ return;
+
+ for(ResourceInjectionTargetMetaData injectionTarget : injectionTargets)
+ {
+ AccessibleObject ao = findInjectionTarget(classLoader, injectionTarget);
+ BeanProperty property = BeanPropertyFactory.create(ao);
+ injectors.add(factory.create(property));
+ }
+ }
+
+ public static Class<?> injectionTarget(String encName,
+ ResourceInjectionMetaData ref,
+ InjectionContainer container)
+ {
+ Class<?> injectionType = null;
+
+ if(ref.getInjectionTargets() == null)
+ return injectionType;
+
+ ClassLoader loader = container.getClassloader();
+ for(ResourceInjectionTargetMetaData injectionTarget : ref.getInjectionTargets())
+ {
+ AccessibleObject ao = findInjectionTarget(loader, injectionTarget);
+ BeanProperty prop = BeanPropertyFactory.create(ao);
+ JndiPropertyInjector propInjector = new JndiPropertyInjector(prop, encName, container.getEnc());
+ container.getInjectors().add(propInjector);
+ // Validate all the injection types are consistent
+ Class<?> type;
+ if (ao instanceof Field)
+ {
+ type = ((Field) ao).getType();
+ }
+ else
+ {
+ type = ((Method) ao).getParameterTypes()[0];
+ }
+ if(injectionType == null)
+ injectionType = type;
+ else
+ {
+ if(!injectionType.equals(type))
+ throw new IllegalStateException("Found multiple injection targets with different types");
+ }
+ }
+
+ return injectionType;
+ }
+ public static AccessibleObject findInjectionTarget(ClassLoader loader, ResourceInjectionTargetMetaData target)
+ {
+ Class<?> clazz = null;
+ try
+ {
+ clazz = loader.loadClass(target.getInjectionTargetClass());
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new RuntimeException("<injection-target> class: " + target.getInjectionTargetClass() + " was not found in deployment");
+ }
+
+ for (Field field : clazz.getDeclaredFields())
+ {
+ if (target.getInjectionTargetName().equals(field.getName()))
+ return field;
+ }
+
+ for (Method method : clazz.getDeclaredMethods())
+ {
+ if (method.getName().equals(target.getInjectionTargetName()))
+ return method;
+ }
+
+ throw new RuntimeException("<injection-target> could not be found: " + target.getInjectionTargetClass() + "." + target.getInjectionTargetName());
+ }
+
+ public static String getEncName(Class type)
+ {
+ return "env/" + type.getName();
+ }
+
+ public static String getEncName(Method method)
+ {
+ String encName = method.getName().substring(3);
+ if (encName.length() > 1)
+ {
+ encName = encName.substring(0, 1).toLowerCase() + encName.substring(1);
+ }
+ else
+ {
+ encName = encName.toLowerCase();
+ }
+
+ encName = getEncName(method.getDeclaringClass()) + "/" + encName;
+ return encName;
+ }
+
+ public static String getEncName(Field field)
+ {
+ return getEncName(field.getDeclaringClass()) + "/" + field.getName();
+ }
+}
Property changes on: trunk/ejb3/src/main/org/jboss/ejb3/client/Utils.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/ejb3/src/main/org/jboss/ejb3/client/injection/ClientPersistenceUnitHandler.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/client/injection/ClientPersistenceUnitHandler.java 2008-11-14 14:58:15 UTC (rev 81052)
+++ trunk/ejb3/src/main/org/jboss/ejb3/client/injection/ClientPersistenceUnitHandler.java 2008-11-14 14:59:40 UTC (rev 81053)
@@ -1,75 +1,75 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ejb3.client.injection;
-
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.Map;
-
-import org.jboss.ejb3.client.Utils;
-import org.jboss.injection.InjectionContainer;
-import org.jboss.injection.InjectionHandler;
-import org.jboss.injection.Injector;
-import org.jboss.metadata.javaee.spec.PersistenceUnitReferenceMetaData;
-import org.jboss.metadata.javaee.spec.RemoteEnvironment;
-
-/**
- * Injection of persistence units into application clients.
- *
- * Only setup injection of persistence units, the enc setup is done on the server.
- * It's expected that the meta data is complete and no annotation handling should be performed.
- *
- * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
- * @version $Revision: $
- */
-public class ClientPersistenceUnitHandler<X extends RemoteEnvironment> implements InjectionHandler<X>
-{
- public void handleClassAnnotations(Class<?> clazz, InjectionContainer container)
- {
- throw new IllegalStateException("Annotations are not handled");
- }
-
- public void handleFieldAnnotations(Field field, InjectionContainer container,
- Map<AccessibleObject, Injector> injectors)
- {
- throw new IllegalStateException("Annotations are not handled");
- }
-
- public void handleMethodAnnotations(Method method, InjectionContainer container,
- Map<AccessibleObject, Injector> injectors)
- {
- throw new IllegalStateException("Annotations are not handled");
- }
-
- public void loadXml(X xml, InjectionContainer container)
- {
- if (xml == null) return;
- if (xml.getPersistenceUnitRefs() == null) return;
-
- for (PersistenceUnitReferenceMetaData ref : xml.getPersistenceUnitRefs())
- {
- String encName = "env/" + ref.getPersistenceUnitRefName();
- Utils.injectionTarget(encName, ref, container);
- }
- }
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.client.injection;
+
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.Map;
+
+import org.jboss.ejb3.client.Utils;
+import org.jboss.injection.InjectionContainer;
+import org.jboss.injection.InjectionHandler;
+import org.jboss.injection.Injector;
+import org.jboss.metadata.javaee.spec.PersistenceUnitReferenceMetaData;
+import org.jboss.metadata.javaee.spec.RemoteEnvironment;
+
+/**
+ * Injection of persistence units into application clients.
+ *
+ * Only setup injection of persistence units, the enc setup is done on the server.
+ * It's expected that the meta data is complete and no annotation handling should be performed.
+ *
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class ClientPersistenceUnitHandler<X extends RemoteEnvironment> implements InjectionHandler<X>
+{
+ public void handleClassAnnotations(Class<?> clazz, InjectionContainer container)
+ {
+ throw new IllegalStateException("Annotations are not handled");
+ }
+
+ public void handleFieldAnnotations(Field field, InjectionContainer container,
+ Map<AccessibleObject, Injector> injectors)
+ {
+ throw new IllegalStateException("Annotations are not handled");
+ }
+
+ public void handleMethodAnnotations(Method method, InjectionContainer container,
+ Map<AccessibleObject, Injector> injectors)
+ {
+ throw new IllegalStateException("Annotations are not handled");
+ }
+
+ public void loadXml(X xml, InjectionContainer container)
+ {
+ if (xml == null) return;
+ if (xml.getPersistenceUnitRefs() == null) return;
+
+ for (PersistenceUnitReferenceMetaData ref : xml.getPersistenceUnitRefs())
+ {
+ String encName = "env/" + ref.getPersistenceUnitRefName();
+ Utils.injectionTarget(encName, ref, container);
+ }
+ }
+}
Property changes on: trunk/ejb3/src/main/org/jboss/ejb3/client/injection/ClientPersistenceUnitHandler.java
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: trunk/ejb3/src/main/org/jboss/ejb3/client/package.html
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: trunk/ejb3/src/main/org/jboss/ejb3/clientmodule/ClientENCInjectionContainer.java
___________________________________________________________________
Name: svn:eol-style
- LF
+ native
Property changes on: trunk/ejb3/src/main/org/jboss/ejb3/clientmodule/ClientEjbResolver.java
___________________________________________________________________
Name: svn:eol-style
- LF
+ native
Modified: trunk/ejb3/src/main/org/jboss/ejb3/clientmodule/EJBRemoteHandler.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/clientmodule/EJBRemoteHandler.java 2008-11-14 14:58:15 UTC (rev 81052)
+++ trunk/ejb3/src/main/org/jboss/ejb3/clientmodule/EJBRemoteHandler.java 2008-11-14 14:59:40 UTC (rev 81053)
@@ -1,338 +1,338 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2007, Red Hat Middleware LLC, and individual contributors
- * 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.reflect.AccessibleObject;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.Collection;
-import java.util.Map;
-
-import javax.ejb.EJB;
-import javax.ejb.EJBs;
-import javax.naming.NameNotFoundException;
-
-import org.jboss.ejb3.EJBContainer;
-import org.jboss.ejb3.annotation.IgnoreDependency;
-import org.jboss.injection.EJBInjectionHandler;
-import org.jboss.injection.EjbEncInjector;
-import org.jboss.injection.EncInjector;
-import org.jboss.injection.InjectionContainer;
-import org.jboss.injection.InjectionUtil;
-import org.jboss.injection.Injector;
-import org.jboss.logging.Logger;
-import org.jboss.metadata.javaee.spec.AbstractEJBReferenceMetaData;
-import org.jboss.metadata.javaee.spec.AnnotatedEJBReferenceMetaData;
-import org.jboss.metadata.javaee.spec.AnnotatedEJBReferencesMetaData;
-import org.jboss.metadata.javaee.spec.EJBReferenceMetaData;
-import org.jboss.metadata.javaee.spec.RemoteEnvironment;
-
-/**
- * Local override until the ejb3 code is released for EJBTHREE-1289.
- *
- * Searches bean class for all @Inject and create Injectors
- * for a remote environment.
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @author Scott.Stark at jboss.org
- * @version $Revision: 70399 $
- */
-public class EJBRemoteHandler<X extends RemoteEnvironment> extends EJBInjectionHandler<X>
-{
- private static final Logger log = Logger.getLogger(EJBRemoteHandler.class);
-
- public void loadXml(X xml, InjectionContainer container)
- {
- if (xml != null)
- {
- log.trace("ejbRefs = " + xml.getEjbReferences());
- if (xml.getAnnotatedEjbReferences() != null)
- loadEjbRefXml(xml.getAnnotatedEjbReferences(), container);
- if (xml.getEjbReferences() != null)
- loadEjbRefXml(xml.getEjbReferences(), container);
- }
- }
-
- protected void loadEjbRefXml(AnnotatedEJBReferencesMetaData refs,
- InjectionContainer container)
- {
- for (AnnotatedEJBReferenceMetaData ref : refs)
- {
- String interfaceName = ref.getBeanInterface().getName();
- String errorType = "@EJB";
-
- ejbRefXml(ref, interfaceName, container, errorType);
- }
- }
-
- protected void loadEjbRefXml(Collection<EJBReferenceMetaData> refs, InjectionContainer container)
- {
- for (EJBReferenceMetaData ref : refs)
- {
- String interfaceName = ref.getRemote();
- String errorType = "<ejb-ref>";
-
- ejbRefXml(ref, interfaceName, container, errorType);
- }
- }
-
- protected void ejbRefXml(AbstractEJBReferenceMetaData ref, String interfaceName, InjectionContainer container, String errorType)
- {
- String encName = "env/" + ref.getEjbRefName();
- InjectionUtil.injectionTarget(encName, ref, container, container.getEncInjections());
- if (container.getEncInjectors().containsKey(encName))
- return;
-
- String mappedName = ref.getMappedName();
- if (mappedName != null && mappedName.equals(""))
- mappedName = null;
- if(mappedName == null && ref.getResolvedJndiName() != null)
- mappedName = ref.getResolvedJndiName();
-
- String link = ref.getLink();
- if (link != null && link.trim().equals("")) link = null;
-
- Class<?> refClass = null;
-
- if (interfaceName != null)
- {
- try
- {
- refClass = container.getClassloader().loadClass(interfaceName);
- }
- catch (ClassNotFoundException e)
- {
- throw new RuntimeException("could not find " + errorType + "'s local interface " + interfaceName + " in " + container.getDeploymentDescriptorType() + " of " + container.getIdentifier());
- }
- }
-
- //----- injectors
-
- if (mappedName == null && refClass == null && link == null)
- {
- // must be jboss.xml only with @EJB used to define reference. jboss.xml used to tag for ignore dependency
- // i think it is ok to assume this because the ejb-jar.xml schema should handle any missing elements
- }
- else
- {
- ejbRefEncInjector(mappedName, encName, null, refClass, link, errorType, container);
- if (ref.getIgnoreDependency() != null)
- {
- log.debug("IGNORING <ejb-ref> DEPENDENCY: " + encName);
- return;
- }
-
- ejbRefDependency(mappedName, link, container, refClass, errorType, encName);
- }
- }
-
- protected void ejbRefDependency(String mappedName, String link, InjectionContainer container, Class<?> refClass, String errorType, String encName)
- {
- if(mappedName != null && mappedName.length() == 0) mappedName = null;
- if (refClass != null && (refClass.equals(Object.class) || refClass.equals(void.class))) refClass = null;
-
- if(mappedName != null)
- {
- addJNDIDependency(container, mappedName);
- return;
- }
-
- if (refClass != null)
- {
- if (link != null && !link.trim().equals(""))
- {
- addDependency(container, link, refClass);
- }
- else
- {
- addDependency(container, refClass);
- }
- }
-
- else
- {
- String msg = "IGNORING DEPENDENCY: unable to resolve dependency of EJB, there is too little information";
- log.warn(msg);
- }
- }
-
- protected void ejbRefEncInjector(String mappedName, String encName, String fieldName, Class refClass, String link, String errorType, InjectionContainer container)
- {
- if (refClass != null && (refClass.equals(Object.class) || refClass.equals(void.class)))
- refClass = null;
- if (mappedName != null && mappedName.trim().equals(""))
- mappedName = null;
- if (mappedName == null)
- {
- //
- AnnotatedEJBReferencesMetaData amds = container.getEnvironmentRefGroup().getAnnotatedEjbReferences();
- if(amds != null)
- {
- AnnotatedEJBReferenceMetaData amd = amds.get(encName);
- if(amd == null && fieldName != null)
- amd = amds.get(fieldName);
- if(amd != null)
- {
- mappedName = amd.getMappedName();
- if(mappedName == null)
- mappedName = amd.getResolvedJndiName();
- }
- }
- }
-
- EncInjector injector = null;
-
- if (mappedName == null)
- {
- injector = new EjbEncInjector(encName, refClass, link, errorType);
- }
- else
- {
- injector = new EjbEncInjector(encName, mappedName, errorType);
- }
-
- container.getEncInjectors().put(encName, injector);
- }
-
- public static EJBContainer getEjbContainer(EJB ref, InjectionContainer container, Class<?> memberType)
- {
- EJBContainer rtn = null;
-
- if (ref.mappedName() != null && !"".equals(ref.mappedName()))
- {
- return null;
- }
-
- if (ref.beanName().equals("") && memberType == null)
- throw new RuntimeException("For deployment " + container.getIdentifier() + "not enough information for @EJB. Please fill out the beanName and/or businessInterface attributes");
-
- Class<?> businessInterface = memberType;
- if (!ref.beanInterface().getName().equals(Object.class.getName()))
- {
- businessInterface = ref.beanInterface();
- }
-
- if (ref.beanName().equals(""))
- {
- try
- {
- rtn = (EJBContainer) container.resolveEjbContainer(businessInterface);
- }
- catch (NameNotFoundException e)
- {
- log.warn("For deployment " + container.getIdentifier() + " could not find jndi binding based on interface only for @EJB(" + businessInterface.getName() + ") " + e.getMessage());
- }
- }
- else
- {
- rtn = (EJBContainer) container.resolveEjbContainer(ref.beanName(), businessInterface);
- }
-
- return rtn;
- }
-
- public static String getJndiName(EJB ref, InjectionContainer container, Class<?> memberType)
- {
- String jndiName;
-
- if (ref.mappedName() != null && !"".equals(ref.mappedName()))
- {
- return ref.mappedName();
- }
-
- if (ref.beanName().equals("") && memberType == null)
- throw new RuntimeException("For deployment " + container.getIdentifier() + "not enough information for @EJB. Please fill out the beanName and/or businessInterface attributes");
-
- Class<?> businessInterface = memberType;
- if (!ref.beanInterface().getName().equals(Object.class.getName()))
- {
- businessInterface = ref.beanInterface();
- }
-
- if (ref.beanName().equals(""))
- {
- try
- {
- jndiName = container.getEjbJndiName(businessInterface);
- }
- catch (NameNotFoundException e)
- {
- throw new RuntimeException("For deployment " + container.getIdentifier() + " could not find jndi binding based on interface only for @EJB(" + businessInterface.getName() + ") " + e.getMessage());
- }
- if (jndiName == null)
- {
- throw new RuntimeException("For deployment " + container.getIdentifier() + " could not find jndi binding based on interface only for @EJB(" + businessInterface.getName() + ")");
- }
- }
- else
- {
- jndiName = container.getEjbJndiName(ref.beanName(), businessInterface);
- if (jndiName == null)
- {
- throw new RuntimeException("For EJB " + container.getIdentifier() + "could not find jndi binding based on beanName and business interface for @EJB(" + ref.beanName() + ", " + businessInterface.getName() + ")");
- }
- }
-
- return jndiName;
- }
-
- public void handleClassAnnotations(Class<?> clazz, InjectionContainer container)
- {
- throw new IllegalStateException("handleClassAnnotation cannot be used in a client");
- }
-
- protected void handleClassAnnotation(EJB ejb, Class<?> clazz, InjectionContainer container)
- {
- throw new IllegalStateException("handleClassAnnotation cannot be used in a client");
- }
-
- public void handleMethodAnnotations(Method method, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
- {
- throw new IllegalStateException("handleMethodAnnotations cannot be used in a client");
- }
-
- public void handleFieldAnnotations(Field field, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
- {
- throw new IllegalStateException("handleFieldAnnotations cannot be used in a client");
- }
-
- protected boolean isIgnoreDependency(InjectionContainer container, EJB ref)
- {
- RemoteEnvironment refGroup = container.getEnvironmentRefGroup();
-
- if (refGroup != null)
- {
- if(refGroup.getEjbReferences() != null)
- for(EJBReferenceMetaData ejbRef : refGroup.getEjbReferences())
- {
- if (ejbRef.getEjbRefName().equals(ref.name()))
- {
- return ejbRef.getIgnoreDependency() != null;
- }
- }
- }
-
- // TODO: shouldn't we scan local ejb refs as well?
-
- return false;
- }
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * 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.reflect.AccessibleObject;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.Collection;
+import java.util.Map;
+
+import javax.ejb.EJB;
+import javax.ejb.EJBs;
+import javax.naming.NameNotFoundException;
+
+import org.jboss.ejb3.EJBContainer;
+import org.jboss.ejb3.annotation.IgnoreDependency;
+import org.jboss.injection.EJBInjectionHandler;
+import org.jboss.injection.EjbEncInjector;
+import org.jboss.injection.EncInjector;
+import org.jboss.injection.InjectionContainer;
+import org.jboss.injection.InjectionUtil;
+import org.jboss.injection.Injector;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.javaee.spec.AbstractEJBReferenceMetaData;
+import org.jboss.metadata.javaee.spec.AnnotatedEJBReferenceMetaData;
+import org.jboss.metadata.javaee.spec.AnnotatedEJBReferencesMetaData;
+import org.jboss.metadata.javaee.spec.EJBReferenceMetaData;
+import org.jboss.metadata.javaee.spec.RemoteEnvironment;
+
+/**
+ * Local override until the ejb3 code is released for EJBTHREE-1289.
+ *
+ * Searches bean class for all @Inject and create Injectors
+ * for a remote environment.
+ *
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 70399 $
+ */
+public class EJBRemoteHandler<X extends RemoteEnvironment> extends EJBInjectionHandler<X>
+{
+ private static final Logger log = Logger.getLogger(EJBRemoteHandler.class);
+
+ public void loadXml(X xml, InjectionContainer container)
+ {
+ if (xml != null)
+ {
+ log.trace("ejbRefs = " + xml.getEjbReferences());
+ if (xml.getAnnotatedEjbReferences() != null)
+ loadEjbRefXml(xml.getAnnotatedEjbReferences(), container);
+ if (xml.getEjbReferences() != null)
+ loadEjbRefXml(xml.getEjbReferences(), container);
+ }
+ }
+
+ protected void loadEjbRefXml(AnnotatedEJBReferencesMetaData refs,
+ InjectionContainer container)
+ {
+ for (AnnotatedEJBReferenceMetaData ref : refs)
+ {
+ String interfaceName = ref.getBeanInterface().getName();
+ String errorType = "@EJB";
+
+ ejbRefXml(ref, interfaceName, container, errorType);
+ }
+ }
+
+ protected void loadEjbRefXml(Collection<EJBReferenceMetaData> refs, InjectionContainer container)
+ {
+ for (EJBReferenceMetaData ref : refs)
+ {
+ String interfaceName = ref.getRemote();
+ String errorType = "<ejb-ref>";
+
+ ejbRefXml(ref, interfaceName, container, errorType);
+ }
+ }
+
+ protected void ejbRefXml(AbstractEJBReferenceMetaData ref, String interfaceName, InjectionContainer container, String errorType)
+ {
+ String encName = "env/" + ref.getEjbRefName();
+ InjectionUtil.injectionTarget(encName, ref, container, container.getEncInjections());
+ if (container.getEncInjectors().containsKey(encName))
+ return;
+
+ String mappedName = ref.getMappedName();
+ if (mappedName != null && mappedName.equals(""))
+ mappedName = null;
+ if(mappedName == null && ref.getResolvedJndiName() != null)
+ mappedName = ref.getResolvedJndiName();
+
+ String link = ref.getLink();
+ if (link != null && link.trim().equals("")) link = null;
+
+ Class<?> refClass = null;
+
+ if (interfaceName != null)
+ {
+ try
+ {
+ refClass = container.getClassloader().loadClass(interfaceName);
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new RuntimeException("could not find " + errorType + "'s local interface " + interfaceName + " in " + container.getDeploymentDescriptorType() + " of " + container.getIdentifier());
+ }
+ }
+
+ //----- injectors
+
+ if (mappedName == null && refClass == null && link == null)
+ {
+ // must be jboss.xml only with @EJB used to define reference. jboss.xml used to tag for ignore dependency
+ // i think it is ok to assume this because the ejb-jar.xml schema should handle any missing elements
+ }
+ else
+ {
+ ejbRefEncInjector(mappedName, encName, null, refClass, link, errorType, container);
+ if (ref.getIgnoreDependency() != null)
+ {
+ log.debug("IGNORING <ejb-ref> DEPENDENCY: " + encName);
+ return;
+ }
+
+ ejbRefDependency(mappedName, link, container, refClass, errorType, encName);
+ }
+ }
+
+ protected void ejbRefDependency(String mappedName, String link, InjectionContainer container, Class<?> refClass, String errorType, String encName)
+ {
+ if(mappedName != null && mappedName.length() == 0) mappedName = null;
+ if (refClass != null && (refClass.equals(Object.class) || refClass.equals(void.class))) refClass = null;
+
+ if(mappedName != null)
+ {
+ addJNDIDependency(container, mappedName);
+ return;
+ }
+
+ if (refClass != null)
+ {
+ if (link != null && !link.trim().equals(""))
+ {
+ addDependency(container, link, refClass);
+ }
+ else
+ {
+ addDependency(container, refClass);
+ }
+ }
+
+ else
+ {
+ String msg = "IGNORING DEPENDENCY: unable to resolve dependency of EJB, there is too little information";
+ log.warn(msg);
+ }
+ }
+
+ protected void ejbRefEncInjector(String mappedName, String encName, String fieldName, Class refClass, String link, String errorType, InjectionContainer container)
+ {
+ if (refClass != null && (refClass.equals(Object.class) || refClass.equals(void.class)))
+ refClass = null;
+ if (mappedName != null && mappedName.trim().equals(""))
+ mappedName = null;
+ if (mappedName == null)
+ {
+ //
+ AnnotatedEJBReferencesMetaData amds = container.getEnvironmentRefGroup().getAnnotatedEjbReferences();
+ if(amds != null)
+ {
+ AnnotatedEJBReferenceMetaData amd = amds.get(encName);
+ if(amd == null && fieldName != null)
+ amd = amds.get(fieldName);
+ if(amd != null)
+ {
+ mappedName = amd.getMappedName();
+ if(mappedName == null)
+ mappedName = amd.getResolvedJndiName();
+ }
+ }
+ }
+
+ EncInjector injector = null;
+
+ if (mappedName == null)
+ {
+ injector = new EjbEncInjector(encName, refClass, link, errorType);
+ }
+ else
+ {
+ injector = new EjbEncInjector(encName, mappedName, errorType);
+ }
+
+ container.getEncInjectors().put(encName, injector);
+ }
+
+ public static EJBContainer getEjbContainer(EJB ref, InjectionContainer container, Class<?> memberType)
+ {
+ EJBContainer rtn = null;
+
+ if (ref.mappedName() != null && !"".equals(ref.mappedName()))
+ {
+ return null;
+ }
+
+ if (ref.beanName().equals("") && memberType == null)
+ throw new RuntimeException("For deployment " + container.getIdentifier() + "not enough information for @EJB. Please fill out the beanName and/or businessInterface attributes");
+
+ Class<?> businessInterface = memberType;
+ if (!ref.beanInterface().getName().equals(Object.class.getName()))
+ {
+ businessInterface = ref.beanInterface();
+ }
+
+ if (ref.beanName().equals(""))
+ {
+ try
+ {
+ rtn = (EJBContainer) container.resolveEjbContainer(businessInterface);
+ }
+ catch (NameNotFoundException e)
+ {
+ log.warn("For deployment " + container.getIdentifier() + " could not find jndi binding based on interface only for @EJB(" + businessInterface.getName() + ") " + e.getMessage());
+ }
+ }
+ else
+ {
+ rtn = (EJBContainer) container.resolveEjbContainer(ref.beanName(), businessInterface);
+ }
+
+ return rtn;
+ }
+
+ public static String getJndiName(EJB ref, InjectionContainer container, Class<?> memberType)
+ {
+ String jndiName;
+
+ if (ref.mappedName() != null && !"".equals(ref.mappedName()))
+ {
+ return ref.mappedName();
+ }
+
+ if (ref.beanName().equals("") && memberType == null)
+ throw new RuntimeException("For deployment " + container.getIdentifier() + "not enough information for @EJB. Please fill out the beanName and/or businessInterface attributes");
+
+ Class<?> businessInterface = memberType;
+ if (!ref.beanInterface().getName().equals(Object.class.getName()))
+ {
+ businessInterface = ref.beanInterface();
+ }
+
+ if (ref.beanName().equals(""))
+ {
+ try
+ {
+ jndiName = container.getEjbJndiName(businessInterface);
+ }
+ catch (NameNotFoundException e)
+ {
+ throw new RuntimeException("For deployment " + container.getIdentifier() + " could not find jndi binding based on interface only for @EJB(" + businessInterface.getName() + ") " + e.getMessage());
+ }
+ if (jndiName == null)
+ {
+ throw new RuntimeException("For deployment " + container.getIdentifier() + " could not find jndi binding based on interface only for @EJB(" + businessInterface.getName() + ")");
+ }
+ }
+ else
+ {
+ jndiName = container.getEjbJndiName(ref.beanName(), businessInterface);
+ if (jndiName == null)
+ {
+ throw new RuntimeException("For EJB " + container.getIdentifier() + "could not find jndi binding based on beanName and business interface for @EJB(" + ref.beanName() + ", " + businessInterface.getName() + ")");
+ }
+ }
+
+ return jndiName;
+ }
+
+ public void handleClassAnnotations(Class<?> clazz, InjectionContainer container)
+ {
+ throw new IllegalStateException("handleClassAnnotation cannot be used in a client");
+ }
+
+ protected void handleClassAnnotation(EJB ejb, Class<?> clazz, InjectionContainer container)
+ {
+ throw new IllegalStateException("handleClassAnnotation cannot be used in a client");
+ }
+
+ public void handleMethodAnnotations(Method method, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
+ {
+ throw new IllegalStateException("handleMethodAnnotations cannot be used in a client");
+ }
+
+ public void handleFieldAnnotations(Field field, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
+ {
+ throw new IllegalStateException("handleFieldAnnotations cannot be used in a client");
+ }
+
+ protected boolean isIgnoreDependency(InjectionContainer container, EJB ref)
+ {
+ RemoteEnvironment refGroup = container.getEnvironmentRefGroup();
+
+ if (refGroup != null)
+ {
+ if(refGroup.getEjbReferences() != null)
+ for(EJBReferenceMetaData ejbRef : refGroup.getEjbReferences())
+ {
+ if (ejbRef.getEjbRefName().equals(ref.name()))
+ {
+ return ejbRef.getIgnoreDependency() != null;
+ }
+ }
+ }
+
+ // TODO: shouldn't we scan local ejb refs as well?
+
+ return false;
+ }
}
\ No newline at end of file
Property changes on: trunk/ejb3/src/main/org/jboss/ejb3/clientmodule/EJBRemoteHandler.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/ejb3/src/main/org/jboss/ejb3/clientmodule/RemotePersistenceUnitHandler.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/clientmodule/RemotePersistenceUnitHandler.java 2008-11-14 14:58:15 UTC (rev 81052)
+++ trunk/ejb3/src/main/org/jboss/ejb3/clientmodule/RemotePersistenceUnitHandler.java 2008-11-14 14:59:40 UTC (rev 81053)
@@ -1,95 +1,95 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ejb3.clientmodule;
-
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.Map;
-
-import javax.naming.NameNotFoundException;
-
-import org.jboss.injection.InjectionContainer;
-import org.jboss.injection.InjectionHandler;
-import org.jboss.injection.InjectionUtil;
-import org.jboss.injection.Injector;
-import org.jboss.injection.PersistenceUnitHandler;
-import org.jboss.metadata.javaee.spec.PersistenceUnitReferenceMetaData;
-import org.jboss.metadata.javaee.spec.RemoteEnvironment;
-
-/**
- * EXPERIMENTAL
- *
- * Allow injection of a persistence unit into a component running outside
- * the VM where the peristence unit is deployed.
- *
- * Currently this only runs for application client which does do any
- * annotation processing by itself. This is delegated to the AnnotationDeployer.
- *
- * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
- * @version $Revision: $
- */
-public class RemotePersistenceUnitHandler<X extends RemoteEnvironment> implements InjectionHandler<X>
-{
- public void handleClassAnnotations(Class<?> clazz, InjectionContainer container)
- {
- throw new UnsupportedOperationException("metadata should have been complete");
- }
-
- public void handleFieldAnnotations(Field field, InjectionContainer container,
- Map<AccessibleObject, Injector> injectors)
- {
- throw new UnsupportedOperationException("metadata should have been complete");
- }
-
- public void handleMethodAnnotations(Method method, InjectionContainer container,
- Map<AccessibleObject, Injector> injectors)
- {
- throw new UnsupportedOperationException("metadata should have been complete");
- }
-
- public void loadXml(X xml, InjectionContainer container)
- {
- if (xml == null) return;
- if (xml.getPersistenceUnitRefs() == null) return;
-
- for (PersistenceUnitReferenceMetaData ref : xml.getPersistenceUnitRefs())
- {
- String encName = "env/" + ref.getPersistenceUnitRefName();
- // we add injection target no matter what. enc injection might be overridden but
- // XML injection cannot be overriden
- Class<?> injectionType = InjectionUtil.injectionTarget(encName, ref, container, container.getEncInjections());
- if (container.getEncInjectors().containsKey(encName))
- return;
- container.getEncInjectors().put(encName, new RemotePuEncInjector(encName, injectionType, ref.getPersistenceUnitName(), "<persistence-unit-ref>"));
- try
- {
- PersistenceUnitHandler.addPUDependency(ref.getPersistenceUnitName(), container);
- }
- catch (NameNotFoundException e)
- {
- throw new RuntimeException("Illegal <persistence-unit-ref> of " + ref.getPersistenceUnitRefName() + " :" + e.getMessage());
- }
- }
- }
-
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.clientmodule;
+
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.Map;
+
+import javax.naming.NameNotFoundException;
+
+import org.jboss.injection.InjectionContainer;
+import org.jboss.injection.InjectionHandler;
+import org.jboss.injection.InjectionUtil;
+import org.jboss.injection.Injector;
+import org.jboss.injection.PersistenceUnitHandler;
+import org.jboss.metadata.javaee.spec.PersistenceUnitReferenceMetaData;
+import org.jboss.metadata.javaee.spec.RemoteEnvironment;
+
+/**
+ * EXPERIMENTAL
+ *
+ * Allow injection of a persistence unit into a component running outside
+ * the VM where the peristence unit is deployed.
+ *
+ * Currently this only runs for application client which does do any
+ * annotation processing by itself. This is delegated to the AnnotationDeployer.
+ *
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class RemotePersistenceUnitHandler<X extends RemoteEnvironment> implements InjectionHandler<X>
+{
+ public void handleClassAnnotations(Class<?> clazz, InjectionContainer container)
+ {
+ throw new UnsupportedOperationException("metadata should have been complete");
+ }
+
+ public void handleFieldAnnotations(Field field, InjectionContainer container,
+ Map<AccessibleObject, Injector> injectors)
+ {
+ throw new UnsupportedOperationException("metadata should have been complete");
+ }
+
+ public void handleMethodAnnotations(Method method, InjectionContainer container,
+ Map<AccessibleObject, Injector> injectors)
+ {
+ throw new UnsupportedOperationException("metadata should have been complete");
+ }
+
+ public void loadXml(X xml, InjectionContainer container)
+ {
+ if (xml == null) return;
+ if (xml.getPersistenceUnitRefs() == null) return;
+
+ for (PersistenceUnitReferenceMetaData ref : xml.getPersistenceUnitRefs())
+ {
+ String encName = "env/" + ref.getPersistenceUnitRefName();
+ // we add injection target no matter what. enc injection might be overridden but
+ // XML injection cannot be overriden
+ Class<?> injectionType = InjectionUtil.injectionTarget(encName, ref, container, container.getEncInjections());
+ if (container.getEncInjectors().containsKey(encName))
+ return;
+ container.getEncInjectors().put(encName, new RemotePuEncInjector(encName, injectionType, ref.getPersistenceUnitName(), "<persistence-unit-ref>"));
+ try
+ {
+ PersistenceUnitHandler.addPUDependency(ref.getPersistenceUnitName(), container);
+ }
+ catch (NameNotFoundException e)
+ {
+ throw new RuntimeException("Illegal <persistence-unit-ref> of " + ref.getPersistenceUnitRefName() + " :" + e.getMessage());
+ }
+ }
+ }
+
+}
Property changes on: trunk/ejb3/src/main/org/jboss/ejb3/clientmodule/RemotePersistenceUnitHandler.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/ejb3/src/main/org/jboss/ejb3/clientmodule/RemotePuEncInjector.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/clientmodule/RemotePuEncInjector.java 2008-11-14 14:58:15 UTC (rev 81052)
+++ trunk/ejb3/src/main/org/jboss/ejb3/clientmodule/RemotePuEncInjector.java 2008-11-14 14:59:40 UTC (rev 81053)
@@ -1,73 +1,73 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ejb3.clientmodule;
-
-import javax.naming.NamingException;
-
-import org.jboss.injection.EncInjector;
-import org.jboss.injection.ExtendedInjectionContainer;
-import org.jboss.injection.InjectionContainer;
-import org.jboss.jpa.deployment.PersistenceUnitDeployment;
-import org.jboss.jpa.remote.RemotelyInjectEntityManagerFactory;
-import org.jboss.jpa.spi.PersistenceUnitRegistry;
-import org.jboss.util.naming.Util;
-
-/**
- * EXPERIMENTAL
- *
- * Setup a remote entity manager factory.
- *
- * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
- * @version $Revision: $
- */
-public class RemotePuEncInjector implements EncInjector
-{
- private String encName;
- private String unitName;
-
- public RemotePuEncInjector(String encName, Class<?> injectionType, String unitName, String error)
- {
- assert encName != null : "encName is null";
- this.encName = encName;
- this.unitName = unitName;
- }
-
- public void inject(InjectionContainer c)
- {
- if(!(c instanceof ExtendedInjectionContainer))
- throw new UnsupportedOperationException("RemotePuEncInjector only works for ExtendedInjectionContainer");
- ExtendedInjectionContainer container = (ExtendedInjectionContainer) c;
-
- String name = container.resolvePersistenceUnitSupplier(unitName);
- PersistenceUnitDeployment deployment = ((PersistenceUnitDeployment) PersistenceUnitRegistry.getPersistenceUnit(name));
- RemotelyInjectEntityManagerFactory factory = new RemotelyInjectEntityManagerFactory(deployment.getXml(), "FIXME");
-
- try
- {
- Util.rebind(container.getEnc(), encName, factory);
- }
- catch (NamingException e)
- {
- throw new RuntimeException(e);
- }
- }
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.clientmodule;
+
+import javax.naming.NamingException;
+
+import org.jboss.injection.EncInjector;
+import org.jboss.injection.ExtendedInjectionContainer;
+import org.jboss.injection.InjectionContainer;
+import org.jboss.jpa.deployment.PersistenceUnitDeployment;
+import org.jboss.jpa.remote.RemotelyInjectEntityManagerFactory;
+import org.jboss.jpa.spi.PersistenceUnitRegistry;
+import org.jboss.util.naming.Util;
+
+/**
+ * EXPERIMENTAL
+ *
+ * Setup a remote entity manager factory.
+ *
+ * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class RemotePuEncInjector implements EncInjector
+{
+ private String encName;
+ private String unitName;
+
+ public RemotePuEncInjector(String encName, Class<?> injectionType, String unitName, String error)
+ {
+ assert encName != null : "encName is null";
+ this.encName = encName;
+ this.unitName = unitName;
+ }
+
+ public void inject(InjectionContainer c)
+ {
+ if(!(c instanceof ExtendedInjectionContainer))
+ throw new UnsupportedOperationException("RemotePuEncInjector only works for ExtendedInjectionContainer");
+ ExtendedInjectionContainer container = (ExtendedInjectionContainer) c;
+
+ String name = container.resolvePersistenceUnitSupplier(unitName);
+ PersistenceUnitDeployment deployment = ((PersistenceUnitDeployment) PersistenceUnitRegistry.getPersistenceUnit(name));
+ RemotelyInjectEntityManagerFactory factory = new RemotelyInjectEntityManagerFactory(deployment.getXml(), "FIXME");
+
+ try
+ {
+ Util.rebind(container.getEnc(), encName, factory);
+ }
+ catch (NamingException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+}
Property changes on: trunk/ejb3/src/main/org/jboss/ejb3/clientmodule/RemotePuEncInjector.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/ejb3/src/main/org/jboss/ejb3/clientmodule/ResourceHandler.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/clientmodule/ResourceHandler.java 2008-11-14 14:58:15 UTC (rev 81052)
+++ trunk/ejb3/src/main/org/jboss/ejb3/clientmodule/ResourceHandler.java 2008-11-14 14:59:40 UTC (rev 81053)
@@ -1,631 +1,631 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * 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.reflect.AccessibleObject;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Collection;
-import java.util.Map;
-
-import javax.annotation.Resource;
-import javax.annotation.Resources;
-import javax.ejb.EJBContext;
-import javax.ejb.EJBException;
-import javax.ejb.TimerService;
-import javax.transaction.UserTransaction;
-
-import org.jboss.ejb3.Container;
-import org.jboss.injection.EJBContextPropertyInjector;
-import org.jboss.injection.EnvEntryEncInjector;
-import org.jboss.injection.InjectionContainer;
-import org.jboss.injection.InjectionHandler;
-import org.jboss.injection.InjectionUtil;
-import org.jboss.injection.Injector;
-import org.jboss.injection.InjectorFactory;
-import org.jboss.injection.JndiPropertyInjector;
-import org.jboss.injection.LinkRefEncInjector;
-import org.jboss.injection.TimerServicePropertyInjector;
-import org.jboss.injection.UserTransactionPropertyInjector;
-import org.jboss.injection.ValueEncInjector;
-import org.jboss.injection.lang.reflect.BeanProperty;
-import org.jboss.injection.lang.reflect.FieldBeanProperty;
-import org.jboss.injection.lang.reflect.MethodBeanProperty;
-import org.jboss.logging.Logger;
-import org.jboss.metadata.javaee.spec.EnvironmentEntryMetaData;
-import org.jboss.metadata.javaee.spec.MessageDestinationReferenceMetaData;
-import org.jboss.metadata.javaee.spec.RemoteEnvironment;
-import org.jboss.metadata.javaee.spec.ResourceEnvironmentReferenceMetaData;
-import org.jboss.metadata.javaee.spec.ResourceReferenceMetaData;
-import org.jboss.reflect.plugins.ValueConvertor;
-import org.omg.CORBA.ORB;
-
-/**
- * Handling of resources in the server side setup of the client container.
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @author Scott.Stark at jboss.org
- * @version $Revision: 71076 $
- */
-public class ResourceHandler<X extends RemoteEnvironment> implements InjectionHandler<X>
-{
- private static final Logger log = Logger.getLogger(ResourceHandler.class);
-
- private boolean checkEncInjectors;
-
- public ResourceHandler()
- {
- this(true);
- }
-
- public ResourceHandler(boolean checkEncInjectors)
- {
- this.checkEncInjectors = checkEncInjectors;
- }
-
- private void createURLInjector(String encName, String mappedName, InjectionContainer container)
- {
- assert encName.length() > 0 : "encName is empty";
- assert mappedName.length() > 0 : "mappedName is empty";
-
- // Create a URL from the mappedName
- try
- {
- URL url = new URL(mappedName.trim());
- container.getEncInjectors().put(encName, new ValueEncInjector(encName, url, "@Resource"));
- }
- catch (MalformedURLException e)
- {
- throw new RuntimeException(e);
- }
- }
-
- private static void loadEnvEntry(InjectionContainer container, Collection<EnvironmentEntryMetaData> envEntries)
- {
- for (EnvironmentEntryMetaData envEntry : envEntries)
- {
- String encName = "env/" + envEntry.getEnvEntryName();
- // 16.4.1.3: If the env-entry-value is not specified, no value will be injected and it
- // will not be initialized into the naming context.
- if(envEntry.getValue() == null)
- {
- log.debug("ignoring env-entry " + envEntry);
- continue;
- }
- InjectionUtil.injectionTarget(encName, envEntry, container, container.getEncInjections());
- if (container.getEncInjectors().containsKey(encName)) continue;
- log.trace("adding env-entry injector " + encName);
- container.getEncInjectors().put(encName, new EnvEntryEncInjector(encName, envEntry.getType(), envEntry.getValue()));
- }
- }
-
- private static void loadXmlResourceRefs(InjectionContainer container, Collection<ResourceReferenceMetaData> refs)
- {
- for (ResourceReferenceMetaData envRef : refs)
- {
- String encName = "env/" + envRef.getResourceRefName();
- if (container.getEncInjectors().containsKey(encName))
- continue;
-
- if (envRef.getMappedName() == null || envRef.getMappedName().equals(""))
- {
- if (envRef.getResUrl() != null)
- {
- try
- {
- container.getEncInjectors().put(encName, new ValueEncInjector(encName, new URL(envRef.getResUrl().trim()), "<resource-ref>"));
- }
- catch (MalformedURLException e)
- {
- throw new RuntimeException(e);
- }
- }
- else if (UserTransaction.class.getName().equals(envRef.getType()))
- {
- final InjectionContainer ic = container;
- InjectorFactory<?> factory = new InjectorFactory<UserTransactionPropertyInjector>()
- {
- public UserTransactionPropertyInjector create(BeanProperty property)
- {
- return new UserTransactionPropertyInjector(property, ic);
- }
- };
- if(envRef.getInjectionTargets() != null)
- {
- InjectionUtil.createInjectors(container.getInjectors(), container.getClassloader(), factory, envRef.getInjectionTargets());
- continue;
- }
- else
- {
- encName = "java:comp/UserTransaction";
- }
- }
- else if (ORB.class.getName().equals(envRef.getType()))
- {
- encName = "java:comp/ORB";
- }
- else
- {
- throw new RuntimeException("mapped-name is required for " + envRef.getResourceRefName() + " of deployment " + container.getIdentifier());
- }
- }
- else
- {
- container.getEncInjectors().put(encName, new LinkRefEncInjector(encName, envRef.getMappedName(), "<resource-ref>"));
- }
- InjectionUtil.injectionTarget(encName, envRef, container, container.getEncInjections());
- }
- }
-
- private static void loadXmlResourceEnvRefs(InjectionContainer container, Collection<ResourceEnvironmentReferenceMetaData> refs)
- {
- for (ResourceEnvironmentReferenceMetaData envRef : refs)
- {
- // EJBTHREE-712
- // TODO: refactor with handlePropertyAnnotation
- String resTypeName = envRef.getType();
- String mappedName = envRef.getMappedName();
- try
- {
- if(resTypeName != null)
- {
- Class<?> resType = Class.forName(resTypeName);
- if(EJBContext.class.isAssignableFrom(resType))
- {
- InjectorFactory<?> factory = new InjectorFactory<EJBContextPropertyInjector>()
- {
- public EJBContextPropertyInjector create(BeanProperty property)
- {
- return new EJBContextPropertyInjector(property);
- }
- };
- InjectionUtil.createInjectors(container.getInjectors(), container.getClassloader(), factory, envRef.getInjectionTargets());
- continue;
- }
- else if (resType.equals(UserTransaction.class))
- {
- final InjectionContainer ic = container;
- InjectorFactory<?> factory = new InjectorFactory<UserTransactionPropertyInjector>()
- {
- public UserTransactionPropertyInjector create(BeanProperty property)
- {
- return new UserTransactionPropertyInjector(property, ic);
- }
- };
- if(envRef.getInjectionTargets() != null)
- {
- InjectionUtil.createInjectors(container.getInjectors(), container.getClassloader(), factory, envRef.getInjectionTargets());
- continue;
- }
- else
- {
- mappedName = "java:comp/UserTransaction";
- }
- }
- else if (resType.equals(ORB.class))
- {
- mappedName = "java:comp/ORB";
- }
- }
- }
- catch(ClassNotFoundException e)
- {
- throw new EJBException(e);
- }
-
- String encName = "env/" + envRef.getResourceEnvRefName();
- if (container.getEncInjectors().containsKey(encName)) continue;
- if (mappedName == null || mappedName.equals(""))
- {
- throw new RuntimeException("mapped-name is required for " + envRef.getResourceEnvRefName() + " of deployment " + container.getIdentifier());
- }
- container.getEncInjectors().put(encName, new LinkRefEncInjector(encName, mappedName, "<resource-ref>"));
- InjectionUtil.injectionTarget(encName, envRef, container, container.getEncInjections());
- }
- }
-
- private static void loadXmlMessageDestinationRefs(InjectionContainer container, Collection<MessageDestinationReferenceMetaData> refs)
- {
- for (MessageDestinationReferenceMetaData envRef : refs)
- {
- String encName = "env/" + envRef.getMessageDestinationRefName();
- if (container.getEncInjectors().containsKey(encName)) continue;
- String jndiName = envRef.getMappedName();
- if (jndiName == null || jndiName.equals(""))
- {
- // Look for a message-destination-link
- jndiName = envRef.getResolvedJndiName();
- if (jndiName == null)
- {
- throw new RuntimeException("message-destination has no jndi-name/resolved-jndi-name " + envRef);
- // TODO: add dependency
- }
- }
- container.getEncInjectors().put(encName, new LinkRefEncInjector(encName, jndiName, "<message-destination-ref>"));
- InjectionUtil.injectionTarget(encName, envRef, container, container.getEncInjections());
- }
- }
-
- public void loadXml(X xml, InjectionContainer container)
- {
- if (xml == null)
- return;
- if (xml.getMessageDestinationReferences() != null)
- loadXmlMessageDestinationRefs(container, xml.getMessageDestinationReferences());
- if (xml.getResourceEnvironmentReferences() != null)
- loadXmlResourceEnvRefs(container, xml.getResourceEnvironmentReferences());
- if (xml.getResourceReferences() != null)
- loadXmlResourceRefs(container, xml.getResourceReferences());
- if (xml.getEnvironmentEntries() != null)
- loadEnvEntry(container, xml.getEnvironmentEntries());
- }
-
- public void handleClassAnnotations(Class<?> clazz, InjectionContainer container)
- {
- Resources resources = container.getAnnotation(Resources.class, clazz);
- if (resources != null)
- {
- for (Resource ref : resources.value())
- {
- handleClassAnnotation(ref, container, clazz);
- }
- }
- Resource res = container.getAnnotation(Resource.class, clazz);
- if (res != null) handleClassAnnotation(res, container, clazz);
- }
-
- private void handleClassAnnotation(Resource ref, InjectionContainer container, Class<?> clazz)
- {
- String encName = ref.name();
- if (encName == null || encName.equals(""))
- {
- throw new RuntimeException("JBoss requires name() for class level @Resource");
- }
- encName = "env/" + ref.name();
- if (container.getEncInjectors().containsKey(encName)) return;
-
- String mappedName = ref.mappedName();
- if (mappedName == null || mappedName.equals(""))
- {
- // Handle class level @Resource(type=ORB.class)
- if(ORB.class.isAssignableFrom(ref.type()))
- {
- mappedName = "java:comp/ORB";
- }
- else if(UserTransaction.class.isAssignableFrom(ref.type()))
- {
- mappedName = "java:comp/UserTransaction";
- }
- else
- {
- throw new RuntimeException("You did not specify a @Resource.mappedName() for name: "
- +ref.name()+", class: " + clazz.getName() + " and there is no binding for that enc name in XML");
- }
- }
-
- if (ref.type() == URL.class)
- {
- createURLInjector(encName, mappedName, container);
- }
- else
- {
- container.getEncInjectors().put(encName, new LinkRefEncInjector(encName, ref.mappedName(), "@Resource"));
- }
- }
-
- public void handleMethodAnnotations(Method method, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
- {
- Resource ref = container.getAnnotation(Resource.class, method);
- if (ref == null) return;
-
- log.trace("method " + method + " has @Resource");
-
- handlePropertyAnnotation(ref, new MethodBeanProperty(method), container, injectors);
- /*
- String encName = ref.name();
- if (encName == null || encName.equals(""))
- {
- encName = InjectionUtil.getEncName(method);
- }
- else
- {
- encName = "env/" + encName;
- }
-
- method.setAccessible(true);
-
- if (!method.getName().startsWith("set"))
- throw new RuntimeException("@Resource can only be used with a set method: " + method);
- if (method.getParameterTypes().length != 1)
- throw new RuntimeException("@Resource can only be used with a set method of one parameter: " + method);
-
- Class type = method.getParameterTypes()[0];
- if (!ref.type().equals(Object.class))
- {
- type = ref.type();
- }
- if (type.equals(UserTransaction.class))
- {
- injectors.put(method, new UserTransactionMethodInjector(method, container));
- }
- else if (type.equals(TimerService.class))
- {
- injectors.put(method, new TimerServiceMethodInjector(method, (Container) container)); // only EJBs
- }
- else if (EJBContext.class.isAssignableFrom(type))
- {
- injectors.put(method, new EJBContextMethodInjector(method));
- }
- else if (type.equals(WebServiceContext.class))
- {
- // FIXME: For now we skip it, and rely on the WS stack to perform the injection
- }
- else if (type.equals(String.class)
- || type.equals(Character.class)
- || type.equals(Byte.class)
- || type.equals(Short.class)
- || type.equals(Integer.class)
- || type.equals(Long.class)
- || type.equals(Boolean.class)
- || type.equals(Double.class)
- || type.equals(Float.class)
- || type.isPrimitive()
- )
- {
-
- // don't add an injector if no XML <env-entry is present as there will be no value to inject
- if (container.getEncInjectors().containsKey(encName))
- {
- injectors.put(method, new JndiMethodInjector(method, encName, container.getEnc()));
- }
- else if (ref.mappedName() != null && ref.mappedName().length() > 0)
- {
- // Use the mappedName as the string value
- String s = ref.mappedName().trim();
- try
- {
- Object value = ValueConvertor.convertValue(type, s);
- container.getEncInjectors().put(encName, new ValueEncInjector(encName, value, "@Resource"));
- injectors.put(method, new JndiMethodInjector(method, encName, container.getEnc()));
- }
- catch(Throwable t)
- {
- throw new RuntimeException("Failed to convert: "+ref.mappedName()+" to type:"+type, t);
- }
- }
- }
- else
- {
- if (!container.getEncInjectors().containsKey(encName))
- {
- String mappedName = ref.mappedName();
- if (mappedName == null || mappedName.equals(""))
- {
- throw new RuntimeException("You did not specify a @Resource.mappedName() on " + method + " and there is no binding for that enc name in XML");
- }
- container.getEncInjectors().put(encName, new LinkRefEncInjector(encName, ref.mappedName(), "@Resource"));
- }
- injectors.put(method, new JndiMethodInjector(method, encName, container.getEnc()));
- }
- */
- }
-
- public void handleFieldAnnotations(Field field, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
- {
- Resource ref = container.getAnnotation(Resource.class, field);
- if (ref == null) return;
-
- log.trace("field " + field + " has @Resource");
-
- handlePropertyAnnotation(ref, new FieldBeanProperty(field), container, injectors);
- /*
- String encName = ref.name();
- if (encName == null || encName.equals(""))
- {
- encName = InjectionUtil.getEncName(field);
- }
- else
- {
- encName = "env/" + encName;
- }
-
- field.setAccessible(true);
-
- Class type = field.getType();
- if (!ref.type().equals(Object.class))
- {
- type = ref.type();
- }
- if (type.equals(UserTransaction.class))
- {
- injectors.put(field, new UserTransactionFieldInjector(field, container));
- }
- else if (type.equals(TimerService.class))
- {
- injectors.put(field, new TimerServiceFieldInjector(field, (Container) container)); // only EJBs
- }
- else if (EJBContext.class.isAssignableFrom(type))
- {
- injectors.put(field, new EJBContextFieldInjector(field));
- }
- else if (type.equals(WebServiceContext.class))
- {
- // FIXME: For now we skip it, and rely on the WS stack to perform the injection
- }
- else if (type.equals(String.class)
- || type.equals(Character.class)
- || type.equals(Byte.class)
- || type.equals(Short.class)
- || type.equals(Integer.class)
- || type.equals(Long.class)
- || type.equals(Boolean.class)
- || type.equals(Double.class)
- || type.equals(Float.class)
- || type.isPrimitive()
- )
- {
- // don't add an injector if no XML <env-entry is present as there will be no value to inject
- if (container.getEncInjectors().containsKey(encName))
- {
- injectors.put(field, new JndiFieldInjector(field, encName, container.getEnc()));
- }
- else if (ref.mappedName() != null && ref.mappedName().length() > 0)
- {
- // Use the mappedName as the string value
- String s = ref.mappedName().trim();
- try
- {
- Object value = ValueConvertor.convertValue(type, s);
- container.getEncInjectors().put(encName, new ValueEncInjector(encName, value, "@Resource"));
- injectors.put(field, new JndiFieldInjector(field, encName, container.getEnc()));
- }
- catch(Throwable t)
- {
- throw new RuntimeException("Failed to convert: "+ref.mappedName()+" to type:"+type, t);
- }
- }
- else
- {
- log.warn("Not injecting " + field.getName() + ", no matching enc injector " + encName + " found");
- }
- }
- else
- {
- if (!container.getEncInjectors().containsKey(encName))
- {
- String mappedName = ref.mappedName();
- if (mappedName == null || mappedName.equals(""))
- {
- throw new RuntimeException("You did not specify a @Resource.mappedName() on " + field + " and there is no binding for enc name " + encName + " in XML");
- }
- container.getEncInjectors().put(encName, new LinkRefEncInjector(encName, ref.mappedName(), "@Resource"));
- }
- injectors.put(field, new JndiFieldInjector(field, encName, container.getEnc()));
- }
- */
- }
-
- private void handlePropertyAnnotation(Resource ref, BeanProperty property, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
- {
- assert ref != null;
- assert property != null;
- assert container != null;
- assert injectors != null;
-
- String encName = ref.name();
- if (encName == null || encName.equals(""))
- {
- //encName = InjectionUtil.getEncName(field);
- encName = property.getDeclaringClass().getName() + "/" + property.getName();
- }
- if (!encName.startsWith("env/"))
- {
- encName = "env/" + encName;
- }
-
- AccessibleObject accObj = property.getAccessibleObject();
-
- Class<?> type = property.getType();
- if (!ref.type().equals(Object.class))
- {
- type = ref.type();
- }
-
- if (type.equals(UserTransaction.class))
- {
- injectors.put(accObj, new UserTransactionPropertyInjector(property, container));
- }
- else if (type.equals(TimerService.class))
- {
- injectors.put(accObj, new TimerServicePropertyInjector(property, (Container) container)); // only EJBs
- }
- else if(type.equals(URL.class) && ref.mappedName() != null && ref.mappedName().length() > 0)
- {
- createURLInjector(encName, ref.mappedName(), container);
- injectors.put(accObj, new JndiPropertyInjector(property, encName, container.getEnc()));
- }
- else if (type.equals(String.class)
- || type.equals(Character.class)
- || type.equals(Byte.class)
- || type.equals(Short.class)
- || type.equals(Integer.class)
- || type.equals(Long.class)
- || type.equals(Boolean.class)
- || type.equals(Double.class)
- || type.equals(Float.class)
- || type.isPrimitive()
- )
- {
- // don't add an injector if no XML <env-entry is present as there will be no value to inject
- if (container.getEncInjectors().containsKey(encName))
- {
- injectors.put(accObj, new JndiPropertyInjector(property, encName, container.getEnc()));
- }
- else if (ref.mappedName() != null && ref.mappedName().length() > 0)
- {
- // Use the mappedName as the string value
- String s = ref.mappedName().trim();
- try
- {
- Object value = ValueConvertor.convertValue(type, s);
- container.getEncInjectors().put(encName, new ValueEncInjector(encName, value, "@Resource"));
- injectors.put(accObj, new JndiPropertyInjector(property, encName, container.getEnc()));
- }
- catch(Throwable t)
- {
- throw new RuntimeException("Failed to convert: "+ref.mappedName()+" to type:"+type, t);
- }
- }
- else
- {
- log.warn("Not injecting " + property.getName() + ", no matching enc injector " + encName + " found");
- }
- }
- else
- {
- if (checkEncInjectors && !container.getEncInjectors().containsKey(encName))
- {
- String mappedName = ref.mappedName();
- if (mappedName == null || mappedName.equals(""))
- {
- // TODO: is this a nice trick?
-// if(ConnectionFactory.class.isAssignableFrom(type))
-// {
-// // neat little trick
-// mappedName = "java:/ConnectionFactory";
-// }
-// else
- if(ORB.class.isAssignableFrom(type))
- mappedName = "java:comp/ORB";
- else if(EJBContext.class.isAssignableFrom(type))
- mappedName = "java:comp/EJBContext";
- else
- throw new RuntimeException("You did not specify a @Resource.mappedName() on " + accObj + " and there is no binding for enc name " + encName + " in XML");
- }
- container.getEncInjectors().put(encName, new LinkRefEncInjector(encName, mappedName, "@Resource"));
- }
- injectors.put(accObj, new JndiPropertyInjector(property, encName, container.getEnc()));
- }
- }
-}
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * 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.reflect.AccessibleObject;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Collection;
+import java.util.Map;
+
+import javax.annotation.Resource;
+import javax.annotation.Resources;
+import javax.ejb.EJBContext;
+import javax.ejb.EJBException;
+import javax.ejb.TimerService;
+import javax.transaction.UserTransaction;
+
+import org.jboss.ejb3.Container;
+import org.jboss.injection.EJBContextPropertyInjector;
+import org.jboss.injection.EnvEntryEncInjector;
+import org.jboss.injection.InjectionContainer;
+import org.jboss.injection.InjectionHandler;
+import org.jboss.injection.InjectionUtil;
+import org.jboss.injection.Injector;
+import org.jboss.injection.InjectorFactory;
+import org.jboss.injection.JndiPropertyInjector;
+import org.jboss.injection.LinkRefEncInjector;
+import org.jboss.injection.TimerServicePropertyInjector;
+import org.jboss.injection.UserTransactionPropertyInjector;
+import org.jboss.injection.ValueEncInjector;
+import org.jboss.injection.lang.reflect.BeanProperty;
+import org.jboss.injection.lang.reflect.FieldBeanProperty;
+import org.jboss.injection.lang.reflect.MethodBeanProperty;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.javaee.spec.EnvironmentEntryMetaData;
+import org.jboss.metadata.javaee.spec.MessageDestinationReferenceMetaData;
+import org.jboss.metadata.javaee.spec.RemoteEnvironment;
+import org.jboss.metadata.javaee.spec.ResourceEnvironmentReferenceMetaData;
+import org.jboss.metadata.javaee.spec.ResourceReferenceMetaData;
+import org.jboss.reflect.plugins.ValueConvertor;
+import org.omg.CORBA.ORB;
+
+/**
+ * Handling of resources in the server side setup of the client container.
+ *
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 71076 $
+ */
+public class ResourceHandler<X extends RemoteEnvironment> implements InjectionHandler<X>
+{
+ private static final Logger log = Logger.getLogger(ResourceHandler.class);
+
+ private boolean checkEncInjectors;
+
+ public ResourceHandler()
+ {
+ this(true);
+ }
+
+ public ResourceHandler(boolean checkEncInjectors)
+ {
+ this.checkEncInjectors = checkEncInjectors;
+ }
+
+ private void createURLInjector(String encName, String mappedName, InjectionContainer container)
+ {
+ assert encName.length() > 0 : "encName is empty";
+ assert mappedName.length() > 0 : "mappedName is empty";
+
+ // Create a URL from the mappedName
+ try
+ {
+ URL url = new URL(mappedName.trim());
+ container.getEncInjectors().put(encName, new ValueEncInjector(encName, url, "@Resource"));
+ }
+ catch (MalformedURLException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private static void loadEnvEntry(InjectionContainer container, Collection<EnvironmentEntryMetaData> envEntries)
+ {
+ for (EnvironmentEntryMetaData envEntry : envEntries)
+ {
+ String encName = "env/" + envEntry.getEnvEntryName();
+ // 16.4.1.3: If the env-entry-value is not specified, no value will be injected and it
+ // will not be initialized into the naming context.
+ if(envEntry.getValue() == null)
+ {
+ log.debug("ignoring env-entry " + envEntry);
+ continue;
+ }
+ InjectionUtil.injectionTarget(encName, envEntry, container, container.getEncInjections());
+ if (container.getEncInjectors().containsKey(encName)) continue;
+ log.trace("adding env-entry injector " + encName);
+ container.getEncInjectors().put(encName, new EnvEntryEncInjector(encName, envEntry.getType(), envEntry.getValue()));
+ }
+ }
+
+ private static void loadXmlResourceRefs(InjectionContainer container, Collection<ResourceReferenceMetaData> refs)
+ {
+ for (ResourceReferenceMetaData envRef : refs)
+ {
+ String encName = "env/" + envRef.getResourceRefName();
+ if (container.getEncInjectors().containsKey(encName))
+ continue;
+
+ if (envRef.getMappedName() == null || envRef.getMappedName().equals(""))
+ {
+ if (envRef.getResUrl() != null)
+ {
+ try
+ {
+ container.getEncInjectors().put(encName, new ValueEncInjector(encName, new URL(envRef.getResUrl().trim()), "<resource-ref>"));
+ }
+ catch (MalformedURLException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+ else if (UserTransaction.class.getName().equals(envRef.getType()))
+ {
+ final InjectionContainer ic = container;
+ InjectorFactory<?> factory = new InjectorFactory<UserTransactionPropertyInjector>()
+ {
+ public UserTransactionPropertyInjector create(BeanProperty property)
+ {
+ return new UserTransactionPropertyInjector(property, ic);
+ }
+ };
+ if(envRef.getInjectionTargets() != null)
+ {
+ InjectionUtil.createInjectors(container.getInjectors(), container.getClassloader(), factory, envRef.getInjectionTargets());
+ continue;
+ }
+ else
+ {
+ encName = "java:comp/UserTransaction";
+ }
+ }
+ else if (ORB.class.getName().equals(envRef.getType()))
+ {
+ encName = "java:comp/ORB";
+ }
+ else
+ {
+ throw new RuntimeException("mapped-name is required for " + envRef.getResourceRefName() + " of deployment " + container.getIdentifier());
+ }
+ }
+ else
+ {
+ container.getEncInjectors().put(encName, new LinkRefEncInjector(encName, envRef.getMappedName(), "<resource-ref>"));
+ }
+ InjectionUtil.injectionTarget(encName, envRef, container, container.getEncInjections());
+ }
+ }
+
+ private static void loadXmlResourceEnvRefs(InjectionContainer container, Collection<ResourceEnvironmentReferenceMetaData> refs)
+ {
+ for (ResourceEnvironmentReferenceMetaData envRef : refs)
+ {
+ // EJBTHREE-712
+ // TODO: refactor with handlePropertyAnnotation
+ String resTypeName = envRef.getType();
+ String mappedName = envRef.getMappedName();
+ try
+ {
+ if(resTypeName != null)
+ {
+ Class<?> resType = Class.forName(resTypeName);
+ if(EJBContext.class.isAssignableFrom(resType))
+ {
+ InjectorFactory<?> factory = new InjectorFactory<EJBContextPropertyInjector>()
+ {
+ public EJBContextPropertyInjector create(BeanProperty property)
+ {
+ return new EJBContextPropertyInjector(property);
+ }
+ };
+ InjectionUtil.createInjectors(container.getInjectors(), container.getClassloader(), factory, envRef.getInjectionTargets());
+ continue;
+ }
+ else if (resType.equals(UserTransaction.class))
+ {
+ final InjectionContainer ic = container;
+ InjectorFactory<?> factory = new InjectorFactory<UserTransactionPropertyInjector>()
+ {
+ public UserTransactionPropertyInjector create(BeanProperty property)
+ {
+ return new UserTransactionPropertyInjector(property, ic);
+ }
+ };
+ if(envRef.getInjectionTargets() != null)
+ {
+ InjectionUtil.createInjectors(container.getInjectors(), container.getClassloader(), factory, envRef.getInjectionTargets());
+ continue;
+ }
+ else
+ {
+ mappedName = "java:comp/UserTransaction";
+ }
+ }
+ else if (resType.equals(ORB.class))
+ {
+ mappedName = "java:comp/ORB";
+ }
+ }
+ }
+ catch(ClassNotFoundException e)
+ {
+ throw new EJBException(e);
+ }
+
+ String encName = "env/" + envRef.getResourceEnvRefName();
+ if (container.getEncInjectors().containsKey(encName)) continue;
+ if (mappedName == null || mappedName.equals(""))
+ {
+ throw new RuntimeException("mapped-name is required for " + envRef.getResourceEnvRefName() + " of deployment " + container.getIdentifier());
+ }
+ container.getEncInjectors().put(encName, new LinkRefEncInjector(encName, mappedName, "<resource-ref>"));
+ InjectionUtil.injectionTarget(encName, envRef, container, container.getEncInjections());
+ }
+ }
+
+ private static void loadXmlMessageDestinationRefs(InjectionContainer container, Collection<MessageDestinationReferenceMetaData> refs)
+ {
+ for (MessageDestinationReferenceMetaData envRef : refs)
+ {
+ String encName = "env/" + envRef.getMessageDestinationRefName();
+ if (container.getEncInjectors().containsKey(encName)) continue;
+ String jndiName = envRef.getMappedName();
+ if (jndiName == null || jndiName.equals(""))
+ {
+ // Look for a message-destination-link
+ jndiName = envRef.getResolvedJndiName();
+ if (jndiName == null)
+ {
+ throw new RuntimeException("message-destination has no jndi-name/resolved-jndi-name " + envRef);
+ // TODO: add dependency
+ }
+ }
+ container.getEncInjectors().put(encName, new LinkRefEncInjector(encName, jndiName, "<message-destination-ref>"));
+ InjectionUtil.injectionTarget(encName, envRef, container, container.getEncInjections());
+ }
+ }
+
+ public void loadXml(X xml, InjectionContainer container)
+ {
+ if (xml == null)
+ return;
+ if (xml.getMessageDestinationReferences() != null)
+ loadXmlMessageDestinationRefs(container, xml.getMessageDestinationReferences());
+ if (xml.getResourceEnvironmentReferences() != null)
+ loadXmlResourceEnvRefs(container, xml.getResourceEnvironmentReferences());
+ if (xml.getResourceReferences() != null)
+ loadXmlResourceRefs(container, xml.getResourceReferences());
+ if (xml.getEnvironmentEntries() != null)
+ loadEnvEntry(container, xml.getEnvironmentEntries());
+ }
+
+ public void handleClassAnnotations(Class<?> clazz, InjectionContainer container)
+ {
+ Resources resources = container.getAnnotation(Resources.class, clazz);
+ if (resources != null)
+ {
+ for (Resource ref : resources.value())
+ {
+ handleClassAnnotation(ref, container, clazz);
+ }
+ }
+ Resource res = container.getAnnotation(Resource.class, clazz);
+ if (res != null) handleClassAnnotation(res, container, clazz);
+ }
+
+ private void handleClassAnnotation(Resource ref, InjectionContainer container, Class<?> clazz)
+ {
+ String encName = ref.name();
+ if (encName == null || encName.equals(""))
+ {
+ throw new RuntimeException("JBoss requires name() for class level @Resource");
+ }
+ encName = "env/" + ref.name();
+ if (container.getEncInjectors().containsKey(encName)) return;
+
+ String mappedName = ref.mappedName();
+ if (mappedName == null || mappedName.equals(""))
+ {
+ // Handle class level @Resource(type=ORB.class)
+ if(ORB.class.isAssignableFrom(ref.type()))
+ {
+ mappedName = "java:comp/ORB";
+ }
+ else if(UserTransaction.class.isAssignableFrom(ref.type()))
+ {
+ mappedName = "java:comp/UserTransaction";
+ }
+ else
+ {
+ throw new RuntimeException("You did not specify a @Resource.mappedName() for name: "
+ +ref.name()+", class: " + clazz.getName() + " and there is no binding for that enc name in XML");
+ }
+ }
+
+ if (ref.type() == URL.class)
+ {
+ createURLInjector(encName, mappedName, container);
+ }
+ else
+ {
+ container.getEncInjectors().put(encName, new LinkRefEncInjector(encName, ref.mappedName(), "@Resource"));
+ }
+ }
+
+ public void handleMethodAnnotations(Method method, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
+ {
+ Resource ref = container.getAnnotation(Resource.class, method);
+ if (ref == null) return;
+
+ log.trace("method " + method + " has @Resource");
+
+ handlePropertyAnnotation(ref, new MethodBeanProperty(method), container, injectors);
+ /*
+ String encName = ref.name();
+ if (encName == null || encName.equals(""))
+ {
+ encName = InjectionUtil.getEncName(method);
+ }
+ else
+ {
+ encName = "env/" + encName;
+ }
+
+ method.setAccessible(true);
+
+ if (!method.getName().startsWith("set"))
+ throw new RuntimeException("@Resource can only be used with a set method: " + method);
+ if (method.getParameterTypes().length != 1)
+ throw new RuntimeException("@Resource can only be used with a set method of one parameter: " + method);
+
+ Class type = method.getParameterTypes()[0];
+ if (!ref.type().equals(Object.class))
+ {
+ type = ref.type();
+ }
+ if (type.equals(UserTransaction.class))
+ {
+ injectors.put(method, new UserTransactionMethodInjector(method, container));
+ }
+ else if (type.equals(TimerService.class))
+ {
+ injectors.put(method, new TimerServiceMethodInjector(method, (Container) container)); // only EJBs
+ }
+ else if (EJBContext.class.isAssignableFrom(type))
+ {
+ injectors.put(method, new EJBContextMethodInjector(method));
+ }
+ else if (type.equals(WebServiceContext.class))
+ {
+ // FIXME: For now we skip it, and rely on the WS stack to perform the injection
+ }
+ else if (type.equals(String.class)
+ || type.equals(Character.class)
+ || type.equals(Byte.class)
+ || type.equals(Short.class)
+ || type.equals(Integer.class)
+ || type.equals(Long.class)
+ || type.equals(Boolean.class)
+ || type.equals(Double.class)
+ || type.equals(Float.class)
+ || type.isPrimitive()
+ )
+ {
+
+ // don't add an injector if no XML <env-entry is present as there will be no value to inject
+ if (container.getEncInjectors().containsKey(encName))
+ {
+ injectors.put(method, new JndiMethodInjector(method, encName, container.getEnc()));
+ }
+ else if (ref.mappedName() != null && ref.mappedName().length() > 0)
+ {
+ // Use the mappedName as the string value
+ String s = ref.mappedName().trim();
+ try
+ {
+ Object value = ValueConvertor.convertValue(type, s);
+ container.getEncInjectors().put(encName, new ValueEncInjector(encName, value, "@Resource"));
+ injectors.put(method, new JndiMethodInjector(method, encName, container.getEnc()));
+ }
+ catch(Throwable t)
+ {
+ throw new RuntimeException("Failed to convert: "+ref.mappedName()+" to type:"+type, t);
+ }
+ }
+ }
+ else
+ {
+ if (!container.getEncInjectors().containsKey(encName))
+ {
+ String mappedName = ref.mappedName();
+ if (mappedName == null || mappedName.equals(""))
+ {
+ throw new RuntimeException("You did not specify a @Resource.mappedName() on " + method + " and there is no binding for that enc name in XML");
+ }
+ container.getEncInjectors().put(encName, new LinkRefEncInjector(encName, ref.mappedName(), "@Resource"));
+ }
+ injectors.put(method, new JndiMethodInjector(method, encName, container.getEnc()));
+ }
+ */
+ }
+
+ public void handleFieldAnnotations(Field field, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
+ {
+ Resource ref = container.getAnnotation(Resource.class, field);
+ if (ref == null) return;
+
+ log.trace("field " + field + " has @Resource");
+
+ handlePropertyAnnotation(ref, new FieldBeanProperty(field), container, injectors);
+ /*
+ String encName = ref.name();
+ if (encName == null || encName.equals(""))
+ {
+ encName = InjectionUtil.getEncName(field);
+ }
+ else
+ {
+ encName = "env/" + encName;
+ }
+
+ field.setAccessible(true);
+
+ Class type = field.getType();
+ if (!ref.type().equals(Object.class))
+ {
+ type = ref.type();
+ }
+ if (type.equals(UserTransaction.class))
+ {
+ injectors.put(field, new UserTransactionFieldInjector(field, container));
+ }
+ else if (type.equals(TimerService.class))
+ {
+ injectors.put(field, new TimerServiceFieldInjector(field, (Container) container)); // only EJBs
+ }
+ else if (EJBContext.class.isAssignableFrom(type))
+ {
+ injectors.put(field, new EJBContextFieldInjector(field));
+ }
+ else if (type.equals(WebServiceContext.class))
+ {
+ // FIXME: For now we skip it, and rely on the WS stack to perform the injection
+ }
+ else if (type.equals(String.class)
+ || type.equals(Character.class)
+ || type.equals(Byte.class)
+ || type.equals(Short.class)
+ || type.equals(Integer.class)
+ || type.equals(Long.class)
+ || type.equals(Boolean.class)
+ || type.equals(Double.class)
+ || type.equals(Float.class)
+ || type.isPrimitive()
+ )
+ {
+ // don't add an injector if no XML <env-entry is present as there will be no value to inject
+ if (container.getEncInjectors().containsKey(encName))
+ {
+ injectors.put(field, new JndiFieldInjector(field, encName, container.getEnc()));
+ }
+ else if (ref.mappedName() != null && ref.mappedName().length() > 0)
+ {
+ // Use the mappedName as the string value
+ String s = ref.mappedName().trim();
+ try
+ {
+ Object value = ValueConvertor.convertValue(type, s);
+ container.getEncInjectors().put(encName, new ValueEncInjector(encName, value, "@Resource"));
+ injectors.put(field, new JndiFieldInjector(field, encName, container.getEnc()));
+ }
+ catch(Throwable t)
+ {
+ throw new RuntimeException("Failed to convert: "+ref.mappedName()+" to type:"+type, t);
+ }
+ }
+ else
+ {
+ log.warn("Not injecting " + field.getName() + ", no matching enc injector " + encName + " found");
+ }
+ }
+ else
+ {
+ if (!container.getEncInjectors().containsKey(encName))
+ {
+ String mappedName = ref.mappedName();
+ if (mappedName == null || mappedName.equals(""))
+ {
+ throw new RuntimeException("You did not specify a @Resource.mappedName() on " + field + " and there is no binding for enc name " + encName + " in XML");
+ }
+ container.getEncInjectors().put(encName, new LinkRefEncInjector(encName, ref.mappedName(), "@Resource"));
+ }
+ injectors.put(field, new JndiFieldInjector(field, encName, container.getEnc()));
+ }
+ */
+ }
+
+ private void handlePropertyAnnotation(Resource ref, BeanProperty property, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
+ {
+ assert ref != null;
+ assert property != null;
+ assert container != null;
+ assert injectors != null;
+
+ String encName = ref.name();
+ if (encName == null || encName.equals(""))
+ {
+ //encName = InjectionUtil.getEncName(field);
+ encName = property.getDeclaringClass().getName() + "/" + property.getName();
+ }
+ if (!encName.startsWith("env/"))
+ {
+ encName = "env/" + encName;
+ }
+
+ AccessibleObject accObj = property.getAccessibleObject();
+
+ Class<?> type = property.getType();
+ if (!ref.type().equals(Object.class))
+ {
+ type = ref.type();
+ }
+
+ if (type.equals(UserTransaction.class))
+ {
+ injectors.put(accObj, new UserTransactionPropertyInjector(property, container));
+ }
+ else if (type.equals(TimerService.class))
+ {
+ injectors.put(accObj, new TimerServicePropertyInjector(property, (Container) container)); // only EJBs
+ }
+ else if(type.equals(URL.class) && ref.mappedName() != null && ref.mappedName().length() > 0)
+ {
+ createURLInjector(encName, ref.mappedName(), container);
+ injectors.put(accObj, new JndiPropertyInjector(property, encName, container.getEnc()));
+ }
+ else if (type.equals(String.class)
+ || type.equals(Character.class)
+ || type.equals(Byte.class)
+ || type.equals(Short.class)
+ || type.equals(Integer.class)
+ || type.equals(Long.class)
+ || type.equals(Boolean.class)
+ || type.equals(Double.class)
+ || type.equals(Float.class)
+ || type.isPrimitive()
+ )
+ {
+ // don't add an injector if no XML <env-entry is present as there will be no value to inject
+ if (container.getEncInjectors().containsKey(encName))
+ {
+ injectors.put(accObj, new JndiPropertyInjector(property, encName, container.getEnc()));
+ }
+ else if (ref.mappedName() != null && ref.mappedName().length() > 0)
+ {
+ // Use the mappedName as the string value
+ String s = ref.mappedName().trim();
+ try
+ {
+ Object value = ValueConvertor.convertValue(type, s);
+ container.getEncInjectors().put(encName, new ValueEncInjector(encName, value, "@Resource"));
+ injectors.put(accObj, new JndiPropertyInjector(property, encName, container.getEnc()));
+ }
+ catch(Throwable t)
+ {
+ throw new RuntimeException("Failed to convert: "+ref.mappedName()+" to type:"+type, t);
+ }
+ }
+ else
+ {
+ log.warn("Not injecting " + property.getName() + ", no matching enc injector " + encName + " found");
+ }
+ }
+ else
+ {
+ if (checkEncInjectors && !container.getEncInjectors().containsKey(encName))
+ {
+ String mappedName = ref.mappedName();
+ if (mappedName == null || mappedName.equals(""))
+ {
+ // TODO: is this a nice trick?
+// if(ConnectionFactory.class.isAssignableFrom(type))
+// {
+// // neat little trick
+// mappedName = "java:/ConnectionFactory";
+// }
+// else
+ if(ORB.class.isAssignableFrom(type))
+ mappedName = "java:comp/ORB";
+ else if(EJBContext.class.isAssignableFrom(type))
+ mappedName = "java:comp/EJBContext";
+ else
+ throw new RuntimeException("You did not specify a @Resource.mappedName() on " + accObj + " and there is no binding for enc name " + encName + " in XML");
+ }
+ container.getEncInjectors().put(encName, new LinkRefEncInjector(encName, mappedName, "@Resource"));
+ }
+ injectors.put(accObj, new JndiPropertyInjector(property, encName, container.getEnc()));
+ }
+ }
+}
Property changes on: trunk/ejb3/src/main/org/jboss/ejb3/clientmodule/ResourceHandler.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/ejb3/src/main/org/jboss/ejb3/deployers/AppClientParsingDeployer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/deployers/AppClientParsingDeployer.java 2008-11-14 14:58:15 UTC (rev 81052)
+++ trunk/ejb3/src/main/org/jboss/ejb3/deployers/AppClientParsingDeployer.java 2008-11-14 14:59:40 UTC (rev 81053)
@@ -1,43 +1,43 @@
-/*
- * 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.vfs.spi.deployer.SchemaResolverDeployer;
-import org.jboss.metadata.client.spec.ApplicationClientMetaData;
-
-/**
- * The javaee application client descriptor parsing deployer
- *
- * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @author adrian at jboss.org
- * @author Scott.Stark at jboss.org
- * @version $Revision: $
- */
-public class AppClientParsingDeployer extends SchemaResolverDeployer<ApplicationClientMetaData>
-{
- public AppClientParsingDeployer()
- {
- super(ApplicationClientMetaData.class);
- setName("application-client.xml");
- }
-
-}
+/*
+ * 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.vfs.spi.deployer.SchemaResolverDeployer;
+import org.jboss.metadata.client.spec.ApplicationClientMetaData;
+
+/**
+ * The javaee application client descriptor parsing deployer
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @author adrian at jboss.org
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: $
+ */
+public class AppClientParsingDeployer extends SchemaResolverDeployer<ApplicationClientMetaData>
+{
+ public AppClientParsingDeployer()
+ {
+ super(ApplicationClientMetaData.class);
+ setName("application-client.xml");
+ }
+
+}
Property changes on: trunk/ejb3/src/main/org/jboss/ejb3/deployers/AppClientParsingDeployer.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/ejb3/src/main/org/jboss/ejb3/deployers/AppClientScanningDeployer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/deployers/AppClientScanningDeployer.java 2008-11-14 14:58:15 UTC (rev 81052)
+++ trunk/ejb3/src/main/org/jboss/ejb3/deployers/AppClientScanningDeployer.java 2008-11-14 14:59:40 UTC (rev 81053)
@@ -1,133 +1,133 @@
-/*
- * 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.deployers;
-
-import java.io.IOException;
-import java.lang.reflect.Field;
-import java.util.jar.Attributes;
-import java.util.jar.Manifest;
-
-import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
-import org.jboss.metadata.client.jboss.JBossClientMetaData;
-import org.jboss.virtual.VFSUtils;
-import org.jboss.virtual.VirtualFile;
-
-/**
- * Scan the main & super classes for annotations.
- *
- * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @author adrian at jboss.org
- * @version $Revision: $
- */
-public class AppClientScanningDeployer extends AbstractOptionalVFSRealDeployer<JBossClientMetaData>
-{
-
- public AppClientScanningDeployer()
- {
- super(JBossClientMetaData.class);
- setOutput(JBossClientMetaData.class);
- }
-
- /* (non-Javadoc)
- * @see org.jboss.deployers.plugins.deployer.AbstractSimpleDeployer#deploy(org.jboss.deployers.spi.deployer.DeploymentUnit)
- */
- @Override
- public void deploy(VFSDeploymentUnit unit, JBossClientMetaData dd) throws DeploymentException
- {
- // FIXME: implement metadata complete
-// if(dd != null && dd.getMetaDataComplete())
-// return;
- // for now the EJB3 client deployer handles all
- if(dd != null)
- return;
-
- try
- {
- String mainClassName = getMainClassName(unit);
- if(mainClassName == null)
- return;
-
- Class<?> mainClass = unit.getClassLoader().loadClass(mainClassName);
-
- log.info("mainClass = " + mainClass);
-
- if(hasAnnotations(mainClass))
- {
- // add a dummy application client dd to fire up the ejb3 client deployer
- dd = new JBossClientMetaData();
- unit.addAttachment(JBossClientMetaData.class, dd);
- }
- }
- catch(ClassNotFoundException e)
- {
- throw new DeploymentException(e);
- }
- catch(IOException e)
- {
- throw new DeploymentException(e);
- }
- }
-
- // TODO: integrate with Ejb3ClientDeployer.getMainClassName
- private String getMainClassName(VFSDeploymentUnit unit) throws IOException
- {
- VirtualFile file = unit.getMetaDataFile("MANIFEST.MF");
- log.trace("parsing " + file);
-
- if(file == null)
- {
- return null;
- }
-
- try
- {
- Manifest mf = VFSUtils.readManifest(file);
- Attributes attrs = mf.getMainAttributes();
- String className = attrs.getValue(Attributes.Name.MAIN_CLASS);
- return className;
- }
- finally
- {
- file.close();
- }
- }
-
- // TODO: should we check for type of annotations?
- private boolean hasAnnotations(Class<?> cls)
- {
- if(cls == null)
- return false;
-
- // Note: this also returns true if super class has annotations
- if(cls.getAnnotations().length > 0)
- return true;
-
- for(Field f : cls.getDeclaredFields())
- {
- if(f.getAnnotations().length > 0)
- return true;
- }
-
- return hasAnnotations(cls.getSuperclass());
- }
-}
+/*
+ * 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.deployers;
+
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.util.jar.Attributes;
+import java.util.jar.Manifest;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.metadata.client.jboss.JBossClientMetaData;
+import org.jboss.virtual.VFSUtils;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * Scan the main & super classes for annotations.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @author adrian at jboss.org
+ * @version $Revision: $
+ */
+public class AppClientScanningDeployer extends AbstractOptionalVFSRealDeployer<JBossClientMetaData>
+{
+
+ public AppClientScanningDeployer()
+ {
+ super(JBossClientMetaData.class);
+ setOutput(JBossClientMetaData.class);
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.deployers.plugins.deployer.AbstractSimpleDeployer#deploy(org.jboss.deployers.spi.deployer.DeploymentUnit)
+ */
+ @Override
+ public void deploy(VFSDeploymentUnit unit, JBossClientMetaData dd) throws DeploymentException
+ {
+ // FIXME: implement metadata complete
+// if(dd != null && dd.getMetaDataComplete())
+// return;
+ // for now the EJB3 client deployer handles all
+ if(dd != null)
+ return;
+
+ try
+ {
+ String mainClassName = getMainClassName(unit);
+ if(mainClassName == null)
+ return;
+
+ Class<?> mainClass = unit.getClassLoader().loadClass(mainClassName);
+
+ log.info("mainClass = " + mainClass);
+
+ if(hasAnnotations(mainClass))
+ {
+ // add a dummy application client dd to fire up the ejb3 client deployer
+ dd = new JBossClientMetaData();
+ unit.addAttachment(JBossClientMetaData.class, dd);
+ }
+ }
+ catch(ClassNotFoundException e)
+ {
+ throw new DeploymentException(e);
+ }
+ catch(IOException e)
+ {
+ throw new DeploymentException(e);
+ }
+ }
+
+ // TODO: integrate with Ejb3ClientDeployer.getMainClassName
+ private String getMainClassName(VFSDeploymentUnit unit) throws IOException
+ {
+ VirtualFile file = unit.getMetaDataFile("MANIFEST.MF");
+ log.trace("parsing " + file);
+
+ if(file == null)
+ {
+ return null;
+ }
+
+ try
+ {
+ Manifest mf = VFSUtils.readManifest(file);
+ Attributes attrs = mf.getMainAttributes();
+ String className = attrs.getValue(Attributes.Name.MAIN_CLASS);
+ return className;
+ }
+ finally
+ {
+ file.close();
+ }
+ }
+
+ // TODO: should we check for type of annotations?
+ private boolean hasAnnotations(Class<?> cls)
+ {
+ if(cls == null)
+ return false;
+
+ // Note: this also returns true if super class has annotations
+ if(cls.getAnnotations().length > 0)
+ return true;
+
+ for(Field f : cls.getDeclaredFields())
+ {
+ if(f.getAnnotations().length > 0)
+ return true;
+ }
+
+ return hasAnnotations(cls.getSuperclass());
+ }
+}
Property changes on: trunk/ejb3/src/main/org/jboss/ejb3/deployers/AppClientScanningDeployer.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/ejb3/src/main/org/jboss/ejb3/deployers/EJBRegistrationDeployer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/deployers/EJBRegistrationDeployer.java 2008-11-14 14:58:15 UTC (rev 81052)
+++ trunk/ejb3/src/main/org/jboss/ejb3/deployers/EJBRegistrationDeployer.java 2008-11-14 14:59:40 UTC (rev 81053)
@@ -1,312 +1,312 @@
-/*
-* 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.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Properties;
-
-import javax.management.MBeanServer;
-
-import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.vfs.spi.deployer.AbstractVFSRealDeployer;
-import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
-import org.jboss.deployment.security.JaccPolicyUtil;
-import org.jboss.deployment.spi.DeploymentEndpointResolver;
-import org.jboss.ejb3.DeploymentScope;
-import org.jboss.ejb3.Ejb3Deployment;
-import org.jboss.kernel.Kernel;
-import org.jboss.logging.Logger;
-import org.jboss.metadata.ear.jboss.JBossAppMetaData;
-import org.jboss.virtual.VirtualFile;
-
-/**
- * Creates initial EJB deployments and initializes only basic metadata.
- * A registration process is required so that
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @author adrian at jboss.org
- * @version $Revision: 57082 $
- * @deprecated use Ejb3Deployer
- */
- at Deprecated
-public class EJBRegistrationDeployer extends AbstractVFSRealDeployer
-{
- private static final Logger log = Logger.getLogger(EJBRegistrationDeployer.class);
-
- private HashSet ignoredJarsSet;
- private MBeanServer mbeanServer;
- private Kernel kernel;
- private Properties defaultPersistenceProperties;
- private List<String> allowedSuffixes;
- private boolean requireDeploymentDescriptor;
-
- public static boolean has30EjbJarXml(InputStream ddStream)
- {
- try
- {
- // look for version="3.0" in the file
- byte[] stringToFind = "version=\"3.0\"".getBytes();
- InputStreamReader reader = new InputStreamReader(ddStream);
- try
- {
- int idx = 0;
- int len = stringToFind.length;
- while (reader.ready())
- {
- int read = reader.read();
- if (read == stringToFind[idx])
- {
- idx++;
- if (idx == len)
- {
- return true;
- }
- }
- else
- {
- idx = 0;
- }
- }
-
- }
- finally
- {
- try
- {
- reader.close();
- ddStream.close();
- }
- catch (IOException ignored)
- {
- }
- }
- }
- catch (Exception ignore)
- {
- }
- return false;
- }
-
- /**
- * Create a new EJBRegistrationDeployer.
- */
- public EJBRegistrationDeployer()
- {
- setOutputs(Ejb3Deployment.class.getName(), JaccPolicyUtil.IGNORE_ME_NAME);
- }
-
- public List<String> getAllowedSuffixes()
- {
- return allowedSuffixes;
- }
-
- public void setAllowedSuffixes(List<String> allowedSuffixes)
- {
- this.allowedSuffixes = allowedSuffixes;
- }
-
- public HashSet getIgnoredJarsSet()
- {
- return ignoredJarsSet;
- }
-
- public void setIgnoredJarsSet(HashSet ignoredJarsSet)
- {
- this.ignoredJarsSet = ignoredJarsSet;
- }
-
- public MBeanServer getMbeanServer()
- {
- return mbeanServer;
- }
-
- public void setMbeanServer(MBeanServer mbeanServer)
- {
- this.mbeanServer = mbeanServer;
- }
-
- public Kernel getKernel()
- {
- return kernel;
- }
-
- public void setKernel(Kernel kernel)
- {
- this.kernel = kernel;
- }
-
- public Properties getDefaultPersistenceProperties()
- {
- return defaultPersistenceProperties;
- }
-
- public void setDefaultPersistenceProperties(Properties defaultPersistenceProperties)
- {
- this.defaultPersistenceProperties = defaultPersistenceProperties;
- }
-
- public boolean getRequireDeploymentDescriptor()
- {
- return requireDeploymentDescriptor;
- }
-
- public void setRequireDeploymentDescriptor(boolean requireDeploymentDescriptor)
- {
- this.requireDeploymentDescriptor = requireDeploymentDescriptor;
- }
-
- public void deploy(VFSDeploymentUnit unit) throws DeploymentException
- {
- try
- {
- // Initialize
- boolean hasEjbDd = false;
- boolean hasJbossDd = false;
-
- VirtualFile jar = unit.getRoot();
- if (jar.isLeaf() || ignoredJarsSet.contains(jar.getName()))
- {
- log.trace("EJBRegistrationDeployer ignoring: " + jar.getName());
- return;
- }
- if(!hasAllowedSuffix(jar.getName()))
- {
- log.trace("EJBRegistrationDeployer suffix not allowed: " + jar.getName());
- return;
- }
-
- VirtualFile ejbjar = unit.getMetaDataFile("ejb-jar.xml");
- if (ejbjar != null)
- {
- InputStream is = ejbjar.openStream();
- boolean has30EjbJarXml = has30EjbJarXml(is);
- is.close();
- if (!has30EjbJarXml) {
- return;
- }
- else {
- hasEjbDd = true;
- }
- }
-
- // Determine if jboss.xml is specified
- hasJbossDd = unit.getMetaDataFile("jboss.xml")!=null;
-
- // If DDs are required and none are present, skip deployment
- // EJBTHREE-1040
- if (this.getRequireDeploymentDescriptor() && !(hasJbossDd || hasEjbDd))
- {
- log.trace(EJBRegistrationDeployer.class.getSimpleName() + " skipping deployment \"" + unit.getSimpleName()
- + "\", jar: \"" + jar.getName()
- + "\" - either EJB3 Deployment Descriptor or \"jboss.xml\" is required and neither were found.");
- return;
- }
-
- log.debug("********* EJBRegistrationDepoyer Begin Unit: " + unit.getSimpleName() + " jar: " + jar.getName());
- JBoss5DeploymentScope scope = null;
- VFSDeploymentUnit parent = unit.getParent();
- boolean initScopeDeployment = false;
- if (parent != null && parent.isAttachmentPresent(JBossAppMetaData.class))
- {
- // An ear parent
- scope = (JBoss5DeploymentScope) parent.getAttachment(DeploymentScope.class);
- if (scope == null)
- {
- boolean isEar = unit != unit.getTopLevel();
- if(parent.isAttachmentPresent(DeploymentEndpointResolver.class) == true)
- scope = new JBoss5DeploymentScope(parent, isEar);
- else
- {
- // EJBTHREE-1291
- scope = new JBoss5DeploymentScope(parent, isEar, unit.getSimpleName());
- initScopeDeployment = true;
- }
- parent.addAttachment(DeploymentScope.class, scope);
- }
- }
- JBoss5DeploymentUnit du = new JBoss5DeploymentUnit(unit);
- du.setDefaultPersistenceProperties(defaultPersistenceProperties);
- Ejb3JBoss5Deployment deployment = new Ejb3JBoss5Deployment(du, kernel, mbeanServer, unit, scope, null);
- if (scope != null)
- scope.register(deployment);
- if(initScopeDeployment)
- {
- scope.setDeployment(deployment);
- }
- // create() creates initial EJB containers and initializes metadata.
- deployment.create();
- if (deployment.getEjbContainers().size() == 0)
- {
- log.trace("EJBRegistrationDeployer no containers in scanned jar, consider adding it to the ignore list: " + jar.getName() + " url: " + jar.toURL() + " unit: " + unit.getSimpleName());
- return;
- }
- unit.addAttachment(Ejb3Deployment.class, deployment);
- // TODO: temporarily disable the security deployment
- unit.addAttachment(JaccPolicyUtil.IGNORE_ME_NAME, true, Boolean.class);
- }
- catch (Exception e)
- {
- throw new DeploymentException(e);
- }
- }
-
- private boolean hasAllowedSuffix(String name)
- {
- if(allowedSuffixes == null)
- return true;
-
- for (String suffix : allowedSuffixes)
- {
- if (name.endsWith(suffix))
- {
- return true;
- }
- }
- return false;
- }
-
- public void undeploy(VFSDeploymentUnit unit)
- {
- Ejb3Deployment deployment = unit.getAttachment(Ejb3Deployment.class);
- if (deployment == null) return;
- try
- {
- deployment.stop();
- }
- catch (Exception e)
- {
- log.error("failed to stop deployment", e);
- }
- try
- {
- deployment.destroy();
- }
- catch (Exception e)
- {
- log.error("failed to destroy deployment", e);
- }
- }
-}
+/*
+* 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.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Properties;
+
+import javax.management.MBeanServer;
+
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.vfs.spi.deployer.AbstractVFSRealDeployer;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.deployment.security.JaccPolicyUtil;
+import org.jboss.deployment.spi.DeploymentEndpointResolver;
+import org.jboss.ejb3.DeploymentScope;
+import org.jboss.ejb3.Ejb3Deployment;
+import org.jboss.kernel.Kernel;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.ear.jboss.JBossAppMetaData;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * Creates initial EJB deployments and initializes only basic metadata.
+ * A registration process is required so that
+ *
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @author adrian at jboss.org
+ * @version $Revision: 57082 $
+ * @deprecated use Ejb3Deployer
+ */
+ at Deprecated
+public class EJBRegistrationDeployer extends AbstractVFSRealDeployer
+{
+ private static final Logger log = Logger.getLogger(EJBRegistrationDeployer.class);
+
+ private HashSet ignoredJarsSet;
+ private MBeanServer mbeanServer;
+ private Kernel kernel;
+ private Properties defaultPersistenceProperties;
+ private List<String> allowedSuffixes;
+ private boolean requireDeploymentDescriptor;
+
+ public static boolean has30EjbJarXml(InputStream ddStream)
+ {
+ try
+ {
+ // look for version="3.0" in the file
+ byte[] stringToFind = "version=\"3.0\"".getBytes();
+ InputStreamReader reader = new InputStreamReader(ddStream);
+ try
+ {
+ int idx = 0;
+ int len = stringToFind.length;
+ while (reader.ready())
+ {
+ int read = reader.read();
+ if (read == stringToFind[idx])
+ {
+ idx++;
+ if (idx == len)
+ {
+ return true;
+ }
+ }
+ else
+ {
+ idx = 0;
+ }
+ }
+
+ }
+ finally
+ {
+ try
+ {
+ reader.close();
+ ddStream.close();
+ }
+ catch (IOException ignored)
+ {
+ }
+ }
+ }
+ catch (Exception ignore)
+ {
+ }
+ return false;
+ }
+
+ /**
+ * Create a new EJBRegistrationDeployer.
+ */
+ public EJBRegistrationDeployer()
+ {
+ setOutputs(Ejb3Deployment.class.getName(), JaccPolicyUtil.IGNORE_ME_NAME);
+ }
+
+ public List<String> getAllowedSuffixes()
+ {
+ return allowedSuffixes;
+ }
+
+ public void setAllowedSuffixes(List<String> allowedSuffixes)
+ {
+ this.allowedSuffixes = allowedSuffixes;
+ }
+
+ public HashSet getIgnoredJarsSet()
+ {
+ return ignoredJarsSet;
+ }
+
+ public void setIgnoredJarsSet(HashSet ignoredJarsSet)
+ {
+ this.ignoredJarsSet = ignoredJarsSet;
+ }
+
+ public MBeanServer getMbeanServer()
+ {
+ return mbeanServer;
+ }
+
+ public void setMbeanServer(MBeanServer mbeanServer)
+ {
+ this.mbeanServer = mbeanServer;
+ }
+
+ public Kernel getKernel()
+ {
+ return kernel;
+ }
+
+ public void setKernel(Kernel kernel)
+ {
+ this.kernel = kernel;
+ }
+
+ public Properties getDefaultPersistenceProperties()
+ {
+ return defaultPersistenceProperties;
+ }
+
+ public void setDefaultPersistenceProperties(Properties defaultPersistenceProperties)
+ {
+ this.defaultPersistenceProperties = defaultPersistenceProperties;
+ }
+
+ public boolean getRequireDeploymentDescriptor()
+ {
+ return requireDeploymentDescriptor;
+ }
+
+ public void setRequireDeploymentDescriptor(boolean requireDeploymentDescriptor)
+ {
+ this.requireDeploymentDescriptor = requireDeploymentDescriptor;
+ }
+
+ public void deploy(VFSDeploymentUnit unit) throws DeploymentException
+ {
+ try
+ {
+ // Initialize
+ boolean hasEjbDd = false;
+ boolean hasJbossDd = false;
+
+ VirtualFile jar = unit.getRoot();
+ if (jar.isLeaf() || ignoredJarsSet.contains(jar.getName()))
+ {
+ log.trace("EJBRegistrationDeployer ignoring: " + jar.getName());
+ return;
+ }
+ if(!hasAllowedSuffix(jar.getName()))
+ {
+ log.trace("EJBRegistrationDeployer suffix not allowed: " + jar.getName());
+ return;
+ }
+
+ VirtualFile ejbjar = unit.getMetaDataFile("ejb-jar.xml");
+ if (ejbjar != null)
+ {
+ InputStream is = ejbjar.openStream();
+ boolean has30EjbJarXml = has30EjbJarXml(is);
+ is.close();
+ if (!has30EjbJarXml) {
+ return;
+ }
+ else {
+ hasEjbDd = true;
+ }
+ }
+
+ // Determine if jboss.xml is specified
+ hasJbossDd = unit.getMetaDataFile("jboss.xml")!=null;
+
+ // If DDs are required and none are present, skip deployment
+ // EJBTHREE-1040
+ if (this.getRequireDeploymentDescriptor() && !(hasJbossDd || hasEjbDd))
+ {
+ log.trace(EJBRegistrationDeployer.class.getSimpleName() + " skipping deployment \"" + unit.getSimpleName()
+ + "\", jar: \"" + jar.getName()
+ + "\" - either EJB3 Deployment Descriptor or \"jboss.xml\" is required and neither were found.");
+ return;
+ }
+
+ log.debug("********* EJBRegistrationDepoyer Begin Unit: " + unit.getSimpleName() + " jar: " + jar.getName());
+ JBoss5DeploymentScope scope = null;
+ VFSDeploymentUnit parent = unit.getParent();
+ boolean initScopeDeployment = false;
+ if (parent != null && parent.isAttachmentPresent(JBossAppMetaData.class))
+ {
+ // An ear parent
+ scope = (JBoss5DeploymentScope) parent.getAttachment(DeploymentScope.class);
+ if (scope == null)
+ {
+ boolean isEar = unit != unit.getTopLevel();
+ if(parent.isAttachmentPresent(DeploymentEndpointResolver.class) == true)
+ scope = new JBoss5DeploymentScope(parent, isEar);
+ else
+ {
+ // EJBTHREE-1291
+ scope = new JBoss5DeploymentScope(parent, isEar, unit.getSimpleName());
+ initScopeDeployment = true;
+ }
+ parent.addAttachment(DeploymentScope.class, scope);
+ }
+ }
+ JBoss5DeploymentUnit du = new JBoss5DeploymentUnit(unit);
+ du.setDefaultPersistenceProperties(defaultPersistenceProperties);
+ Ejb3JBoss5Deployment deployment = new Ejb3JBoss5Deployment(du, kernel, mbeanServer, unit, scope, null);
+ if (scope != null)
+ scope.register(deployment);
+ if(initScopeDeployment)
+ {
+ scope.setDeployment(deployment);
+ }
+ // create() creates initial EJB containers and initializes metadata.
+ deployment.create();
+ if (deployment.getEjbContainers().size() == 0)
+ {
+ log.trace("EJBRegistrationDeployer no containers in scanned jar, consider adding it to the ignore list: " + jar.getName() + " url: " + jar.toURL() + " unit: " + unit.getSimpleName());
+ return;
+ }
+ unit.addAttachment(Ejb3Deployment.class, deployment);
+ // TODO: temporarily disable the security deployment
+ unit.addAttachment(JaccPolicyUtil.IGNORE_ME_NAME, true, Boolean.class);
+ }
+ catch (Exception e)
+ {
+ throw new DeploymentException(e);
+ }
+ }
+
+ private boolean hasAllowedSuffix(String name)
+ {
+ if(allowedSuffixes == null)
+ return true;
+
+ for (String suffix : allowedSuffixes)
+ {
+ if (name.endsWith(suffix))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public void undeploy(VFSDeploymentUnit unit)
+ {
+ Ejb3Deployment deployment = unit.getAttachment(Ejb3Deployment.class);
+ if (deployment == null) return;
+ try
+ {
+ deployment.stop();
+ }
+ catch (Exception e)
+ {
+ log.error("failed to stop deployment", e);
+ }
+ try
+ {
+ deployment.destroy();
+ }
+ catch (Exception e)
+ {
+ log.error("failed to destroy deployment", e);
+ }
+ }
+}
Property changes on: trunk/ejb3/src/main/org/jboss/ejb3/deployers/EJBRegistrationDeployer.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/ejb3/src/main/org/jboss/ejb3/deployers/Ejb3ClientDeployer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/deployers/Ejb3ClientDeployer.java 2008-11-14 14:58:15 UTC (rev 81052)
+++ trunk/ejb3/src/main/org/jboss/ejb3/deployers/Ejb3ClientDeployer.java 2008-11-14 14:59:40 UTC (rev 81053)
@@ -1,322 +1,322 @@
-/*
- * 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.util.ArrayList;
-import java.util.List;
-import java.util.jar.Attributes;
-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.beans.metadata.api.annotations.Inject;
-import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.deployers.spi.structure.ClassPathEntry;
-import org.jboss.deployers.spi.structure.StructureMetaData;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.deployers.vfs.spi.deployer.AbstractSimpleVFSRealDeployer;
-import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
-import org.jboss.ejb3.InitialContextFactory;
-import org.jboss.ejb3.KernelAbstraction;
-import org.jboss.ejb3.clientmodule.ClientENCInjectionContainer;
-import org.jboss.jpa.resolvers.PersistenceUnitDependencyResolver;
-import org.jboss.kernel.Kernel;
-import org.jboss.kernel.spi.deployment.KernelDeployment;
-import org.jboss.metadata.client.jboss.JBossClientMetaData;
-import org.jboss.metadata.ear.jboss.JBossAppMetaData;
-import org.jboss.naming.Util;
-import org.jboss.virtual.VFSUtils;
-import org.jboss.virtual.VirtualFile;
-
-/**
- * Deploys a client application jar.
- *
- * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @author adrian at jboss.org
- * @version $Revision: $
- */
-public class Ejb3ClientDeployer extends AbstractSimpleVFSRealDeployer<JBossClientMetaData>
-{
- private Kernel kernel;
- private MBeanServer server;
- /** A flag indicating if a deployment based jndi should be linked to the JBossClientMetaData.jndiName */
- private boolean linkDeploymentJndiName = true;
-
- private PersistenceUnitDependencyResolver persistenceUnitDependencyResolver;
-
- /**
- * Create a new Ejb3ClientDeployer.
- */
- public Ejb3ClientDeployer()
- {
- super(JBossClientMetaData.class);
- setOutput(ClientENCInjectionContainer.class);
- // JBossASKernel install output
- setOutput(KernelDeployment.class);
- }
-
- public boolean isLinkDeploymentJndiName()
- {
- return linkDeploymentJndiName;
- }
-
- public void setLinkDeploymentJndiName(boolean linkDeploymentJndiName)
- {
- this.linkDeploymentJndiName = linkDeploymentJndiName;
- }
-
- /**
- * Deploy a client application
- * @param unit - the application jar unit
- * @param metaData - the metadata for the application
- */
- @Override
- public void deploy(VFSDeploymentUnit unit, JBossClientMetaData metaData) throws DeploymentException
- {
- log.debug("deploy " + unit.getName());
-
- String appClientName = getJndiName(metaData);
- String deploymentClientName = null;
- if(appClientName == null)
- appClientName = getDeploymentJndiName(unit);
- else if(linkDeploymentJndiName)
- deploymentClientName = getDeploymentJndiName(unit);
-
- try
- {
- // I create the namespace here, because I destroy it in undeploy
- InitialContext iniCtx = InitialContextFactory.getInitialContext();
- Context encCtx = Util.createSubcontext(iniCtx, appClientName);
- log.debug("Creating client ENC binding under: " + appClientName);
- if(deploymentClientName != null && deploymentClientName.equals(appClientName) == false)
- {
- Util.createLinkRef(iniCtx, deploymentClientName, appClientName);
- }
-
- // Notify the client launcher of extra class path entries in an EAR (See EE 8.2)
- List<VirtualFile> classPath = unit.getClassPath();
- ArrayList<String> cpURIs = new ArrayList<String>();
- for(VirtualFile vf : classPath)
- {
- String uri = vf.toURI().toString();
- cpURIs.add(uri);
- }
- // Also need to include the ear lib dir entries
- VFSDeploymentUnit earUnit = unit.getParent();
- if(earUnit != null)
- {
- List<VirtualFile> earClassPath = earUnit.getClassPath();
- JBossAppMetaData earMD = earUnit.getAttachment(JBossAppMetaData.class);
- if(earMD != null)
- {
- String libDir = earMD.getLibraryDirectory();
- if(libDir == null)
- libDir = "lib";
- String libDirPrefix = libDir + "/";
- for(VirtualFile vf : earClassPath)
- {
- if(vf.getPathName().startsWith(libDirPrefix))
- {
- String uri = vf.toURI().toString();
- cpURIs.add(uri);
- }
- }
- }
- }
-
- encCtx.bind("classPathEntries", cpURIs);
- // java:comp/UserTransaction -> UserTransaction
- Util.createLinkRef(encCtx, "UserTransaction", "UserTransaction");
-
- // TODO: Notify the client launcher of other metadata stuff (injectors, lifecycle callbacks etc)
- // FIXME: For now I expose the entire metadata
- encCtx.bind("metaData", metaData);
-
- String mainClassName = getMainClassName(unit, true);
-
- Class<?> mainClass = loadClass(unit, mainClassName);
-
- ClientENCInjectionContainer container = new ClientENCInjectionContainer(unit, metaData, mainClass, appClientName, unit.getClassLoader(), encCtx, persistenceUnitDependencyResolver);
-
- //di.deployedObject = container.getObjectName();
- unit.addAttachment(ClientENCInjectionContainer.class, container);
- JBoss5DeploymentUnit ejb3Unit = new JBoss5DeploymentUnit(unit);
- getKernelAbstraction().install(container.getObjectName().getCanonicalName(),
- container.getDependencyPolicy(), ejb3Unit, container);
- }
- catch(Exception e)
- {
- log.error("Could not deploy " + unit.getName(), e);
- undeploy(unit, metaData);
- throw new DeploymentException("Could not deploy " + unit.getName(), e);
- }
- }
-
- /**
- * Get the class path entries which have been determined by the EARStructure.
- * Will return null if this unit is not part of an ear deployment.
- */
- private List<ClassPathEntry> getClassPathEntries(VFSDeploymentUnit unit)
- {
-// log.info("class path = " + unit.getTopLevel().getAttachment(StructureMetaData.class).getContext("").getClassPath());
- StructureMetaData smd = unit.getTopLevel().getAttachment(StructureMetaData.class);
- if(smd == null)
- return null;
- // A context without a path is the one we want (see AbstractStructureDeployer)
- return smd.getContext("").getClassPath();
- }
-
- /**
- * 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 unit
- * @param dd
- * @return a good JNDI name
- */
- private String getJndiName(JBossClientMetaData dd)
- {
- String jndiName = dd.getJndiName();
- return jndiName;
- }
- private String getDeploymentJndiName(DeploymentUnit unit)
- {
- String jndiName;
- String shortName = unit.getSimpleName();
- 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 JBossASKernel(kernel);
- }
-
- // TODO: move this method either to a utility class or to the scanning deployer
- protected String getMainClassName(VFSDeploymentUnit unit, boolean fail) throws Exception
- {
- VirtualFile file = unit.getMetaDataFile("MANIFEST.MF");
- log.trace("parsing " + file);
- // Default to the jboss client main
- String mainClassName = "org.jboss.client.AppClientMain";
-
- if (file != null)
- {
- try
- {
- Manifest mf = VFSUtils.readManifest(file);
- Attributes attrs = mf.getMainAttributes();
- String className = attrs.getValue(Attributes.Name.MAIN_CLASS);
- if (className != null)
- {
- mainClassName = className;
- }
- }
- finally
- {
- file.close();
- }
- }
- return mainClassName;
- }
-
- 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;
- }
-
- @Inject
- public void setPersistenceUnitDependencyResolver(PersistenceUnitDependencyResolver resolver)
- {
- this.persistenceUnitDependencyResolver = resolver;
- }
-
- @Override
- public void undeploy(VFSDeploymentUnit unit, JBossClientMetaData metaData)
- {
- log.debug("undeploy " + unit.getName());
-
- ClientENCInjectionContainer container = unit.getAttachment(ClientENCInjectionContainer.class);
- if(container != null)
- getKernelAbstraction().uninstall(container.getObjectName().getCanonicalName());
-
- String appClientName = getJndiName(metaData);
- String deploymentClientName = null;
- if(appClientName == null)
- appClientName = getDeploymentJndiName(unit);
- else if(linkDeploymentJndiName)
- deploymentClientName = getDeploymentJndiName(unit);
-
- log.debug("Removing client ENC from: " + appClientName);
- try
- {
- InitialContext iniCtx = InitialContextFactory.getInitialContext();
- Util.unbind(iniCtx, appClientName);
- if(deploymentClientName != null && deploymentClientName.equals(appClientName) == false)
- Util.removeLinkRef(deploymentClientName);
- }
- 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);
- }
- }
-
-}
+/*
+ * 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.util.ArrayList;
+import java.util.List;
+import java.util.jar.Attributes;
+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.beans.metadata.api.annotations.Inject;
+import org.jboss.deployers.spi.DeploymentException;
+import org.jboss.deployers.spi.structure.ClassPathEntry;
+import org.jboss.deployers.spi.structure.StructureMetaData;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.vfs.spi.deployer.AbstractSimpleVFSRealDeployer;
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.ejb3.InitialContextFactory;
+import org.jboss.ejb3.KernelAbstraction;
+import org.jboss.ejb3.clientmodule.ClientENCInjectionContainer;
+import org.jboss.jpa.resolvers.PersistenceUnitDependencyResolver;
+import org.jboss.kernel.Kernel;
+import org.jboss.kernel.spi.deployment.KernelDeployment;
+import org.jboss.metadata.client.jboss.JBossClientMetaData;
+import org.jboss.metadata.ear.jboss.JBossAppMetaData;
+import org.jboss.naming.Util;
+import org.jboss.virtual.VFSUtils;
+import org.jboss.virtual.VirtualFile;
+
+/**
+ * Deploys a client application jar.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @author adrian at jboss.org
+ * @version $Revision: $
+ */
+public class Ejb3ClientDeployer extends AbstractSimpleVFSRealDeployer<JBossClientMetaData>
+{
+ private Kernel kernel;
+ private MBeanServer server;
+ /** A flag indicating if a deployment based jndi should be linked to the JBossClientMetaData.jndiName */
+ private boolean linkDeploymentJndiName = true;
+
+ private PersistenceUnitDependencyResolver persistenceUnitDependencyResolver;
+
+ /**
+ * Create a new Ejb3ClientDeployer.
+ */
+ public Ejb3ClientDeployer()
+ {
+ super(JBossClientMetaData.class);
+ setOutput(ClientENCInjectionContainer.class);
+ // JBossASKernel install output
+ setOutput(KernelDeployment.class);
+ }
+
+ public boolean isLinkDeploymentJndiName()
+ {
+ return linkDeploymentJndiName;
+ }
+
+ public void setLinkDeploymentJndiName(boolean linkDeploymentJndiName)
+ {
+ this.linkDeploymentJndiName = linkDeploymentJndiName;
+ }
+
+ /**
+ * Deploy a client application
+ * @param unit - the application jar unit
+ * @param metaData - the metadata for the application
+ */
+ @Override
+ public void deploy(VFSDeploymentUnit unit, JBossClientMetaData metaData) throws DeploymentException
+ {
+ log.debug("deploy " + unit.getName());
+
+ String appClientName = getJndiName(metaData);
+ String deploymentClientName = null;
+ if(appClientName == null)
+ appClientName = getDeploymentJndiName(unit);
+ else if(linkDeploymentJndiName)
+ deploymentClientName = getDeploymentJndiName(unit);
+
+ try
+ {
+ // I create the namespace here, because I destroy it in undeploy
+ InitialContext iniCtx = InitialContextFactory.getInitialContext();
+ Context encCtx = Util.createSubcontext(iniCtx, appClientName);
+ log.debug("Creating client ENC binding under: " + appClientName);
+ if(deploymentClientName != null && deploymentClientName.equals(appClientName) == false)
+ {
+ Util.createLinkRef(iniCtx, deploymentClientName, appClientName);
+ }
+
+ // Notify the client launcher of extra class path entries in an EAR (See EE 8.2)
+ List<VirtualFile> classPath = unit.getClassPath();
+ ArrayList<String> cpURIs = new ArrayList<String>();
+ for(VirtualFile vf : classPath)
+ {
+ String uri = vf.toURI().toString();
+ cpURIs.add(uri);
+ }
+ // Also need to include the ear lib dir entries
+ VFSDeploymentUnit earUnit = unit.getParent();
+ if(earUnit != null)
+ {
+ List<VirtualFile> earClassPath = earUnit.getClassPath();
+ JBossAppMetaData earMD = earUnit.getAttachment(JBossAppMetaData.class);
+ if(earMD != null)
+ {
+ String libDir = earMD.getLibraryDirectory();
+ if(libDir == null)
+ libDir = "lib";
+ String libDirPrefix = libDir + "/";
+ for(VirtualFile vf : earClassPath)
+ {
+ if(vf.getPathName().startsWith(libDirPrefix))
+ {
+ String uri = vf.toURI().toString();
+ cpURIs.add(uri);
+ }
+ }
+ }
+ }
+
+ encCtx.bind("classPathEntries", cpURIs);
+ // java:comp/UserTransaction -> UserTransaction
+ Util.createLinkRef(encCtx, "UserTransaction", "UserTransaction");
+
+ // TODO: Notify the client launcher of other metadata stuff (injectors, lifecycle callbacks etc)
+ // FIXME: For now I expose the entire metadata
+ encCtx.bind("metaData", metaData);
+
+ String mainClassName = getMainClassName(unit, true);
+
+ Class<?> mainClass = loadClass(unit, mainClassName);
+
+ ClientENCInjectionContainer container = new ClientENCInjectionContainer(unit, metaData, mainClass, appClientName, unit.getClassLoader(), encCtx, persistenceUnitDependencyResolver);
+
+ //di.deployedObject = container.getObjectName();
+ unit.addAttachment(ClientENCInjectionContainer.class, container);
+ JBoss5DeploymentUnit ejb3Unit = new JBoss5DeploymentUnit(unit);
+ getKernelAbstraction().install(container.getObjectName().getCanonicalName(),
+ container.getDependencyPolicy(), ejb3Unit, container);
+ }
+ catch(Exception e)
+ {
+ log.error("Could not deploy " + unit.getName(), e);
+ undeploy(unit, metaData);
+ throw new DeploymentException("Could not deploy " + unit.getName(), e);
+ }
+ }
+
+ /**
+ * Get the class path entries which have been determined by the EARStructure.
+ * Will return null if this unit is not part of an ear deployment.
+ */
+ private List<ClassPathEntry> getClassPathEntries(VFSDeploymentUnit unit)
+ {
+// log.info("class path = " + unit.getTopLevel().getAttachment(StructureMetaData.class).getContext("").getClassPath());
+ StructureMetaData smd = unit.getTopLevel().getAttachment(StructureMetaData.class);
+ if(smd == null)
+ return null;
+ // A context without a path is the one we want (see AbstractStructureDeployer)
+ return smd.getContext("").getClassPath();
+ }
+
+ /**
+ * 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 unit
+ * @param dd
+ * @return a good JNDI name
+ */
+ private String getJndiName(JBossClientMetaData dd)
+ {
+ String jndiName = dd.getJndiName();
+ return jndiName;
+ }
+ private String getDeploymentJndiName(DeploymentUnit unit)
+ {
+ String jndiName;
+ String shortName = unit.getSimpleName();
+ 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 JBossASKernel(kernel);
+ }
+
+ // TODO: move this method either to a utility class or to the scanning deployer
+ protected String getMainClassName(VFSDeploymentUnit unit, boolean fail) throws Exception
+ {
+ VirtualFile file = unit.getMetaDataFile("MANIFEST.MF");
+ log.trace("parsing " + file);
+ // Default to the jboss client main
+ String mainClassName = "org.jboss.client.AppClientMain";
+
+ if (file != null)
+ {
+ try
+ {
+ Manifest mf = VFSUtils.readManifest(file);
+ Attributes attrs = mf.getMainAttributes();
+ String className = attrs.getValue(Attributes.Name.MAIN_CLASS);
+ if (className != null)
+ {
+ mainClassName = className;
+ }
+ }
+ finally
+ {
+ file.close();
+ }
+ }
+ return mainClassName;
+ }
+
+ 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;
+ }
+
+ @Inject
+ public void setPersistenceUnitDependencyResolver(PersistenceUnitDependencyResolver resolver)
+ {
+ this.persistenceUnitDependencyResolver = resolver;
+ }
+
+ @Override
+ public void undeploy(VFSDeploymentUnit unit, JBossClientMetaData metaData)
+ {
+ log.debug("undeploy " + unit.getName());
+
+ ClientENCInjectionContainer container = unit.getAttachment(ClientENCInjectionContainer.class);
+ if(container != null)
+ getKernelAbstraction().uninstall(container.getObjectName().getCanonicalName());
+
+ String appClientName = getJndiName(metaData);
+ String deploymentClientName = null;
+ if(appClientName == null)
+ appClientName = getDeploymentJndiName(unit);
+ else if(linkDeploymentJndiName)
+ deploymentClientName = getDeploymentJndiName(unit);
+
+ log.debug("Removing client ENC from: " + appClientName);
+ try
+ {
+ InitialContext iniCtx = InitialContextFactory.getInitialContext();
+ Util.unbind(iniCtx, appClientName);
+ if(deploymentClientName != null && deploymentClientName.equals(appClientName) == false)
+ Util.removeLinkRef(deploymentClientName);
+ }
+ 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);
+ }
+ }
+
+}
Property changes on: trunk/ejb3/src/main/org/jboss/ejb3/deployers/Ejb3ClientDeployer.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/ejb3/src/main/org/jboss/ejb3/deployers/Ejb3JBoss5Deployment.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/deployers/Ejb3JBoss5Deployment.java 2008-11-14 14:58:15 UTC (rev 81052)
+++ trunk/ejb3/src/main/org/jboss/ejb3/deployers/Ejb3JBoss5Deployment.java 2008-11-14 14:59:40 UTC (rev 81053)
@@ -1,168 +1,168 @@
-/*
-* 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.util.Map;
-
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-import javax.security.jacc.PolicyConfiguration;
-
-import org.jboss.beans.metadata.plugins.AbstractSupplyMetaData;
-import org.jboss.deployment.MappedReferenceMetaDataResolverDeployer;
-import org.jboss.deployment.dependency.ContainerDependencyMetaData;
-import org.jboss.ejb3.Container;
-import org.jboss.ejb3.DependencyPolicy;
-import org.jboss.ejb3.DeploymentUnit;
-import org.jboss.ejb3.EJBContainer;
-import org.jboss.ejb3.Ejb3Deployment;
-import org.jboss.ejb3.MCDependencyPolicy;
-import org.jboss.ejb3.javaee.JavaEEApplication;
-import org.jboss.ejb3.javaee.JavaEEComponent;
-import org.jboss.ejb3.kernel.JNDIKernelRegistryPlugin;
-import org.jboss.kernel.Kernel;
-import org.jboss.logging.Logger;
-import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
-import org.jboss.metadata.ejb.jboss.JBossMetaData;
-import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
-import org.jboss.metadata.ejb.jboss.jndipolicy.spi.EjbDeploymentSummary;
-
-/**
- * JBoss 5.0 Microkernel specific implementation
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @author adrian at jboss.org
- * @version $Revision: 56592 $
- */
-public class Ejb3JBoss5Deployment extends Ejb3Deployment
-{
- private static Logger log = Logger.getLogger(Ejb3JBoss5Deployment.class);
- private org.jboss.deployers.structure.spi.DeploymentUnit jbossUnit;
- private Map<String, ContainerDependencyMetaData> endpoints;
-
- public Ejb3JBoss5Deployment(DeploymentUnit ejb3Unit, Kernel kernel, MBeanServer mbeanServer, org.jboss.deployers.structure.spi.DeploymentUnit jbossUnit, JBoss5DeploymentScope deploymentScope, JBossMetaData metaData)
- {
- // Either call the old constructor and do process persistence units
- //super(ejb3Unit, deploymentScope, metaData, persistenceUnitsMetaData);
- // or call the new constructor and don't process persistence units
- super(jbossUnit, ejb3Unit, deploymentScope, metaData);
-
- this.jbossUnit = jbossUnit;
- kernelAbstraction = new JBossASKernel(kernel, mbeanServer);
-
- // todo maybe mbeanServer should be injected?
- this.mbeanServer = mbeanServer;
- org.jboss.deployers.structure.spi.DeploymentUnit topUnit = jbossUnit.getTopLevel();
- endpoints = (Map<String, ContainerDependencyMetaData>) topUnit.getAttachment(MappedReferenceMetaDataResolverDeployer.ENDPOINT_MAP_KEY);
- }
-
- protected PolicyConfiguration createPolicyConfiguration() throws Exception
- {
- return null;
- }
-
- protected void putJaccInService(PolicyConfiguration pc, DeploymentUnit ejb3Unit)
- {
- //Ignore
- }
-
- public DependencyPolicy createDependencyPolicy(JavaEEComponent component)
- {
- return new JBoss5DependencyPolicy(component);
- }
-
- @Override
- public JavaEEApplication getApplication()
- {
- // getApplication must return null if there is no ear
- JavaEEApplication app = super.getApplication();
- if(((JBoss5DeploymentScope) app).isEar())
- return app;
- return null;
- }
-
- @Override
- protected void registerEJBContainer(Container container) throws Exception
- {
- // Add the jndi supplies
- MCDependencyPolicy dependsPolicy = (MCDependencyPolicy) container.getDependencyPolicy();
- EJBContainer ejbContainer = (EJBContainer) container;
- JBossEnterpriseBeanMetaData beanMD = ejbContainer.getXml();
-
- ContainerDependencyMetaData cdmd = null;
- if(endpoints != null)
- {
- String ejbKey = "ejb/" + jbossUnit.getRelativePath() + "#" + container.getEjbName();
- cdmd = endpoints.get(ejbKey);
- }
- else
- {
- log.warn(jbossUnit+" has no ContainerDependencyMetaData attachment");
- }
-
- if(cdmd != null)
- {
- for(String jndiName : cdmd.getJndiNames())
- {
- String supplyName = JNDIKernelRegistryPlugin.JNDI_DEPENDENCY_PREFIX + jndiName;
- AbstractSupplyMetaData supply = new AbstractSupplyMetaData(supplyName);
- dependsPolicy.getSupplies().add(supply);
- }
- }
-
- // EJBTHREE-1335: container name in meta data
- generateContainerName(container, beanMD);
-
- super.registerEJBContainer(container);
- }
-
- private void generateContainerName(Container container, JBossEnterpriseBeanMetaData beanMD)
- {
- ObjectName on = container.getObjectName();
- assert on!=null : "ObjectName was null";
-
- // Heiko: This should actually generate the name and assign it to ejb3 meta data
- // Currently we stick to copying the values around until an EJB3 team member figures out a proper way
- beanMD.setGeneratedContainerName(on.getCanonicalName());
- }
-
- private static EjbDeploymentSummary getUnitSummary(DeploymentUnit unit, JBossEnterpriseBeanMetaData beanMD)
- {
- ClassLoader loader = unit.getClassLoader();
- EjbDeploymentSummary summary = new EjbDeploymentSummary();
- summary.setBeanMD(beanMD);
- summary.setBeanClassName(beanMD.getEjbClass());
- summary.setDeploymentName(unit.getShortName());
- String baseName = unit.getRootFile().getName();
- summary.setDeploymentScopeBaseName(baseName);
- summary.setEjbName(beanMD.getEjbName());
- summary.setLoader(loader);
- summary.setLocal(beanMD.isMessageDriven());
- if(beanMD instanceof JBossSessionBeanMetaData)
- {
- JBossSessionBeanMetaData sbeanMD = (JBossSessionBeanMetaData) beanMD;
- summary.setStateful(sbeanMD.isStateful());
- }
- summary.setService(beanMD.isService());
- return summary;
- }
-}
+/*
+* 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.util.Map;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import javax.security.jacc.PolicyConfiguration;
+
+import org.jboss.beans.metadata.plugins.AbstractSupplyMetaData;
+import org.jboss.deployment.MappedReferenceMetaDataResolverDeployer;
+import org.jboss.deployment.dependency.ContainerDependencyMetaData;
+import org.jboss.ejb3.Container;
+import org.jboss.ejb3.DependencyPolicy;
+import org.jboss.ejb3.DeploymentUnit;
+import org.jboss.ejb3.EJBContainer;
+import org.jboss.ejb3.Ejb3Deployment;
+import org.jboss.ejb3.MCDependencyPolicy;
+import org.jboss.ejb3.javaee.JavaEEApplication;
+import org.jboss.ejb3.javaee.JavaEEComponent;
+import org.jboss.ejb3.kernel.JNDIKernelRegistryPlugin;
+import org.jboss.kernel.Kernel;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
+import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
+import org.jboss.metadata.ejb.jboss.jndipolicy.spi.EjbDeploymentSummary;
+
+/**
+ * JBoss 5.0 Microkernel specific implementation
+ *
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @author adrian at jboss.org
+ * @version $Revision: 56592 $
+ */
+public class Ejb3JBoss5Deployment extends Ejb3Deployment
+{
+ private static Logger log = Logger.getLogger(Ejb3JBoss5Deployment.class);
+ private org.jboss.deployers.structure.spi.DeploymentUnit jbossUnit;
+ private Map<String, ContainerDependencyMetaData> endpoints;
+
+ public Ejb3JBoss5Deployment(DeploymentUnit ejb3Unit, Kernel kernel, MBeanServer mbeanServer, org.jboss.deployers.structure.spi.DeploymentUnit jbossUnit, JBoss5DeploymentScope deploymentScope, JBossMetaData metaData)
+ {
+ // Either call the old constructor and do process persistence units
+ //super(ejb3Unit, deploymentScope, metaData, persistenceUnitsMetaData);
+ // or call the new constructor and don't process persistence units
+ super(jbossUnit, ejb3Unit, deploymentScope, metaData);
+
+ this.jbossUnit = jbossUnit;
+ kernelAbstraction = new JBossASKernel(kernel, mbeanServer);
+
+ // todo maybe mbeanServer should be injected?
+ this.mbeanServer = mbeanServer;
+ org.jboss.deployers.structure.spi.DeploymentUnit topUnit = jbossUnit.getTopLevel();
+ endpoints = (Map<String, ContainerDependencyMetaData>) topUnit.getAttachment(MappedReferenceMetaDataResolverDeployer.ENDPOINT_MAP_KEY);
+ }
+
+ protected PolicyConfiguration createPolicyConfiguration() throws Exception
+ {
+ return null;
+ }
+
+ protected void putJaccInService(PolicyConfiguration pc, DeploymentUnit ejb3Unit)
+ {
+ //Ignore
+ }
+
+ public DependencyPolicy createDependencyPolicy(JavaEEComponent component)
+ {
+ return new JBoss5DependencyPolicy(component);
+ }
+
+ @Override
+ public JavaEEApplication getApplication()
+ {
+ // getApplication must return null if there is no ear
+ JavaEEApplication app = super.getApplication();
+ if(((JBoss5DeploymentScope) app).isEar())
+ return app;
+ return null;
+ }
+
+ @Override
+ protected void registerEJBContainer(Container container) throws Exception
+ {
+ // Add the jndi supplies
+ MCDependencyPolicy dependsPolicy = (MCDependencyPolicy) container.getDependencyPolicy();
+ EJBContainer ejbContainer = (EJBContainer) container;
+ JBossEnterpriseBeanMetaData beanMD = ejbContainer.getXml();
+
+ ContainerDependencyMetaData cdmd = null;
+ if(endpoints != null)
+ {
+ String ejbKey = "ejb/" + jbossUnit.getRelativePath() + "#" + container.getEjbName();
+ cdmd = endpoints.get(ejbKey);
+ }
+ else
+ {
+ log.warn(jbossUnit+" has no ContainerDependencyMetaData attachment");
+ }
+
+ if(cdmd != null)
+ {
+ for(String jndiName : cdmd.getJndiNames())
+ {
+ String supplyName = JNDIKernelRegistryPlugin.JNDI_DEPENDENCY_PREFIX + jndiName;
+ AbstractSupplyMetaData supply = new AbstractSupplyMetaData(supplyName);
+ dependsPolicy.getSupplies().add(supply);
+ }
+ }
+
+ // EJBTHREE-1335: container name in meta data
+ generateContainerName(container, beanMD);
+
+ super.registerEJBContainer(container);
+ }
+
+ private void generateContainerName(Container container, JBossEnterpriseBeanMetaData beanMD)
+ {
+ ObjectName on = container.getObjectName();
+ assert on!=null : "ObjectName was null";
+
+ // Heiko: This should actually generate the name and assign it to ejb3 meta data
+ // Currently we stick to copying the values around until an EJB3 team member figures out a proper way
+ beanMD.setGeneratedContainerName(on.getCanonicalName());
+ }
+
+ private static EjbDeploymentSummary getUnitSummary(DeploymentUnit unit, JBossEnterpriseBeanMetaData beanMD)
+ {
+ ClassLoader loader = unit.getClassLoader();
+ EjbDeploymentSummary summary = new EjbDeploymentSummary();
+ summary.setBeanMD(beanMD);
+ summary.setBeanClassName(beanMD.getEjbClass());
+ summary.setDeploymentName(unit.getShortName());
+ String baseName = unit.getRootFile().getName();
+ summary.setDeploymentScopeBaseName(baseName);
+ summary.setEjbName(beanMD.getEjbName());
+ summary.setLoader(loader);
+ summary.setLocal(beanMD.isMessageDriven());
+ if(beanMD instanceof JBossSessionBeanMetaData)
+ {
+ JBossSessionBeanMetaData sbeanMD = (JBossSessionBeanMetaData) beanMD;
+ summary.setStateful(sbeanMD.isStateful());
+ }
+ summary.setService(beanMD.isService());
+ return summary;
+ }
+}
Property changes on: trunk/ejb3/src/main/org/jboss/ejb3/deployers/Ejb3JBoss5Deployment.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/ejb3/src/main/org/jboss/ejb3/deployers/JBoss5DeploymentScope.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/deployers/JBoss5DeploymentScope.java 2008-11-14 14:58:15 UTC (rev 81052)
+++ trunk/ejb3/src/main/org/jboss/ejb3/deployers/JBoss5DeploymentScope.java 2008-11-14 14:59:40 UTC (rev 81053)
@@ -1,254 +1,254 @@
-/*
-* 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.util.Collection;
-import java.util.concurrent.ConcurrentHashMap;
-
-import javax.management.ObjectName;
-import javax.naming.NameNotFoundException;
-
-import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
-import org.jboss.deployment.spi.DeploymentEndpointResolver;
-import org.jboss.deployment.spi.EndpointInfo;
-import org.jboss.deployment.spi.EndpointType;
-import org.jboss.ejb3.DeploymentScope;
-import org.jboss.ejb3.EJBContainer;
-import org.jboss.ejb3.Ejb3Deployment;
-import org.jboss.ejb3.deployers.tmp.EjbModuleEjbResolver;
-import org.jboss.ejb3.javaee.JavaEEComponentHelper;
-import org.jboss.logging.Logger;
-
-/**
- * Abstraction for an EAR/WAR or anything that scopes EJB deployments
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @author adrian at jboss.org
- * @author Scott.Stark at jboss.org
- * @version $Revision: 55144 $
- */
-public class JBoss5DeploymentScope implements DeploymentScope
-{
- public static final String ATTACHMENT_KEY = "org.jboss.ejb3.deployers.JBoss5DeploymentScope.deployments";
- private static final Logger log = Logger.getLogger(JBoss5DeploymentScope.class);
- /** The Map<String,Ejb3Deployment> of the deployment vfs path name to deployment */
- private ConcurrentHashMap<String, Ejb3Deployment> deployments;
- /** The deployment endpoint resolver implementation */
- private DeploymentEndpointResolver endpointResolver;
- private EjbModuleEjbResolver ejbRefResolver;
- /** The parent deployment short name */
- private String shortName;
- /** The deployment short name minus any .suffix */
- private String baseName;
-
- private boolean isEar;
-
- @SuppressWarnings("unchecked")
- public JBoss5DeploymentScope(VFSDeploymentUnit parent, boolean isEar)
- {
- this.isEar = isEar;
- this.shortName = parent.getSimpleName();
- baseName = null;
- if(isEar)
- {
- this.baseName = shortName;
- int idx = shortName.lastIndexOf('.');
- if( idx > 0 )
- baseName = shortName.substring(0, idx);
- }
-
- // Create the deployment map attachment if it does not exist
- deployments = (ConcurrentHashMap<String, Ejb3Deployment>)parent.getAttachment(ATTACHMENT_KEY);
- if (deployments == null)
- {
- deployments = new ConcurrentHashMap<String, Ejb3Deployment>();
- parent.addAttachment(ATTACHMENT_KEY, deployments);
- }
- // MappedReferenceMetaDataResolverDeployer output, Look for the endpoint resolver
- endpointResolver = parent.getAttachment(DeploymentEndpointResolver.class);
- /*
- if(endpointResolver == null)
- throw new IllegalStateException("No DeploymentEndpointResolver found in deployment: "+parent);
- */
- }
- /**
- * Temp ctor until EJBTHREE-1291 is resolved
- * @param parent
- * @param shortName
- */
- public JBoss5DeploymentScope(VFSDeploymentUnit parent, boolean isEar, String shortName)
- {
- this(parent, isEar);
- ejbRefResolver = new EjbModuleEjbResolver(this, shortName);
- }
- public void setDeployment(Ejb3Deployment deployment)
- {
- ejbRefResolver.setDeployment(deployment);
- }
-
- public DeploymentEndpointResolver getEndpointResolver()
- {
- return endpointResolver;
- }
- public void setEndpointResolver(DeploymentEndpointResolver endpointResolver)
- {
- this.endpointResolver = endpointResolver;
- }
-
- public Collection<Ejb3Deployment> getEjbDeployments()
- {
- return deployments.values();
- }
-
- public void register(Ejb3Deployment deployment)
- {
- // Create the path name relative to the root
- String pathName = deployment.getDeploymentUnit().getRootFile().getPathName();
- if(pathName.startsWith(shortName))
- {
- if(pathName.length() > shortName.length())
- pathName = pathName.substring(shortName.length()+1);
- else
- pathName = "";
- }
- deployments.put(pathName, deployment);
- }
-
- public void unregister(Ejb3Deployment deployment)
- {
- String pathName = deployment.getDeploymentUnit().getRootFile().getPathName();
- if(pathName.startsWith(shortName))
- pathName = pathName.substring(shortName.length()+1);
- deployments.remove(pathName);
- }
-
- public Ejb3Deployment findRelativeDeployment(String relativeName)
- {
- if (relativeName.startsWith("../"))
- {
- relativeName = relativeName.substring(3);
- }
- return deployments.get(relativeName);
- }
-
- @SuppressWarnings("unchecked")
- public EJBContainer getEjbContainer(Class businessIntf, String vfsContext)
- throws NameNotFoundException
- {
- // Get the deployment endpoint
- if(ejbRefResolver != null)
- {
- // TODO: EJBTHREE-1291
- return ejbRefResolver.getEjbContainer(businessIntf);
- }
-
- EJBContainer container = null;
- EndpointInfo endpoint = endpointResolver.getEndpointInfo(businessIntf, EndpointType.EJB, vfsContext);
- if(endpoint != null)
- {
- log.debug("Found endpoint for interface: "+businessIntf+", endpoint: "+endpoint);
- Ejb3Deployment deployment = deployments.get(endpoint.getPathName());
- String ejbObjectName = JavaEEComponentHelper.createObjectName(deployment, endpoint.getName());
- ObjectName ejbON;
- try
- {
- ejbON = new ObjectName(ejbObjectName);
- }
- catch (Exception e)
- {
- throw new IllegalStateException("Failed to build ejb container ObjectName", e);
- }
- container = (EJBContainer) deployment.getContainer(ejbON);
- // TODO: container = deployment.getEjbContainerForEjbName(endpoint.getName());
- }
- else
- {
- log.debug("Failed to find endpoint for interface: "+businessIntf);
- }
- return container;
- }
-
- @SuppressWarnings("unchecked")
- public EJBContainer getEjbContainer(String ejbLink, Class businessIntf, String vfsContext)
- {
- if(ejbRefResolver != null)
- {
- // TODO: EJBTHREE-1291
- return ejbRefResolver.getEjbContainer(ejbLink, businessIntf);
- }
-
- EJBContainer container = null;
- // First try the ejbLink
- EndpointInfo endpoint = endpointResolver.getEndpointInfo(ejbLink, EndpointType.EJB, vfsContext);
- if(endpoint != null)
- {
- log.debug("Found endpoint for ejbLink: "+ejbLink+", endpoint: "+endpoint);
- Ejb3Deployment deployment = deployments.get(endpoint.getPathName());
- String ejbObjectName = JavaEEComponentHelper.createObjectName(deployment, endpoint.getName());
- ObjectName ejbON;
- try
- {
- ejbON = new ObjectName(ejbObjectName);
- }
- catch (Exception e)
- {
- throw new IllegalStateException("Failed to build ejb container ObjectName", e);
- }
- container = (EJBContainer) deployment.getContainer(ejbON);
- // TODO: container = deployment.getEjbContainerForEjbName(endpoint.getName()); container = deployment.getEjbContainerForEjbName(endpoint.getName());
- }
- else
- {
- log.debug("Failed to find endpoint for ejbLink: "+ejbLink);
- // Try the business interface
- try
- {
- container = getEjbContainer(businessIntf, vfsContext);
- }
- catch(NameNotFoundException e)
- {
- log.debug("Did not resolve container by interface: "+businessIntf, e);
- }
- }
- return container;
- }
-
- public String getName()
- {
- return shortName;
- }
-
- public String getShortName()
- {
- return shortName;
- }
-
- public String getBaseName()
- {
- return baseName;
- }
-
- protected boolean isEar()
- {
- return isEar;
- }
-}
+/*
+* 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.util.Collection;
+import java.util.concurrent.ConcurrentHashMap;
+
+import javax.management.ObjectName;
+import javax.naming.NameNotFoundException;
+
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.deployment.spi.DeploymentEndpointResolver;
+import org.jboss.deployment.spi.EndpointInfo;
+import org.jboss.deployment.spi.EndpointType;
+import org.jboss.ejb3.DeploymentScope;
+import org.jboss.ejb3.EJBContainer;
+import org.jboss.ejb3.Ejb3Deployment;
+import org.jboss.ejb3.deployers.tmp.EjbModuleEjbResolver;
+import org.jboss.ejb3.javaee.JavaEEComponentHelper;
+import org.jboss.logging.Logger;
+
+/**
+ * Abstraction for an EAR/WAR or anything that scopes EJB deployments
+ *
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @author adrian at jboss.org
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: 55144 $
+ */
+public class JBoss5DeploymentScope implements DeploymentScope
+{
+ public static final String ATTACHMENT_KEY = "org.jboss.ejb3.deployers.JBoss5DeploymentScope.deployments";
+ private static final Logger log = Logger.getLogger(JBoss5DeploymentScope.class);
+ /** The Map<String,Ejb3Deployment> of the deployment vfs path name to deployment */
+ private ConcurrentHashMap<String, Ejb3Deployment> deployments;
+ /** The deployment endpoint resolver implementation */
+ private DeploymentEndpointResolver endpointResolver;
+ private EjbModuleEjbResolver ejbRefResolver;
+ /** The parent deployment short name */
+ private String shortName;
+ /** The deployment short name minus any .suffix */
+ private String baseName;
+
+ private boolean isEar;
+
+ @SuppressWarnings("unchecked")
+ public JBoss5DeploymentScope(VFSDeploymentUnit parent, boolean isEar)
+ {
+ this.isEar = isEar;
+ this.shortName = parent.getSimpleName();
+ baseName = null;
+ if(isEar)
+ {
+ this.baseName = shortName;
+ int idx = shortName.lastIndexOf('.');
+ if( idx > 0 )
+ baseName = shortName.substring(0, idx);
+ }
+
+ // Create the deployment map attachment if it does not exist
+ deployments = (ConcurrentHashMap<String, Ejb3Deployment>)parent.getAttachment(ATTACHMENT_KEY);
+ if (deployments == null)
+ {
+ deployments = new ConcurrentHashMap<String, Ejb3Deployment>();
+ parent.addAttachment(ATTACHMENT_KEY, deployments);
+ }
+ // MappedReferenceMetaDataResolverDeployer output, Look for the endpoint resolver
+ endpointResolver = parent.getAttachment(DeploymentEndpointResolver.class);
+ /*
+ if(endpointResolver == null)
+ throw new IllegalStateException("No DeploymentEndpointResolver found in deployment: "+parent);
+ */
+ }
+ /**
+ * Temp ctor until EJBTHREE-1291 is resolved
+ * @param parent
+ * @param shortName
+ */
+ public JBoss5DeploymentScope(VFSDeploymentUnit parent, boolean isEar, String shortName)
+ {
+ this(parent, isEar);
+ ejbRefResolver = new EjbModuleEjbResolver(this, shortName);
+ }
+ public void setDeployment(Ejb3Deployment deployment)
+ {
+ ejbRefResolver.setDeployment(deployment);
+ }
+
+ public DeploymentEndpointResolver getEndpointResolver()
+ {
+ return endpointResolver;
+ }
+ public void setEndpointResolver(DeploymentEndpointResolver endpointResolver)
+ {
+ this.endpointResolver = endpointResolver;
+ }
+
+ public Collection<Ejb3Deployment> getEjbDeployments()
+ {
+ return deployments.values();
+ }
+
+ public void register(Ejb3Deployment deployment)
+ {
+ // Create the path name relative to the root
+ String pathName = deployment.getDeploymentUnit().getRootFile().getPathName();
+ if(pathName.startsWith(shortName))
+ {
+ if(pathName.length() > shortName.length())
+ pathName = pathName.substring(shortName.length()+1);
+ else
+ pathName = "";
+ }
+ deployments.put(pathName, deployment);
+ }
+
+ public void unregister(Ejb3Deployment deployment)
+ {
+ String pathName = deployment.getDeploymentUnit().getRootFile().getPathName();
+ if(pathName.startsWith(shortName))
+ pathName = pathName.substring(shortName.length()+1);
+ deployments.remove(pathName);
+ }
+
+ public Ejb3Deployment findRelativeDeployment(String relativeName)
+ {
+ if (relativeName.startsWith("../"))
+ {
+ relativeName = relativeName.substring(3);
+ }
+ return deployments.get(relativeName);
+ }
+
+ @SuppressWarnings("unchecked")
+ public EJBContainer getEjbContainer(Class businessIntf, String vfsContext)
+ throws NameNotFoundException
+ {
+ // Get the deployment endpoint
+ if(ejbRefResolver != null)
+ {
+ // TODO: EJBTHREE-1291
+ return ejbRefResolver.getEjbContainer(businessIntf);
+ }
+
+ EJBContainer container = null;
+ EndpointInfo endpoint = endpointResolver.getEndpointInfo(businessIntf, EndpointType.EJB, vfsContext);
+ if(endpoint != null)
+ {
+ log.debug("Found endpoint for interface: "+businessIntf+", endpoint: "+endpoint);
+ Ejb3Deployment deployment = deployments.get(endpoint.getPathName());
+ String ejbObjectName = JavaEEComponentHelper.createObjectName(deployment, endpoint.getName());
+ ObjectName ejbON;
+ try
+ {
+ ejbON = new ObjectName(ejbObjectName);
+ }
+ catch (Exception e)
+ {
+ throw new IllegalStateException("Failed to build ejb container ObjectName", e);
+ }
+ container = (EJBContainer) deployment.getContainer(ejbON);
+ // TODO: container = deployment.getEjbContainerForEjbName(endpoint.getName());
+ }
+ else
+ {
+ log.debug("Failed to find endpoint for interface: "+businessIntf);
+ }
+ return container;
+ }
+
+ @SuppressWarnings("unchecked")
+ public EJBContainer getEjbContainer(String ejbLink, Class businessIntf, String vfsContext)
+ {
+ if(ejbRefResolver != null)
+ {
+ // TODO: EJBTHREE-1291
+ return ejbRefResolver.getEjbContainer(ejbLink, businessIntf);
+ }
+
+ EJBContainer container = null;
+ // First try the ejbLink
+ EndpointInfo endpoint = endpointResolver.getEndpointInfo(ejbLink, EndpointType.EJB, vfsContext);
+ if(endpoint != null)
+ {
+ log.debug("Found endpoint for ejbLink: "+ejbLink+", endpoint: "+endpoint);
+ Ejb3Deployment deployment = deployments.get(endpoint.getPathName());
+ String ejbObjectName = JavaEEComponentHelper.createObjectName(deployment, endpoint.getName());
+ ObjectName ejbON;
+ try
+ {
+ ejbON = new ObjectName(ejbObjectName);
+ }
+ catch (Exception e)
+ {
+ throw new IllegalStateException("Failed to build ejb container ObjectName", e);
+ }
+ container = (EJBContainer) deployment.getContainer(ejbON);
+ // TODO: container = deployment.getEjbContainerForEjbName(endpoint.getName()); container = deployment.getEjbContainerForEjbName(endpoint.getName());
+ }
+ else
+ {
+ log.debug("Failed to find endpoint for ejbLink: "+ejbLink);
+ // Try the business interface
+ try
+ {
+ container = getEjbContainer(businessIntf, vfsContext);
+ }
+ catch(NameNotFoundException e)
+ {
+ log.debug("Did not resolve container by interface: "+businessIntf, e);
+ }
+ }
+ return container;
+ }
+
+ public String getName()
+ {
+ return shortName;
+ }
+
+ public String getShortName()
+ {
+ return shortName;
+ }
+
+ public String getBaseName()
+ {
+ return baseName;
+ }
+
+ protected boolean isEar()
+ {
+ return isEar;
+ }
+}
Property changes on: trunk/ejb3/src/main/org/jboss/ejb3/deployers/JBoss5DeploymentScope.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/ejb3/src/main/org/jboss/ejb3/deployers/JBoss5DeploymentUnit.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/deployers/JBoss5DeploymentUnit.java 2008-11-14 14:58:15 UTC (rev 81052)
+++ trunk/ejb3/src/main/org/jboss/ejb3/deployers/JBoss5DeploymentUnit.java 2008-11-14 14:59:40 UTC (rev 81053)
@@ -1,235 +1,235 @@
-/*
-* 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.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Collections;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Map;
-
-import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
-import org.jboss.ejb3.interceptor.InterceptorInfoRepository;
-import org.jboss.virtual.VirtualFile;
-import org.jboss.virtual.VirtualFileFilter;
-import org.jboss.virtual.VisitorAttributes;
-import org.jboss.virtual.plugins.context.jar.JarUtils;
-import org.jboss.virtual.plugins.vfs.helpers.FilterVirtualFileVisitor;
-import org.jboss.virtual.plugins.vfs.helpers.SuffixesExcludeFilter;
-
-/**
- * Comment
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision: 43304 $
- */
-public class JBoss5DeploymentUnit implements org.jboss.ejb3.DeploymentUnit
-{
- private VFSDeploymentUnit unit;
- private ClassLoader classLoader;
- private InterceptorInfoRepository interceptorInfoRepository;
- private Map defaultPersistenceProperties;
-
- public JBoss5DeploymentUnit(VFSDeploymentUnit unit)
- {
- this(unit, unit.getClassLoader());
- }
-
- public JBoss5DeploymentUnit(VFSDeploymentUnit unit, ClassLoader classLoader)
- {
- assert unit != null : "unit is null";
- assert classLoader != null : "classLoader is null";
-
- this.unit = unit;
- this.classLoader = classLoader;
- this.interceptorInfoRepository = new InterceptorInfoRepository(classLoader);
- }
-
- public Object addAttachment(String name, Object attachment)
- {
- return unit.addAttachment(name, attachment);
- }
- public Object getAttachment(String name)
- {
- return unit.getAttachment(name);
- }
- public Object removeAttachment(String name)
- {
- return unit.removeAttachment(name);
- }
-
- public VirtualFile getRootFile()
- {
- return unit.getFile("");
- }
-
- public String getRelativePath()
- {
- return unit.getRelativePath();
- }
-
- public URL getRelativeURL(String jar)
- {
- try
- {
- return new URL(jar);
- }
- catch (MalformedURLException e)
- {
- try
- {
- if (getUrl() == null)
- throw new RuntimeException("relative <jar-file> not allowed when standalone deployment unit is used");
- return new URL(getUrl(), jar);
- }
- catch (Exception e1)
- {
- throw new RuntimeException("could not find relative path: " + jar, e1);
- }
- }
- }
-
- URL extractDescriptorUrl(String resource)
- {
- try
- {
- VirtualFile vf = unit.getMetaDataFile(resource);
- if (vf == null) return null;
- return vf.toURL();
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- }
-
- public URL getPersistenceXml()
- {
- return extractDescriptorUrl("persistence.xml");
- }
-
- public URL getEjbJarXml()
- {
- return extractDescriptorUrl("ejb-jar.xml");
- }
-
- public URL getJbossXml()
- {
- return extractDescriptorUrl("jboss.xml");
- }
-
- public VirtualFile getMetaDataFile(String name)
- {
- return unit.getMetaDataFile(name);
- }
-
- public List<Class> getClasses()
- {
- return null;
- }
-
- public ClassLoader getClassLoader()
- {
- return classLoader;
- }
-
- public ClassLoader getResourceLoader()
- {
- return getClassLoader();
- }
-
- public String getShortName()
- {
- return unit.getFile("").getName();
- }
-
- public URL getUrl()
- {
- try
- {
- return unit.getFile("").toURL();
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- }
-
- public String getDefaultEntityManagerName()
- {
- String url = getUrl().toString();
- String name = url.substring(url.lastIndexOf('/') + 1, url.lastIndexOf('.'));
- return name;
- }
-
- public Map getDefaultPersistenceProperties()
- {
- return defaultPersistenceProperties;
- }
-
- public void setDefaultPersistenceProperties(Map defaultPersistenceProperties)
- {
- this.defaultPersistenceProperties = defaultPersistenceProperties;
- }
-
- public Hashtable getJndiProperties()
- {
- return null;
- }
-
- public InterceptorInfoRepository getInterceptorInfoRepository()
- {
- return interceptorInfoRepository;
- }
-
- public List<VirtualFile> getResources(VirtualFileFilter filter)
- {
- VisitorAttributes va = new VisitorAttributes();
- va.setLeavesOnly(true);
- SuffixesExcludeFilter noJars = new SuffixesExcludeFilter(JarUtils.getSuffixes());
- va.setRecurseFilter(noJars);
- FilterVirtualFileVisitor visitor = new FilterVirtualFileVisitor(filter, va);
-
- List<VirtualFile> classPath = unit.getClassPath();
- if(classPath == null)
- return Collections.emptyList();
-
- for(VirtualFile root : classPath)
- {
- try
- {
- if( root.isLeaf() == false )
- root.visit(visitor);
- }
- catch (IOException e)
- {
- throw new RuntimeException(e);
- }
- }
-
- List<VirtualFile> resources = visitor.getMatched();
-
- return resources;
- }
-}
+/*
+* 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.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Collections;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
+import org.jboss.ejb3.interceptor.InterceptorInfoRepository;
+import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.VirtualFileFilter;
+import org.jboss.virtual.VisitorAttributes;
+import org.jboss.virtual.plugins.context.jar.JarUtils;
+import org.jboss.virtual.plugins.vfs.helpers.FilterVirtualFileVisitor;
+import org.jboss.virtual.plugins.vfs.helpers.SuffixesExcludeFilter;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @version $Revision: 43304 $
+ */
+public class JBoss5DeploymentUnit implements org.jboss.ejb3.DeploymentUnit
+{
+ private VFSDeploymentUnit unit;
+ private ClassLoader classLoader;
+ private InterceptorInfoRepository interceptorInfoRepository;
+ private Map defaultPersistenceProperties;
+
+ public JBoss5DeploymentUnit(VFSDeploymentUnit unit)
+ {
+ this(unit, unit.getClassLoader());
+ }
+
+ public JBoss5DeploymentUnit(VFSDeploymentUnit unit, ClassLoader classLoader)
+ {
+ assert unit != null : "unit is null";
+ assert classLoader != null : "classLoader is null";
+
+ this.unit = unit;
+ this.classLoader = classLoader;
+ this.interceptorInfoRepository = new InterceptorInfoRepository(classLoader);
+ }
+
+ public Object addAttachment(String name, Object attachment)
+ {
+ return unit.addAttachment(name, attachment);
+ }
+ public Object getAttachment(String name)
+ {
+ return unit.getAttachment(name);
+ }
+ public Object removeAttachment(String name)
+ {
+ return unit.removeAttachment(name);
+ }
+
+ public VirtualFile getRootFile()
+ {
+ return unit.getFile("");
+ }
+
+ public String getRelativePath()
+ {
+ return unit.getRelativePath();
+ }
+
+ public URL getRelativeURL(String jar)
+ {
+ try
+ {
+ return new URL(jar);
+ }
+ catch (MalformedURLException e)
+ {
+ try
+ {
+ if (getUrl() == null)
+ throw new RuntimeException("relative <jar-file> not allowed when standalone deployment unit is used");
+ return new URL(getUrl(), jar);
+ }
+ catch (Exception e1)
+ {
+ throw new RuntimeException("could not find relative path: " + jar, e1);
+ }
+ }
+ }
+
+ URL extractDescriptorUrl(String resource)
+ {
+ try
+ {
+ VirtualFile vf = unit.getMetaDataFile(resource);
+ if (vf == null) return null;
+ return vf.toURL();
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public URL getPersistenceXml()
+ {
+ return extractDescriptorUrl("persistence.xml");
+ }
+
+ public URL getEjbJarXml()
+ {
+ return extractDescriptorUrl("ejb-jar.xml");
+ }
+
+ public URL getJbossXml()
+ {
+ return extractDescriptorUrl("jboss.xml");
+ }
+
+ public VirtualFile getMetaDataFile(String name)
+ {
+ return unit.getMetaDataFile(name);
+ }
+
+ public List<Class> getClasses()
+ {
+ return null;
+ }
+
+ public ClassLoader getClassLoader()
+ {
+ return classLoader;
+ }
+
+ public ClassLoader getResourceLoader()
+ {
+ return getClassLoader();
+ }
+
+ public String getShortName()
+ {
+ return unit.getFile("").getName();
+ }
+
+ public URL getUrl()
+ {
+ try
+ {
+ return unit.getFile("").toURL();
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public String getDefaultEntityManagerName()
+ {
+ String url = getUrl().toString();
+ String name = url.substring(url.lastIndexOf('/') + 1, url.lastIndexOf('.'));
+ return name;
+ }
+
+ public Map getDefaultPersistenceProperties()
+ {
+ return defaultPersistenceProperties;
+ }
+
+ public void setDefaultPersistenceProperties(Map defaultPersistenceProperties)
+ {
+ this.defaultPersistenceProperties = defaultPersistenceProperties;
+ }
+
+ public Hashtable getJndiProperties()
+ {
+ return null;
+ }
+
+ public InterceptorInfoRepository getInterceptorInfoRepository()
+ {
+ return interceptorInfoRepository;
+ }
+
+ public List<VirtualFile> getResources(VirtualFileFilter filter)
+ {
+ VisitorAttributes va = new VisitorAttributes();
+ va.setLeavesOnly(true);
+ SuffixesExcludeFilter noJars = new SuffixesExcludeFilter(JarUtils.getSuffixes());
+ va.setRecurseFilter(noJars);
+ FilterVirtualFileVisitor visitor = new FilterVirtualFileVisitor(filter, va);
+
+ List<VirtualFile> classPath = unit.getClassPath();
+ if(classPath == null)
+ return Collections.emptyList();
+
+ for(VirtualFile root : classPath)
+ {
+ try
+ {
+ if( root.isLeaf() == false )
+ root.visit(visitor);
+ }
+ catch (IOException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ List<VirtualFile> resources = visitor.getMatched();
+
+ return resources;
+ }
+}
Property changes on: trunk/ejb3/src/main/org/jboss/ejb3/deployers/JBoss5DeploymentUnit.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/ejb3/src/main/org/jboss/ejb3/deployers/JBossASDepdencyPolicy.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/deployers/JBossASDepdencyPolicy.java 2008-11-14 14:58:15 UTC (rev 81052)
+++ trunk/ejb3/src/main/org/jboss/ejb3/deployers/JBossASDepdencyPolicy.java 2008-11-14 14:59:40 UTC (rev 81053)
@@ -1,157 +1,157 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2007, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ejb3.deployers;
-
-import java.util.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.DependencyMetaData;
-import org.jboss.beans.metadata.spi.SupplyMetaData;
-import org.jboss.ejb3.DependencyPolicy;
-import org.jboss.ejb3.javaee.JavaEEComponent;
-import org.jboss.ejb3.kernel.JNDIKernelRegistryPlugin;
-
-/**
- * The implementation of the DependencyPolicy used by the jbossas ejb3
- * related deployers.
- *
- * @author Scott.Stark at jboss.org
- * @version $Revision:$
- */
-public class JBossASDepdencyPolicy extends JBoss5DependencyPolicy
- implements DependencyPolicy
-{
- private JavaEEComponent component;
- private Set<DependencyMetaData> dependencies = new HashSet<DependencyMetaData>();
- private Set<DemandMetaData> demands = new HashSet<DemandMetaData>();
- private Set<SupplyMetaData> supplies = new HashSet<SupplyMetaData>();
-
- public JBossASDepdencyPolicy(JavaEEComponent component)
- {
- super(component);
- this.component = component;
- }
-
- public void addDependency(String dependency)
- {
- addDependency(new AbstractDemandMetaData(dependency));
- }
- public void addDependency(DemandMetaData dependency)
- {
- demands.add(dependency);
- }
- public void addDependency(DependencyMetaData dependency)
- {
- dependencies.add(dependency);
- }
-
- public void addDependency(Class<?> businessInterface)
- {
- addDependency("Class:" + businessInterface.getName());
- }
-
- /**
- * Add a dependency on an enterprise bean.
- *
- * Optionally the ejb link is prefixed with the path name to
- * another ejb-jar file separated with a '#' to the enterprise bean's name.
- *
- * @param ejbLink the name of the target enterprise bean
- * @param businessInterface
- */
- 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)
- {
- String unitName = ejbLink.substring(0, hashIndex);
- String ejbName = ejbLink.substring(hashIndex + 1);
- // Work around ejb2/3 container name mismatches by adding
- String ejb3Name = component.createObjectName(unitName, ejbName);
- String ejb2Name = "TODO...";
- String demand = null;
- AbstractDemandMetaData admd = new AbstractDemandMetaData(demand);
- admd.setTransformer("");
- //addDependency(admd);
- }
- else
- {
- //addDependency(new EjbLinkDemandMetaData(component, ejbLink));
- }
- }
-
- public void addJNDIName(String name)
- {
- assert name != null : "name is null";
- assert name.length() > 0 : "name is empty";
-
- addDependency(JNDIKernelRegistryPlugin.JNDI_DEPENDENCY_PREFIX + name);
- }
-
- public Set<DependencyMetaData> getDependencies()
- {
- return dependencies;
- }
- public Set<DemandMetaData> getDemands()
- {
- return demands;
- }
-
- public void addSupply(Class<?> businessInterface)
- {
- supplies.add(new AbstractSupplyMetaData("Class:" + businessInterface.getName()));
- }
-
- public Set<SupplyMetaData> getSupplies()
- {
- return supplies;
- }
- public void addDatasource(String jndiName)
- {
- addDependency(createDataSourceKernelName(jndiName));
- }
-
- public static String createDataSourceKernelName(String jndiName)
- {
- String ds = jndiName;
- if (ds.startsWith("java:/"))
- {
- ds = ds.substring(6);
-
- }
- else if (ds.startsWith("java:"))
- {
- ds = ds.substring(5);
- }
- String onStr = "jboss.jca:name=" + ds + ",service=DataSourceBinding";
- return onStr;
- }
-}
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.deployers;
+
+import java.util.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.DependencyMetaData;
+import org.jboss.beans.metadata.spi.SupplyMetaData;
+import org.jboss.ejb3.DependencyPolicy;
+import org.jboss.ejb3.javaee.JavaEEComponent;
+import org.jboss.ejb3.kernel.JNDIKernelRegistryPlugin;
+
+/**
+ * The implementation of the DependencyPolicy used by the jbossas ejb3
+ * related deployers.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class JBossASDepdencyPolicy extends JBoss5DependencyPolicy
+ implements DependencyPolicy
+{
+ private JavaEEComponent component;
+ private Set<DependencyMetaData> dependencies = new HashSet<DependencyMetaData>();
+ private Set<DemandMetaData> demands = new HashSet<DemandMetaData>();
+ private Set<SupplyMetaData> supplies = new HashSet<SupplyMetaData>();
+
+ public JBossASDepdencyPolicy(JavaEEComponent component)
+ {
+ super(component);
+ this.component = component;
+ }
+
+ public void addDependency(String dependency)
+ {
+ addDependency(new AbstractDemandMetaData(dependency));
+ }
+ public void addDependency(DemandMetaData dependency)
+ {
+ demands.add(dependency);
+ }
+ public void addDependency(DependencyMetaData dependency)
+ {
+ dependencies.add(dependency);
+ }
+
+ public void addDependency(Class<?> businessInterface)
+ {
+ addDependency("Class:" + businessInterface.getName());
+ }
+
+ /**
+ * Add a dependency on an enterprise bean.
+ *
+ * Optionally the ejb link is prefixed with the path name to
+ * another ejb-jar file separated with a '#' to the enterprise bean's name.
+ *
+ * @param ejbLink the name of the target enterprise bean
+ * @param businessInterface
+ */
+ 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)
+ {
+ String unitName = ejbLink.substring(0, hashIndex);
+ String ejbName = ejbLink.substring(hashIndex + 1);
+ // Work around ejb2/3 container name mismatches by adding
+ String ejb3Name = component.createObjectName(unitName, ejbName);
+ String ejb2Name = "TODO...";
+ String demand = null;
+ AbstractDemandMetaData admd = new AbstractDemandMetaData(demand);
+ admd.setTransformer("");
+ //addDependency(admd);
+ }
+ else
+ {
+ //addDependency(new EjbLinkDemandMetaData(component, ejbLink));
+ }
+ }
+
+ public void addJNDIName(String name)
+ {
+ assert name != null : "name is null";
+ assert name.length() > 0 : "name is empty";
+
+ addDependency(JNDIKernelRegistryPlugin.JNDI_DEPENDENCY_PREFIX + name);
+ }
+
+ public Set<DependencyMetaData> getDependencies()
+ {
+ return dependencies;
+ }
+ public Set<DemandMetaData> getDemands()
+ {
+ return demands;
+ }
+
+ public void addSupply(Class<?> businessInterface)
+ {
+ supplies.add(new AbstractSupplyMetaData("Class:" + businessInterface.getName()));
+ }
+
+ public Set<SupplyMetaData> getSupplies()
+ {
+ return supplies;
+ }
+ public void addDatasource(String jndiName)
+ {
+ addDependency(createDataSourceKernelName(jndiName));
+ }
+
+ public static String createDataSourceKernelName(String jndiName)
+ {
+ String ds = jndiName;
+ if (ds.startsWith("java:/"))
+ {
+ ds = ds.substring(6);
+
+ }
+ else if (ds.startsWith("java:"))
+ {
+ ds = ds.substring(5);
+ }
+ String onStr = "jboss.jca:name=" + ds + ",service=DataSourceBinding";
+ return onStr;
+ }
+}
Property changes on: trunk/ejb3/src/main/org/jboss/ejb3/deployers/JBossASDepdencyPolicy.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/ejb3/src/main/org/jboss/ejb3/deployers/JBossASKernel.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/deployers/JBossASKernel.java 2008-11-14 14:58:15 UTC (rev 81052)
+++ trunk/ejb3/src/main/org/jboss/ejb3/deployers/JBossASKernel.java 2008-11-14 14:59:40 UTC (rev 81053)
@@ -1,314 +1,314 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2007, Red Hat Middleware LLC, and individual contributors
- * 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.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.management.InstanceNotFoundException;
-import javax.management.MBeanException;
-import javax.management.MBeanInfo;
-import javax.management.MBeanOperationInfo;
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-import javax.management.ReflectionException;
-
-import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
-import org.jboss.beans.metadata.plugins.AbstractConstructorMetaData;
-import org.jboss.beans.metadata.plugins.AbstractDemandMetaData;
-import org.jboss.beans.metadata.plugins.AbstractValueMetaData;
-import org.jboss.beans.metadata.spi.BeanMetaDataFactory;
-import org.jboss.beans.metadata.spi.DemandMetaData;
-import org.jboss.beans.metadata.spi.SupplyMetaData;
-import org.jboss.ejb3.DependencyPolicy;
-import org.jboss.ejb3.DeploymentUnit;
-import org.jboss.ejb3.KernelAbstraction;
-import org.jboss.ejb3.MCDependencyPolicy;
-import org.jboss.kernel.Kernel;
-import org.jboss.kernel.plugins.deployment.AbstractKernelDeployment;
-import org.jboss.kernel.spi.deployment.KernelDeployment;
-import org.jboss.kernel.spi.registry.KernelRegistryEntry;
-import org.jboss.logging.Logger;
-
-/**
- * The JBossAS implementation of the ejb3 KernelAbstraction integration api
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @author Scott.Stark at jboss.org
- * @version $Revision:$
- */
-public class JBossASKernel
- implements KernelAbstraction
-{
- private static Logger log = Logger.getLogger(JBossASKernel.class);
- private MBeanServer mbeanServer;
- private Kernel kernel;
-
- public JBossASKernel(Kernel kernel)
- {
- this(kernel, null);
- }
- public JBossASKernel(Kernel kernel, MBeanServer mbeanServer)
- {
- this.kernel = kernel;
- this.mbeanServer = mbeanServer;
- }
-
- public MBeanServer getMbeanServer()
- {
- return mbeanServer;
- }
- public void setMbeanServer(MBeanServer mbeanServer)
- {
- this.mbeanServer = mbeanServer;
- }
-
- public void install(String name, DependencyPolicy dependencies,
- DeploymentUnit unit, Object service)
- {
- // Look for the kernel deployment
- KernelDeployment deployment = null;
- if(unit != null)
- {
- deployment = (KernelDeployment) unit.getAttachment(KernelDeployment.class.getName());
- if(deployment == null)
- {
- AbstractKernelDeployment akd = new AbstractKernelDeployment();
- akd.setBeanFactories(new ArrayList<BeanMetaDataFactory>());
- deployment = akd;
- String kdname = unit.getShortName();
- deployment.setName(kdname);
- unit.addAttachment(KernelDeployment.class.getName(), deployment);
- log.info("Created KernelDeployment for: "+unit.getShortName());
- }
- }
-
- // Create the metadata for the bean to install
- AbstractBeanMetaData bean = new AbstractBeanMetaData(name, service.getClass().getName());
- bean.setConstructor(new AlreadyInstantiated(service));
- MCDependencyPolicy policy = (MCDependencyPolicy) dependencies;
- bean.setDepends(policy.getDependencies());
- bean.setDemands(policy.getDemands());
- bean.setSupplies(policy.getSupplies());
- log.info("installing bean: " + name);
- log.info(" with dependencies:");
- for (Object obj : policy.getDependencies())
- {
- Object msgObject = obj;
- if (obj instanceof AbstractDemandMetaData)
- {
- msgObject = ((AbstractDemandMetaData)obj).getDemand();
- }
- log.info("\t" + msgObject);
- }
- log.info(" and demands:");
- for(DemandMetaData dmd : policy.getDemands())
- {
- log.info("\t" + dmd.getDemand());
- }
- log.info(" and supplies:");
- for(SupplyMetaData smd : policy.getSupplies())
- {
- log.info("\t" + smd.getSupply());
- }
-
- if(unit != null)
- {
- // Just add the mc bean metadata to the unit
- deployment.getBeanFactories().add(bean);
- log.info("Added bean("+name+") to KernelDeployment of: "+unit.getShortName());
- }
- else
- {
- // Install directly into the kernel
- try
- {
- try
- {
- kernel.getController().uninstall(name);
- }
- catch (IllegalStateException e){}
-
- log.info("Installing bean("+name+") into kernel");
- kernel.getController().install(bean);
- }
- catch (Throwable throwable)
- {
- throw new RuntimeException(throwable);
- }
- }
- }
-
- public void installMBean(ObjectName on, DependencyPolicy dependencies,
- Object service)
- {
- if(mbeanServer == null)
- throw new RuntimeException("No MBeanServer has been injected");
-
- try
- {
- mbeanServer.registerMBean(service, on);
- install(on.getCanonicalName(), dependencies, null, service);
-
- // EJBTHREE-606: emulate the ServiceController calls
- MBeanInfo info = mbeanServer.getMBeanInfo(on); // redundant call for speed
- invokeOptionalMethod(on, info, "create");
- invokeOptionalMethod(on, info, "start");
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- }
-
- public void uninstall(String name)
- {
-
-
- }
-
- public Object getAttribute(ObjectName objectName, String attribute) throws Exception
- {
- String name = objectName.getCanonicalName();
- KernelRegistryEntry entry = kernel.getRegistry().getEntry(name);
- if (entry != null)
- {
- Object target = entry.getTarget();
- Field field = target.getClass().getField(attribute);
- return field.get(target);
- }
- return null;
- }
-
- public Set getMBeans(ObjectName query) throws Exception
- {
- Object target = kernel.getRegistry().getEntry(query);
- Set set = new HashSet();
- set.add(target);
- return set;
- }
-
- public void uninstallMBean(ObjectName on)
- {
- try
- {
- // EJBTHREE-606: emulate the ServiceController calls
- MBeanInfo info = mbeanServer.getMBeanInfo(on); // redundant call for speed
- try
- {
- invokeOptionalMethod(on, info, "stop");
- }
- catch(Exception e)
- {
- log.warn("stop on " + on + " failed", e);
- }
- try
- {
- invokeOptionalMethod(on, info, "destroy");
- }
- catch(Exception e)
- {
- log.warn("destroy on " + on + " failed", e);
- }
-
- mbeanServer.unregisterMBean(on);
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- }
-
- public Object invoke(ObjectName objectName, String operationName, Object[] params, String[] signature) throws Exception
- {
- String name = objectName.getCanonicalName();
- KernelRegistryEntry entry = kernel.getRegistry().getEntry(name);
- if (entry != null)
- {
- Object target = entry.getTarget();
- Class[] types = new Class[signature.length];
- for (int i = 0; i < signature.length; ++i)
- {
- types[i] = Thread.currentThread().getContextClassLoader().loadClass(signature[i]);
- }
- Method method = target.getClass().getMethod(operationName, types);
- return method.invoke(target, params);
- }
- return null;
- }
-
- private boolean hasOperation(MBeanInfo info, String operationName)
- {
- for(MBeanOperationInfo operationInfo : info.getOperations())
- {
- if(operationInfo.getName().equals(operationName) == false)
- continue;
-
- // void return type
- if(operationInfo.getReturnType().equals("void") == false)
- continue;
-
- // no parameters
- if(operationInfo.getSignature().length != 0)
- continue;
-
- return true;
- }
-
- return false;
- }
- private void invokeOptionalMethod(ObjectName on, MBeanInfo info, String operationName)
- throws InstanceNotFoundException, MBeanException, ReflectionException
- {
- Object params[] = { };
- String signature[] = { };
- if(hasOperation(info, operationName))
- mbeanServer.invoke(on, operationName, params, signature);
- }
-
- public static class AlreadyInstantiated extends AbstractConstructorMetaData
- {
- private static final long serialVersionUID = 1L;
-
- private Object bean;
-
- public class Factory
- {
-
- public Object create()
- {
- return bean;
- }
- }
-
- public AlreadyInstantiated(Object bean)
- {
- this.bean = bean;
- this.setFactory(new AbstractValueMetaData(new Factory()));
- this.setFactoryClass(Factory.class.getName());
- this.setFactoryMethod("create");
- }
- }
-
-}
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * 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.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.management.InstanceNotFoundException;
+import javax.management.MBeanException;
+import javax.management.MBeanInfo;
+import javax.management.MBeanOperationInfo;
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+import javax.management.ReflectionException;
+
+import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
+import org.jboss.beans.metadata.plugins.AbstractConstructorMetaData;
+import org.jboss.beans.metadata.plugins.AbstractDemandMetaData;
+import org.jboss.beans.metadata.plugins.AbstractValueMetaData;
+import org.jboss.beans.metadata.spi.BeanMetaDataFactory;
+import org.jboss.beans.metadata.spi.DemandMetaData;
+import org.jboss.beans.metadata.spi.SupplyMetaData;
+import org.jboss.ejb3.DependencyPolicy;
+import org.jboss.ejb3.DeploymentUnit;
+import org.jboss.ejb3.KernelAbstraction;
+import org.jboss.ejb3.MCDependencyPolicy;
+import org.jboss.kernel.Kernel;
+import org.jboss.kernel.plugins.deployment.AbstractKernelDeployment;
+import org.jboss.kernel.spi.deployment.KernelDeployment;
+import org.jboss.kernel.spi.registry.KernelRegistryEntry;
+import org.jboss.logging.Logger;
+
+/**
+ * The JBossAS implementation of the ejb3 KernelAbstraction integration api
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class JBossASKernel
+ implements KernelAbstraction
+{
+ private static Logger log = Logger.getLogger(JBossASKernel.class);
+ private MBeanServer mbeanServer;
+ private Kernel kernel;
+
+ public JBossASKernel(Kernel kernel)
+ {
+ this(kernel, null);
+ }
+ public JBossASKernel(Kernel kernel, MBeanServer mbeanServer)
+ {
+ this.kernel = kernel;
+ this.mbeanServer = mbeanServer;
+ }
+
+ public MBeanServer getMbeanServer()
+ {
+ return mbeanServer;
+ }
+ public void setMbeanServer(MBeanServer mbeanServer)
+ {
+ this.mbeanServer = mbeanServer;
+ }
+
+ public void install(String name, DependencyPolicy dependencies,
+ DeploymentUnit unit, Object service)
+ {
+ // Look for the kernel deployment
+ KernelDeployment deployment = null;
+ if(unit != null)
+ {
+ deployment = (KernelDeployment) unit.getAttachment(KernelDeployment.class.getName());
+ if(deployment == null)
+ {
+ AbstractKernelDeployment akd = new AbstractKernelDeployment();
+ akd.setBeanFactories(new ArrayList<BeanMetaDataFactory>());
+ deployment = akd;
+ String kdname = unit.getShortName();
+ deployment.setName(kdname);
+ unit.addAttachment(KernelDeployment.class.getName(), deployment);
+ log.info("Created KernelDeployment for: "+unit.getShortName());
+ }
+ }
+
+ // Create the metadata for the bean to install
+ AbstractBeanMetaData bean = new AbstractBeanMetaData(name, service.getClass().getName());
+ bean.setConstructor(new AlreadyInstantiated(service));
+ MCDependencyPolicy policy = (MCDependencyPolicy) dependencies;
+ bean.setDepends(policy.getDependencies());
+ bean.setDemands(policy.getDemands());
+ bean.setSupplies(policy.getSupplies());
+ log.info("installing bean: " + name);
+ log.info(" with dependencies:");
+ for (Object obj : policy.getDependencies())
+ {
+ Object msgObject = obj;
+ if (obj instanceof AbstractDemandMetaData)
+ {
+ msgObject = ((AbstractDemandMetaData)obj).getDemand();
+ }
+ log.info("\t" + msgObject);
+ }
+ log.info(" and demands:");
+ for(DemandMetaData dmd : policy.getDemands())
+ {
+ log.info("\t" + dmd.getDemand());
+ }
+ log.info(" and supplies:");
+ for(SupplyMetaData smd : policy.getSupplies())
+ {
+ log.info("\t" + smd.getSupply());
+ }
+
+ if(unit != null)
+ {
+ // Just add the mc bean metadata to the unit
+ deployment.getBeanFactories().add(bean);
+ log.info("Added bean("+name+") to KernelDeployment of: "+unit.getShortName());
+ }
+ else
+ {
+ // Install directly into the kernel
+ try
+ {
+ try
+ {
+ kernel.getController().uninstall(name);
+ }
+ catch (IllegalStateException e){}
+
+ log.info("Installing bean("+name+") into kernel");
+ kernel.getController().install(bean);
+ }
+ catch (Throwable throwable)
+ {
+ throw new RuntimeException(throwable);
+ }
+ }
+ }
+
+ public void installMBean(ObjectName on, DependencyPolicy dependencies,
+ Object service)
+ {
+ if(mbeanServer == null)
+ throw new RuntimeException("No MBeanServer has been injected");
+
+ try
+ {
+ mbeanServer.registerMBean(service, on);
+ install(on.getCanonicalName(), dependencies, null, service);
+
+ // EJBTHREE-606: emulate the ServiceController calls
+ MBeanInfo info = mbeanServer.getMBeanInfo(on); // redundant call for speed
+ invokeOptionalMethod(on, info, "create");
+ invokeOptionalMethod(on, info, "start");
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public void uninstall(String name)
+ {
+
+
+ }
+
+ public Object getAttribute(ObjectName objectName, String attribute) throws Exception
+ {
+ String name = objectName.getCanonicalName();
+ KernelRegistryEntry entry = kernel.getRegistry().getEntry(name);
+ if (entry != null)
+ {
+ Object target = entry.getTarget();
+ Field field = target.getClass().getField(attribute);
+ return field.get(target);
+ }
+ return null;
+ }
+
+ public Set getMBeans(ObjectName query) throws Exception
+ {
+ Object target = kernel.getRegistry().getEntry(query);
+ Set set = new HashSet();
+ set.add(target);
+ return set;
+ }
+
+ public void uninstallMBean(ObjectName on)
+ {
+ try
+ {
+ // EJBTHREE-606: emulate the ServiceController calls
+ MBeanInfo info = mbeanServer.getMBeanInfo(on); // redundant call for speed
+ try
+ {
+ invokeOptionalMethod(on, info, "stop");
+ }
+ catch(Exception e)
+ {
+ log.warn("stop on " + on + " failed", e);
+ }
+ try
+ {
+ invokeOptionalMethod(on, info, "destroy");
+ }
+ catch(Exception e)
+ {
+ log.warn("destroy on " + on + " failed", e);
+ }
+
+ mbeanServer.unregisterMBean(on);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public Object invoke(ObjectName objectName, String operationName, Object[] params, String[] signature) throws Exception
+ {
+ String name = objectName.getCanonicalName();
+ KernelRegistryEntry entry = kernel.getRegistry().getEntry(name);
+ if (entry != null)
+ {
+ Object target = entry.getTarget();
+ Class[] types = new Class[signature.length];
+ for (int i = 0; i < signature.length; ++i)
+ {
+ types[i] = Thread.currentThread().getContextClassLoader().loadClass(signature[i]);
+ }
+ Method method = target.getClass().getMethod(operationName, types);
+ return method.invoke(target, params);
+ }
+ return null;
+ }
+
+ private boolean hasOperation(MBeanInfo info, String operationName)
+ {
+ for(MBeanOperationInfo operationInfo : info.getOperations())
+ {
+ if(operationInfo.getName().equals(operationName) == false)
+ continue;
+
+ // void return type
+ if(operationInfo.getReturnType().equals("void") == false)
+ continue;
+
+ // no parameters
+ if(operationInfo.getSignature().length != 0)
+ continue;
+
+ return true;
+ }
+
+ return false;
+ }
+ private void invokeOptionalMethod(ObjectName on, MBeanInfo info, String operationName)
+ throws InstanceNotFoundException, MBeanException, ReflectionException
+ {
+ Object params[] = { };
+ String signature[] = { };
+ if(hasOperation(info, operationName))
+ mbeanServer.invoke(on, operationName, params, signature);
+ }
+
+ public static class AlreadyInstantiated extends AbstractConstructorMetaData
+ {
+ private static final long serialVersionUID = 1L;
+
+ private Object bean;
+
+ public class Factory
+ {
+
+ public Object create()
+ {
+ return bean;
+ }
+ }
+
+ public AlreadyInstantiated(Object bean)
+ {
+ this.bean = bean;
+ this.setFactory(new AbstractValueMetaData(new Factory()));
+ this.setFactoryClass(Factory.class.getName());
+ this.setFactoryMethod("create");
+ }
+ }
+
+}
Property changes on: trunk/ejb3/src/main/org/jboss/ejb3/deployers/JBossASKernel.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/ejb3/src/main/org/jboss/ejb3/deployers/JBossClientParsingDeployer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/deployers/JBossClientParsingDeployer.java 2008-11-14 14:58:15 UTC (rev 81052)
+++ trunk/ejb3/src/main/org/jboss/ejb3/deployers/JBossClientParsingDeployer.java 2008-11-14 14:59:40 UTC (rev 81053)
@@ -1,81 +1,81 @@
-/*
- * 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.spi.DeploymentException;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.deployers.vfs.spi.deployer.SchemaResolverDeployer;
-import org.jboss.metadata.client.jboss.JBossClientMetaData;
-import org.jboss.metadata.client.spec.ApplicationClientMetaData;
-
-/**
- * The jboss-client.xml javaee client parsing deployer
- *
- * This deployer generates a merged JBossClientMetaData.
- * For application-client.xml ApplicationClientMetaData is retrieved from
- * the attachments. If there is a jboss-client.xml it will be parsed
- * by the SchemaResolverDeployer.
- * If either one is available a merged view will be created.
- *
- * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @author adrian at jboss.org
- * @author Scott.Stark at jboss.org
- * @version $Revision: $
- */
-public class JBossClientParsingDeployer extends SchemaResolverDeployer<JBossClientMetaData>
-{
- public JBossClientParsingDeployer()
- {
- super(JBossClientMetaData.class);
- // If an ApplicationClientMetaData is available use it
- setInputs(ApplicationClientMetaData.class);
- setName("jboss-client.xml");
- }
-
- /**
- * Override to create the merged JBossClientMetaData view
- */
- @Override
- protected void createMetaData(DeploymentUnit unit, String name, String suffix) throws DeploymentException
- {
- super.createMetaData(unit, name, suffix);
- JBossClientMetaData jbossMetaData = getMetaData(unit, JBossClientMetaData.class.getName());
- ApplicationClientMetaData acmd = unit.getAttachment(ApplicationClientMetaData.class);
- // If either one is available generate a merged view
- if(jbossMetaData == null && acmd == null)
- return;
-
- // If there no JBossClientMetaData was created from a jboss-client.xml, create one
- if (jbossMetaData == null)
- {
- jbossMetaData = new JBossClientMetaData();
- }
- // Create a merged view
- JBossClientMetaData metaData = new JBossClientMetaData();
- metaData.merge(jbossMetaData, acmd, true);
- // Register the merged view as the output
- unit.getTransientManagedObjects().addAttachment(JBossClientMetaData.class.getName(), metaData, getOutput());
- // Keep the raw parsed as well
- // TODO: Wolf: Why? (ProfileService?)
- unit.getTransientManagedObjects().addAttachment("Raw"+JBossClientMetaData.class.getName(), jbossMetaData, getOutput());
- }
-}
+/*
+ * 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.spi.DeploymentException;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployers.vfs.spi.deployer.SchemaResolverDeployer;
+import org.jboss.metadata.client.jboss.JBossClientMetaData;
+import org.jboss.metadata.client.spec.ApplicationClientMetaData;
+
+/**
+ * The jboss-client.xml javaee client parsing deployer
+ *
+ * This deployer generates a merged JBossClientMetaData.
+ * For application-client.xml ApplicationClientMetaData is retrieved from
+ * the attachments. If there is a jboss-client.xml it will be parsed
+ * by the SchemaResolverDeployer.
+ * If either one is available a merged view will be created.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @author adrian at jboss.org
+ * @author Scott.Stark at jboss.org
+ * @version $Revision: $
+ */
+public class JBossClientParsingDeployer extends SchemaResolverDeployer<JBossClientMetaData>
+{
+ public JBossClientParsingDeployer()
+ {
+ super(JBossClientMetaData.class);
+ // If an ApplicationClientMetaData is available use it
+ setInputs(ApplicationClientMetaData.class);
+ setName("jboss-client.xml");
+ }
+
+ /**
+ * Override to create the merged JBossClientMetaData view
+ */
+ @Override
+ protected void createMetaData(DeploymentUnit unit, String name, String suffix) throws DeploymentException
+ {
+ super.createMetaData(unit, name, suffix);
+ JBossClientMetaData jbossMetaData = getMetaData(unit, JBossClientMetaData.class.getName());
+ ApplicationClientMetaData acmd = unit.getAttachment(ApplicationClientMetaData.class);
+ // If either one is available generate a merged view
+ if(jbossMetaData == null && acmd == null)
+ return;
+
+ // If there no JBossClientMetaData was created from a jboss-client.xml, create one
+ if (jbossMetaData == null)
+ {
+ jbossMetaData = new JBossClientMetaData();
+ }
+ // Create a merged view
+ JBossClientMetaData metaData = new JBossClientMetaData();
+ metaData.merge(jbossMetaData, acmd, true);
+ // Register the merged view as the output
+ unit.getTransientManagedObjects().addAttachment(JBossClientMetaData.class.getName(), metaData, getOutput());
+ // Keep the raw parsed as well
+ // TODO: Wolf: Why? (ProfileService?)
+ unit.getTransientManagedObjects().addAttachment("Raw"+JBossClientMetaData.class.getName(), jbossMetaData, getOutput());
+ }
+}
Property changes on: trunk/ejb3/src/main/org/jboss/ejb3/deployers/JBossClientParsingDeployer.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/ejb3/src/main/org/jboss/ejb3/deployers/MergedJBossClientMetaDataDeployer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/deployers/MergedJBossClientMetaDataDeployer.java 2008-11-14 14:58:15 UTC (rev 81052)
+++ trunk/ejb3/src/main/org/jboss/ejb3/deployers/MergedJBossClientMetaDataDeployer.java 2008-11-14 14:59:40 UTC (rev 81053)
@@ -1,94 +1,94 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * 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.spi.DeploymentException;
-import org.jboss.deployers.spi.deployer.DeploymentStages;
-import org.jboss.deployers.spi.deployer.helpers.AbstractDeployer;
-import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.deployment.AnnotationMetaDataDeployer;
-import org.jboss.metadata.client.jboss.JBossClientMetaData;
-import org.jboss.metadata.client.spec.AnnotationMergedView;
-import org.jboss.metadata.client.spec.ApplicationClient5MetaData;
-import org.jboss.metadata.client.spec.ApplicationClientMetaData;
-
-
-/**
- * A deployer that merges annotation metadata, xml metadata, and jboss metadata
- * into a merged JBossClientMetaData.
- *
- * @author Scott.Stark at jboss.org
- * @version $Revision:$
- */
-public class MergedJBossClientMetaDataDeployer extends AbstractDeployer
-{
- public static final String CLIENT_MERGED_ATTACHMENT_NAME = "merged."+JBossClientMetaData.class.getName();
-
- /**
- * Create a new JBossEjbParsingDeployer.
- */
- public MergedJBossClientMetaDataDeployer()
- {
- setStage(DeploymentStages.POST_CLASSLOADER);
- // application.xml metadata
- addInput(ApplicationClientMetaData.class);
- // jboss-client.xml metadata
- addInput(JBossClientMetaData.class);
- // annotated metadata view
- addInput(AnnotationMetaDataDeployer.CLIENT_ANNOTATED_ATTACHMENT_NAME);
- // Output is the merge JBossMetaData view
- setOutput(JBossClientMetaData.class);
- // Specify a separate merged name to distiguish this output from JBossClientMetaData
- addOutput(CLIENT_MERGED_ATTACHMENT_NAME);
- }
-
- public void deploy(DeploymentUnit unit) throws DeploymentException
- {
- ApplicationClientMetaData specMetaData = unit.getAttachment(ApplicationClientMetaData.class);
- JBossClientMetaData metaData = unit.getAttachment(JBossClientMetaData.class);
- // Check for an annotated view
- String key = AnnotationMetaDataDeployer.CLIENT_ANNOTATED_ATTACHMENT_NAME;
- ApplicationClient5MetaData annotatedMetaData = unit.getAttachment(key, ApplicationClient5MetaData.class);
- if(specMetaData == null && metaData == null && annotatedMetaData == null)
- return;
-
- if(annotatedMetaData != null)
- {
- if(specMetaData != null)
- {
- ApplicationClient5MetaData specMerged = new ApplicationClient5MetaData();
- AnnotationMergedView.merge(specMerged, specMetaData, annotatedMetaData);
- specMetaData = specMerged;
- }
- else
- specMetaData = annotatedMetaData;
- }
-
- // Create a merged view
- JBossClientMetaData mergedMetaData = new JBossClientMetaData();
- mergedMetaData.merge(metaData, specMetaData, false);
-
- // Output the merged JBossMetaData
- unit.getTransientManagedObjects().addAttachment(JBossClientMetaData.class, mergedMetaData);
- unit.addAttachment(CLIENT_MERGED_ATTACHMENT_NAME, mergedMetaData, JBossClientMetaData.class);
- }
-}
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * 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.spi.DeploymentException;
+import org.jboss.deployers.spi.deployer.DeploymentStages;
+import org.jboss.deployers.spi.deployer.helpers.AbstractDeployer;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.deployment.AnnotationMetaDataDeployer;
+import org.jboss.metadata.client.jboss.JBossClientMetaData;
+import org.jboss.metadata.client.spec.AnnotationMergedView;
+import org.jboss.metadata.client.spec.ApplicationClient5MetaData;
+import org.jboss.metadata.client.spec.ApplicationClientMetaData;
+
+
+/**
+ * A deployer that merges annotation metadata, xml metadata, and jboss metadata
+ * into a merged JBossClientMetaData.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revision:$
+ */
+public class MergedJBossClientMetaDataDeployer extends AbstractDeployer
+{
+ public static final String CLIENT_MERGED_ATTACHMENT_NAME = "merged."+JBossClientMetaData.class.getName();
+
+ /**
+ * Create a new JBossEjbParsingDeployer.
+ */
+ public MergedJBossClientMetaDataDeployer()
+ {
+ setStage(DeploymentStages.POST_CLASSLOADER);
+ // application.xml metadata
+ addInput(ApplicationClientMetaData.class);
+ // jboss-client.xml metadata
+ addInput(JBossClientMetaData.class);
+ // annotated metadata view
+ addInput(AnnotationMetaDataDeployer.CLIENT_ANNOTATED_ATTACHMENT_NAME);
+ // Output is the merge JBossMetaData view
+ setOutput(JBossClientMetaData.class);
+ // Specify a separate merged name to distiguish this output from JBossClientMetaData
+ addOutput(CLIENT_MERGED_ATTACHMENT_NAME);
+ }
+
+ public void deploy(DeploymentUnit unit) throws DeploymentException
+ {
+ ApplicationClientMetaData specMetaData = unit.getAttachment(ApplicationClientMetaData.class);
+ JBossClientMetaData metaData = unit.getAttachment(JBossClientMetaData.class);
+ // Check for an annotated view
+ String key = AnnotationMetaDataDeployer.CLIENT_ANNOTATED_ATTACHMENT_NAME;
+ ApplicationClient5MetaData annotatedMetaData = unit.getAttachment(key, ApplicationClient5MetaData.class);
+ if(specMetaData == null && metaData == null && annotatedMetaData == null)
+ return;
+
+ if(annotatedMetaData != null)
+ {
+ if(specMetaData != null)
+ {
+ ApplicationClient5MetaData specMerged = new ApplicationClient5MetaData();
+ AnnotationMergedView.merge(specMerged, specMetaData, annotatedMetaData);
+ specMetaData = specMerged;
+ }
+ else
+ specMetaData = annotatedMetaData;
+ }
+
+ // Create a merged view
+ JBossClientMetaData mergedMetaData = new JBossClientMetaData();
+ mergedMetaData.merge(metaData, specMetaData, false);
+
+ // Output the merged JBossMetaData
+ unit.getTransientManagedObjects().addAttachment(JBossClientMetaData.class, mergedMetaData);
+ unit.addAttachment(CLIENT_MERGED_ATTACHMENT_NAME, mergedMetaData, JBossClientMetaData.class);
+ }
+}
Property changes on: trunk/ejb3/src/main/org/jboss/ejb3/deployers/MergedJBossClientMetaDataDeployer.java
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: trunk/ejb3/src/resources/test/appclient/application-client.xml
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: trunk/ejb3/src/resources/test/appclient/application.xml
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: trunk/ejb3/src/resources/test/appclient/jboss-client.xml
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: trunk/ejb3/src/resources/test/appclient/simpleresource/application-client.xml
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: trunk/ejb3/src/resources/test/iiop/custom.jndi.properties
___________________________________________________________________
Name: svn:eol-style
+ native
Property changes on: trunk/ejb3/src/resources/test/iiop/jndi.properties
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/CustomJNDIJBossTestCase.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/CustomJNDIJBossTestCase.java 2008-11-14 14:58:15 UTC (rev 81052)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/CustomJNDIJBossTestCase.java 2008-11-14 14:59:40 UTC (rev 81053)
@@ -1,126 +1,126 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ejb3.test;
-
-import java.util.StringTokenizer;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.jboss.test.AbstractTestDelegate;
-import org.jboss.test.JBossTestCase;
-import org.jboss.test.JBossTestServices;
-
-/**
- * This test case will use custom.jndi.properties to find the deployer.
- *
- * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @version $Revision: $
- */
-public class CustomJNDIJBossTestCase extends JBossTestCase
-{
-
- public CustomJNDIJBossTestCase(String name)
- {
- super(name);
- }
-
- /**
- * Overriden to return CustomJNDIJBossTestServices as the test delegate.
- */
- public static AbstractTestDelegate getDelegate(Class clazz) throws Exception
- {
- AbstractTestDelegate delegate = new CustomJNDIJBossTestServices(clazz);
- return delegate;
- }
-
- /**
- * Get a JBossTestSetup that does login and deployment in setUp/tearDown
- *
- * @param test a Test
- * @param jarNames is a comma seperated list of deployments
- */
- public static Test getDeploySetup(final Test test, final String jarNames)
- throws Exception
- {
- CustomJNDIJBossTestSetup wrapper = new CustomJNDIJBossTestSetup(test)
- {
- protected void setUp() throws Exception
- {
- super.setUp();
- deploymentException = null;
- try
- {
- this.delegate.init();
-
- if (this.getDelegate().isSecureTest())
- this.delegate.login();
-
- if (jarNames == null) return;
-
- // deploy the comma seperated list of jars
- StringTokenizer st = new StringTokenizer(jarNames, ", ");
- while (st != null && st.hasMoreTokens())
- {
- String jarName = st.nextToken();
- this.redeploy(jarName);
- this.getLog().debug("deployed package: " + jarName);
- }
- }
- catch (Exception ex)
- {
- // Throw this in testServerFound() instead.
- deploymentException = ex;
- }
- }
-
- protected void tearDown() throws Exception
- {
- if (jarNames == null) return; //Nothing to Undeploy
-
- // undeploy the comma seperated list of jars
- StringTokenizer st = new StringTokenizer(jarNames, ", ");
- String[] depoyments = new String[st.countTokens()];
- for (int i = depoyments.length - 1; i >= 0; i--)
- depoyments[i] = st.nextToken();
- for (int i = 0; i < depoyments.length; i++)
- {
- String jarName = depoyments[i];
- this.undeploy(jarName);
- this.getLog().debug("undeployed package: " + jarName);
- }
-
- if (this.getDelegate().isSecureTest())
- this.delegate.logout();
- }
- };
- return wrapper;
- }
-
- public static Test getDeploySetup(final Class clazz, final String jarName)
- throws Exception
- {
- TestSuite suite = new TestSuite();
- suite.addTest(new TestSuite(clazz));
- return getDeploySetup(suite, jarName);
- }
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test;
+
+import java.util.StringTokenizer;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.jboss.test.AbstractTestDelegate;
+import org.jboss.test.JBossTestCase;
+import org.jboss.test.JBossTestServices;
+
+/**
+ * This test case will use custom.jndi.properties to find the deployer.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class CustomJNDIJBossTestCase extends JBossTestCase
+{
+
+ public CustomJNDIJBossTestCase(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * Overriden to return CustomJNDIJBossTestServices as the test delegate.
+ */
+ public static AbstractTestDelegate getDelegate(Class clazz) throws Exception
+ {
+ AbstractTestDelegate delegate = new CustomJNDIJBossTestServices(clazz);
+ return delegate;
+ }
+
+ /**
+ * Get a JBossTestSetup that does login and deployment in setUp/tearDown
+ *
+ * @param test a Test
+ * @param jarNames is a comma seperated list of deployments
+ */
+ public static Test getDeploySetup(final Test test, final String jarNames)
+ throws Exception
+ {
+ CustomJNDIJBossTestSetup wrapper = new CustomJNDIJBossTestSetup(test)
+ {
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ deploymentException = null;
+ try
+ {
+ this.delegate.init();
+
+ if (this.getDelegate().isSecureTest())
+ this.delegate.login();
+
+ if (jarNames == null) return;
+
+ // deploy the comma seperated list of jars
+ StringTokenizer st = new StringTokenizer(jarNames, ", ");
+ while (st != null && st.hasMoreTokens())
+ {
+ String jarName = st.nextToken();
+ this.redeploy(jarName);
+ this.getLog().debug("deployed package: " + jarName);
+ }
+ }
+ catch (Exception ex)
+ {
+ // Throw this in testServerFound() instead.
+ deploymentException = ex;
+ }
+ }
+
+ protected void tearDown() throws Exception
+ {
+ if (jarNames == null) return; //Nothing to Undeploy
+
+ // undeploy the comma seperated list of jars
+ StringTokenizer st = new StringTokenizer(jarNames, ", ");
+ String[] depoyments = new String[st.countTokens()];
+ for (int i = depoyments.length - 1; i >= 0; i--)
+ depoyments[i] = st.nextToken();
+ for (int i = 0; i < depoyments.length; i++)
+ {
+ String jarName = depoyments[i];
+ this.undeploy(jarName);
+ this.getLog().debug("undeployed package: " + jarName);
+ }
+
+ if (this.getDelegate().isSecureTest())
+ this.delegate.logout();
+ }
+ };
+ return wrapper;
+ }
+
+ public static Test getDeploySetup(final Class clazz, final String jarName)
+ throws Exception
+ {
+ TestSuite suite = new TestSuite();
+ suite.addTest(new TestSuite(clazz));
+ return getDeploySetup(suite, jarName);
+ }
+}
Property changes on: trunk/ejb3/src/test/org/jboss/ejb3/test/CustomJNDIJBossTestCase.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/CustomJNDIJBossTestServices.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/CustomJNDIJBossTestServices.java 2008-11-14 14:58:15 UTC (rev 81052)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/CustomJNDIJBossTestServices.java 2008-11-14 14:59:40 UTC (rev 81053)
@@ -1,83 +1,83 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ejb3.test;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Properties;
-
-import javax.naming.InitialContext;
-
-import org.jboss.test.JBossTestServices;
-
-/**
- * This class provides services for JBoss unit tests.
- * If found it uses custom.jndi.properties to establish a connection with
- * the Main Deployer.
- *
- * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @version $Revision: $
- */
-public class CustomJNDIJBossTestServices extends JBossTestServices
-{
-
- public CustomJNDIJBossTestServices(Class clazz)
- {
- super(clazz);
- }
- public CustomJNDIJBossTestServices(String className)
- {
- super(className);
- }
-
- protected Properties getCustomJNDIProperties() throws IOException
- {
- InputStream in = getClass().getClassLoader().getResourceAsStream("custom.jndi.properties");
- if(in == null)
- {
- log.debug("no custom.jndi.properties found using defaults");
- return null;
- }
- Properties props = new Properties();
- props.load(in);
- in.close();
- return props;
- }
-
- @Override
- public void init() throws Exception
- {
- if(initialContext == null)
- {
- initialContext = new InitialContext(getCustomJNDIProperties());
- log.debug("initialContext.getEnvironment()=" + initialContext.getEnvironment());
- jndiEnv = initialContext.getEnvironment();
-
- log.debug("server = " + getServer());
- }
- }
-
- protected boolean isSecureTest()
- {
- return Boolean.getBoolean("jbosstest.secure");
- }
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+import javax.naming.InitialContext;
+
+import org.jboss.test.JBossTestServices;
+
+/**
+ * This class provides services for JBoss unit tests.
+ * If found it uses custom.jndi.properties to establish a connection with
+ * the Main Deployer.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class CustomJNDIJBossTestServices extends JBossTestServices
+{
+
+ public CustomJNDIJBossTestServices(Class clazz)
+ {
+ super(clazz);
+ }
+ public CustomJNDIJBossTestServices(String className)
+ {
+ super(className);
+ }
+
+ protected Properties getCustomJNDIProperties() throws IOException
+ {
+ InputStream in = getClass().getClassLoader().getResourceAsStream("custom.jndi.properties");
+ if(in == null)
+ {
+ log.debug("no custom.jndi.properties found using defaults");
+ return null;
+ }
+ Properties props = new Properties();
+ props.load(in);
+ in.close();
+ return props;
+ }
+
+ @Override
+ public void init() throws Exception
+ {
+ if(initialContext == null)
+ {
+ initialContext = new InitialContext(getCustomJNDIProperties());
+ log.debug("initialContext.getEnvironment()=" + initialContext.getEnvironment());
+ jndiEnv = initialContext.getEnvironment();
+
+ log.debug("server = " + getServer());
+ }
+ }
+
+ protected boolean isSecureTest()
+ {
+ return Boolean.getBoolean("jbosstest.secure");
+ }
+}
Property changes on: trunk/ejb3/src/test/org/jboss/ejb3/test/CustomJNDIJBossTestServices.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/CustomJNDIJBossTestSetup.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/CustomJNDIJBossTestSetup.java 2008-11-14 14:58:15 UTC (rev 81052)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/CustomJNDIJBossTestSetup.java 2008-11-14 14:59:40 UTC (rev 81053)
@@ -1,56 +1,56 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ejb3.test;
-
-import junit.framework.Test;
-
-import org.jboss.test.JBossTestServices;
-import org.jboss.test.JBossTestSetup;
-
-/**
- * Comment
- *
- * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @version $Revision: $
- */
-public class CustomJNDIJBossTestSetup extends JBossTestSetup
-{
-
- public CustomJNDIJBossTestSetup(Test test) throws Exception
- {
- super(test);
- }
-
- protected CustomJNDIJBossTestServices getDelegate()
- {
- return (CustomJNDIJBossTestServices) this.delegate;
- }
-
- @Override
- protected void setUp() throws Exception
- {
- // override so we get the right delegate
-
- delegate = (JBossTestServices) CustomJNDIJBossTestCase.getDelegate(clazz);
- delegate.setUp();
- }
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test;
+
+import junit.framework.Test;
+
+import org.jboss.test.JBossTestServices;
+import org.jboss.test.JBossTestSetup;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class CustomJNDIJBossTestSetup extends JBossTestSetup
+{
+
+ public CustomJNDIJBossTestSetup(Test test) throws Exception
+ {
+ super(test);
+ }
+
+ protected CustomJNDIJBossTestServices getDelegate()
+ {
+ return (CustomJNDIJBossTestServices) this.delegate;
+ }
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ // override so we get the right delegate
+
+ delegate = (JBossTestServices) CustomJNDIJBossTestCase.getDelegate(clazz);
+ delegate.setUp();
+ }
+}
Property changes on: trunk/ejb3/src/test/org/jboss/ejb3/test/CustomJNDIJBossTestSetup.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/appclient/HelloWorldBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/appclient/HelloWorldBean.java 2008-11-14 14:58:15 UTC (rev 81052)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/appclient/HelloWorldBean.java 2008-11-14 14:59:40 UTC (rev 81053)
@@ -1,41 +1,41 @@
-/*
- * 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.test.appclient;
-
-import javax.ejb.Remote;
-import javax.ejb.Stateless;
-
-/**
- * Comment
- *
- * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @version $Revision: $
- */
- at Stateless
- at Remote(HelloWorldService.class)
-public class HelloWorldBean implements HelloWorldService
-{
- public String sayHelloTo(String name)
- {
- return "Hi " + name;
- }
-}
+/*
+ * 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.test.appclient;
+
+import javax.ejb.Remote;
+import javax.ejb.Stateless;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+ at Stateless
+ at Remote(HelloWorldService.class)
+public class HelloWorldBean implements HelloWorldService
+{
+ public String sayHelloTo(String name)
+ {
+ return "Hi " + name;
+ }
+}
Property changes on: trunk/ejb3/src/test/org/jboss/ejb3/test/appclient/HelloWorldBean.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/appclient/HelloWorldService.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/appclient/HelloWorldService.java 2008-11-14 14:58:15 UTC (rev 81052)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/appclient/HelloWorldService.java 2008-11-14 14:59:40 UTC (rev 81053)
@@ -1,33 +1,33 @@
-/*
- * 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.test.appclient;
-
-/**
- * Comment
- *
- * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @version $Revision: $
- */
-public interface HelloWorldService
-{
- String sayHelloTo(String name);
-}
+/*
+ * 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.test.appclient;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public interface HelloWorldService
+{
+ String sayHelloTo(String name);
+}
Property changes on: trunk/ejb3/src/test/org/jboss/ejb3/test/appclient/HelloWorldService.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/appclient/MessageReplierBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/appclient/MessageReplierBean.java 2008-11-14 14:58:15 UTC (rev 81052)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/appclient/MessageReplierBean.java 2008-11-14 14:59:40 UTC (rev 81053)
@@ -1,86 +1,86 @@
-/*
- * 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.test.appclient;
-
-import javax.annotation.Resource;
-import javax.ejb.ActivationConfigProperty;
-import javax.ejb.EJBException;
-import javax.ejb.MessageDriven;
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-
-import org.jboss.logging.Logger;
-
-/**
- * This message bean will just reply the message.
- *
- * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @version $Revision: $
- */
- at MessageDriven(activationConfig = {
- @ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Queue"),
- @ActivationConfigProperty(propertyName="destination", propertyValue="queue/messageReplier")
-})
-public class MessageReplierBean implements MessageListener
-{
- private static final Logger log = Logger.getLogger(MessageReplierBean.class);
-
- @Resource(mappedName="java:ConnectionFactory")
- private ConnectionFactory connectionFactory;
-
- public void onMessage(Message message)
- {
- try
- {
- if(message.getJMSReplyTo() != null)
- {
- Destination destination = message.getJMSReplyTo();
-
- Connection conn = connectionFactory.createConnection();
- try
- {
- Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageProducer producer = session.createProducer(destination);
- producer.send(destination, message);
- producer.close();
- session.close();
- }
- finally
- {
- conn.close();
- }
- }
- else
- log.info("no reply to specified");
- }
- catch(JMSException e)
- {
- throw new EJBException(e);
- }
- }
-}
+/*
+ * 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.test.appclient;
+
+import javax.annotation.Resource;
+import javax.ejb.ActivationConfigProperty;
+import javax.ejb.EJBException;
+import javax.ejb.MessageDriven;
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+
+import org.jboss.logging.Logger;
+
+/**
+ * This message bean will just reply the message.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+ at MessageDriven(activationConfig = {
+ @ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Queue"),
+ @ActivationConfigProperty(propertyName="destination", propertyValue="queue/messageReplier")
+})
+public class MessageReplierBean implements MessageListener
+{
+ private static final Logger log = Logger.getLogger(MessageReplierBean.class);
+
+ @Resource(mappedName="java:ConnectionFactory")
+ private ConnectionFactory connectionFactory;
+
+ public void onMessage(Message message)
+ {
+ try
+ {
+ if(message.getJMSReplyTo() != null)
+ {
+ Destination destination = message.getJMSReplyTo();
+
+ Connection conn = connectionFactory.createConnection();
+ try
+ {
+ Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageProducer producer = session.createProducer(destination);
+ producer.send(destination, message);
+ producer.close();
+ session.close();
+ }
+ finally
+ {
+ conn.close();
+ }
+ }
+ else
+ log.info("no reply to specified");
+ }
+ catch(JMSException e)
+ {
+ throw new EJBException(e);
+ }
+ }
+}
Property changes on: trunk/ejb3/src/test/org/jboss/ejb3/test/appclient/MessageReplierBean.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/appclient/client/HelloWorldClient.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/appclient/client/HelloWorldClient.java 2008-11-14 14:58:15 UTC (rev 81052)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/appclient/client/HelloWorldClient.java 2008-11-14 14:59:40 UTC (rev 81053)
@@ -1,129 +1,129 @@
-/*
- * 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.test.appclient.client;
-
-import javax.annotation.Resource;
-import javax.ejb.EJB;
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.Destination;
-import javax.jms.MessageConsumer;
-import javax.jms.MessageProducer;
-import javax.jms.Queue;
-import javax.jms.Session;
-import javax.jms.TextMessage;
-
-import org.jboss.ejb3.test.appclient.HelloWorldService;
-
-/**
- * Comment
- *
- * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @version $Revision: $
- */
-public class HelloWorldClient
-{
- @EJB
- private static HelloWorldService helloWorldService;
-
- @Resource(name="msg")
- private static String msg;
-
- private static String result;
-
- @Resource(mappedName="ConnectionFactory")
- private static ConnectionFactory connectionFactory;
-
- @Resource(name="messageReplier")
- private static Destination destination;
-
- private static int postConstructCalls = 0;
-
- public static int getPostConstructCalls()
- {
- return postConstructCalls;
- }
-
- public static String getResult()
- {
- return result;
- }
-
- public static void main(String args[])
- {
- String name = "unspecified";
- if(args.length > 0)
- name = args[0];
-
- if(helloWorldService == null)
- throw new NullPointerException("helloWorldService is null");
-
- if(msg == null)
- throw new NullPointerException("msg is null");
-
- result = helloWorldService.sayHelloTo(name) + ", " + msg;
-
- testMDB();
- }
-
- public static void testMDB()
- {
- if(connectionFactory == null)
- throw new NullPointerException("connectionFactory is null");
-
- if(destination == null)
- throw new NullPointerException("destination is null");
-
- try
- {
- Connection conn = connectionFactory.createConnection();
- Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- Queue replyTo = session.createTemporaryQueue();
- TextMessage msg = session.createTextMessage("Hello world");
- msg.setJMSReplyTo(replyTo);
-
- MessageConsumer consumer = session.createConsumer(replyTo);
- conn.start();
-
- MessageProducer producer = session.createProducer(destination);
- producer.send(destination, msg);
-
- TextMessage reply = (TextMessage) consumer.receive(2000);
- System.out.println("reply = " + reply.getText());
-
- producer.close();
- conn.stop();
- consumer.close();
- session.close();
- }
- catch(Exception e)
- {
- throw new RuntimeException(e);
- }
- }
-
- public static void postConstruct()
- {
- postConstructCalls++;
- }
-}
+/*
+ * 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.test.appclient.client;
+
+import javax.annotation.Resource;
+import javax.ejb.EJB;
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.Destination;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
+import org.jboss.ejb3.test.appclient.HelloWorldService;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class HelloWorldClient
+{
+ @EJB
+ private static HelloWorldService helloWorldService;
+
+ @Resource(name="msg")
+ private static String msg;
+
+ private static String result;
+
+ @Resource(mappedName="ConnectionFactory")
+ private static ConnectionFactory connectionFactory;
+
+ @Resource(name="messageReplier")
+ private static Destination destination;
+
+ private static int postConstructCalls = 0;
+
+ public static int getPostConstructCalls()
+ {
+ return postConstructCalls;
+ }
+
+ public static String getResult()
+ {
+ return result;
+ }
+
+ public static void main(String args[])
+ {
+ String name = "unspecified";
+ if(args.length > 0)
+ name = args[0];
+
+ if(helloWorldService == null)
+ throw new NullPointerException("helloWorldService is null");
+
+ if(msg == null)
+ throw new NullPointerException("msg is null");
+
+ result = helloWorldService.sayHelloTo(name) + ", " + msg;
+
+ testMDB();
+ }
+
+ public static void testMDB()
+ {
+ if(connectionFactory == null)
+ throw new NullPointerException("connectionFactory is null");
+
+ if(destination == null)
+ throw new NullPointerException("destination is null");
+
+ try
+ {
+ Connection conn = connectionFactory.createConnection();
+ Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ Queue replyTo = session.createTemporaryQueue();
+ TextMessage msg = session.createTextMessage("Hello world");
+ msg.setJMSReplyTo(replyTo);
+
+ MessageConsumer consumer = session.createConsumer(replyTo);
+ conn.start();
+
+ MessageProducer producer = session.createProducer(destination);
+ producer.send(destination, msg);
+
+ TextMessage reply = (TextMessage) consumer.receive(2000);
+ System.out.println("reply = " + reply.getText());
+
+ producer.close();
+ conn.stop();
+ consumer.close();
+ session.close();
+ }
+ catch(Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public static void postConstruct()
+ {
+ postConstructCalls++;
+ }
+}
Property changes on: trunk/ejb3/src/test/org/jboss/ejb3/test/appclient/client/HelloWorldClient.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/appclient/client/SimpleResourceClient.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/appclient/client/SimpleResourceClient.java 2008-11-14 14:58:15 UTC (rev 81052)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/appclient/client/SimpleResourceClient.java 2008-11-14 14:59:40 UTC (rev 81053)
@@ -1,48 +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);
- }
-
-}
+/*
+ * 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);
+ }
+
+}
Property changes on: trunk/ejb3/src/test/org/jboss/ejb3/test/appclient/client/SimpleResourceClient.java
___________________________________________________________________
Name: svn:eol-style
+ native
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 2008-11-14 14:58:15 UTC (rev 81052)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/appclient/unit/AppClientUnitTestCase.java 2008-11-14 14:59:40 UTC (rev 81053)
@@ -1,76 +1,76 @@
-/*
- * 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.test.appclient.unit;
-
-import java.net.URL;
-import java.util.Date;
-
-import junit.framework.Test;
-
-import org.jboss.ejb3.client.ClientLauncher;
-import org.jboss.ejb3.metamodel.ApplicationClientDD;
-import org.jboss.ejb3.test.appclient.client.HelloWorldClient;
-import org.jboss.metadata.client.jboss.JBossClientMetaData;
-import org.jboss.test.JBossTestCase;
-
-/**
- * Comment
- *
- * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @version $Revision: $
- */
-public class AppClientUnitTestCase extends JBossTestCase
-{
- public AppClientUnitTestCase(String name)
- {
- super(name);
- }
-
- public void test1() throws Throwable
- {
- String mainClassName = HelloWorldClient.class.getName();
- String applicationClientName = "applicationclient_test"; // must match JNDI name in jboss-client.xml or display-name in application-client.xml
- String name = new Date().toString();
- String args[] = { name };
-
- ClientLauncher launcher = new ClientLauncher();
- launcher.launch(mainClassName, applicationClientName, args);
-
- {
- String actual = HelloWorldClient.getResult();
- String expected = "Hi " + name + ", how are you?";
- assertEquals(expected, actual);
- }
-
- {
- int actual = HelloWorldClient.getPostConstructCalls();
- int expected = 1;
- assertEquals("postConstruct should be called once", expected, actual);
- }
- }
-
- public static Test suite() throws Exception
- {
- return getDeploySetup(AppClientUnitTestCase.class, "appclient-jms-service.xml,appclient-test.ear");
- //return getDeploySetup(AppClientUnitTestCase.class, "appclient-test.jar,appclient-test-client.jar");
- }
-}
+/*
+ * 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.test.appclient.unit;
+
+import java.net.URL;
+import java.util.Date;
+
+import junit.framework.Test;
+
+import org.jboss.ejb3.client.ClientLauncher;
+import org.jboss.ejb3.metamodel.ApplicationClientDD;
+import org.jboss.ejb3.test.appclient.client.HelloWorldClient;
+import org.jboss.metadata.client.jboss.JBossClientMetaData;
+import org.jboss.test.JBossTestCase;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class AppClientUnitTestCase extends JBossTestCase
+{
+ public AppClientUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void test1() throws Throwable
+ {
+ String mainClassName = HelloWorldClient.class.getName();
+ String applicationClientName = "applicationclient_test"; // must match JNDI name in jboss-client.xml or display-name in application-client.xml
+ String name = new Date().toString();
+ String args[] = { name };
+
+ ClientLauncher launcher = new ClientLauncher();
+ launcher.launch(mainClassName, applicationClientName, args);
+
+ {
+ String actual = HelloWorldClient.getResult();
+ String expected = "Hi " + name + ", how are you?";
+ assertEquals(expected, actual);
+ }
+
+ {
+ int actual = HelloWorldClient.getPostConstructCalls();
+ int expected = 1;
+ assertEquals("postConstruct should be called once", expected, actual);
+ }
+ }
+
+ public static Test suite() throws Exception
+ {
+ return getDeploySetup(AppClientUnitTestCase.class, "appclient-jms-service.xml,appclient-test.ear");
+ //return getDeploySetup(AppClientUnitTestCase.class, "appclient-test.jar,appclient-test-client.jar");
+ }
+}
Property changes on: trunk/ejb3/src/test/org/jboss/ejb3/test/appclient/unit/AppClientUnitTestCase.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/appclient/unit/SimpleResourceEarUnitTestCase.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/appclient/unit/SimpleResourceEarUnitTestCase.java 2008-11-14 14:58:15 UTC (rev 81052)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/appclient/unit/SimpleResourceEarUnitTestCase.java 2008-11-14 14:59:40 UTC (rev 81053)
@@ -1,112 +1,112 @@
-/*
- * 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.metadata.client.jboss.JBossClientMetaData;
-import org.jboss.test.JBossTestCase;
-
-/**
- * Comment
- *
- * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @version $Revision: $
- */
-public class SimpleResourceEarUnitTestCase extends JBossTestCase
-{
-
- public SimpleResourceEarUnitTestCase(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 Throwable
- {
- 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 launcher = new ClientLauncher();
- launcher.launch(mainClassName, applicationClientName, args);
- }
-
- public static Test suite() throws Exception
- {
- return getDeploySetup(SimpleResourceEarUnitTestCase.class, "appclient-simpleresource.ear");
- }
-
-}
+/*
+ * 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.metadata.client.jboss.JBossClientMetaData;
+import org.jboss.test.JBossTestCase;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class SimpleResourceEarUnitTestCase extends JBossTestCase
+{
+
+ public SimpleResourceEarUnitTestCase(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 Throwable
+ {
+ 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 launcher = new ClientLauncher();
+ launcher.launch(mainClassName, applicationClientName, args);
+ }
+
+ public static Test suite() throws Exception
+ {
+ return getDeploySetup(SimpleResourceEarUnitTestCase.class, "appclient-simpleresource.ear");
+ }
+
+}
Property changes on: trunk/ejb3/src/test/org/jboss/ejb3/test/appclient/unit/SimpleResourceEarUnitTestCase.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/appclient/unit/SimpleResourceUnitTestCase.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/appclient/unit/SimpleResourceUnitTestCase.java 2008-11-14 14:58:15 UTC (rev 81052)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/appclient/unit/SimpleResourceUnitTestCase.java 2008-11-14 14:59:40 UTC (rev 81053)
@@ -1,112 +1,112 @@
-/*
- * 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.metadata.client.jboss.JBossClientMetaData;
-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 Throwable
- {
- 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 launcher = new ClientLauncher();
- launcher.launch(mainClassName, applicationClientName, args);
- }
-
- public static Test suite() throws Exception
- {
- return getDeploySetup(SimpleResourceUnitTestCase.class, "appclient-simpleresource-client.jar");
- }
-
-}
+/*
+ * 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.metadata.client.jboss.JBossClientMetaData;
+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 Throwable
+ {
+ 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 launcher = new ClientLauncher();
+ launcher.launch(mainClassName, applicationClientName, args);
+ }
+
+ public static Test suite() throws Exception
+ {
+ return getDeploySetup(SimpleResourceUnitTestCase.class, "appclient-simpleresource-client.jar");
+ }
+
+}
Property changes on: trunk/ejb3/src/test/org/jboss/ejb3/test/appclient/unit/SimpleResourceUnitTestCase.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/common/unit/DBSetup.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/common/unit/DBSetup.java 2008-11-14 14:58:15 UTC (rev 81052)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/common/unit/DBSetup.java 2008-11-14 14:59:40 UTC (rev 81053)
@@ -1,156 +1,156 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ejb3.test.common.unit;
-
-import java.sql.DriverManager;
-import java.sql.Connection;
-import java.sql.Statement;
-import java.io.File;
-import java.io.IOException;
-import java.lang.reflect.Method;
-
-import junit.extensions.TestSetup;
-import junit.framework.Test;
-
-/** A TestSetup that starts hypersonic before the testcase with a tcp
- * listening port at 1701.
- *
- * @author Scott.Stark at jboss.org
- * @version $Revison:$
- */
-public class DBSetup extends TestSetup
-{
- public DBSetup(Test test)
- {
- super(test);
- }
-
- protected void setUp() throws Exception
- {
- File hypersoniDir = new File("output/hypersonic");
- if (!hypersoniDir.exists())
- {
- hypersoniDir.mkdirs();
- }
-
- if (!hypersoniDir.isDirectory())
- {
- throw new IOException("Failed to create directory: " + hypersoniDir);
- }
-
- File dbPath = new File(hypersoniDir, "clusteredentity-db");
-
- // Start DB in new thread, or else it will block us
- DBThread serverThread = new DBThread(dbPath);
- serverThread.start();
-
- int elapsed = 0;
- while (!serverThread.isStarted() && elapsed < 15000)
- {
- try
- {
- Thread.sleep(100);
- elapsed += 100;
- }
- catch (InterruptedException ie)
- {
- System.out.println("Interrupted while waiting for Hypersonic");
- }
- }
-
- if (!serverThread.isStarted())
- System.out.println("Hypersonic failed to start in a timely fashion");
- }
-
- protected void tearDown() throws Exception
- {
- Class.forName("org.hsqldb.jdbcDriver");
- String dbURL = "jdbc:hsqldb:hsql://" + System.getProperty("jbosstest.server.host", "localhost") + ":1701";
- Connection conn = DriverManager.getConnection(dbURL, "sa", "");
- Statement statement = conn.createStatement();
- statement.executeQuery("SHUTDOWN COMPACT");
-
- }
-
- public static void main(String[] args) throws Exception
- {
- DBSetup setup = new DBSetup(null);
- setup.setUp();
- Thread.sleep(120*1000);
- setup.tearDown();
- }
-
- class DBThread extends Thread
- {
- boolean started;
- File dbPath;
-
- DBThread(File dbPath)
- {
- super("hypersonic");
- this.dbPath = dbPath;
- }
-
- boolean isStarted()
- {
- return started;
- }
-
- public void run()
- {
- try
- {
- // Create startup arguments
- // BES 2007/09/25 We use -silent true to avoid
- // http://sourceforge.net/tracker/index.php?func=detail&aid=1673747&group_id=23316&atid=378131
- String[] args = {
- "-database",
- dbPath.toString(),
- "-port",
- String.valueOf(1701),
- "-silent",
- "true",
- "-trace",
- "false",
- "-no_system_exit",
- "true",
- };
- System.out.println("Starting hsqldb");
- // HACK Do this by reflection for now until we determine how
- // we want to handle this in EJB3
- Class clazz = Thread.currentThread().getContextClassLoader().loadClass("org.hsqldb.Server");
- Method main = clazz.getDeclaredMethod("main", new Class[] { String[].class });
- main.invoke(null, new Object[] { args });
-// org.hsqldb.Server.main(args);
- System.out.println("Done");
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- finally
- {
- started = true;
- }
- }
- }
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.common.unit;
+
+import java.sql.DriverManager;
+import java.sql.Connection;
+import java.sql.Statement;
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.Method;
+
+import junit.extensions.TestSetup;
+import junit.framework.Test;
+
+/** A TestSetup that starts hypersonic before the testcase with a tcp
+ * listening port at 1701.
+ *
+ * @author Scott.Stark at jboss.org
+ * @version $Revison:$
+ */
+public class DBSetup extends TestSetup
+{
+ public DBSetup(Test test)
+ {
+ super(test);
+ }
+
+ protected void setUp() throws Exception
+ {
+ File hypersoniDir = new File("output/hypersonic");
+ if (!hypersoniDir.exists())
+ {
+ hypersoniDir.mkdirs();
+ }
+
+ if (!hypersoniDir.isDirectory())
+ {
+ throw new IOException("Failed to create directory: " + hypersoniDir);
+ }
+
+ File dbPath = new File(hypersoniDir, "clusteredentity-db");
+
+ // Start DB in new thread, or else it will block us
+ DBThread serverThread = new DBThread(dbPath);
+ serverThread.start();
+
+ int elapsed = 0;
+ while (!serverThread.isStarted() && elapsed < 15000)
+ {
+ try
+ {
+ Thread.sleep(100);
+ elapsed += 100;
+ }
+ catch (InterruptedException ie)
+ {
+ System.out.println("Interrupted while waiting for Hypersonic");
+ }
+ }
+
+ if (!serverThread.isStarted())
+ System.out.println("Hypersonic failed to start in a timely fashion");
+ }
+
+ protected void tearDown() throws Exception
+ {
+ Class.forName("org.hsqldb.jdbcDriver");
+ String dbURL = "jdbc:hsqldb:hsql://" + System.getProperty("jbosstest.server.host", "localhost") + ":1701";
+ Connection conn = DriverManager.getConnection(dbURL, "sa", "");
+ Statement statement = conn.createStatement();
+ statement.executeQuery("SHUTDOWN COMPACT");
+
+ }
+
+ public static void main(String[] args) throws Exception
+ {
+ DBSetup setup = new DBSetup(null);
+ setup.setUp();
+ Thread.sleep(120*1000);
+ setup.tearDown();
+ }
+
+ class DBThread extends Thread
+ {
+ boolean started;
+ File dbPath;
+
+ DBThread(File dbPath)
+ {
+ super("hypersonic");
+ this.dbPath = dbPath;
+ }
+
+ boolean isStarted()
+ {
+ return started;
+ }
+
+ public void run()
+ {
+ try
+ {
+ // Create startup arguments
+ // BES 2007/09/25 We use -silent true to avoid
+ // http://sourceforge.net/tracker/index.php?func=detail&aid=1673747&group_id=23316&atid=378131
+ String[] args = {
+ "-database",
+ dbPath.toString(),
+ "-port",
+ String.valueOf(1701),
+ "-silent",
+ "true",
+ "-trace",
+ "false",
+ "-no_system_exit",
+ "true",
+ };
+ System.out.println("Starting hsqldb");
+ // HACK Do this by reflection for now until we determine how
+ // we want to handle this in EJB3
+ Class clazz = Thread.currentThread().getContextClassLoader().loadClass("org.hsqldb.Server");
+ Method main = clazz.getDeclaredMethod("main", new Class[] { String[].class });
+ main.invoke(null, new Object[] { args });
+// org.hsqldb.Server.main(args);
+ System.out.println("Done");
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ finally
+ {
+ started = true;
+ }
+ }
+ }
+}
Property changes on: trunk/ejb3/src/test/org/jboss/ejb3/test/common/unit/DBSetup.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/iiop/HomedStatelessBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/iiop/HomedStatelessBean.java 2008-11-14 14:58:15 UTC (rev 81052)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/iiop/HomedStatelessBean.java 2008-11-14 14:59:40 UTC (rev 81053)
@@ -1,58 +1,58 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ejb3.test.iiop;
-
-import javax.annotation.Resource;
-import javax.annotation.security.RolesAllowed;
-import javax.ejb.Remote;
-import javax.ejb.RemoteHome;
-import javax.ejb.SessionContext;
-import javax.ejb.Stateless;
-
-import org.jboss.ejb3.annotation.RemoteBinding;
-import org.jboss.ejb3.annotation.defaults.RemoteBindingDefaults;
-
-/**
- * Comment
- *
- * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @version $Revision: $
- */
- at Stateless
- at Remote(MySession.class)
- at RemoteHome(HomedStatelessHome.class)
- at RemoteBinding(factory=RemoteBindingDefaults.PROXY_FACTORY_IMPLEMENTATION_IOR)
-public class HomedStatelessBean
-{
- @Resource SessionContext ctx;
-
- @RolesAllowed({"user"})
- public String getWhoAmI()
- {
- return ctx.getCallerPrincipal().getName();
- }
-
- public String sayHelloTo(String name)
- {
- return "Hi " + name;
- }
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.iiop;
+
+import javax.annotation.Resource;
+import javax.annotation.security.RolesAllowed;
+import javax.ejb.Remote;
+import javax.ejb.RemoteHome;
+import javax.ejb.SessionContext;
+import javax.ejb.Stateless;
+
+import org.jboss.ejb3.annotation.RemoteBinding;
+import org.jboss.ejb3.annotation.defaults.RemoteBindingDefaults;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+ at Stateless
+ at Remote(MySession.class)
+ at RemoteHome(HomedStatelessHome.class)
+ at RemoteBinding(factory=RemoteBindingDefaults.PROXY_FACTORY_IMPLEMENTATION_IOR)
+public class HomedStatelessBean
+{
+ @Resource SessionContext ctx;
+
+ @RolesAllowed({"user"})
+ public String getWhoAmI()
+ {
+ return ctx.getCallerPrincipal().getName();
+ }
+
+ public String sayHelloTo(String name)
+ {
+ return "Hi " + name;
+ }
+}
Property changes on: trunk/ejb3/src/test/org/jboss/ejb3/test/iiop/HomedStatelessBean.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/iiop/HomedStatelessHome.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/iiop/HomedStatelessHome.java 2008-11-14 14:58:15 UTC (rev 81052)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/iiop/HomedStatelessHome.java 2008-11-14 14:59:40 UTC (rev 81053)
@@ -1,38 +1,38 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ejb3.test.iiop;
-
-import java.rmi.RemoteException;
-
-import javax.ejb.CreateException;
-import javax.ejb.EJBHome;
-
-/**
- * Comment
- *
- * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @version $Revision: $
- */
-public interface HomedStatelessHome extends EJBHome
-{
- MySession create() throws CreateException, RemoteException;
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.iiop;
+
+import java.rmi.RemoteException;
+
+import javax.ejb.CreateException;
+import javax.ejb.EJBHome;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public interface HomedStatelessHome extends EJBHome
+{
+ MySession create() throws CreateException, RemoteException;
+}
Property changes on: trunk/ejb3/src/test/org/jboss/ejb3/test/iiop/HomedStatelessHome.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/ejb3/src/test/org/jboss/ejb3/test/iiop/MyServiceBean.java
===================================================================
--- trunk/ejb3/src/test/org/jboss/ejb3/test/iiop/MyServiceBean.java 2008-11-14 14:58:15 UTC (rev 81052)
+++ trunk/ejb3/src/test/org/jboss/ejb3/test/iiop/MyServiceBean.java 2008-11-14 14:59:40 UTC (rev 81053)
@@ -1,61 +1,61 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ejb3.test.iiop;
-
-import javax.ejb.Remote;
-
-import org.jboss.ejb3.annotation.RemoteBinding;
-import org.jboss.ejb3.annotation.Service;
-import org.jboss.ejb3.annotation.defaults.RemoteBindingDefaults;
-import org.jboss.logging.Logger;
-
-/**
- * Comment
- *
- * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @version $Revision: $
- */
- at Service
- at Remote(MyStateful.class)
- at RemoteBinding(factory=RemoteBindingDefaults.PROXY_FACTORY_IMPLEMENTATION_IOR)
-public class MyServiceBean
-{
- @SuppressWarnings("unused")
- private static final Logger log = Logger.getLogger(MyServiceBean.class);
-
- private String name;
-
- public String getName()
- {
- return name;
- }
-
- public String sayHello()
- {
- return "Hello " + name;
- }
-
- public void setName(String name)
- {
- this.name = name;
- }
-}
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.ejb3.test.iiop;
+
+import javax.ejb.Remote;
+
+import org.jboss.ejb3.annotation.RemoteBinding;
+import org.jboss.ejb3.annotation.Service;
+import org.jboss.ejb3.annotation.defaults.RemoteBindingDefaults;
+import org.jboss.logging.Logger;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+ at Service
+ at Remote(MyStateful.class)
+ at RemoteBinding(factory=RemoteBindingDefaults.PROXY_FACTORY_IMPLEMENTATION_IOR)
+public class MyServiceBean
+{
+ @SuppressWarnings("unused")
+ private static final Logger log = Logger.getLogger(MyServiceBean.class);
+
+ private String name;
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public String sayHello()
+ {
+ return "Hello " + name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+}
Property changes on: trunk/ejb3/src/test/org/jboss/ejb3/test/iiop/MyServiceBean.java
___________________________________________________________________
Name: svn:eol-style
+ native
More information about the jboss-cvs-commits
mailing list