[jboss-cvs] JBossAS SVN: r108153 - in projects/ejb3/branches/infinispan-int: core and 14 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Sep 15 18:24:55 EDT 2010
Author: pferraro
Date: 2010-09-15 18:24:51 -0400 (Wed, 15 Sep 2010)
New Revision: 108153
Added:
projects/ejb3/branches/infinispan-int/core/src/test/java/org/jboss/ejb3/core/test/ejbthree2168/
projects/ejb3/branches/infinispan-int/core/src/test/java/org/jboss/ejb3/core/test/ejbthree2168/SimpleSLSB.java
projects/ejb3/branches/infinispan-int/core/src/test/java/org/jboss/ejb3/core/test/ejbthree2168/unit/
projects/ejb3/branches/infinispan-int/core/src/test/java/org/jboss/ejb3/core/test/ejbthree2168/unit/EnvEntryTypeTestCase.java
projects/ejb3/branches/infinispan-int/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree2165/
projects/ejb3/branches/infinispan-int/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree2165/Base.java
projects/ejb3/branches/infinispan-int/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree2165/BeanA.java
projects/ejb3/branches/infinispan-int/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree2165/unit/
projects/ejb3/branches/infinispan-int/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree2165/unit/ClassHelperTestCase.java
Removed:
projects/ejb3/branches/infinispan-int/concurrency/
projects/ejb3/branches/infinispan-int/core/src/test/java/org/jboss/ejb3/core/test/ejbthree2168/SimpleSLSB.java
projects/ejb3/branches/infinispan-int/core/src/test/java/org/jboss/ejb3/core/test/ejbthree2168/unit/
projects/ejb3/branches/infinispan-int/core/src/test/java/org/jboss/ejb3/core/test/ejbthree2168/unit/EnvEntryTypeTestCase.java
projects/ejb3/branches/infinispan-int/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree2165/Base.java
projects/ejb3/branches/infinispan-int/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree2165/BeanA.java
projects/ejb3/branches/infinispan-int/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree2165/unit/
projects/ejb3/branches/infinispan-int/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree2165/unit/ClassHelperTestCase.java
Modified:
projects/ejb3/branches/infinispan-int/
projects/ejb3/branches/infinispan-int/core/pom.xml
projects/ejb3/branches/infinispan-int/core/src/main/java/org/jboss/ejb3/Ejb3AnnotationHandler.java
projects/ejb3/branches/infinispan-int/core/src/main/java/org/jboss/ejb3/Ejb3Deployment.java
projects/ejb3/branches/infinispan-int/core/src/main/java/org/jboss/ejb3/mdb/MessagingContainer.java
projects/ejb3/branches/infinispan-int/core/src/main/java/org/jboss/ejb3/stateless/StatelessContainer.java
projects/ejb3/branches/infinispan-int/core/src/main/java/org/jboss/injection/EnvEntryEncInjector.java
projects/ejb3/branches/infinispan-int/core/src/main/java/org/jboss/injection/ResourceHandler.java
projects/ejb3/branches/infinispan-int/core/src/main/resources/META-INF/ejb3-deployers-jboss-beans.xml
projects/ejb3/branches/infinispan-int/core/src/test/java/org/jboss/ejb3/core/test/common/AbstractEJB3TestCase.java
projects/ejb3/branches/infinispan-int/interceptors/pom.xml
projects/ejb3/branches/infinispan-int/interceptors/src/main/java/org/jboss/ejb3/interceptors/lang/ClassHelper.java
Log:
merge --depth=infinity -r107932:108136
Property changes on: projects/ejb3/branches/infinispan-int
___________________________________________________________________
Name: svn:ignore
- .git
bin
target-eclipse
.settings
+ .git
bin
target-eclipse
.settings
.project
Modified: projects/ejb3/branches/infinispan-int/core/pom.xml
===================================================================
--- projects/ejb3/branches/infinispan-int/core/pom.xml 2010-09-15 21:29:30 UTC (rev 108152)
+++ projects/ejb3/branches/infinispan-int/core/pom.xml 2010-09-15 22:24:51 UTC (rev 108153)
@@ -17,7 +17,7 @@
<!-- Artifact Information -->
<artifactId>jboss-ejb3-core</artifactId>
<packaging>jar</packaging>
- <version>1.5.0</version>
+ <version>1.5.1</version>
<name>JBoss EJB 3.0 Core</name>
<url>http://labs.jboss.com/jbossejb3</url>
<description>JBoss EJB 3.0 Core</description>
@@ -49,6 +49,7 @@
<version.sun-jaxws>2.1.1</version.sun-jaxws>
<version.org.jboss.ejb3.async>1.0.0-alpha-5</version.org.jboss.ejb3.async>
<version.org.jboss.ejb3.instantiator>1.0.0-alpha-2</version.org.jboss.ejb3.instantiator>
+ <version.org.jboss.ejb3.ejbref.resolver>1.0.0-alpha-1</version.org.jboss.ejb3.ejbref.resolver>
</properties>
<!-- Build Information -->
@@ -505,6 +506,20 @@
<version>${version.org.jboss.ejb3.context}</version>
<scope>runtime</scope>
</dependency>
+
+ <!-- ejbref-resolver -->
+ <dependency>
+ <groupId>org.jboss.ejb3.ejbref.resolver</groupId>
+ <artifactId>ejbref-resolver-spi</artifactId>
+ <version>${version.org.jboss.ejb3.ejbref.resolver}</version>
+ </dependency>
+ <!-- For test support -->
+ <dependency>
+ <groupId>org.jboss.ejb3.ejbref.resolver</groupId>
+ <artifactId>ejbref-resolver-ejb30-impl</artifactId>
+ <version>${version.org.jboss.ejb3.ejbref.resolver}</version>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>org.jboss.ejb3.timeout</groupId>
Modified: projects/ejb3/branches/infinispan-int/core/src/main/java/org/jboss/ejb3/Ejb3AnnotationHandler.java
===================================================================
--- projects/ejb3/branches/infinispan-int/core/src/main/java/org/jboss/ejb3/Ejb3AnnotationHandler.java 2010-09-15 21:29:30 UTC (rev 108152)
+++ projects/ejb3/branches/infinispan-int/core/src/main/java/org/jboss/ejb3/Ejb3AnnotationHandler.java 2010-09-15 22:24:51 UTC (rev 108153)
@@ -21,21 +21,14 @@
*/
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.annotation.impl.PostConstructImpl;
import org.jboss.ejb3.mdb.ConsumerContainer;
import org.jboss.ejb3.mdb.MDB;
import org.jboss.ejb3.service.ServiceContainer;
@@ -50,6 +43,13 @@
import org.jboss.metadata.ejb.jboss.JBossServiceBeanMetaData;
import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.List;
+
/**
* @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
* @author <a href="mailto:bill at jboss.com">Bill Burke</a>
@@ -107,6 +107,11 @@
visible = (AnnotationsAttribute) cf.getAttribute(AnnotationsAttribute.visibleTag);
}
+ private static void addAnnotation(java.lang.annotation.Annotation annotation, EJBContainer container, Method method)
+ {
+ container.getAnnotations().addAnnotation(method, annotation.annotationType(), annotation);
+ }
+
/**
* 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.
@@ -353,9 +358,41 @@
MDB container = new MDB(ejbNames.get(ejbIndex), (Domain) domain.getManager(), di.getClassLoader(), className,
ctxProperties, deployment, beanMetaData);
+ // EJB 3.0 5.6.3: the class or any super-class may implement the ejbCreate method
+ Method method = getMethod(container.getBeanClass(), "ejbCreate");
+ if(method != null)
+ {
+ addAnnotation(new PostConstructImpl(), container, method);
+ }
+
return container;
}
+ /**
+ * Find a specific public method on a class (slow).
+ *
+ * Note that this method is slow, because it uses exception for control flow.
+ * Also Class does a brute search in its private method cache.
+ *
+ * @param cls
+ * @param methodName
+ * @param parameterTypes
+ * @return the method or null if not found
+ * @see Class#getMethod(String, Class[])
+ */
+ private static Method getMethod(Class<?> cls, String methodName, Class<?>... parameterTypes)
+ {
+ try
+ {
+ // call to cls.getMethod is slow
+ return cls.getMethod(methodName, parameterTypes);
+ }
+ catch (NoSuchMethodException e)
+ {
+ return null;
+ }
+ }
+
protected void populateBaseInfo() throws Exception
{
String ejbName = null;
Modified: projects/ejb3/branches/infinispan-int/core/src/main/java/org/jboss/ejb3/Ejb3Deployment.java
===================================================================
--- projects/ejb3/branches/infinispan-int/core/src/main/java/org/jboss/ejb3/Ejb3Deployment.java 2010-09-15 21:29:30 UTC (rev 108152)
+++ projects/ejb3/branches/infinispan-int/core/src/main/java/org/jboss/ejb3/Ejb3Deployment.java 2010-09-15 22:24:51 UTC (rev 108153)
@@ -49,8 +49,8 @@
import org.jboss.ejb3.cache.CacheFactoryRegistry;
import org.jboss.ejb3.cache.persistence.PersistenceManagerFactoryRegistry;
import org.jboss.ejb3.common.lang.ClassHelper;
-import org.jboss.ejb3.common.resolvers.spi.EjbReference;
-import org.jboss.ejb3.common.resolvers.spi.EjbReferenceResolver;
+import org.jboss.ejb3.ejbref.resolver.spi.EjbReference;
+import org.jboss.ejb3.ejbref.resolver.spi.EjbReferenceResolver;
import org.jboss.ejb3.instantiator.spi.AttachmentNames;
import org.jboss.ejb3.instantiator.spi.BeanInstantiator;
import org.jboss.ejb3.javaee.JavaEEApplication;
@@ -134,6 +134,11 @@
private org.jboss.deployers.structure.spi.DeploymentUnit deploymentUnit;
+ // DEPRECATED!!! Use org.jboss.ejb3.ejbref.resolver.spi.EjbReferenceResolver instead
+ @Deprecated
+ private org.jboss.ejb3.common.resolvers.spi.EjbReferenceResolver deprecatedEjbRefResolver;
+
+ /** Resolver used for resolving jndi name from {@link EjbReference} */
private EjbReferenceResolver ejbReferenceResolver;
private PersistenceUnitDependencyResolver persistenceUnitDependencyResolver;
@@ -196,7 +201,7 @@
@Deprecated
public boolean canResolveEJB()
{
- return ejbReferenceResolver != null;
+ return this.ejbReferenceResolver != null;
}
public JavaEEApplication getApplication()
@@ -248,11 +253,29 @@
return persistenceManagerFactoryRegistry;
}
+ /**
+ *
+ * @param resolver
+ * @deprecated Use {@link #setEJBReferenceResolver(EjbReferenceResolver)} instead
+ */
+ public void setEJBReferenceResolver(org.jboss.ejb3.common.resolvers.spi.EjbReferenceResolver resolver)
+ {
+ log.debug("setEJBReferenceResolver(" + org.jboss.ejb3.common.resolvers.spi.EjbReferenceResolver.class + ") is deprecated");
+ this.deprecatedEjbRefResolver = resolver;
+ }
+
+ /**
+ * Sets the {@link EjbReferenceResolver} to be used for resolving jndi names
+ * from an {@link EjbReference}
+ *
+ * @param resolver
+ */
@Inject
public void setEJBReferenceResolver(EjbReferenceResolver resolver)
{
this.ejbReferenceResolver = resolver;
}
+
public ExecutorService getAsynchronousProcessor()
{
@@ -803,7 +826,7 @@
public String resolveEJB(String link, Class<?> beanInterface, String mappedName)
{
EjbReference reference = new EjbReference(link, beanInterface.getName(), mappedName);
- return ejbReferenceResolver.resolveEjb(deploymentUnit, reference);
+ return this.ejbReferenceResolver.resolveEjb(deploymentUnit, reference);
}
public String resolveMessageDestination(String link)
Modified: projects/ejb3/branches/infinispan-int/core/src/main/java/org/jboss/ejb3/mdb/MessagingContainer.java
===================================================================
--- projects/ejb3/branches/infinispan-int/core/src/main/java/org/jboss/ejb3/mdb/MessagingContainer.java 2010-09-15 21:29:30 UTC (rev 108152)
+++ projects/ejb3/branches/infinispan-int/core/src/main/java/org/jboss/ejb3/mdb/MessagingContainer.java 2010-09-15 22:24:51 UTC (rev 108153)
@@ -21,7 +21,6 @@
*/
package org.jboss.ejb3.mdb;
-import java.io.Serializable;
import java.lang.reflect.Method;
import java.util.Hashtable;
import java.util.Map;
@@ -291,7 +290,13 @@
public void callTimeout(Timer timer) throws Exception
{
// the method annotated with @Timeout or it's xml equivalent
- if (timeout == null) throw new EJBException("No method has been annotated with @Timeout");
+ if (this.timeout == null)
+ {
+ throw new EJBException(
+ "No timeout method has been specified (either through @Timeout or deployment descriptor) for bean named: "
+ + this.ejbName);
+ }
+
// call the timeout method
this.callTimeout(timer, this.timeout);
}
Modified: projects/ejb3/branches/infinispan-int/core/src/main/java/org/jboss/ejb3/stateless/StatelessContainer.java
===================================================================
--- projects/ejb3/branches/infinispan-int/core/src/main/java/org/jboss/ejb3/stateless/StatelessContainer.java 2010-09-15 21:29:30 UTC (rev 108152)
+++ projects/ejb3/branches/infinispan-int/core/src/main/java/org/jboss/ejb3/stateless/StatelessContainer.java 2010-09-15 22:24:51 UTC (rev 108153)
@@ -195,7 +195,12 @@
public void callTimeout(Timer timer) throws Exception
{
// the method annotated with @Timeout or it's xml equivalent
- if (timeout == null) throw new EJBException("No method has been annotated with @Timeout");
+ if (this.timeout == null)
+ {
+ throw new EJBException(
+ "No timeout method has been specified (either through @Timeout or deployment descriptor) for bean named: "
+ + this.ejbName);
+ }
// call the timeout method
this.callTimeout(timer, timeout);
Modified: projects/ejb3/branches/infinispan-int/core/src/main/java/org/jboss/injection/EnvEntryEncInjector.java
===================================================================
--- projects/ejb3/branches/infinispan-int/core/src/main/java/org/jboss/injection/EnvEntryEncInjector.java 2010-09-15 21:29:30 UTC (rev 108152)
+++ projects/ejb3/branches/infinispan-int/core/src/main/java/org/jboss/injection/EnvEntryEncInjector.java 2010-09-15 22:24:51 UTC (rev 108153)
@@ -21,6 +21,7 @@
*/
package org.jboss.injection;
+import org.jboss.ejb3.common.classloader.util.PrimitiveClassLoadingUtil;
import org.jboss.logging.Logger;
import org.jboss.util.naming.Util;
@@ -52,7 +53,7 @@
{
Util.rebind(container.getEnc(),
name,
- getEnvEntryValue());
+ getEnvEntryValue(container.getClassloader()));
}
catch (Exception e)
{
@@ -60,35 +61,43 @@
}
}
-
+ @Deprecated
protected Object getEnvEntryValue() throws ClassNotFoundException
{
- Class type = Thread.currentThread().getContextClassLoader().loadClass(entryType);
+ ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+ return this.getEnvEntryValue(tccl);
+ }
+
+ private Object getEnvEntryValue(ClassLoader cl) throws ClassNotFoundException
+ {
+ // Use PrimitiveClassLoadingUtil since the type might be primitive
+ Class<?> type = PrimitiveClassLoadingUtil.loadClass(entryType, cl);
+
if (type == String.class)
{
return value;
}
- else if (type == Integer.class)
+ else if (type == Integer.class || type == int.class)
{
return new Integer(value);
}
- else if (type == Long.class)
+ else if (type == Long.class || type == long.class)
{
return new Long(value);
}
- else if (type == Double.class)
+ else if (type == Double.class || type == double.class)
{
return new Double(value);
}
- else if (type == Float.class)
+ else if (type == Float.class || type == float.class)
{
return new Float(value);
}
- else if (type == Byte.class)
+ else if (type == Byte.class || type == byte.class)
{
return new Byte(value);
}
- else if (type == Character.class)
+ else if (type == Character.class || type == char.class)
{
String input = value;
if (input == null || input.length() == 0)
@@ -104,11 +113,11 @@
return new Character(input.charAt(0));
}
}
- else if (type == Short.class)
+ else if (type == Short.class || type == short.class)
{
return new Short(value);
}
- else if (type == Boolean.class)
+ else if (type == Boolean.class || type == boolean.class)
{
return new Boolean(value);
}
Modified: projects/ejb3/branches/infinispan-int/core/src/main/java/org/jboss/injection/ResourceHandler.java
===================================================================
--- projects/ejb3/branches/infinispan-int/core/src/main/java/org/jboss/injection/ResourceHandler.java 2010-09-15 21:29:30 UTC (rev 108152)
+++ projects/ejb3/branches/infinispan-int/core/src/main/java/org/jboss/injection/ResourceHandler.java 2010-09-15 22:24:51 UTC (rev 108153)
@@ -28,6 +28,7 @@
import java.net.URL;
import java.util.Collection;
import java.util.Map;
+import java.util.Set;
import javax.annotation.Resource;
import javax.annotation.Resources;
@@ -45,6 +46,7 @@
import org.jboss.metadata.javaee.spec.MessageDestinationReferenceMetaData;
import org.jboss.metadata.javaee.spec.RemoteEnvironment;
import org.jboss.metadata.javaee.spec.ResourceEnvironmentReferenceMetaData;
+import org.jboss.metadata.javaee.spec.ResourceInjectionTargetMetaData;
import org.jboss.metadata.javaee.spec.ResourceReferenceMetaData;
import org.jboss.reflect.plugins.ValueConvertor;
import org.omg.CORBA.ORB;
@@ -101,7 +103,12 @@
InjectionUtil.injectionTarget(encName, envEntry, container, container.getEncInjections());
if (container.getEncInjectors().containsKey(encName)) continue;
log.trace("adding env-entry injector " + encName);
- container.getEncInjectors().put(encName, new EnvEntryEncInjector(encName, envEntry.getType(), envEntry.getValue()));
+ String envEntryType = getEnvEntryType(container, envEntry);
+ if (envEntryType == null)
+ {
+ throw new RuntimeException("env-entry-type is not specified for env-entry named " + envEntry.getName());
+ }
+ container.getEncInjectors().put(encName, new EnvEntryEncInjector(encName, envEntryType, envEntry.getValue()));
}
}
@@ -269,6 +276,55 @@
InjectionUtil.injectionTarget(encName, envRef, container, container.getEncInjections());
}
}
+
+ /**
+ * Returns the env-entry-type for the passed {@link EnvironmentEntryMetaData}.
+ * <p>
+ * If the passed env-entry has the env-entry-type explicitly specified, then
+ * that value is returned. Else, this method checks for the presence of any
+ * injection targets for this env-entry. If there's a injection target, then
+ * the env-entry-type is deduced based on the field/method of the injection target.
+ * </p>
+ * <p>
+ * This method returns null if the env-entry-type isn't explicitly specified and
+ * if the env-entry-type could not be deduced from the injection targets of this
+ * env-entry.
+ * </p>
+ * @param container The container to which this env-entry belongs
+ * @param envEntry The env-entry metadata
+ * @return
+ */
+ private static String getEnvEntryType(InjectionContainer container, EnvironmentEntryMetaData envEntry)
+ {
+ // first check whether the type is explicitly specified
+ String explicitType = envEntry.getType();
+ if (explicitType != null)
+ {
+ return explicitType;
+ }
+ // check if this env-entry has an injection-target. If yes, then
+ // fetch the type from the injection target's field/method type
+ Set<ResourceInjectionTargetMetaData> injectionTargets = envEntry.getInjectionTargets();
+ if (injectionTargets == null || injectionTargets.isEmpty())
+ {
+ return null;
+ }
+ // even if there are multiple injection targets, we just check for the first one
+ // TODO: Check for injection targets and if there's a mismatch in the types between
+ // different injection targets, then throw an error
+ ResourceInjectionTargetMetaData injectionTarget = injectionTargets.iterator().next();
+ AccessibleObject accessibleObject = InjectionUtil.findInjectionTarget(container.getClassloader(), injectionTarget);
+ if (accessibleObject instanceof Field)
+ {
+ return ((Field) accessibleObject).getType().getName();
+ }
+ else if (accessibleObject instanceof Method)
+ {
+ return ((Method) accessibleObject).getParameterTypes()[0].getName();
+ }
+
+ return null;
+ }
public void loadXml(X xml, InjectionContainer container)
{
Modified: projects/ejb3/branches/infinispan-int/core/src/main/resources/META-INF/ejb3-deployers-jboss-beans.xml
===================================================================
--- projects/ejb3/branches/infinispan-int/core/src/main/resources/META-INF/ejb3-deployers-jboss-beans.xml 2010-09-15 21:29:30 UTC (rev 108152)
+++ projects/ejb3/branches/infinispan-int/core/src/main/resources/META-INF/ejb3-deployers-jboss-beans.xml 2010-09-15 22:24:51 UTC (rev 108153)
@@ -77,11 +77,6 @@
</constructor>
</bean>
-
-
- <!-- EJB Reference Resolver -->
- <bean name="org.jboss.ejb3.EjbReferenceResolver" class="org.jboss.ejb3.core.resolvers.ScopedEJBReferenceResolver"/>
-
<!-- Add Annotation Plugins upon installation -->
<bean name="org.jboss.ejb3.AddAnnotationPluginOnBeanAnnotationAdaptorCallbackService"
class="org.jboss.ejb3.mcint.annotationadaptor.AddAnnotationPluginOnBeanAnnotationAdaptorCallbackService">
@@ -89,7 +84,8 @@
<parameter><inject bean="jboss.kernel:service=Kernel"/></parameter>
</constructor>
</bean>
-
+
+ <!-- TODO: Move this out of core -->
<!-- EJB Reference Annotation Plugin -->
<bean name="org.jboss.ejb3.EjbReferenceAnnotationPlugin"
class="org.jboss.ejb3.mcint.metadata.plugins.EjbReferenceAnnotationPlugin">
Modified: projects/ejb3/branches/infinispan-int/core/src/test/java/org/jboss/ejb3/core/test/common/AbstractEJB3TestCase.java
===================================================================
--- projects/ejb3/branches/infinispan-int/core/src/test/java/org/jboss/ejb3/core/test/common/AbstractEJB3TestCase.java 2010-09-15 21:29:30 UTC (rev 108152)
+++ projects/ejb3/branches/infinispan-int/core/src/test/java/org/jboss/ejb3/core/test/common/AbstractEJB3TestCase.java 2010-09-15 22:24:51 UTC (rev 108153)
@@ -59,7 +59,7 @@
import org.jboss.ejb3.common.registrar.plugin.mc.Ejb3McRegistrar;
import org.jboss.ejb3.common.registrar.spi.Ejb3RegistrarLocator;
import org.jboss.ejb3.common.registrar.spi.NotBoundException;
-import org.jboss.ejb3.core.resolvers.ScopedEJBReferenceResolver;
+import org.jboss.ejb3.ejbref.resolver.ejb30.impl.ScopedEJBReferenceResolver;
import org.jboss.ejb3.service.ServiceContainer;
import org.jboss.ejb3.session.SessionContainer;
import org.jboss.ejb3.stateful.StatefulContainer;
Copied: projects/ejb3/branches/infinispan-int/core/src/test/java/org/jboss/ejb3/core/test/ejbthree2168 (from rev 108136, projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree2168)
Deleted: projects/ejb3/branches/infinispan-int/core/src/test/java/org/jboss/ejb3/core/test/ejbthree2168/SimpleSLSB.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree2168/SimpleSLSB.java 2010-09-14 10:43:32 UTC (rev 108136)
+++ projects/ejb3/branches/infinispan-int/core/src/test/java/org/jboss/ejb3/core/test/ejbthree2168/SimpleSLSB.java 2010-09-15 22:24:51 UTC (rev 108153)
@@ -1,53 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, 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.core.test.ejbthree2168;
-
-import javax.ejb.Stateless;
-
-/**
- * SimpleSLSB
- *
- * @author Jaikiran Pai
- * @version $Revision: $
- */
- at Stateless
-public class SimpleSLSB
-{
-
- // Note: Don't change this field name, the EnvEntryTypeTestCase depends on the field name string
- private String someEnvEntryField;
-
- // Note: Don't change this field name, the EnvEntryTypeTestCase depends on the field name string
- private char somePrimitiveField;
-
- // Note: Don't change method name since the EnvEntryTypeTestCase depends on this method name string
- public void setSomeOtherEnvEntry(Boolean test)
- {
- // do nothing
- }
-
- // Note: Don't change method name since the EnvEntryTypeTestCase depends on this method name string
- public void setSomeMethodWithPrimitiveParam(int test)
- {
- // do nothing
- }
-}
Copied: projects/ejb3/branches/infinispan-int/core/src/test/java/org/jboss/ejb3/core/test/ejbthree2168/SimpleSLSB.java (from rev 108136, projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree2168/SimpleSLSB.java)
===================================================================
--- projects/ejb3/branches/infinispan-int/core/src/test/java/org/jboss/ejb3/core/test/ejbthree2168/SimpleSLSB.java (rev 0)
+++ projects/ejb3/branches/infinispan-int/core/src/test/java/org/jboss/ejb3/core/test/ejbthree2168/SimpleSLSB.java 2010-09-15 22:24:51 UTC (rev 108153)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.core.test.ejbthree2168;
+
+import javax.ejb.Stateless;
+
+/**
+ * SimpleSLSB
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+ at Stateless
+public class SimpleSLSB
+{
+
+ // Note: Don't change this field name, the EnvEntryTypeTestCase depends on the field name string
+ private String someEnvEntryField;
+
+ // Note: Don't change this field name, the EnvEntryTypeTestCase depends on the field name string
+ private char somePrimitiveField;
+
+ // Note: Don't change method name since the EnvEntryTypeTestCase depends on this method name string
+ public void setSomeOtherEnvEntry(Boolean test)
+ {
+ // do nothing
+ }
+
+ // Note: Don't change method name since the EnvEntryTypeTestCase depends on this method name string
+ public void setSomeMethodWithPrimitiveParam(int test)
+ {
+ // do nothing
+ }
+}
Copied: projects/ejb3/branches/infinispan-int/core/src/test/java/org/jboss/ejb3/core/test/ejbthree2168/unit (from rev 108136, projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree2168/unit)
Deleted: projects/ejb3/branches/infinispan-int/core/src/test/java/org/jboss/ejb3/core/test/ejbthree2168/unit/EnvEntryTypeTestCase.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree2168/unit/EnvEntryTypeTestCase.java 2010-09-14 10:43:32 UTC (rev 108136)
+++ projects/ejb3/branches/infinispan-int/core/src/test/java/org/jboss/ejb3/core/test/ejbthree2168/unit/EnvEntryTypeTestCase.java 2010-09-15 22:24:51 UTC (rev 108153)
@@ -1,232 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, 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.core.test.ejbthree2168.unit;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-
-import junit.framework.Assert;
-
-import org.jboss.ejb3.core.test.ejbthree2168.SimpleSLSB;
-import org.jboss.injection.EncInjector;
-import org.jboss.injection.InjectionContainer;
-import org.jboss.injection.ResourceHandler;
-import org.jboss.metadata.ejb.jboss.JBossEnvironmentRefsGroupMetaData;
-import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
-import org.jboss.metadata.javaee.spec.EnvironmentEntriesMetaData;
-import org.jboss.metadata.javaee.spec.EnvironmentEntryMetaData;
-import org.jboss.metadata.javaee.spec.ResourceInjectionTargetMetaData;
-import org.jnp.server.SingletonNamingServer;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-/**
- * Tests that if env-entry-type isn't explicitly specified on a env-entry, then
- * the env-entry-type is inferred from the injection target (if any)
- *
- * @author Jaikiran Pai
- * @version $Revision: $
- */
-public class EnvEntryTypeTestCase
-{
-
- private static SingletonNamingServer namingServer;
-
- @BeforeClass
- public static void beforeClass() throws Exception
- {
- // startup the local naming server
- bootupNamingServer();
- }
-
- @AfterClass
- public static void afterClass()
- {
- if (namingServer != null)
- {
- namingServer.destroy();
- }
- }
-
- private static void bootupNamingServer() throws Exception
- {
- namingServer = new SingletonNamingServer();
-
- }
-
- /**
- * Test a env-entry without an explicit env-entry-type, with a injection target pointing
- * to a {@link Field}
- *
- * @throws Exception
- */
- @Test
- public void testEnvEntryWithoutExplicitTypeForFieldInjection() throws Exception
- {
-
- // create the env-entry
- EnvironmentEntryMetaData envEntryForField = new EnvironmentEntryMetaData();
- envEntryForField.setEnvEntryName("testField");
- envEntryForField.setValue("test");
-
- // the injection target
- ResourceInjectionTargetMetaData injectionTargetForField = new ResourceInjectionTargetMetaData();
- injectionTargetForField.setInjectionTargetClass(SimpleSLSB.class.getName());
- injectionTargetForField.setInjectionTargetName("someEnvEntryField");
-
- // setup the env-entry to use the injection target
- envEntryForField.setInjectionTargets(Collections.singleton(injectionTargetForField));
-
- // create env-entry for a injection target field of type primitive
- EnvironmentEntryMetaData envEntryForPrimitiveField = new EnvironmentEntryMetaData();
- envEntryForPrimitiveField.setEnvEntryName("testFieldWithPrimitive");
- envEntryForPrimitiveField.setValue("c");
-
- // the injection target for a primitive field
- ResourceInjectionTargetMetaData injectionTargetForPrimitiveField = new ResourceInjectionTargetMetaData();
- injectionTargetForPrimitiveField.setInjectionTargetClass(SimpleSLSB.class.getName());
- injectionTargetForPrimitiveField.setInjectionTargetName("somePrimitiveField");
-
- // setup the env-entry to use the injection target
- envEntryForPrimitiveField.setInjectionTargets(Collections.singleton(injectionTargetForPrimitiveField));
-
-
- // a mock container
- InjectionContainer mockInjectionContainer = mock(InjectionContainer.class);
- ClassLoader tccl = Thread.currentThread().getContextClassLoader();
- Map<String, EncInjector> encInjectors = new HashMap<String, EncInjector>();
- // setup the mocks
- when(mockInjectionContainer.getClassloader()).thenReturn(tccl);
- when(mockInjectionContainer.getEncInjectors()).thenReturn(encInjectors);
- when(mockInjectionContainer.getEnc()).thenReturn(this.getLocalContext());
-
- // bean metadata
- JBossSessionBeanMetaData sessionBean = new JBossSessionBeanMetaData();
- JBossEnvironmentRefsGroupMetaData envRefGroup = new JBossEnvironmentRefsGroupMetaData();
- EnvironmentEntriesMetaData envEntries = new EnvironmentEntriesMetaData();
- // add the env-entry to the env entries collection
- envEntries.add(envEntryForField);
- envEntries.add(envEntryForPrimitiveField);
- envRefGroup.setEnvironmentEntries(envEntries);
- sessionBean.setEnvironmentRefsGroup(envRefGroup);
-
- // process using a ResourceHandler
- ResourceHandler<JBossSessionBeanMetaData> resourceHandler = new ResourceHandler<JBossSessionBeanMetaData>();
- resourceHandler.loadXml(sessionBean, mockInjectionContainer);
-
- // Test
- Assert.assertEquals("Unexpected number of EncInjectors", 2, encInjectors.size());
- for (EncInjector encInjector : encInjectors.values())
- {
- // run the ENC injections
- encInjector.inject(mockInjectionContainer);
- }
- }
-
- /**
- * Test a env-entry without an explicit env-entry-type, with a injection target pointing
- * to a {@link Method}
- *
- * @throws Exception
- */
- @Test
- public void testEnvEntryWithoutExplicitTypeForMethodInjection() throws Exception
- {
-
- // create the env-entry
- EnvironmentEntryMetaData envEntryForMethod = new EnvironmentEntryMetaData();
- envEntryForMethod.setEnvEntryName("testMethod");
- envEntryForMethod.setValue("true");
-
- // the injection target
- ResourceInjectionTargetMetaData injectionTargetForMethod = new ResourceInjectionTargetMetaData();
- injectionTargetForMethod.setInjectionTargetClass(SimpleSLSB.class.getName());
- injectionTargetForMethod.setInjectionTargetName("setSomeOtherEnvEntry");
-
- // setup the env-entry to use the injection target
- envEntryForMethod.setInjectionTargets(Collections.singleton(injectionTargetForMethod));
-
- // create env-entry for a injection target method with primitive params
- EnvironmentEntryMetaData envEntryForPrimitiveMethod = new EnvironmentEntryMetaData();
- envEntryForPrimitiveMethod.setEnvEntryName("testMethodWithPrimitive");
- envEntryForPrimitiveMethod.setValue("3");
-
- // the injection target for a primitive field
- ResourceInjectionTargetMetaData injectionTargetForMethodWithPrimitiveParam = new ResourceInjectionTargetMetaData();
- injectionTargetForMethodWithPrimitiveParam.setInjectionTargetClass(SimpleSLSB.class.getName());
- injectionTargetForMethodWithPrimitiveParam.setInjectionTargetName("setSomeMethodWithPrimitiveParam");
-
- // setup the env-entry to use the injection target
- envEntryForPrimitiveMethod.setInjectionTargets(Collections.singleton(injectionTargetForMethodWithPrimitiveParam));
-
- // mock container
- InjectionContainer mockInjectionContainer = mock(InjectionContainer.class);
- ClassLoader tccl = Thread.currentThread().getContextClassLoader();
- Map<String, EncInjector> encInjectors = new HashMap<String, EncInjector>();
- // setup the mocks
- when(mockInjectionContainer.getClassloader()).thenReturn(tccl);
- when(mockInjectionContainer.getEncInjectors()).thenReturn(encInjectors);
- when(mockInjectionContainer.getEnc()).thenReturn(this.getLocalContext());
-
- // bean metadata
- JBossSessionBeanMetaData sessionBean = new JBossSessionBeanMetaData();
- JBossEnvironmentRefsGroupMetaData envRefGroup = new JBossEnvironmentRefsGroupMetaData();
- EnvironmentEntriesMetaData envEntries = new EnvironmentEntriesMetaData();
- envEntries.add(envEntryForMethod);
- envEntries.add(envEntryForPrimitiveMethod);
- envRefGroup.setEnvironmentEntries(envEntries);
- sessionBean.setEnvironmentRefsGroup(envRefGroup);
-
- // process using ResourceHandler
- ResourceHandler<JBossSessionBeanMetaData> resourceHandler = new ResourceHandler<JBossSessionBeanMetaData>();
- resourceHandler.loadXml(sessionBean, mockInjectionContainer);
-
- // Test
- Assert.assertEquals("Unexpected number of EncInjectors", 2, encInjectors.size());
- for (EncInjector encInjector : encInjectors.values())
- {
- // run the ENC injectors
- encInjector.inject(mockInjectionContainer);
- }
- }
-
- private Context getLocalContext() throws NamingException
- {
- Properties props = new Properties();
- props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.LocalOnlyContextFactory");
- return new InitialContext(props);
- }
-}
Copied: projects/ejb3/branches/infinispan-int/core/src/test/java/org/jboss/ejb3/core/test/ejbthree2168/unit/EnvEntryTypeTestCase.java (from rev 108136, projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree2168/unit/EnvEntryTypeTestCase.java)
===================================================================
--- projects/ejb3/branches/infinispan-int/core/src/test/java/org/jboss/ejb3/core/test/ejbthree2168/unit/EnvEntryTypeTestCase.java (rev 0)
+++ projects/ejb3/branches/infinispan-int/core/src/test/java/org/jboss/ejb3/core/test/ejbthree2168/unit/EnvEntryTypeTestCase.java 2010-09-15 22:24:51 UTC (rev 108153)
@@ -0,0 +1,232 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.core.test.ejbthree2168.unit;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import junit.framework.Assert;
+
+import org.jboss.ejb3.core.test.ejbthree2168.SimpleSLSB;
+import org.jboss.injection.EncInjector;
+import org.jboss.injection.InjectionContainer;
+import org.jboss.injection.ResourceHandler;
+import org.jboss.metadata.ejb.jboss.JBossEnvironmentRefsGroupMetaData;
+import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
+import org.jboss.metadata.javaee.spec.EnvironmentEntriesMetaData;
+import org.jboss.metadata.javaee.spec.EnvironmentEntryMetaData;
+import org.jboss.metadata.javaee.spec.ResourceInjectionTargetMetaData;
+import org.jnp.server.SingletonNamingServer;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Tests that if env-entry-type isn't explicitly specified on a env-entry, then
+ * the env-entry-type is inferred from the injection target (if any)
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class EnvEntryTypeTestCase
+{
+
+ private static SingletonNamingServer namingServer;
+
+ @BeforeClass
+ public static void beforeClass() throws Exception
+ {
+ // startup the local naming server
+ bootupNamingServer();
+ }
+
+ @AfterClass
+ public static void afterClass()
+ {
+ if (namingServer != null)
+ {
+ namingServer.destroy();
+ }
+ }
+
+ private static void bootupNamingServer() throws Exception
+ {
+ namingServer = new SingletonNamingServer();
+
+ }
+
+ /**
+ * Test a env-entry without an explicit env-entry-type, with a injection target pointing
+ * to a {@link Field}
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testEnvEntryWithoutExplicitTypeForFieldInjection() throws Exception
+ {
+
+ // create the env-entry
+ EnvironmentEntryMetaData envEntryForField = new EnvironmentEntryMetaData();
+ envEntryForField.setEnvEntryName("testField");
+ envEntryForField.setValue("test");
+
+ // the injection target
+ ResourceInjectionTargetMetaData injectionTargetForField = new ResourceInjectionTargetMetaData();
+ injectionTargetForField.setInjectionTargetClass(SimpleSLSB.class.getName());
+ injectionTargetForField.setInjectionTargetName("someEnvEntryField");
+
+ // setup the env-entry to use the injection target
+ envEntryForField.setInjectionTargets(Collections.singleton(injectionTargetForField));
+
+ // create env-entry for a injection target field of type primitive
+ EnvironmentEntryMetaData envEntryForPrimitiveField = new EnvironmentEntryMetaData();
+ envEntryForPrimitiveField.setEnvEntryName("testFieldWithPrimitive");
+ envEntryForPrimitiveField.setValue("c");
+
+ // the injection target for a primitive field
+ ResourceInjectionTargetMetaData injectionTargetForPrimitiveField = new ResourceInjectionTargetMetaData();
+ injectionTargetForPrimitiveField.setInjectionTargetClass(SimpleSLSB.class.getName());
+ injectionTargetForPrimitiveField.setInjectionTargetName("somePrimitiveField");
+
+ // setup the env-entry to use the injection target
+ envEntryForPrimitiveField.setInjectionTargets(Collections.singleton(injectionTargetForPrimitiveField));
+
+
+ // a mock container
+ InjectionContainer mockInjectionContainer = mock(InjectionContainer.class);
+ ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+ Map<String, EncInjector> encInjectors = new HashMap<String, EncInjector>();
+ // setup the mocks
+ when(mockInjectionContainer.getClassloader()).thenReturn(tccl);
+ when(mockInjectionContainer.getEncInjectors()).thenReturn(encInjectors);
+ when(mockInjectionContainer.getEnc()).thenReturn(this.getLocalContext());
+
+ // bean metadata
+ JBossSessionBeanMetaData sessionBean = new JBossSessionBeanMetaData();
+ JBossEnvironmentRefsGroupMetaData envRefGroup = new JBossEnvironmentRefsGroupMetaData();
+ EnvironmentEntriesMetaData envEntries = new EnvironmentEntriesMetaData();
+ // add the env-entry to the env entries collection
+ envEntries.add(envEntryForField);
+ envEntries.add(envEntryForPrimitiveField);
+ envRefGroup.setEnvironmentEntries(envEntries);
+ sessionBean.setEnvironmentRefsGroup(envRefGroup);
+
+ // process using a ResourceHandler
+ ResourceHandler<JBossSessionBeanMetaData> resourceHandler = new ResourceHandler<JBossSessionBeanMetaData>();
+ resourceHandler.loadXml(sessionBean, mockInjectionContainer);
+
+ // Test
+ Assert.assertEquals("Unexpected number of EncInjectors", 2, encInjectors.size());
+ for (EncInjector encInjector : encInjectors.values())
+ {
+ // run the ENC injections
+ encInjector.inject(mockInjectionContainer);
+ }
+ }
+
+ /**
+ * Test a env-entry without an explicit env-entry-type, with a injection target pointing
+ * to a {@link Method}
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testEnvEntryWithoutExplicitTypeForMethodInjection() throws Exception
+ {
+
+ // create the env-entry
+ EnvironmentEntryMetaData envEntryForMethod = new EnvironmentEntryMetaData();
+ envEntryForMethod.setEnvEntryName("testMethod");
+ envEntryForMethod.setValue("true");
+
+ // the injection target
+ ResourceInjectionTargetMetaData injectionTargetForMethod = new ResourceInjectionTargetMetaData();
+ injectionTargetForMethod.setInjectionTargetClass(SimpleSLSB.class.getName());
+ injectionTargetForMethod.setInjectionTargetName("setSomeOtherEnvEntry");
+
+ // setup the env-entry to use the injection target
+ envEntryForMethod.setInjectionTargets(Collections.singleton(injectionTargetForMethod));
+
+ // create env-entry for a injection target method with primitive params
+ EnvironmentEntryMetaData envEntryForPrimitiveMethod = new EnvironmentEntryMetaData();
+ envEntryForPrimitiveMethod.setEnvEntryName("testMethodWithPrimitive");
+ envEntryForPrimitiveMethod.setValue("3");
+
+ // the injection target for a primitive field
+ ResourceInjectionTargetMetaData injectionTargetForMethodWithPrimitiveParam = new ResourceInjectionTargetMetaData();
+ injectionTargetForMethodWithPrimitiveParam.setInjectionTargetClass(SimpleSLSB.class.getName());
+ injectionTargetForMethodWithPrimitiveParam.setInjectionTargetName("setSomeMethodWithPrimitiveParam");
+
+ // setup the env-entry to use the injection target
+ envEntryForPrimitiveMethod.setInjectionTargets(Collections.singleton(injectionTargetForMethodWithPrimitiveParam));
+
+ // mock container
+ InjectionContainer mockInjectionContainer = mock(InjectionContainer.class);
+ ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+ Map<String, EncInjector> encInjectors = new HashMap<String, EncInjector>();
+ // setup the mocks
+ when(mockInjectionContainer.getClassloader()).thenReturn(tccl);
+ when(mockInjectionContainer.getEncInjectors()).thenReturn(encInjectors);
+ when(mockInjectionContainer.getEnc()).thenReturn(this.getLocalContext());
+
+ // bean metadata
+ JBossSessionBeanMetaData sessionBean = new JBossSessionBeanMetaData();
+ JBossEnvironmentRefsGroupMetaData envRefGroup = new JBossEnvironmentRefsGroupMetaData();
+ EnvironmentEntriesMetaData envEntries = new EnvironmentEntriesMetaData();
+ envEntries.add(envEntryForMethod);
+ envEntries.add(envEntryForPrimitiveMethod);
+ envRefGroup.setEnvironmentEntries(envEntries);
+ sessionBean.setEnvironmentRefsGroup(envRefGroup);
+
+ // process using ResourceHandler
+ ResourceHandler<JBossSessionBeanMetaData> resourceHandler = new ResourceHandler<JBossSessionBeanMetaData>();
+ resourceHandler.loadXml(sessionBean, mockInjectionContainer);
+
+ // Test
+ Assert.assertEquals("Unexpected number of EncInjectors", 2, encInjectors.size());
+ for (EncInjector encInjector : encInjectors.values())
+ {
+ // run the ENC injectors
+ encInjector.inject(mockInjectionContainer);
+ }
+ }
+
+ private Context getLocalContext() throws NamingException
+ {
+ Properties props = new Properties();
+ props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.LocalOnlyContextFactory");
+ return new InitialContext(props);
+ }
+}
Modified: projects/ejb3/branches/infinispan-int/interceptors/pom.xml
===================================================================
--- projects/ejb3/branches/infinispan-int/interceptors/pom.xml 2010-09-15 21:29:30 UTC (rev 108152)
+++ projects/ejb3/branches/infinispan-int/interceptors/pom.xml 2010-09-15 22:24:51 UTC (rev 108153)
@@ -10,7 +10,7 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jboss-ejb3-interceptors</artifactId>
- <version>1.0.8-SNAPSHOT</version>
+ <version>1.0.9-SNAPSHOT</version>
<packaging>jar</packaging>
<name>JBoss EJB 3.0 Interceptors</name>
<url>http://www.jboss.org</url>
Modified: projects/ejb3/branches/infinispan-int/interceptors/src/main/java/org/jboss/ejb3/interceptors/lang/ClassHelper.java
===================================================================
--- projects/ejb3/branches/infinispan-int/interceptors/src/main/java/org/jboss/ejb3/interceptors/lang/ClassHelper.java 2010-09-15 21:29:30 UTC (rev 108152)
+++ projects/ejb3/branches/infinispan-int/interceptors/src/main/java/org/jboss/ejb3/interceptors/lang/ClassHelper.java 2010-09-15 22:24:51 UTC (rev 108153)
@@ -289,13 +289,18 @@
* *in the passed collection of <code>methods</code>*. Returns true if the method
* is overriden by any of the passed methods, else returns false.
*
- * @param method
+ * @param method
* @param methods
* @return
*/
public static boolean isOverridden(Method method, Method... methods)
{
-
+ // if the method is "private" then it's not overridden
+ if(Modifier.isPrivate(method.getModifiers()))
+ {
+ return false;
+ }
+
for (Method someMethod : methods)
{
// first compare the names, if not equal then no
Copied: projects/ejb3/branches/infinispan-int/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree2165 (from rev 108136, projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree2165)
Deleted: projects/ejb3/branches/infinispan-int/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree2165/Base.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree2165/Base.java 2010-09-14 10:43:32 UTC (rev 108136)
+++ projects/ejb3/branches/infinispan-int/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree2165/Base.java 2010-09-15 22:24:51 UTC (rev 108153)
@@ -1,44 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, 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.interceptors.test.ejbthree2165;
-
-import javax.interceptor.InvocationContext;
-
-/**
- * Base
- *
- * @author Jaikiran Pai
- * @version $Revision: $
- */
-public class Base
-{
-
- private Object aroundInvoke(InvocationContext ctx)
- {
- return null;
- }
-
- public void someMethod()
- {
-
- }
-}
Copied: projects/ejb3/branches/infinispan-int/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree2165/Base.java (from rev 108136, projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree2165/Base.java)
===================================================================
--- projects/ejb3/branches/infinispan-int/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree2165/Base.java (rev 0)
+++ projects/ejb3/branches/infinispan-int/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree2165/Base.java 2010-09-15 22:24:51 UTC (rev 108153)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.interceptors.test.ejbthree2165;
+
+import javax.interceptor.InvocationContext;
+
+/**
+ * Base
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class Base
+{
+
+ private Object aroundInvoke(InvocationContext ctx)
+ {
+ return null;
+ }
+
+ public void someMethod()
+ {
+
+ }
+}
Deleted: projects/ejb3/branches/infinispan-int/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree2165/BeanA.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree2165/BeanA.java 2010-09-14 10:43:32 UTC (rev 108136)
+++ projects/ejb3/branches/infinispan-int/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree2165/BeanA.java 2010-09-15 22:24:51 UTC (rev 108153)
@@ -1,50 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, 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.interceptors.test.ejbthree2165;
-
-import javax.interceptor.InvocationContext;
-
-/**
- * BeanA
- *
- * @author Jaikiran Pai
- * @version $Revision: $
- */
-public class BeanA extends Base
-{
-
- private Object aroundInvoke(InvocationContext ctx)
- {
- return null;
- }
-
- protected void doNothing()
- {
-
- }
-
- @Override
- public void someMethod()
- {
-
- }
-}
Copied: projects/ejb3/branches/infinispan-int/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree2165/BeanA.java (from rev 108136, projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree2165/BeanA.java)
===================================================================
--- projects/ejb3/branches/infinispan-int/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree2165/BeanA.java (rev 0)
+++ projects/ejb3/branches/infinispan-int/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree2165/BeanA.java 2010-09-15 22:24:51 UTC (rev 108153)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.interceptors.test.ejbthree2165;
+
+import javax.interceptor.InvocationContext;
+
+/**
+ * BeanA
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class BeanA extends Base
+{
+
+ private Object aroundInvoke(InvocationContext ctx)
+ {
+ return null;
+ }
+
+ protected void doNothing()
+ {
+
+ }
+
+ @Override
+ public void someMethod()
+ {
+
+ }
+}
Copied: projects/ejb3/branches/infinispan-int/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree2165/unit (from rev 108136, projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree2165/unit)
Deleted: projects/ejb3/branches/infinispan-int/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree2165/unit/ClassHelperTestCase.java
===================================================================
--- projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree2165/unit/ClassHelperTestCase.java 2010-09-14 10:43:32 UTC (rev 108136)
+++ projects/ejb3/branches/infinispan-int/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree2165/unit/ClassHelperTestCase.java 2010-09-15 22:24:51 UTC (rev 108153)
@@ -1,93 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, 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.interceptors.test.ejbthree2165.unit;
-
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import javax.interceptor.InvocationContext;
-
-import junit.framework.Assert;
-
-import org.jboss.ejb3.interceptors.lang.ClassHelper;
-import org.jboss.ejb3.interceptors.test.ejbthree2165.Base;
-import org.jboss.ejb3.interceptors.test.ejbthree2165.BeanA;
-import org.junit.Test;
-
-/**
- * Tests for {@link ClassHelper}
- *
- * @author Jaikiran Pai
- * @version $Revision: $
- */
-public class ClassHelperTestCase
-{
-
- /**
- * Tests the {@link ClassHelper#isOverridden(Method, Method...)} method
- *
- * @throws Exception
- */
- @Test
- public void testIsMethodOverridden() throws Exception
- {
- Class<?> klass = BeanA.class;
- List<Method> methods = new ArrayList<Method>();
- // get all the methods on BeanA and its superclass
- while (klass != null)
- {
- Method[] methodsOnClass = klass.getDeclaredMethods();
- methods.addAll(Arrays.asList(methodsOnClass));
-
- klass = klass.getSuperclass();
- }
- Method[] allMethods = methods.toArray(new Method[methods.size()]);
-
- // private methods cannot be overridden
- Method aroundInvokeOnBaseClass = Base.class.getDeclaredMethod("aroundInvoke", new Class<?>[] {InvocationContext.class});
- // public method on base class which has been overridden in the sub-class
- Method publicMethodOnBaseClass = Base.class.getDeclaredMethod("someMethod", new Class<?>[0]);
- // protected method on sub-class (which isn't in base class)
- Method protectedMethodOnBeanA = BeanA.class.getDeclaredMethod("doNothing", new Class<?>[0]);
-
- // private method shouldn't be overridden
- boolean isPrivateMethodOverridden = ClassHelper.isOverridden(aroundInvokeOnBaseClass, allMethods);
- Assert.assertFalse("Private method was considered overridden", isPrivateMethodOverridden);
-
- boolean isPublicMethodOverridden = ClassHelper.isOverridden(publicMethodOnBaseClass, allMethods);
- Assert.assertTrue("Public method which was overridden in " + BeanA.class + " was *not* considered overridden", isPublicMethodOverridden);
-
- boolean isProtectedMethodOverridden = ClassHelper.isOverridden(protectedMethodOnBeanA, allMethods);
- Assert.assertFalse("Protected method which was *not* overridden in " + BeanA.class + " was considered overridden", isProtectedMethodOverridden);
-
- // none of the methods on BeanA can be considered overridden, since
- // BeanA doesn't have any sub-classes
- for (Method methodOnBeanA : BeanA.class.getDeclaredMethods())
- {
- boolean isOverridden = ClassHelper.isOverridden(methodOnBeanA, allMethods);
- Assert.assertFalse("Method: " + methodOnBeanA + " was incorrectly considered overridden", isOverridden);
- }
-
- }
-}
Copied: projects/ejb3/branches/infinispan-int/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree2165/unit/ClassHelperTestCase.java (from rev 108136, projects/ejb3/trunk/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree2165/unit/ClassHelperTestCase.java)
===================================================================
--- projects/ejb3/branches/infinispan-int/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree2165/unit/ClassHelperTestCase.java (rev 0)
+++ projects/ejb3/branches/infinispan-int/interceptors/src/test/java/org/jboss/ejb3/interceptors/test/ejbthree2165/unit/ClassHelperTestCase.java 2010-09-15 22:24:51 UTC (rev 108153)
@@ -0,0 +1,93 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.interceptors.test.ejbthree2165.unit;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import javax.interceptor.InvocationContext;
+
+import junit.framework.Assert;
+
+import org.jboss.ejb3.interceptors.lang.ClassHelper;
+import org.jboss.ejb3.interceptors.test.ejbthree2165.Base;
+import org.jboss.ejb3.interceptors.test.ejbthree2165.BeanA;
+import org.junit.Test;
+
+/**
+ * Tests for {@link ClassHelper}
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class ClassHelperTestCase
+{
+
+ /**
+ * Tests the {@link ClassHelper#isOverridden(Method, Method...)} method
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testIsMethodOverridden() throws Exception
+ {
+ Class<?> klass = BeanA.class;
+ List<Method> methods = new ArrayList<Method>();
+ // get all the methods on BeanA and its superclass
+ while (klass != null)
+ {
+ Method[] methodsOnClass = klass.getDeclaredMethods();
+ methods.addAll(Arrays.asList(methodsOnClass));
+
+ klass = klass.getSuperclass();
+ }
+ Method[] allMethods = methods.toArray(new Method[methods.size()]);
+
+ // private methods cannot be overridden
+ Method aroundInvokeOnBaseClass = Base.class.getDeclaredMethod("aroundInvoke", new Class<?>[] {InvocationContext.class});
+ // public method on base class which has been overridden in the sub-class
+ Method publicMethodOnBaseClass = Base.class.getDeclaredMethod("someMethod", new Class<?>[0]);
+ // protected method on sub-class (which isn't in base class)
+ Method protectedMethodOnBeanA = BeanA.class.getDeclaredMethod("doNothing", new Class<?>[0]);
+
+ // private method shouldn't be overridden
+ boolean isPrivateMethodOverridden = ClassHelper.isOverridden(aroundInvokeOnBaseClass, allMethods);
+ Assert.assertFalse("Private method was considered overridden", isPrivateMethodOverridden);
+
+ boolean isPublicMethodOverridden = ClassHelper.isOverridden(publicMethodOnBaseClass, allMethods);
+ Assert.assertTrue("Public method which was overridden in " + BeanA.class + " was *not* considered overridden", isPublicMethodOverridden);
+
+ boolean isProtectedMethodOverridden = ClassHelper.isOverridden(protectedMethodOnBeanA, allMethods);
+ Assert.assertFalse("Protected method which was *not* overridden in " + BeanA.class + " was considered overridden", isProtectedMethodOverridden);
+
+ // none of the methods on BeanA can be considered overridden, since
+ // BeanA doesn't have any sub-classes
+ for (Method methodOnBeanA : BeanA.class.getDeclaredMethods())
+ {
+ boolean isOverridden = ClassHelper.isOverridden(methodOnBeanA, allMethods);
+ Assert.assertFalse("Method: " + methodOnBeanA + " was incorrectly considered overridden", isOverridden);
+ }
+
+ }
+}
More information about the jboss-cvs-commits
mailing list