[jboss-cvs] JBossAS SVN: r70238 - in trunk/ejb3: src/main/org/jboss and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Feb 28 23:25:46 EST 2008
Author: scott.stark at jboss.org
Date: 2008-02-28 23:25:34 -0500 (Thu, 28 Feb 2008)
New Revision: 70238
Removed:
trunk/ejb3/src/main/org/jboss/ejb3/AllowedOperationsInterceptor.java
trunk/ejb3/src/main/org/jboss/ejb3/AnnotationRepositoryToMetaData.java
trunk/ejb3/src/main/org/jboss/ejb3/BaseContext.java
trunk/ejb3/src/main/org/jboss/ejb3/BeanContext.java
trunk/ejb3/src/main/org/jboss/ejb3/BeanContextLifecycleCallback.java
trunk/ejb3/src/main/org/jboss/ejb3/ClassFileFilter.java
trunk/ejb3/src/main/org/jboss/ejb3/ClientDescriptorFileFilter.java
trunk/ejb3/src/main/org/jboss/ejb3/ClientKernelAbstraction.java
trunk/ejb3/src/main/org/jboss/ejb3/Container.java
trunk/ejb3/src/main/org/jboss/ejb3/ContainerDelegateWrapper.java
trunk/ejb3/src/main/org/jboss/ejb3/ContainerDelegateWrapperMBean.java
trunk/ejb3/src/main/org/jboss/ejb3/ContainerPlugin.java
trunk/ejb3/src/main/org/jboss/ejb3/DefaultEjbEncFactory.java
trunk/ejb3/src/main/org/jboss/ejb3/DefaultPersistenceProperties.java
trunk/ejb3/src/main/org/jboss/ejb3/DependencyPolicy.java
trunk/ejb3/src/main/org/jboss/ejb3/DeploymentScope.java
trunk/ejb3/src/main/org/jboss/ejb3/DeploymentUnit.java
trunk/ejb3/src/main/org/jboss/ejb3/EJB3Deployer.java
trunk/ejb3/src/main/org/jboss/ejb3/EJB3DeployerMBean.java
trunk/ejb3/src/main/org/jboss/ejb3/EJB3Util.java
trunk/ejb3/src/main/org/jboss/ejb3/EJBContainer.java
trunk/ejb3/src/main/org/jboss/ejb3/EJBContainerInvocation.java
trunk/ejb3/src/main/org/jboss/ejb3/EJBContainerInvocationWrapper.java
trunk/ejb3/src/main/org/jboss/ejb3/EJBContextFactory.java
trunk/ejb3/src/main/org/jboss/ejb3/EJBContextImpl.java
trunk/ejb3/src/main/org/jboss/ejb3/EJBInvocation.java
trunk/ejb3/src/main/org/jboss/ejb3/EJBMetaDataLoader.java
trunk/ejb3/src/main/org/jboss/ejb3/EJBProxyFactory.java
trunk/ejb3/src/main/org/jboss/ejb3/ENCPropagationInterceptor.java
trunk/ejb3/src/main/org/jboss/ejb3/Ejb3AnnotationHandler.java
trunk/ejb3/src/main/org/jboss/ejb3/Ejb3Deployment.java
trunk/ejb3/src/main/org/jboss/ejb3/Ejb3DescriptorHandler.java
trunk/ejb3/src/main/org/jboss/ejb3/Ejb3Handler.java
trunk/ejb3/src/main/org/jboss/ejb3/Ejb3HandlerFactory.java
trunk/ejb3/src/main/org/jboss/ejb3/Ejb3JmxDeployment.java
trunk/ejb3/src/main/org/jboss/ejb3/Ejb3Module.java
trunk/ejb3/src/main/org/jboss/ejb3/Ejb3ModuleMBean.java
trunk/ejb3/src/main/org/jboss/ejb3/Ejb3Registry.java
trunk/ejb3/src/main/org/jboss/ejb3/EjbEncFactory.java
trunk/ejb3/src/main/org/jboss/ejb3/FileSuffixFilter.java
trunk/ejb3/src/main/org/jboss/ejb3/InfinitePool.java
trunk/ejb3/src/main/org/jboss/ejb3/InitialContextFactory.java
trunk/ejb3/src/main/org/jboss/ejb3/JBossProxy.java
trunk/ejb3/src/main/org/jboss/ejb3/JarsIgnoredForScanning.java
trunk/ejb3/src/main/org/jboss/ejb3/JarsIgnoredForScanningMBean.java
trunk/ejb3/src/main/org/jboss/ejb3/JmxClientKernelAbstraction.java
trunk/ejb3/src/main/org/jboss/ejb3/JmxDependencyPolicy.java
trunk/ejb3/src/main/org/jboss/ejb3/JmxDeploymentScopeImpl.java
trunk/ejb3/src/main/org/jboss/ejb3/JmxDeploymentUnit.java
trunk/ejb3/src/main/org/jboss/ejb3/JmxKernelAbstraction.java
trunk/ejb3/src/main/org/jboss/ejb3/JndiProxyFactory.java
trunk/ejb3/src/main/org/jboss/ejb3/JndiUtil.java
trunk/ejb3/src/main/org/jboss/ejb3/KernelAbstraction.java
trunk/ejb3/src/main/org/jboss/ejb3/KernelAbstractionFactory.java
trunk/ejb3/src/main/org/jboss/ejb3/LocalProxy.java
trunk/ejb3/src/main/org/jboss/ejb3/MCClientKernelAbstraction.java
trunk/ejb3/src/main/org/jboss/ejb3/MCDependencyPolicy.java
trunk/ejb3/src/main/org/jboss/ejb3/MCKernelAbstraction.java
trunk/ejb3/src/main/org/jboss/ejb3/NonSerializableFactory.java
trunk/ejb3/src/main/org/jboss/ejb3/PersistenceUnitRegistry.java
trunk/ejb3/src/main/org/jboss/ejb3/ProxyFactory.java
trunk/ejb3/src/main/org/jboss/ejb3/ProxyFactoryHelper.java
trunk/ejb3/src/main/org/jboss/ejb3/ProxyUtils.java
trunk/ejb3/src/main/org/jboss/ejb3/SecurityActions.java
trunk/ejb3/src/main/org/jboss/ejb3/ServiceDelegateWrapper.java
trunk/ejb3/src/main/org/jboss/ejb3/ServiceDelegateWrapperMBean.java
trunk/ejb3/src/main/org/jboss/ejb3/ThreadLocalStack.java
trunk/ejb3/src/main/org/jboss/ejb3/annotation/
trunk/ejb3/src/main/org/jboss/ejb3/aop/
trunk/ejb3/src/main/org/jboss/ejb3/asynchronous/
trunk/ejb3/src/main/org/jboss/ejb3/cache/
trunk/ejb3/src/main/org/jboss/ejb3/client/
trunk/ejb3/src/main/org/jboss/ejb3/clientmodule/
trunk/ejb3/src/main/org/jboss/ejb3/cluster/
trunk/ejb3/src/main/org/jboss/ejb3/dd/
trunk/ejb3/src/main/org/jboss/ejb3/dependency/
trunk/ejb3/src/main/org/jboss/ejb3/embedded/
trunk/ejb3/src/main/org/jboss/ejb3/enc/
trunk/ejb3/src/main/org/jboss/ejb3/entity/
trunk/ejb3/src/main/org/jboss/ejb3/iiop/
trunk/ejb3/src/main/org/jboss/ejb3/injection/
trunk/ejb3/src/main/org/jboss/ejb3/interceptor/
trunk/ejb3/src/main/org/jboss/ejb3/javaee/
trunk/ejb3/src/main/org/jboss/ejb3/jms/
trunk/ejb3/src/main/org/jboss/ejb3/kernel/
trunk/ejb3/src/main/org/jboss/ejb3/lang/
trunk/ejb3/src/main/org/jboss/ejb3/mdb/
trunk/ejb3/src/main/org/jboss/ejb3/metadata/
trunk/ejb3/src/main/org/jboss/ejb3/naming/
trunk/ejb3/src/main/org/jboss/ejb3/pool/
trunk/ejb3/src/main/org/jboss/ejb3/protocol/
trunk/ejb3/src/main/org/jboss/ejb3/proxy/
trunk/ejb3/src/main/org/jboss/ejb3/remoting/
trunk/ejb3/src/main/org/jboss/ejb3/security/
trunk/ejb3/src/main/org/jboss/ejb3/service/
trunk/ejb3/src/main/org/jboss/ejb3/session/
trunk/ejb3/src/main/org/jboss/ejb3/stateful/
trunk/ejb3/src/main/org/jboss/ejb3/stateless/
trunk/ejb3/src/main/org/jboss/ejb3/statistics/
trunk/ejb3/src/main/org/jboss/ejb3/timerservice/
trunk/ejb3/src/main/org/jboss/ejb3/tx/
trunk/ejb3/src/main/org/jboss/ejb3/util/
trunk/ejb3/src/main/org/jboss/injection/
trunk/ejb3/src/main/org/jboss/lang/
trunk/ejb3/src/main/org/jboss/persistence/
Modified:
trunk/ejb3/build.xml
trunk/ejb3/src/main/org/jboss/ejb3/deployers/EJBRegistrationDeployer.java
trunk/ejb3/src/main/org/jboss/ejb3/deployers/Ejb3Deployer.java
trunk/ejb3/src/main/org/jboss/ejb3/deployers/Ejb3JBoss5Deployment.java
Log:
Remove all code other than deployers and add ejb3-core lib to classpath
Modified: trunk/ejb3/build.xml
===================================================================
--- trunk/ejb3/build.xml 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/build.xml 2008-02-29 04:25:34 UTC (rev 70238)
@@ -115,6 +115,7 @@
<path refid="cglib.classpath"/>
<path refid="jboss.integration.classpath"/>
<path refid="jboss.jboss.ejb3.cache.classpath"/>
+ <path refid="jboss.jboss.ejb3.core.classpath"/>
<path refid="jboss.jboss.ejb3.ext.api.classpath" />
<path refid="jboss.jboss.ejb3.ext.api.impl.classpath" />
<path refid="jboss.jboss.ejb3.interceptors.classpath" />
@@ -254,7 +255,7 @@
failonerror="${javac.fail.onerror}">
<src path="${source.java}"/>
<classpath refid="javac.classpath"/>
- <include name="${javac.includes}"/>
+ <include name="org/jboss/ejb3/deployers/**"/>
<exclude name="${javac.excludes}"/>
</javac>
</target>
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/AllowedOperationsInterceptor.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/AllowedOperationsInterceptor.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/AllowedOperationsInterceptor.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -1,55 +0,0 @@
-/*
- * 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;
-
-import org.jboss.aop.advice.Interceptor;
-import org.jboss.aop.joinpoint.Invocation;
-import org.jboss.ejb.AllowedOperationsAssociation;
-import org.jboss.ejb.AllowedOperationsFlags;
-
-/**
- * @author <a href="mailto:kabir.khan at jboss.org">Kabir Khan</a>
- * @version $Revision$
- */
-public class AllowedOperationsInterceptor implements Interceptor
-{
-
- public String getName()
- {
- return "AllowedOperationsInterceptor";
- }
-
- public Object invoke(Invocation invocation) throws Throwable
- {
- try
- {
- AllowedOperationsAssociation.pushInMethodFlag(AllowedOperationsFlags.IN_EJB_TIMEOUT);
- return invocation.invokeNext();
- }
- finally
- {
- AllowedOperationsAssociation.popInMethodFlag();
- }
- }
-
-}
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/AnnotationRepositoryToMetaData.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/AnnotationRepositoryToMetaData.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/AnnotationRepositoryToMetaData.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -1,332 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., 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;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Member;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Map;
-
-import javassist.CtClass;
-import javassist.CtConstructor;
-import javassist.CtField;
-import javassist.CtMember;
-import javassist.CtMethod;
-import javassist.NotFoundException;
-
-import org.jboss.annotation.factory.AnnotationCreator;
-import org.jboss.aop.annotation.AnnotationRepository;
-import org.jboss.logging.Logger;
-import org.jboss.metadata.plugins.context.AbstractMetaDataContext;
-import org.jboss.metadata.plugins.loader.memory.MemoryMetaDataLoader;
-import org.jboss.metadata.plugins.loader.reflection.ClassMetaDataRetrievalFactory;
-import org.jboss.metadata.spi.MetaData;
-import org.jboss.metadata.spi.context.MetaDataContext;
-import org.jboss.metadata.spi.retrieval.MetaDataRetrieval;
-import org.jboss.metadata.spi.retrieval.MetaDataRetrievalToMetaDataBridge;
-import org.jboss.metadata.spi.scope.CommonLevels;
-import org.jboss.metadata.spi.scope.Scope;
-import org.jboss.metadata.spi.scope.ScopeKey;
-import org.jboss.metadata.spi.signature.ConstructorSignature;
-import org.jboss.metadata.spi.signature.FieldSignature;
-import org.jboss.metadata.spi.signature.MethodSignature;
-import org.jboss.metadata.spi.signature.Signature;
-
-/**
- * AnnotationRepositoryToMetaData.
- *
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 1.1 $
- */
-public class AnnotationRepositoryToMetaData extends AnnotationRepository
-{
- /** The log */
- private static final Logger log = Logger.getLogger(AnnotationRepositoryToMetaData.class);
-
- /** The metadata */
- private MetaData metaData;
-
- /** The mutable metadata */
- private MemoryMetaDataLoader mutableMetaData;
-
- /** The classloader */
- private ClassLoader classLoader;
-
- public AnnotationRepositoryToMetaData(EJBContainer container)
- {
- if (container == null)
- throw new IllegalArgumentException("Null container");
-
- Class<?> beanClass = container.getClazz();
- if (beanClass == null)
- throw new IllegalArgumentException("Null bean class");
- String name = container.getObjectName().getCanonicalName();
- if (name == null)
- throw new IllegalArgumentException("Null name");
- this.classLoader = container.getClassloader();
- if (classLoader == null)
- throw new IllegalArgumentException("Null class");
-
- MetaDataRetrieval classMetaData = ClassMetaDataRetrievalFactory.INSTANCE.getMetaDataRetrieval(new Scope(CommonLevels.CLASS, beanClass));
- ScopeKey instanceScope = new ScopeKey(CommonLevels.INSTANCE, name);
- mutableMetaData = new MemoryMetaDataLoader(instanceScope);
- MetaDataRetrieval dynamicXml = new EJBMetaDataLoader(instanceScope, container);
-
- MetaDataContext classContext = new AbstractMetaDataContext(classMetaData);
- MetaDataRetrieval[] instance = { dynamicXml, mutableMetaData };
- MetaDataContext instanceContext = new AbstractMetaDataContext(classContext, Arrays.asList(instance));
- metaData = new MetaDataRetrievalToMetaDataBridge(instanceContext);
- }
-
- /**
- * Create a signature from javassist member
- *
- * @param member the member
- * @return the signature
- */
- protected static Signature getSignature(CtMember member)
- {
- if (member == null)
- throw new IllegalArgumentException("Null member");
-
- try
- {
- if (member instanceof CtMethod)
- {
- CtMethod method = (CtMethod) member;
- CtClass[] parameterTypes = method.getParameterTypes();
- String[] params = Signature.NO_PARAMETERS;
- if (parameterTypes.length > 0)
- {
- params = new String[parameterTypes.length];
- for (int i = 0; i < params.length; ++i)
- params[i] = parameterTypes[i].getName();
- }
- return new MethodSignature(method.getName(), params);
- }
- if (member instanceof CtConstructor)
- {
- CtConstructor constructor = (CtConstructor) member;
- CtClass[] parameterTypes = constructor.getParameterTypes();
- String[] params = Signature.NO_PARAMETERS;
- if (parameterTypes.length > 0)
- {
- params = new String[parameterTypes.length];
- for (int i = 0; i < params.length; ++i)
- params[i] = parameterTypes[i].getName();
- }
- return new ConstructorSignature(params);
- }
- if (member instanceof CtField)
- {
- return new FieldSignature(member.getName());
- }
- throw new IllegalArgumentException("Unknown member type: " + member);
- }
- catch (NotFoundException e)
- {
- throw new RuntimeException("Error determing signature: " + member, e);
- }
- }
-
- /**
- * Initialise an annotation
- *
- * @param annotation the annotation or a string
- * @return the annotation
- */
- protected Annotation initAnnotation(Object annotation)
- {
- if (annotation == null)
- throw new IllegalArgumentException("Null annotation");
-
- if (annotation instanceof Annotation)
- return (Annotation) annotation;
-
- if (annotation instanceof String == false)
- throw new IllegalArgumentException("Not an annotation: " + annotation);
-
- try
- {
- return (Annotation) AnnotationCreator.createAnnotation((String) annotation, classLoader);
- }
- catch (RuntimeException e)
- {
- throw e;
- }
- catch (Exception e)
- {
- throw new RuntimeException("Error creating annotation: " + annotation, e);
- }
- }
-
- protected Class loadClass(String className)
- {
- try
- {
- return classLoader.loadClass(className);
- }
- catch (ClassNotFoundException e)
- {
- throw new RuntimeException("Unable to load class for annotation " + className + " using class loader " + classLoader);
- }
- }
-
- public void addAnnotation(CtMember m, String annotation)
- {
- mutableMetaData.addAnnotation(getSignature(m), initAnnotation(annotation));
- }
-
- public void addAnnotation(Member m, Class annotation, Object value)
- {
- mutableMetaData.addAnnotation(m, initAnnotation(value));
- }
-
- public void addAnnotation(Member m, String annotation, Object value)
- {
- mutableMetaData.addAnnotation(m, initAnnotation(value));
- }
-
- public void addClassAnnotation(Class annotation, Object value)
- {
- mutableMetaData.addAnnotation(initAnnotation(value));
- }
-
- public void addClassAnnotation(String annotation, String value)
- {
- mutableMetaData.addAnnotation(initAnnotation(value));
- }
-
- public void disableAnnotation(Member m, String annotation)
- {
- log.warn("Not implemented: disableAnnotation(" + m + ", " + annotation + ")");
- }
-
- public void disableAnnotation(String annotation)
- {
- log.warn("Not implemented: disableAnnotation(" + annotation + ")");
- }
-
- public void enableAnnotation(String annotation)
- {
- log.warn("Not implemented: enableAnnotation(" + annotation + ")");
- }
-
- public Map getAnnotations()
- {
- log.warn("Not implemented: getAnnotations()");
- return Collections.emptyMap();
- }
-
- public Map getClassAnnotations()
- {
- log.warn("Not implemented: getClassAnnotations()");
- return Collections.emptyMap();
- }
-
- public boolean hasAnnotation(CtMember m, String annotation)
- {
- if (annotation == null)
- throw new IllegalArgumentException("Null annotation");
- MetaData component = metaData.getComponentMetaData(getSignature(m));
- if (component == null)
- return false;
- return component.isMetaDataPresent(annotation);
- }
-
- public boolean hasAnnotation(Member m, Class annotation)
- {
- if (annotation == null)
- throw new IllegalArgumentException("Null annotation");
- MetaData component = metaData.getComponentMetaData(Signature.getSignature(m));
- if (component == null)
- return false;
- return component.isAnnotationPresent(annotation);
- }
-
- public boolean hasAnnotation(Member m, String annotation)
- {
- if (annotation == null)
- throw new IllegalArgumentException("Null annotation");
- MetaData component = metaData.getComponentMetaData(Signature.getSignature(m));
- if (component == null)
- return false;
- return component.isAnnotationPresent(loadClass(annotation));
- }
-
- public boolean hasClassAnnotation(Class annotation)
- {
- if (annotation == null)
- throw new IllegalArgumentException("Null annotation");
- return metaData.isAnnotationPresent(annotation);
- }
-
- public boolean hasClassAnnotation(String annotation)
- {
- if (annotation == null)
- throw new IllegalArgumentException("Null annotation");
- return metaData.isAnnotationPresent(loadClass(annotation));
- }
-
- public boolean isDisabled(Class annotation)
- {
- return false;
- }
-
- public boolean isDisabled(Member m, Class annotation)
- {
- return false;
- }
-
- public boolean isDisabled(Member m, String annotation)
- {
- return false;
- }
-
- public boolean isDisabled(String annotation)
- {
- return false;
- }
-
- public Object resolveClassAnnotation(Class annotation)
- {
- if (annotation == null)
- throw new IllegalArgumentException("Null annotation");
- return metaData.getAnnotation(annotation);
- }
-
- public Object resolveAnnotation(Member m, Class annotation)
- {
- if (annotation == null)
- throw new IllegalArgumentException("Null annotation");
- MetaData component = metaData.getComponentMetaData(Signature.getSignature(m));
- if (component == null)
- return null;
- return component.getAnnotation(annotation);
- }
-
- protected Object resolveAnnotation(Member m, String annotation)
- {
- return resolveAnnotation(m, loadClass(annotation));
- }
-}
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/BaseContext.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/BaseContext.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/BaseContext.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -1,135 +0,0 @@
-/*
- * 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;
-
-import java.util.HashMap;
-
-import org.jboss.aop.metadata.SimpleMetaData;
-import org.jboss.ejb3.interceptor.InterceptorInfo;
-import org.jboss.logging.Logger;
-import org.jboss.security.RealmMapping;
-
-/**
- * Comment
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- */
-public abstract class BaseContext<T extends Container> implements BeanContext<T>
-{
- protected static Logger log = Logger.getLogger(BaseContext.class);
- protected T container;
- protected Object bean;
- protected RealmMapping rm;
- protected SimpleMetaData metadata;
-
- protected HashMap<Class, Object> interceptorInstances;
-
- /**
- * Use with extreme caution, must not break getInstance post condition.
- *
- * @param container
- */
- protected BaseContext(T container)
- {
- assert container != null : "container is null";
-
- this.container = container;
- }
-
- protected BaseContext(T container, Object bean)
- {
- this(container);
-
- assert bean != null : "bean is null";
-
- this.bean = bean;
- }
-
- public Object getId()
- {
- return null;
- }
-
- /**
- * Returns the enterprise bean, never returns null.
- */
- public Object getInstance()
- {
- return bean;
- }
-
- public T getContainer()
- {
- return container;
- }
-
- public SimpleMetaData getMetaData()
- {
- if (metadata == null) metadata = new SimpleMetaData();
- return metadata;
- }
-
- @Deprecated
- public void initialiseInterceptorInstances()
- {
- /*
- HashSet<InterceptorInfo> interceptors = ((EJBContainer)container).getApplicableInterceptors();
- if (interceptors != null && interceptors.size() > 0 && interceptorInstances == null)
- {
- HashMap<Class,InterceptorInjector> interceptorInjectors = ((EJBContainer)container).getInterceptorInjectors();
- interceptorInstances = new HashMap<Class, Object>();
- for (InterceptorInfo info : interceptors)
- {
- try
- {
- Object instance = info.getClazz().newInstance();
- interceptorInstances.put(info.getClazz(), instance);
- interceptorInjectors.get(info.getClazz()).inject(this, instance);
- }
- catch (Exception e)
- {
- log.warn("Interceptors must have a public noargs constructor: " + info.getClazz().getName());
- }
- }
- }
- */
- log.warn("FIXME: don't call BaseContext.initialiseInterceptorInstances (EJBTHREE-1174)");
- }
-
- @Deprecated
- public Object[] getInterceptorInstances(InterceptorInfo[] interceptorInfos)
- {
- Object[] interceptors = new Object[interceptorInfos.length];
- int i = 0;
- for (InterceptorInfo info : interceptorInfos)
- {
- interceptors[i++] = interceptorInstances.get(info.getClazz());
- }
- return interceptors;
- }
-
- public Object getInvokedMethodKey()
- {
- return container;
- }
-}
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/BeanContext.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/BeanContext.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/BeanContext.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -1,53 +0,0 @@
-/*
- * 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;
-
-import javax.ejb.EJBContext;
-import org.jboss.aop.metadata.SimpleMetaData;
-import org.jboss.ejb3.interceptor.InterceptorInfo;
-
-/**
- * An instance of an enterprise bean linked to its container.
- *
- * Must have a constructor with container argument.
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- */
-public interface BeanContext<T extends Container>
-{
- Object getInstance();
-
- T getContainer();
-
- void initialiseInterceptorInstances();
-
- void remove();
-
- SimpleMetaData getMetaData();
-
- EJBContext getEJBContext();
-
- Object[] getInterceptorInstances(InterceptorInfo[] interceptorInfos);
-//
-// Object getInvokedMethodKey();
-}
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/BeanContextLifecycleCallback.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/BeanContextLifecycleCallback.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/BeanContextLifecycleCallback.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -1,46 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ejb3;
-
-/**
- * The EJBContextLifecycleCallback provides a way to modify the
- * EJBContext prior to use by the bean.
- *
- * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @version $Revision: $
- */
-public interface BeanContextLifecycleCallback<T extends BeanContext>
-{
- /**
- * The context has been attached to a bean instance.
- *
- * @param ctx
- */
- void attached(T ctx);
-
- /**
- * The context has been released from a bean instance.
- *
- * @param ctx
- */
- void released(T ctx);
-}
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/ClassFileFilter.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/ClassFileFilter.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/ClassFileFilter.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -1,48 +0,0 @@
-/*
- * 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;
-
-import org.jboss.virtual.VirtualFileFilter;
-import org.jboss.virtual.VirtualFile;
-
-import java.io.IOException;
-
-/**
- * Comment
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision: 44334 $
- */
-public class ClassFileFilter implements VirtualFileFilter
-{
- public boolean accepts(VirtualFile file)
- {
- try
- {
- return file.isLeaf() && file.getName().endsWith(".class");
- }
- catch (IOException e)
- {
- throw new RuntimeException(e);
- }
- }
-}
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/ClientDescriptorFileFilter.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/ClientDescriptorFileFilter.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/ClientDescriptorFileFilter.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -1,55 +0,0 @@
-/*
- * 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;
-
-import org.jboss.virtual.VirtualFileFilter;
-import org.jboss.virtual.VirtualFile;
-
-import java.io.IOException;
-
-/**
- * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
- */
-public class ClientDescriptorFileFilter implements VirtualFileFilter
-{
- public boolean accepts(VirtualFile file)
- {
- try
- {
- if (file.isLeaf())
- {
- if (file.getName().equals("application-client.xml") || file.getName().equals("jboss-client.xml"))
- {
- VirtualFile parent = file.getParent();
- if (parent != null && parent.getName().equals("META-INF"))
- return true;
- }
- }
-
- return false;
- }
- catch (IOException e)
- {
- throw new RuntimeException(e);
- }
- }
-}
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/ClientKernelAbstraction.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/ClientKernelAbstraction.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/ClientKernelAbstraction.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -1,36 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., 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;
-
-import javax.management.ObjectName;
-
-import javax.management.MBeanServer;
-
-/**
- * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
- */
-public interface ClientKernelAbstraction
-{
- Object invoke(ObjectName name, String operationName, Object[] params, String[] signature) throws Exception;
-
- public Object getAttribute(ObjectName name, String attribute) throws Exception;
-}
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/Container.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/Container.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/Container.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -1,116 +0,0 @@
-/*
- * 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;
-
-import java.util.Hashtable;
-import javax.ejb.TimerService;
-import javax.management.ObjectName;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-
-import org.jboss.ejb3.pool.Pool;
-import org.jboss.ejb3.statistics.InvocationStatistics;
-
-/**
- * Comment
- *
- * A container is optionally associated with a security manager. If it is
- * the container is running in secured mode, if not the container is running
- * in unchecked mode.
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- */
-public interface Container
-{
- String ENC_CTX_NAME = "java:comp";
-
- // TODO: Wolf: I don't like this, why the '?', and why the public method
- /**
- * Create a bean context for use in a pool.
- * @return a ready to use bean context
- */
- BeanContext<?> createBeanContext();
-
- Object getMBean();
-
- Class getBeanClass();
-
- String getEjbName();
-
- ObjectName getObjectName();
-
- TimerService getTimerService();
-
- /**
- * This method is called by EJBTimerServiceImpl to re-establish a persistent timer.
- */
- TimerService getTimerService(Object pKey);
-
- Pool getPool();
-
- void invokePostConstruct(BeanContext beanContext, Object[] params);
-
- void invokePreDestroy(BeanContext beanContext);
-
- void invokePostActivate(BeanContext beanContext);
-
- void invokePrePassivate(BeanContext beanContext);
-
- void invokeInit(Object bean, Class[] initTypes, Object[] initValues);
-
- BeanContext<?> peekContext();
-
- BeanContext<?> popContext();
-
- void pushContext(BeanContext<?> ctx);
-
- public void create() throws Exception;
-
- public void start() throws Exception;
-
- public void stop() throws Exception;
-
- public void destroy() throws Exception;
-
- InitialContext getInitialContext();
-
- Hashtable getInitialContextProperties();
-
- Context getEnc();
-
- void processMetadata();
-
- DependencyPolicy getDependencyPolicy();
-
- InvocationStatistics getInvokeStats();
-
- /**
- * Get the security manager associated with a container.
- *
- * @param type the type to cast to
- * @return the security manager or null if there is no manager associated
- */
- <T> T getSecurityManager(Class<T> type);
-
- boolean isClustered();
-}
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/ContainerDelegateWrapper.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/ContainerDelegateWrapper.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/ContainerDelegateWrapper.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -1,55 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ejb3;
-
-import javax.ejb.TimerService;
-
-import org.jboss.ejb3.statistics.InvocationStatistics;
-
-/**
- * Comment
- *
- * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @version $Revision: $
- */
-public class ContainerDelegateWrapper<CONTAINER_TYPE extends Container> implements ContainerDelegateWrapperMBean
-{
- protected CONTAINER_TYPE delegate;
-
- protected ContainerDelegateWrapper(CONTAINER_TYPE delegate)
- {
- assert delegate != null : "delegate is null";
-
- this.delegate = delegate;
- }
-
- // FIXME: this is here for EJBTHREE-630, re-establishing timers
- public TimerService getTimerService(Object pKey)
- {
- return delegate.getTimerService(pKey);
- }
-
- public InvocationStatistics getInvokeStats()
- {
- return delegate.getInvokeStats();
- }
-}
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/ContainerDelegateWrapperMBean.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/ContainerDelegateWrapperMBean.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/ContainerDelegateWrapperMBean.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -1,40 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ejb3;
-
-import javax.ejb.TimerService;
-
-import org.jboss.ejb3.statistics.InvocationStatistics;
-
-/**
- * Comment
- *
- * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @version $Revision: $
- */
-public interface ContainerDelegateWrapperMBean
-{
- InvocationStatistics getInvokeStats();
-
- // FIXME: this is here for EJBTHREE-630, re-establishing timers
- TimerService getTimerService(Object pKey);
-}
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/ContainerPlugin.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/ContainerPlugin.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/ContainerPlugin.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -1,47 +0,0 @@
-/*
- * 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;
-
-import org.jboss.system.Service;
-
-import org.jboss.ejb.AllowedOperationsFlags;
-
-/**
- * This is a superinterface for all Container plugins.
- *
- * <p>All plugin interfaces must extend this interface.
- *
- * @see Service
- * @author <a href="mailto:rickard.oberg at telkel.com">Rickard �berg</a>
- * @version $Revision$
- */
-public interface ContainerPlugin
- extends Service, AllowedOperationsFlags
-{
- /**
- * This callback is set by the container so that the plugin may access it
- *
- * @param con The container using this plugin. This may be null if the
- plugin is being disassociated from a container.
- */
- void setContainer(Container con);
-}
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/DefaultEjbEncFactory.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/DefaultEjbEncFactory.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/DefaultEjbEncFactory.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -1,72 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., 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;
-
-import org.jboss.naming.ENCFactory;
-
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-
-/**
- * comment
- *
- * @author <a href="bill at jboss.com">Bill Burke</a>
- * @version $Revision: 1.1 $
- */
-public class DefaultEjbEncFactory implements EjbEncFactory
-{
-
- public Context getEnc(EJBContainer container)
- {
- pushEnc(container);
- InitialContext ctx = container.getInitialContext();
- try
- {
- return (Context)ctx.lookup("java:comp");
- }
- catch (NamingException e)
- {
- throw new RuntimeException(e);
- }
- finally
- {
- popEnc(container);
- }
- }
-
- public void pushEnc(EJBContainer container)
- {
- ENCFactory.pushContextId(container.getObjectName());
- }
-
- public void popEnc(EJBContainer container)
- {
- ENCFactory.popContextId();
- }
-
-
- public void cleanupEnc(EJBContainer container)
- {
- ENCFactory.getEncById().remove(container.getObjectName());
- }
-}
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/DefaultPersistenceProperties.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/DefaultPersistenceProperties.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/DefaultPersistenceProperties.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -1,55 +0,0 @@
-/*
-* 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;
-
-import java.util.Properties;
-import java.net.URL;
-
-/**
- * Comment
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision: 55144 $
- */
-public class DefaultPersistenceProperties
-{
- private Properties properties;
-
- public DefaultPersistenceProperties() throws Exception
- {
- URL propsUrl = this.getClass().getClassLoader().getResource("META-INF/persistence.properties");
- properties = new Properties();
- properties.load(propsUrl.openStream());
- /* Current hack to establish the hibernate bytecode provider from the
- externalized persistence.properties
- */
- String bcprovider = properties.getProperty("hibernate.bytecode.provider", "javassist");
- System.setProperty("hibernate.bytecode.provider", bcprovider);
-
- }
-
- public Properties getProperties()
- {
- return properties;
- }
-
-}
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/DependencyPolicy.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/DependencyPolicy.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/DependencyPolicy.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -1,35 +0,0 @@
-/*
- * 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;
-
-/**
- * Abstraction for JMX Kernel vs. 5.0 MC to log dependencies
- * on persistence contexts, datasources, queues, topics, etc.
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- */
-public interface DependencyPolicy
-{
- public void addDependency(String dependency);
- public void addDatasource(String jndiName);
-}
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/DeploymentScope.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/DeploymentScope.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/DeploymentScope.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -1,49 +0,0 @@
-/*
- * 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;
-
-import java.util.Collection;
-
-import org.jboss.ejb3.javaee.JavaEEApplication;
-
-/**
- * Abstraction for accessing contents of an EAR
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- */
-public interface DeploymentScope extends JavaEEApplication
-{
- public Collection<Ejb3Deployment> getEjbDeployments();
- void register(Ejb3Deployment deployment);
- void unregister(Ejb3Deployment deployment);
-
- /**
- * Find a deployment based on its relative deployment name
- *
- * @param relativeName expects "../foo.jar" so expects the .. in front
- * @return
- */
- Ejb3Deployment findRelativeDeployment(String relativeName);
- String getShortName();
- String getBaseName();
-}
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/DeploymentUnit.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/DeploymentUnit.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/DeploymentUnit.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -1,72 +0,0 @@
-/*
- * 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;
-
-import java.net.URL;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Map;
-
-import org.jboss.ejb3.interceptor.InterceptorInfoRepository;
-import org.jboss.virtual.VirtualFile;
-import org.jboss.virtual.VirtualFileFilter;
-
-/**
- * Comment
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- */
-public interface DeploymentUnit
-{
- ClassLoader getClassLoader();
-
- ClassLoader getResourceLoader();
-
- String getShortName();
-
- List<VirtualFile> getResources(VirtualFileFilter filter);
-
- URL getUrl();
-
- URL getPersistenceXml();
-
- URL getEjbJarXml();
-
- URL getJbossXml();
-
- List<Class> getClasses();
-
- String getDefaultEntityManagerName();
-
- Map getDefaultPersistenceProperties();
-
- Hashtable getJndiProperties();
-
- InterceptorInfoRepository getInterceptorInfoRepository();
-
- URL getRelativeURL(String path);
-
- VirtualFile getMetaDataFile(String string);
-
- VirtualFile getRootFile();
-}
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/EJB3Deployer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/EJB3Deployer.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/EJB3Deployer.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -1,561 +0,0 @@
-/*
- * 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;
-
-import java.io.DataInputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.BufferedInputStream;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Properties;
-import javax.management.ObjectName;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import javax.naming.LinkRef;
-
-import org.jboss.deployment.DeploymentException;
-import org.jboss.deployment.DeploymentInfo;
-import org.jboss.deployment.SubDeployer;
-import org.jboss.deployment.SubDeployerSupport;
-import org.jboss.logging.Logger;
-import org.jboss.metadata.MetaData;
-import org.jboss.metadata.XmlFileLoader;
-import org.jboss.mx.loading.LoaderRepositoryFactory;
-import org.jboss.mx.util.MBeanProxyExt;
-import org.jboss.mx.util.ObjectNameConverter;
-import org.jboss.system.ServiceControllerMBean;
-import org.jboss.util.file.ArchiveBrowser;
-import org.jboss.util.file.ClassFileFilter;
-import org.w3c.dom.Element;
-
-import javassist.bytecode.AnnotationsAttribute;
-import javassist.bytecode.ClassFile;
-
-/**
- * Deployer for Aspects
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- */
- at Deprecated
-public class EJB3Deployer extends SubDeployerSupport
- implements SubDeployer, EJB3DeployerMBean
-{
- private final static Logger log = Logger.getLogger(EJB3Deployer.class);
-
- private ServiceControllerMBean serviceController;
-
- /** A map of current deployments */
- private HashMap deployments = new HashMap();
-
- /** Hold a proxy reference to myself, used when registering to MainDeployer */
- private SubDeployer thisProxy;
-
- private Properties DefaultProperties;
-
- private boolean deployEjb3ExtensionOnly;
-
- private HashSet ignoredJarsSet;
- private HashMap<DeploymentInfo, String> jmxNames = new HashMap();
-
- private boolean requireDeploymentDescriptor;
-
- /**
- * Default CTOR used to set default values to the Suffixes and RelativeOrder
- * attributes. Those are read at subdeployer registration time by the MainDeployer
- * to alter its SuffixOrder.
- */
- public EJB3Deployer()
- {
- setSuffixes(new String[]{".jar", ".ejb3", ".par"});
- setRelativeOrder(400); // before old EJB 2.1 deployer
- }
-
- public static boolean hasFile(DeploymentInfo di, String filePath)
- {
- String urlStr = di.url.getFile();
- try
- {
- URL dd = di.localCl.findResource(filePath);
- if (dd != null)
- {
-
- // If the DD url is not a subset of the urlStr then this is coming
- // from a jar referenced by the deployment jar manifest and the
- // this deployment jar it should not be treated as persistence
- if (di.localUrl != null)
- {
- urlStr = di.localUrl.toString();
- }
-
- String ddStr = dd.toString();
- if (ddStr.indexOf(urlStr) >= 0)
- {
- return true;
- }
- }
- }
- catch (Exception ignore)
- {
- }
- return false;
- }
-
- public static boolean hasPersistenceXml(DeploymentInfo di)
- {
- return hasFile(di, "META-INF/persistence.xml");
- }
-
- public static boolean has30EjbJarXml(DeploymentInfo di)
- {
- if (!hasFile(di, "META-INF/ejb-jar.xml")) return false;
- InputStream ddStream = di.localCl.getResourceAsStream("META-INF/ejb-jar.xml");
-
- return has30EjbJarXml(ddStream);
- }
-
- 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;
- }
-
- protected boolean hasJbossXml(DeploymentInfo di)
- {
- return hasFile(di, "META-INF/jboss.xml");
- }
-
- protected boolean hasOnlyJbossXml(DeploymentInfo di)
- {
- if (!hasFile(di, "META-INF/ejb-jar.xml")
- && this.hasJbossXml(di))
- {
- return true;
- }
- return false;
- }
-
- public boolean hasEjbAnnotation(DeploymentInfo di)
- {
- Iterator it = ArchiveBrowser.getBrowser(di.localUrl, new ClassFileFilter());
- try
- {
- while (it.hasNext())
- {
- InputStream stream = (InputStream) it.next();
- DataInputStream dstream = new DataInputStream(new BufferedInputStream(stream));
- ClassFile cf = null;
- try
- {
- cf = new ClassFile(dstream);
- AnnotationsAttribute visible = (AnnotationsAttribute) cf.getAttribute(AnnotationsAttribute.visibleTag);
- if (visible != null)
- {
- if (EJB3Util.isStateless(visible)) return true;
- if (EJB3Util.isStatefulSession(visible)) return true;
- if (EJB3Util.isMessageDriven(visible)) return true;
- if (EJB3Util.isConsumer(visible)) return true;
- if (EJB3Util.isService(visible)) return true;
- }
- }
- finally
- {
- dstream.close();
- stream.close();
- }
- }
- }
- catch (IOException e)
- {
- throw new RuntimeException(e);
- }
- return false;
- }
-
- /**
- * Returns true if this deployer can deploy the given DeploymentInfo.
- *
- * @return True if this deployer can deploy the given DeploymentInfo.
- * @jmx:managed-operation
- */
- public boolean accepts(DeploymentInfo di)
- {
-
- // Check for deployment descriptor if the deployer is
- // configured to require one for deployment
- // EJBTHREE-1040
- if (this.getRequireDeploymentDescriptor() && !(EJB3Deployer.has30EjbJarXml(di) || this.hasJbossXml(di)))
- {
- log.trace(EJB3Deployer.class.getSimpleName() + " skipping deployment of \"" + di.localUrl
- + "\"; deployer is configured to require DD and none was found.");
- return false;
- }
-
- String urlStr = di.url.getFile();
- if (urlStr.endsWith(".ejb3") || urlStr.endsWith(".ejb3/") || urlStr.endsWith(".par") || urlStr.endsWith(".par/"))
- {
- return true;
- }
-
- // To be accepted the deployment's root name must end in jar
- if (!urlStr.endsWith(".jar") && !urlStr.endsWith(".jar/"))
- {
- return false;
- }
-
- if (ignoredJarsSet.contains(di.shortName))
- {
- return false;
- }
-
- if (has30EjbJarXml(di)) return true;
-
- if (!deployEjb3ExtensionOnly)
- {
- if (hasPersistenceXml(di)) return true;
- if (hasOnlyJbossXml(di)) return true;
- if (hasEjbAnnotation(di)) return true;
- }
-
- return false;
- }
-
- public Properties getDefaultProperties()
- {
- return DefaultProperties;
- }
-
- public void setJarsIgnoredForScanning(JarsIgnoredForScanningMBean mbean)
- {
- ignoredJarsSet = mbean.getIgnoredJarsSet();
- }
-
- public boolean getDeployEjb3ExtensionOnly()
- {
- return deployEjb3ExtensionOnly;
- }
-
- public void setDeployEjb3ExtensionOnly(boolean deployEjb3ExtensionOnly)
- {
- this.deployEjb3ExtensionOnly = deployEjb3ExtensionOnly;
- }
-
-
- public boolean getRequireDeploymentDescriptor()
- {
- return requireDeploymentDescriptor;
- }
-
- public void setRequireDeploymentDescriptor(boolean requireDeploymentDescriptor)
- {
- this.requireDeploymentDescriptor = requireDeploymentDescriptor;
- }
-
- /**
- * Overriden to set the hibernate.bytecode.provider from the
- *
- * @throws Exception
- */
- protected void createService() throws Exception
- {
- URL propsUrl = this.getClass().getClassLoader().getResource("META-INF/persistence.properties");
- DefaultProperties = new Properties();
- DefaultProperties.load(propsUrl.openStream());
- log.debug("Default persistence.properties: " + DefaultProperties);
- /* Current hack to establish the hibernate bytecode provider from the
- externalized persistence.properties
- */
- String bcprovider = DefaultProperties.getProperty("hibernate.bytecode.provider", "javassist");
- System.setProperty("hibernate.bytecode.provider", bcprovider);
- super.createService();
- }
-
- /**
- * Get a reference to the ServiceController
- */
- protected void startService() throws Exception
- {
- serviceController = (ServiceControllerMBean)
- MBeanProxyExt.create(ServiceControllerMBean.class,
- ServiceControllerMBean.OBJECT_NAME, server);
-
- // make a proxy to myself, so that calls from the MainDeployer
- // can go through the MBeanServer, so interceptors can be added
- thisProxy = (SubDeployer)
- MBeanProxyExt.create(SubDeployer.class, super.getServiceName(), super.getServer());
-
- // register with the main deployer
- mainDeployer.addDeployer(thisProxy);
-
- // todo remove when we merge older model of ENC
- InitialContext iniCtx = InitialContextFactory.getInitialContext();
- initializeJavaComp(iniCtx);
- }
-
- public static void initializeJavaComp(InitialContext iniCtx)
- throws NamingException
- {
- Context ctx = (Context) iniCtx.lookup("java:");
- ctx.rebind("comp.ejb3", new LinkRef("java:comp"));
- }
-
- /**
- * Implements the template method in superclass. This method stops all the
- * applications in this server.
- */
- protected void stopService() throws Exception
- {
- for (Iterator modules = deployments.values().iterator();
- modules.hasNext();)
- {
- DeploymentInfo di = (DeploymentInfo) modules.next();
- stop(di);
- } // avoid concurrent modification exception
- for (Iterator modules = new ArrayList(deployments.values()).iterator();
- modules.hasNext();)
- {
- DeploymentInfo di = (DeploymentInfo) modules.next();
- destroy(di);
- }
- deployments.clear();
-
- // deregister with MainDeployer
- mainDeployer.removeDeployer(thisProxy);
-
- serviceController = null;
- }
-
- public void init(DeploymentInfo di) throws DeploymentException
- {
- try
- {
- if( di.url.getProtocol().equalsIgnoreCase("file") )
- {
- File file = new File(di.url.getFile());
-
- if( !file.isDirectory() )
- {
- // If not directory we watch the package
- di.watch = di.url;
- }
- else
- {
- // If directory we watch the xml files
- di.watch = new URL(di.url, "META-INF/ejb-jar.xml");
- }
- }
- else
- {
- // We watch the top only, no directory support
- di.watch = di.url;
- }
-
- XmlFileLoader xfl = new XmlFileLoader();
- InputStream in = di.localCl.getResourceAsStream("META-INF/jboss.xml");
- if( in != null )
- {
- try
- {
- Element jboss = xfl.getDocument(in, "META-INF/jboss.xml").getDocumentElement();
- // Check for a ejb level class loading config
- Element loader = MetaData.getOptionalChild(jboss, "loader-repository");
- if( loader != null )
- {
- LoaderRepositoryFactory.LoaderRepositoryConfig config =
- LoaderRepositoryFactory.parseRepositoryConfig(loader);
- di.setRepositoryInfo(config);
- }
-
- Element jmxNameElement = MetaData.getOptionalChild(jboss, "jmx-name");
- if (jmxNameElement != null)
- {
- jmxNames.put(di, jmxNameElement.getChildNodes().item(0).getNodeValue());
- }
- }
- finally
- {
- in.close();
- }
- }
- }
- catch (Exception e)
- {
- if (e instanceof DeploymentException)
- {
- throw (DeploymentException) e;
- }
- throw new DeploymentException( "failed to initialize", e );
- }
-
- // invoke super-class initialization
- super.init(di);
- }
-
- public synchronized void create(DeploymentInfo di) throws DeploymentException
- {
- log.debug("create, " + di.shortName);
-
- try
- {
- // initialize the annotations loader
- URL loaderURL = (di.localUrl != null ? di.localUrl : di.url);
- di.annotationsCl = new URLClassLoader(new URL[]{loaderURL}, di.ucl);
-
- Ejb3Module ejbModule = new Ejb3Module(di);
- String name = jmxNames.get(di);
- if (name == null)
- name = Ejb3Module.BASE_EJB3_JMX_NAME + ",module=" + di.shortName;
- // Build an escaped JMX name including deployment shortname
- ObjectName ejbModuleName = ObjectNameConverter.convert(name);
- // Check that the name is not registered
- if (server.isRegistered(ejbModuleName) == true)
- {
- log.debug("The EJBModule name: " + ejbModuleName
- + "is already registered, adding uid=" + System.identityHashCode(ejbModule));
- name = name + ",uid=" + System.identityHashCode(ejbModule);
- ejbModuleName = ObjectNameConverter.convert(name);
- }
- server.registerMBean(ejbModule, ejbModuleName);
- di.deployedObject = ejbModuleName;
- log.debug("Deploying: " + di.url);
- // Invoke the create life cycle method
- serviceController.create(di.deployedObject);
- }
- catch (Exception e)
- {
- throw new DeploymentException("Error during create of EjbModule: "
- + di.url, e);
- }
- super.create(di);
- }
-
- public synchronized void start(DeploymentInfo di)
- throws DeploymentException
- {
- try
- {
- // Start application
- log.debug("start application, deploymentInfo: " + di +
- ", short name: " + di.shortName +
- ", parent short name: " +
- (di.parent == null ? "null" : di.parent.shortName));
- serviceController.start(di.deployedObject);
- log.info("Deployed: " + di.url); // Register deployment. Use the application name in the hashtable
- // FIXME: this is obsolete!! (really?!)
- deployments.put(di.url, di);
- }
- catch (Exception e)
- {
- stop(di);
- destroy(di);
- throw new DeploymentException("Could not deploy " + di.url, e);
- }
- super.start(di);
- }
-
- public void stop(DeploymentInfo di)
- throws DeploymentException
- {
- log.debug("init, " + di.shortName);
- try
- {
- serviceController.stop(di.deployedObject);
- }
- catch (Exception e)
- {
- throw new DeploymentException("problem stopping ejb module: " +
- di.url, e);
- }
-
- super.stop(di);
- }
-
- public void destroy(DeploymentInfo di)
- throws DeploymentException
- {
- // FIXME: If the put() is obsolete above, this is obsolete, too
- deployments.remove(di.url);
- try
- {
- serviceController.destroy(di.deployedObject);
- serviceController.remove(di.deployedObject);
- }
- catch (Exception e)
- {
- throw new DeploymentException("problem destroying ejb module: " +
- di.url, e);
- }
-
- jmxNames.remove(di);
-
- super.destroy(di);
- }
-}
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/EJB3DeployerMBean.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/EJB3DeployerMBean.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/EJB3DeployerMBean.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -1,48 +0,0 @@
-/*
- * 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;
-
-import java.util.Properties;
-
-import javax.management.ObjectName;
-
-import org.jboss.deployment.SubDeployerMBean;
-import org.jboss.mx.util.ObjectNameFactory;
-
-/**
- * EJB3Deployer MBean interface.
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- */
-public interface EJB3DeployerMBean extends SubDeployerMBean
-{
- /** The default ObjectName */
- ObjectName OBJECT_NAME = ObjectNameFactory.create("jboss.ejb3:service=EJB3Deployer");
-
- /** Default properties */
- Properties getDefaultProperties();
-
- /** Jar files to ignore */
- void setJarsIgnoredForScanning(JarsIgnoredForScanningMBean mbean);
-
-}
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/EJB3Util.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/EJB3Util.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/EJB3Util.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -1,90 +0,0 @@
-/*
- * 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;
-
-import java.util.Hashtable;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import javassist.bytecode.AnnotationsAttribute;
-import javassist.bytecode.annotation.Annotation;
-import javassist.bytecode.annotation.StringMemberValue;
-
-/**
- * Comment
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- */
-public class EJB3Util
-{
- public static boolean isStateless(AnnotationsAttribute group)
- {
- return group.getAnnotation(javax.ejb.Stateless.class.getName()) != null;
- }
-
- public static boolean isStatefulSession(AnnotationsAttribute group)
- {
- return group.getAnnotation(javax.ejb.Stateful.class.getName()) != null;
- }
-
- public static boolean isEntity(AnnotationsAttribute group)
- {
- return group.getAnnotation(javax.persistence.Entity.class.getName()) != null;
- }
-
- public static boolean isMessageDriven(AnnotationsAttribute group)
- {
- return group.getAnnotation(javax.ejb.MessageDriven.class.getName()) != null;
- }
-
- public static boolean isService(AnnotationsAttribute group)
- {
- return group.getAnnotation(org.jboss.ejb3.annotation.Service.class.getName()) != null;
- }
-
- public static boolean isConsumer(AnnotationsAttribute group)
- {
- return group.getAnnotation(org.jboss.ejb3.annotation.Consumer.class.getName()) != null;
- }
-
- public static String getAspectDomain(AnnotationsAttribute visible, String defaultContainerName)
- {
- if (visible != null )
- {
- Annotation dinfo = visible.getAnnotation(org.jboss.ejb3.annotation.AspectDomain.class
- .getName());
- if (dinfo != null)
- {
- StringMemberValue dmv = (StringMemberValue) dinfo
- .getMemberValue("value");
- if (dmv != null)
- {
- return dmv.getValue();
- }
- }
- }
-
- return defaultContainerName;
- }
-}
-
-
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/EJBContainer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/EJBContainer.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/EJBContainer.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -1,1452 +0,0 @@
-/*
- * 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;
-
-import java.lang.annotation.Annotation;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Map;
-
-import javax.annotation.PostConstruct;
-import javax.annotation.PreDestroy;
-import javax.ejb.EJBContext;
-import javax.ejb.EJBException;
-import javax.ejb.Local;
-import javax.ejb.Remote;
-import javax.ejb.TimedObject;
-import javax.ejb.Timeout;
-import javax.ejb.Timer;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.LinkRef;
-import javax.naming.NameNotFoundException;
-import javax.naming.NamingException;
-import javax.naming.Reference;
-import javax.naming.StringRefAddr;
-
-import org.jboss.aop.Advisor;
-import org.jboss.aop.Domain;
-import org.jboss.aop.InstanceAdvisor;
-import org.jboss.aop.MethodInfo;
-import org.jboss.aop.advice.Interceptor;
-import org.jboss.aop.advice.PerVmAdvice;
-import org.jboss.aop.annotation.AnnotationRepository;
-import org.jboss.aop.util.MethodHashing;
-import org.jboss.ejb3.annotation.Clustered;
-import org.jboss.ejb3.annotation.SecurityDomain;
-import org.jboss.ejb3.annotation.defaults.PoolDefaults;
-import org.jboss.ejb3.aop.BeanContainer;
-import org.jboss.ejb3.aop.LifeCycleInvocation;
-import org.jboss.ejb3.deployers.Ejb3Deployer;
-import org.jboss.ejb3.deployers.JBoss5DependencyPolicy;
-import org.jboss.ejb3.entity.PersistenceUnitDeployment;
-import org.jboss.ejb3.interceptor.InterceptorInfoRepository;
-import org.jboss.ejb3.interceptor.InterceptorInjector;
-import org.jboss.ejb3.interceptors.aop.InterceptorsFactory;
-import org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor;
-import org.jboss.ejb3.interceptors.container.ManagedObjectAdvisor;
-import org.jboss.ejb3.interceptors.direct.DirectContainer;
-import org.jboss.ejb3.interceptors.direct.IndirectContainer;
-import org.jboss.ejb3.javaee.JavaEEComponent;
-import org.jboss.ejb3.javaee.JavaEEComponentHelper;
-import org.jboss.ejb3.javaee.JavaEEModule;
-import org.jboss.ejb3.pool.Pool;
-import org.jboss.ejb3.pool.PoolFactory;
-import org.jboss.ejb3.pool.PoolFactoryRegistry;
-import org.jboss.ejb3.security.JaccHelper;
-import org.jboss.ejb3.security.SecurityDomainManager;
-import org.jboss.ejb3.statistics.InvocationStatistics;
-import org.jboss.ejb3.tx.UserTransactionImpl;
-import org.jboss.iiop.CorbaORBService;
-import org.jboss.injection.DependsHandler;
-import org.jboss.injection.EJBHandler;
-import org.jboss.injection.EncInjector;
-import org.jboss.injection.InjectionContainer;
-import org.jboss.injection.InjectionHandler;
-import org.jboss.injection.InjectionUtil;
-import org.jboss.injection.Injector;
-import org.jboss.injection.JndiInjectHandler;
-import org.jboss.injection.PersistenceContextHandler;
-import org.jboss.injection.PersistenceUnitHandler;
-import org.jboss.injection.ResourceHandler;
-import org.jboss.injection.WebServiceRefHandler;
-import org.jboss.logging.Logger;
-import org.jboss.metadata.ejb.jboss.JBossAssemblyDescriptorMetaData;
-import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
-import org.jboss.metadata.ejb.jboss.JBossMetaData;
-import org.jboss.metadata.ejb.spec.InterceptorMetaData;
-import org.jboss.metadata.ejb.spec.InterceptorsMetaData;
-import org.jboss.metadata.ejb.spec.NamedMethodMetaData;
-import org.jboss.metadata.javaee.spec.Environment;
-import org.jboss.metadata.javaee.spec.ServiceReferenceMetaData;
-import org.jboss.naming.Util;
-import org.jboss.util.StringPropertyReplacer;
-import org.jboss.virtual.VirtualFile;
-
-/**
- * Comment
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- */
-public abstract class EJBContainer implements Container, IndirectContainer<EJBContainer, DirectContainer<EJBContainer>>, InjectionContainer, JavaEEComponent
-{
- private static final Logger log = Logger.getLogger(EJBContainer.class);
-
- private String name;
-
- private BeanContainer beanContainer;
-
- private DirectContainer<EJBContainer> directContainer;
-
- protected EjbEncFactory encFactory = new DefaultEjbEncFactory();
-
- protected Pool pool;
-
- protected String ejbName;
-
- protected ObjectName objectName;
-
- protected int defaultConstructorIndex;
-
- protected String beanClassName;
-
- private Class<?> beanClass;
-
- protected ClassLoader classloader;
-
- // for performance there is an array.
- protected List<Injector> injectors = new ArrayList<Injector>();
-
- protected Context enc;
-
-// protected LifecycleInterceptorHandler callbackHandler;
-
- protected Hashtable initialContextProperties;
-
- protected Map<String, EncInjector> encInjectors = new HashMap<String, EncInjector>();
-
- protected JBossEnterpriseBeanMetaData xml;
- protected JBossAssemblyDescriptorMetaData assembly;
-
- protected Map<String, Map<AccessibleObject, Injector>> encInjections = new HashMap<String, Map<AccessibleObject, Injector>>();
-
-// protected List<InterceptorInfo> classInterceptors = new ArrayList<InterceptorInfo>();
-//
-// protected LinkedHashSet<InterceptorInfo> applicableInterceptors;
-
- private HashMap<Class<?>, InterceptorInjector> interceptorInjectors = new HashMap<Class<?>, InterceptorInjector>();
-
- private Ejb3Deployment deployment;
-
- private DependencyPolicy dependencyPolicy;
-
- private String jaccContextId;
-
- protected HashMap invokedMethod = new HashMap();
-
- protected InvocationStatistics invokeStats = new InvocationStatistics();
-
- private String partitionName;
-
- private List<Class<?>> businessInterfaces;
-
- private ThreadLocalStack<BeanContext<?>> currentBean = new ThreadLocalStack<BeanContext<?>>();
-
- /**
- * @param name Advisor name
- * @param manager Domain to get interceptor bindings from
- * @param cl the EJB's classloader
- * @param beanClassName
- * @param ejbName
- * @param ctxProperties
- * @param interceptorRepository
- * @param deployment
- * @param beanMetaData the meta data for this bean or null
- */
-
- public EJBContainer(String name, Domain domain, ClassLoader cl,
- String beanClassName, String ejbName, Hashtable ctxProperties,
- Ejb3Deployment deployment, JBossEnterpriseBeanMetaData beanMetaData) throws ClassNotFoundException
- {
- assert name != null : "name is null";
- assert deployment != null : "deployment is null";
-
- this.name = name;
- this.deployment = deployment;
- this.beanClassName = beanClassName;
- this.classloader = cl;
- this.xml = beanMetaData;
-
- this.beanClass = classloader.loadClass(beanClassName);
-
- // We can't type cast the direct container, because we just loaded the beanClass
- // so assuming we have an object is a safe bet.
- this.beanContainer = new BeanContainer(this);
- // Because interceptors will query back the EJBContainer for annotations
- // we must have set beanContainer first and then do the advisor.
- beanContainer.initialize(ejbName, domain, beanClass, beanMetaData, cl);
-
- this.ejbName = ejbName;
- String on = createObjectName(ejbName);
- try
- {
- objectName = new ObjectName(on);
- }
- catch (MalformedObjectNameException e)
- {
- throw new RuntimeException("failed to create object name for: " + on, e);
- }
-
- //annotations = new AnnotationRepositoryToMetaData(this);
-
- initialContextProperties = ctxProperties;
- try
- {
- Util.createSubcontext(getEnc(), "env");
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- bindORB();
- bindEJBContext();
-
- this.dependencyPolicy = deployment.createDependencyPolicy(this);
- }
-
- private void bindEJBContext()
- {
- try
- {
- Reference ref = new Reference(EJBContext.class.getName(), EJBContextFactory.class.getName(), null);
- ref.add(new StringRefAddr("containerGuid", Ejb3Registry.guid(this)));
- ref.add(new StringRefAddr("containerClusterUid", Ejb3Registry.clusterUid(this)));
- ref.add(new StringRefAddr("isClustered", Boolean.toString(isClustered())));
- Util.rebind(getEnc(), "EJBContext", ref);
- }
- catch (NamingException e)
- {
- throw new RuntimeException(e);
- }
- }
-
- private void bindORB()
- {
- try
- {
- Util.rebind(getEnc(), "ORB", new LinkRef("java:/" + CorbaORBService.ORB_NAME));
- }
- catch(NamingException e)
- {
- throw new RuntimeException(e);
- }
- }
-
- public abstract BeanContext<?> createBeanContext();
-
- public String createObjectName(String ejbName)
- {
- return JavaEEComponentHelper.createObjectName(deployment, ejbName);
- }
-
- /**
- * Do not call, for BeanContainer.
- * @throws IllegalAccessException
- * @throws InstantiationException
- */
- public Object createInterceptor(Class<?> interceptorClass) throws InstantiationException, IllegalAccessException
- {
- Object instance = interceptorClass.newInstance();
- InterceptorInjector interceptorInjector = interceptorInjectors.get(interceptorClass);
- assert interceptorInjector != null : "interceptorInjector not found for " + interceptorClass;
- interceptorInjector.inject(null, instance);
- return instance;
- }
-
- public String createObjectName(String unitName, String ejbName)
- {
- return JavaEEComponentHelper.createObjectName(deployment, unitName, ejbName);
- }
-
- // TODO: re-evaluate this exposure
- @Deprecated
- public Advisor getAdvisor()
- {
- return beanContainer._getAdvisor();
- }
-
- /*
- * TODO: re-evalute this exposure
- */
- @Deprecated
- public AnnotationRepository getAnnotations()
- {
- return beanContainer.getAnnotationRepository();
- }
-
- protected BeanContainer getBeanContainer()
- {
- return beanContainer;
- }
-
- /**
- *
- * @return the bean class of this container
- * @deprecated use getBeanClass
- */
- public Class<?> getClazz()
- {
- return getBeanClass();
- }
-
- @SuppressWarnings("unchecked")
- public static <C extends EJBContainer> C getEJBContainer(Advisor advisor)
- {
- try
- {
- return (C) ((ManagedObjectAdvisor<Object, BeanContainer>) advisor).getContainer().getEJBContainer();
- }
- catch(ClassCastException e)
- {
- throw new ClassCastException(e.getMessage() + " using " + advisor);
- }
- }
-
- public String getName()
- {
- return name;
- }
-
- public void pushContext(BeanContext<?> beanContext)
- {
- currentBean.push(beanContext);
- }
-
- /**
- * Makes sure that EJB's ENC is available
- * Delegates to whatever implementation is used to push the ENC of the EJB
- * onto the stack
- *
- */
- protected void pushEnc()
- {
- encFactory.pushEnc(this);
- }
-
- public BeanContext<?> peekContext()
- {
- BeanContext<?> ctx = currentBean.get();
- assert ctx != null : "ctx is null";
- return ctx;
- }
-
- public BeanContext<?> popContext()
- {
- return currentBean.pop();
- }
-
- /**
- * Pops EJB's ENC from the stack. Delegates to whatever implementation
- * is used to pop the EJB's ENC from the stock
- *
- */
- protected void popEnc()
- {
- encFactory.popEnc(this);
- }
-
- public Environment getEnvironmentRefGroup()
- {
- return xml;
- }
-
- public List<Injector> getInjectors()
- {
- return injectors;
- }
-
-
- public String getJaccContextId()
- {
- return jaccContextId;
- }
-
- /**
- * Do not call, used by BeanContainer.
- * @return
- */
- public List<Method> getVirtualMethods()
- {
- return null;
- }
-
- public void setJaccContextId(String jaccContextId)
- {
- this.jaccContextId = jaccContextId;
- }
-
- public VirtualFile getRootFile()
- {
- return getDeploymentUnit().getRootFile();
- }
-
- /**
- * Return all the business interfaces implemented by this bean.
- *
- * Available after the meta data has been processed.
- *
- * @return an array of business interfaces or empty if no interface is provided
- */
- public List<Class<?>> getBusinessInterfaces()
- {
- if(businessInterfaces == null) throw new IllegalStateException("businessInterfaces not yet initialized");
- return businessInterfaces;
- }
-
- /**
- * Returns a String identifier for this bean that is qualified by the
- * deployment, and hence should be unique across deployments. Name is of the
- * form "ear=foo.ear,jar=foo.jar,name=Bar", where "Bar" is the value
- * returned by {@link #getEjbName()}. The "ear=foo.ear" portion is ommitted
- * if the bean is not packaged in an ear.
- */
- public String getDeploymentQualifiedName()
- {
- return objectName.getCanonicalName();
- }
-
- public DeploymentUnit getDeploymentUnit()
- {
- return deployment.getDeploymentUnit();
- }
-
- public Ejb3Deployment getDeployment()
- {
- return deployment;
- }
-
- public DependencyPolicy getDependencyPolicy()
- {
- return dependencyPolicy;
- }
-
- public boolean isAnnotationPresent(Class<? extends Annotation> annotationType)
- {
- return beanContainer.isAnnotationPresent(annotationType);
- }
-
- /**
- * Is the method a business method of this container.
- *
- * @param businessMethod the method in question
- * @return true if so, otherwise false
- */
- public boolean isBusinessMethod(Method businessMethod)
- {
- for(Class<?> businessInterface : getBusinessInterfaces())
- {
- for(Method method : businessInterface.getMethods())
- {
- if(isCallable(method, businessMethod))
- return true;
- }
- }
- return false;
- }
-
- /**
- * Can method definition method be used to call method other.
- * For example if the method is defined in an interface it can be used to call a method
- * in a class.
- *
- * @param method
- * @param other
- * @return
- */
- private static boolean isCallable(Method method, Method other)
- {
- if ((method.getDeclaringClass().isAssignableFrom(other.getDeclaringClass())) && (method.getName() == other.getName()))
- {
- if (!method.getReturnType().equals(other.getReturnType()))
- return false;
- Class[] params1 = method.getParameterTypes();
- Class[] params2 = other.getParameterTypes();
- if (params1.length == params2.length)
- {
- for (int i = 0; i < params1.length; i++)
- {
- if (params1[i] != params2[i])
- return false;
- }
- return true;
- }
- }
- return false;
- }
-
- /**
- * introspects EJB container to find all dependencies
- * and initialize any extra metadata.
- * <p/>
- * This must be called before container is registered with any microcontainer
- *
- * @param dependencyPolicy
- */
- public void processMetadata()
- {
- // XML must be done first so that any annotation overrides are initialized
-
- // todo injection handlers should be pluggable from XML
- Collection<InjectionHandler<Environment>> handlers = new ArrayList<InjectionHandler<Environment>>();
- handlers.add(new EJBHandler<Environment>());
- handlers.add(new DependsHandler<Environment>());
- handlers.add(new JndiInjectHandler<Environment>());
- handlers.add(new PersistenceContextHandler<Environment>());
- handlers.add(new PersistenceUnitHandler<Environment>());
- handlers.add(new ResourceHandler<Environment>());
- handlers.add(new WebServiceRefHandler<Environment>());
-
- ClassLoader old = Thread.currentThread().getContextClassLoader();
- Thread.currentThread().setContextClassLoader(classloader);
- try
- {
- // EJB container's XML must be processed before interceptor's as it may override interceptor's references
- for (InjectionHandler<Environment> handler : handlers) handler.loadXml(xml, this);
-
- Map<AccessibleObject, Injector> tmp = InjectionUtil.processAnnotations(this, handlers, getBeanClass());
- injectors.addAll(tmp.values());
-
- /*
- initialiseInterceptors();
- */
- for (Class<?> interceptorClass : beanContainer.getInterceptorClasses())
- {
- InterceptorMetaData interceptorMetaData = findInterceptor(interceptorClass);
- if(interceptorMetaData == null)
- continue;
-
- for (InjectionHandler<Environment> handler : handlers)
- {
- handler.loadXml(interceptorMetaData, this);
- }
- }
- for (Class<?> interceptorClass : beanContainer.getInterceptorClasses())
- {
- Map<AccessibleObject, Injector> injections = InjectionUtil.processAnnotations(this, handlers, interceptorClass);
- InterceptorInjector injector = new InterceptorInjector(injections);
- interceptorInjectors.put(interceptorClass, injector);
- }
-
- // When @WebServiceRef is not used service-ref won't be processed
- // In this case we process them late
- if(xml != null && xml.getServiceReferences() != null)
- {
- for(ServiceReferenceMetaData sref : xml.getServiceReferences())
- {
- // FIXME: fix WS metadata
- /*
- if(!sref.isProcessed())
- {
- try
- {
- String name = sref.getServiceRefName();
- String encName = "env/" + name;
- Context encCtx = getEnc();
-
- UnifiedVirtualFile vfsRoot = new VirtualFileAdaptor(getRootFile());
- new ServiceRefDelegate().bindServiceRef(encCtx, encName, vfsRoot, getClassloader(), sref);
-
- }
- catch (Exception e)
- {
- log.error("Failed to bind service-ref", e);
- }
- }
- */
- }
- }
-
- // EJBTHREE-1025
- this.checkForDuplicateLocalAndRemoteInterfaces();
-
- for(Class<?> businessInterface : getBusinessInterfaces())
- ((JBoss5DependencyPolicy) getDependencyPolicy()).addSupply(businessInterface);
-
- Class localHomeInterface = ProxyFactoryHelper.getLocalHomeInterface(this);
- if(localHomeInterface != null)
- ((JBoss5DependencyPolicy) getDependencyPolicy()).addSupply(localHomeInterface);
-
- Class remoteHomeInterface = ProxyFactoryHelper.getRemoteHomeInterface(this);
- if(remoteHomeInterface != null)
- ((JBoss5DependencyPolicy) getDependencyPolicy()).addSupply(remoteHomeInterface);
- }
- finally
- {
- Thread.currentThread().setContextClassLoader(old);
- }
- }
-
- /**
- * Ensures that the bean does not implement any one interface as both @Local and @Remote
- *
- * @throws EJBException If the bean does implements any one interface as both @Local and @Remote
- */
- protected void checkForDuplicateLocalAndRemoteInterfaces() throws EJBException
- {
- // Initialize issue used in Error Message
- String issue = "(EJBTHREE-1025)";
-
- // Obtain annotations, if found
- Local local = (Local) resolveAnnotation(Local.class);
- Remote remote = (Remote) resolveAnnotation(Remote.class);
-
- // If either local or remote is unspecified, return safely - there can be no overlap
- if (local == null || remote == null)
- {
- return;
- }
-
- // Ensure "value" attribute of both local and remote are not blank
- if (local.value().length < 1 && local.value().length < 1)
- {
- throw new EJBException("Cannot designate both " + Local.class.getName() + " and " + Remote.class.getName()
- + " annotations without 'value' attribute on " + this.getEjbName() + ". " + issue);
- }
-
- // Iterate through local and remote interfaces, ensuring any one interface is not being used for both local and remote exposure
- for (Class<?> localClass : local.value())
- {
- for (Class<?> remoteClass : remote.value())
- {
- if (localClass.equals(remoteClass))
- {
- throw new EJBException("Cannot designate " + localClass.getName() + " as both " + Local.class.getName()
- + " and " + Remote.class.getName() + " on " + this.getEjbName() + ". " + issue);
- }
- }
- }
- }
-
- public JBossEnterpriseBeanMetaData getXml()
- {
- return xml;
- }
-
- public JBossAssemblyDescriptorMetaData getAssemblyDescriptor()
- {
- return assembly;
- }
-
- // FIXME: remove
- @Deprecated
- public void setAssemblyDescriptor(JBossAssemblyDescriptorMetaData assembly)
- {
- this.assembly = assembly;
- }
-
- protected abstract List<Class<?>> resolveBusinessInterfaces();
-
- public InterceptorInfoRepository getInterceptorRepository()
- {
- throw new RuntimeException("invalid");
- }
-
- public Map<String, EncInjector> getEncInjectors()
- {
- return encInjectors;
- }
-
- public ClassLoader getClassloader()
- {
- return classloader;
- }
-
- public InitialContext getInitialContext()
- {
- try
- {
- return InitialContextFactory.getInitialContext(initialContextProperties);
- }
- catch (NamingException e)
- {
- throw new RuntimeException(e);
- }
- }
-
- public Map<String, Map<AccessibleObject, Injector>> getEncInjections()
- {
- return encInjections;
- }
-
- public Context getEnc()
- {
- if (enc == null)
- {
- enc = encFactory.getEnc(this);
- }
- return enc;
- }
-
- public Hashtable getInitialContextProperties()
- {
- return initialContextProperties;
- }
-
- public ObjectName getObjectName()
- {
- return objectName;
- }
-
- public String getEjbName()
- {
- return ejbName;
- }
-
- public String getBeanClassName()
- {
- return beanClassName;
- }
-
- public Class<?> getBeanClass()
- {
- return beanClass;
- }
-
- public Pool getPool()
- {
- return pool;
- }
-
- /**
- * Gets the name of the cluster partition with which this container is
- * associated. Not available until <code>EJBContainer.start()</code>
- * is completed.
- *
- * @return the name of the cluster partition with which this container is
- * associated, or <code>null</code> if the container is not clustered
- */
- public String getPartitionName()
- {
- if (partitionName == null)
- this.findPartitionName();
- return partitionName;
- }
-
- protected Object construct()
- {
- /*
- Interceptor[] cInterceptors = constructorInterceptors[defaultConstructorIndex];
- if (cInterceptors == null)
- {
- try
- {
- return constructors[defaultConstructorIndex].newInstance();
- }
- catch (InstantiationException e)
- {
- throw new RuntimeException(e);
- }
- catch (IllegalAccessException e)
- {
- throw new RuntimeException(e);
- }
- catch (InvocationTargetException e)
- {
- throw new RuntimeException(e);
- }
- }
- ConstructorInvocation invocation = new ConstructorInvocation(
- cInterceptors);
-
- invocation.setAdvisor(this);
- invocation.setConstructor(constructors[defaultConstructorIndex]);
- try
- {
- return invocation.invokeNext();
- }
- catch (Throwable throwable)
- {
- throw new RuntimeException(throwable);
- }
- */
- try
- {
- return beanContainer.construct();
- }
- catch (SecurityException e)
- {
- throw new RuntimeException(e);
- }
- catch (NoSuchMethodException e)
- {
- throw new RuntimeException(e);
- }
- }
-
- public void create() throws Exception
- {
- /*
- initializeClassContainer();
- for (int i = 0; i < constructors.length; i++)
- {
- if (constructors[i].getParameterTypes().length == 0)
- {
- defaultConstructorIndex = i;
- break;
- }
- }
- */
- }
-
- // Everything must be done in start to make sure all dependencies have been satisfied
- public void start() throws Exception
- {
- initializePool();
-
- for (EncInjector injector : encInjectors.values())
- {
- injector.inject(this);
- }
-
- // creating of injector array should come after injection into ENC as an ENC injector
- // may add additional injectors into the injector list. An example is an extended persistence
- // context which mush be created and added to the SFSB bean context.
-
- Injector[] injectors2 = injectors.toArray(new Injector[injectors.size()]);
- if (pool != null) pool.setInjectors(injectors2);
-
-// createCallbackHandler();
-
- JaccHelper.configureContainer(jaccContextId, this);
-
- // If we're clustered, find our partition name
- findPartitionName();
-
- log.info("STARTED EJB: " + beanClass.getName() + " ejbName: " + ejbName);
- }
-
- public void stop() throws Exception
- {
- encFactory.cleanupEnc(this);
-
- if (pool != null)
- {
- pool.destroy();
- pool = null;
- }
-
- log.info("STOPPED EJB: " + beanClass.getName() + " ejbName: " + ejbName);
- }
-
- public void destroy() throws Exception
- {
- }
-
- @SuppressWarnings("unchecked")
- public <T> T getSecurityManager(Class<T> type)
- {
- try
- {
- InitialContext ctx = getInitialContext();
- SecurityDomain securityAnnotation = (SecurityDomain) resolveAnnotation(SecurityDomain.class);
- if (securityAnnotation != null && securityAnnotation.value().length() > 0)
- {
- return (T) SecurityDomainManager.getSecurityManager(securityAnnotation.value(),ctx);
- }
- return null;
- }
- catch (NamingException e)
- {
- throw new RuntimeException(e);
- }
- }
-
- protected Method getTimeoutCallback(NamedMethodMetaData timeoutMethodMetaData, Class<?> beanClass)
- {
- JBossEnterpriseBeanMetaData metaData = xml;
- if(metaData != null)
- {
- if(timeoutMethodMetaData != null)
- {
- String methodName = timeoutMethodMetaData.getMethodName();
- try
- {
- return beanClass.getMethod(methodName, Timer.class);
- }
- catch (SecurityException e)
- {
- throw new RuntimeException(e);
- }
- catch (NoSuchMethodException e)
- {
- throw new RuntimeException("No method " + methodName + "(javax.ejb.Timer timer) found on bean " + ejbName, e);
- }
- }
- }
-
- if(TimedObject.class.isAssignableFrom(beanClass))
- {
- try
- {
- return TimedObject.class.getMethod("ejbTimeout", Timer.class);
- }
- catch (SecurityException e)
- {
- throw new RuntimeException(e);
- }
- catch (NoSuchMethodException e)
- {
- throw new RuntimeException(e);
- }
- }
-
- if(metaData != null)
- {
- // TODO: cross cutting concern
- if(metaData.getEjbJarMetaData().isMetadataComplete())
- return null;
- }
-
- for (Method method : beanClass.getMethods())
- {
- if (getAnnotation(Timeout.class, method) != null)
- {
- if (Modifier.isPublic(method.getModifiers()) &&
- method.getReturnType().equals(Void.TYPE) &&
- method.getParameterTypes().length == 1 &&
- method.getParameterTypes()[0].equals(Timer.class))
- {
- // TODO: check for multiples
- return method;
- }
- else
- {
- throw new RuntimeException("@Timeout method " + method + " must have signature: void <METHOD>(javax.ejb.Timer timer) (EJB3 18.2.2)");
- }
- }
- }
-
- return null;
- }
-
- protected void initializePool() throws Exception
- {
- org.jboss.ejb3.annotation.Pool poolAnnotation = getAnnotation(org.jboss.ejb3.annotation.Pool.class);
- if (poolAnnotation == null)
- throw new IllegalStateException("No pool annotation");
- String registeredPoolName = poolAnnotation.value();
- // EJBTHREE-1119
- if(registeredPoolName==null||registeredPoolName.trim().equals(""))
- {
- // Default the Pool Implementation
- registeredPoolName = PoolDefaults.POOL_IMPLEMENTATION_THREADLOCAL;
- }
- int maxSize = poolAnnotation.maxSize();
- long timeout = poolAnnotation.timeout();
- Ejb3Deployer deployer = deployment.getDeployer();
- PoolFactoryRegistry registry = deployer.getPoolFactoryRegistry();
- PoolFactory factory = registry.getPoolFactory(registeredPoolName);
- pool = factory.createPool();
- pool.initialize(this, maxSize, timeout);
-
- resolveInjectors();
- pool.setInjectors(injectors.toArray(new Injector[injectors.size()]));
- }
-
- /**
- * Note that this method is a WIP.
- *
- * @param beanContext
- * @param callbackAnnotationClass on of PostConstruct, PreDestroy, PostActivate or PrePassivate
- */
- protected void invokeCallback(BeanContext<?> beanContext, Class<? extends Annotation> callbackAnnotationClass)
- {
- try
- {
- List<Interceptor> interceptors = new ArrayList<Interceptor>(InterceptorsFactory.getLifeCycleInterceptors((InstanceAdvisor) getAdvisor(), callbackAnnotationClass));
- interceptors.add(0, PerVmAdvice.generateInterceptor(null, new InvocationContextInterceptor(), "setup"));
-
- LifeCycleInvocation invocation = new LifeCycleInvocation(interceptors.toArray(new Interceptor[0]));
- invocation.setAdvisor(getAdvisor());
- invocation.setTargetObject(beanContext.getInstance());
- invocation.invokeNext();
- }
- catch(Throwable t)
- {
- throw new RuntimeException(t);
- }
- }
-
- public void invokePostConstruct(BeanContext<?> beanContext)
- {
- invokeCallback(beanContext, PostConstruct.class);
- }
-
- @Deprecated
- public void invokePostConstruct(BeanContext beanContext, Object[] params)
- {
- invokePostConstruct(beanContext);
- }
-
- public void invokePreDestroy(BeanContext beanContext)
- {
- // This is the correct way to destroy an instance, do
- // not call invokeCallback here.
- beanContainer.destroy(beanContext.getInstance());
- }
-
- public void invokePostActivate(BeanContext beanContext)
- {
- throw new RuntimeException("PostActivate not implemented for container");
- }
-
- public void invokePrePassivate(BeanContext beanContext)
- {
- throw new RuntimeException("PrePassivate not implemented for container");
- }
-
- public void invokeInit(Object bean, Class[] initParameterTypes,
- Object[] initParameterValues)
- {
- // do nothing, only useful on a stateful session bean
- }
-
- public static final String MANAGED_ENTITY_MANAGER_FACTORY = "ManagedEntityManagerFactory";
-
- public static final String ENTITY_MANAGER_FACTORY = "EntityManagerFactory";
-
- protected void resolveInjectors() throws Exception
- {
- pushEnc();
- try
- {
- Thread.currentThread().setContextClassLoader(classloader);
- try
- {
- Util.rebind(getEnc(), "UserTransaction", new UserTransactionImpl());
- }
- catch (NamingException e)
- {
- NamingException namingException = new NamingException("Could not bind user transaction for ejb name " + ejbName + " into JNDI under jndiName: " + getEnc().getNameInNamespace() + "/" + "UserTransaction");
- namingException.setRootCause(e);
- throw namingException;
- }
- try
- {
- Util.rebind(getEnc(), "TransactionSynchronizationRegistry", new LinkRef("java:TransactionSynchronizationRegistry"));
- log.debug("Linked java:comp/TransactionSynchronizationRegistry to JNDI name: java:TransactionSynchronizationRegistry");
- }
- catch (NamingException e)
- {
- NamingException namingException = new NamingException("Could not bind TransactionSynchronizationRegistry for ejb name " + ejbName + " into JNDI under jndiName: " + getEnc().getNameInNamespace() + "/" + "TransactionSynchronizationRegistry");
- namingException.setRootCause(e);
- throw namingException;
- }
- }
- finally
- {
- popEnc();
- }
- }
-
- /*
- protected void createCallbackHandler()
- {
- try
- {
- callbackHandler = new LifecycleInterceptorHandler(this,
- getHandledCallbacks());
- }
- catch (Exception e)
- {
- throw new RuntimeException("Error creating callback handler for bean "
- + beanClassName, e);
- }
- }
- */
-
- protected Class[] getHandledCallbacks()
- {
- return new Class[]
- {PostConstruct.class, PreDestroy.class, Timeout.class};
- }
-
- // TODO: once injection is finalized this method will disappear
- private InterceptorMetaData findInterceptor(Class<?> interceptorClass)
- {
- if(xml == null)
- return null;
- JBossMetaData ejbJarMetaData = xml.getEjbJarMetaData();
- if(ejbJarMetaData == null)
- return null;
- InterceptorsMetaData interceptors = ejbJarMetaData.getInterceptors();
- if(interceptors == null)
- return null;
- for(InterceptorMetaData interceptorMetaData : interceptors)
- {
- if(interceptorMetaData.getInterceptorClass().equals(interceptorClass.getName()))
- return interceptorMetaData;
- }
- return null;
- }
-
- protected void findPartitionName()
- {
- Clustered clustered = (Clustered) resolveAnnotation(Clustered.class);
- if (clustered == null)
- {
- partitionName = null;
- return;
- }
-
- String value = clustered.partition();
- try
- {
- String replacedValue = StringPropertyReplacer.replaceProperties(value);
- if (value != replacedValue)
- {
- log.debug("Replacing @Clustered partition attribute " + value + " with " + replacedValue);
- value = replacedValue;
- }
- }
- catch (Exception e)
- {
- log.warn("Unable to replace @Clustered partition attribute " + value +
- ". Caused by " + e.getClass() + " " + e.getMessage());
- }
-
- partitionName = value;
- }
-
- public <T> T getBusinessObject(BeanContext<?> beanContext, Class<T> businessInterface) throws IllegalStateException
- {
- throw new IllegalStateException("Not implemented");
- }
-
- public Object getInvokedBusinessInterface(BeanContext beanContext) throws IllegalStateException
- {
- throw new IllegalStateException("Not implemented");
- }
-
- protected Object getInvokedInterface(Method method)
- {
- Remote remoteAnnotation = (Remote) resolveAnnotation(Remote.class);
- if (remoteAnnotation != null)
- {
- Class[] remotes = remoteAnnotation.value();
- for (int i = 0; i < remotes.length; ++i)
- {
- try
- {
- remotes[i].getMethod(method.getName(), method.getParameterTypes());
- return remotes[i];
- }
- catch (NoSuchMethodException e)
- {
- }
- }
- }
-
- Local localAnnotation = (Local) resolveAnnotation(Local.class);
- if (localAnnotation != null)
- {
- Class[] locals = localAnnotation.value();
- for (int i = 0; i < locals.length; ++i)
- {
- Method[] interfaceMethods = locals[i].getMethods();
- for (int j = 0; j < interfaceMethods.length; ++j)
- {
- if (interfaceMethods[j].equals(method))
- return locals[i];
- }
- }
- }
-
- return null;
- }
-
- // todo these method overrides for aop are for performance reasons
- private Class loadPublicAnnotation(String annotation)
- {
- try
- {
- Class ann = classloader.loadClass(annotation);
- if (!ann.isAnnotation()) return null;
- Retention retention = (Retention) ann.getAnnotation(Retention.class);
- if (retention != null && retention.value() == RetentionPolicy.RUNTIME) return ann;
-
- }
- catch (ClassNotFoundException ignored)
- {
- }
- return null;
- }
-
- /*
- @Override
- public boolean hasAnnotation(Class tgt, String annotation)
- {
- if (annotations.hasClassAnnotation(annotation)) return true;
- if (tgt == null) return false;
- try
- {
- Class ann = loadPublicAnnotation(annotation);
- // it is metadata or CLASS annotation
- if (ann == null) return AnnotationElement.isAnyAnnotationPresent(tgt, annotation);
- return tgt.isAnnotationPresent(ann);
- }
- catch (Exception e)
- {
- throw new RuntimeException(e); //To change body of catch statement use Options | File Templates.
- }
- }
-
-
- @Override
- public boolean hasAnnotation(Method m, String annotation)
- {
- if (annotations.hasAnnotation(m, annotation)) return true;
- try
- {
- Class ann = loadPublicAnnotation(annotation);
- // it is metadata or CLASS annotation
- if (ann == null) return AnnotationElement.isAnyAnnotationPresent(m, annotation);
- return m.isAnnotationPresent(ann);
- }
- catch (Exception e)
- {
- throw new RuntimeException(e); //To change body of catch statement use Options | File Templates.
- }
- }
-
- @Override
- public boolean hasAnnotation(Field m, String annotation)
- {
- if (annotations.hasAnnotation(m, annotation)) return true;
- try
- {
- Class ann = loadPublicAnnotation(annotation);
- // it is metadata or CLASS annotation
- if (ann == null) return AnnotationElement.isAnyAnnotationPresent(m, annotation);
- return m.isAnnotationPresent(ann);
- }
- catch (Exception e)
- {
- throw new RuntimeException(e); //To change body of catch statement use Options | File Templates.
- }
- }
-
- @Override
- public boolean hasAnnotation(Constructor m, String annotation)
- {
- if (annotations.hasAnnotation(m, annotation)) return true;
- try
- {
- Class ann = loadPublicAnnotation(annotation);
- // it is metadata or CLASS annotation
- if (ann == null) return AnnotationElement.isAnyAnnotationPresent(m, annotation);
- return m.isAnnotationPresent(ann);
- }
- catch (Exception e)
- {
- throw new RuntimeException(e); //To change body of catch statement use Options | File Templates.
- }
- }
- */
-
- public Container resolveEjbContainer(String link, Class businessIntf)
- {
- return deployment.getEjbContainer(link, businessIntf);
- }
-
- public Container resolveEjbContainer(Class businessIntf) throws NameNotFoundException
- {
- return deployment.getEjbContainer(businessIntf);
- }
-
- public String resolveMessageDestination(String link)
- {
- return deployment.resolveMessageDestination(link);
- }
-
- public <T extends Annotation> T getAnnotation(Class<T> annotationType)
- {
- return beanContainer.getAnnotation(annotationType);
- }
-
- public <T extends Annotation> T getAnnotation(Class<T> annotationType, Class<?> clazz)
- {
- return beanContainer.getAnnotation(clazz, annotationType);
- }
-
- public <T extends Annotation> T getAnnotation(Class<T> annotationType, Class<?> clazz, Method method)
- {
- return beanContainer.getAnnotation(annotationType, clazz, method);
- }
-
- public <T extends Annotation> T getAnnotation(Class<T> annotationType, Method method)
- {
- return beanContainer.getAnnotation(annotationType, method);
- }
-
- public <T extends Annotation> T getAnnotation(Class<T> annotationType, Class<?> clazz, Field field)
- {
- return beanContainer.getAnnotation(annotationType, clazz, field);
- }
-
- public <T extends Annotation> T getAnnotation(Class<T> annotationType, Field field)
- {
- return beanContainer.getAnnotation(annotationType, field);
- }
-
- /**
- * @deprecated use getAnnotation
- */
- @SuppressWarnings("unchecked")
- public Object resolveAnnotation(Class annotationType)
- {
- return getAnnotation(annotationType);
- }
-
- /**
- * @deprecated use getAnnotation
- */
- @SuppressWarnings("unchecked")
- public Object resolveAnnotation(Field field, Class annotationType)
- {
- return getAnnotation(annotationType, field);
- }
-
- /**
- * @deprecated use getAnnotation
- */
- @SuppressWarnings("unchecked")
- public Object resolveAnnotation(Method method, Class annotationType)
- {
- return getAnnotation(annotationType, method);
- }
-
- /**
- * @deprecated this is going to be gone soon
- */
- @SuppressWarnings("unchecked")
- public Object resolveAnnotation(Method m, Class[] annotationChoices)
- {
- Object value = null;
- int i = 0;
- while (value == null && i < annotationChoices.length){
- value = resolveAnnotation(m, annotationChoices[i++]);
- }
-
- return value;
- }
-
- public String getIdentifier()
- {
- return getEjbName();
- }
-
- public String getDeploymentDescriptorType()
- {
- return "ejb-jar.xml";
- }
-
- public PersistenceUnitDeployment getPersistenceUnitDeployment(String unitName) throws NameNotFoundException
- {
- return deployment.getPersistenceUnitDeployment(unitName);
- }
-
- public String getEjbJndiName(Class businessInterface) throws NameNotFoundException
- {
- return deployment.getEjbJndiName(businessInterface);
- }
-
- public String getEjbJndiName(String link, Class businessInterface)
- {
- return deployment.getEjbJndiName(link, businessInterface);
- }
-
- public InvocationStatistics getInvokeStats()
- {
- return invokeStats;
- }
-
- @Deprecated
- protected MethodInfo getMethodInfo(Method method)
- {
- long hash = MethodHashing.calculateHash(method);
- MethodInfo info = getAdvisor().getMethodInfo(hash);
- if (info == null)
- {
- throw new RuntimeException("Could not resolve beanClass method from proxy call: " + method.toString());
- }
- return info;
- }
-
- public boolean isClustered()
- {
- return false;
- }
-
- public JavaEEModule getModule()
- {
- return deployment;
- }
-
- public abstract boolean hasJNDIBinding(String jndiName);
-
- /**
- * After XML processing has been done this allows the container
- * to further initialize the meta data.
- */
- public void instantiated()
- {
- this.businessInterfaces = resolveBusinessInterfaces();
-
- // Before we start to process annotations, make sure we also have the ones from interceptors-aop.
- // FIXME: because of the flaked life cycle of an EJBContainer (we add annotations after it's been
- // constructed), we must reinitialize the whole thing.
- beanContainer.reinitializeAdvisor();
- }
-
- public void setDirectContainer(DirectContainer<EJBContainer> container)
- {
- this.directContainer = container;
- }
-
- public String toString()
- {
- return getObjectName().getCanonicalName();
- }
-}
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/EJBContainerInvocation.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/EJBContainerInvocation.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/EJBContainerInvocation.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -1,111 +0,0 @@
-/*
- * 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;
-
-import java.lang.reflect.Method;
-import org.jboss.aop.Advisor;
-import org.jboss.aop.MethodInfo;
-import org.jboss.aop.advice.Interceptor;
-import org.jboss.aop.joinpoint.Invocation;
-import org.jboss.aop.joinpoint.MethodInvocation;
-
-/**
- * Representation of an EJB invocation on the serverside
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- */
-public class EJBContainerInvocation<A extends EJBContainer, T extends BeanContext> extends MethodInvocation
-{
- private static final long serialVersionUID = 4941832732679380382L;
-
- protected T ctx;
- private BeanContextLifecycleCallback<T> callback;
-
- public EJBContainerInvocation(MethodInfo info)
- {
- super(info, info.getInterceptors());
- }
-
- public EJBContainerInvocation(Interceptor[] interceptors, long methodHash, Method advisedMethod, Method unadvisedMethod, Advisor advisor)
- {
- super(interceptors, methodHash, advisedMethod, unadvisedMethod, advisor);
- }
-
- public EJBContainerInvocation()
- {
- super(null, null);
- }
-
- /*
- @SuppressWarnings("unchecked")
- public A getAdvisor()
- {
- return (A) super.getAdvisor();
- }
- */
-
- public T getBeanContext()
- {
- return ctx;
- }
-
- public void setBeanContext(T beanCtx)
- {
- if(beanCtx != null)
- {
- ctx = beanCtx;
-
- if(callback != null)
- callback.attached(beanCtx);
- }
- else
- {
- if(callback != null)
- callback.released(ctx);
-
- ctx = null;
- }
- }
-
- public Invocation getWrapper(Interceptor[] newchain)
- {
- return new EJBContainerInvocationWrapper<A, T>(this, newchain);
- }
-
- public Invocation copy()
- {
- EJBContainerInvocation<A, T> wrapper = new EJBContainerInvocation<A, T>(interceptors, methodHash, advisedMethod, unadvisedMethod, advisor);
- wrapper.metadata = this.metadata;
- wrapper.currentInterceptor = this.currentInterceptor;
- wrapper.setTargetObject(this.getTargetObject());
- wrapper.setArguments(this.getArguments());
- wrapper.setBeanContext(this.ctx);
- wrapper.callback = this.callback;
- return wrapper;
- }
-
- public void setContextCallback(BeanContextLifecycleCallback<T> callback)
- {
- this.callback = callback;
- }
-}
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/EJBContainerInvocationWrapper.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/EJBContainerInvocationWrapper.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/EJBContainerInvocationWrapper.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -1,176 +0,0 @@
-/*
- * 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;
-
-import java.lang.reflect.Method;
-import java.util.Map;
-
-import org.jboss.aop.Advisor;
-import org.jboss.aop.advice.Interceptor;
-import org.jboss.aop.joinpoint.Invocation;
-import org.jboss.aop.metadata.SimpleMetaData;
-import org.jboss.logging.Logger;
-
-/**
- * This wrapper class allows you to insert a chain of interceptors into the middle of a call stack.
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- */
-public class EJBContainerInvocationWrapper<A extends EJBContainer, T extends BeanContext> extends EJBContainerInvocation<A, T>
-{
- private static final long serialVersionUID = 5402917625526438235L;
-
- private static final Logger log = Logger.getLogger(EJBContainerInvocationWrapper.class);
-
- protected EJBContainerInvocation<A, T> wrapped;
-
- public EJBContainerInvocationWrapper(EJBContainerInvocation<A, T> wrapped, Interceptor[] interceptors)
- {
- super(interceptors, wrapped.getMethodHash(), wrapped.getMethod(), wrapped.getActualMethod(), wrapped.getAdvisor());
- this.wrapped = wrapped;
- }
-
- public Object invokeNext() throws Throwable
- {
- if (currentInterceptor < interceptors.length)
- {
- try
- {
- return interceptors[currentInterceptor++].invoke(this);
- }
- finally
- {
- // so that interceptors like clustering can reinvoke down the chain
- currentInterceptor--;
- }
- }
- try
- {
- return wrapped.invokeNext();
- }
- finally
- {
- responseContextInfo = wrapped.getResponseContextInfo();
- }
- }
-
- public Method getMethod()
- {
- return wrapped.getMethod();
- }
-
- public long getMethodHash()
- {
- return wrapped.getMethodHash();
- }
-
- public Object getTargetObject()
- {
- return wrapped.getTargetObject();
- }
-
- public void setTargetObject(Object targetObject)
- {
- wrapped.setTargetObject(targetObject);
- }
-
- public Object[] getArguments()
- {
- return wrapped.getArguments();
- }
-
- public void setArguments(Object[] args)
- {
- wrapped.setArguments(args);
- }
-
- public Object resolveClassAnnotation(Class annotation)
- {
- return wrapped.resolveClassAnnotation(annotation);
- }
-
- public Object resolveAnnotation(Class annotation)
- {
- return wrapped.resolveAnnotation(annotation);
- }
-
- public Object getMetaData(Object key, Object attr)
- {
- return wrapped.getMetaData(key, attr);
- }
-
- public Invocation getWrapper(Interceptor[] newchain)
- {
- return wrapped.getWrapper(newchain);
- }
-
- public Invocation copy()
- {
- return wrapped.copy();
- }
-
- public Map getResponseContextInfo()
- {
- return wrapped.getResponseContextInfo();
- }
-
- public void setResponseContextInfo(Map responseContextInfo)
- {
- wrapped.setResponseContextInfo(responseContextInfo);
- }
-
- public void addResponseAttachment(Object key, Object val)
- {
- wrapped.addResponseAttachment(key, val);
- }
-
- public Object getResponseAttachment(Object key)
- {
- return wrapped.getResponseAttachment(key);
- }
-
- public SimpleMetaData getMetaData()
- {
- return wrapped.getMetaData();
- }
-
- public void setMetaData(SimpleMetaData data)
- {
- wrapped.setMetaData(data);
- }
-
- public Object resolveClassMetaData(Object key, Object attr)
- {
- return wrapped.resolveClassMetaData(key, attr);
- }
-
- public Object invokeNext(Interceptor[] newInterceptors) throws Throwable
- {
- return wrapped.invokeNext(newInterceptors);
- }
-
- public Advisor getAdvisor()
- {
- return wrapped.getAdvisor();
- }
-}
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/EJBContextFactory.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/EJBContextFactory.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/EJBContextFactory.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -1,59 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ejb3;
-
-import java.util.Hashtable;
-
-import javax.ejb.EJBContext;
-import javax.naming.Context;
-import javax.naming.Name;
-import javax.naming.Reference;
-import javax.naming.spi.ObjectFactory;
-
-/**
- * Comment
- *
- * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @version $Revision$
- */
-public class EJBContextFactory implements ObjectFactory
-{
- /* (non-Javadoc)
- * @see javax.naming.spi.ObjectFactory#getObjectInstance(java.lang.Object, javax.naming.Name, javax.naming.Context, java.util.Hashtable)
- */
- public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?, ?> environment)
- throws Exception
- {
- Reference ref = (Reference) obj;
- String containerGuid = (String) ref.get("containerGuid").getContent();
- boolean isClustered = Boolean.getBoolean((String)ref.get("isClustered").getContent());
-
- EJBContainer container = (EJBContainer)Ejb3Registry.getContainer(containerGuid);
- if (container == null && isClustered)
- {
- String containerClusterUid = (String) ref.get("containerClusterUid").getContent();
- container = (EJBContainer)Ejb3Registry.getClusterContainer(containerClusterUid);
- }
-
- return container.peekContext().getEJBContext();
- }
-}
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/EJBContextImpl.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/EJBContextImpl.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/EJBContextImpl.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -1,376 +0,0 @@
-/*
- * 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;
-
-import java.security.Identity;
-import java.security.Principal;
-import java.security.PrivilegedActionException;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Properties;
-import java.util.Set;
-
-import javax.ejb.EJBContext;
-import javax.ejb.EJBException;
-import javax.ejb.EJBHome;
-import javax.ejb.EJBLocalHome;
-import javax.ejb.TimerService;
-import javax.ejb.TransactionManagementType;
-import javax.naming.NamingException;
-import javax.transaction.Status;
-import javax.transaction.SystemException;
-import javax.transaction.TransactionManager;
-import javax.transaction.UserTransaction;
-
-import org.jboss.ejb3.annotation.SecurityDomain;
-import org.jboss.ejb3.tx.TxUtil;
-import org.jboss.ejb3.tx.UserTransactionImpl;
-import org.jboss.logging.Logger;
-import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
-import org.jboss.metadata.javaee.spec.SecurityRoleRefMetaData;
-import org.jboss.security.RealmMapping;
-import org.jboss.security.SecurityContext;
-import org.jboss.security.SecurityRoleRef;
-import org.jboss.security.SimplePrincipal;
-import org.jboss.security.integration.ejb.EJBAuthorizationHelper;
-import org.jboss.security.plugins.SecurityContextAssociation;
-
-/**
- * EJB3 Enterprise Context Implementation
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @author Anil.Saldhana at redhat.com
- * @version $Revision$
- */
-public abstract class EJBContextImpl<T extends Container, B extends BeanContext<T>> implements EJBContext
-{
- private static final Logger log = Logger.getLogger(EJBContextImpl.class);
- protected transient T container;
- protected transient RealmMapping rm;
- protected B beanContext;
-
- /** Principal for the bean associated with the call **/
- private Principal beanPrincipal;
-
- protected EJBContextImpl(B beanContext)
- {
- assert beanContext != null : "beanContext is null";
-
- this.beanContext = beanContext;
- this.container = beanContext.getContainer();
- this.rm = container.getSecurityManager(RealmMapping.class);
- }
-
- protected T getContainer()
- {
- return container;
- }
-
- protected RealmMapping getRm()
- {
- return rm;
- }
-
- public Object lookup(String name)
- {
- String newName;
- if (name.startsWith("/"))
- {
- newName = "env" + name;
- }
- else
- {
- newName = "env/" + name;
- }
- try
- {
- return getContainer().getEnc().lookup(newName);
- }
- catch (NamingException ignored)
- {
- try
- {
- return getContainer().getInitialContext().lookup(name);
- }
- catch (NamingException ignored2)
- {
-
- }
- }
- return null;
- }
-
- @SuppressWarnings("deprecation")
- public Identity getCallerIdentity()
- {
- throw new IllegalStateException("deprecated");
- }
-
- /*public Principal getCallerPrincipal()
- {
- Principal principal = null;
-
- RunAsIdentity runAsIdentity = SecurityActions.peekRunAsIdentity(1);
-
- principal = SecurityAssociation.getCallerPrincipal();
-
- if (getRm() != null)
- {
- principal = getRm().getPrincipal(principal);
- }
-
- // This method never returns null.
- if (principal == null)
- throw new java.lang.IllegalStateException("No valid security context for the caller identity");
-
- return principal;
- }
-*/
-
- public Principal getCallerPrincipal()
- {
- if(beanPrincipal == null)
- {
- EJBContainer ec = (EJBContainer) container;
-
- Principal callerPrincipal = null;
-
- RealmMapping rm = container.getSecurityManager(RealmMapping.class);
-
- SecurityContext sc = SecurityContextAssociation.getSecurityContext();
- if(sc == null)
- {
- SecurityDomain domain =(SecurityDomain)ec.resolveAnnotation(SecurityDomain.class);
- String unauth = domain.unauthenticatedPrincipal();
- if(unauth != null && unauth.length() > 0)
- if(domain.unauthenticatedPrincipal() != null)
- callerPrincipal = new SimplePrincipal(unauth);
- }
- else
- {
- EJBAuthorizationHelper helper = new EJBAuthorizationHelper(sc);
- callerPrincipal = helper.getCallerPrincipal(rm);
- }
-
- if(callerPrincipal == null)
- {
- //try the incoming principal
- callerPrincipal = sc.getUtil().getUserPrincipal();
- if(rm != null)
- callerPrincipal = rm.getPrincipal(callerPrincipal);
- }
-
- if(callerPrincipal == null)
- {
- SecurityDomain domain =(SecurityDomain)ec.resolveAnnotation(SecurityDomain.class);
- String unauth = domain.unauthenticatedPrincipal();
- if(unauth != null && unauth.length() > 0)
- if(domain.unauthenticatedPrincipal() != null)
- callerPrincipal = new SimplePrincipal(unauth);
- }
-
- // This method never returns null.
- if (callerPrincipal == null)
- throw new java.lang.IllegalStateException("No valid security context for the caller identity");
-
- beanPrincipal = callerPrincipal;
- }
- return beanPrincipal;
- }
-
-
- @SuppressWarnings("deprecation")
- public boolean isCallerInRole(Identity role)
- {
- throw new IllegalStateException("deprecated");
- }
-
- public boolean isCallerInRole(String roleName)
- {
- EJBContainer ejbc = (EJBContainer)container;
- SecurityContext sc = SecurityContextAssociation.getSecurityContext();
- if(sc == null)
- {
- SecurityDomain domain =(SecurityDomain)ejbc.resolveAnnotation(SecurityDomain.class);
- try
- {
- sc = SecurityActions.createSecurityContext(domain.value());
- }
- catch (PrivilegedActionException e)
- {
- throw new RuntimeException(e);
- }
- }
- // TODO: this is to slow
- Set<SecurityRoleRefMetaData> roleRefs = new HashSet<SecurityRoleRefMetaData>();
- JBossEnterpriseBeanMetaData eb = ejbc.getXml();
- if(eb != null)
- {
- Collection<SecurityRoleRefMetaData> srf = eb.getSecurityRoleRefs();
- if(srf != null)
- roleRefs.addAll(srf);
- }
-
- //TODO: Get rid of this conversion asap
- Set<SecurityRoleRef> srset = new HashSet<SecurityRoleRef>();
- for(SecurityRoleRefMetaData srmd: roleRefs)
- {
- srset.add(new SecurityRoleRef(srmd.getRoleName(),srmd.getRoleLink(),null));
- }
- Principal principal = getCallerPrincipal();
- EJBAuthorizationHelper helper = new EJBAuthorizationHelper(sc);
- return helper.isCallerInRole(roleName,
- ejbc.getEjbName(),
- principal,
- srset);
- }
-
- /*public boolean isCallerInRole(String roleName)
- {
- // TODO revert to aspects.security.SecurityContext impl when JBoss AOP 1.1 is out.
- Principal principal = getCallerPrincipal();
-
- // Check the caller of this beans run-as identity
- // todo use priveleged stuff in ejb class
- RunAsIdentity runAsIdentity = SecurityActions.peekRunAsIdentity(1);
-
- if (principal == null && runAsIdentity == null)
- return false;
-
- if (getRm() == null)
- {
- String msg = "isCallerInRole() called with no security context. "
- + "Check that a security-domain has been set for the application.";
- throw new IllegalStateException(msg);
- }
-
- //Ensure that you go through the security role references that may be configured
- EJBContainer ejbc = (EJBContainer)container;
- if(ejbc.getXml() != null)
- {
- Collection<SecurityRoleRef> securityRoleRefs = ejbc.getXml().getSecurityRoleRefs();
- for(SecurityRoleRef roleRef: securityRoleRefs)
- {
- String refName = roleRef.getRoleName();
- if(roleName.equals(refName))
- roleName = roleRef.getRoleLink();
- }
- }
-
- HashSet set = new HashSet();
- set.add(new SimplePrincipal(roleName));
-
- // This is work in progress - currently, getRm().doesUserHaveRole(principal, set)
- // and getRm().getUserRoles(principal) ignores the principal parameter and is not
- // using the principal from the pushed RunAsIdentity
- boolean doesUserHaveRole = false;
- if (runAsIdentity != null)
- doesUserHaveRole = runAsIdentity.doesUserHaveRole(set);
-
- if (!doesUserHaveRole)
- doesUserHaveRole = getRm().doesUserHaveRole(principal, set);
-
- java.util.Set roles = getRm().getUserRoles(principal);
-
- return doesUserHaveRole;
- }*/
-
- public TimerService getTimerService() throws IllegalStateException
- {
- return getContainer().getTimerService();
- }
-
- public UserTransaction getUserTransaction() throws IllegalStateException
- {
- TransactionManagementType type = TxUtil.getTransactionManagementType(getContainer());
- if (type != TransactionManagementType.BEAN) throw new IllegalStateException("Container " + getContainer().getEjbName() + ": it is illegal to inject UserTransaction into a CMT bean");
-
- return new UserTransactionImpl();
- }
-
- public EJBHome getEJBHome()
- {
- throw new IllegalStateException("EJB 3.0 does not have a home type.");
- }
-
- public EJBLocalHome getEJBLocalHome()
- {
- throw new IllegalStateException("EJB 3.0 does not have a home type.");
- }
-
- public Properties getEnvironment()
- {
- throw new EJBException("Deprecated");
- }
-
- public void setRollbackOnly() throws IllegalStateException
- {
- // EJB1.1 11.6.1: Must throw IllegalStateException if BMT
- TransactionManagementType type = TxUtil.getTransactionManagementType(getContainer());
- if (type != TransactionManagementType.CONTAINER) throw new IllegalStateException("Container " + getContainer().getEjbName() + ": it is illegal to call setRollbackOnly from BMT: " + type);
-
- try
- {
- TransactionManager tm = TxUtil.getTransactionManager();
-
- // The getRollbackOnly and setRollBackOnly method of the SessionContext interface should be used
- // only in the session bean methods that execute in the context of a transaction.
- if (tm.getTransaction() == null)
- throw new IllegalStateException("setRollbackOnly() not allowed without a transaction.");
-
- tm.setRollbackOnly();
- }
- catch (SystemException e)
- {
- log.warn("failed to set rollback only; ignoring", e);
- }
- }
-
- public boolean getRollbackOnly() throws IllegalStateException
- {
- // EJB1.1 11.6.1: Must throw IllegalStateException if BMT
- TransactionManagementType type = TxUtil.getTransactionManagementType(getContainer());
- if (type != TransactionManagementType.CONTAINER)
- throw new IllegalStateException("Container " + getContainer().getEjbName() + ": it is illegal to call getRollbackOnly from BMT: " + type);
-
- try
- {
- TransactionManager tm = TxUtil.getTransactionManager();
-
- // The getRollbackOnly and setRollBackOnly method of the SessionContext interface should be used
- // only in the session bean methods that execute in the context of a transaction.
- if (tm.getTransaction() == null)
- throw new IllegalStateException("getRollbackOnly() not allowed without a transaction.");
-
- // EJBTHREE-805, consider an asynchronous rollback due to timeout
- int status = tm.getStatus();
- return status == Status.STATUS_MARKED_ROLLBACK
- || status == Status.STATUS_ROLLING_BACK
- || status == Status.STATUS_ROLLEDBACK;
- }
- catch (SystemException e)
- {
- log.warn("failed to get tx manager status; ignoring", e);
- return true;
- }
- }
-}
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/EJBInvocation.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/EJBInvocation.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/EJBInvocation.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -1,165 +0,0 @@
-/*
- * 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;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.HashMap;
-import java.util.Map;
-import org.jboss.aop.advice.Interceptor;
-import org.jboss.aop.joinpoint.Invocation;
-import org.jboss.aop.metadata.SimpleMetaData;
-import org.jboss.aop.metadata.ThreadMetaData;
-import org.jboss.logging.Logger;
-
-/**
- * Comment
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- */
-public abstract class EJBInvocation implements Invocation
-{
- private static final Logger log = Logger.getLogger(EJBInvocation.class);
-
- protected transient Interceptor[] interceptors;
- protected long methodHash;
- protected transient int currentInterceptor = 0;
- protected transient Method method;
- protected Object[] arguments;
- protected SimpleMetaData metadata = null;
- protected transient Map responseContextInfo = null;
-
- protected EJBInvocation(Method method, long methodHash, Object[] arguments, Interceptor[] interceptors)
- {
- this.method = method;
- this.methodHash = methodHash;
- this.arguments = arguments;
- this.interceptors = interceptors;
- }
-
- protected EJBInvocation()
- {
- }
-
- public Object invokeNext() throws Throwable
- {
- if (currentInterceptor < interceptors.length)
- {
- try
- {
- return interceptors[currentInterceptor++].invoke(this);
- }
- finally
- {
- // so that interceptors like clustering can reinvoke down the chain
- currentInterceptor--;
- }
- }
- try
- {
- return method.invoke(getTargetObject(), getArguments());
- }
- catch (InvocationTargetException e)
- {
- throw e.getTargetException();
- }
- }
-
- public Method getMethod()
- {
- return method;
- }
-
- public long getMethodHash()
- {
- return methodHash;
- }
-
- public Interceptor[] getInterceptors()
- {
- return interceptors;
- }
-
- public void setInterceptors(Interceptor[] interceptors)
- {
- this.interceptors = interceptors;
- }
-
- public Object[] getArguments()
- {
- return arguments;
- }
-
- public void setArguments(Object[] args)
- {
- this.arguments = args;
- }
-
- public Object getMetaData(Object key, Object attr)
- {
- // todo: set up the chain for metadata resolving
- Object value = null;
- if (metadata != null) value = metadata.getMetaData(key, attr);
- if (value != null) return value;
- value = ThreadMetaData.instance().getMetaData(key, attr);
- return value;
- }
-
- public Map getResponseContextInfo()
- {
- return responseContextInfo;
- }
-
- public void setResponseContextInfo(Map responseContextInfo)
- {
- this.responseContextInfo = responseContextInfo;
- }
-
- public void addResponseAttachment(Object key, Object val)
- {
- if (responseContextInfo == null) responseContextInfo = new HashMap();
- responseContextInfo.put(key, val);
- }
-
- public Object getResponseAttachment(Object key)
- {
- if (responseContextInfo == null) return null;
- return responseContextInfo.get(key);
- }
-
- public SimpleMetaData getMetaData()
- {
- if (metadata == null) metadata = new SimpleMetaData();
- return metadata;
- }
-
- public void setMetaData(SimpleMetaData data)
- {
- this.metadata = data;
- }
-
- public Object invokeNext(Interceptor[] newInterceptors) throws Throwable
- {
- throw new RuntimeException("NOT IMPLEMENTED");
- }
-}
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/EJBMetaDataLoader.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/EJBMetaDataLoader.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/EJBMetaDataLoader.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -1,182 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., 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;
-
-import java.lang.annotation.Annotation;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.jboss.ejb3.annotation.SecurityDomain;
-import org.jboss.ejb3.annotation.impl.SecurityDomainImpl;
-import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
-import org.jboss.metadata.plugins.loader.BasicMetaDataLoader;
-import org.jboss.metadata.spi.retrieval.AnnotationItem;
-import org.jboss.metadata.spi.retrieval.AnnotationsItem;
-import org.jboss.metadata.spi.retrieval.MetaDataRetrieval;
-import org.jboss.metadata.spi.retrieval.simple.SimpleAnnotationItem;
-import org.jboss.metadata.spi.retrieval.simple.SimpleAnnotationsItem;
-import org.jboss.metadata.spi.scope.ScopeKey;
-import org.jboss.metadata.spi.signature.MethodSignature;
-import org.jboss.metadata.spi.signature.Signature;
-
-/**
- * EJBMetaDataLoader.
- *
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision: 1.1 $
- */
-public class EJBMetaDataLoader extends BasicMetaDataLoader
-{
- /** The container */
- private EJBContainer container;
-
- /** Component cache */
- private Map<Signature, MetaDataRetrieval> cache = new ConcurrentHashMap<Signature, MetaDataRetrieval>();
-
- /**
- * Create a new EJBMetaDataLoader.
- *
- * @param key the scope
- * @param container the container
- */
- public EJBMetaDataLoader(ScopeKey key, EJBContainer container)
- {
- super(key);
- if (container == null)
- throw new IllegalArgumentException("Null container");
- this.container = container;
- }
-
- /**
- * Get the bean metadata
- *
- * @return the bean metadata
- */
- protected JBossEnterpriseBeanMetaData getBeanMetaData()
- {
- return container.getXml();
- }
-
- public MetaDataRetrieval getComponentMetaDataRetrieval(Signature signature)
- {
- JBossEnterpriseBeanMetaData beanMetaData = getBeanMetaData();
- if (beanMetaData == null)
- return null;
-
- if (signature instanceof MethodSignature == false)
- return null;
-
- MetaDataRetrieval retrieval = cache.get(signature);
- if (retrieval != null)
- return retrieval;
-
- retrieval = new MethodMetaDataRetrieval((MethodSignature) signature);
- cache.put(signature, retrieval);
- return retrieval;
- }
-
- public boolean isEmpty()
- {
- return getBeanMetaData() != null;
- }
-
- public <T extends Annotation> AnnotationItem<T> retrieveAnnotation(Class<T> annotationType)
- {
- JBossEnterpriseBeanMetaData beanMetaData = getBeanMetaData();
- if (beanMetaData == null)
- return null;
-
- if (annotationType == SecurityDomain.class)
- {
- String securityDomain = beanMetaData.getSecurityDomain();
- if (securityDomain != null)
- return new SimpleAnnotationItem(new SecurityDomainImpl(securityDomain));
- }
- return null;
- }
-
- public AnnotationsItem retrieveAnnotations()
- {
- List<AnnotationItem> annotations = new ArrayList<AnnotationItem>();
- AnnotationItem annotation = retrieveAnnotation(SecurityDomain.class);
- if (annotation != null)
- annotations.add(annotation);
- if (annotations.isEmpty())
- return SimpleAnnotationsItem.NO_ANNOTATIONS;
- else
- return new SimpleAnnotationsItem(annotations.toArray(new AnnotationItem[annotations.size()]));
- }
-
- /**
- * MethodMetaDataRetrieval.
- */
- private class MethodMetaDataRetrieval extends BasicMetaDataLoader
- {
- /** The signature */
- private MethodSignature signature;
-
- /**
- * Create a new MethodMetaDataRetrieval.
- *
- * @param methodSignature the signature
- */
- public MethodMetaDataRetrieval(MethodSignature methodSignature)
- {
- this.signature = methodSignature;
- }
-
- public MetaDataRetrieval getComponentMetaDataRetrieval(Signature signature)
- {
- return null;
- }
-
- public boolean isEmpty()
- {
- return false;
- }
-
- public <T extends Annotation> AnnotationItem<T> retrieveAnnotation(Class<T> annotationType)
- {
- /* Example
- JBossEnterpriseBeanMetaData beanMetaData = getBeanMetaData();
- if (beanMetaData == null)
- return null;
-
- if (annotationType == TransactionTimeout.class)
- {
- MethodAttributesMetaData methodAttributes = beanMetaData.getMethodAttributes();
- int timeout = methodAttributes.getMethodTransactionTimeout(signature.getName());
- return new SimpleAnnotationItem(new TransactionTimeoutImpl(timeout));
- }
- */
- return null;
- }
-
- public AnnotationsItem retrieveAnnotations()
- {
- // TODO
- return SimpleAnnotationsItem.NO_ANNOTATIONS;
- }
- }
-}
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/EJBProxyFactory.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/EJBProxyFactory.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/EJBProxyFactory.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -1,132 +0,0 @@
-/*
- * 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;
-
-import java.util.Collection;
-
-import javax.ejb.EJBMetaData;
-
-import org.jboss.invocation.Invocation;
-import org.jboss.metadata.InvokerProxyBindingMetaData;
-
-import org.jboss.ejb.GenericEntityObjectFactory;
-
-/**
- * This is an interface for Container plugins. Implementations of this
- * interface are responsible for receiving remote invocations of EJB's
- * and to forward these requests to the Container it is being used with.
- *
- * <p>It is responsible for providing any EJBObject and EJBHome
- * implementations (which may be statically or dynamically created).
- *
- * <p>Before forwarding a call to the container it must call
- * Thread.setContextClassLoader() with the classloader of the container.
- * It must also handle any propagated transaction and security contexts
- * properly. It may acquire the TransactionManager from JNDI.
- *
- * @see Container
- *
- * @author <a href="mailto:rickard.oberg at telkel.com">Rickard �berg</a>
- * @author <a href="mailto:marc.fleury at telkel.com">Marc Fleury</a>
- * @version $Revision$
- *
- *<p><b>20011219 marc fleury:</b>
-* <ul>
-* <li>Moved from typed return to Object to allow for optimizations in creation
-* <li>Per Dain Sundstrom requests removed the Remote Exception.
-* <li>The Container Invoker is going to be replaced by the ProxyFactory
-*</ul>
- */
-public interface EJBProxyFactory
-extends GenericEntityObjectFactory, ContainerPlugin
-{
- /**
- * Set the invoker meta data so that the ProxyFactory can initialize properly
- */
- void setInvokerMetaData(InvokerProxyBindingMetaData imd);
- /**
- * Set the invoker jndi binding
- */
- void setInvokerBinding(String binding);
- /**
- * Protocol specific isIdentical implementation
- *
- * @param container the container
- * @param mi the invocation
- * @return true when identical, false otherwise
- */
- boolean isIdentical(Container container, Invocation mi);
- /**
- * This method is called whenever the metadata for this container is
- * needed.
- *
- * @return An implementation of the EJBMetaData interface.
- */
- EJBMetaData getEJBMetaData();
-
- /**
- * This method is called whenever the EJBHome implementation for this
- * container is needed.
- *
- * @return An implementation of the home interface for this container.
- */
- Object getEJBHome();
-
- /**
- * This method is called whenever an EJBObject implementation for a
- * stateless session bean is needed.
- *
- * @return An implementation of the remote interface for this container.
- */
- Object getStatelessSessionEJBObject();
-
- /**
- * This method is called whenever an EJBObject implementation for a stateful
- * session bean is needed.
- *
- * @param id The id of the session.
- * @return An implementation of the remote interface for this
- * container.
- */
- Object getStatefulSessionEJBObject(Object id);
-
- /**
- * This method is called whenever an EJBObject implementation for an
- * entitybean is needed.
- *
- * @param id The primary key of the entity.
- * @return An implementation of the remote interface for this
- * container.
- */
- Object getEntityEJBObject(Object id);
-
- /**
- * This method is called whenever a collection of EJBObjects for a
- * collection of primary keys is needed.
- *
- * @param en Enumeration of primary keys.
- * @return A collection of EJBObjects implementing the remote
- * interface for this container.
- */
- Collection getEntityCollection(Collection en);
-}
-
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/ENCPropagationInterceptor.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/ENCPropagationInterceptor.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/ENCPropagationInterceptor.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -1,48 +0,0 @@
-/*
- * 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;
-
-import org.jboss.aop.joinpoint.Invocation;
-import org.jboss.ejb3.aop.AbstractInterceptor;
-
-/**
- * This interceptor is needed so that the ENC is propagated in asynchronous calls.
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- */
-public class ENCPropagationInterceptor extends AbstractInterceptor
-{
- public Object invoke(Invocation invocation) throws Throwable
- {
- EJBContainer container = getEJBContainer(invocation);
- try
- {
- container.pushEnc();
- return invocation.invokeNext();
- }
- finally
- {
- container.popEnc();
- }
- }
-}
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/Ejb3AnnotationHandler.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/Ejb3AnnotationHandler.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/Ejb3AnnotationHandler.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -1,412 +0,0 @@
-/*
- * 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;
-
-import java.util.ArrayList;
-import java.util.Hashtable;
-import java.util.List;
-
-import javassist.bytecode.AnnotationsAttribute;
-import javassist.bytecode.ClassFile;
-import javassist.bytecode.annotation.Annotation;
-import javassist.bytecode.annotation.StringMemberValue;
-
-import javax.ejb.TransactionAttribute;
-import javax.ejb.TransactionAttributeType;
-
-import org.jboss.aop.AspectManager;
-import org.jboss.aop.Domain;
-import org.jboss.aop.DomainDefinition;
-import org.jboss.ejb3.mdb.ConsumerContainer;
-import org.jboss.ejb3.mdb.MDB;
-import org.jboss.ejb3.service.ServiceContainer;
-import org.jboss.ejb3.stateful.StatefulContainer;
-import org.jboss.ejb3.stateless.StatelessContainer;
-import org.jboss.logging.Logger;
-import org.jboss.metadata.ejb.jboss.JBossConsumerBeanMetaData;
-import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
-import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeansMetaData;
-import org.jboss.metadata.ejb.jboss.JBossMessageDrivenBeanMetaData;
-import org.jboss.metadata.ejb.jboss.JBossMetaData;
-import org.jboss.metadata.ejb.jboss.JBossServiceBeanMetaData;
-import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
-
-/**
- * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
- * @author <a href="mailto:bill at jboss.com">Bill Burke</a>
- * @version <tt>$Revision$</tt>
- */
-public class Ejb3AnnotationHandler implements Ejb3Handler
-{
- private static final Logger log = Logger.getLogger(Ejb3AnnotationHandler.class);
-
- protected static enum EJB_TYPE
- {
- STATELESS, STATEFUL, MESSAGE_DRIVEN, ENTITY, SERVICE, CONSUMER
- }
-
- protected DeploymentUnit di;
-
- protected ClassFile cf;
- protected List<String> ejbNames = new ArrayList<String>();
- protected Class<?> ejbClass;
- protected String className;
- protected EJB_TYPE ejbType;
- protected Annotation annotation;
- protected AnnotationsAttribute visible;
- protected Hashtable ctxProperties;
- protected String defaultSLSBDomain;
- protected String defaultSFSBDomain;
- protected String defaultMDBDomain;
- protected String defaultServiceDomain;
- protected String defaultConsumerDomain;
- protected Ejb3Deployment deployment;
-
- public Ejb3AnnotationHandler(Ejb3Deployment deployment)
- {
- this.deployment = deployment;
- this.di = deployment.getDeploymentUnit();
- defaultSLSBDomain = deployment.getDefaultSLSBDomain();
- defaultSFSBDomain = deployment.getDefaultSFSBDomain();
- defaultMDBDomain = deployment.getDefaultMDBDomain();
- defaultServiceDomain = deployment.getDefaultServiceDomain();
- defaultConsumerDomain = deployment.getDefaultConsumerDomain();
- }
-
- public Ejb3AnnotationHandler(Ejb3Deployment deployment, ClassFile cf)
- {
- this.deployment = deployment;
- this.di = deployment.getDeploymentUnit();
- defaultSLSBDomain = deployment.getDefaultSLSBDomain();
- defaultSFSBDomain = deployment.getDefaultSFSBDomain();
- defaultMDBDomain = deployment.getDefaultMDBDomain();
- defaultServiceDomain = deployment.getDefaultServiceDomain();
- defaultConsumerDomain = deployment.getDefaultConsumerDomain();
-
- this.cf = cf;
- className = cf.getName();
- visible = (AnnotationsAttribute) cf.getAttribute(AnnotationsAttribute.visibleTag);
- }
-
- /**
- * The link from an enterprise bean to it's interceptors is via the EJB Jar meta data.
- * So we try to recreate that link it's not already established.
- *
- * Because of a bug in jboss-metadata an annotated bean will not always
- * get some meta data, so we create some for it.
- *
- * TODO: JBMETA-4
- *
- * @param <M>
- * @param deployment
- * @param ejbName
- * @param enterpriseBeanMetaDataClass
- * @return
- */
- private <M extends JBossEnterpriseBeanMetaData> M getEnterpriseBeanMetaData(Ejb3Deployment deployment, String ejbName, Class<M> enterpriseBeanMetaDataClass)
- {
- JBossMetaData ejbJarMetaData = deployment.getMetaData();
- // If there is no meta data at all, don't establish the link.
- if(ejbJarMetaData == null)
- return null;
-
- M beanMetaData = deployment.getEnterpriseBeanMetaData(ejbName, enterpriseBeanMetaDataClass);
- if(beanMetaData == null)
- {
- log.warn("JBMETA-4: did not find any bean meta data for annotation bean " + ejbName + ", will create some");
- try
- {
- beanMetaData = enterpriseBeanMetaDataClass.newInstance();
- }
- catch (InstantiationException e)
- {
- throw new RuntimeException();
- }
- catch (IllegalAccessException e)
- {
- throw new RuntimeException();
- }
- beanMetaData.setEjbName(ejbName);
- JBossEnterpriseBeansMetaData enterpriseBeans = ejbJarMetaData.getEnterpriseBeans();
- if(enterpriseBeans == null)
- {
- enterpriseBeans = new JBossEnterpriseBeansMetaData();
- ejbJarMetaData.setEnterpriseBeans(enterpriseBeans);
- }
- enterpriseBeans.add(beanMetaData);
- }
- return beanMetaData;
- }
-
- public void setCtxProperties(Hashtable ctxProperties)
- {
- this.ctxProperties = ctxProperties;
- }
-
- protected String getJaccContextId()
- {
- return di.getShortName();
- }
-
- public boolean isEjb()
- {
- if (visible == null) return false;
-
- if (EJB3Util.isStateless(visible)) return true;
- if (EJB3Util.isMessageDriven(visible)) return true;
- if (EJB3Util.isStatefulSession(visible)) return true;
- return false;
- }
-
- public boolean isJBossBeanType()
- {
- if (visible == null) return false;
-
- if (EJB3Util.isService(visible)) return true;
- if (EJB3Util.isConsumer(visible)) return true;
- return false;
- }
-
- public List getContainers(ClassFile cf, Ejb3Deployment deployment) throws Exception
- {
- List<EJBContainer> containers = new ArrayList<EJBContainer>();
-
- populateBaseInfo();
-
- // TODO: because Ejb3Deployment.deploy will first do annotation deployments
- // and then meta data deployments, bean meta data will never be attached to
- // the container. So we do it here.
- for (int ejbIndex = 0; ejbIndex < ejbNames.size(); ++ejbIndex)
- {
- String ejbName = ejbNames.get(ejbIndex);
- if (ejbType == EJB_TYPE.STATELESS)
- {
- EJBContainer container = getStatelessContainer(ejbIndex, getEnterpriseBeanMetaData(deployment, ejbName, JBossSessionBeanMetaData.class));
- container.setJaccContextId(getJaccContextId());
- containers.add(container);
- }
- else if (ejbType == EJB_TYPE.STATEFUL)
- {
- StatefulContainer container = getStatefulContainer(ejbIndex, getEnterpriseBeanMetaData(deployment, ejbName, JBossSessionBeanMetaData.class));
- container.setJaccContextId(getJaccContextId());
- containers.add(container);
- }
- else if (ejbType == EJB_TYPE.MESSAGE_DRIVEN)
- {
- MDB container = getMDB(ejbIndex, getEnterpriseBeanMetaData(deployment, ejbName, JBossMessageDrivenBeanMetaData.class));
- validateMDBTransactionAttribute(container);
- container.setJaccContextId(getJaccContextId());
- containers.add(container);
- }
- else if (ejbType == EJB_TYPE.SERVICE)
- {
- ServiceContainer container = getServiceContainer(ejbIndex, getEnterpriseBeanMetaData(deployment, ejbName, JBossServiceBeanMetaData.class));
- container.setJaccContextId(getJaccContextId());
- containers.add(container);
- }
- else if (ejbType == EJB_TYPE.CONSUMER)
- {
- ConsumerContainer container = getConsumerContainer(ejbIndex, getEnterpriseBeanMetaData(deployment, ejbName, JBossConsumerBeanMetaData.class));
- container.setJaccContextId(getJaccContextId());
- containers.add(container);
- }
- log.debug("found EJB3: ejbName=" + ejbName + ", class=" + className + ", type=" + ejbType);
- }
-
- return containers;
- }
-
- protected void validateMDBTransactionAttribute(MDB mdb)
- {
- TransactionAttribute tx = (TransactionAttribute)mdb.resolveAnnotation(TransactionAttribute.class);
- if (tx != null)
- {
- TransactionAttributeType type = tx.value();
- if (type != TransactionAttributeType.REQUIRED && type != TransactionAttributeType.NOT_SUPPORTED)
- throw new RuntimeException("MDB " + mdb.getEjbName() + " has an invalid TransactionAttribute: " + type +
- ". Only REQUIRED and NOT_SUPPORTED are valid");
- }
- }
-
- protected String getAspectDomain(int ejbIndex, String defaultDomain)
- {
- return EJB3Util.getAspectDomain(visible, defaultDomain);
- }
-
- protected ServiceContainer getServiceContainer(int ejbIndex, JBossServiceBeanMetaData beanMetaData) throws Exception
- {
- String containerName = getAspectDomain(ejbIndex, defaultServiceDomain);
- DomainDefinition domain = AspectManager.instance().getContainer(containerName);
-
- if (domain == null)
- throw new RuntimeException("No container configured with name '"
- + containerName + "''");
-
- return new ServiceContainer(deployment.getMbeanServer(), di.getClassLoader(), className,
- ejbNames.get(ejbIndex), (Domain) domain.getManager(), ctxProperties,
- deployment, beanMetaData);
-
- }
-
- protected ConsumerContainer getConsumerContainer(int ejbIndex, JBossConsumerBeanMetaData beanMetaData) throws Exception
- {
- String containerName = getAspectDomain(ejbIndex, defaultConsumerDomain);
- DomainDefinition domain = AspectManager.instance().getContainer(containerName);
-
- if (domain == null)
- throw new RuntimeException("No container configured with name '"
- + containerName + "''");
-
- return new ConsumerContainer(ejbNames.get(ejbIndex), (Domain) domain.getManager(),
- di.getClassLoader(), className, ctxProperties,
- deployment, beanMetaData);
-
- }
-
- protected StatefulContainer getStatefulContainer(int ejbIndex, JBossSessionBeanMetaData beanMetaData) throws Exception
- {
- String containerName = getAspectDomain(ejbIndex, defaultSFSBDomain);
- DomainDefinition domain = AspectManager.instance().getContainer(containerName);
-
- if (domain == null)
- throw new RuntimeException("No container configured with name '"
- + containerName + "''");
-
- return new StatefulContainer(di.getClassLoader(), className,
- ejbNames.get(ejbIndex), (Domain) domain.getManager(), ctxProperties,
- deployment, beanMetaData);
-
- }
-
- protected EJBContainer getStatelessContainer(int ejbIndex, JBossSessionBeanMetaData beanMetaData) throws Exception
- {
- String containerName = getAspectDomain(ejbIndex, defaultSLSBDomain);
-
- DomainDefinition domain = AspectManager.instance().getContainer(containerName);
-
- if (domain == null)
- throw new RuntimeException("No container configured with name '"
- + containerName + "''");
-
- return new StatelessContainer(di.getClassLoader(), className,
- ejbNames.get(ejbIndex), (Domain) domain.getManager(),
- ctxProperties, deployment, beanMetaData);
- }
-
- protected String getMDBDomainName(int ejbIndex)
- {
- return defaultMDBDomain;
- }
-
- protected void createProxyFactories()
- {
-
- }
-
- protected MDB getMDB(int ejbIndex, JBossMessageDrivenBeanMetaData beanMetaData) throws Exception
- {
- String domainName = getMDBDomainName(ejbIndex);
-
- String containerName = getAspectDomain(ejbIndex, domainName);
- DomainDefinition domain = AspectManager.instance().getContainer(containerName);
-
- if (domain == null)
- throw new RuntimeException("No container configured with name '"
- + containerName + "''");
-
- MDB container = new MDB(ejbNames.get(ejbIndex), (Domain) domain.getManager(), di.getClassLoader(), className,
- ctxProperties, deployment, beanMetaData);
-
- return container;
- }
-
- protected void populateBaseInfo() throws Exception
- {
- String ejbName = null;
- ejbClass = di.getClassLoader().loadClass(className);
-
- visible = (AnnotationsAttribute) cf.getAttribute(AnnotationsAttribute.visibleTag);
-
- if (visible != null)
- {
- annotation = visible.getAnnotation(javax.ejb.Stateless.class.getName());
- if (annotation != null)
- {
- ejbType = EJB_TYPE.STATELESS;
- }
- else
- {
- annotation = visible.getAnnotation(javax.ejb.Stateful.class.getName());
- if (annotation != null)
- {
- ejbType = EJB_TYPE.STATEFUL;
- }
- else
- {
- annotation = visible.getAnnotation(javax.persistence.Entity.class.getName());
- if (annotation != null)
- {
- ejbType = EJB_TYPE.ENTITY;
- }
- else
- {
- annotation = visible.getAnnotation(javax.ejb.MessageDriven.class.getName());
- if (annotation != null)
- {
- ejbType = EJB_TYPE.MESSAGE_DRIVEN;
- }
- else
- {
- annotation = visible.getAnnotation(org.jboss.ejb3.annotation.Service.class.getName());
- if (annotation != null)
- {
- ejbType = EJB_TYPE.SERVICE;
- }
- else
- {
- annotation = visible.getAnnotation(org.jboss.ejb3.annotation.Consumer.class.getName());
- if (annotation != null)
- {
- ejbType = EJB_TYPE.CONSUMER;
- }
- }
- }
- }
- }
- }
-
- if (annotation != null)
- {
- StringMemberValue mv = (StringMemberValue) annotation.getMemberValue("name");
- if (mv != null)
- ejbName = mv.getValue();
- else
- ejbName = ejbClass.getSimpleName();
- }
- }
-
- if (ejbName != null)
- {
- ejbNames.add(ejbName);
- }
- }
-}
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/Ejb3Deployment.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/Ejb3Deployment.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/Ejb3Deployment.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -1,764 +0,0 @@
-/*
- * 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;
-
-import java.io.BufferedInputStream;
-import java.io.DataInputStream;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-import javassist.bytecode.ClassFile;
-
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-import javax.naming.InitialContext;
-import javax.naming.NameNotFoundException;
-import javax.naming.NamingException;
-import javax.persistence.Entity;
-import javax.security.jacc.PolicyConfiguration;
-import javax.security.jacc.PolicyConfigurationFactory;
-
-import org.hibernate.ejb.packaging.PersistenceMetadata;
-import org.jboss.deployers.spi.DeploymentException;
-import org.jboss.ejb3.cache.CacheFactoryRegistry;
-import org.jboss.ejb3.cache.persistence.PersistenceManagerFactoryRegistry;
-import org.jboss.ejb3.deployers.Ejb3Deployer;
-import org.jboss.ejb3.enc.EjbModuleEjbResolver;
-import org.jboss.ejb3.enc.EjbModulePersistenceUnitResolver;
-import org.jboss.ejb3.enc.MessageDestinationResolver;
-import org.jboss.ejb3.entity.PersistenceUnitDeployment;
-import org.jboss.ejb3.entity.SecondLevelCacheUtil;
-import org.jboss.ejb3.javaee.JavaEEApplication;
-import org.jboss.ejb3.javaee.JavaEEComponent;
-import org.jboss.ejb3.javaee.JavaEEModule;
-import org.jboss.ejb3.metadata.jpa.spec.PersistenceUnitMetaData;
-import org.jboss.ejb3.metadata.jpa.spec.PersistenceUnitsMetaData;
-import org.jboss.ejb3.remoting.RemoteProxyFactoryRegistry;
-import org.jboss.logging.Logger;
-import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
-import org.jboss.metadata.ejb.jboss.JBossMetaData;
-import org.jboss.metadata.javaee.spec.MessageDestinationsMetaData;
-import org.jboss.virtual.VirtualFile;
-
-/**
- * An EjbModule represents a collection of beans that are deployed as a unit.
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @author adrian at jboss.org
- * @version $Revision$
- */
-public abstract class Ejb3Deployment implements JavaEEModule
-{
- private static final Logger log = Logger.getLogger(Ejb3Deployment.class);
-
- public static final String ACTUAL_ENTITY_MANAGER_FACTORY_CONTEXT = "java:/ActualEntityManagerFactories";
-
- public static final String MANAGED_ENTITY_FACTORY_CONTEXT = "java:/managedEntityFactories";
-
- private JBossMetaData metaData;
-
- private PersistenceUnitsMetaData persistenceUnitsMetaData;
-
- protected DeploymentUnit unit;
-
- protected Ejb3Deployer deployer;
-
- protected LinkedHashMap<ObjectName, Container> ejbContainers = new LinkedHashMap<ObjectName, Container>();
-
- protected boolean hasEntities;
-
- protected List<String> explicitEntityClasses = new ArrayList<String>();
-
- protected List<PersistenceUnitDeployment> persistenceUnitDeployments = new ArrayList<PersistenceUnitDeployment>();;
-
- protected String defaultSLSBDomain = "Stateless Bean";
-
- protected String defaultSFSBDomain = "Stateful Bean";
-
- protected String defaultMDBDomain = "Message Driven Bean";
-
- protected String defaultConsumerDomain = "Consumer Bean";
-
- protected String defaultServiceDomain = "Service Bean";
-
- protected InitialContext initialContext;
-
- protected KernelAbstraction kernelAbstraction;
-
- // used for @Management interfaces
- protected MBeanServer mbeanServer;
-
- protected DeploymentScope deploymentScope;
-
- protected EjbModuleEjbResolver ejbRefResolver;
-
- protected EjbModulePersistenceUnitResolver persistenceUnitResolver;
-
- protected MessageDestinationResolver messageDestinationResolver;
-
- //The JACC PolicyConfiguration
- PolicyConfiguration pc;
-
- public Ejb3Deployment(DeploymentUnit unit, DeploymentScope deploymentScope, JBossMetaData metaData, PersistenceUnitsMetaData persistenceUnitsMetaData,
- Ejb3Deployer deployer)
- {
- assert unit != null : "unit is null";
- assert deployer != null : "deployer is null";
-
- this.unit = unit;
- this.deployer = deployer;
- this.deploymentScope = deploymentScope;
- this.metaData = metaData;
- this.persistenceUnitsMetaData = persistenceUnitsMetaData;
- try
- {
- initialContext = InitialContextFactory.getInitialContext(unit.getJndiProperties());
- }
- catch (NamingException e)
- {
- throw new RuntimeException(e);
- }
- ejbRefResolver = new EjbModuleEjbResolver(deploymentScope, unit.getShortName(), ejbContainers, this);
- persistenceUnitResolver = new EjbModulePersistenceUnitResolver(persistenceUnitDeployments, deploymentScope,
- ejbContainers);
- MessageDestinationsMetaData destinations = null;
- if (metaData != null && metaData.getAssemblyDescriptor() != null)
- destinations = metaData.getAssemblyDescriptor().getMessageDestinations();
- messageDestinationResolver = new MessageDestinationResolver(deploymentScope, destinations);
- }
-
- public JavaEEApplication getApplication()
- {
- return deploymentScope;
- }
-
- public DeploymentScope getEar()
- {
- return deploymentScope;
- }
-
- public KernelAbstraction getKernelAbstraction()
- {
- return kernelAbstraction;
- }
-
- public MBeanServer getMbeanServer()
- {
- return mbeanServer;
- }
-
- public void setMbeanServer(MBeanServer mbeanServer)
- {
- this.mbeanServer = mbeanServer;
- }
-
- public DeploymentUnit getDeploymentUnit()
- {
- return unit;
- }
-
- public String getDefaultSLSBDomain()
- {
- return defaultSLSBDomain;
- }
-
- public Ejb3Deployer getDeployer()
- {
- return this.deployer;
- }
-
- public CacheFactoryRegistry getCacheFactoryRegistry()
- {
- return this.getDeployer().getCacheFactoryRegistry();
- }
-
- public RemoteProxyFactoryRegistry getRemoteProxyFactoryRegistry()
- {
- return this.getDeployer().getRemoteProxyFactoryRegistry();
- }
-
- public PersistenceManagerFactoryRegistry getPersistenceManagerFactoryRegistry()
- {
- return this.getDeployer().getPersistenceManagerFactoryRegistry();
- }
-
- /**
- * Returns a partial MBean attribute name of the form
- * ",ear=foo.ear,jar=foo.jar"
- *
- * @return
- */
- public String getScopeKernelName()
- {
- String scopedKernelName = "";
- if (deploymentScope != null)
- scopedKernelName += ",ear=" + deploymentScope.getShortName();
- scopedKernelName += ",jar=" + unit.getShortName();
- return scopedKernelName;
- }
-
- /**
- * The default AOP domain for stateless session beans
- *
- * @param defaultSLSBDomain
- */
- public void setDefaultSLSBDomain(String defaultSLSBDomain)
- {
- this.defaultSLSBDomain = defaultSLSBDomain;
- }
-
- public String getDefaultSFSBDomain()
- {
- return defaultSFSBDomain;
- }
-
- public String getDefaultConsumerDomain()
- {
- return defaultConsumerDomain;
- }
-
- /**
- * The default stateful session bean aspect domain
- *
- * @param defaultSFSBDomain
- */
- public void setDefaultSFSBDomain(String defaultSFSBDomain)
- {
- this.defaultSFSBDomain = defaultSFSBDomain;
- }
-
- public String getDefaultMDBDomain()
- {
- return defaultMDBDomain;
- }
-
- /**
- * The default AOP domain for message driven beans.
- *
- * @param defaultMDBDomain
- */
- public void setDefaultMDBDomain(String defaultMDBDomain)
- {
- this.defaultMDBDomain = defaultMDBDomain;
- }
-
- public String getDefaultServiceDomain()
- {
- return defaultServiceDomain;
- }
-
- /**
- * default AOP domain for service beans.
- *
- * @param defaultServiceDomain
- */
- public void setDefaultServiceDomain(String defaultServiceDomain)
- {
- this.defaultServiceDomain = defaultServiceDomain;
- }
-
- protected String getJaccContextId()
- {
- return unit.getShortName();
- }
-
- public Container getContainer(ObjectName name)
- {
- return (Container) ejbContainers.get(name);
- }
-
- public java.util.Map getEjbContainers()
- {
- return ejbContainers;
- }
-
- public PersistenceUnitDeployment getPersistenceUnitDeployment(String unitName) throws NameNotFoundException
- {
- return persistenceUnitResolver.getPersistenceUnitDeployment(unitName);
- }
-
- public PersistenceUnitDeployment getPersistenceUnitDeploymentInternal(String unitName)
- {
- return persistenceUnitResolver.getPersistenceUnitDeploymentInternal(unitName);
- }
-
- public List<PersistenceUnitDeployment> getPersistenceUnitDeployments()
- {
- return persistenceUnitDeployments;
- }
-
- public EJBContainer getEjbContainer(String ejbLink, Class businessIntf)
- {
- return ejbRefResolver.getEjbContainer(ejbLink, businessIntf);
- }
-
- public String getEjbJndiName(String ejbLink, Class businessIntf)
- {
- return ejbRefResolver.getEjbJndiName(ejbLink, businessIntf);
- }
-
- public EJBContainer getEjbContainer(Ejb3Deployment deployment, Class businessIntf) throws NameNotFoundException
- {
- return ejbRefResolver.getEjbContainer(deployment, businessIntf);
- }
-
- public EJBContainer getEjbContainer(Class businessIntf) throws NameNotFoundException
- {
- return ejbRefResolver.getEjbContainer(businessIntf);
- }
-
- public String getEjbJndiName(Class businessIntf) throws NameNotFoundException
- {
- return ejbRefResolver.getEjbJndiName(businessIntf);
- }
-
- protected void processEJBContainerMetadata(Container container) throws Exception
- {
- log.trace("Process EJB container metadata " + container);
- ObjectName on = container.getObjectName();
- ejbContainers.put(on, container);
- container.processMetadata();
- }
-
- protected void registerEJBContainer(Container container) throws Exception
- {
- ObjectName on = container.getObjectName();
- String name = on.getCanonicalName();
- DependencyPolicy dependsPolicy = container.getDependencyPolicy();
- dependsPolicy.addDependency("jboss.ejb:service=EJBTimerService");
- kernelAbstraction.install(name, dependsPolicy, container);
- mbeanServer.registerMBean(container.getMBean(), on);
- log.debug("Bound ejb3 container " + name);
- }
-
- protected abstract PolicyConfiguration createPolicyConfiguration() throws Exception;
-
- protected abstract void putJaccInService(PolicyConfiguration pc, DeploymentUnit unit);
-
- /**
- * Create all EJB containers and Persistence Units
- * The only things that should be initialized is metadata that does not need access to any
- * other deployment. This is because we want the entire EAR to be initialized so that we do not
- * have to guess on dependencies MBean names. This is because of the silly scoping rules for persistence units
- * and EJBs.
- *
- * @throws Exception
- */
- public void create() throws Exception
- {
- try
- {
- long start = System.currentTimeMillis();
-
- pc = createPolicyConfiguration();
-
- deploy();
-
- initializePersistenceUnits();
-
- log.debug("EJB3 deployment time took: " + (System.currentTimeMillis() - start));
- }
- catch (Exception e)
- {
- try
- {
- destroy();
- }
- catch (Exception ignored)
- {
- // ignore
- }
- throw e;
- }
- }
-
- public void start() throws Exception
- {
- try
- {
- startPersistenceUnits();
-
- for (Object o : ejbContainers.values())
- {
- Container con = (Container) o;
- processEJBContainerMetadata(con);
- }
-
- for (Object o : ejbContainers.values())
- {
- Container con = (Container) o;
- registerEJBContainer(con);
- }
-
- putJaccInService(pc, unit);
- }
- catch (Exception ex)
- {
- try
- {
- stop();
- destroy();
- }
- catch (Exception ignored)
- {
- }
- throw ex;
- }
- }
-
- protected void deploy() throws Exception
- {
- Ejb3HandlerFactory factory = Ejb3HandlerFactory.getInstance(this);
- if (unit.getUrl() != null)
- deployUrl(factory);
-
- if (unit.getClasses() != null)
- {
- for (Class explicit : unit.getClasses())
- {
- if (explicit.isAnnotationPresent(Entity.class))
- {
- continue;
- }
- String name = explicit.getName().replace('.', '/') + ".class";
- InputStream stream = explicit.getClassLoader().getResourceAsStream(name);
- deployElement(stream, factory, initialContext);
- }
- }
-
- deployBeansFromLib(initialContext);
- }
-
- protected void deployUrl(Ejb3HandlerFactory factory) throws Exception
- {
- // make sure we are not deploying ejbs from client jar
- List<VirtualFile> clientDescriptors = unit.getResources(new org.jboss.ejb3.ClientDescriptorFileFilter());
-
- if (clientDescriptors.size() > 0)
- return;
-
- InitialContext ctx = initialContext;
- // need to look into every entry in the archive to see if anybody has tags
- // defined.
- List<VirtualFile> classes = unit.getResources(new org.jboss.ejb3.ClassFileFilter());
- for (VirtualFile classFile : classes)
- {
- InputStream stream = classFile.openStream();
- deployElement(stream, factory, ctx);
- }
- }
-
- protected void deployElement(InputStream stream, Ejb3HandlerFactory factory, InitialContext ctx) throws Exception
- {
- DataInputStream dstream = new DataInputStream(new BufferedInputStream(stream));
- ClassFile cf = null;
- try
- {
- cf = new ClassFile(dstream);
- }
- finally
- {
- dstream.close();
- stream.close();
- }
-
- deployElement(factory, cf, ctx);
-
- }
-
- protected void deployBeansFromLib(InitialContext ctx) throws Exception
- {
- JBossMetaData dd = getMetaData();
- if (dd != null)
- {
- Ejb3DescriptorHandler handler = new Ejb3DescriptorHandler(this, dd);
- handler.setCtxProperties(unit.getJndiProperties());
-
- Map<String, Container> localContainers = new HashMap<String, Container>();
- Iterator<Container> containerIterator = ejbContainers.values().iterator();
- while (containerIterator.hasNext())
- {
- Container container = containerIterator.next();
- localContainers.put(container.getEjbName(), container);
- }
-
- List<Container> containers = handler.getContainers(this, localContainers);
- for (Container con : containers)
- {
- // EJBContainer has finished with all metadata initialization from XML files and such.
- // this is really a hook to do some processing after XML has been set up and before
- // and processing of dependencies and such.
- ((EJBContainer) con).instantiated();
- this.ejbContainers.put(con.getObjectName(), con);
- Ejb3Registry.register(con);
- }
- }
- }
-
- protected void deployElement(Ejb3HandlerFactory factory, ClassFile cf, InitialContext ctx) throws Exception
- {
- Ejb3Handler handler = factory.createHandler(cf);
- handler.setCtxProperties(unit.getJndiProperties());
-
- if (handler.isEjb() || handler.isJBossBeanType())
- {
- List<Container> containers = handler.getContainers(cf, this);
- for (Container con : containers)
- {
- // EJBContainer has finished with all metadata initialization from XML files and such.
- // this is really a hook to do some processing after XML has been set up and before
- // and processing of dependencies and such.
- try
- {
- ((EJBContainer) con).instantiated();
- this.ejbContainers.put(con.getObjectName(), con);
- Ejb3Registry.register(con);
- }
- catch (Throwable t)
- {
- throw new DeploymentException(
- "Error creating ejb container " + con.getEjbName() + ": " + t.getMessage(), t);
- }
- }
- }
- }
-
- protected void initializePersistenceUnits() throws Exception
- {
- hasEntities = persistenceUnitsMetaData != null;
-
- if (!hasEntities)
- return;
-
- if (unit.getClasses() != null)
- {
- for (Class<?> explicit : unit.getClasses())
- {
- if (explicit.isAnnotationPresent(Entity.class))
- {
- explicitEntityClasses.add(explicit.getName());
- }
- }
- }
-
- // scope the unitName if this is an ejb archive
- // todo revert to this: List<PersistenceMetadata> persistenceMetadata = PersistenceXmlLoader.deploy(persistenceXmlUrl, new HashMap(), new EJB3DTDEntityResolver());
- for (PersistenceUnitMetaData persistenceUnitMetaData : persistenceUnitsMetaData)
- {
- PersistenceMetadata metadata = persistenceUnitMetaData.getLegacyMetadata();
-
- String earShortName = deploymentScope == null ? null : deploymentScope.getShortName();
- boolean isScoped = ejbContainers.size() > 0;
-
- // Ensure 2nd level cache entries are segregated from other deployments
- String cache_prefix = metadata.getProps().getProperty(SecondLevelCacheUtil.HIBERNATE_CACHE_REGION_PREFIX);
- if (cache_prefix == null)
- {
- // Create a region_prefix for the 2nd level cache to ensure
- // deployments are segregated
- String jarName = isScoped ? unit.getShortName() : null;
- cache_prefix = SecondLevelCacheUtil.createCacheRegionPrefix(earShortName, jarName, metadata.getName());
- metadata.getProps().setProperty(SecondLevelCacheUtil.HIBERNATE_CACHE_REGION_PREFIX, cache_prefix);
- }
- PersistenceUnitDeployment deployment = new PersistenceUnitDeployment(initialContext, this,
- explicitEntityClasses, persistenceUnitMetaData, earShortName, unit.getShortName(), isScoped);
- PersistenceUnitRegistry.register(deployment);
- persistenceUnitDeployments.add(deployment);
- }
- }
-
- public abstract DependencyPolicy createDependencyPolicy(JavaEEComponent component);
-
- protected void startPersistenceUnits()
- {
- if (persistenceUnitDeployments == null)
- return;
-
- for (PersistenceUnitDeployment entityDeployment : persistenceUnitDeployments)
- {
- if (entityDeployment != null)
- {
- DependencyPolicy policy = createDependencyPolicy(entityDeployment);
- entityDeployment.addDependencies(policy);
- kernelAbstraction.install(entityDeployment.getKernelName(), policy, entityDeployment);
- }
- }
- }
-
- protected void stopPersistenceUnits()
- {
- if (persistenceUnitDeployments == null)
- return;
-
- for (PersistenceUnitDeployment entityDeployment : persistenceUnitDeployments)
- {
- try
- {
- PersistenceUnitRegistry.unregister(entityDeployment);
- if (entityDeployment != null)
- {
- kernelAbstraction.uninstall(entityDeployment.getKernelName());
- }
- }
- catch (Exception e)
- {
- log.debug("error trying to shut down persistence unit", e);
- }
- }
-
- }
-
- public void stop() throws Exception
- {
- for (ObjectName on : ejbContainers.keySet())
- {
- try
- {
- mbeanServer.unregisterMBean(on);
- kernelAbstraction.uninstall(on.getCanonicalName());
- }
- catch (Exception e)
- {
- log.debug("error trying to shut down ejb container", e);
- }
- }
- stopPersistenceUnits();
- }
-
- public void destroy() throws Exception
- {
- undeploy();
-
- PolicyConfigurationFactory pcFactory = PolicyConfigurationFactory.getPolicyConfigurationFactory();
- PolicyConfiguration pc = pcFactory.getPolicyConfiguration(getJaccContextId(), true);
- pc.delete();
- }
-
- private void undeploy()
- {
- for (Container container : ejbContainers.values())
- {
- Ejb3Registry.unregister(container);
- }
- }
-
- // /**
- // * Get the jndi name of a message destination.
- // *
- // * @param name the name of the message destination
- // * @return the jndi name
- // */
- // private String getMessageDestination(String name)
- // {
- // EjbJarDD dd;
- // // FIXME: Why isn't dd stored somewhere?
- // try
- // {
- // dd = EjbJarDDObjectFactory.parse(getDeploymentUnit().getEjbJarXml());
- // dd = JBossDDObjectFactory.parse(getDeploymentUnit().getJbossXml(), dd);
- // }
- // catch(IOException e)
- // {
- // throw new RuntimeException(e);
- // }
- // catch(JBossXBException e)
- // {
- // throw new RuntimeException(e);
- // }
- //
- // AssemblyDescriptor ad = dd.getAssemblyDescriptor();
- // if(ad == null)
- // throw new IllegalStateException("No assembly descriptor found in '" + getName() + "'");
- // MessageDestination md = ad.findMessageDestination(name);
- // if(md == null)
- // throw new IllegalStateException("No message destination '" + name + "' found in '" + getName() + "'");
- // String jndiName = md.getJndiName();
- // if(jndiName == null)
- // throw new IllegalStateException("No jndi name specified for message destination '" + name + "' in '" + getName() + "'");
- // return jndiName;
- // }
-
- public String resolveMessageDestination(String link)
- {
- // // FIXME: this is a copy of DeploymentEjbResolver
- // int hashIndex = link.indexOf('#');
- // if (hashIndex != -1)
- // {
- // if (deploymentScope == null)
- // {
- // log.warn("ejb link '" + link + "' is relative, but no deployment scope found");
- // return null;
- // }
- // String relativePath = link.substring(0, hashIndex);
- // Ejb3Deployment dep = deploymentScope.findRelativeDeployment(relativePath);
- // if (dep == null)
- // {
- // log.warn("can't find a deployment for path '" + relativePath + "' of ejb link '" + link + "'");
- // return null;
- // }
- // String name = link.substring(hashIndex + 1);
- // return dep.getMessageDestination(name);
- // }
- // return getMessageDestination(link);
- return messageDestinationResolver.resolveMessageDestination(link);
- }
-
- public MessageDestinationResolver getMessageDestinationResolver()
- {
- return messageDestinationResolver;
- }
-
- /**
- * Do not call, for use in Ejb3Handler.
- *
- * @param <B>
- * @param ejbName
- * @param enterpriseBeanMetaDataClass
- * @return
- */
- protected <B extends JBossEnterpriseBeanMetaData> B getEnterpriseBeanMetaData(String ejbName, Class<B> enterpriseBeanMetaDataClass)
- {
- if(metaData == null)
- return null;
- return enterpriseBeanMetaDataClass.cast(metaData.getEnterpriseBean(ejbName));
- }
-
- /**
- * Get the meta data associated with this deployment or null if none.
- *
- * @return meta data or null
- */
- public JBossMetaData getMetaData()
- {
- return metaData;
- }
-
- public String getName()
- {
- return unit.getShortName();
- }
-}
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/Ejb3DescriptorHandler.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/Ejb3DescriptorHandler.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/Ejb3DescriptorHandler.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -1,2221 +0,0 @@
-/*
- * 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;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Field;
-import java.lang.reflect.Member;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.StringTokenizer;
-
-import javassist.bytecode.ClassFile;
-
-import javax.annotation.PostConstruct;
-import javax.annotation.PreDestroy;
-import javax.annotation.Resource;
-import javax.annotation.security.DeclareRoles;
-import javax.annotation.security.DenyAll;
-import javax.annotation.security.PermitAll;
-import javax.annotation.security.RolesAllowed;
-import javax.ejb.ActivationConfigProperty;
-import javax.ejb.Init;
-import javax.ejb.Local;
-import javax.ejb.MessageDriven;
-import javax.ejb.PostActivate;
-import javax.ejb.PrePassivate;
-import javax.ejb.Remote;
-import javax.ejb.Remove;
-import javax.ejb.Stateless;
-import javax.ejb.TransactionAttribute;
-import javax.ejb.TransactionManagement;
-import javax.ejb.TransactionManagementType;
-import javax.interceptor.AroundInvoke;
-import javax.interceptor.ExcludeDefaultInterceptors;
-import javax.interceptor.Interceptors;
-
-import org.jboss.aop.annotation.AnnotationRepository;
-import org.jboss.ejb.ActivationConfigPropertyImpl;
-import org.jboss.ejb.AroundInvokeImpl;
-import org.jboss.ejb.DeclareRolesImpl;
-import org.jboss.ejb.DenyAllImpl;
-import org.jboss.ejb.InitImpl;
-import org.jboss.ejb.InterceptorsImpl;
-import org.jboss.ejb.LocalImpl;
-import org.jboss.ejb.MessageDrivenImpl;
-import org.jboss.ejb.PermitAllImpl;
-import org.jboss.ejb.PostActivateImpl;
-import org.jboss.ejb.PostConstructImpl;
-import org.jboss.ejb.PreDestroyImpl;
-import org.jboss.ejb.PrePassivateImpl;
-import org.jboss.ejb.RemoteImpl;
-import org.jboss.ejb.RemoveImpl;
-import org.jboss.ejb.ResourceImpl;
-import org.jboss.ejb.RolesAllowedImpl;
-import org.jboss.ejb.RunAsImpl;
-import org.jboss.ejb.StatelessImpl;
-import org.jboss.ejb.TransactionAttributeImpl;
-import org.jboss.ejb.TransactionManagementImpl;
-import org.jboss.ejb3.annotation.Cache;
-import org.jboss.ejb3.annotation.Clustered;
-import org.jboss.ejb3.annotation.Consumer;
-import org.jboss.ejb3.annotation.CurrentMessage;
-import org.jboss.ejb3.annotation.DefaultActivationSpecs;
-import org.jboss.ejb3.annotation.DeliveryMode;
-import org.jboss.ejb3.annotation.Depends;
-import org.jboss.ejb3.annotation.IgnoreDependency;
-import org.jboss.ejb3.annotation.LocalBinding;
-import org.jboss.ejb3.annotation.LocalHomeBinding;
-import org.jboss.ejb3.annotation.Management;
-import org.jboss.ejb3.annotation.MessageProperties;
-import org.jboss.ejb3.annotation.PersistenceManager;
-import org.jboss.ejb3.annotation.Pool;
-import org.jboss.ejb3.annotation.Producers;
-import org.jboss.ejb3.annotation.RemoteBinding;
-import org.jboss.ejb3.annotation.RemoteBindings;
-import org.jboss.ejb3.annotation.RemoteHomeBinding;
-import org.jboss.ejb3.annotation.ResourceAdapter;
-import org.jboss.ejb3.annotation.SecurityDomain;
-import org.jboss.ejb3.annotation.SerializedConcurrentAccess;
-import org.jboss.ejb3.annotation.Service;
-import org.jboss.ejb3.annotation.TransactionTimeout;
-import org.jboss.ejb3.annotation.defaults.PoolDefaults;
-import org.jboss.ejb3.annotation.impl.CacheImpl;
-import org.jboss.ejb3.annotation.impl.ClusteredImpl;
-import org.jboss.ejb3.annotation.impl.ConsumerImpl;
-import org.jboss.ejb3.annotation.impl.CurrentMessageImpl;
-import org.jboss.ejb3.annotation.impl.DefaultActivationSpecsImpl;
-import org.jboss.ejb3.annotation.impl.DependsImpl;
-import org.jboss.ejb3.annotation.impl.ExcludeDefaultInterceptorsImpl;
-import org.jboss.ejb3.annotation.impl.IgnoreDependencyImpl;
-import org.jboss.ejb3.annotation.impl.LocalBindingImpl;
-import org.jboss.ejb3.annotation.impl.LocalHomeBindingImpl;
-import org.jboss.ejb3.annotation.impl.LocalHomeImpl;
-import org.jboss.ejb3.annotation.impl.ManagementImpl;
-import org.jboss.ejb3.annotation.impl.MessagePropertiesImpl;
-import org.jboss.ejb3.annotation.impl.PersistenceManagerImpl;
-import org.jboss.ejb3.annotation.impl.PoolImpl;
-import org.jboss.ejb3.annotation.impl.ProducerImpl;
-import org.jboss.ejb3.annotation.impl.ProducersImpl;
-import org.jboss.ejb3.annotation.impl.RemoteBindingImpl;
-import org.jboss.ejb3.annotation.impl.RemoteBindingsImpl;
-import org.jboss.ejb3.annotation.impl.RemoteHomeBindingImpl;
-import org.jboss.ejb3.annotation.impl.RemoteHomeImpl;
-import org.jboss.ejb3.annotation.impl.ResourceAdapterImpl;
-import org.jboss.ejb3.annotation.impl.RunAsPrincipalImpl;
-import org.jboss.ejb3.annotation.impl.SecurityDomainImpl;
-import org.jboss.ejb3.annotation.impl.SerializedConcurrentAccessImpl;
-import org.jboss.ejb3.annotation.impl.ServiceImpl;
-import org.jboss.ejb3.annotation.impl.TransactionTimeoutImpl;
-import org.jboss.ejb3.interceptor.InterceptorInfoRepository;
-import org.jboss.ejb3.lang.ClassHelper;
-import org.jboss.ejb3.mdb.ConsumerContainer;
-import org.jboss.ejb3.mdb.MDB;
-import org.jboss.ejb3.service.ServiceContainer;
-import org.jboss.ejb3.stateful.StatefulContainer;
-import org.jboss.ha.client.loadbalance.LoadBalancePolicy;
-import org.jboss.logging.Logger;
-import org.jboss.metadata.ejb.jboss.CacheConfigMetaData;
-import org.jboss.metadata.ejb.jboss.ClusterConfigMetaData;
-import org.jboss.metadata.ejb.jboss.JBossAssemblyDescriptorMetaData;
-import org.jboss.metadata.ejb.jboss.JBossConsumerBeanMetaData;
-import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
-import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeansMetaData;
-import org.jboss.metadata.ejb.jboss.JBossGenericBeanMetaData;
-import org.jboss.metadata.ejb.jboss.JBossMessageDrivenBeanMetaData;
-import org.jboss.metadata.ejb.jboss.JBossMetaData;
-import org.jboss.metadata.ejb.jboss.JBossServiceBeanMetaData;
-import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
-import org.jboss.metadata.ejb.jboss.LocalProducerMetaData;
-import org.jboss.metadata.ejb.jboss.MessagePropertiesMetaData;
-import org.jboss.metadata.ejb.jboss.MethodAttributeMetaData;
-import org.jboss.metadata.ejb.jboss.MethodAttributesMetaData;
-import org.jboss.metadata.ejb.jboss.PoolConfigMetaData;
-import org.jboss.metadata.ejb.jboss.ProducerMetaData;
-import org.jboss.metadata.ejb.jboss.RemoteBindingMetaData;
-import org.jboss.metadata.ejb.jboss.ResourceManagerMetaData;
-import org.jboss.metadata.ejb.spec.ActivationConfigMetaData;
-import org.jboss.metadata.ejb.spec.ActivationConfigPropertyMetaData;
-import org.jboss.metadata.ejb.spec.AroundInvokeMetaData;
-import org.jboss.metadata.ejb.spec.AroundInvokesMetaData;
-import org.jboss.metadata.ejb.spec.BusinessLocalsMetaData;
-import org.jboss.metadata.ejb.spec.BusinessRemotesMetaData;
-import org.jboss.metadata.ejb.spec.ContainerTransactionMetaData;
-import org.jboss.metadata.ejb.spec.ExcludeListMetaData;
-import org.jboss.metadata.ejb.spec.InitMethodMetaData;
-import org.jboss.metadata.ejb.spec.InitMethodsMetaData;
-import org.jboss.metadata.ejb.spec.InterceptorBindingMetaData;
-import org.jboss.metadata.ejb.spec.InterceptorBindingsMetaData;
-import org.jboss.metadata.ejb.spec.InterceptorClassesMetaData;
-import org.jboss.metadata.ejb.spec.MethodMetaData;
-import org.jboss.metadata.ejb.spec.MethodParametersMetaData;
-import org.jboss.metadata.ejb.spec.MethodPermissionMetaData;
-import org.jboss.metadata.ejb.spec.MethodPermissionsMetaData;
-import org.jboss.metadata.ejb.spec.NamedMethodMetaData;
-import org.jboss.metadata.ejb.spec.RemoveMethodMetaData;
-import org.jboss.metadata.ejb.spec.RemoveMethodsMetaData;
-import org.jboss.metadata.ejb.spec.SecurityIdentityMetaData;
-import org.jboss.metadata.ejb.spec.SubscriptionDurability;
-import org.jboss.metadata.javaee.jboss.AnnotationMetaData;
-import org.jboss.metadata.javaee.jboss.AnnotationPropertiesMetaData;
-import org.jboss.metadata.javaee.jboss.AnnotationPropertyMetaData;
-import org.jboss.metadata.javaee.jboss.AnnotationsMetaData;
-import org.jboss.metadata.javaee.spec.LifecycleCallbackMetaData;
-import org.jboss.metadata.javaee.spec.LifecycleCallbacksMetaData;
-import org.jboss.metadata.javaee.spec.MessageDestinationMetaData;
-import org.jboss.metadata.javaee.spec.MessageDestinationReferenceMetaData;
-import org.jboss.metadata.javaee.spec.MessageDestinationReferencesMetaData;
-import org.jboss.metadata.javaee.spec.ResourceInjectionTargetMetaData;
-import org.jboss.metadata.javaee.spec.ResourceReferenceMetaData;
-import org.jboss.metadata.javaee.spec.ResourceReferencesMetaData;
-import org.jboss.metadata.javaee.spec.RunAsMetaData;
-import org.jboss.metadata.javaee.spec.SecurityRoleMetaData;
-import org.jboss.metadata.javaee.spec.SecurityRolesMetaData;
-
-/**
- * @version <tt>$Revision$</tt>
- * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
- * @author <a href="mailto:bill at jboss.com">Bill Burke</a>
- */
-public class Ejb3DescriptorHandler extends Ejb3AnnotationHandler
-{
- private static final Logger log = Logger
- .getLogger(Ejb3DescriptorHandler.class);
-
- protected JBossMetaData dd;
-
- protected List<JBossEnterpriseBeanMetaData> ejbs = new ArrayList<JBossEnterpriseBeanMetaData>();
-
- public Ejb3DescriptorHandler(Ejb3Deployment deployment, ClassFile cf, JBossMetaData dd)
- {
- super(deployment, cf);
- assert dd != null : "dd is null";
- this.dd = dd;
- }
-
- public Ejb3DescriptorHandler(Ejb3Deployment deployment, JBossMetaData dd)
- {
- super(deployment);
- assert dd != null : "dd is null";
- this.dd = dd;
- }
-
- /**
- * @param original
- * @param binding
- * @return
- */
- private Interceptors createInterceptorsFromInterceptorBinding(Interceptors original, InterceptorBindingMetaData binding) throws ClassNotFoundException
- {
- assert binding != null : "binding is null";
-
- InterceptorsImpl impl;
- InterceptorClassesMetaData classes;
- if (binding.isTotalOrdering())
- {
- impl = new InterceptorsImpl();
- classes = binding.getInterceptorOrder();
- }
- else
- {
- impl = InterceptorsImpl.getImpl(original);
- classes = binding.getInterceptorClasses();
- }
- if (classes != null)
- {
- for (String name : classes)
- {
- Class<?> clazz = di.getClassLoader().loadClass(name);
- impl.addValue(clazz);
- }
- }
- return impl;
- }
-
- /**
- * Find all enterprise beans using the given ejb class.
- *
- * @param dd the dd to search in
- * @param className the ejb class to find
- * @return a list of enterprise beans, never null
- */
- private List<JBossEnterpriseBeanMetaData> findEjbsByClass(JBossMetaData dd, String className)
- {
- assert dd != null : "dd is null";
- assert className != null : "className is null";
-
- List<JBossEnterpriseBeanMetaData> result = new ArrayList<JBossEnterpriseBeanMetaData>();
-
- JBossEnterpriseBeansMetaData enterpriseBeans = dd.getEnterpriseBeans();
- if(enterpriseBeans == null)
- return result;
-
- for(JBossEnterpriseBeanMetaData bean : enterpriseBeans)
- {
- if(bean.getEjbClass() != null && bean.getEjbClass().equals(className))
- result.add(bean);
- }
-
- return result;
- }
-
- public boolean isEjb()
- {
- if (super.isEjb())
- return true;
-
- JBossEnterpriseBeansMetaData enterpriseBeans = dd.getEnterpriseBeans();
- if (enterpriseBeans == null)
- {
- return false;
- }
-
- return findEjbsByClass(dd, cf.getName()).size() > 0;
- }
-
- /**
- * Helper method to load classes. If no class name is specified
- * the bean class is returned.
- *
- * @param container The EJB container
- * @param name The name of the class or null for the bean class
- * @return The resulting <tt>Class</tt> object or the bean class
- */
- private Class<?> loadClass(EJBContainer container, String name)
- {
- if(name == null)
- return container.getBeanClass();
- try
- {
- return di.getClassLoader().loadClass(name);
- }
- catch(ClassNotFoundException e)
- {
- // TODO: what shall be the proper exception
- throw new RuntimeException(e);
- }
- }
-
- protected void populateBaseInfo() throws Exception
- {
- super.populateBaseInfo();
-
- List<JBossEnterpriseBeanMetaData> ejbsByClass = findEjbsByClass(dd, cf.getName());
-
- for (int i = 0; i < ejbNames.size(); ++i)
- {
- String ejbNameFromAnnotation = ejbNames.get(i);
- ejbs.add(dd.getEnterpriseBean(ejbNameFromAnnotation));
-
- boolean removed = false;
- int j = 0;
- while (!removed && j < ejbsByClass.size())
- {
- JBossEnterpriseBeanMetaData ejbByClass = ejbsByClass.get(j);
- if (ejbByClass.getEjbName().equals(ejbNameFromAnnotation))
- {
- ejbsByClass.remove(j);
- } else
- ++j;
- }
- }
-
- for (JBossEnterpriseBeanMetaData enterpriseBean : ejbsByClass)
- {
- String ejbName = enterpriseBean.getEjbName();
-
- ejbs.add(enterpriseBean);
- ejbNames.add(ejbName);
-
- ejbType = getEjbType(enterpriseBean);
- }
- }
-
- protected EJB_TYPE getEjbType(JBossEnterpriseBeanMetaData enterpriseBean)
- {
- if (enterpriseBean.isSession())
- {
- if (((JBossSessionBeanMetaData) enterpriseBean).isStateless())
- return EJB_TYPE.STATELESS;
- else
- return EJB_TYPE.STATEFUL;
- } else if (enterpriseBean.isEntity())
- return EJB_TYPE.ENTITY;
- else if (enterpriseBean.isMessageDriven())
- return EJB_TYPE.MESSAGE_DRIVEN;
- else if (enterpriseBean.isService())
- return EJB_TYPE.SERVICE;
- else if (enterpriseBean.isConsumer())
- return EJB_TYPE.CONSUMER;
- else
- throw new IllegalStateException("unknown bean type encountered " + enterpriseBean);
- }
-
- public List<Container> getContainers(Ejb3Deployment deployment, Map<String, Container> preexistingContainers) throws Exception
- {
- List<Container> containers = new ArrayList<Container>();
-
- JBossEnterpriseBeansMetaData allXmlEjbs = (dd.getEnterpriseBeans() != null) ? dd.getEnterpriseBeans() : new JBossEnterpriseBeansMetaData();
-
- ejbNames = new ArrayList<String>();
- for (JBossEnterpriseBeanMetaData ejb : allXmlEjbs)
- {
- String ejbName = ejb.getEjbName();
- if (preexistingContainers.get(ejbName) == null)
- {
- ejbNames.add(ejbName);
- ejbs.add(ejb);
- }
- }
-
- for (int ejbIndex = 0; ejbIndex < ejbNames.size(); ++ejbIndex)
- {
- String ejbName = ejbNames.get(ejbIndex);
- JBossEnterpriseBeanMetaData enterpriseBean = ejbs.get(ejbIndex);
- ejbType = getEjbType(enterpriseBean);
- className = enterpriseBean.getEjbClass();
-
- if (className == null)
- log.warn("Descriptor based bean has no ejb-class defined: " + ejbName);
- else
- {
- ejbClass = di.getClassLoader().loadClass(className);
- if (ejbType == EJB_TYPE.STATELESS)
- {
- EJBContainer container = getStatelessContainer(ejbIndex, (JBossSessionBeanMetaData) enterpriseBean);
- container.setJaccContextId(getJaccContextId());
- containers.add(container);
- }
- else if (ejbType == EJB_TYPE.STATEFUL)
- {
- StatefulContainer container = getStatefulContainer(ejbIndex, (JBossSessionBeanMetaData) enterpriseBean);
- container.setJaccContextId(getJaccContextId());
- containers.add(container);
- }
- else if (ejbType == EJB_TYPE.MESSAGE_DRIVEN)
- {
- MDB container = getMDB(ejbIndex, (JBossMessageDrivenBeanMetaData) enterpriseBean);
- container.setJaccContextId(getJaccContextId());
- containers.add(container);
- }
- else if (ejbType == EJB_TYPE.SERVICE)
- {
- ServiceContainer container = getServiceContainer(ejbIndex, (JBossServiceBeanMetaData) enterpriseBean);
- container.setJaccContextId(getJaccContextId());
- containers.add(container);
- }
- else if (ejbType == EJB_TYPE.CONSUMER)
- {
- ConsumerContainer container = getConsumerContainer(ejbIndex, (JBossConsumerBeanMetaData) enterpriseBean);
- container.setJaccContextId(getJaccContextId());
- containers.add(container);
- }
- log.debug("found EJB3: ejbName=" + ejbName + ", class=" + className + ", type=" + ejbType);
- }
- }
-
- return containers;
- }
-
- @Override
- protected StatefulContainer getStatefulContainer(int ejbIndex, JBossSessionBeanMetaData enterpriseBean)
- throws Exception
- {
- String ejbName = ejbNames.get(ejbIndex);
-
- StatefulContainer container = super.getStatefulContainer(ejbIndex, enterpriseBean);
-
- container.setAssemblyDescriptor(dd.getAssemblyDescriptor());
-
- if(enterpriseBean instanceof JBossSessionBeanMetaData)
- addInterfaces(container, (JBossSessionBeanMetaData) enterpriseBean);
- else
- log.trace("Not analyzing interfaces on " + enterpriseBean);
-
- addDescriptorAnnotations(container, enterpriseBean, ejbName, true);
-
- return container;
- }
-
- private void addHomeAnnotations(EJBContainer container,
- JBossSessionBeanMetaData sessionBean) throws Exception
- {
- if (sessionBean.getHome() != null)
- {
- RemoteHomeImpl annotation = new RemoteHomeImpl(di.getClassLoader()
- .loadClass(sessionBean.getHome()));
- addClassAnnotation(container, annotation.annotationType(), annotation);
- }
-
- if (sessionBean.getLocalHome() != null)
- {
- LocalHomeImpl annotation = new LocalHomeImpl(di.getClassLoader()
- .loadClass(sessionBean.getLocalHome()));
- addClassAnnotation(container, annotation.annotationType(), annotation);
- }
- }
-
- @Override
- protected EJBContainer getStatelessContainer(int ejbIndex, JBossSessionBeanMetaData enterpriseBean)
- throws Exception
- {
- String ejbName = ejbNames.get(ejbIndex);
-
- EJBContainer container = super.getStatelessContainer(ejbIndex, enterpriseBean);
-
- container.setAssemblyDescriptor(dd.getAssemblyDescriptor());
-
- StatelessImpl annotation = new StatelessImpl(ejbName);
- if (enterpriseBean != null && !isAnnotatedBean())
- {
- addClassAnnotation(container, Stateless.class, annotation);
- }
-
- if(enterpriseBean instanceof JBossSessionBeanMetaData)
- addInterfaces(container, (JBossSessionBeanMetaData) enterpriseBean);
- else
- log.debug("Not analyzing interfaces on " + enterpriseBean);
-
- addDescriptorAnnotations(container, enterpriseBean, ejbName);
-
- return container;
- }
-
- @Override
- protected ServiceContainer getServiceContainer(int ejbIndex, JBossServiceBeanMetaData service)
- throws Exception
- {
- String ejbName = ejbNames.get(ejbIndex);
-
- ServiceContainer container = super.getServiceContainer(ejbIndex, service);
- ServiceImpl annotation = new ServiceImpl((Service) container
- .resolveAnnotation(Service.class));
-
- container.setAssemblyDescriptor(dd.getAssemblyDescriptor());
-
- if (service != null && !isAnnotatedBean())
- {
- if (service.getObjectName() != null)
- annotation.setObjectName(service.getObjectName());
- if (service.getEjbName() != null)
- annotation.setName(service.getEjbName());
- if (service.getXmbean() != null)
- annotation.setXMBean(service.getXmbean());
- addClassAnnotation(container, Service.class, annotation);
- }
-
- addInterfaces(container, service);
-
- addDescriptorAnnotations(container, service, ejbName);
-
- addServiceAnnotations(container, service);
-
- return container;
- }
-
- @Override
- protected ConsumerContainer getConsumerContainer(int ejbIndex, JBossConsumerBeanMetaData consumer)
- throws Exception
- {
- String ejbName = ejbNames.get(ejbIndex);
-
- ConsumerContainer container = super.getConsumerContainer(ejbIndex, consumer);
- ConsumerImpl annotation = new ConsumerImpl((Consumer) container
- .resolveAnnotation(Consumer.class));
-
- container.setAssemblyDescriptor(dd.getAssemblyDescriptor());
-
- if (consumer != null && !isAnnotatedBean())
- {
- if (consumer.getMessageDestination() != null)
- {
- ActivationConfigPropertyImpl property = new ActivationConfigPropertyImpl(
- "destination", consumer.getMessageDestination());
- annotation.addActivationConfig(property);
- }
-
- if (consumer.getMessageDestinationType() != null)
- {
- ActivationConfigPropertyImpl property = new ActivationConfigPropertyImpl(
- "destinationType", consumer.getMessageDestinationType());
- annotation.addActivationConfig(property);
- }
-
- addClassAnnotation(container, Consumer.class, annotation);
- }
-
- // A consumer bean doesn't have any business interfaces
- //addInterfaces(container, consumer);
-
- addDescriptorAnnotations(container, consumer, ejbName);
-
- addConsumerAnnotations(container, consumer);
-
- return container;
- }
-
- protected String getMDBDomainName(int ejbIndex)
- {
- return defaultMDBDomain;
- }
-
- @Override
- protected MDB getMDB(int ejbIndex, JBossMessageDrivenBeanMetaData enterpriseBean) throws Exception
- {
- String ejbName = ejbNames.get(ejbIndex);
-
- MDB container = super.getMDB(ejbIndex, enterpriseBean);
-
- container.setAssemblyDescriptor(dd.getAssemblyDescriptor());
-
- if(enterpriseBean instanceof JBossMessageDrivenBeanMetaData)
- addMDBAnnotations(container, ejbName, (JBossMessageDrivenBeanMetaData) enterpriseBean);
- /*
- else if(enterpriseBean instanceof JBossGenericBeanMetaData)
- {
- // EJBTHREE-936: TODO: unsupported wickedness starts here
- JBossMessageDrivenBeanMetaData mdb = new JBossMessageDrivenBeanMetaData();
- mdb.setDestinationJndiName(enterpriseBean.getMappedName());
-
- addMDBAnnotations(container, ejbName, mdb);
- }
- */
-
- // An MDB doesn't have business interfaces, or does it?
- //addInterfaces(container, enterpriseBean);
-
- addDescriptorAnnotations(container, enterpriseBean, ejbName);
-
- return container;
- }
-
- protected String getAspectDomain(int ejbIndex, String defaultDomain)
- {
- JBossEnterpriseBeanMetaData enterpriseBean = ejbs.get(ejbIndex);
- if (enterpriseBean != null)
- {
- String aopDomainName = enterpriseBean.getAopDomainName();
- if (aopDomainName != null)
- {
- log.debug("Found aop-domain-name element for annotation "
- + aopDomainName + " for ejbName "
- + enterpriseBean.getEjbName());
-
- return aopDomainName;
- }
- }
- return super.getAspectDomain(ejbIndex, defaultDomain);
- }
-
- protected boolean isAnnotatedBean()
- {
- return super.isEjb() || super.isJBossBeanType();
- }
-
- private void addMDBAnnotations(MDB container, String ejbName, JBossMessageDrivenBeanMetaData mdb)
- {
- if (mdb != null)
- {
- if (mdb.getResourceAdapterName() != null)
- {
- ResourceAdapter adapter = new ResourceAdapterImpl(mdb.getResourceAdapterName());
- addClassAnnotation(container, ResourceAdapter.class, adapter);
- }
-
- ArrayList<ActivationConfigProperty> properties = new ArrayList<ActivationConfigProperty>();
-
- if (mdb.isJMS())
- {
- if (mdb.getAcknowledgeMode() != null)
- properties.add(new ActivationConfigPropertyImpl("acknowledgeMode", mdb.getAcknowledgeMode()));
-
- if(mdb.getMessageDestinationType() != null)
- {
- properties.add(new ActivationConfigPropertyImpl("destinationType", mdb.getMessageDestinationType()));
- }
- SubscriptionDurability subscriptionDurability = mdb.getSubscriptionDurability();
- if(subscriptionDurability != null)
- {
- String durable = "false";
- if (subscriptionDurability.equals(SubscriptionDurability.Durable))
- durable = "true";
- properties.add(new ActivationConfigPropertyImpl("subscriptionDurability", durable));
- if (subscriptionDurability.equals(SubscriptionDurability.Durable))
- properties.add(new ActivationConfigPropertyImpl("subscriptionName", "subscriptionName"));
- }
-
- // prefer jndi name over message destination link
- if (mdb.getDestinationJndiName() != null)
- {
- properties.add(new ActivationConfigPropertyImpl("destination", mdb
- .getDestinationJndiName()));
- }
- else if(mdb.getMessageDestinationLink() != null)
- {
- log.warn("Message destination link on a MDB is not yet implemented, specify a jndi name in jboss.xml");
- /*
- // TODO: I can't resolve here, because we're still scanning, maybe this will work:
- // This will be picked up by MessagingContainer and then resolved to a jndi name
- properties.add(new ActivationConfigPropertyImpl("destinationLink", mdb.getMessageDestinationLink()));
- */
- }
-
- if (mdb.getMdbSubscriptionId() != null)
- {
- properties.add(new ActivationConfigPropertyImpl("subscriptionName", mdb
- .getMdbSubscriptionId()));
-
- }
-
- // FIXME These properties are only for our jmsra.rar
-
- if (mdb.getMdbUser() != null)
- {
- properties.add(new ActivationConfigPropertyImpl("user", mdb
- .getMdbUser()));
- }
-
- if (mdb.getMdbPassword() != null)
- {
- properties.add(new ActivationConfigPropertyImpl("password", mdb
- .getMdbPassword()));
-
- }
- }
-
- ActivationConfigMetaData activationConfig = mdb.getActivationConfig();
- if (activationConfig != null && activationConfig.getActivationConfigProperties() != null)
- {
- for (ActivationConfigPropertyMetaData property : activationConfig.getActivationConfigProperties())
- {
- properties.add(new ActivationConfigPropertyImpl(property
- .getName(), property.getValue()));
- }
- }
-
- ActivationConfigPropertyImpl[] propsArray = new ActivationConfigPropertyImpl[properties
- .size()];
- properties.toArray(propsArray);
- MessageDrivenImpl annotation = new MessageDrivenImpl(ejbName,
- propsArray);
- if (mdb.getMessagingType() != null)
- {
- try
- {
- annotation.setMessageListenerInterface(container
- .getClassloader().loadClass(mdb.getMessagingType()));
- } catch (ClassNotFoundException e)
- {
- throw new RuntimeException(e);
- }
- }
-
- if (isAnnotatedBean())
- {
- annotation.merge(ejbClass.getAnnotation(MessageDriven.class));
- }
-
- addClassAnnotation(container, MessageDriven.class, annotation);
-
- addDefaultActivationConfig(container, mdb);
- }
- }
-
- private void addDefaultActivationConfig(MDB container, JBossMessageDrivenBeanMetaData mdb)
- {
- ActivationConfigMetaData defaultActivationConfig = mdb.getDefaultActivationConfig();
- if (defaultActivationConfig != null)
- {
- DefaultActivationSpecsImpl activationAnnotation = new DefaultActivationSpecsImpl();
- for (ActivationConfigPropertyMetaData property : defaultActivationConfig.getActivationConfigProperties())
- {
- activationAnnotation.addActivationConfigProperty(new ActivationConfigPropertyImpl(property
- .getName(), property.getValue()));
- }
-
- DefaultActivationSpecs existingAnnotation = ejbClass.getAnnotation(DefaultActivationSpecs.class);
- if (existingAnnotation != null)
- activationAnnotation.merge(existingAnnotation);
-
- addClassAnnotation(container, DefaultActivationSpecs.class, activationAnnotation);
- }
- }
-
- private void addInterfaces(EJBContainer container, JBossSessionBeanMetaData enterpriseBean) throws ClassNotFoundException
- {
- if (enterpriseBean != null)
- {
- // Initialize
- List<Class<?>> localClasses = new ArrayList<Class<?>>();
- List<Class<?>> remoteClasses = new ArrayList<Class<?>>();
- List<String> localClassNames = new ArrayList<String>();
- List<String> remoteClassNames = new ArrayList<String>();
-
- // Obtain business interfaces (local and remote)
- BusinessLocalsMetaData businessLocals = enterpriseBean.getBusinessLocals();
- BusinessRemotesMetaData businessRemotes = enterpriseBean.getBusinessRemotes();
-
- // Obtain local and remote interfaces
- String local = enterpriseBean.getLocal();
- String remote = enterpriseBean.getRemote();
-
- // If business locals are defined
- if (businessLocals != null)
- {
- localClassNames.addAll(businessLocals);
- }
-
- // If business remotes are defined
- if (businessRemotes != null)
- {
- remoteClassNames.addAll(businessRemotes);
- }
-
- // If local interface(s) is/are defined
- if (local != null)
- {
- // Add all defines local interfaces to list
- StringTokenizer classes = new StringTokenizer(local, ",");
- while (classes.hasMoreTokens())
- {
- String token = classes.nextToken();
- String classname = token.trim();
- localClassNames.add(classname);
- }
- }
-
- // If remote interface(s) is/are defined
- if (remote != null)
- {
- // Add all defined remote interfaces to list
- StringTokenizer classes = new StringTokenizer(remote, ",");
- while (classes.hasMoreTokens())
- {
- String token = classes.nextToken();
- String classname = token.trim();
- remoteClassNames.add(classname);
- }
- }
-
- // For each of the local and business local interfaces
- for (String localClassName : localClassNames)
- {
- // Obtain class
- Class<?> localClass = di.getClassLoader().loadClass(localClassName);
-
- // Ensure specified class is an interface
- if (!localClass.isInterface())
- {
- throw new RuntimeException("Specified class for @Local " + localClass.getName()
- + " is not an interface");
- }
-
- // Log and add the business remote interface to the list of classes to be added as @Local
- log.debug("Adding @Local interface " + localClass.getName() + " as specified in metadata");
- localClasses.add(localClass);
- }
-
- // For each of the remote and business remote interfaces
- for (String remoteClassName : remoteClassNames)
- {
- // Obtain class
- Class<?> remoteClass = di.getClassLoader().loadClass(remoteClassName);
-
- // Ensure specified class is an interface
- if (!remoteClass.isInterface())
- {
- throw new RuntimeException("Specified class for @Remote " + remoteClass.getName()
- + " is not an interface");
- }
-
- // Log and add the business remote interface to the list
- log.debug("Adding @Remote interface " + remoteClass.getName() + " as specified in metadata");
- remoteClasses.add(remoteClass);
- }
-
- // Add @Local to local and local business interfaces
- if (localClasses.size() > 0)
- {
- Class<?>[] lIntfs = new Class[localClasses.size()];
- lIntfs = localClasses.toArray(lIntfs);
- addClassAnnotation(container, Local.class, new LocalImpl(lIntfs));
- }
-
- // Add @Remote to remote and remote business interfaces
- if (remoteClasses.size() > 0)
- {
- Class<?>[] rIntfs = new Class[remoteClasses.size()];
- rIntfs = remoteClasses.toArray(rIntfs);
- addClassAnnotation(container, Remote.class, new RemoteImpl(rIntfs));
- }
- }
- }
-
- /**
- * Add descriptor annotations on non stateful session beans.
- *
- * @param container
- * @param enterpriseBean
- * @param ejbName
- * @throws Exception
- */
- private void addDescriptorAnnotations(EJBContainer container, JBossEnterpriseBeanMetaData enterpriseBean, String ejbName) throws Exception
- {
- addDescriptorAnnotations(container, enterpriseBean, ejbName, false);
- }
-
- private void addDescriptorAnnotations(EJBContainer container, JBossEnterpriseBeanMetaData enterpriseBean, String ejbName, boolean isStateful) throws Exception
- {
- // EJBTHREE-936: TODO: another wicked patch: jndi-name might mean local-jndi-name
- // TODO: Make sure this is done after addInterfaces!
- if(enterpriseBean instanceof JBossGenericBeanMetaData)
- {
- Class<?>[] remoteAndBusinessRemoteInterfaces = ProxyFactoryHelper.getRemoteAndBusinessRemoteInterfaces(container);
- if(remoteAndBusinessRemoteInterfaces.length == 0)
- {
- enterpriseBean.setLocalJndiName(enterpriseBean.getMappedName());
- enterpriseBean.setMappedName(null);
- }
- }
-
- addTransactionAnnotations(container, enterpriseBean, ejbName);
-
- addAssemblyAnnotations(container, enterpriseBean, ejbName);
-
- addSecurityAnnotations(container, enterpriseBean, ejbName);
-
- addEjbAnnotations(container, enterpriseBean);
-
- addEjb21Annotations(container, isStateful);
- }
-
- /**
- * EJB3 4.3.5
- * On a 2.1 session bean the ejbRemove is treated as PreDestroy, ejbActivate as PostActivate,
- * and ejbPassivate as PrePassivate. If it is a stateless session bean the ejbCreate is treated
- * as PostConstruct, if it is stateful the ejbCreate is treated as Init.
- *
- * @param container
- * @param enterpriseBean
- * @throws Exception
- */
- private void addEjb21Annotations(EJBContainer container, boolean isStateful) throws Exception
- {
- Class<?>[] interfaces = ejbClass.getInterfaces();
- for (Class<?> beanInterface : interfaces)
- {
- if (beanInterface.equals(javax.ejb.SessionBean.class))
- {
- MethodMetaData method = new MethodMetaData();
- method.setEjbName(container.getEjbName());
-
- Annotation annotation;
- Class<? extends Annotation> annotationClass;
- // EJB3 4.6.2: The class may implement the ejbCreate method(s).
- // EJB3 4.6.4: The method must be declared as public.
- if(hasPublicMethod(ejbClass, "ejbCreate"))
- {
- if(isStateful)
- {
- annotation = new InitImpl();
- }
- else
- {
- annotation = new PostConstructImpl();
- }
- annotationClass = annotation.annotationType();
- method.setMethodName("ejbCreate");
- addAnnotations(annotationClass, annotation, container, method);
- }
-
- annotation = new PostActivateImpl();
- annotationClass = javax.ejb.PostActivate.class;
- method.setMethodName("ejbActivate");
- addAnnotations(annotationClass, annotation, container, method);
-
- annotation = new PrePassivateImpl();
- annotationClass = javax.ejb.PrePassivate.class;
- method.setMethodName("ejbPassivate");
- addAnnotations(annotationClass, annotation, container, method);
-
- annotation = new PreDestroyImpl();
- annotationClass = javax.annotation.PreDestroy.class;
- method.setMethodName("ejbRemove");
- addAnnotations(annotationClass, annotation, container, method);
-
- annotation = new ResourceImpl();
- annotationClass = Resource.class;
- method.setMethodName("setSessionContext");
- // TODO: set param?
- addAnnotations(annotationClass, annotation, container, method);
- }
- }
- }
-
- private void addAssemblyAnnotations(EJBContainer container,
- JBossEnterpriseBeanMetaData enterpriseBean, String ejbName) throws Exception
- {
- JBossAssemblyDescriptorMetaData assembly = dd.getAssemblyDescriptor();
- if (assembly != null)
- {
- addExcludeAnnotations(container, assembly.getExcludeList(), ejbName);
-
-// addInterceptorBindingAnnotations(container, enterpriseBean, ejbName);
- }
-
- if (enterpriseBean instanceof JBossSessionBeanMetaData)
- {
- JBossSessionBeanMetaData sessionBean = (JBossSessionBeanMetaData) enterpriseBean;
- addInitAnnotations(container, sessionBean.getInitMethods(), ejbName);
- addRemoveAnnotations(container, sessionBean.getRemoveMethods(), ejbName);
- }
- }
-
- private void addExcludeAnnotations(EJBContainer container, ExcludeListMetaData list, String ejbName)
- throws ClassNotFoundException, NoSuchMethodException, NoSuchFieldException
- {
- if (list != null && list.getMethods() != null)
- {
- for(MethodMetaData method : list.getMethods())
- {
- if (method.getEjbName().equals(ejbName))
- {
- DenyAllImpl annotation = new DenyAllImpl();
- addAnnotations(DenyAll.class, annotation, container, method);
- }
- }
- }
- }
-
- private void addInitAnnotations(EJBContainer container, InitMethodsMetaData list, String ejbName)
- throws ClassNotFoundException, NoSuchMethodException, NoSuchFieldException
- {
- if (list != null)
- {
- for (InitMethodMetaData initMethod : list)
- {
- NamedMethodMetaData method = initMethod.getBeanMethod();
- InitImpl annotation = new InitImpl();
- addAnnotations(Init.class, annotation, container, method);
- }
- }
- }
-
- private void addRemoveAnnotations(EJBContainer container, RemoveMethodsMetaData list, String ejbName)
- throws ClassNotFoundException, NoSuchMethodException,
- NoSuchFieldException
- {
- if (list != null)
- {
- for (RemoveMethodMetaData removeMethod : list)
- {
- NamedMethodMetaData method = removeMethod.getBeanMethod();
- RemoveImpl annotation = new RemoveImpl(removeMethod.isRetainIfException());
- addAnnotations(Remove.class, annotation, container, method);
- }
- }
- }
-
- private void addSecurityAnnotations(EJBContainer container, JBossEnterpriseBeanMetaData enterpriseBean, String ejbName)
- throws ClassNotFoundException, NoSuchMethodException, NoSuchFieldException
- {
- JBossAssemblyDescriptorMetaData assembly = dd.getAssemblyDescriptor();
- if (assembly != null)
- {
- SecurityRolesMetaData securityRoles = assembly.getSecurityRoles();
-
- if (securityRoles != null && securityRoles.size() > 0)
- {
- List<String> roleList = new ArrayList<String>();
- for (SecurityRoleMetaData securityRole : securityRoles)
- {
- roleList.add(securityRole.getRoleName());
-
- }
- DeclareRolesImpl annotation = new DeclareRolesImpl(roleList.toArray(new String[roleList.size()]));
- addClassAnnotation(container, DeclareRoles.class, annotation);
- }
-
- MethodPermissionsMetaData methodPermissions = assembly.getMethodPermissions();
- if(methodPermissions != null)
- {
- for (MethodPermissionMetaData permission : methodPermissions)
- {
- for (MethodMetaData method : permission.getMethods())
- {
- if (method.getEjbName().equals(ejbName))
- {
- if (permission.isNotChecked())
- {
- PermitAllImpl annotation = new PermitAllImpl();
- addAnnotations(PermitAll.class, annotation, container, method);
- } else
- {
- RolesAllowedImpl annotation = new RolesAllowedImpl();
-
- for (String roleName : permission.getRoles())
- {
- annotation.addValue(roleName);
- }
- addAnnotations(RolesAllowed.class, annotation, container, method);
- }
- }
- }
- }
- }
- }
-
- if (enterpriseBean != null && enterpriseBean.getSecurityDomain() != null)
- {
- String securityDomain = enterpriseBean.getSecurityDomain();
-
- SecurityDomainImpl annotation = new SecurityDomainImpl(securityDomain);
-
- if (dd.getUnauthenticatedPrincipal() != null)
- annotation.setUnauthenticatedPrincipal(dd
- .getUnauthenticatedPrincipal());
-
- addClassAnnotation(container, annotation.annotationType(), annotation);
- } else if (dd.getSecurityDomain() != null)
- {
- String securityDomain = dd.getSecurityDomain();
-
- SecurityDomainImpl annotation = new SecurityDomainImpl(securityDomain);
-
- if (dd.getUnauthenticatedPrincipal() != null)
- annotation.setUnauthenticatedPrincipal(dd
- .getUnauthenticatedPrincipal());
-
- addClassAnnotation(container, annotation.annotationType(), annotation);
- } else if (dd.getUnauthenticatedPrincipal() != null)
- {
- SecurityDomain annotation = ejbClass.getAnnotation(SecurityDomain.class);
- SecurityDomainImpl override;
- if (annotation != null)
- {
- override = new SecurityDomainImpl(annotation.value());
- override.setUnauthenticatedPrincipal(dd
- .getUnauthenticatedPrincipal());
- }
- else
- {
- override = new SecurityDomainImpl();
- override.setUnauthenticatedPrincipal(dd.getUnauthenticatedPrincipal());
- }
- addClassAnnotation(container, override.annotationType(), override);
- }
- }
-
- private void addTransactionAnnotations(EJBContainer container, JBossEnterpriseBeanMetaData enterpriseBean, String ejbName)
- throws ClassNotFoundException, NoSuchMethodException, NoSuchFieldException
- {
- if (enterpriseBean != null)
- {
- TransactionManagementType transactionType = enterpriseBean.getTransactionType();
- if (transactionType != null)
- {
- TransactionManagementImpl annotation = new TransactionManagementImpl();
- annotation.setValue(transactionType);
- addClassAnnotation(container, TransactionManagement.class, annotation);
- }
-
- MethodAttributesMetaData attributes = enterpriseBean.getMethodAttributes();
- if (attributes != null)
- {
- for(MethodAttributeMetaData method : attributes)
- {
- TransactionTimeout timeoutAnnotation = new TransactionTimeoutImpl(method.getTransactionTimeout());
- addAnnotations(TransactionTimeout.class, timeoutAnnotation, container, method.getMethodName(), null);
- }
- }
- }
-
- JBossAssemblyDescriptorMetaData descriptor = dd.getAssemblyDescriptor();
- if (descriptor != null && descriptor.getContainerTransactions() != null)
- {
- for(ContainerTransactionMetaData transaction : descriptor.getContainerTransactions())
- {
- for(MethodMetaData method : transaction.getMethods())
- {
- if (method.getEjbName().equals(ejbName))
- {
- TransactionAttributeImpl annotation = new TransactionAttributeImpl();
- annotation.setType(transaction.getTransAttribute());
- addAnnotations(TransactionAttribute.class, annotation, container, method);
- }
- }
- }
- }
- }
-
- /**
- * Interceptors are additive. What's in the annotations and in the XML is
- * merged
- */
- private void addInterceptorBindingAnnotations(EJBContainer container,
- JBossEnterpriseBeanMetaData enterpriseBean, String ejbName)
- throws ClassNotFoundException, NoSuchMethodException,
- NoSuchFieldException
- {
- boolean definesInterceptors = false;
-
- InterceptorBindingsMetaData interceptorBindings = dd.getAssemblyDescriptor().getInterceptorBindings();
- if(interceptorBindings != null)
- {
- for (InterceptorBindingMetaData binding : interceptorBindings)
- {
- // Wolf: why ignore ordered binding?
- /*
- if (binding.isOrdered())
- {
- continue;
- }
- */
- if (binding.getEjbName().equals(ejbName))
- {
- if(binding.getMethod() == null)
- {
- addClassLevelInterceptorBindingAnnotations(container, binding);
- definesInterceptors = true;
- }
- else
- {
- definesInterceptors = addMethodLevelInterceptorBindingAnnotations(
- container, binding);
- }
-
- }
- }
- }
-
- /*
- if (!definesInterceptors
- && di.getInterceptorInfoRepository().hasDefaultInterceptors())
- {
- addClassAnnotation(container, DefaultInterceptorMarker.class,
- new DefaultInterceptorMarkerImpl());
- }
- */
- }
-
- /**
- * Interceptors are additive. What's in the annotations and in the XML is
- * merged
- */
- private void addClassLevelInterceptorBindingAnnotations(
- EJBContainer container, InterceptorBindingMetaData binding)
- throws ClassNotFoundException
- {
- Interceptors interceptors = (Interceptors) container
- .resolveAnnotation(Interceptors.class);
- if (binding != null)
- {
- Interceptors impl = createInterceptorsFromInterceptorBinding(interceptors, binding);
-
- addClassAnnotation(container, impl.annotationType(), impl);
- }
-
- boolean exclude = false;
- if (binding != null)
- exclude = binding.isExcludeDefaultInterceptors();
- if (exclude
- && container.resolveAnnotation(ExcludeDefaultInterceptors.class) == null)
- {
- addClassAnnotation(container, ExcludeDefaultInterceptors.class,
- new ExcludeDefaultInterceptorsImpl());
- }
-
- }
-
- /**
- * Interceptors are additive. What's in the annotations and in the XML is
- * merged
- */
- private boolean addMethodLevelInterceptorBindingAnnotations(
- EJBContainer container, InterceptorBindingMetaData binding)
- throws ClassNotFoundException
- {
- /*
- boolean addedAnnotations = false;
- for (java.lang.reflect.Method method : container.getBeanClass()
- .getMethods())
- {
- boolean matches = false;
- if (method.getName().equals(binding.getMethod().getMethodName()))
- {
- if (binding.getMethod().getMethodParams() == null)
- {
- matches = true;
- } else
- {
- Class<?>[] methodParams = method.getParameterTypes();
- MethodParametersMetaData bindingParams = binding.getMethod().getMethodParams();
-
- if (methodParams.length == bindingParams.size())
- {
- matches = true;
- int i = 0;
- for (String paramName : bindingParams)
- {
- String methodParamName = InterceptorInfoRepository
- .simpleType(methodParams[i++]);
- if (!paramName.equals(methodParamName))
- {
- matches = false;
- break;
- }
- }
- }
- }
- }
-
- if (matches)
- {
- Interceptors interceptors = (Interceptors) container
- .resolveAnnotation(method, Interceptors.class);
- if (binding != null)
- {
- Interceptors impl = createInterceptorsFromInterceptorBinding(interceptors, binding);
- log.debug("adding " + Interceptors.class.getName()
- + " method annotation to " + method);
- container.getAnnotations().addAnnotation(method,
- Interceptors.class, impl);
- }
-
- boolean excludeDefault = false;
- if (binding != null)
- excludeDefault = binding.isExcludeDefaultInterceptors();
- if (excludeDefault
- && container.resolveAnnotation(method,
- ExcludeDefaultInterceptors.class) == null)
- {
- log.debug("adding " + ExcludeDefaultInterceptors.class.getName()
- + " method annotation to " + method);
- container.getAnnotations().addAnnotation(method,
- ExcludeDefaultInterceptors.class,
- new ExcludeDefaultInterceptorsImpl());
- }
-
- boolean excludeClass = false;
- if (binding != null)
- excludeClass = binding.isExcludeClassInterceptors();
- if (excludeClass
- && container.resolveAnnotation(method,
- ExcludeClassInterceptors.class) == null)
- {
- log.debug("adding " + ExcludeClassInterceptors.class.getName()
- + " method annotation to " + method);
- container.getAnnotations().addAnnotation(method,
- ExcludeClassInterceptors.class,
- new ExcludeClassInterceptorsImpl());
- }
- matches = false;
- addedAnnotations = true;
- }
- }
-
- return addedAnnotations;
- */
- return false;
- }
-
- private void addEjbAnnotations(EJBContainer container,
- JBossEnterpriseBeanMetaData enterpriseBean) throws Exception
- {
- if (enterpriseBean != null)
- {
- if (enterpriseBean instanceof JBossSessionBeanMetaData)
- {
- addHomeAnnotations(container, (JBossSessionBeanMetaData) enterpriseBean);
-
- addJndiAnnotations(container, (JBossSessionBeanMetaData) enterpriseBean);
- }
-
- addInterceptorMethodAnnotations(container, enterpriseBean);
-
- handleResourceRefs(container, enterpriseBean.getResourceReferences());
-
- addMessageDestinationAnnotations(container, enterpriseBean.getMessageDestinationReferences());
-
- addSecurityIdentityAnnotation(container, enterpriseBean.getSecurityIdentity());
-
- addDependencies(container, enterpriseBean);
-
- addPoolAnnotations(container, enterpriseBean);
-
- addXmlAnnotations(container, enterpriseBean);
-
- if (enterpriseBean instanceof JBossSessionBeanMetaData)
- {
- addConcurrentAnnotations(container, (JBossSessionBeanMetaData)enterpriseBean);
- addClusterAnnotations(container, (JBossSessionBeanMetaData)enterpriseBean);
- addCacheAnnotations(container, (JBossSessionBeanMetaData)enterpriseBean);
- }
- }
- }
-
- private void addConcurrentAnnotations(EJBContainer container,
- JBossSessionBeanMetaData enterpriseBean) throws Exception
- {
- if (enterpriseBean.isConcurrent() != null)
- {
- if (enterpriseBean.isConcurrent())
- {
- SerializedConcurrentAccessImpl annotation = new SerializedConcurrentAccessImpl();
- addClassAnnotation(container, SerializedConcurrentAccess.class, annotation);
- }
- else
- {
- container.getAnnotations().disableAnnotation(SerializedConcurrentAccess.class.getName());
- }
- }
- }
-
- private void addPoolAnnotations(EJBContainer container,
- JBossEnterpriseBeanMetaData enterpriseBean) throws Exception
- {
- if (enterpriseBean.getPoolConfig() != null)
- {
- PoolConfigMetaData config = enterpriseBean.getPoolConfig();
-
- PoolImpl poolAnnotation = new PoolImpl();
-
- if (config.getValue() != null && !config.getValue().trim().equals(""))
- poolAnnotation.setValue(config.getValue());
-
- // EJBTHREE-1119
- if(config.getValue()==null || config.getValue().trim().equals(""))
- {
- // Set default implementation to Threadlocal
- poolAnnotation.setValue(PoolDefaults.POOL_IMPLEMENTATION_THREADLOCAL);
- }
-
- if (config.getMaxSize() != null)
- poolAnnotation.setMaxSize(config.getMaxSize());
-
- if (config.getTimeout() != null)
- poolAnnotation.setTimeout(config.getTimeout());
-
- addClassAnnotation(container, Pool.class, poolAnnotation);
- }
- }
-
- private void addXmlAnnotations(EJBContainer container,
- JBossEnterpriseBeanMetaData enterpriseBean) throws Exception
- {
- AnnotationsMetaData annotations = enterpriseBean.getAnnotations();
- if(annotations == null)
- return;
-
- for(AnnotationMetaData xmlAnnotation: annotations)
- {
- Class<? extends Annotation> annotationClass = (Class<? extends Annotation>) di.getClassLoader().loadClass(xmlAnnotation.getAnnotationClass());
- Class<? extends Annotation> annotationImplementationClass = (Class<? extends Annotation>) di.getClassLoader().loadClass(xmlAnnotation.getAnnotationImplementationClass());
- Annotation annotation = annotationImplementationClass.newInstance();
-
- AnnotationPropertiesMetaData properties = xmlAnnotation.getProperties();
- if (properties != null)
- {
- for (AnnotationPropertyMetaData property : properties)
- {
- Field field = annotationImplementationClass.getDeclaredField(property.getName());
- setAnnotationPropertyField(field, annotation, property.getPropertyValue());
- }
- }
-
- if (xmlAnnotation.getInjectionTarget() == null)
- {
- addClassAnnotation(container, annotationClass, annotation);
- }
- else
- {
- MethodMetaData method = new MethodMetaData();
- method.setMethodName(xmlAnnotation.getInjectionTarget().getInjectionTargetName());
- addAnnotations(annotationClass, annotation, container, method);
- }
- }
- }
-
- // FIXME: Wolf: Why do we have this method here? It's a bean property setter, so should
- // be part of bean spi.
- protected void setAnnotationPropertyField(Field field, Object annotation, String value) throws Exception
- {
- if (field.getType() == String.class)
- field.set(annotation, value);
- else if (field.getType() == Long.class || field.getType() == Long.TYPE)
- field.setLong(annotation, Long.parseLong(value));
- else if (field.getType() == Integer.class || field.getType() == Integer.TYPE)
- field.setInt(annotation, Integer.parseInt(value));
- else if (field.getType() == Class.class)
- field.set(annotation, di.getClassLoader().loadClass(value));
- else if (field.getType() == Boolean.class || field.getType() == Boolean.TYPE)
- field.setBoolean(annotation, Boolean.parseBoolean(value));
- else
- throw new IllegalArgumentException("unsupported field type " + field.getType() + " on field " + field);
- }
-
- private void addCacheAnnotations(EJBContainer container,
- JBossSessionBeanMetaData enterpriseBean) throws Exception
- {
- if (enterpriseBean.getCacheConfig() != null)
- {
- CacheConfigMetaData config = enterpriseBean.getCacheConfig();
- if (config.getValue() != null && !config.getValue().equals(""))
- {
- String cacheValue = config.getValue();
- CacheImpl cacheAnnotation = new CacheImpl(cacheValue);
- addClassAnnotation(container, Cache.class, cacheAnnotation);
-
- // FIXME: Wolf: what the hell is this?
- // FIXME: ALR: This shouldn't be hardcoded; configuration needs reworking
- if (cacheValue.equals("SimpleStatefulCache"))
- {
- if (!ejbClass.isAnnotationPresent(PersistenceManager.class))
- {
- PersistenceManagerImpl persistenceAnnotation = new PersistenceManagerImpl();
- if (config.getPersistenceManager() != null)
- {
- persistenceAnnotation.setValue(config.getPersistenceManager());
- }
- addClassAnnotation(container, PersistenceManager.class, persistenceAnnotation);
- }
- }
- }
-
- if (config.getName() != null)
- {
- org.jboss.ejb3.annotation.impl.CacheConfigImpl configAnnotation = new org.jboss.ejb3.annotation.impl.CacheConfigImpl();
-
- configAnnotation.setName(config.getName());
-
- if (config.getMaxSize() != null)
- configAnnotation.setMaxSize(config.getMaxSize());
-
- if (config.getIdleTimeoutSeconds() != null)
- configAnnotation.setIdleTimeoutSeconds(config.getIdleTimeoutSeconds());
-
- if (config.getReplicationIsPassivation() != null)
- configAnnotation.setReplicationIsPassivation(Boolean.parseBoolean(config.getReplicationIsPassivation()));
-
- if (config.getRemoveTimeoutSeconds() != null)
- configAnnotation.setRemovalTimeoutSeconds(config.getRemoveTimeoutSeconds());
-
- org.jboss.ejb3.annotation.CacheConfig existingConfig = ejbClass.getAnnotation(org.jboss.ejb3.annotation.CacheConfig.class);
- if (existingConfig != null)
- configAnnotation.merge(existingConfig);
-
- addClassAnnotation(container, org.jboss.ejb3.annotation.CacheConfig.class, configAnnotation);
- }
- else
- {
- org.jboss.ejb3.annotation.impl.CacheConfigImpl configAnnotation = new org.jboss.ejb3.annotation.impl.CacheConfigImpl();
-
- if (config.getMaxSize() != null)
- configAnnotation.setMaxSize(config.getMaxSize());
-
- if (config.getIdleTimeoutSeconds() != null)
- configAnnotation.setIdleTimeoutSeconds(config.getIdleTimeoutSeconds());
-
- if (config.getRemoveTimeoutSeconds() != null)
- configAnnotation.setRemovalTimeoutSeconds(config.getRemoveTimeoutSeconds());
-
- org.jboss.ejb3.annotation.CacheConfig existingConfig = ejbClass.getAnnotation(org.jboss.ejb3.annotation.CacheConfig.class);
- if (existingConfig != null)
- configAnnotation.merge(existingConfig);
-
- addClassAnnotation(container, org.jboss.ejb3.annotation.CacheConfig.class, configAnnotation);
- }
- }
-
- }
-
- private void addClusterAnnotations(EJBContainer container,
- JBossSessionBeanMetaData enterpriseBean) throws Exception
- {
- /* FIXME: Why disable the annotation?
- if (!enterpriseBean.isClustered())
- {
- // ask directly, not the container (metadata setup in progress)
- Clustered existingAnnotation = ejbClass.getAnnotation(Clustered.class);
- if (existingAnnotation != null)
- container.getAnnotations().disableAnnotation(Clustered.class.getName());
- return;
- }
- */
-
- ClusterConfigMetaData config = enterpriseBean.getClusterConfig();
- if (config != null)
- {
- ClusteredImpl clusteredAnnotation = new ClusteredImpl();
-
- if (config.getBeanLoadBalancePolicy() != null)
- {
- Class<? extends LoadBalancePolicy> policy = (Class<? extends LoadBalancePolicy>) di.getClassLoader()
- .loadClass(config.getBeanLoadBalancePolicy());
- clusteredAnnotation.setLoadBalancePolicy(""); // This branch is dead, putting NPE in place for valid compile only
- }
-
- if (config.getHomeLoadBalancePolicy() != null)
- {
- Class<? extends LoadBalancePolicy> policy = (Class<? extends LoadBalancePolicy>) di.getClassLoader()
- .loadClass(config.getHomeLoadBalancePolicy());
- clusteredAnnotation.setHomeLoadBalancePolicy(""); // This branch is dead, putting NPE in place for valid compile only
- }
-
- if (config.getPartitionName() != null)
- {
- clusteredAnnotation.setPartition(config.getPartitionName());
- }
-
- addClassAnnotation(container, Clustered.class, clusteredAnnotation);
- }
- }
-
- private void addDependencies(EJBContainer container,
- JBossEnterpriseBeanMetaData enterpriseBean) throws Exception
- {
- Set<String> depends = enterpriseBean.getDepends();
- if (depends != null && depends.size() > 0)
- {
- DependsImpl annotation = new DependsImpl();
- Iterator<String> dependencies = enterpriseBean.getDepends()
- .iterator();
- while (dependencies.hasNext())
- {
- annotation.addDependency(dependencies.next());
- }
-
- addClassAnnotation(container, Depends.class, annotation);
- }
-
- if (enterpriseBean.getIgnoreDependency() != null)
- {
- for(ResourceInjectionTargetMetaData ignore : enterpriseBean.getIgnoreDependency().getInjectionTargets())
- {
- IgnoreDependencyImpl annotation = new IgnoreDependencyImpl();
-
- MethodMetaData method = new MethodMetaData();
- method.setMethodName(ignore.getInjectionTargetName());
-
- addAnnotations(IgnoreDependency.class, annotation, container, method);
- }
- }
- }
-
- private void addServiceAnnotations(EJBContainer container, JBossServiceBeanMetaData service)
- throws ClassNotFoundException
- {
- if (service == null)
- return;
-
- String management = service.getManagement();
-
- if (management != null)
- {
- ManagementImpl annotation = new ManagementImpl(di.getClassLoader().loadClass(management));
- addClassAnnotation(container, Management.class, annotation);
- }
- }
-
- private void addConsumerAnnotations(EJBContainer container,
- JBossConsumerBeanMetaData consumer) throws ClassNotFoundException,
- NoSuchFieldException, NoSuchMethodException
- {
- if (consumer == null)
- return;
-
- List<ProducerMetaData> producers = consumer.getProducers();
- List<LocalProducerMetaData> localProducers = consumer.getLocalProducers();
- if ((producers != null && producers.size() > 0) || (localProducers != null && localProducers.size() > 0))
- {
- ProducersImpl producersAnnotation = new ProducersImpl();
-
- if(producers != null)
- {
- for(ProducerMetaData producer : producers)
- {
- ProducerImpl annotation = new ProducerImpl(di.getClassLoader()
- .loadClass(producer.getClassName()));
- if (producer.getConnectionFactory() != null)
- annotation.setConnectionFactory(producer.getConnectionFactory());
- producersAnnotation.addProducer(annotation);
- }
- }
-
- if(localProducers != null)
- {
- for(ProducerMetaData producer : localProducers)
- {
- ProducerImpl annotation = new ProducerImpl(di.getClassLoader()
- .loadClass(producer.getClassName()));
- if (producer.getConnectionFactory() != null)
- annotation.setConnectionFactory(producer.getConnectionFactory());
- producersAnnotation.addProducer(annotation);
- }
- }
-
- addClassAnnotation(container, Producers.class, producersAnnotation);
- }
-
- MethodAttributesMetaData currentMessage = consumer
- .getCurrentMessage();
- if (currentMessage != null)
- {
- CurrentMessageImpl annotation = new CurrentMessageImpl();
- for(MethodAttributeMetaData method : currentMessage)
- {
- addAnnotations(CurrentMessage.class, annotation, container, method);
- }
- }
-
- List<MessagePropertiesMetaData> propertiesList = consumer.getMessageProperties();
- if (propertiesList != null)
- {
- for(MessagePropertiesMetaData properties : propertiesList)
- {
- MessagePropertiesImpl annotation = new MessagePropertiesImpl();
-
- String delivery = properties.getDelivery();
- if (delivery != null && delivery.equals("Persistent"))
- annotation.setDelivery(DeliveryMode.PERSISTENT);
- else
- annotation.setDelivery(DeliveryMode.NON_PERSISTENT);
-
- Integer priority = properties.getPriority();
- if (priority != null)
- annotation.setDelivery(DeliveryMode.PERSISTENT);
-
- String interfac = properties.getClassName();
- if (interfac != null)
- {
- Class<?> clazz = di.getClassLoader().loadClass(interfac);
- annotation.setInterface(clazz);
- }
-
- MethodAttributeMetaData method = properties.getMethod();
- addAnnotations(MessageProperties.class, annotation, container, method);
- }
- }
- }
-
- private void addJndiAnnotations(EJBContainer container,
- JBossSessionBeanMetaData enterpriseBean) throws ClassNotFoundException
- {
- addLocalJndiAnnotations(container, enterpriseBean);
- addRemoteJndiAnnotations(container, enterpriseBean);
- }
-
- private void addLocalJndiAnnotations(EJBContainer container,
- JBossSessionBeanMetaData enterpriseBean) throws ClassNotFoundException
- {
- String localJndiName = enterpriseBean.getLocalJndiName();
- if (localJndiName != null)
- {
- LocalBindingImpl localBinding = new LocalBindingImpl(localJndiName);
- addClassAnnotation(container, LocalBinding.class, localBinding);
- }
-
- String localHomeJndiName = enterpriseBean.getLocalHomeJndiName();
- if (localHomeJndiName != null)
- {
- LocalHomeBindingImpl localHomeBinding = new LocalHomeBindingImpl(localHomeJndiName);
- addClassAnnotation(container, LocalHomeBinding.class, localHomeBinding);
- }
- }
-
- private void addRemoteJndiAnnotations(EJBContainer container,
- JBossSessionBeanMetaData enterpriseBean) throws ClassNotFoundException
- {
- String homeJndiName = enterpriseBean.getHomeJndiName();
- if (homeJndiName != null && !homeJndiName.trim().equals(""))
- {
- RemoteHomeBindingImpl homeBinding = new RemoteHomeBindingImpl(homeJndiName);
- addClassAnnotation(container, RemoteHomeBinding.class, homeBinding);
- }
-
- // JBCTS-718
- // If jndi-name is defined, use the value specified
- String jndiName = enterpriseBean.getJndiName();
- if (jndiName != null && !jndiName.trim().equals(""))
- {
- RemoteBindingImpl remoteBindingAnnotation = new RemoteBindingImpl();
- remoteBindingAnnotation.setJndiBinding(jndiName);
- addClassAnnotation(container, RemoteBinding.class, remoteBindingAnnotation);
- log.debug("Adding " + RemoteBinding.class.getName() + " to " + container.toString() + ": "
- + remoteBindingAnnotation.toString());
- return;
- }
-
- List<RemoteBindingMetaData> bindingsList = enterpriseBean.getRemoteBindings();
- if (bindingsList == null || bindingsList.size() == 0)
- {
- addSimpleJndiAnnotations(container, enterpriseBean);
- return;
- }
-
- AnnotationRepository annotations = container.getAnnotations();
-
- annotations.disableAnnotation(RemoteBinding.class.getName());
-
- List<RemoteBindingImpl> bindingAnnotationsList = new ArrayList<RemoteBindingImpl>();
-
- for(RemoteBindingMetaData binding : bindingsList)
- {
- RemoteBindingImpl bindingAnnotation = new RemoteBindingImpl();
-
- if (binding.getJndiName() != null)
- bindingAnnotation.setJndiBinding(binding.getJndiName());
-
- if (binding.getClientBindUrl() != null)
- bindingAnnotation.setBindUrl(binding.getClientBindUrl());
-
- if (binding.getInterceptorStack() != null)
- bindingAnnotation.setStack(binding.getInterceptorStack());
-
- if (binding.getProxyFactory() != null)
- bindingAnnotation.setFactory(binding.getProxyFactory());
-
- bindingAnnotationsList.add(bindingAnnotation);
-
- }
-
- RemoteBindingsImpl bindingsAnnotation = new RemoteBindingsImpl(bindingAnnotationsList);
- addClassAnnotation(container, RemoteBindings.class, bindingsAnnotation);
- }
-
- private void addSimpleJndiAnnotations(EJBContainer container,
- JBossEnterpriseBeanMetaData enterpriseBean) throws ClassNotFoundException
- {
- RemoteBindingImpl remoteBinding = null;
-
- String jndiName = enterpriseBean.getMappedName();
- if (jndiName != null)
- {
- remoteBinding = new RemoteBindingImpl();
- remoteBinding.setJndiBinding(jndiName);
- addClassAnnotation(container, RemoteBinding.class, remoteBinding);
- }
-
- if (remoteBinding != null)
- {
- RemoteBinding existingBinding = ejbClass.getAnnotation(RemoteBinding.class);
- if (existingBinding != null)
- remoteBinding.merge(existingBinding);
-
- addClassAnnotation(container, RemoteBinding.class, remoteBinding);
- }
- }
-
- private void handleResourceRefs(EJBContainer container, ResourceReferencesMetaData resourceRefList)
- {
- if(resourceRefList == null)
- return;
-
- for(ResourceReferenceMetaData ref : resourceRefList)
- {
- if (ref.getResourceName() != null)
- {
- // for <resource-manager>
- ResourceManagerMetaData resourceManager = dd.getResourceManager(ref.getResourceName());
- if(resourceManager != null)
- {
- ref.setJndiName(resourceManager.getResJndiName());
- ref.setMappedName(resourceManager.getResJndiName());
- }
- }
- }
- }
-
- private void addMessageDestinationAnnotations(EJBContainer container, MessageDestinationReferencesMetaData refs)
- {
- if(refs == null)
- return;
-
- for(MessageDestinationReferenceMetaData ref : refs)
- {
- if (ref.getMappedName() == null || ref.getMappedName().equals(""))
- {
- JBossAssemblyDescriptorMetaData descriptor = dd.getAssemblyDescriptor();
- if (descriptor != null)
- {
- MessageDestinationMetaData destination = descriptor.getMessageDestination(ref.getLink());
- if (destination != null)
- {
- ref.setMappedName(destination.getJndiName());
- }
- }
- }
- }
- }
-
- private void addInterceptorMethodAnnotations(EJBContainer container,
- JBossEnterpriseBeanMetaData enterpriseBean)
- {
- if (enterpriseBean instanceof JBossSessionBeanMetaData)
- {
- JBossSessionBeanMetaData sessionBean = (JBossSessionBeanMetaData) enterpriseBean;
- addInterceptorMethodAnnotation(container, enterpriseBean,
- sessionBean.getAroundInvokes(),
- AroundInvoke.class, "around-invoke-method");
- addInterceptorMethodAnnotation(container, enterpriseBean,
- sessionBean.getPostConstructs(),
- PostConstruct.class, "post-construct-method");
- addInterceptorMethodAnnotation(container, enterpriseBean,
- sessionBean.getPostActivates(),
- PostActivate.class, "post-activate-method");
- addInterceptorMethodAnnotation(container, enterpriseBean,
- sessionBean.getPrePassivates(),
- PrePassivate.class, "pre-passivate-method");
- addInterceptorMethodAnnotation(container, enterpriseBean,
- sessionBean.getPreDestroys(),
- PreDestroy.class, "pre-destroy-method");
- }
- else if (enterpriseBean instanceof JBossMessageDrivenBeanMetaData)
- {
- JBossMessageDrivenBeanMetaData messageDriven = (JBossMessageDrivenBeanMetaData) enterpriseBean;
- addInterceptorMethodAnnotation(container, enterpriseBean,
- messageDriven.getAroundInvokes(),
- AroundInvoke.class, "around-invoke-method");
- addInterceptorMethodAnnotation(container, enterpriseBean,
- messageDriven.getPostConstructs(),
- PostConstruct.class, "post-construct-method");
- addInterceptorMethodAnnotation(container, enterpriseBean,
- messageDriven.getPreDestroys(),
- PreDestroy.class, "pre-destroy-method");
- }
- }
-
- private void addInterceptorMethodAnnotation(EJBContainer container, Class<?> cls, String methodName, Class<? extends Annotation> ann, String xmlName)
- {
- Method found = null;
- for (Method rm : cls.getDeclaredMethods())
- {
- if (rm.getName().equals(methodName))
- {
- if (ann == AroundInvoke.class)
- {
- if (InterceptorInfoRepository.checkValidBusinessSignature(rm))
- {
- found = rm;
- break;
- }
- } else
- {
- if (InterceptorInfoRepository
- .checkValidBeanLifecycleSignature(rm))
- {
- found = rm;
- break;
- }
- }
- }
- }
-
- if (found == null)
- {
- log.warn("No method found within " + cls.getName()
- + " with name " + methodName
- + " with the right signature for " + xmlName + "was found");
- return;
- }
-
- if (container.resolveAnnotation(found, ann) == null)
- {
- log.debug("adding " + ann.getName() + " method annotation to "
- + found);
-
- container.getAnnotations().addAnnotation(found, ann,
- getInterceptorImpl(ann));
- }
- }
-
- private void addInterceptorMethodAnnotation(EJBContainer container, JBossEnterpriseBeanMetaData enterpriseBean, AroundInvokesMetaData callbacks, Class<? extends Annotation> ann, String xmlName)
- {
- if (callbacks == null)
- return;
-
- for(AroundInvokeMetaData callback : callbacks)
- {
- Class<?> callbackClass = loadClass(container, callback.getClassName());
-
- addInterceptorMethodAnnotation(container, callbackClass, callback.getMethodName(), ann, xmlName);
- }
- }
-
- private void addInterceptorMethodAnnotation(EJBContainer container,
- JBossEnterpriseBeanMetaData enterpriseBean, LifecycleCallbacksMetaData callbacks, Class<? extends Annotation> ann, String xmlName)
- {
- if (callbacks == null)
- return;
-
- for(LifecycleCallbackMetaData callback : callbacks)
- {
- Class<?> callbackClass = loadClass(container, callback.getClassName());
-
- addInterceptorMethodAnnotation(container, callbackClass, callback.getMethodName(), ann, xmlName);
- }
- }
-
- private Object getInterceptorImpl(Class<?> ann)
- {
- if (ann == AroundInvoke.class)
- {
- return new AroundInvokeImpl();
- } else if (ann == PostConstruct.class)
- {
- return new PostConstructImpl();
- } else if (ann == PostActivate.class)
- {
- return new PostActivateImpl();
- } else if (ann == PrePassivate.class)
- {
- return new PrePassivateImpl();
- } else if (ann == PreDestroy.class)
- {
- return new PreDestroyImpl();
- }
-
- return null;
- }
-
- private void addSecurityIdentityAnnotation(EJBContainer container,
- SecurityIdentityMetaData identity)
- {
- if (identity != null && !identity.isUseCallerId())
- {
- RunAsMetaData runAs = identity.getRunAs();
- RunAsImpl annotation = null;
- if (runAs != null)
- {
- annotation = new RunAsImpl(runAs.getRoleName());
- addClassAnnotation(container, annotation.annotationType(),
- annotation);
- }
-
- String runAsPrincipal = identity.getRunAsPrincipal();
- if (runAsPrincipal != null)
- {
- RunAsPrincipalImpl principalAnnotation = new RunAsPrincipalImpl(runAsPrincipal);
- addClassAnnotation(container, principalAnnotation
- .annotationType(), principalAnnotation);
- }
- }
- }
-
- /*
- * This method in non-deterministic. It should expect to be called
- * in random order, so at the end there is no guarenteed security
- * annotation configuration.
- */
- @Deprecated
- protected void overrideAnnotations(EJBContainer container, Member m,
- String annotation, Object value)
- {
- /*
- AnnotationRepository annotations = container.getAnnotations();
-
- if (value instanceof javax.annotation.security.DenyAll)
- {
- annotations.disableAnnotation(m,
- javax.annotation.security.PermitAll.class.getName());
- annotations.disableAnnotation(m,
- javax.annotation.security.RolesAllowed.class.getName());
- } else if (value instanceof javax.annotation.security.PermitAll)
- {
- annotations.disableAnnotation(m,
- javax.annotation.security.DenyAll.class.getName());
- annotations.disableAnnotation(m,
- javax.annotation.security.RolesAllowed.class.getName());
- } else if (value instanceof javax.annotation.security.RolesAllowed)
- {
- annotations.disableAnnotation(m,
- javax.annotation.security.PermitAll.class.getName());
- annotations.disableAnnotation(m,
- javax.annotation.security.DenyAll.class.getName());
- }
- */
- }
-
- private void addClassAnnotation(EJBContainer container, Class<? extends Annotation> annotationClass, Annotation annotation)
- {
- log.debug("adding class annotation " + annotationClass.getName() + " to "
- + container + " " + annotation);
- container.getAnnotations()
- .addClassAnnotation(annotationClass, annotation);
- }
-
- private <A extends Annotation> void addAnnotations(Class<A> annotationClass, A annotation, EJBContainer container, MethodAttributeMetaData method)
- {
- addAnnotations(annotationClass, annotation, container, method.getMethodName(), null);
- }
-
- private void addAnnotations(Class<? extends Annotation> annotationClass, Annotation annotation, EJBContainer container, String methodName, MethodParametersMetaData params)
- {
- try
- {
- AnnotationRepository annotations = container.getAnnotations();
- if (methodName.equals("*"))
- {
- log.debug("adding " + annotationClass.getName() + " annotation to "
- + ejbClass.getName() + "." + methodName);
-
- for (java.lang.reflect.Method declaredMethod : ejbClass
- .getDeclaredMethods())
- {
- annotations.addAnnotation(declaredMethod, annotationClass,
- annotation);
- overrideAnnotations(container, declaredMethod, annotationClass
- .getName(), annotation);
- }
- } else
- {
- if (params == null)
- {
- java.lang.reflect.Method[] methods = ejbClass.getMethods();
- boolean foundMethod = false;
- for (int methodIndex = 0; methodIndex < methods.length; ++methodIndex)
- {
- if (methods[methodIndex].getName().equals(methodName))
- {
- log.debug("adding " + annotationClass.getName()
- + " method annotation to " + methods[methodIndex]);
- annotations.addAnnotation(methods[methodIndex],
- annotationClass, annotation);
- overrideAnnotations(container, methods[methodIndex],
- annotationClass.getName(), annotation);
- foundMethod = true;
-
- }
- }
-
- if (!foundMethod)
- {
- methods = ejbClass.getDeclaredMethods();
- for (int methodIndex = 0; methodIndex < methods.length; ++methodIndex)
- {
- if (methods[methodIndex].getName().equals(methodName))
- {
- log.debug("adding " + annotationClass.getName()
- + " method annotation to " + methods[methodIndex]);
- annotations.addAnnotation(methods[methodIndex],
- annotationClass, annotation);
- overrideAnnotations(container, methods[methodIndex],
- annotationClass.getName(), annotation);
- foundMethod = true;
-
- }
- }
- }
-
- if (!foundMethod)
- {
- java.lang.reflect.Field member = ejbClass
- .getDeclaredField(methodName);
- if (member != null)
- {
- log.debug("adding " + annotationClass.getName()
- + " field annotation to " + member);
- annotations
- .addAnnotation(member, annotationClass, annotation);
- overrideAnnotations(container, member, annotationClass
- .getName(), annotation);
- }
- }
- } else
- {
- Class<?>[] methodSignature = new Class[params.size()];
- int paramIndex = 0;
- for(String param : params)
- {
- Class<?> paramClass = null;
- if (param.equals("boolean"))
- paramClass = boolean.class;
- else if (param.equals("int"))
- paramClass = int.class;
- else if (param.equals("long"))
- paramClass = long.class;
- else if (param.equals("short"))
- paramClass = short.class;
- else if (param.equals("byte"))
- paramClass = byte.class;
- else if (param.equals("char"))
- paramClass = char.class;
- else
- paramClass = di.getClassLoader().loadClass(param);
- methodSignature[paramIndex++] = paramClass;
- }
- if(log.isTraceEnabled())
- log.trace("Looking for method " + methodName + Arrays.toString(methodSignature) + " on class " + ejbClass);
- Member member = ClassHelper.getPrivateMethod(ejbClass, methodName, methodSignature);
- log.debug("adding " + annotationClass.getName()
- + " method annotation to " + member);
- annotations.addAnnotation(member, annotationClass, annotation);
- overrideAnnotations(container, member, annotationClass.getName(),
- annotation);
- }
- }
- }
- catch (Exception e)
- {
- throw new RuntimeException("Unable to create annotation for method/field " + methodName + " for EJB " + container.getEjbName(), e);
- }
- }
-
- private void addAnnotations(Class<? extends Annotation> annotationClass, Annotation annotation, EJBContainer container, NamedMethodMetaData method)
- {
- addAnnotations(annotationClass, annotation, container, method.getMethodName(), method.getMethodParams());
- }
-
- private void addAnnotations(Class<? extends Annotation> annotationClass, Annotation annotation,
- EJBContainer container, MethodMetaData method) throws ClassNotFoundException,
- NoSuchMethodException, NoSuchFieldException
- {
- addAnnotations(annotationClass, annotation, container, method.getMethodName(), method.getMethodParams());
- }
-
- /**
- * Verify whether the class has a public method with a certain name.
- *
- * @param cls the class to check
- * @param methodName the method to find
- * @return true if a method with that name exists on that class
- */
- private boolean hasPublicMethod(Class<?> cls, String methodName)
- {
- assert cls != null : "cls is null";
- assert methodName != null : "methodName is null";
-
- for(java.lang.reflect.Method m : cls.getMethods())
- {
- if(m.getName().equals(methodName))
- return true;
- }
-
- return false;
- }
-
-}
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/Ejb3Handler.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/Ejb3Handler.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/Ejb3Handler.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -1,44 +0,0 @@
-/*
- * 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;
-
-import java.util.Hashtable;
-import java.util.List;
-import javassist.bytecode.ClassFile;
-
-/**
- *
- *
- * @version <tt>$Revision$</tt>
- * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
- * @author <a href="mailto:bill at jboss.com">Bill Burke</a>
- */
-public interface Ejb3Handler
-{
- boolean isEjb();
-
- boolean isJBossBeanType();
-
- List<Container> getContainers(ClassFile cf, Ejb3Deployment deployment) throws Exception;
-
- void setCtxProperties(Hashtable ctxProperties);
-}
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/Ejb3HandlerFactory.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/Ejb3HandlerFactory.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/Ejb3HandlerFactory.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -1,85 +0,0 @@
-/*
- * 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;
-
-import java.net.URL;
-import org.jboss.ejb3.metamodel.EjbJarDD;
-import org.jboss.ejb3.metamodel.EjbJarDDObjectFactory;
-import org.jboss.ejb3.metamodel.JBossDDObjectFactory;
-import org.jboss.ejb3.interceptor.InterceptorInfoRepository;
-import org.jboss.metadata.ejb.jboss.JBossMetaData;
-
-import javassist.bytecode.ClassFile;
-
-public abstract class Ejb3HandlerFactory
-{
- public abstract Ejb3Handler createHandler(ClassFile cf) throws Exception;
-
- private static class DDFactory extends Ejb3HandlerFactory
- {
- private JBossMetaData dd;
- private Ejb3Deployment di;
-
- public DDFactory(Ejb3Deployment di) throws Exception
- {
- this.di = di;
- this.dd = di.getMetaData();
-
- InterceptorInfoRepository repository = this.di.getDeploymentUnit().getInterceptorInfoRepository();
- repository.initialise(dd);
- }
-
-
- public Ejb3Handler createHandler(ClassFile cf) throws Exception
- {
- return new Ejb3DescriptorHandler(di, cf, dd);
- }
- }
-
- private static class AnnotationFactory extends Ejb3HandlerFactory
- {
- private Ejb3Deployment di;
-
- public AnnotationFactory(Ejb3Deployment di) throws Exception
- {
- this.di = di;
- }
-
-
- public Ejb3Handler createHandler(ClassFile cf) throws Exception
- {
- return new Ejb3AnnotationHandler(di, cf);
- }
- }
-
- public static Ejb3HandlerFactory getInstance(Ejb3Deployment di) throws Exception
- {
- URL ddResource = di.getDeploymentUnit().getEjbJarXml();
-
- URL jbossDdResource = di.getDeploymentUnit().getJbossXml();
-
- if (ddResource == null && jbossDdResource == null)
- return new AnnotationFactory(di);
- else
- return new DDFactory(di);
- }
-}
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/Ejb3JmxDeployment.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/Ejb3JmxDeployment.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/Ejb3JmxDeployment.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -1,79 +0,0 @@
-/*
- * 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;
-
-import javax.security.jacc.PolicyConfiguration;
-
-import org.jboss.deployment.DeploymentInfo;
-import org.jboss.ejb3.javaee.JavaEEComponent;
-import org.jboss.ejb3.security.JaccHelper;
-import org.jboss.logging.Logger;
-
-/**
- * JBoss 4.0 Microkernel specific implementation
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- */
- at Deprecated
-public class Ejb3JmxDeployment extends Ejb3Deployment
-{
- private DeploymentInfo deploymentInfo;
-
- private static final Logger log = Logger.getLogger(Ejb3JmxDeployment.class);
-
- public Ejb3JmxDeployment(DeploymentInfo di, DeploymentScope deploymentScope)
- {
- super(new JmxDeploymentUnit(di), deploymentScope, null, null, null);
- this.deploymentInfo = di;
- kernelAbstraction = new JmxKernelAbstraction(di);
-
- // todo maybe mbeanServer should be injected?
- mbeanServer = di.getServer();
- }
-
- protected PolicyConfiguration createPolicyConfiguration() throws Exception
- {
- return JaccHelper.initialiseJacc(getJaccContextId());
-
- }
-
- protected void putJaccInService(PolicyConfiguration pc, DeploymentUnit unit)
- {
- try
- {
- JaccHelper.putJaccInService(pc, deploymentInfo);
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
-
- }
-
- public DependencyPolicy createDependencyPolicy(JavaEEComponent component)
- {
- return new JmxDependencyPolicy();
- }
-
-
-}
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/Ejb3Module.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/Ejb3Module.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/Ejb3Module.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -1,141 +0,0 @@
-/*
- * 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;
-
-import java.util.Map;
-import javax.management.ObjectName;
-import org.jboss.deployment.DeploymentInfo;
-import org.jboss.system.ServiceMBeanSupport;
-import org.jboss.logging.Logger;
-
-/**
- * An EjbModule represents a collection of beans that are deployed as a unit.
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- */
- at Deprecated
-public class Ejb3Module extends ServiceMBeanSupport implements Ejb3ModuleMBean
-{
- public final static String BASE_EJB3_JMX_NAME = "jboss.j2ee:service=EJB3";
- private static final Logger log = Logger.getLogger(Ejb3Module.class);
-
- private Ejb3JmxDeployment deployment;
- private DeploymentInfo di;
-
- public Ejb3Module(DeploymentInfo di)
- {
- DeploymentScope deploymentScope = null;
- if (di.parent != null)
- {
- if (di.parent.shortName.endsWith(".ear") || di.parent.shortName.endsWith(".ear/"))
- {
- synchronized(di.parent.context)
- {
- deploymentScope = (DeploymentScope)di.parent.context.get("EJB3_EAR_METADATA");
- if (deploymentScope == null)
- {
- deploymentScope = new JmxDeploymentScopeImpl(di.parent.shortName);
- di.parent.context.put("EJB3_EAR_METADATA", deploymentScope);
- }
- }
- }
- }
- deployment = new Ejb3JmxDeployment(di, deploymentScope);
- if (deploymentScope != null)
- {
- deploymentScope.register(deployment);
- }
- this.di = di;
- }
-
- protected void createService() throws Exception
- {
- super.createService();
- ClassLoader old = Thread.currentThread().getContextClassLoader();
- try
- {
- Thread.currentThread().setContextClassLoader(di.ucl);
- deployment.create();
- }
- finally
- {
- Thread.currentThread().setContextClassLoader(old);
- }
- }
-
- protected void startService() throws Exception
- {
- ClassLoader old = Thread.currentThread().getContextClassLoader();
- try
- {
- Thread.currentThread().setContextClassLoader(di.ucl);
- deployment.start();
- }
- finally
- {
- Thread.currentThread().setContextClassLoader(old);
- }
- super.startService();
-
- }
-
- protected void stopService() throws Exception
- {
- ClassLoader old = Thread.currentThread().getContextClassLoader();
- try
- {
- Thread.currentThread().setContextClassLoader(di.ucl);
- deployment.stop();
- }
- finally
- {
- Thread.currentThread().setContextClassLoader(old);
- }
- super.stopService();
- }
-
- protected void destroyService() throws Exception
- {
- ClassLoader old = Thread.currentThread().getContextClassLoader();
- try
- {
- Thread.currentThread().setContextClassLoader(di.ucl);
- deployment.destroy();
- }
- finally
- {
- Thread.currentThread().setContextClassLoader(old);
- }
- super.destroyService();
- }
-
- public Container getContainer(ObjectName name)
- {
- return deployment.getContainer(name);
- }
-
- public Map getContainers()
- {
- return deployment.getEjbContainers();
- }
-}
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/Ejb3ModuleMBean.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/Ejb3ModuleMBean.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/Ejb3ModuleMBean.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -1,39 +0,0 @@
-/*
- * 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;
-
-
-/**
- * MBean interface.
- *
- * @see Container
- * @see EJBDeployer
- */
-
-public interface Ejb3ModuleMBean extends org.jboss.system.ServiceMBean
-
-{
- Container getContainer(javax.management.ObjectName name);
-
- java.util.Map getContainers();
-}
-
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/Ejb3Registry.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/Ejb3Registry.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/Ejb3Registry.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -1,214 +0,0 @@
-/*
- * 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;
-
-import java.rmi.dgc.VMID;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.jboss.logging.Logger;
-
-/**
- * Maintains an administration of all EJB3 container available.
- *
- * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
- * @version <tt>$Revision$</tt>
- */
-public class Ejb3Registry
-{
- private static final Logger log = Logger.getLogger(Ejb3Registry.class);
-
- private static Map<String, Container> containers = new HashMap<String, Container>();
- private static Map<String, Container> clusterContainers = new HashMap<String, Container>();
-
- private static final VMID vmid = new VMID();
-
- /**
- * Find a potential container.
- *
- * @param oid the canonical object name of the container
- * @return the container or null if not found
- */
- public static Container findContainer(String oid)
- {
- return containers.get(oid);
- }
-
- public static VMID getVMID()
- {
- return vmid;
- }
-
- /**
- * Reports the existance of a container.
- *
- * @param container the container to check
- * @return true if found, false otherwise
- */
- public static boolean hasContainer(Container container)
- {
- return hasContainer(oid(container));
- }
-
- /**
- * Reports the existance of a container.
- *
- * @param oid the canonical object name of the container
- * @return true if found, false otherwise
- */
- private static boolean hasContainer(String oid)
- {
- return containers.containsKey(oid);
- }
-
- private static final String oid(Container container)
- {
- return container.getObjectName().getCanonicalName();
- }
-
- public static boolean hasClusterContainer(String oid)
- {
- return clusterContainers.containsKey(oid);
- }
-
- public static final String guid(Container container, VMID vmid)
- {
- return container.getObjectName().getCanonicalName() + ",VMID=" + vmid;
- }
-
- public static final String guid(Container container)
- {
- return guid(container, vmid);
- }
-
- public static final String clusterUid(Container container)
- {
- if (container.isClustered())
- return container.getObjectName().getCanonicalName() + ",Partition=" + ((EJBContainer)container).getPartitionName();
-
- return container.getObjectName().getCanonicalName();
- }
-
- public static final String clusterUid(String oid, String partitionName)
- {
- return oid + ",Partition=" + partitionName;
- }
-
- /**
- * Registers a container.
- *
- * @param container the container to register
- * @throws IllegalStateException if the container is already registered
- */
- public static void register(Container container)
- {
- String guid = guid(container);
- if(hasContainer(guid))
- throw new IllegalStateException("Container " + guid + " + is already registered");
- containers.put(guid, container);
-
- if (container.isClustered())
- clusterContainers.put(clusterUid(container), container);
-
- log.debug("Registered container " + guid);
- }
-
- /**
- * Unregisters a container.
- *
- * @param container the container to unregister
- * @throws IllegalStateException if the container is not registered
- */
- public static void unregister(Container container)
- {
- String guid = guid(container);
- if(!hasContainer(guid))
- throw new IllegalStateException("Container " + guid + " + is not registered");
- containers.remove(guid);
-
- if (container.isClustered())
- clusterContainers.remove(clusterUid(container));
-
- log.debug("Unregistered container " + guid);
- }
-
- /**
- * Returns the container specified by the given GUID.
- * Never returns null.
- *
- * @param guid the GUID
- * @return the container
- * @throws IllegalStateException if the container is not registered
- */
- public static Container getContainer(String guid)
- {
- if(!hasContainer(guid))
- throw new IllegalStateException("Container " + guid + " is not registered");
-
- return containers.get(guid);
- }
-
- /**
- * Returns the container specified by the given canocical object name.
- * Never returns null.
- *
- * @param oid the canonical object name of the container
- * @return the container
- * @throws IllegalStateException if the container is not registered
- */
- public static Container getClusterContainer(String clusterUid)
- {
- Container container = clusterContainers.get(clusterUid);
- if(container == null)
- throw new IllegalStateException("Container " + clusterUid + " is not registered " + clusterContainers);
-
- return container;
- }
-
- /**
- * Returns the container specified by the given canonical object name
- * which is expected to be of the given type.
- * Never returns null.
- *
- * @param oid the canonical object name of the container
- * @param type the container type
- * @return the container
- * @throws IllegalStateException if the container is not registered
- */
- @SuppressWarnings("unchecked")
- public static <T extends Container> T getContainer(String oid, Class<T> type)
- {
- return (T) getContainer(oid);
- }
-
- /**
- * Returns an unmodifiable collection of the registered containers.
- *
- * @return the containers
- */
- public static Collection<Container> getContainers()
- {
- return Collections.unmodifiableCollection(containers.values());
- }
-}
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/EjbEncFactory.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/EjbEncFactory.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/EjbEncFactory.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -1,55 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2006, JBoss Inc., 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;
-
-import javax.naming.Context;
-
-/**
- * ENC Abstraction for EJB Container
- *
- * @author <a href="bill at jboss.com">Bill Burke</a>
- * @version $Revision: 1.1 $
- */
-public interface EjbEncFactory
-{
- Context getEnc(EJBContainer container);
-
- /**
- * Push the EJB's ENC onto the current thread
- *
- * @param container
- */
- void pushEnc(EJBContainer container);
-
- /**
- * pop the EJB's ENC from the current thread
- *
- * @param container
- */
- void popEnc(EJBContainer container);
-
- /**
- *
- * @param container
- */
- void cleanupEnc(EJBContainer container);
-}
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/FileSuffixFilter.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/FileSuffixFilter.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/FileSuffixFilter.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -1,44 +0,0 @@
-/*
- * 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;
-
-import org.jboss.util.file.ArchiveBrowser;
-
-/**
- * comment
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- */
-public class FileSuffixFilter implements ArchiveBrowser.Filter
-{
- private String suffix;
-
- public FileSuffixFilter(String suffix)
- {
- this.suffix = suffix;
- }
-
- public boolean accept(String filename)
- {
- return filename.endsWith(suffix);
- }
-}
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/InfinitePool.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/InfinitePool.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/InfinitePool.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -1,98 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ejb3;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import org.jboss.ejb3.pool.AbstractPool;
-
-/**
- * A pool that has no constraints.
- *
- * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
- * @version $Revision$
- */
-public class InfinitePool extends AbstractPool
-{
- private List<BeanContext> active = new LinkedList<BeanContext>();
-
- public void destroy()
- {
- for(BeanContext ctx : active)
- {
- // call super.remove or else get concurrent modification
- super.remove(ctx);
- }
- active = null;
- }
-
- public BeanContext<?> get()
- {
- return get(null, null);
- }
-
- public BeanContext<?> get(Class[] initTypes, Object[] initValues)
- {
- BeanContext ctx = create(initTypes, initValues);
- synchronized(active)
- {
- active.add(ctx);
- }
- return ctx;
- }
-
- public int getAvailableCount()
- {
- return -1;
- }
-
- public int getCurrentSize()
- {
- return active.size();
- }
-
- public int getMaxSize()
- {
- return -1;
- }
-
- public void release(BeanContext ctx)
- {
- remove(ctx);
- }
-
- public void remove(BeanContext ctx)
- {
- synchronized(active)
- {
- active.remove(ctx);
- }
-
- super.remove(ctx);
- }
-
- public void setMaxSize(int maxSize)
- {
- }
-
-}
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/InitialContextFactory.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/InitialContextFactory.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/InitialContextFactory.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -1,159 +0,0 @@
-/*
- * 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;
-
-import java.util.Hashtable;
-import java.util.Properties;
-
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-
-import org.jboss.logging.Logger;
-
-import org.jboss.mx.util.MBeanServerLocator;
-
-import org.jboss.system.server.ServerConfig;
-
-/**
- * @version <tt>$Revision$</tt>
- * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
- */
-public class InitialContextFactory
-{
-private static final Logger log = Logger.getLogger(InitialContextFactory.class);
-
- private static Properties props = null;
- private static Properties securityProperties = null;
- private static InitialContext baseInitialContext = null;
- private static Context haContext = null;
- private static Integer haJndiPort = null;
-
- public static InitialContext getInitialContext() throws NamingException
- {
- InitialContext jndiContext;
-
- if (props == null)
- {
- if (baseInitialContext == null)
- {
- baseInitialContext = new InitialContext();
- }
- jndiContext = baseInitialContext;
-
- try
- {
- jndiContext.getEnvironment();
- }
- catch (NamingException e)
- {
- jndiContext = baseInitialContext = new InitialContext();
- }
- }
- else
- {
- if (securityProperties != null)
- {
- Properties combinedProps = new Properties();
- combinedProps.putAll(props);
- combinedProps.putAll(securityProperties);
- jndiContext = new InitialContext(combinedProps);
- }
- else
- jndiContext = new InitialContext(props);
- }
-
- return jndiContext;
- }
-
- public static InitialContext getInitialContext(Hashtable props)
- throws NamingException
- {
- InitialContext ctx = null;
- if (props != null)
- {
- ctx = new InitialContext(props);
- }
- else
- {
- ctx = getInitialContext();
- }
- return ctx;
- }
-
- public static Context getHAContext(Context ctx)
- throws NamingException
- {
- if (haContext == null)
- {
- Hashtable env = ctx.getEnvironment();
- Object providerUrl = env.get(Context.PROVIDER_URL);
- if (providerUrl == null)
- {
- try
- {
- String bindAddress = System.getProperty(ServerConfig.SERVER_BIND_ADDRESS);
- env.put(Context.PROVIDER_URL, bindAddress + ":" + getHaJndiPort());
- InitialContext haCtx = new InitialContext(env);
- haCtx.bind("HA_TEST", null);
- haCtx.unbind("HA_TEST");
- haContext = haCtx;
- }
- catch (Exception e)
- {
- log.debug("Unable to access HA JNDI: " + e);
- }
- }
- }
- return haContext;
- }
-
- private static Integer getHaJndiPort() throws Exception
- {
- if (haJndiPort == null)
- {
- MBeanServer server = MBeanServerLocator.locateJBoss();
- ObjectName objectName = new ObjectName("jboss:service=HAJNDI");
- haJndiPort = (Integer)server.getAttribute(objectName, "Port");
- }
- return haJndiPort;
- }
-
- public static void setProperties(Properties properties)
- {
- props = properties;
- }
-
- public static void setSecurity(String user, String password)
- {
- if (props != null)
- {
- securityProperties = new Properties();
- securityProperties.put(Context.SECURITY_PRINCIPAL, user);
- securityProperties.put(Context.SECURITY_CREDENTIALS, password);
- securityProperties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.security.jndi.JndiLoginInitialContextFactory");
- }
- }
-}
-
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/JBossProxy.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/JBossProxy.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/JBossProxy.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -1,31 +0,0 @@
-/*
- * 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;
-
-/**
- * @author <a href="mailto:kabir.khan at jboss.org">Kabir Khan</a>
- * @version $Revision$
- */
-public interface JBossProxy
-{
- Object getAsynchronousProxy();
-}
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/JarsIgnoredForScanning.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/JarsIgnoredForScanning.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/JarsIgnoredForScanning.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -1,62 +0,0 @@
-/*
- * 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;
-
-import java.util.HashSet;
-import org.jboss.system.ServiceMBeanSupport;
-
-/**
- * Simple service that lists jars that will be ignored for scanning for annotations to deploy
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- */
-public class JarsIgnoredForScanning extends ServiceMBeanSupport implements JarsIgnoredForScanningMBean
-{
- String[] ignoredJars;
- HashSet ignoredJarsSet = new HashSet();
-
- public String[] getIgnoredJars()
- {
- return ignoredJars;
- }
-
- public void setIgnoredJars(String[] ignoredJars)
- {
- this.ignoredJars = ignoredJars;
- for (String jar : ignoredJars)
- {
- ignoredJarsSet.add(jar.trim());
- }
- }
-
- public HashSet getIgnoredJarsSet()
- {
- return ignoredJarsSet;
- }
-
- public void setIgnoredJarsSet(HashSet ignoredJarsSet)
- {
- this.ignoredJarsSet = ignoredJarsSet;
- }
-
-}
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/JarsIgnoredForScanningMBean.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/JarsIgnoredForScanningMBean.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/JarsIgnoredForScanningMBean.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -1,41 +0,0 @@
-/*
- * 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;
-
-import java.util.HashSet;
-
-/**
- * Comment
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- */
-public interface JarsIgnoredForScanningMBean
-{
- String[] getIgnoredJars();
-
- void setIgnoredJars(String[] ignoredJars);
-
- HashSet getIgnoredJarsSet();
-
- void setIgnoredJarsSet(HashSet ignoredJarsSet);
-}
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/JmxClientKernelAbstraction.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/JmxClientKernelAbstraction.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/JmxClientKernelAbstraction.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -1,51 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., 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;
-
-import javax.management.MBeanServerConnection;
-import javax.management.ObjectName;
-import org.jboss.logging.Logger;
-
-/**
- * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
- */
-public class JmxClientKernelAbstraction implements ClientKernelAbstraction
-{
- private static final Logger log = Logger.getLogger(JmxKernelAbstraction.class);
-
- private MBeanServerConnection server;
-
- public JmxClientKernelAbstraction(MBeanServerConnection server)
- {
- this.server = server;
- }
-
- public Object invoke(ObjectName name, String operationName, Object[] params, String[] signature) throws Exception
- {
- return server.invoke(name, operationName, params, signature);
- }
-
- public Object getAttribute(ObjectName name, String attribute) throws Exception
- {
- return server.getAttribute(name, attribute);
- }
-}
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/JmxDependencyPolicy.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/JmxDependencyPolicy.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/JmxDependencyPolicy.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -1,90 +0,0 @@
-/*
- * 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;
-
-import java.util.Collection;
-import java.util.HashSet;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-
-/**
- * Old JMX Kernel dependency registry
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- */
- at Deprecated
-public class JmxDependencyPolicy implements DependencyPolicy
-{
- protected HashSet<ObjectName> dependencies = new HashSet<ObjectName>();
-
- public void addDependency(String dependency)
- {
- ObjectName on = null;
- try
- {
- on = new ObjectName(dependency);
- }
- catch (MalformedObjectNameException e)
- {
- throw new RuntimeException(dependency, e);
- }
- dependencies.add(on);
- }
-
- public Collection getDependencies()
- {
- return dependencies;
- }
-
- public Collection getDependencies(Collection currentDependencies)
- {
- dependencies.addAll(currentDependencies);
- return dependencies;
- }
-
- public void addDatasource(String jndiName)
- {
- String ds = jndiName;
- if (ds.startsWith("java:/"))
- {
- ds = ds.substring(6);
-
- }
- else if (ds.startsWith("java:"))
- {
- ds = ds.substring(5);
- }
- //tring onStr = "jboss.jca:name=" + ds + ",service=ManagedConnectionFactory";
- String onStr = "jboss.jca:name=" + ds + ",service=DataSourceBinding";
-
- try
- {
- dependencies.add(new ObjectName(onStr));
- }
- catch (MalformedObjectNameException e)
- {
- throw new RuntimeException(e);
- }
- }
-
-}
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/JmxDeploymentScopeImpl.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/JmxDeploymentScopeImpl.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/JmxDeploymentScopeImpl.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -1,82 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., 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;
-
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.Collection;
-
-/**
- * JMX JBoss 4.x Kernel abstraction for an ear.
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision: 1.17 $
- */
-public class JmxDeploymentScopeImpl implements DeploymentScope
-{
- private ConcurrentHashMap<String, Ejb3Deployment> deployments = new ConcurrentHashMap<String, Ejb3Deployment>();
- private String shortName;
- private String baseName;
-
- public JmxDeploymentScopeImpl(String shortName)
- {
- this.shortName = shortName;
- int idx = shortName.lastIndexOf('.');
- baseName = shortName.substring(0, idx);
- }
-
- public Collection<Ejb3Deployment> getEjbDeployments()
- {
- return deployments.values();
- }
-
- public void register(Ejb3Deployment deployment)
- {
- deployments.put(deployment.getDeploymentUnit().getShortName(), deployment);
- }
-
- public void unregister(Ejb3Deployment deployment)
- {
- deployments.remove(deployment.getDeploymentUnit().getShortName());
- }
-
- public Ejb3Deployment findRelativeDeployment(String relativeName)
- {
- String relativeShortName = relativeName.substring(3);
- return deployments.get(relativeShortName);
- }
-
- public String getName()
- {
- return shortName;
- }
-
- public String getShortName()
- {
- return shortName;
- }
-
- public String getBaseName()
- {
- return baseName;
- }
-
-}
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/JmxDeploymentUnit.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/JmxDeploymentUnit.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/JmxDeploymentUnit.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -1,255 +0,0 @@
-/*
- * 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;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Map;
-
-import org.jboss.deployment.DeploymentInfo;
-import org.jboss.ejb3.interceptor.InterceptorInfoRepository;
-import org.jboss.logging.Logger;
-import org.jboss.mx.util.MBeanProxyExt;
-import org.jboss.virtual.VFS;
-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$
- */
- at Deprecated
-public class JmxDeploymentUnit implements DeploymentUnit
-{
- protected static final Logger log = Logger.getLogger(JmxDeploymentUnit.class);
-
- private DeploymentInfo deploymentInfo;
- InterceptorInfoRepository interceptorInfoRepository = new InterceptorInfoRepository(null);
- private VirtualFile vfsRoot;
-
- public JmxDeploymentUnit(DeploymentInfo deploymentInfo)
- {
- this.deploymentInfo = deploymentInfo;
- try
- {
- VFS vfs = VFS.getVFS(deploymentInfo.url);
- vfsRoot = vfs.getRoot();
- }
- catch (IOException e)
- {
- throw new RuntimeException();
- }
- }
-
- public VirtualFile getRootFile()
- {
- return vfsRoot;
- }
-
- public URL getRelativeURL(String jar)
- {
- URL url = null;
- try
- {
- url = new URL(jar);
- }
- catch (MalformedURLException e)
- {
- try
- {
- if (jar.startsWith(".."))
- {
- if (getUrl() == null)
- throw new RuntimeException("relative <jar-file> not allowed when standalone deployment unit is used");
- String base = getUrl().toString();
- jar = jar.replaceAll("\\.\\./", "+");
- int idx = jar.lastIndexOf('+');
- jar = jar.substring(idx + 1);
- for (int i = 0; i < idx + 1; i++)
- {
- int slash = base.lastIndexOf('/');
- base = base.substring(0, slash + 1);
- }
- url = new URL(base + jar.substring(idx));
- }
- else
- {
- File fp = new File(jar);
- url = fp.toURL();
- }
- }
- catch (MalformedURLException e1)
- {
- throw new RuntimeException("Unable to find relative url: " + jar, e1);
- }
- }
- return url;
- }
-
- URL extractDescriptorUrl(String resource)
- {
- String urlStr = deploymentInfo.url.getFile();
- // However the jar must also contain at least one ejb-jar.xml
- try
- {
- URL dd = deploymentInfo.localCl.findResource(resource);
- if (dd == null)
- {
- return null;
- }
-
- // If the DD url is not a subset of the urlStr then this is coming
- // from a jar referenced by the deployment jar manifest and the
- // this deployment jar it should not be treated as an ejb-jar
- if (deploymentInfo.localUrl != null)
- {
- urlStr = deploymentInfo.localUrl.toString();
- }
-
- String ddStr = dd.toString();
- if (ddStr.indexOf(urlStr) >= 0)
- {
- return dd;
- }
- }
- catch (Exception ignore)
- {
- }
- return null;
- }
-
- public URL getPersistenceXml()
- {
- return extractDescriptorUrl("META-INF/persistence.xml");
- }
-
- public URL getEjbJarXml()
- {
- return extractDescriptorUrl("META-INF/ejb-jar.xml");
- }
-
- public URL getJbossXml()
- {
- return extractDescriptorUrl("META-INF/jboss.xml");
- }
-
- public List<Class> getClasses()
- {
- return null;
- }
-
- public ClassLoader getClassLoader()
- {
- return deploymentInfo.ucl;
- }
-
- public ClassLoader getResourceLoader()
- {
- return deploymentInfo.localCl;
- }
-
- public String getShortName()
- {
- return deploymentInfo.shortName;
- }
-
- public URL getUrl()
- {
- return deploymentInfo.url;
- }
-
- public String getDefaultEntityManagerName()
- {
- String url = getUrl().toString();
- String name = url.substring(url.lastIndexOf('/') + 1, url.lastIndexOf('.'));
- return name;
- }
-
- public Map getDefaultPersistenceProperties()
- {
- try
- {
- EJB3DeployerMBean deployer = (EJB3DeployerMBean) MBeanProxyExt.create(EJB3DeployerMBean.class, EJB3DeployerMBean.OBJECT_NAME,
- deploymentInfo.getServer());
-
- return deployer.getDefaultProperties();
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- }
-
-
- 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);
- try
- {
- vfsRoot.visit(visitor);
- }
- catch (IOException e)
- {
- throw new RuntimeException(e);
- }
- return visitor.getMatched();
-
- }
-
- public VirtualFile getMetaDataFile(String path)
- {
- try
- {
- return vfsRoot.getChild(path);
- }
- catch (IOException e)
- {
- log.debug("Cannot get meta data file: " + path);
- return null;
- }
- }
-}
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/JmxKernelAbstraction.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/JmxKernelAbstraction.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/JmxKernelAbstraction.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -1,180 +0,0 @@
-/*
- * 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;
-
-import javax.management.DynamicMBean;
-import javax.management.MBeanServer;
-import javax.management.ObjectName;
-import org.jboss.deployment.DeploymentInfo;
-import org.jboss.mx.util.MBeanProxyExt;
-import org.jboss.system.ServiceControllerMBean;
-import org.jboss.system.ServiceMBeanSupport;
-import org.jboss.logging.Logger;
-
-/**
- * Comment
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- */
-public class JmxKernelAbstraction
- extends JmxClientKernelAbstraction
- implements KernelAbstraction
-{
- private static final Logger log = Logger.getLogger(JmxKernelAbstraction.class);
-
- private MBeanServer server;
- private ServiceControllerMBean serviceController;
- private DeploymentInfo di;
-
- public JmxKernelAbstraction(DeploymentInfo di)
- {
- super(di.getServer());
- this.server = di.getServer();
- serviceController = (ServiceControllerMBean) MBeanProxyExt.create(ServiceControllerMBean.class, ServiceControllerMBean.OBJECT_NAME,
- di.getServer());
- this.di = di;
- }
-
- public JmxKernelAbstraction(MBeanServer server)
- {
- super(server);
- serviceController = (ServiceControllerMBean) MBeanProxyExt.create(ServiceControllerMBean.class, ServiceControllerMBean.OBJECT_NAME,
- server);
- }
-
- public void setMbeanServer(MBeanServer server)
- {
- this.server = server;
- }
-
-
- public void install(String name, DependencyPolicy dependencies, Object service)
- {
- if (!(service instanceof ServiceMBeanSupport) && !(service instanceof DynamicMBean))
- {
- log.debug("creating wrapper delegate for: " + service.getClass().getName());
- // create mbean delegate.
- service = new ServiceDelegateWrapper(service);
- }
- JmxDependencyPolicy policy = (JmxDependencyPolicy)dependencies;
- try
- {
- log.info("installing MBean: " + name + " with dependencies:");
- for (Object obj : policy.getDependencies())
- {
- log.info("\t" + obj);
- }
- ObjectName on = new ObjectName(name);
-
- if(policy.getDependencies().contains(on))
- throw new IllegalStateException("circular dependencies detected");
-
- server.registerMBean(service, on);
- addParentDependency(on);
-
- serviceController.create(on, policy.getDependencies());
- serviceController.start(on);
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- }
-
- private void addParentDependency(ObjectName on)
- {
- //di.mbeans.add(on);
-
- // this is done so that we can get dependency error messages.
- // and this is the only reason this is done.
- // if you don't put add to the top DI mbean list, then no dependency
- // error message is printed out if there is one.
- DeploymentInfo parent = di;
- while (parent.parent != null)
- {
- parent = parent.parent;
- }
- parent.mbeans.add(on);
-
- }
-
- private void removeParentDependency(ObjectName on)
- {
- DeploymentInfo parent = di;
- while (parent.parent != null)
- {
- parent = parent.parent;
- }
- parent.mbeans.remove(on);
- }
-
- public void installMBean(ObjectName on, DependencyPolicy dependencies, Object service)
- {
- JmxDependencyPolicy policy = (JmxDependencyPolicy)dependencies;
- try
- {
- server.registerMBean(service, on);
- addParentDependency(on);
- serviceController.create(on, policy.getDependencies());
- serviceController.start(on);
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- }
-
- public void uninstallMBean(ObjectName on)
- {
- try
- {
- serviceController.stop(on);
- serviceController.destroy(on);
- serviceController.remove(on);
- removeParentDependency(on);
- if(server.isRegistered(on))
- server.unregisterMBean(on);
- else
- log.warn(on + " is not registered");
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- }
-
- public void uninstall(String name)
- {
- ObjectName on;
- try
- {
- on = new ObjectName(name);
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
-
- uninstallMBean(on);
- }
-}
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/JndiProxyFactory.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/JndiProxyFactory.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/JndiProxyFactory.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -1,68 +0,0 @@
-/*
- * 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;
-
-import java.util.Hashtable;
-
-import javax.ejb.EJBException;
-
-import org.jnp.interfaces.MarshalledValuePair;
-import javax.naming.Context;
-import javax.naming.Name;
-import javax.naming.Reference;
-import javax.naming.spi.ObjectFactory;
-import org.jboss.logging.Logger;
-
-/**
- * Responsible for creating an EJB proxy
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- */
-public class JndiProxyFactory implements ObjectFactory
-{
- private static final Logger log = Logger.getLogger(JndiProxyFactory.class);
-
- public static final String FACTORY = "FACTORY";
-
- public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable environment) throws Exception
- {
- Reference ref = (Reference) obj;
- String factoryName = (String) ref.get(FACTORY).getContent();
-
- try
- {
- ProxyFactory factory = (ProxyFactory) nameCtx.lookup(factoryName);
-
- Object proxy = factory.createProxy();
- MarshalledValuePair marshalledProxy = new MarshalledValuePair(proxy);
- return marshalledProxy.get();
- }
- catch (EJBException e)
- {
- throw e;
- }
- catch (ClassCastException e)
- {
- throw new EJBException("Invalid invocation of local interface", e);
- }
- }
-}
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/JndiUtil.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/JndiUtil.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/JndiUtil.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -1,58 +0,0 @@
-/*
- * 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;
-
-import javax.naming.Context;
-import javax.naming.NameNotFoundException;
-import javax.naming.NamingException;
-
-import org.jboss.logging.Logger;
-
-/**
- * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
- */
-public class JndiUtil
-{
- private static final Logger log = Logger.getLogger(JndiUtil.class);
-
- public static Object lookup(Context jndiContext, String binding)
- throws NamingException
- {
- Object object = null;
-
- try
- {
- object = jndiContext.lookup(binding);
- }
- catch (NameNotFoundException e)
- {
- Context haCtx = InitialContextFactory.getHAContext(jndiContext);
- if(haCtx == null)
- throw e;
- object = haCtx.lookup(binding);
- }
-
- return object;
- }
-}
-
-
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/KernelAbstraction.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/KernelAbstraction.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/KernelAbstraction.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -1,45 +0,0 @@
-/*
- * 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;
-
-import javax.management.ObjectName;
-
-import javax.management.MBeanServer;
-
-/**
- * Abstraction for the underlying kernel (microcontainer or jmx kernel)
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- */
-public interface KernelAbstraction extends ClientKernelAbstraction
-{
- public void install(String name, DependencyPolicy dependencies, Object service);
-
- public void uninstall(String name);
-
- void installMBean(ObjectName on, DependencyPolicy dependencies, Object service);
-
- void uninstallMBean(ObjectName on);
-
- void setMbeanServer(MBeanServer server);
-}
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/KernelAbstractionFactory.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/KernelAbstractionFactory.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/KernelAbstractionFactory.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -1,100 +0,0 @@
-/*
- * 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;
-
-import javax.management.MBeanServer;
-import javax.management.MBeanServerConnection;
-
-import org.jboss.kernel.Kernel;
-import org.jboss.logging.Logger;
-
-/**
- * @version <tt>$Revision: 46471 $</tt>
- * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
- */
-public class KernelAbstractionFactory
-{
- private static final Logger log = Logger.getLogger(KernelAbstractionFactory.class);
-
- private static ClientKernelAbstraction clientKernelAbstraction = null;
- private static KernelAbstraction kernelAbstraction = null;
- private static Kernel kernel = null;
-
- public static KernelAbstraction getInstance() throws Exception
- {
- if (kernelAbstraction == null)
- {
- MBeanServer mbeanServer = (MBeanServer)getMBeanServer();
- if (kernel != null)
- kernelAbstraction = new MCKernelAbstraction(kernel, mbeanServer);
- else
- {
- kernelAbstraction = new JmxKernelAbstraction(mbeanServer);
- }
- }
-
- return kernelAbstraction;
- }
-
- public static ClientKernelAbstraction getClientInstance() throws Exception
- {
- if (clientKernelAbstraction == null)
- {
- if (kernel != null)
- {
- clientKernelAbstraction = new MCClientKernelAbstraction(kernel);
- }
- else
- {
- MBeanServerConnection mbeanServer = (MBeanServerConnection)getMBeanServer();
- clientKernelAbstraction = new JmxClientKernelAbstraction(mbeanServer);
- }
- }
-
- return clientKernelAbstraction;
- }
-
- public static void setKernel(Kernel k)
- {
- kernel = k;
- kernelAbstraction = null;
- clientKernelAbstraction = null;
- }
-
- protected static MBeanServerConnection getMBeanServer() throws Exception
- {
- MBeanServerConnection mbeanServer;
-
- try
- {
- mbeanServer = org.jboss.mx.util.MBeanServerLocator.locateJBoss();
- }
- catch (IllegalStateException e)
- {
- String adaptorName = System.getProperty("jbosstest.server.name", "jmx/invoker/RMIAdaptor");
- mbeanServer = (MBeanServerConnection)InitialContextFactory.getInitialContext().lookup(adaptorName);
- }
-
- return mbeanServer;
- }
-}
-
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/LocalProxy.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/LocalProxy.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/LocalProxy.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -1,85 +0,0 @@
-/*
- * 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;
-
-
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.lang.reflect.InvocationHandler;
-import org.jboss.ejb3.remoting.Proxy;
-import org.jboss.logging.Logger;
-
-/**
- * Comment
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- */
-public abstract class LocalProxy implements InvocationHandler, Externalizable, Proxy
-{
- private static Logger log = Logger.getLogger(LocalProxy.class);
-
- private transient Container container = null;
- protected String containerClusterUid;
- protected String containerGuid;
- protected String proxyName;
-
-
- public LocalProxy()
- {
- }
-
- protected LocalProxy(Container container)
- {
- this.container = container;
- this.containerGuid = Ejb3Registry.guid(container);
- this.containerClusterUid = Ejb3Registry.clusterUid(container);
- proxyName = container.getEjbName();
- }
-
- protected Container getContainer()
- {
- if(container == null)
- container = Ejb3Registry.findContainer(containerGuid);
- if(container == null)
- log.warn("Container " + containerGuid + " is not yet available");
- return container;
- }
-
- public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
- {
- this.containerGuid = in.readUTF();
- this.containerClusterUid = in.readUTF();
- this.proxyName = in.readUTF();
- }
-
- public void writeExternal(ObjectOutput out) throws IOException
- {
- out.writeUTF(containerGuid);
- out.writeUTF(containerClusterUid);
- out.writeUTF(proxyName);
- }
-
- public abstract String toString();
-}
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/MCClientKernelAbstraction.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/MCClientKernelAbstraction.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/MCClientKernelAbstraction.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -1,85 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., 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;
-
-import org.jboss.ejb3.embedded.resource.RARDeployment;
-import org.jboss.kernel.Kernel;
-import org.jboss.kernel.spi.registry.KernelRegistryEntry;
-import org.jboss.logging.Logger;
-
-import javax.management.ObjectName;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-
-/**
- * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
- */
-public class MCClientKernelAbstraction implements ClientKernelAbstraction
-{
- private static final Logger log = Logger.getLogger(MCClientKernelAbstraction.class);
-
- protected Kernel kernel;
-
- public MCClientKernelAbstraction(Kernel kernel)
- {
- this.kernel = kernel;
- }
-
- 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();
- if (target instanceof RARDeployment)
- {
- RARDeployment deployment = (RARDeployment) target;
- return deployment.invoke(operationName, params, signature);
- }
- else
- {
- 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;
- }
-
- 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;
- }
-}
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/MCDependencyPolicy.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/MCDependencyPolicy.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/MCDependencyPolicy.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -1,156 +0,0 @@
-/*
- * 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;
-
-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.dependency.EjbLinkDemandMetaData;
-import org.jboss.ejb3.javaee.JavaEEComponent;
-import org.jboss.ejb3.kernel.JNDIKernelRegistryPlugin;
-
-/**
- * dependency registry for Microcontainer
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- */
-public class MCDependencyPolicy 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 MCDependencyPolicy(JavaEEComponent component)
- {
- assert component != null : "component is null";
-
- 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 addDatasource(String jndiName)
- {
- String ds = jndiName;
- if (ds.startsWith("java:/"))
- {
- ds = ds.substring(6);
-
- }
- else if (ds.startsWith("java:"))
- {
- ds = ds.substring(5);
- }
- addDependency(ds);
- }
-
-
- public void addDependency(Class<?> businessInterface)
- {
- // TODO: more sophisticated
- 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)
- {
-// if (deploymentScope == null)
-// {
-// log.warn("ejb link '" + ejbLink + "' is relative, but no deployment scope found");
-// return null;
-// }
- String unitName = ejbLink.substring(0, hashIndex);
-// Ejb3Deployment dep = deploymentScope.findRelativeDeployment(relativePath);
-// if (dep == null)
-// {
-// log.warn("can't find a deployment for path '" + relativePath + "' of ejb link '" + ejbLink + "'");
-// return null;
-// }
- String ejbName = ejbLink.substring(hashIndex + 1);
- addDependency(component.createObjectName(unitName, ejbName));
- }
- else
- addDependency(new EjbLinkDemandMetaData(component, ejbLink));
- }
-
- public void addJNDIName(String name, ClassLoader loader)
- {
- 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;
- }
-}
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/MCKernelAbstraction.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/MCKernelAbstraction.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/MCKernelAbstraction.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -1,260 +0,0 @@
-/*
- * 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;
-
-import java.lang.reflect.Method;
-
-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.AbstractValueMetaData;
-import org.jboss.beans.metadata.plugins.AbstractDemandMetaData;
-import org.jboss.beans.metadata.spi.SupplyMetaData;
-import org.jboss.beans.metadata.spi.DemandMetaData;
-import org.jboss.kernel.Kernel;
-import org.jboss.kernel.spi.registry.KernelRegistryEntry;
-
-import org.jboss.ejb3.embedded.resource.RARDeployment;
-
-import org.jboss.logging.Logger;
-
-/**
- * Abstraction layer for installing beans into the micro container.
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- */
-public class MCKernelAbstraction
- extends MCClientKernelAbstraction
- implements KernelAbstraction
-{
- private static final Logger log = Logger.getLogger(MCKernelAbstraction.class);
-
- public static class AlreadyInstantiated extends AbstractConstructorMetaData
- {
- private static final long serialVersionUID = 8120833830553872619L;
-
- 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");
- }
- }
-
- private MBeanServer server;
-
- public MCKernelAbstraction(Kernel kernel, MBeanServer server)
- {
- super(kernel);
- this.server = server;
- }
-
- public void setMbeanServer(MBeanServer server)
- {
- this.server = server;
- }
-
- 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;
- }
-
- public void install(String name, DependencyPolicy dependencies, Object service)
- {
- 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 + " 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());
- }
- try
- {
- try
- {
- kernel.getController().uninstall(name);
- }
- catch (IllegalStateException e){}
-
- kernel.getController().install(bean);
- }
- catch (Throwable throwable)
- {
- throw new RuntimeException(throwable);
- }
- }
-
- public void installMBean(ObjectName on, DependencyPolicy dependencies, Object service)
- {
- try
- {
- server.registerMBean(service, on);
- install(on.getCanonicalName(), dependencies, service);
-
- // EJBTHREE-606: emulate the ServiceController calls
- MBeanInfo info = server.getMBeanInfo(on); // redundant call for speed
- invokeOptionalMethod(on, info, "create");
- invokeOptionalMethod(on, info, "start");
- }
- catch (Exception e)
- {
- e.printStackTrace();
- throw new RuntimeException(e);
- }
- }
-
- private void invokeOptionalMethod(ObjectName on, MBeanInfo info, String operationName) throws InstanceNotFoundException, MBeanException, ReflectionException
- {
- Object params[] = { };
- String signature[] = { };
- if(hasOperation(info, operationName))
- server.invoke(on, operationName, params, signature);
- }
-
- public void uninstallMBean(ObjectName on)
- {
- try
- {
- // EJBTHREE-606: emulate the ServiceController calls
- MBeanInfo info = server.getMBeanInfo(on); // redundant call for speed
- try
- {
- invokeOptionalMethod(on, info, "stop");
- }
- catch(Exception e)
- {
- // TODO: invalidate bean?
- log.warn("stop on " + on + " failed", e);
- }
- try
- {
- invokeOptionalMethod(on, info, "destroy");
- }
- catch(Exception e)
- {
- // TODO: invalidate bean?
- log.warn("destroy on " + on + " failed", e);
- }
-
- server.unregisterMBean(on);
- kernel.getController().uninstall(on.getCanonicalName());
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- }
-
- public void uninstall(String name)
- {
- try
- {
- log.info("uninstalling bean: " + name);
- kernel.getController().uninstall(name);
- }
- 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();
- if (target instanceof RARDeployment)
- {
- RARDeployment deployment = (RARDeployment)target;
- return deployment.invoke(operationName, params, signature);
- }
- else
- {
- 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;
- }
-}
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/NonSerializableFactory.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/NonSerializableFactory.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/NonSerializableFactory.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -1,106 +0,0 @@
-/*
- * 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;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.util.Map;
-import javax.naming.Context;
-import javax.naming.Name;
-import javax.naming.NamingException;
-import javax.naming.RefAddr;
-import javax.naming.Reference;
-import javax.naming.StringRefAddr;
-import javax.naming.spi.ObjectFactory;
-import org.jboss.naming.Util;
-
-/**
- * A utility class that allows one to bind a non-serializable object into a
- * local JNDI context. The binding will only be valid for the lifetime of the
- * VM in which the JNDI InitialContext lives. An example usage code snippet is:
- * <p/>
- * Internally, there is a static map that is keyed based on Context identityMap and the atom name of the target
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>.
- * @author <a href="mailto:Scott.Stark at jboss.org">Scott Stark</a>.
- * @version $Revision$
- * @see javax.naming.spi.ObjectFactory
- * @see #rebind(javax.naming.Context, String, Object)
- */
-public class NonSerializableFactory implements ObjectFactory
-{
- private static Map wrapperMap = Collections.synchronizedMap(new HashMap());
-
- public static void unbind(Context ctx, String strName) throws NamingException
- {
- Name name = ctx.getNameParser("").parse(strName);
- int size = name.size();
- String atom = name.get(size - 1);
- Context parentCtx = Util.createSubcontext(ctx, name.getPrefix(size - 1));
- String key = parentCtx.getNameInNamespace() + "/" + atom;
- wrapperMap.remove(key);
- Util.unbind(ctx, strName);
-
- }
-
- public static void rebind(Context ctx, String strName, Object value) throws javax.naming.NamingException
- {
- Name name = ctx.getNameParser("").parse(strName);
- int size = name.size();
- String atom = name.get(size - 1);
- Context parentCtx = Util.createSubcontext(ctx, name.getPrefix(size - 1));
- String key = parentCtx.getNameInNamespace() + "/" + atom;
- wrapperMap.put(key, value);
- String className = value.getClass().getName();
- String factory = NonSerializableFactory.class.getName();
- StringRefAddr addr = new StringRefAddr("nns", key);
- Reference memoryRef = new Reference(className, addr, factory, null);
- parentCtx.rebind(atom, memoryRef);
- }
-
- public static void bind(Context ctx, String strName, Object value) throws javax.naming.NamingException
- {
- Name name = ctx.getNameParser("").parse(strName);
- int size = name.size();
- String atom = name.get(size - 1);
- Context parentCtx = Util.createSubcontext(ctx, name.getPrefix(size - 1));
- String key = parentCtx.getNameInNamespace() + "/" + atom;
- wrapperMap.put(key, value);
- String className = value.getClass().getName();
- String factory = NonSerializableFactory.class.getName();
- StringRefAddr addr = new StringRefAddr("nns", key);
- Reference memoryRef = new Reference(className, addr, factory, null);
-
- parentCtx.bind(atom, memoryRef);
- }
-
- public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable env)
- throws Exception
- { // Get the nns value from the Reference obj and use it as the map key
- Reference ref = (Reference) obj;
- RefAddr addr = ref.get("nns");
- String key = (String) addr.getContent();
- return wrapperMap.get(key);
- }
-// --- End ObjectFactory interface methods
-}
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/PersistenceUnitRegistry.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/PersistenceUnitRegistry.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/PersistenceUnitRegistry.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -1,60 +0,0 @@
-/*
- * 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;
-
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.Collection;
-import org.jboss.logging.Logger;
-import org.jboss.ejb3.entity.PersistenceUnitDeployment;
-
-/**
- * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
- * @version <tt>$Revision$</tt>
- */
-public class PersistenceUnitRegistry
-{
- private static final Logger log = Logger.getLogger(PersistenceUnitRegistry.class);
-
- private static ConcurrentHashMap<String, PersistenceUnitDeployment> persistenceUnits = new ConcurrentHashMap<String, PersistenceUnitDeployment>();
-
- public static void register(PersistenceUnitDeployment container)
- {
- if (persistenceUnits.contains(container.getKernelName())) throw new RuntimeException("Persistence Unit is already registered: " + container.getKernelName());
- persistenceUnits.put(container.getKernelName(), container);
- }
-
- public static void unregister(PersistenceUnitDeployment container)
- {
- persistenceUnits.remove(container.getKernelName());
- }
-
- public static PersistenceUnitDeployment getPersistenceUnit(String kernelName)
- {
- return persistenceUnits.get(kernelName);
- }
-
- public static Collection<PersistenceUnitDeployment> getPersistenceUnits()
- {
- return persistenceUnits.values();
- }
-
-}
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/ProxyFactory.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/ProxyFactory.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/ProxyFactory.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -1,41 +0,0 @@
-/*
- * 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;
-
-/**
- * Comment
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- */
-public interface ProxyFactory
-{
- public Object createHomeProxy();
-
- public Object createProxy();
-
- public Object createProxy(Object id);
-
- public void start() throws Exception;
-
- public void stop() throws Exception;
-}
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/ProxyFactoryHelper.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/ProxyFactoryHelper.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/ProxyFactoryHelper.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -1,967 +0,0 @@
-/*
- * 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;
-
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import javax.ejb.EJBHome;
-import javax.ejb.EJBLocalHome;
-import javax.ejb.EJBLocalObject;
-import javax.ejb.EJBObject;
-import javax.ejb.Local;
-import javax.ejb.LocalHome;
-import javax.ejb.Remote;
-import javax.ejb.RemoteHome;
-import javax.jws.WebService;
-import javax.management.ObjectName;
-
-import org.jboss.ejb.LocalImpl;
-import org.jboss.ejb.RemoteImpl;
-import org.jboss.ejb3.annotation.JndiBindingPolicy;
-import org.jboss.ejb3.annotation.LocalBinding;
-import org.jboss.ejb3.annotation.LocalHomeBinding;
-import org.jboss.ejb3.annotation.RemoteBinding;
-import org.jboss.ejb3.annotation.RemoteBindings;
-import org.jboss.ejb3.annotation.RemoteHomeBinding;
-import org.jboss.ejb3.jndipolicy.DefaultJndiBindingPolicy;
-import org.jboss.ejb3.jndipolicy.Ejb3DeploymentSummary;
-import org.jboss.ejb3.jndipolicy.impl.PackagingBasedJndiBindingPolicy;
-import org.jboss.ejb3.lang.ClassHelper;
-import org.jboss.ejb3.remoting.RemoteProxyFactory;
-import org.jboss.ejb3.service.ServiceContainer;
-import org.jboss.ejb3.session.SessionContainer;
-import org.jboss.ejb3.stateful.StatefulContainer;
-import org.jboss.ejb3.stateless.StatelessContainer;
-import org.jboss.logging.Logger;
-
-/**
- * Comment
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- */
-public class ProxyFactoryHelper
-{
- private static final Logger log = Logger.getLogger(ProxyFactoryHelper.class);
-
- private static String getEndpointInterface(Container container)
- {
- WebService ws = (javax.jws.WebService) ((EJBContainer) container).resolveAnnotation(javax.jws.WebService.class);
- if (ws != null)
- {
- return ws.endpointInterface();
- }
- return null;
- }
-
- /**
- *
- * @param container
- * @return the local interfaces of the container or an empty array
- */
- public static Class<?>[] getLocalAndBusinessLocalInterfaces(Container container)
- {
- // Initialize
- Set<Class<?>> localAndBusinessLocalInterfaces = new HashSet<Class<?>>();
-
- // Obtain Bean Class
- Class<?> beanClass = container.getBeanClass();
-
- // Obtain @Local
- Local localAnnotation = ((EJBContainer) container).getAnnotation(Local.class);
-
- // Obtain @LocalHome
- LocalHome localHomeAnnotation = ((EJBContainer) container).getAnnotation(LocalHome.class);
-
- // Obtain @Remote
- Remote remoteAnnotation = ((EJBContainer) container).getAnnotation(Remote.class);
-
- // Obtain Remote and Business Remote interfaces
- Class<?>[] remoteAndBusinessRemoteInterfaces = ProxyFactoryHelper.getRemoteAndBusinessRemoteInterfaces(container);
-
- // Obtain all business interfaces from the bean class
- Set<Class<?>> businessInterfacesImplementedByBeanClass = ProxyFactoryHelper.getBusinessInterfaces(beanClass);
-
- // Obtain all business interfaces directly implemented by the bean class (not including supers)
- Set<Class<?>> businessInterfacesDirectlyImplementedByBeanClass = ProxyFactoryHelper.getBusinessInterfaces(
- beanClass, false);
-
- // Determine whether Stateful or Stateless
- boolean isStateless = (container instanceof StatelessContainer) ? true : false;
-
- // EJBTHREE-1127
- // Determine local interface from return value of "create" in Local Home
- if (localHomeAnnotation != null)
- {
- localAndBusinessLocalInterfaces.addAll(ProxyFactoryHelper.getReturnTypesFromCreateMethods(localHomeAnnotation
- .value(), isStateless));
- }
-
- // For each of the business interfaces implemented by the bean class
- for (Class<?> clazz : businessInterfacesImplementedByBeanClass)
- {
- // If @Local is on the interface
- if (clazz.isAnnotationPresent(Local.class))
- {
- // Add to the list of locals
- localAndBusinessLocalInterfaces.add(clazz);
- }
- }
-
- // EJBTHREE-1062
- // EJB 3 Core Specification 4.6.6
- // If bean class implements a single interface, that interface is assumed to be the
- // business interface of the bean. This business interface will be a local interface unless the
- // interface is designated as a remote business interface by use of the Remote
- // annotation on the bean class or interface or by means of the deployment descriptor.
- if (businessInterfacesDirectlyImplementedByBeanClass.size() == 1 && localAndBusinessLocalInterfaces.size() == 0)
- {
- // Obtain the implemented interface
- Class<?> singleInterface = businessInterfacesDirectlyImplementedByBeanClass.iterator().next();
-
- // If not explicitly marked as @Remote, and is a valid business interface
- if (remoteAnnotation == null && singleInterface.getAnnotation(Remote.class) == null)
- {
- // Return the implemented interface, adding to the container
- Class<?>[] returnValue = new Class[]
- {singleInterface};
- Local li = new LocalImpl(returnValue);
- ((EJBContainer) container).getAnnotations().addClassAnnotation(Local.class, li);
- return returnValue;
- }
- }
-
- // @Local was defined
- if (localAnnotation != null)
- {
- // If @Local has no value or empty value
- if (localAnnotation.value() == null || localAnnotation.value().length == 0)
- {
- // If @Local is defined with no value and there are no business interfaces
- if (businessInterfacesImplementedByBeanClass.size() == 0)
- {
- throw new RuntimeException("Use of empty @Local on bean " + container.getEjbName()
- + " and there are no valid business interfaces");
- }
- // If more than one business interface is directly implemented by the bean class
- else if (businessInterfacesImplementedByBeanClass.size() > 1)
- {
- throw new RuntimeException("Use of empty @Local on bean " + container.getEjbName()
- + " with more than one default interface " + businessInterfacesImplementedByBeanClass);
- }
- // JIRA EJBTHREE-1062
- // EJB 3 4.6.6
- // If the bean class implements only one business interface, that
- //interface is exposed as local business if not denoted as @Remote
- else
- {
- // If not explicitly marked as @Remote
- if (remoteAnnotation == null)
- {
- // Return the implemented interface and add to container
- Class<?>[] returnValue = businessInterfacesImplementedByBeanClass.toArray(new Class<?>[]
- {});
- Local li = new LocalImpl(returnValue);
- ((EJBContainer) container).getAnnotations().addClassAnnotation(Local.class, li);
- return returnValue;
- }
- }
- }
- // @Local has value
- else
- {
- // For each of the interfaces in @Local.value
- for (Class<?> clazz : localAnnotation.value())
- {
- // Add to the list of locals
- localAndBusinessLocalInterfaces.add(clazz);
- }
-
- // For each of the business interfaces implemented by the bean class
- for (Class<?> clazz : businessInterfacesImplementedByBeanClass)
- {
- // If @Local is on the interface
- if (clazz.isAnnotationPresent(Local.class))
- {
- // Add to the list of locals
- localAndBusinessLocalInterfaces.add(clazz);
- }
- }
- }
- }
-
- // If local interfaces have been defined/discovered
- if (localAndBusinessLocalInterfaces.size() > 0)
- {
- // Check to ensure @Local and @Remote are not defined on the same interface
- // EJBTHREE-751
- for (Class<?> remoteInterface : remoteAndBusinessRemoteInterfaces)
- {
- for (Class<?> localInterface : localAndBusinessLocalInterfaces)
- {
- if (localInterface.equals(remoteInterface))
- {
- throw new RuntimeException("@Remote and @Local may not both be specified on the same interface \""
- + remoteInterface.toString() + "\" per EJB3 Spec 4.6.7, Bullet 5.4");
- }
- }
- }
-
- // Return local interfaces, first adding to the container
- Class<?>[] rtn = localAndBusinessLocalInterfaces.toArray(new Class<?>[]
- {});
- localAnnotation = new LocalImpl(rtn);
- ((EJBContainer) container).getAnnotations().addClassAnnotation(Local.class, localAnnotation);
- return rtn;
- }
- // If no local interfaces have been defined/discovered
- else
- {
- // Obtain WS Endpoint
- String endpoint = ProxyFactoryHelper.getEndpointInterface(container);
-
- // If neither WS Endpoint or remotes are defined
- if (remoteAndBusinessRemoteInterfaces.length == 0 && endpoint == null)
- throw new RuntimeException(
- "Bean Class "
- + beanClass.getName()
- + " has no local, webservice, or remote interfaces defined and does not implement at least one business interface: "
- + container.getEjbName());
-
- }
-
- // No local or business local interfaces discovered
- return new Class<?>[]
- {};
- }
-
- /**
- * Resolve the potential business interfaces on an enterprise bean.
- * Returns all interfaces implemented by this class and its supers which
- * are potentially a business interface.
- *
- * Note: for normal operation call container.getBusinessInterfaces().
- *
- * @param beanClass the EJB implementation class
- * @return a list of potential business interfaces
- * @see org.jboss.ejb3.EJBContainer#getBusinessInterfaces()
- */
- public static Set<Class<?>> getBusinessInterfaces(Class<?> beanClass)
- {
- // Obtain all business interfaces implemented by this bean class and its superclasses
- return ProxyFactoryHelper.getBusinessInterfaces(beanClass, new HashSet<Class<?>>());
- }
-
- /**
- * Resolve the potential business interfaces on an enterprise bean.
- * Returns all interfaces implemented by this class and, optionally, its supers which
- * are potentially a business interface.
- *
- * Note: for normal operation call container.getBusinessInterfaces().
- *
- * @param beanClass the EJB implementation class
- * @param includeSupers Whether or not to include superclasses of the specified beanClass in this check
- * @return a list of potential business interfaces
- * @see org.jboss.ejb3.EJBContainer#getBusinessInterfaces()
- */
- public static Set<Class<?>> getBusinessInterfaces(Class<?> beanClass, boolean includeSupers)
- {
- // Obtain all business interfaces implemented by this bean class and optionally, its superclass
- return ProxyFactoryHelper.getBusinessInterfaces(beanClass, new HashSet<Class<?>>(), includeSupers);
- }
-
- private static Set<Class<?>> getBusinessInterfaces(Class<?> beanClass, Set<Class<?>> interfaces)
- {
- return ProxyFactoryHelper.getBusinessInterfaces(beanClass, interfaces, true);
- }
-
- private static Set<Class<?>> getBusinessInterfaces(Class<?> beanClass, Set<Class<?>> interfaces,
- boolean includeSupers)
- {
- /*
- * 4.6.6:
- * The following interfaces are excluded when determining whether the bean class has
- * more than one interface: java.io.Serializable; java.io.Externalizable;
- * any of the interfaces defined by the javax.ejb package.
- */
- for (Class<?> intf : beanClass.getInterfaces())
- {
- if (intf.equals(java.io.Externalizable.class))
- continue;
- if (intf.equals(java.io.Serializable.class))
- continue;
- if (intf.getName().startsWith("javax.ejb"))
- continue;
-
- // FIXME Other aop frameworks might add other interfaces, this should really be configurable
- if (intf.getName().startsWith("org.jboss.aop"))
- continue;
-
- interfaces.add(intf);
- }
-
- // If there's no superclass, or we shouldn't check the superclass, return
- if (!includeSupers || beanClass.getSuperclass() == null)
- {
- return interfaces;
- }
- else
- {
- // Include any superclasses' interfaces
- return getBusinessInterfaces(beanClass.getSuperclass(), interfaces);
- }
- }
-
- public static Class<?> getLocalHomeInterface(Container container)
- {
- LocalHome li = ((EJBContainer) container).getAnnotation(javax.ejb.LocalHome.class);
- if (li != null)
- return li.value();
- return null;
- }
-
- public static Class<?> getRemoteHomeInterface(Container container)
- {
- RemoteHome li = ((EJBContainer) container).getAnnotation(javax.ejb.RemoteHome.class);
- if (li != null)
- return li.value();
- return null;
- }
-
- public static boolean publishesInterface(Container container, Class<?> businessInterface)
- {
- if (!(container instanceof SessionContainer))
- return false;
- Class<?>[] remotes = getRemoteAndBusinessRemoteInterfaces(container);
- for (Class<?> intf : remotes)
- {
- if (intf.getName().equals(businessInterface.getName()))
- return true;
- }
-
- Class<?> remoteHome = getRemoteHomeInterface(container);
- if (remoteHome != null)
- {
- if (businessInterface.getName().equals(remoteHome.getName()))
- {
- return true;
- }
- }
- Class<?>[] locals = getLocalAndBusinessLocalInterfaces(container);
- for (Class<?> clazz : locals)
- {
- if (clazz.getName().equals(businessInterface.getName()))
- {
- return true;
- }
- }
- Class<?> localHome = getLocalHomeInterface(container);
- if (localHome != null)
- {
- if (businessInterface.getName().equals(localHome.getName()))
- {
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * Obtains the JNDI name for the specified container; may either be explicitly-defined by
- * annotation / XML or will otherwise default to the configured JNDI Binding Policy
- *
- * @param container
- * @param businessInterface
- * @return
- */
- public static String getJndiName(Container container, Class<?> businessInterface)
- {
- assert container != null : "container is null";
- assert businessInterface != null : "businessInterface is null";
-
- // Initialize to defaults of remote and not home
- String jndiName = null;
- boolean isHome = false;
- boolean isLocal = false;
-
- // Determine if remote
- Class<?>[] remotes = ProxyFactoryHelper.getRemoteAndBusinessRemoteInterfaces(container);
- for (Class<?> clazz : remotes)
- {
- if (clazz.getName().equals(businessInterface.getName()))
- {
- // Check for declared @RemoteBindings
- RemoteBindings bindings = ((EJBContainer) container).getAnnotation(RemoteBindings.class);
- if (bindings != null)
- {
- // Encountered, return
- return bindings.value()[0].jndiBinding();
- }
- // Check for declared @RemoteBinding
- RemoteBinding binding = ((EJBContainer) container).getAnnotation(RemoteBinding.class);
- if (binding != null)
- {
- // Encountered, return
- return binding.jndiBinding();
- }
- }
- }
-
- // Determine if remote home
- Class<?> remoteHome = getRemoteHomeInterface(container);
- if (remoteHome != null)
- {
- if (businessInterface.getName().equals(remoteHome.getName()))
- {
- // Check for declared @RemoteHomeBinding
- RemoteHomeBinding binding = ((EJBContainer) container).getAnnotation(RemoteHomeBinding.class);
- if (binding != null)
- {
- // Encountered, return
- return binding.jndiBinding();
- }
-
- // Set home for policy
- isHome = true;
- }
- }
-
- // Determine if local and home
- Class<?> localHome = getLocalHomeInterface(container);
- if (localHome != null)
- {
- if (businessInterface.getName().equals(localHome.getName()))
- {
- // Check for declared @LocalHomeBinding
- LocalHomeBinding binding = ((EJBContainer) container).getAnnotation(LocalHomeBinding.class);
- if (binding != null)
- {
- // Encountered, return
- return binding.jndiBinding();
- }
-
- // Set local and home for policy
- isHome = true;
- isLocal = true;
- }
- }
-
- // Determine if local
- Class<?>[] locals = getLocalAndBusinessLocalInterfaces(container);
- for (Class<?> clazz : locals)
- {
- if (clazz.getName().equals(businessInterface.getName()))
- {
- // Check for declared @LocalBinding
- LocalBinding binding = ((EJBContainer) container).getAnnotation(LocalBinding.class);
- if (binding != null)
- {
- // Encountered, return
- return binding.jndiBinding();
- }
-
- // Set local for policy
- isLocal = true;
- }
- }
-
- // If JNDI Name has not been explicitly specified, use policy
- if (jndiName == null)
- {
- // Log
- log.debug("JNDI name has not been explicitly set for EJB " + container.getEjbName() + ", interface "
- + businessInterface.getName());
-
- // Set JNDI name
- Ejb3DeploymentSummary summary = ProxyFactoryHelper.getDeploymentSummaryFromContainer(container);
- summary.setHome(isHome);
- summary.setLocal(isLocal);
- jndiName = ProxyFactoryHelper.getJndiBindingPolicy(container).getJndiName(summary);
- }
-
- // Return
- return jndiName;
- }
-
- /**
- * Returns all local interfaces in the specified container; interfaces
- * marked as "local" via either annotation or XML and extending EJBLocalObject
- *
- * @param container
- * @return
- */
- public static Class<?>[] getLocalInterfaces(Container container)
- {
- return ProxyFactoryHelper.getInterfacesAssignableFromClass(ProxyFactoryHelper
- .getLocalAndBusinessLocalInterfaces(container), EJBLocalObject.class, true);
- }
-
- /**
- * Returns all remote interfaces in the specified container; interfaces
- * marked as "remote" via either annotation or XML and extending EJBObject
- *
- * @param container
- * @return
- */
- public static Class<?>[] getRemoteInterfaces(Container container)
- {
- return ProxyFactoryHelper.getInterfacesAssignableFromClass(ProxyFactoryHelper
- .getRemoteAndBusinessRemoteInterfaces(container), EJBObject.class, true);
- }
-
- /**
- * Returns all local business interfaces in the specified container; interfaces
- * marked as "local" via either annotation or XML and not extending EJBLocalObject
- *
- * @param container
- * @return
- */
- public static Class<?>[] getLocalBusinessInterfaces(Container container)
- {
- return ProxyFactoryHelper.getInterfacesAssignableFromClass(ProxyFactoryHelper
- .getLocalAndBusinessLocalInterfaces(container), EJBLocalObject.class, false);
- }
-
- /**
- * Returns all remote business interfaces in the specified container; interfaces
- * marked as "remote" via either annotation or XML and not extending EJBObject
- *
- * @param container
- * @return
- */
- public static Class<?>[] getRemoteBusinessInterfaces(Container container)
- {
- return ProxyFactoryHelper.getInterfacesAssignableFromClass(ProxyFactoryHelper
- .getRemoteAndBusinessRemoteInterfaces(container), EJBObject.class, false);
- }
-
- /**
- * Returns an subset of the specified array of interfaces either
- * assignable to or not assignable to the specified class, depending
- * upon the flag "assignable"
- *
- * @param interfaces
- * @param clazz
- * @param assignable
- * @return
- */
- private static Class<?>[] getInterfacesAssignableFromClass(Class<?>[] interfaces, Class<?> clazz, boolean assignable)
- {
- // Initialize
- List<Class<?>> subset = new ArrayList<Class<?>>();
-
- // For all interfaces
- for (Class<?> interfaze : interfaces)
- {
- // If we want assignable classes only
- if (assignable && clazz.isAssignableFrom(interfaze))
- {
- subset.add(interfaze);
- }
-
- // If we want classes not assignable only
- if (!assignable && !clazz.isAssignableFrom(interfaze))
- {
- subset.add(interfaze);
- }
- }
-
- // Return
- return subset.toArray(new Class<?>[]
- {});
- }
-
- /**
- * Returns all remote and remote business interfaces in the specified container,
- * designated by @Remote or in ejb-jar.xml as "remote" or "business-remote"
- *
- * @param container
- * @return the remote interfaces of the container or an empty array
- */
- public static Class<?>[] getRemoteAndBusinessRemoteInterfaces(Container container)
- {
- // Initialize
- Remote remoteAnnotation = ((EJBContainer) container).getAnnotation(Remote.class);
- RemoteHome remoteHomeAnnotation = ((EJBContainer) container).getAnnotation(RemoteHome.class);
- Set<Class<?>> remoteAndRemoteBusinessInterfaces = new HashSet<Class<?>>();
- Class<?> beanClass = container.getBeanClass();
- boolean isStateless = (container instanceof StatelessContainer) ? true : false;
-
- // Obtain business interfaces
- Class<?>[] businessInterfaces = ProxyFactoryHelper.getBusinessInterfaces(beanClass).toArray(new Class[]
- {});
-
- // EJBTHREE-1127
- // Determine remote interface from return value of "create" in Remote Home
- if (remoteHomeAnnotation != null)
- {
- remoteAndRemoteBusinessInterfaces.addAll(ProxyFactoryHelper.getReturnTypesFromCreateMethods(
- remoteHomeAnnotation.value(), isStateless));
- }
-
- // If @Remote is not defined
- if (remoteAnnotation == null)
- {
- // For each of the business interfaces
- for (Class<?> clazz : businessInterfaces)
- {
- // If @Remote is on the business interface
- if (clazz.isAnnotationPresent(Remote.class))
- {
- // Add to the list of remotes
- remoteAndRemoteBusinessInterfaces.add(clazz);
- }
- }
- }
- // @Remote was defined
- else
- {
- // @Remote declares interfaces, add these
- if (remoteAnnotation.value().length > 0)
- {
- for (Class<?> clazz : remoteAnnotation.value())
- {
- remoteAndRemoteBusinessInterfaces.add(clazz);
- }
- }
- // @Remote is empty
- else
- {
- // No business interfaces were defined on the bean
- if (businessInterfaces.length == 0)
- {
- throw new RuntimeException("Use of empty @Remote on bean " + container.getEjbName()
- + " and there are no valid business interfaces");
- }
-
- // More than one default interface, cannot be marked as @Remote
- else if (businessInterfaces.length > 1)
- {
- throw new RuntimeException("Use of empty @Remote on bean " + container.getEjbName()
- + " with more than one default interface " + businessInterfaces);
- }
- // Only one default interface, mark as @Remote and return
- else
- {
- Class<?>[] rtn =
- {(Class<?>) businessInterfaces[0]};
- remoteAnnotation = new RemoteImpl(rtn);
- ((EJBContainer) container).getAnnotations().addClassAnnotation(javax.ejb.Remote.class, remoteAnnotation);
- return rtn;
- }
- }
- }
-
- // If remotes were found
- if (remoteAndRemoteBusinessInterfaces.size() > 0)
- {
- // Set interfaces and return
- Class<?>[] remotesArray = remoteAndRemoteBusinessInterfaces
- .toArray(new Class[remoteAndRemoteBusinessInterfaces.size()]);
- remoteAnnotation = new RemoteImpl(remotesArray);
- ((EJBContainer) container).getAnnotations().addClassAnnotation(Remote.class, remoteAnnotation);
- return remoteAnnotation.value();
- }
- // No remotes were found
- else
- {
- return new Class<?>[]
- {};
- }
- }
-
- /**
- * Obtains the return types declared by the "create" methods for the specified home interface.
- *
- * @param homeInterface
- * @param isStateless Flag to indicate whether this is for a Stateful or Stateless container
- * @return
- */
- private static Set<Class<?>> getReturnTypesFromCreateMethods(Class<?> homeInterface, boolean isStateless)
- {
- // Ensure we've been passed a Home or LocalHome interface (Developers only)
- assert (EJBHome.class.isAssignableFrom(homeInterface) || EJBLocalHome.class.isAssignableFrom(homeInterface));
-
- // Ensure we've been passed a Home or LocalHome interface (End-User)
- if (!EJBHome.class.isAssignableFrom(homeInterface) && !EJBLocalHome.class.isAssignableFrom(homeInterface))
- {
- throw new RuntimeException("Declared EJB 2.1 Home Interface " + homeInterface.getName() + " does not extend "
- + EJBHome.class.getName() + " or " + EJBLocalHome.class.getName()
- + " as required by EJB 3.0 Core Specification 4.6.8 and 4.6.10");
- }
-
- // Initialize
- Set<Class<?>> types = new HashSet<Class<?>>();
- List<Method> createMethods = null;
-
- // If for a Stateless Container
- if (isStateless)
- {
- // Initialize error message
- String specViolationErrorMessage = "EJB 3.0 Specification Violation (4.6.8 Bullet 4, 4.6.10 Bullet 4): \""
- + "A stateless session bean must define exactly one create method with no arguments." + "\"; found in "
- + homeInterface.getName();
-
- // Get all methods with signature "create"
- createMethods = new ArrayList<Method>();
- try
- {
- createMethods.add(homeInterface.getMethod("create", new Class<?>[]
- {}));
- }
- // EJB 3.0 Specification 4.6.8 Bullet 4 Violation
- // EJBTHREE-1156
- catch (NoSuchMethodException e)
- {
- throw new RuntimeException(specViolationErrorMessage);
- }
-
- // Ensure only one create method is defined
- // EJB 3.0 Specification 4.6.8 Bullet 4 Violation
- // EJBTHREE-1156
- if (createMethods.size() > 1)
- {
- throw new RuntimeException(specViolationErrorMessage);
- }
- }
- else
- {
- // Obtain all "create<METHOD>" methods
- createMethods = ClassHelper.getAllMethodsByPrefix(homeInterface, "create");
- }
- if (createMethods.size() == 0)
- {
- throw new RuntimeException("EJB 3.0 Core Specification Violation (4.6.8 Bullet 5): EJB2.1 Home Interface "
- + homeInterface + " does not declare a \'create<METHOD>\' method");
- }
-
- // Add all return types
- for (Method method : createMethods)
- {
- types.add(method.getReturnType());
- }
-
- // Return
- return types;
- }
-
- public static String getClientBindUrl(RemoteBinding binding) throws Exception
- {
- String clientBindUrl = binding.clientBindUrl();
- if (clientBindUrl.trim().length() == 0)
- {
- ObjectName connectionON = new ObjectName(
- "jboss.remoting:type=Connector,name=DefaultEjb3Connector,handler=ejb3");
- KernelAbstraction kernelAbstraction = KernelAbstractionFactory.getInstance();
- try
- {
- clientBindUrl = (String) kernelAbstraction.getAttribute(connectionON, "InvokerLocator");
- if (clientBindUrl == null)
- clientBindUrl = RemoteProxyFactory.DEFAULT_CLIENT_BINDING;
- }
- catch (Exception e)
- {
- clientBindUrl = RemoteProxyFactory.DEFAULT_CLIENT_BINDING;
- }
- }
-
- return clientBindUrl;
- }
-
- public static String getHomeJndiName(EJBContainer container)
- {
- // Initialize
-
- // Use explicitly-specified binding, if defined
- RemoteHomeBinding binding = (RemoteHomeBinding) container.resolveAnnotation(RemoteHomeBinding.class);
- if (binding != null)
- return binding.jndiBinding();
-
- // Use Default JNDI Binding Policy
- return ProxyFactoryHelper.getJndiBindingPolicy(container).getDefaultRemoteHomeJndiName(
- ProxyFactoryHelper.getDeploymentSummaryFromContainer(container));
- }
-
- public static String getLocalHomeJndiName(EJBContainer container)
- {
- // Initialize
-
- // Use explicitly-specified binding, if defined
- LocalHomeBinding binding = (LocalHomeBinding) container.resolveAnnotation(LocalHomeBinding.class);
- if (binding != null)
- return binding.jndiBinding();
-
- // Use Default JNDI Binding Policy
- return ProxyFactoryHelper.getJndiBindingPolicy(container).getDefaultLocalHomeJndiName(
- ProxyFactoryHelper.getDeploymentSummaryFromContainer(container));
- }
-
- public static String getLocalJndiName(EJBContainer container)
- {
- return getLocalJndiName(container, true);
- }
-
- private static String getLocalJndiName(EJBContainer container, boolean conflictCheck)
- {
- // Initialize
-
- // See if local binding is explicitly-defined
- LocalBinding localBinding = (LocalBinding) container.resolveAnnotation(LocalBinding.class);
-
- // If none specified
- if (localBinding == null)
- {
- // Get JNDI name from policy
- String name = ProxyFactoryHelper.getJndiBindingPolicy(container).getDefaultLocalJndiName(
- ProxyFactoryHelper.getDeploymentSummaryFromContainer(container));
-
- if (conflictCheck)
- checkForJndiNamingConflict(container);
-
- return name;
- }
- // Local Binding was explicitly-specified, use it
- else
- {
- return localBinding.jndiBinding();
- }
- }
-
- public static String getRemoteJndiName(EJBContainer container)
- {
- return getRemoteJndiName(container, true);
- }
-
- public static String getRemoteJndiName(EJBContainer container, boolean check)
- {
- RemoteBinding binding = (RemoteBinding) container.resolveAnnotation(RemoteBinding.class);
-
- return getRemoteJndiName(container, binding);
- }
-
- private static void checkForJndiNamingConflict(EJBContainer container)
- {
- if (container.resolveAnnotation(Local.class) != null)
- {
- Ejb3DeploymentSummary summary = ProxyFactoryHelper.getDeploymentSummaryFromContainer(container);
- String localJndiName = ProxyFactoryHelper.getJndiBindingPolicy(container).getDefaultLocalJndiName(summary);
- String remoteJndiName = ProxyFactoryHelper.getJndiBindingPolicy(container).getDefaultRemoteJndiName(summary);
- String ejbName = container.getEjbName();
- if ((localJndiName.equals(remoteJndiName)))
- {
- throw new javax.ejb.EJBException("Conflict between default jndi name " + remoteJndiName
- + " for both remote and local for ejb-name:" + ejbName + ", bean class=" + container.getBeanClass());
- }
-
- }
- }
-
- private static String getRemoteJndiName(EJBContainer container, RemoteBinding binding)
- {
- return getRemoteJndiName(container, binding, true);
- }
-
- public static String getRemoteJndiName(EJBContainer container, RemoteBinding binding, boolean conflictCheck)
- {
- String jndiName = null;
- if (binding == null || binding.jndiBinding() == null || binding.jndiBinding().equals(""))
- {
- jndiName = getDefaultRemoteJndiName(container);
-
- if (conflictCheck)
- checkForJndiNamingConflict(container);
- }
- else
- {
- jndiName = binding.jndiBinding();
- }
-
- return jndiName;
- }
-
- public static String getDefaultRemoteJndiName(EJBContainer container)
- {
- return ProxyFactoryHelper.getJndiBindingPolicy(container).getDefaultRemoteJndiName(
- ProxyFactoryHelper.getDeploymentSummaryFromContainer(container));
- }
-
- /**
- * Obtains the JNDI Binding Policy for the specified container
- *
- * @param container
- * @author ALR
- * @return
- */
- private static DefaultJndiBindingPolicy getJndiBindingPolicy(Container container)
- {
- EJBContainer ejbContainer = (EJBContainer) container;
- JndiBindingPolicy bindingPolicy = ejbContainer.getAnnotation(JndiBindingPolicy.class);
- Class<? extends DefaultJndiBindingPolicy> policy = null;
- if (bindingPolicy != null)
- policy = bindingPolicy.policy();
- else
- {
- Class<? extends DefaultJndiBindingPolicy> policyClass = PackagingBasedJndiBindingPolicy.class;
- log.warn("No default JNDI Binding Policy Defined (see ejb3-interceptors-aop.xml for example); defaulting to "
- + policyClass.getName());
- policy = policyClass;
- }
- log.debug("Obtaining JNDI name from policy " + policy.getName());
- try
- {
- return policy.newInstance();
- }
- catch (InstantiationException e)
- {
- throw new RuntimeException("Could not instanciate JNDI Binding Policy: " + policy.getName(), e);
- }
- catch (IllegalAccessException e)
- {
- throw new RuntimeException(e);
- }
- }
-
- private static Ejb3DeploymentSummary getDeploymentSummaryFromContainer(Container container)
- {
- // Construct Deployment Summary
- Ejb3DeploymentSummary summary = new Ejb3DeploymentSummary();
- summary.setEjbName(container.getEjbName());
- summary.setService(container instanceof ServiceContainer);
- summary.setStateful(container instanceof StatefulContainer);
- summary.setDeploymentName(((EJBContainer) container).getDeployment().getName());
- summary.setBeanClass(container.getBeanClass());
- if (container instanceof EJBContainer)
- {
- DeploymentScope scope = ((EJBContainer) container).getDeployment().getEar();
- if (scope != null)
- {
- summary.setDeploymentScopeBaseName(scope.getBaseName());
- }
- }
- return summary;
- }
-}
\ No newline at end of file
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/ProxyUtils.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/ProxyUtils.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/ProxyUtils.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -1,160 +0,0 @@
-/*
- * 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;
-
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import javax.ejb.EJBHome;
-import javax.ejb.EJBObject;
-import org.jboss.aop.advice.Interceptor;
-import org.jboss.aop.joinpoint.MethodInvocation;
-import org.jboss.aop.util.MethodHashing;
-import org.jboss.aop.util.PayloadKey;
-import org.jboss.aspects.asynch.AsynchMixin;
-import org.jboss.aspects.asynch.AsynchProvider;
-import org.jboss.aspects.asynch.AsynchProxyInterceptor;
-import org.jboss.aspects.asynch.FutureHolder;
-import org.jboss.ejb3.asynchronous.AsynchronousInterceptor;
-import org.jboss.ejb3.remoting.Proxy;
-
-/**
- * @author <a href="mailto:kabir.khan at jboss.org">Kabir Khan</a>
- * @version $Revision$
- */
-public class ProxyUtils
-{
- public final static Class ASYNCH_PROVIDER_CLASS = AsynchProvider.class;
- public final static long GET_ASYNCHRONOUS;
- public static final long TO_STRING;
- public static final long EQUALS;
- public static final long HASHCODE;
- public static final Method GET_PRIMARY_KEY;
- public static final Method GET_HANDLE;
- public static final Method GET_EJB_HOME;
- public static final Method IS_IDENTICAL;
- public static final Method GET_HOME_HANDLE;
- public static final Method GET_EJB_METADATA;
- public static final Method REMOVE;
-
- static
- {
- try
- {
- Class[] empty = {};
-
- Method method = JBossProxy.class.getMethod("getAsynchronousProxy", empty);
- GET_ASYNCHRONOUS = MethodHashing.calculateHash(method);
- TO_STRING = MethodHashing.calculateHash(Object.class.getDeclaredMethod("toString", empty));
- EQUALS = MethodHashing.calculateHash(Object.class.getDeclaredMethod("equals", new Class[]{Object.class}));
- HASHCODE = MethodHashing.calculateHash(Object.class.getDeclaredMethod("hashCode", empty));
-
- GET_PRIMARY_KEY = EJBObject.class.getMethod("getPrimaryKey", empty);
- GET_HANDLE = EJBObject.class.getMethod("getHandle", empty);
- GET_EJB_HOME = EJBObject.class.getMethod("getEJBHome", empty);
- IS_IDENTICAL = EJBObject.class.getMethod("isIdentical", new Class[] { EJBObject.class });
- REMOVE = EJBObject.class.getMethod("remove", empty);
-
- GET_HOME_HANDLE = EJBHome.class.getMethod("getHomeHandle", empty);
- GET_EJB_METADATA = EJBHome.class.getMethod("getEJBMetaData", empty);
- }
- catch (NoSuchMethodException e)
- {
- throw new RuntimeException(e);
- }
- }
-
- public static boolean isAsynchronous(Class[] infs)
- {
- for (int i = 0; i < infs.length; i++)
- {
- if (infs[i] == ASYNCH_PROVIDER_CLASS)
- {
- return true;
- }
- }
- return false;
- }
-
- public static Class[] addAsynchProviderInterface(Class[] infs)
- {
- ArrayList interfaces = new ArrayList();
-
- for (int i = 0; i < infs.length; i++)
- {
- if (infs[i] == ASYNCH_PROVIDER_CLASS)
- {
- //This should not happen
- continue;
- }
- interfaces.add(infs[i]);
- }
-
- interfaces.add(ASYNCH_PROVIDER_CLASS);
- return (Class[]) interfaces.toArray(new Class[interfaces.size()]);
- }
-
- public static Interceptor[] addAsynchProxyInterceptor(AsynchMixin mixin, Interceptor[] interceptors)
- {
- AsynchProxyInterceptor interceptor = new AsynchProxyInterceptor(mixin);
- Interceptor[] newInterceptors = null;
- newInterceptors = new Interceptor[interceptors.length + 1];
- newInterceptors[0] = interceptor;
- System.arraycopy(interceptors, 0, newInterceptors, 1, interceptors.length);
- return newInterceptors;
- }
-
- public static void addLocalAsynchronousInfo(MethodInvocation invocation, FutureHolder provider)
- {
- if (provider != null)
- {
- invocation.getMetaData().addMetaData(AsynchronousInterceptor.ASYNCH, AsynchronousInterceptor.INVOKE_ASYNCH, "YES", PayloadKey.AS_IS);
- invocation.getMetaData().addMetaData(AsynchronousInterceptor.ASYNCH, AsynchronousInterceptor.FUTURE_HOLDER, provider, PayloadKey.AS_IS);
- }
- }
-
- public static Object handleCallLocally(Object jbproxy, Proxy ih, Method m, Object[] args)
- {
- long hash = MethodHashing.calculateHash(m);
- return handleCallLocally(hash, jbproxy, ih, m, args);
- }
-
- public static Object handleCallLocally(long hash, Object jbproxy, Proxy ih, Method m, Object[] args)
- {
- if (hash == ProxyUtils.GET_ASYNCHRONOUS)
- {
- return ih.getAsynchronousProxy((JBossProxy)jbproxy);
- }
- else if (hash == TO_STRING)
- {
- return ih.toString();
- }
- else if (hash == HASHCODE)
- {
- return new Integer(ih.toString().hashCode());
- }
- else if (hash == EQUALS)
- {
- return new Boolean(ih.toString().equals(args[0].toString()));
- }
- return null;
- }
-}
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/SecurityActions.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/SecurityActions.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/SecurityActions.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -1,327 +0,0 @@
-/*
- * 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;
-
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
-
-import javax.security.auth.Subject;
-import javax.security.jacc.PolicyContext;
-
-import org.jboss.security.RunAsIdentity;
-import org.jboss.security.SecurityAssociation;
-import org.jboss.security.SecurityContext;
-import org.jboss.security.SecurityContextFactory;
-import org.jboss.security.plugins.SecurityContextAssociation;
-
-/**
- * A collection of privileged actions for this package
- *
- * @author Scott.Stark at jboss.org
- * @version $Revison:$
- */
-public class SecurityActions
-{
- private static class SetContextID implements PrivilegedAction
- {
- String contextID;
-
- SetContextID(String contextID)
- {
- this.contextID = contextID;
- }
-
- public Object run()
- {
- String previousID = PolicyContext.getContextID();
- PolicyContext.setContextID(contextID);
- return previousID;
- }
- }
-
- private static class PeekRunAsRoleAction implements PrivilegedAction
- {
- int depth;
-
- PeekRunAsRoleAction(int depth)
- {
- this.depth = depth;
- }
-
- public Object run()
- {
- RunAsIdentity principal = SecurityAssociation.peekRunAsIdentity(depth);
- return principal;
- }
- }
-
- private static class GetSubjectAction implements PrivilegedAction
- {
- static PrivilegedAction ACTION = new GetSubjectAction();
- public Object run()
- {
- Subject subject = SecurityAssociation.getSubject();
- return subject;
- }
- }
-
- private static class PopRunAsIdentityAction implements PrivilegedAction
- {
- static PrivilegedAction ACTION = new PopRunAsIdentityAction();
- public Object run()
- {
- return SecurityAssociation.popRunAsIdentity();
- }
- }
-
- private static class PushRunAsIdentityAction implements PrivilegedAction
- {
- RunAsIdentity runAsIdentity;
-
- PushRunAsIdentityAction(RunAsIdentity runAsIdentity)
- {
- this.runAsIdentity = runAsIdentity;
- }
-
- public Object run()
- {
- SecurityAssociation.pushRunAsIdentity(runAsIdentity);
- return null;
- }
- }
-
- static ClassLoader getContextClassLoader()
- {
- return TCLAction.UTIL.getContextClassLoader();
- }
-
- static ClassLoader getContextClassLoader(Thread thread)
- {
- return TCLAction.UTIL.getContextClassLoader(thread);
- }
-
- static void setContextClassLoader(ClassLoader loader)
- {
- TCLAction.UTIL.setContextClassLoader(loader);
- }
-
- static void setContextClassLoader(Thread thread, ClassLoader loader)
- {
- TCLAction.UTIL.setContextClassLoader(thread, loader);
- }
-
- static String setContextID(String contextID)
- {
- PrivilegedAction action = new SetContextID(contextID);
- String previousID = (String) AccessController.doPrivileged(action);
- return previousID;
- }
-
- public static RunAsIdentity peekRunAsIdentity(int depth)
- {
- PrivilegedAction action = new PeekRunAsRoleAction(depth);
- RunAsIdentity principal = (RunAsIdentity) AccessController.doPrivileged(action);
- return principal;
- }
-
- public static Subject getActiveSubject()
- {
- Subject subject = (Subject) AccessController.doPrivileged(GetSubjectAction.ACTION);
- return subject;
- }
-
- public static void pushRunAsIdentity(RunAsIdentity runAsIdentity)
- {
- PrivilegedAction action = new PushRunAsIdentityAction(runAsIdentity);
- AccessController.doPrivileged(action);
- }
-
- public static void pushRunAs(final RunAsIdentity runAsIdentity)
- {
- AccessController.doPrivileged(new PrivilegedAction()
- {
- public Object run()
- {
- SecurityContext sc = getSecurityContext();
- sc.setOutgoingRunAs(runAsIdentity);
- return null;
- }
- });
- }
-
- public static SecurityContext getSecurityContext()
- {
- return (SecurityContext) AccessController.doPrivileged(new PrivilegedAction()
- {
-
- public Object run()
- {
- return SecurityContextAssociation.getSecurityContext();
- }
-
- });
- }
-
- public static RunAsIdentity popRunAsIdentity()
- {
- return (RunAsIdentity)AccessController.doPrivileged(PopRunAsIdentityAction.ACTION);
- }
-
- public static RunAsIdentity popRunAs()
- {
- return (RunAsIdentity)AccessController.doPrivileged(new PrivilegedAction()
- {
- public Object run()
- {
- SecurityContext sc = getSecurityContext();
- RunAsIdentity ra = (RunAsIdentity) sc.getOutgoingRunAs();
- sc.setOutgoingRunAs(null);
- return ra;
- }
- });
- }
-
- interface TCLAction
- {
- class UTIL
- {
- static TCLAction getTCLAction()
- {
- return System.getSecurityManager() == null ? NON_PRIVILEGED : PRIVILEGED;
- }
-
- static ClassLoader getContextClassLoader()
- {
- return getTCLAction().getContextClassLoader();
- }
-
- static ClassLoader getContextClassLoader(Thread thread)
- {
- return getTCLAction().getContextClassLoader(thread);
- }
-
- static void setContextClassLoader(ClassLoader cl)
- {
- getTCLAction().setContextClassLoader(cl);
- }
-
- static void setContextClassLoader(Thread thread, ClassLoader cl)
- {
- getTCLAction().setContextClassLoader(thread, cl);
- }
- }
-
- TCLAction NON_PRIVILEGED = new TCLAction()
- {
- public ClassLoader getContextClassLoader()
- {
- return Thread.currentThread().getContextClassLoader();
- }
-
- public ClassLoader getContextClassLoader(Thread thread)
- {
- return thread.getContextClassLoader();
- }
-
- public void setContextClassLoader(ClassLoader cl)
- {
- Thread.currentThread().setContextClassLoader(cl);
- }
-
- public void setContextClassLoader(Thread thread, ClassLoader cl)
- {
- thread.setContextClassLoader(cl);
- }
- };
-
- TCLAction PRIVILEGED = new TCLAction()
- {
- private final PrivilegedAction getTCLPrivilegedAction = new PrivilegedAction()
- {
- public Object run()
- {
- return Thread.currentThread().getContextClassLoader();
- }
- };
-
- public ClassLoader getContextClassLoader()
- {
- return (ClassLoader) AccessController.doPrivileged(getTCLPrivilegedAction);
- }
-
- public ClassLoader getContextClassLoader(final Thread thread)
- {
- return (ClassLoader) AccessController.doPrivileged(new PrivilegedAction()
- {
- public Object run()
- {
- return thread.getContextClassLoader();
- }
- });
- }
-
- public void setContextClassLoader(final ClassLoader cl)
- {
- AccessController.doPrivileged(new PrivilegedAction()
- {
- public Object run()
- {
- Thread.currentThread().setContextClassLoader(cl);
- return null;
- }
- });
- }
-
- public void setContextClassLoader(final Thread thread, final ClassLoader cl)
- {
- AccessController.doPrivileged(new PrivilegedAction()
- {
- public Object run()
- {
- thread.setContextClassLoader(cl);
- return null;
- }
- });
- }
- };
-
- ClassLoader getContextClassLoader();
-
- ClassLoader getContextClassLoader(Thread thread);
-
- void setContextClassLoader(ClassLoader cl);
-
- void setContextClassLoader(Thread thread, ClassLoader cl);
- }
-
- public static SecurityContext createSecurityContext(final String securityDomain) throws PrivilegedActionException
- {
- return (SecurityContext) AccessController.doPrivileged(new PrivilegedExceptionAction()
- {
- public Object run() throws Exception
- {
- return SecurityContextFactory.createSecurityContext(securityDomain);
- }});
- }
-}
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/ServiceDelegateWrapper.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/ServiceDelegateWrapper.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/ServiceDelegateWrapper.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -1,159 +0,0 @@
-/*
- * 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;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-import javax.ejb.TimerService;
-
-import org.jboss.ejb3.statistics.InvocationStatistics;
-
-import org.jboss.system.ServiceMBeanSupport;
-
-/**
- * Comment
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- * @deprecated service mbeans are no longer in use
- */
- at Deprecated
-public class ServiceDelegateWrapper extends ServiceMBeanSupport implements ServiceDelegateWrapperMBean
-{
- private Object delegate;
- private Method createMethod;
- private Method startMethod;
- private Method stopMethod;
- private Method destroyMethod;
-
-
- public ServiceDelegateWrapper(Object delegate)
- {
- this.delegate = delegate;
- try
- {
- createMethod = delegate.getClass().getMethod("create");
- }
- catch (NoSuchMethodException ignored)
- {
- }
- try
- {
- startMethod = delegate.getClass().getMethod("start");
- }
- catch (NoSuchMethodException ignored)
- {
- }
- try
- {
- stopMethod = delegate.getClass().getMethod("stop");
- }
- catch (NoSuchMethodException ignored)
- {
- }
- try
- {
- destroyMethod = delegate.getClass().getMethod("destroy");
- }
- catch (NoSuchMethodException ignored)
- {
- }
-
- }
-
- @Override
- protected void createService() throws Exception
- {
- super.createService();
- try
- {
- if (createMethod != null) createMethod.invoke(delegate);
- }
- catch (InvocationTargetException e)
- {
- Throwable t = e.getCause();
- if (t instanceof Exception) throw (Exception)t;
- else throw new RuntimeException(t);
- }
- }
-
- @Override
- protected void startService() throws Exception
- {
- super.startService();
- try
- {
- if (startMethod != null) startMethod.invoke(delegate);
- }
- catch (InvocationTargetException e)
- {
- Throwable t = e.getCause();
- if (t instanceof Exception) throw (Exception)t;
- else throw new RuntimeException(t);
- }
- }
-
- @Override
- protected void stopService() throws Exception
- {
- super.stopService();
- try
- {
- if (stopMethod != null) stopMethod.invoke(delegate);
- }
- catch (InvocationTargetException e)
- {
- Throwable t = e.getCause();
- if (t instanceof Exception) throw (Exception)t;
- else throw new RuntimeException(t);
- }
-
- }
-
- @Override
- protected void destroyService() throws Exception
- {
- super.destroyService();
- try
- {
- if (destroyMethod != null) destroyMethod.invoke(delegate);
- }
- catch (InvocationTargetException e)
- {
- Throwable t = e.getCause();
- if (t instanceof Exception) throw (Exception)t;
- else throw new RuntimeException(t);
- }
- }
-
- // FIXME: this is here for EJBTHREE-630, re-establishing timers
- public TimerService getTimerService(Object pKey)
- {
- return ((Container) delegate).getTimerService(pKey);
- }
-
- public InvocationStatistics getInvokeStats()
- {
- return ((Container) delegate).getInvokeStats();
- }
-}
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/ServiceDelegateWrapperMBean.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/ServiceDelegateWrapperMBean.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/ServiceDelegateWrapperMBean.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -1,43 +0,0 @@
-/*
- * 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;
-
-import javax.ejb.TimerService;
-
-import org.jboss.ejb3.statistics.InvocationStatistics;
-import org.jboss.system.ServiceMBean;
-
-/**
- * Comment
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- * @deprecated service mbeans are no longer used
- */
- at Deprecated
-public interface ServiceDelegateWrapperMBean extends ServiceMBean
-{
- // FIXME: this is here to re-establish timers (EJBTHREE-630), do not use for other purposes
- TimerService getTimerService(Object pKey);
-
- InvocationStatistics getInvokeStats();
-}
Deleted: trunk/ejb3/src/main/org/jboss/ejb3/ThreadLocalStack.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/ThreadLocalStack.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/ThreadLocalStack.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -1,78 +0,0 @@
-/*
- * 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;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Comment
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- */
-public class ThreadLocalStack<T>
-{
- private ThreadLocal<ArrayList<T>> stack = new ThreadLocal<ArrayList<T>>();
-
- public void push(T obj)
- {
- ArrayList<T> list = stack.get();
- if (list == null)
- {
- list = new ArrayList<T>(1);
- stack.set(list);
- }
- list.add(obj);
- }
-
- public T pop()
- {
- ArrayList<T> list = stack.get();
- if (list == null)
- {
- return null;
- }
- T rtn = list.remove(list.size() - 1);
- if (list.size() == 0)
- {
- stack.set(null);
- list.clear();
- }
- return rtn;
- }
-
- public T get()
- {
- ArrayList<T> list = (ArrayList<T>)stack.get();
- if (list == null)
- {
- return null;
- }
- return list.get(list.size() - 1);
- }
-
- public List<T> getList()
- {
- return stack.get();
- }
-}
Modified: trunk/ejb3/src/main/org/jboss/ejb3/deployers/EJBRegistrationDeployer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/deployers/EJBRegistrationDeployer.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/deployers/EJBRegistrationDeployer.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -191,7 +191,7 @@
}
JBoss5DeploymentUnit du = new JBoss5DeploymentUnit(unit);
du.setDefaultPersistenceProperties(defaultPersistenceProperties);
- Ejb3JBoss5Deployment deployment = new Ejb3JBoss5Deployment(du, kernel, mbeanServer, unit, scope, null, null, null);
+ Ejb3JBoss5Deployment deployment = new Ejb3JBoss5Deployment(du, kernel, mbeanServer, unit, scope, null, null);
if (scope != null) scope.register(deployment);
// create() creates initial EJB containers and initializes metadata.
deployment.create();
Modified: trunk/ejb3/src/main/org/jboss/ejb3/deployers/Ejb3Deployer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/deployers/Ejb3Deployer.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/deployers/Ejb3Deployer.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -138,8 +138,11 @@
}
JBoss5DeploymentUnit du = new JBoss5DeploymentUnit(unit);
du.setDefaultPersistenceProperties(defaultPersistenceProperties);
- Ejb3JBoss5Deployment deployment = new Ejb3JBoss5Deployment(du, kernel, mbeanServer, unit, scope, metaData, persistenceUnitsMetaData,
- this);
+ Ejb3JBoss5Deployment deployment = new Ejb3JBoss5Deployment(du, kernel, mbeanServer, unit, scope, metaData, persistenceUnitsMetaData);
+ deployment.setCacheFactoryRegistry(this.getCacheFactoryRegistry());
+ deployment.setPersistenceManagerFactoryRegistry(this.getPersistenceManagerFactoryRegistry());
+ deployment.setRemoteProxyFactoryRegistry(this.getRemoteProxyFactoryRegistry());
+ deployment.setPoolFactoryRegistry(this.getPoolFactoryRegistry());
if (scope != null) scope.register(deployment);
// create() creates initial EJB containers and initializes metadata.
deployment.create();
Modified: trunk/ejb3/src/main/org/jboss/ejb3/deployers/Ejb3JBoss5Deployment.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/deployers/Ejb3JBoss5Deployment.java 2008-02-29 04:21:12 UTC (rev 70237)
+++ trunk/ejb3/src/main/org/jboss/ejb3/deployers/Ejb3JBoss5Deployment.java 2008-02-29 04:25:34 UTC (rev 70238)
@@ -49,9 +49,9 @@
private org.jboss.deployers.structure.spi.DeploymentUnit jbossUnit;
- public Ejb3JBoss5Deployment(DeploymentUnit ejb3Unit, Kernel kernel, MBeanServer mbeanServer, org.jboss.deployers.structure.spi.DeploymentUnit jbossUnit, DeploymentScope deploymentScope, JBossMetaData metaData, PersistenceUnitsMetaData persistenceUnitsMetaData, Ejb3Deployer deployer)
+ public Ejb3JBoss5Deployment(DeploymentUnit ejb3Unit, Kernel kernel, MBeanServer mbeanServer, org.jboss.deployers.structure.spi.DeploymentUnit jbossUnit, DeploymentScope deploymentScope, JBossMetaData metaData, PersistenceUnitsMetaData persistenceUnitsMetaData)
{
- super(ejb3Unit, deploymentScope, metaData, persistenceUnitsMetaData, deployer);
+ super(ejb3Unit, deploymentScope, metaData, persistenceUnitsMetaData);
this.jbossUnit = jbossUnit;
kernelAbstraction = new MCKernelAbstraction(kernel, mbeanServer);
More information about the jboss-cvs-commits
mailing list