[webbeans-commits] Webbeans SVN: r552 - in ri/trunk/webbeans-ri: src/main/java/org/jboss/webbeans and 7 other directories.
webbeans-commits at lists.jboss.org
webbeans-commits at lists.jboss.org
Thu Dec 18 14:48:17 EST 2008
Author: pete.muir at jboss.org
Date: 2008-12-18 14:48:16 -0500 (Thu, 18 Dec 2008)
New Revision: 552
Added:
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ejb/valid/Labrador.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ejb/valid/PomeranianInterface.java
Modified:
ri/trunk/webbeans-ri/.settings/org.eclipse.jdt.core.prefs
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ejb/DefaultEnterpriseBeanLookup.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ejb/EjbDescriptorCache.java
ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/JNDI.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ejb/EnterpriseBeanDeclarationTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ejb/EnterpriseBeanRemoveMethodTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ejb/EnterpriseBeanSpecializationTest.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ejb/invalid/Armant.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ejb/valid/Laika.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ejb/valid/Pomeranian.java
ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/mock/MockEjbDescriptor.java
Log:
Bah, really commit
Modified: ri/trunk/webbeans-ri/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- ri/trunk/webbeans-ri/.settings/org.eclipse.jdt.core.prefs 2008-12-18 19:37:12 UTC (rev 551)
+++ ri/trunk/webbeans-ri/.settings/org.eclipse.jdt.core.prefs 2008-12-18 19:48:16 UTC (rev 552)
@@ -1,4 +1,4 @@
-#Tue Dec 16 18:53:08 GMT 2008
+#Tue Dec 16 18:57:16 GMT 2008
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.source=1.5
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java 2008-12-18 19:37:12 UTC (rev 551)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ManagerImpl.java 2008-12-18 19:48:16 UTC (rev 552)
@@ -49,6 +49,7 @@
import org.jboss.webbeans.bean.AbstractBean;
import org.jboss.webbeans.bean.proxy.ProxyPool;
import org.jboss.webbeans.contexts.ContextMap;
+import org.jboss.webbeans.ejb.EjbDescriptorCache;
import org.jboss.webbeans.event.EventManager;
import org.jboss.webbeans.introspector.AnnotatedItem;
import org.jboss.webbeans.introspector.AnnotatedMethod;
@@ -87,6 +88,8 @@
private Set<Decorator> decorators;
// The registered interceptors
private Set<Interceptor> interceptors;
+
+ private EjbDescriptorCache ejbDescriptorCache;
/**
* Constructor
@@ -103,6 +106,7 @@
this.interceptors = new HashSet<Interceptor>();
this.contextMap = new ContextMap();
this.eventManager = new EventManager(this);
+ this.ejbDescriptorCache = new EjbDescriptorCache();
List<Class<? extends Annotation>> defaultEnabledDeploymentTypes = new ArrayList<Class<? extends Annotation>>();
defaultEnabledDeploymentTypes.add(0, Standard.class);
@@ -629,6 +633,11 @@
{
return resolver;
}
+
+ public EjbDescriptorCache getEjbDescriptorCache()
+ {
+ return ejbDescriptorCache;
+ }
/**
* Gets a string representation
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java 2008-12-18 19:37:12 UTC (rev 551)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/bean/EnterpriseBean.java 2008-12-18 19:48:16 UTC (rev 552)
@@ -31,14 +31,13 @@
import javax.webbeans.Observes;
import javax.webbeans.Produces;
import javax.webbeans.Specializes;
-import javax.webbeans.manager.EnterpriseBeanLookup;
import javax.webbeans.manager.Manager;
import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.bootstrap.spi.EjbDescriptor;
import org.jboss.webbeans.bootstrap.spi.MethodDescriptor;
import org.jboss.webbeans.contexts.DependentContext;
-import org.jboss.webbeans.ejb.EjbDescriptorCache;
+import org.jboss.webbeans.ejb.DefaultEnterpriseBeanLookup;
import org.jboss.webbeans.introspector.AnnotatedField;
import org.jboss.webbeans.introspector.AnnotatedMethod;
import org.jboss.webbeans.introspector.AnnotatedParameter;
@@ -83,7 +82,11 @@
protected void init()
{
super.init();
- Iterable<EjbDescriptor<T>> ejbDescriptors = EjbDescriptorCache.instance().get(getType());
+ Iterable<EjbDescriptor<T>> ejbDescriptors = manager.getEjbDescriptorCache().get(getType());
+ if (ejbDescriptors == null)
+ {
+ throw new DefinitionException("Not an EJB " + toString());
+ }
for (EjbDescriptor<T> ejbDescriptor : ejbDescriptors)
{
if (this.ejbDescriptor == null)
@@ -160,7 +163,8 @@
{
return;
}
- if (EjbDescriptorCache.instance().containsKey(getType().getSuperclass()))
+ // TODO Should also check the bean type it does contain!
+ if (!manager.getEjbDescriptorCache().containsKey(getType().getSuperclass()))
{
throw new DefinitionException("Annotation defined specializing EJB must have EJB superclass");
}
@@ -171,18 +175,27 @@
*/
protected void initRemoveMethod()
{
- if (!ejbDescriptor.isStateful())
- {
- // Nothing to do for stateless enterprise beans;
- return;
- }
// >1 @Destructor
if (getAnnotatedItem().getAnnotatedMethods(Destructor.class).size() > 1)
{
throw new DefinitionException("Multiple @Destructor methods not allowed on " + getAnnotatedItem());
}
-
+
+ if (getAnnotatedItem().getAnnotatedMethods(Destructor.class).size() == 1)
+ {
+ AnnotatedMethod<?> destructorMethod = getAnnotatedItem().getAnnotatedMethods(Destructor.class).iterator().next();
+ for (MethodDescriptor removeMethod : ejbDescriptor.getRemoveMethods())
+ {
+ AnnotatedMethod<?> annotatedRemoveMethod = getAnnotatedItem().getMethod(removeMethod);
+ if (annotatedRemoveMethod != null && annotatedRemoveMethod.equals(destructorMethod))
+ {
+ this.removeMethod = destructorMethod;
+ return;
+ }
+ }
+ throw new DefinitionException("Method annotated @Destructor is not an EJB remove method on " + toString());
+ }
// <1 (0) @Destructors
Set<MethodDescriptor> noArgsRemoveMethods = getNoArgsRemoveMethods(ejbDescriptor);
if (noArgsRemoveMethods.size() == 1)
@@ -190,10 +203,10 @@
this.removeMethod = annotatedItem.getMethod(noArgsRemoveMethods.iterator().next());
return;
}
-
+
if (!getScopeType().equals(Dependent.class))
{
- throw new DefinitionException("Only @Dependent scoped enterprise beans can be without remove methods");
+ throw new DefinitionException("Only @Dependent scoped enterprise beans can be without remove methods " + toString());
}
}
@@ -210,16 +223,6 @@
}
return noArgsRemoveMethods;
}
-
- private void checkDestructorMethods()
- {
- // TODO Check that any method annotated @Destructor is actually in the remove method list
- /*
- if (removeMethod.isAnnotationPresent(Destructor.class) && !removeMethod.isAnnotationPresent(EJB.REMOVE_ANNOTATION))
- {
- throw new DefinitionException("Methods marked @Destructor must also be marked @Remove on " + removeMethod.getName());
- }*/
- }
/**
* Validates the remove method
@@ -230,7 +233,10 @@
{
return;
}
-
+ else if (ejbDescriptor.isStateless())
+ {
+ throw new DefinitionException("Can't define a remove method on SLSBs");
+ }
if (removeMethod.isAnnotationPresent(Initializer.class))
{
throw new DefinitionException("Remove methods cannot be initializers on " + removeMethod.getName());
@@ -261,7 +267,7 @@
try
{
DependentContext.INSTANCE.setActive(true);
- T instance = (T) manager.getInstanceByType(EnterpriseBeanLookup.class).lookup(ejbDescriptor.getEjbName());
+ T instance = (T) manager.getInstanceByType(DefaultEnterpriseBeanLookup.class).lookup(ejbDescriptor);
bindDecorators();
bindInterceptors();
injectEjbAndCommonFields();
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ejb/DefaultEnterpriseBeanLookup.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ejb/DefaultEnterpriseBeanLookup.java 2008-12-18 19:37:12 UTC (rev 551)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ejb/DefaultEnterpriseBeanLookup.java 2008-12-18 19:48:16 UTC (rev 552)
@@ -18,9 +18,12 @@
package org.jboss.webbeans.ejb;
import javax.webbeans.CreationException;
+import javax.webbeans.Current;
+import javax.webbeans.Initializer;
import javax.webbeans.Standard;
import javax.webbeans.manager.EnterpriseBeanLookup;
+import org.jboss.webbeans.ManagerImpl;
import org.jboss.webbeans.bootstrap.spi.EjbDescriptor;
import org.jboss.webbeans.util.JNDI;
@@ -33,6 +36,14 @@
@Standard
public class DefaultEnterpriseBeanLookup implements EnterpriseBeanLookup
{
+
+ private ManagerImpl manager;
+
+ @Initializer
+ public DefaultEnterpriseBeanLookup(@Current ManagerImpl manager)
+ {
+ this.manager = manager;
+ }
/**
* Looks up and EJB based on the name
@@ -46,7 +57,7 @@
{
throw new NullPointerException("No EJB name supplied for lookup");
}
- return lookup(EjbDescriptorCache.instance().get(ejbName));
+ return lookup(manager.getEjbDescriptorCache().get(ejbName));
}
/**
@@ -59,9 +70,15 @@
@SuppressWarnings("unchecked")
public static <T> T lookup(EjbDescriptor<T> ejbDescriptor)
{
+ if (!ejbDescriptor.getLocalBusinessInterfaces().iterator().hasNext())
+ {
+ throw new RuntimeException("EJB must have local interface " + ejbDescriptor);
+ }
+ String jndiName = ejbDescriptor.getLocalBusinessInterfaces().iterator().next().getJndiName();
try
{
- return (T) JNDI.lookup(ejbDescriptor.getEjbName());
+ // TODO Implement enterprise proxies and select the correct jndiName
+ return (T) JNDI.lookup(jndiName);
}
catch (Exception e)
{
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ejb/EjbDescriptorCache.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ejb/EjbDescriptorCache.java 2008-12-18 19:37:12 UTC (rev 551)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/ejb/EjbDescriptorCache.java 2008-12-18 19:48:16 UTC (rev 552)
@@ -25,32 +25,14 @@
import org.jboss.webbeans.bootstrap.spi.EjbDescriptor;
/**
- * Singleton for accessing EJB descriptors by EJB implementation class or name
+ * EJB descriptors by EJB implementation class or name
*
* @author Pete Muir
*
*/
public class EjbDescriptorCache
{
- // The singleton
- private static EjbDescriptorCache instance;
- /**
- * Accessor for the singleton
- *
- * @return The instance
- */
- public static EjbDescriptorCache instance()
- {
- return instance;
- }
-
- // Static initalizer block
- static
- {
- instance = new EjbDescriptorCache();
- }
-
// EJB name -> EJB descriptor map
private ConcurrentMap<String, EjbDescriptor<?>> ejbsByName;
// EJB implementation class -> EJB descriptors map
@@ -134,5 +116,17 @@
add(ejbDescriptor);
}
}
+
+ public void clear()
+ {
+ ejbsByBeanClass.clear();
+ ejbsByName.clear();
+ }
+
+ @Override
+ public String toString()
+ {
+ return ejbsByBeanClass + "\n" + ejbsByName;
+ }
}
Modified: ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/JNDI.java
===================================================================
--- ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/JNDI.java 2008-12-18 19:37:12 UTC (rev 551)
+++ ri/trunk/webbeans-ri/src/main/java/org/jboss/webbeans/util/JNDI.java 2008-12-18 19:48:16 UTC (rev 552)
@@ -17,7 +17,16 @@
package org.jboss.webbeans.util;
+import java.util.Hashtable;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.webbeans.ExecutionException;
+
+import org.jboss.webbeans.log.LogProvider;
+import org.jboss.webbeans.log.Logging;
+
+
/**
* Provides JNDI access abstraction
*
@@ -26,6 +35,62 @@
public class JNDI
{
+ private static final LogProvider log = Logging.getLogProvider(JNDI.class);
+ private static Hashtable initialContextProperties;
+
+ private static InitialContext initialContext;
+
+ public static InitialContext getInitialContext(Hashtable<String, String> props) throws NamingException
+ {
+ if (props==null)
+ {
+ throw new IllegalStateException("JNDI properties not initialized, Seam was not started correctly");
+ }
+
+ if (log.isDebugEnabled())
+ {
+ log.debug("JNDI InitialContext properties:" + props);
+ }
+
+ try {
+ return props.size()==0 ?
+ new InitialContext() :
+ new InitialContext(props);
+ }
+ catch (NamingException e) {
+ log.debug("Could not obtain initial context", e);
+ throw e;
+ }
+
+ }
+
+ public static InitialContext getInitialContext() throws NamingException
+ {
+ if (initialContext == null) initInitialContext();
+
+ return initialContext;
+ }
+
+ private static synchronized void initInitialContext() throws NamingException
+ {
+ if (initialContext == null)
+ {
+ initialContext = getInitialContext(initialContextProperties);
+ }
+ }
+
+ public static void setInitialContextProperties(Hashtable initialContextProperties)
+ {
+ initialContextProperties = initialContextProperties;
+ initialContext = null;
+ }
+
+ public static Hashtable getInitialContextProperties()
+ {
+ return initialContextProperties;
+ }
+
+
/**
* Looks up a object in JNDI
*
@@ -47,7 +112,14 @@
*/
public static <T> T lookup(String name, Class<? extends T> expectedType)
{
- return null;
+ try
+ {
+ return (T) getInitialContext().lookup(name);
+ }
+ catch (NamingException e)
+ {
+ throw new ExecutionException("Error looking " + name + " up in JNDI", e);
+ }
}
public static void set(String key, Object value)
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ejb/EnterpriseBeanDeclarationTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ejb/EnterpriseBeanDeclarationTest.java 2008-12-18 19:37:12 UTC (rev 551)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ejb/EnterpriseBeanDeclarationTest.java 2008-12-18 19:48:16 UTC (rev 552)
@@ -14,14 +14,16 @@
import org.jboss.webbeans.test.ejb.invalid.Boxer;
import org.jboss.webbeans.test.ejb.invalid.Bullmastiff;
import org.jboss.webbeans.test.ejb.invalid.Dachshund;
-import org.jboss.webbeans.test.ejb.invalid.GreatDane;
import org.jboss.webbeans.test.ejb.invalid.Greyhound;
import org.jboss.webbeans.test.ejb.invalid.Husky;
import org.jboss.webbeans.test.ejb.invalid.IrishTerrier;
import org.jboss.webbeans.test.ejb.invalid.Pekingese;
import org.jboss.webbeans.test.ejb.invalid.Pug;
+import org.jboss.webbeans.test.ejb.invalid.Saluki;
+import org.jboss.webbeans.test.ejb.valid.Labrador;
import org.jboss.webbeans.test.ejb.valid.Laika;
import org.jboss.webbeans.test.ejb.valid.Pitbull;
+import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
/**
@@ -39,6 +41,26 @@
@SuppressWarnings("unused")
public class EnterpriseBeanDeclarationTest extends AbstractTest
{
+
+ @BeforeMethod
+ public void setupEjbDescriptors()
+ {
+ addToEjbCache(Pug.class);
+ addToEjbCache(Giraffe.class);
+ addToEjbCache(Husky.class);
+ addToEjbCache(Pitbull.class);
+ addToEjbCache(IrishTerrier.class);
+ addToEjbCache(Laika.class);
+ addToEjbCache(Leopard.class);
+ addToEjbCache(Labrador.class);
+ addToEjbCache(Greyhound.class);
+ addToEjbCache(Dachshund.class);
+ addToEjbCache(Bullmastiff.class);
+ addToEjbCache(Pekingese.class);
+ addToEjbCache(Boxer.class);
+ addToEjbCache(Beagle.class);
+ addToEjbCache(Saluki.class);
+ }
/**
* An EJB stateless session bean must belong to the @Dependent pseudo-scope.
@@ -116,7 +138,7 @@
@SpecAssertion(section = "3.3")
public void testSingletonWithDependentScopeOK()
{
- EnterpriseBean<GreatDane> greatDane = BeanFactory.createEnterpriseBean(GreatDane.class, manager);
+ BeanFactory.createEnterpriseBean(Labrador.class, manager);
}
/**
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ejb/EnterpriseBeanRemoveMethodTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ejb/EnterpriseBeanRemoveMethodTest.java 2008-12-18 19:37:12 UTC (rev 551)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ejb/EnterpriseBeanRemoveMethodTest.java 2008-12-18 19:48:16 UTC (rev 552)
@@ -13,7 +13,6 @@
import org.jboss.webbeans.test.ejb.invalid.Armant;
import org.jboss.webbeans.test.ejb.invalid.GoldenRetriever;
import org.jboss.webbeans.test.ejb.invalid.JackRussellTerrier;
-import org.jboss.webbeans.test.ejb.invalid.Poodle;
import org.jboss.webbeans.test.ejb.invalid.Pumi;
import org.jboss.webbeans.test.ejb.invalid.Rottweiler;
import org.jboss.webbeans.test.ejb.invalid.RussellTerrier;
@@ -22,6 +21,7 @@
import org.jboss.webbeans.test.ejb.valid.Koirus;
import org.jboss.webbeans.test.ejb.valid.Toller;
import org.jboss.webbeans.test.ejb.valid.WelshCorgie;
+import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
/**
@@ -38,6 +38,22 @@
@SuppressWarnings("unused")
public class EnterpriseBeanRemoveMethodTest extends AbstractTest
{
+
+ @BeforeMethod
+ public void setupEjbDescriptors()
+ {
+ addToEjbCache(JackRussellTerrier.class);
+ addToEjbCache(Pumi.class);
+ addToEjbCache(RussellTerrier.class);
+ addToEjbCache(Rottweiler.class);
+ addToEjbCache(GoldenRetriever.class);
+ addToEjbCache(Armant.class);
+ addToEjbCache(Spitz.class);
+ addToEjbCache(Toller.class);
+ addToEjbCache(WelshCorgie.class);
+ addToEjbCache(Koirus.class);
+ }
+
public static boolean visited = false;
/**
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ejb/EnterpriseBeanSpecializationTest.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ejb/EnterpriseBeanSpecializationTest.java 2008-12-18 19:37:12 UTC (rev 551)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ejb/EnterpriseBeanSpecializationTest.java 2008-12-18 19:48:16 UTC (rev 552)
@@ -11,6 +11,7 @@
import org.jboss.webbeans.test.ejb.invalid.GreaterDane;
import org.jboss.webbeans.test.ejb.valid.Hound;
import org.jboss.webbeans.test.ejb.valid.HoundOfBaskerville;
+import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
/**
@@ -23,6 +24,15 @@
@SpecVersion("20081206")
public class EnterpriseBeanSpecializationTest extends AbstractTest
{
+
+ @BeforeMethod
+ public void setupEjbDescriptors()
+ {
+ addToEjbCache(HoundOfBaskerville.class);
+ addToEjbCache(Hound.class);
+ addToEjbCache(GreaterDane.class);
+ }
+
/**
* If an implementation class of an enterprise Web Bean X defined using
* annotations is annotated @Specializes, then the implementation class of X
@@ -132,7 +142,7 @@
@SpecAssertion(section = "3.3.6")
public void testAnnotationDefinedSpecializingEnterpriseBeanNotDirectlyExtendingAnnotationDefinedEnterpriseBeanFails()
{
- EnterpriseBean<GreaterDane> greaterDane = BeanFactory.createEnterpriseBean(GreaterDane.class, manager);
+ BeanFactory.createEnterpriseBean(GreaterDane.class, manager);
}
@Test(expectedExceptions = DefinitionException.class, groups = { "stub", "specialization", "enterpriseBeans" })
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ejb/invalid/Armant.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ejb/invalid/Armant.java 2008-12-18 19:37:12 UTC (rev 551)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ejb/invalid/Armant.java 2008-12-18 19:48:16 UTC (rev 552)
@@ -1,12 +1,13 @@
package org.jboss.webbeans.test.ejb.invalid;
+import javax.ejb.Remove;
import javax.ejb.Stateless;
import javax.webbeans.Destructor;
@Stateless
public class Armant
{
- @Destructor
+ @Destructor @Remove
public void bye() {
}
Added: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ejb/valid/Labrador.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ejb/valid/Labrador.java (rev 0)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ejb/valid/Labrador.java 2008-12-18 19:48:16 UTC (rev 552)
@@ -0,0 +1,12 @@
+package org.jboss.webbeans.test.ejb.valid;
+
+import javax.webbeans.Dependent;
+
+import org.jboss.webbeans.test.annotations.Singleton;
+
+ at Singleton
+ at Dependent
+public class Labrador
+{
+
+}
Property changes on: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ejb/valid/Labrador.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ejb/valid/Laika.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ejb/valid/Laika.java 2008-12-18 19:37:12 UTC (rev 551)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ejb/valid/Laika.java 2008-12-18 19:48:16 UTC (rev 552)
@@ -1,5 +1,6 @@
package org.jboss.webbeans.test.ejb.valid;
+import javax.ejb.Remove;
import javax.webbeans.ApplicationScoped;
import org.jboss.webbeans.test.annotations.Singleton;
@@ -9,4 +10,10 @@
public class Laika
{
+ @Remove
+ public void remove()
+ {
+
+ }
+
}
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ejb/valid/Pomeranian.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ejb/valid/Pomeranian.java 2008-12-18 19:37:12 UTC (rev 551)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ejb/valid/Pomeranian.java 2008-12-18 19:48:16 UTC (rev 552)
@@ -11,7 +11,7 @@
@Stateful
@Tame
@Named("Teddy")
-public class Pomeranian
+public class Pomeranian implements PomeranianInterface
{
public static Thread notificationThread;
Added: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ejb/valid/PomeranianInterface.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ejb/valid/PomeranianInterface.java (rev 0)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ejb/valid/PomeranianInterface.java 2008-12-18 19:48:16 UTC (rev 552)
@@ -0,0 +1,6 @@
+package org.jboss.webbeans.test.ejb.valid;
+
+public interface PomeranianInterface
+{
+
+}
Property changes on: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/ejb/valid/PomeranianInterface.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/mock/MockEjbDescriptor.java
===================================================================
--- ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/mock/MockEjbDescriptor.java 2008-12-18 19:37:12 UTC (rev 551)
+++ ri/trunk/webbeans-ri/src/test/java/org/jboss/webbeans/test/mock/MockEjbDescriptor.java 2008-12-18 19:48:16 UTC (rev 552)
@@ -1,9 +1,10 @@
package org.jboss.webbeans.test.mock;
import java.lang.reflect.Method;
-import java.util.Collection;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
+import java.util.List;
import javax.ejb.MessageDriven;
import javax.ejb.Remove;
@@ -13,36 +14,38 @@
import org.jboss.webbeans.bootstrap.spi.BusinessInterfaceDescriptor;
import org.jboss.webbeans.bootstrap.spi.EjbDescriptor;
import org.jboss.webbeans.bootstrap.spi.MethodDescriptor;
+import org.jboss.webbeans.test.annotations.Singleton;
public class MockEjbDescriptor<T> implements EjbDescriptor<T>
{
- private Class<T> type;
- private String ejbName;
+ private final Class<T> type;
+ private final String ejbName;
+ private final List<BusinessInterfaceDescriptor<?>> localInterfaces;
+ private final HashSet<MethodDescriptor> removeMethods;
- public MockEjbDescriptor(Class<T> type)
+ public MockEjbDescriptor(final Class<T> type)
{
this.type = type;
- this.ejbName = type.getSimpleName() + "/local";
- }
+ this.ejbName = type.getSimpleName();
+ this.localInterfaces = new ArrayList<BusinessInterfaceDescriptor<?>>();
+ for (final Class<Object> clazz : type.getInterfaces())
+ {
+ localInterfaces.add(new BusinessInterfaceDescriptor<Object>()
+ {
- public String getEjbName()
- {
- return ejbName;
- }
+ public Class<Object> getInterface()
+ {
+ return clazz;
+ }
- public Iterable<BusinessInterfaceDescriptor<?>> getLocalBusinessInterfaces()
- {
- return Collections.emptyList();
- }
-
- public Iterable<BusinessInterfaceDescriptor<?>> getRemoteBusinessInterfaces()
- {
- return Collections.emptyList();
- }
-
- public Iterable<MethodDescriptor> getRemoveMethods()
- {
- Collection<MethodDescriptor> removeMethods = new HashSet<MethodDescriptor>();
+ public String getJndiName()
+ {
+ return clazz.getSimpleName() + "/local";
+ }
+
+ });
+ }
+ this.removeMethods = new HashSet<MethodDescriptor>();
for (final Method method : type.getMethods())
{
if (method.isAnnotationPresent(Remove.class))
@@ -50,11 +53,6 @@
removeMethods.add(new MethodDescriptor()
{
- public Class<?> getDeclaringClass()
- {
- return type;
- }
-
public String getMethodName()
{
return method.getName();
@@ -65,9 +63,35 @@
return method.getParameterTypes();
}
+ @Override
+ public String toString()
+ {
+ return method.toString();
+ }
+
});
}
}
+ }
+
+ public String getEjbName()
+ {
+ return ejbName;
+ }
+
+ public Iterable<BusinessInterfaceDescriptor<?>> getLocalBusinessInterfaces()
+ {
+ return localInterfaces;
+ }
+
+ public Iterable<BusinessInterfaceDescriptor<?>> getRemoteBusinessInterfaces()
+ {
+ return Collections.emptyList();
+ }
+
+ public Iterable<MethodDescriptor> getRemoveMethods()
+ {
+
return removeMethods;
}
@@ -83,8 +107,7 @@
public boolean isSingleton()
{
- return false;
- //return type.isAnnotationPresent(Singleton.class);
+ return type.isAnnotationPresent(Singleton.class);
}
public boolean isStateful()
@@ -118,6 +141,7 @@
{
builder.append(" (MDB)");
}
+ builder.append("remove methods; " + removeMethods + "; ");
builder.append("; BeanClass: " + getType() + "; Local Business Interfaces: " + getLocalBusinessInterfaces());
return builder.toString();
}
More information about the weld-commits
mailing list