Return-Path: X-Original-To: apmail-openejb-commits-archive@www.apache.org Delivered-To: apmail-openejb-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D73B66BD2 for ; Wed, 1 Jun 2011 23:56:58 +0000 (UTC) Received: (qmail 26982 invoked by uid 500); 1 Jun 2011 23:56:58 -0000 Delivered-To: apmail-openejb-commits-archive@openejb.apache.org Received: (qmail 26954 invoked by uid 500); 1 Jun 2011 23:56:58 -0000 Mailing-List: contact commits-help@openejb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@openejb.apache.org Delivered-To: mailing list commits@openejb.apache.org Received: (qmail 26947 invoked by uid 99); 1 Jun 2011 23:56:58 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 01 Jun 2011 23:56:58 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 01 Jun 2011 23:56:54 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 61ACD238890D; Wed, 1 Jun 2011 23:56:34 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1130358 - in /openejb/trunk/openejb3: container/openejb-core/src/main/java/org/apache/openejb/ container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ container/openejb-core/src/main/java/org/apache/openejb/cdi/ containe... Date: Wed, 01 Jun 2011 23:56:34 -0000 To: commits@openejb.apache.org From: dblevins@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110601235634.61ACD238890D@eris.apache.org> Author: dblevins Date: Wed Jun 1 23:56:32 2011 New Revision: 1130358 URL: http://svn.apache.org/viewvc?rev=1130358&view=rev Log: Big jump forward in EJB/CDI integration OPENEJB-1197 OPENEJB-1337 Added: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/cdi/InjectionTest.java openejb/trunk/openejb3/tck/cdi-embedded/src/test/java/org/apache/openejb/tck/cdi/embedded/Archive.java (contents, props changed) - copied, changed from r1124537, geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/archive/Archives.java openejb/trunk/openejb3/tck/cdi-embedded/src/test/java/org/apache/openejb/tck/cdi/embedded/ContainersImpl.java openejb/trunk/openejb3/tck/cdi-embedded/src/test/java/org/apache/openejb/tck/cdi/embedded/Report.java Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/AppContext.java openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/OpenEJB.java openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/OpenEjbContainer.java openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiBuilder.java openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiEjbBean.java openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiScanner.java openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/cdi/OWBContextThreadListener.java openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/cdi/ThreadSingletonServiceImpl.java openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/NewLoaderLogic.java openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/CoreContainerSystem.java openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/spi/ContainerSystem.java openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/stateful/StatefulTest.java openejb/trunk/openejb3/tck/cdi-embedded/src/test/java/org/apache/openejb/tck/cdi/embedded/BeansImpl.java openejb/trunk/openejb3/tck/cdi-embedded/src/test/java/org/apache/openejb/tck/cdi/embedded/StandaloneContainersImpl.java openejb/trunk/openejb3/tck/cdi-embedded/src/test/resources/META-INF/jboss-test-harness.properties openejb/trunk/openejb3/tck/cdi-embedded/src/test/resources/failing.xml openejb/trunk/openejb3/tck/cdi-embedded/src/test/resources/passing.xml Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/AppContext.java URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/AppContext.java?rev=1130358&r1=1130357&r2=1130358&view=diff ============================================================================== --- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/AppContext.java (original) +++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/AppContext.java Wed Jun 1 23:56:32 2011 @@ -35,6 +35,7 @@ import java.util.concurrent.TimeUnit; * @version $Rev$ $Date$ */ public class AppContext extends DeploymentContext { + private final SystemInstance systemInstance; private final ClassLoader classLoader; private final Context globalJndiContext; Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/OpenEJB.java URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/OpenEJB.java?rev=1130358&r1=1130357&r2=1130358&view=diff ============================================================================== --- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/OpenEJB.java (original) +++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/OpenEJB.java Wed Jun 1 23:56:32 2011 @@ -70,7 +70,7 @@ public final class OpenEJB { if (appServer == null) { throw new IllegalArgumentException("appServer must not be null"); } - initialized = new Exception("Initialized at "+new Date()).fillInStackTrace(); + initialized = new InitializationException("Initialized at "+new Date()).fillInStackTrace(); Logger.configure(); Logger logger = Logger.getInstance(LogCategory.OPENEJB_STARTUP, "org.apache.openejb.util.resources"); @@ -242,7 +242,7 @@ public final class OpenEJB { public static void destroy() { Assembler assembler = SystemInstance.get().getComponent(Assembler.class); - assembler.destroy(); + if (assembler != null) assembler.destroy(); SystemInstance.reset(); instance = null; } @@ -283,4 +283,11 @@ public final class OpenEJB { public static boolean isInitialized() { return instance != null || SystemInstance.get().getComponent(ContainerSystem.class) != null; } + + public static class InitializationException extends Exception { + public InitializationException(String message) + { + super(message); + } + } } Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/OpenEjbContainer.java URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/OpenEjbContainer.java?rev=1130358&r1=1130357&r2=1130358&view=diff ============================================================================== --- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/OpenEjbContainer.java (original) +++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/OpenEjbContainer.java Wed Jun 1 23:56:32 2011 @@ -16,7 +16,6 @@ */ package org.apache.openejb; -import bsh.Modifiers; import org.apache.openejb.assembler.classic.AppInfo; import org.apache.openejb.assembler.classic.Assembler; import org.apache.openejb.config.AppModule; @@ -77,13 +76,15 @@ public class OpenEjbContainer extends EJ private static OpenEjbContainer instance; - private final Context context; + private final AppContext appContext; private ServiceManagerProxy serviceManager; private Options options; + private OpenEjbContainer.GlobalContext globalJndiContext; - private OpenEjbContainer(Map map, Context context) { - this.context = new GlobalContext(context); + private OpenEjbContainer(Map map, AppContext appContext) { + this.appContext = appContext; + this.globalJndiContext = new GlobalContext(appContext.getGlobalJndiContext()); final Properties properties = new Properties(); properties.putAll(map); @@ -99,7 +100,7 @@ public class OpenEjbContainer extends EJ serviceManager.stop(); } try { - context.close(); + globalJndiContext.close(); } catch (NamingException e) { throw new IllegalStateException(e); } @@ -109,7 +110,7 @@ public class OpenEjbContainer extends EJ @Override public Context getContext() { - return context; + return globalJndiContext; } public T inject(T object) { @@ -188,7 +189,7 @@ public class OpenEjbContainer extends EJ public EJBContainer createEJBContainer(Map map) { if (isOtherProvider(map)) return null; - if (instance != null) { + if (instance != null || OpenEJB.isInitialized()) { logger.info("EJBContainer already initialized. Call ejbContainer.close() to allow reinitialization"); return instance; } @@ -265,7 +266,7 @@ public class OpenEjbContainer extends EJ } - return instance = new OpenEjbContainer(map, appContext.getGlobalJndiContext()); + return instance = new OpenEjbContainer(map, appContext); } catch (OpenEJBException e) { @@ -283,6 +284,13 @@ public class OpenEjbContainer extends EJ } throw new InitializationException(e); + } finally { + if (instance == null && OpenEJB.isInitialized()) { + try { + OpenEJB.destroy(); + } catch (Exception e) { + } + } } } Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java?rev=1130358&r1=1130357&r2=1130358&view=diff ============================================================================== --- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java (original) +++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java Wed Jun 1 23:56:32 2011 @@ -507,6 +507,7 @@ public class Assembler extends Assembler } AppContext appContext = new AppContext(appInfo.appId, SystemInstance.get(), classLoader, globalJndiContext, appJndiContext, appInfo.standaloneModule); + containerSystem.addAppContext(appContext); Context containerSystemContext = containerSystem.getJNDIContext(); Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiBuilder.java URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiBuilder.java?rev=1130358&r1=1130357&r2=1130358&view=diff ============================================================================== --- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiBuilder.java (original) +++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiBuilder.java Wed Jun 1 23:56:32 2011 @@ -21,6 +21,7 @@ import java.util.List; import org.apache.openejb.AppContext; import org.apache.openejb.BeanContext; import org.apache.openejb.assembler.classic.AppInfo; +import org.apache.openejb.assembler.classic.EjbJarInfo; import org.apache.openejb.core.ThreadContext; import org.apache.openejb.loader.SystemInstance; import org.apache.webbeans.config.WebBeansFinder; @@ -36,6 +37,8 @@ public class CdiBuilder { } public void build(AppInfo appInfo, AppContext appContext, List allDeployments) { + if (!hasBeans(appInfo)) return; + ThreadSingletonService singletonService = SystemInstance.get().getComponent(ThreadSingletonService.class); logger.info("existing thread singleton service in SystemInstance() " + singletonService); //TODO hack for tests. Currently initialized in OpenEJB line 90. cf alternative in AccessTimeoutTest which would @@ -46,6 +49,14 @@ public class CdiBuilder { singletonService.initialize(new StartupObject(appContext, appInfo, allDeployments)); } + private boolean hasBeans(AppInfo appInfo) { + for (EjbJarInfo ejbJar : appInfo.ejbJars) { + if (ejbJar.beans != null) return true; + } + + return false; + } + public static ThreadSingletonService initializeOWB(ClassLoader classLoader) { ThreadSingletonService singletonService = new ThreadSingletonServiceImpl(); logger.info("Created new singletonService " + singletonService); Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiEjbBean.java URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiEjbBean.java?rev=1130358&r1=1130357&r2=1130358&view=diff ============================================================================== --- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiEjbBean.java (original) +++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiEjbBean.java Wed Jun 1 23:56:32 2011 @@ -26,8 +26,10 @@ import javax.ejb.Remove; import javax.enterprise.context.spi.CreationalContext; import javax.enterprise.inject.spi.SessionBeanType; import java.lang.reflect.Method; +import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List; +import java.util.Set; public class CdiEjbBean extends BaseEjbBean { private final BeanContext beanContext; @@ -35,6 +37,23 @@ public class CdiEjbBean extends BaseE public CdiEjbBean(BeanContext beanContext, WebBeansContext webBeansContext) { super(beanContext.getBeanClass(), toSessionType(beanContext.getComponentType()), webBeansContext); this.beanContext = beanContext; + + + if (beanContext.isLocalbean()) addApiType(beanContext.getBeanClass()); + + addApiType(beanContext.getHomeInterface()); + addApiType(beanContext.getLocalHomeInterface()); + + for (Class clazz : beanContext.getBusinessLocalInterfaces()) addApiType(clazz); + for (Class clazz : beanContext.getBusinessRemoteInterfaces()) addApiType(clazz); + + } + + @Override + public void addApiType(Class apiType) { + if (apiType == null) return; + + super.addApiType(apiType); } public BeanContext getBeanContext() { Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiScanner.java URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiScanner.java?rev=1130358&r1=1130357&r2=1130358&view=diff ============================================================================== --- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiScanner.java (original) +++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/cdi/CdiScanner.java Wed Jun 1 23:56:32 2011 @@ -145,7 +145,7 @@ public class CdiScanner implements Scann try { return classLoader.loadClass(className); } catch (ClassNotFoundException e) { - throw new RuntimeException("Unable to load " + type + " class", e); + throw new RuntimeException("Unable to load class: "+className, e); } } Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/cdi/OWBContextThreadListener.java URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/cdi/OWBContextThreadListener.java?rev=1130358&r1=1130357&r2=1130358&view=diff ============================================================================== --- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/cdi/OWBContextThreadListener.java (original) +++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/cdi/OWBContextThreadListener.java Wed Jun 1 23:56:32 2011 @@ -45,7 +45,8 @@ public class OWBContextThreadListener im AppContext appContext = moduleContext.getAppContext(); WebBeansContext owbContext = appContext.get(WebBeansContext.class); if (owbContext == null) { - throw new IllegalStateException("WebBeansContext not initialized in appContext " + appContext); +// throw new IllegalStateException("WebBeansContext not initialized in appContext " + appContext); + return; } Object oldOWBContext = singletonService.contextEntered(owbContext); OWBContextHolder holder = new OWBContextHolder(oldOWBContext); Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/cdi/ThreadSingletonServiceImpl.java URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/cdi/ThreadSingletonServiceImpl.java?rev=1130358&r1=1130357&r2=1130358&view=diff ============================================================================== --- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/cdi/ThreadSingletonServiceImpl.java (original) +++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/cdi/ThreadSingletonServiceImpl.java Wed Jun 1 23:56:32 2011 @@ -20,6 +20,9 @@ package org.apache.openejb.cdi; +import org.apache.openejb.AppContext; +import org.apache.openejb.loader.SystemInstance; +import org.apache.openejb.spi.ContainerSystem; import org.apache.openejb.util.LogCategory; import org.apache.openejb.util.Logger; import org.apache.webbeans.config.OpenWebBeansConfiguration; @@ -27,6 +30,8 @@ import org.apache.webbeans.config.WebBea import org.apache.webbeans.spi.ContainerLifecycle; import org.apache.webbeans.spi.ResourceInjectionService; +import java.util.List; + /** * @version $Rev:$ $Date:$ */ @@ -100,8 +105,21 @@ public class ThreadSingletonServiceImpl } private WebBeansContext getContext() { + return get(); + } + + public static WebBeansContext get() + { WebBeansContext context = contexts.get(); if (context == null) { + // Fallback strategy is to just grab the first AppContext and assume it is the right one + // This kind of algorithm could be greatly improved + final ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class); + + final List appContexts = containerSystem.getAppContexts(); + + if (appContexts.size() > 0) return appContexts.get(0).getWebBeansContext(); + throw new IllegalStateException("On a thread without an initialized context"); } return context; Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java?rev=1130358&r1=1130357&r2=1130358&view=diff ============================================================================== --- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java (original) +++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java Wed Jun 1 23:56:32 2011 @@ -21,6 +21,7 @@ import static java.util.Arrays.asList; import static org.apache.openejb.util.Join.join; import java.lang.annotation.Annotation; +import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.lang.reflect.Modifier; @@ -84,6 +85,7 @@ import javax.ejb.TransactionAttribute; import javax.ejb.TransactionAttributeType; import javax.ejb.TransactionManagement; import javax.ejb.TransactionManagementType; +import javax.inject.Inject; import javax.interceptor.ExcludeClassInterceptors; import javax.interceptor.ExcludeDefaultInterceptors; import javax.interceptor.Interceptors; @@ -112,6 +114,7 @@ import org.apache.openejb.jee.AroundInvo import org.apache.openejb.jee.AroundTimeout; import org.apache.openejb.jee.AssemblyDescriptor; import org.apache.openejb.jee.AsyncMethod; +import org.apache.openejb.jee.Beans; import org.apache.openejb.jee.ConcurrencyManagementType; import org.apache.openejb.jee.ConcurrentLockType; import org.apache.openejb.jee.ConcurrentMethod; @@ -591,6 +594,15 @@ public class AnnotationDeployer implemen } } + { + final Beans beans = ejbModule.getBeans(); + + if (beans != null) { + beans.getManagedClasses().addAll(finder.getAnnotatedClassNames()); + } + } + + return ejbModule; } Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java?rev=1130358&r1=1130357&r2=1130358&view=diff ============================================================================== --- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java (original) +++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentLoader.java Wed Jun 1 23:56:32 2011 @@ -56,6 +56,7 @@ import java.io.IOException; import java.io.InputStream; import java.net.MalformedURLException; import java.net.URL; +import java.net.URLClassLoader; import java.net.URLDecoder; import java.util.ArrayList; import java.util.Arrays; @@ -1086,13 +1087,31 @@ public class DeploymentLoader implements private static Map getDescriptors(ResourceFinder finder, boolean log) throws OpenEJBException { try { - return altDDSources(finder.getResourcesMap(ddDir), log); + return altDDSources(mapDescriptors(finder), log); } catch (IOException e) { throw new OpenEJBException("Unable to determine descriptors in jar.", e); } } + private static Map mapDescriptors(ResourceFinder finder) + throws IOException + { + final Map map = finder.getResourcesMap(ddDir); + + if (map.size() == 0) { + + String[] known = {"web.xml", "ejb-jar.xml", "openejb-jar.xml", "env-entries.properties", "beans.xml", "ra.xml", "application.xml", "application-client.xml", "persistence.xml"}; + for (String descriptor : known) { + + final URL url = finder.getResource(ddDir + descriptor); + if (url != null) map.put(descriptor, url); + } + + } + return map; + } + /** * Modifies the map passed in with all the alt dd URLs found * @@ -1249,9 +1268,8 @@ public class DeploymentLoader implements pathToScanDescriptors=new URL(baseURLString.substring(0,baseURLString.lastIndexOf("WEB-INF/classes/"))); } - ResourceFinder finder = new ResourceFinder("", classLoader, pathToScanDescriptors); - Map descriptors = altDDSources(finder.getResourcesMap(ddDir), false); + Map descriptors = getDescriptors(classLoader, pathToScanDescriptors); String path = baseUrl.getPath(); if (path.endsWith("/")) path = path.substring(0, path.length() - 1); @@ -1273,7 +1291,7 @@ public class DeploymentLoader implements return WebModule.class; } - if (descriptors.containsKey("ejb-jar.xml")) { + if (descriptors.containsKey("ejb-jar.xml") || descriptors.containsKey("beans.xml")) { return EjbModule.class; } @@ -1298,6 +1316,14 @@ public class DeploymentLoader implements throw new UnknownModuleTypeException("Unknown module type: url=" + baseUrl.toExternalForm()); } + private Map getDescriptors(ClassLoader classLoader, URL pathToScanDescriptors) + throws IOException + { + ResourceFinder finder = new ResourceFinder("", classLoader, pathToScanDescriptors); + + return altDDSources(mapDescriptors(finder), false); + } + private Class checkAnnotations(URL urls, ClassLoader classLoader, final boolean scanPotentialEjbModules, final boolean scanPotentialClientModules) { Class cls = null; if (scanPotentialEjbModules || scanPotentialClientModules) { Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/NewLoaderLogic.java URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/NewLoaderLogic.java?rev=1130358&r1=1130357&r2=1130358&view=diff ============================================================================== --- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/NewLoaderLogic.java (original) +++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/NewLoaderLogic.java Wed Jun 1 23:56:32 2011 @@ -158,11 +158,15 @@ public class NewLoaderLogic { "axis2-", "bcprov-", "bsh-", + "bval-core", + "bval-jsr", "catalina-", "cglib-", + "commons-beanutils", "commons-cli-", "commons-codec-", "commons-collections-", + "commons-dbcp", "commons-dbcp-all-1.3-", "commons-discovery-", "commons-httpclient-", @@ -178,16 +182,18 @@ public class NewLoaderLogic { "derby-", "dom4j-", "geronimo-", + "gragent.jar", "guice-", + "hibernate-", "howl-", "hsqldb-", "htmlunit-", - "hibernate-", "icu4j-", "idb-", "idea_rt.jar", "jasypt-", "javaee-", + "javaee-api", "javassist-", "javaws.jar", "javax.", @@ -212,6 +218,10 @@ public class NewLoaderLogic { "myfaces-", "neethi-", "nekohtml-", + "openejb-api", + "openejb-javaagent", + "openejb-jee", + "openejb-loader", "openjpa-", "opensaml-", "openwebbeans-", @@ -231,6 +241,10 @@ public class NewLoaderLogic { "stax-api-", "swizzle-", "testng-", + "webbeans-ee", + "webbeans-ejb", + "webbeans-impl", + "webbeans-spi", "wsdl4j-", "wss4j-", "wstx-asl-", @@ -250,7 +264,8 @@ public class NewLoaderLogic { while (iterator.hasNext()) { URL url = iterator.next(); File file = URLs.toFile(url); - String name = file.getName(); + + String name = filter(file).getName(); // System.out.println("JAR "+name); if (filter.accept(name)) iterator.remove(); } @@ -260,6 +275,22 @@ public class NewLoaderLogic { return new UrlSet(urls); } + private static File filter(File location) { + List invalid = new ArrayList(); + invalid.add("classes"); + invalid.add("test-classes"); + invalid.add("target"); + invalid.add("build"); + invalid.add("dist"); + invalid.add("bin"); + + while (invalid.contains(location.getName())) { + location = location.getParentFile(); + } + return location; + } + + public static void _loadFromClasspath(FileUtils base, List jarList, ClassLoader classLoader) { PerformanceTimer timer = new PerformanceTimer(); Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java?rev=1130358&r1=1130357&r2=1130358&view=diff ============================================================================== --- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java (original) +++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ReadDescriptors.java Wed Jun 1 23:56:32 2011 @@ -293,8 +293,8 @@ public class ReadDescriptors implements Beans beans = readBeans(url); ejbModule.setBeans(beans); } else { - DeploymentLoader.logger.debug("No beans.xml found assuming annotated beans present: " + appModule.getJarLocation() + ", module: " + ejbModule.getModuleId()); - ejbModule.setBeans(new Beans()); +// DeploymentLoader.logger.debug("No beans.xml found assuming annotated beans present: " + appModule.getJarLocation() + ", module: " + ejbModule.getModuleId()); +// ejbModule.setBeans(new Beans()); } } Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/CoreContainerSystem.java URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/CoreContainerSystem.java?rev=1130358&r1=1130357&r2=1130358&view=diff ============================================================================== --- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/CoreContainerSystem.java (original) +++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/CoreContainerSystem.java Wed Jun 1 23:56:32 2011 @@ -16,10 +16,13 @@ */ package org.apache.openejb.core; +import org.apache.openejb.AppContext; import org.apache.openejb.BeanContext; import org.apache.openejb.Container; import org.apache.openejb.loader.SystemInstance; +import java.util.ArrayList; +import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; @@ -29,12 +32,12 @@ import javax.naming.Context; * @org.apache.xbean.XBean element="containerSystem" */ public class CoreContainerSystem implements org.apache.openejb.spi.ContainerSystem { - Map deployments = new ConcurrentHashMap(); - Map containers = new ConcurrentHashMap(); - Map webDeployments = new ConcurrentHashMap(); + private final Map apps = new ConcurrentHashMap(); + private final Map deployments = new ConcurrentHashMap(); + private final Map containers = new ConcurrentHashMap(); + private final Map webDeployments = new ConcurrentHashMap(); private final Context jndiContext; - /** * Constructs a CoreContainerSystem and initializes the root JNDI context. * It also creates three sub contexts, namely @@ -122,4 +125,14 @@ public class CoreContainerSystem impleme public Context getJNDIContext() { return jndiContext; } + + @Override + public List getAppContexts() { + return new ArrayList(apps.values()); + } + + @Override + public void addAppContext(AppContext appContext) { + apps.put(appContext.getId(), appContext); + } } Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/spi/ContainerSystem.java URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/spi/ContainerSystem.java?rev=1130358&r1=1130357&r2=1130358&view=diff ============================================================================== --- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/spi/ContainerSystem.java (original) +++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/spi/ContainerSystem.java Wed Jun 1 23:56:32 2011 @@ -16,11 +16,13 @@ */ package org.apache.openejb.spi; +import org.apache.openejb.AppContext; import org.apache.openejb.BeanContext; import org.apache.openejb.Container; import org.apache.openejb.core.WebContext; import javax.naming.Context; +import java.util.List; public interface ContainerSystem { @@ -35,4 +37,8 @@ public interface ContainerSystem { WebContext getWebContext(String id); Context getJNDIContext(); + + List getAppContexts(); + + void addAppContext(AppContext appContext); } \ No newline at end of file Added: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/cdi/InjectionTest.java URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/cdi/InjectionTest.java?rev=1130358&view=auto ============================================================================== --- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/cdi/InjectionTest.java (added) +++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/cdi/InjectionTest.java Wed Jun 1 23:56:32 2011 @@ -0,0 +1,103 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.openejb.cdi; + +import junit.framework.TestCase; +import org.apache.openejb.jee.Beans; +import org.apache.openejb.jee.SessionBean; +import org.apache.openejb.jee.SingletonBean; +import org.apache.openejb.junit.ApplicationComposer; +import org.apache.openejb.junit.Module; +import org.junit.Test; +import org.junit.runner.RunWith; + +import javax.ejb.EJB; +import javax.ejb.Singleton; +import javax.inject.Inject; + +/** + * @version $Rev$ $Date$ + */ +@RunWith(ApplicationComposer.class) +public class InjectionTest extends TestCase { + + @EJB + private Orange orange; + + @Test + public void test() throws Exception { + + assertNotNull(orange); + assertNotNull(orange.getBlue()); + + } + + @Module + public SessionBean getEjbs() { + return new SingletonBean(Orange.class); + } + + @Module + public Beans getBeans() { + final Beans beans = new Beans(); + beans.addManagedClass(Blue.class); + beans.addManagedClass(Green.class); + return beans; + } + + @Singleton + public static class Orange { + + private Blue blue; + + @Inject + public void setBlue(Blue blue) { + this.blue = blue; + } + + public Blue getBlue() { + return blue; + } + } + + public static class Blue { + + private Green green; + + public Blue() + { + "".length(); + } + + public Green getGreen() { + return green; + } + + @Inject + public void setGreen(Green green) { + this.green = green; + } + } + + public static class Green { + + public Green() + { + "".length(); + } + } +} Modified: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/stateful/StatefulTest.java URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/stateful/StatefulTest.java?rev=1130358&r1=1130357&r2=1130358&view=diff ============================================================================== --- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/stateful/StatefulTest.java (original) +++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/stateful/StatefulTest.java Wed Jun 1 23:56:32 2011 @@ -16,24 +16,19 @@ */ package org.apache.openejb.core.stateful; +import javax.ejb.LocalBean; +import javax.ejb.Stateful; +import javax.naming.InitialContext; + import junit.framework.TestCase; import org.apache.openejb.assembler.classic.Assembler; import org.apache.openejb.assembler.classic.SecurityServiceInfo; import org.apache.openejb.assembler.classic.TransactionServiceInfo; +import org.apache.openejb.client.LocalInitialContextFactory; import org.apache.openejb.config.ConfigurationFactory; -import org.apache.openejb.core.ivm.naming.InitContextFactory; import org.apache.openejb.jee.EjbJar; import org.apache.openejb.jee.StatefulBean; -import javax.ejb.Stateful; -import javax.ejb.SessionBean; -import javax.ejb.EJBException; -import javax.ejb.SessionContext; -import javax.ejb.LocalBean; -import javax.naming.InitialContext; -import javax.annotation.Resource; -import java.rmi.RemoteException; - /** * This test case serves as a nice tiny template for other test cases * and purposely doesn't do anything very complicated. @@ -45,7 +40,7 @@ public class StatefulTest extends TestCa @Override protected void setUp() throws Exception { - System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, InitContextFactory.class.getName()); + System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, LocalInitialContextFactory.class.getName()); ConfigurationFactory config = new ConfigurationFactory(); Assembler assembler = new Assembler(); @@ -69,29 +64,11 @@ public class StatefulTest extends TestCa @Stateful @LocalBean - public static class MyBean implements SessionBean { + public static class MyBean { public String echo(String string) { StringBuilder sb = new StringBuilder(string); return sb.reverse().toString(); } - - public void ejbActivate() throws EJBException, RemoteException { - } - - public void ejbPassivate() throws EJBException, RemoteException { - } - - public void ejbRemove() throws EJBException, RemoteException { - } - - @Resource - public void setStatefulContext(SessionContext statefulContext) { - System.out.println("StatefulTest$MyBean.setStatefulContext"); - } - - public void setSessionContext(SessionContext sessionContext) throws EJBException, RemoteException { - System.out.println("StatefulTest$MyBean.setSessionContext"); - } } } Copied: openejb/trunk/openejb3/tck/cdi-embedded/src/test/java/org/apache/openejb/tck/cdi/embedded/Archive.java (from r1124537, geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/archive/Archives.java) URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/tck/cdi-embedded/src/test/java/org/apache/openejb/tck/cdi/embedded/Archive.java?p2=openejb/trunk/openejb3/tck/cdi-embedded/src/test/java/org/apache/openejb/tck/cdi/embedded/Archive.java&p1=geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/archive/Archives.java&r1=1124537&r2=1130358&rev=1130358&view=diff ============================================================================== --- geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/archive/Archives.java (original) +++ openejb/trunk/openejb3/tck/cdi-embedded/src/test/java/org/apache/openejb/tck/cdi/embedded/Archive.java Wed Jun 1 23:56:32 2011 @@ -14,127 +14,119 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.xbean.finder.archive; +package org.apache.openejb.tck.cdi.embedded; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; import java.io.File; -import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.net.URL; -import java.util.HashMap; -import java.util.Map; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; import static junit.framework.Assert.assertNotNull; -import static junit.framework.Assert.assertTrue; /** -* @version $Rev$ $Date$ -*/ -public class Archives { + * @version $Rev$ $Date$ + */ +public class Archive +{ - public static File fileArchive(Class[] classes) throws IOException { - return fileArchive(new HashMap(), classes); - } + private final String name; - public static File fileArchive(Map entries, Class... classes) throws IOException { + private final InputStream in; - ClassLoader loader = Archives.class.getClassLoader(); - File classpath = File.createTempFile("path with spaces", "classes"); + public Archive(Iterable urls, Iterable> classes) + { - assertTrue(classpath.delete()); - assertTrue(classpath.mkdirs()); + try + { + ClassLoader loader = Archive.class.getClassLoader(); + // Create the ZIP file + final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); - for (Class clazz : classes) { - String name = clazz.getName().replace('.', File.separatorChar) + ".class"; - File file = new File(classpath, name); + final ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(byteArrayOutputStream)); - File d = file.getParentFile(); + this.name = name(classes); - if (!d.exists()) assertTrue(d.getAbsolutePath(), d.mkdirs()); + for (Class clazz : classes) + { - URL resource = loader.getResource(name); - assertNotNull(resource); + String name = clazz.getName().replace('.', File.separatorChar) + ".class"; - InputStream in = new BufferedInputStream(resource.openStream()); - BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(file)); + URL resource = loader.getResource(name); + assertNotNull(resource); - int i = -1; - while ((i = in.read()) != -1) { - out.write(i); - } + // Add ZIP entry to output stream. + out.putNextEntry(new ZipEntry(name)); - out.close(); - in.close(); - } + InputStream in = new BufferedInputStream(resource.openStream()); + + int i = -1; + while ((i = in.read()) != -1) + { + out.write(i); + } - for (Map.Entry entry : entries.entrySet()) { + // Complete the entry + out.closeEntry(); + } - final String key = entry.getKey().replace('/', File.separatorChar); + for (final URL url : urls) + { - final File file = new File(classpath, key); + final String name = "META-INF/" + new File(url.getFile()).getName(); - File d = file.getParentFile(); + out.putNextEntry(new ZipEntry(name)); - if (!d.exists()) assertTrue(d.getAbsolutePath(), d.mkdirs()); + final InputStream in = new BufferedInputStream(url.openStream()); - BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(file)); + int i = -1; + while ((i = in.read()) != -1) + { + out.write(i); + } - out.write(entry.getValue().getBytes()); + in.close(); + } + // Complete the ZIP file out.close(); - } - return classpath; + this.in = new ByteArrayInputStream(byteArrayOutputStream.toByteArray()); + } + catch (IOException e) + { + throw new RuntimeException(e); + } } - public static File jarArchive(Class[] classes) throws IOException { - return jarArchive(new HashMap(), classes); + public String getName() + { + return name; } - public static File jarArchive(Map entries, Class... classes) throws IOException { - - ClassLoader loader = Archives.class.getClassLoader(); - - File classpath = File.createTempFile("path with spaces", ".jar"); - - // Create the ZIP file - ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(classpath))); - - for (Class clazz : classes) { - String name = clazz.getName().replace('.', File.separatorChar) + ".class"; - - URL resource = loader.getResource(name); - assertNotNull(resource); - - // Add ZIP entry to output stream. - out.putNextEntry(new ZipEntry(name)); - - InputStream in = new BufferedInputStream(resource.openStream()); + public InputStream getIn() + { + return in; + } - int i = -1; - while ((i = in.read()) != -1) { - out.write(i); + private String name(Iterable> classes) + { + for (Class clazz : classes) + { + if (clazz.getName().endsWith("AbstractJSR299Test")) continue; + if (clazz.getName().endsWith("Test")) + { + return clazz.getName()+".jar"; } - - // Complete the entry - out.closeEntry(); - } - - for (Map.Entry entry : entries.entrySet()) { - - out.putNextEntry(new ZipEntry(entry.getKey())); - - out.write(entry.getValue().getBytes()); } - // Complete the ZIP file - out.close(); - return classpath; + return "test-archive.jar"; } } Propchange: openejb/trunk/openejb3/tck/cdi-embedded/src/test/java/org/apache/openejb/tck/cdi/embedded/Archive.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: openejb/trunk/openejb3/tck/cdi-embedded/src/test/java/org/apache/openejb/tck/cdi/embedded/BeansImpl.java URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/tck/cdi-embedded/src/test/java/org/apache/openejb/tck/cdi/embedded/BeansImpl.java?rev=1130358&r1=1130357&r2=1130358&view=diff ============================================================================== --- openejb/trunk/openejb3/tck/cdi-embedded/src/test/java/org/apache/openejb/tck/cdi/embedded/BeansImpl.java (original) +++ openejb/trunk/openejb3/tck/cdi-embedded/src/test/java/org/apache/openejb/tck/cdi/embedded/BeansImpl.java Wed Jun 1 23:56:32 2011 @@ -16,7 +16,11 @@ */ package org.apache.openejb.tck.cdi.embedded; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; /** * @version $Rev$ $Date$ @@ -24,16 +28,23 @@ import java.io.IOException; public class BeansImpl implements org.jboss.jsr299.tck.spi.Beans { public boolean isProxy(Object instance) { + System.out.println("isProxy: " + instance); return instance.getClass().getName().contains("$$"); } @Override public byte[] serialize(Object instance) throws IOException { - return new byte[0]; + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + ObjectOutputStream os = new ObjectOutputStream(baos); + os.writeObject(instance); + os.flush(); + return baos.toByteArray(); } @Override public Object deserialize(byte[] bytes) throws IOException, ClassNotFoundException { - return null; + ByteArrayInputStream bais = new ByteArrayInputStream(bytes); + ObjectInputStream is = new ObjectInputStream(bais); + return is.readObject(); } } Added: openejb/trunk/openejb3/tck/cdi-embedded/src/test/java/org/apache/openejb/tck/cdi/embedded/ContainersImpl.java URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/tck/cdi-embedded/src/test/java/org/apache/openejb/tck/cdi/embedded/ContainersImpl.java?rev=1130358&view=auto ============================================================================== --- openejb/trunk/openejb3/tck/cdi-embedded/src/test/java/org/apache/openejb/tck/cdi/embedded/ContainersImpl.java (added) +++ openejb/trunk/openejb3/tck/cdi-embedded/src/test/java/org/apache/openejb/tck/cdi/embedded/ContainersImpl.java Wed Jun 1 23:56:32 2011 @@ -0,0 +1,138 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.openejb.tck.cdi.embedded; + +import org.apache.openejb.OpenEJB; +import org.apache.openejb.assembler.classic.Assembler; +import org.apache.openejb.cdi.ThreadSingletonService; +import org.apache.openejb.cdi.ThreadSingletonServiceImpl; +import org.apache.openejb.loader.SystemInstance; +import org.apache.openejb.util.SetAccessible; +import org.apache.webbeans.config.WebBeansContext; +import org.apache.webbeans.container.BeanManagerImpl; +import org.jboss.testharness.api.DeploymentException; +import org.jboss.testharness.spi.Containers; + +import javax.ejb.embeddable.EJBContainer; +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.lang.reflect.AccessibleObject; +import java.lang.reflect.Field; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; + +/** + * @version $Rev$ $Date$ + */ +public class ContainersImpl implements Containers { + + private static String stuck; + + private Exception exception; + private EJBContainer container; + + @Override + public boolean deploy(InputStream archive, String name) { + if (!OpenEJB.isInitialized()) stuck = name; + else System.out.println("STUCK " + stuck); + + exception = null; + + final Assembler assembler = SystemInstance.get().getComponent(Assembler.class); + + ThreadSingletonServiceImpl.exit(null); + if (assembler != null) { + assembler.destroy(); + } + try { + final Map map = new HashMap(); + map.put(EJBContainer.MODULES, writeToFile(archive, name)); + map.put(EJBContainer.APP_NAME, name); + + container = EJBContainer.createEJBContainer(map); + + final WebBeansContext webBeansContext = ThreadSingletonServiceImpl.get(); + dump(webBeansContext.getBeanManagerImpl()); + + } catch (Exception e) { + exception = e; + return false; + } + + return true; + } + + private void dump(Object o) + { + try + { + final Class clazz = o.getClass(); + + for (Field field : clazz.getDeclaredFields()) + { + SetAccessible.on(field); + + if (Collection.class.isAssignableFrom(field.getType())) { + final Collection collection = (Collection) field.get(o); + System.out.println(field.getName() + "\t= " + collection.size()); + } + } + } + catch (Exception e) + { + + } + } + + private File writeToFile(InputStream archive, String name) throws IOException { + final File file = File.createTempFile("deploy", "-" + name); + file.deleteOnExit(); + + final BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(file)); + + try { + int i = -1; + while ((i = archive.read()) != -1) out.write(i); + } finally { + out.close(); + } + + return file; + } + + @Override + public DeploymentException getDeploymentException() { + return new DeploymentException(exception.getLocalizedMessage(), exception); + } + + @Override + public void undeploy(String name) { + if (container != null) container.close(); + } + + @Override + public void setup() throws IOException { + } + + @Override + public void cleanup() throws IOException { + } +} Added: openejb/trunk/openejb3/tck/cdi-embedded/src/test/java/org/apache/openejb/tck/cdi/embedded/Report.java URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/tck/cdi-embedded/src/test/java/org/apache/openejb/tck/cdi/embedded/Report.java?rev=1130358&view=auto ============================================================================== --- openejb/trunk/openejb3/tck/cdi-embedded/src/test/java/org/apache/openejb/tck/cdi/embedded/Report.java (added) +++ openejb/trunk/openejb3/tck/cdi-embedded/src/test/java/org/apache/openejb/tck/cdi/embedded/Report.java Wed Jun 1 23:56:32 2011 @@ -0,0 +1,97 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.openejb.tck.cdi.embedded; + +import org.xml.sax.Attributes; +import org.xml.sax.SAXException; +import org.xml.sax.helpers.DefaultHandler; + +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; +import java.io.File; +import java.util.Collections; +import java.util.LinkedList; + +/** + * @version $Rev$ $Date$ + */ +public class Report { + + public static void main(String[] args) throws Exception { + new Report().main(); + } + + private final LinkedList classes = new LinkedList(); + + private void main() throws Exception { + final File file = new File("/Users/dblevins/work/uber/openejb/tck/cdi-embedded/target/surefire-reports/testng-results.xml"); + + final SAXParser parser = SAXParserFactory.newInstance().newSAXParser(); + + parser.parse(file, new DefaultHandler() { + @Override + public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { + final String name = qName; + if ("class".equals(name)) { + classes.add(new TestClass(attributes.getValue("name"))); + } + + if ("test-method".equals(name)) { + classes.getLast().addStatus(attributes.getValue("status")); + } + } + }); + + Collections.sort(classes); + + int i = 0; + for (TestClass testClass : classes) { + if (!testClass.hasFailures()) continue; + System.out.printf("\n", testClass.name); + i++; + } + + System.out.println(i); + } + + public static class TestClass implements Comparable{ + + private final String name; + private int failed; + private int passed; + private int error; + + public TestClass(String name) { + this.name = name; + } + + public void addStatus(String status) { + if ("PASS".equals(status)) passed++; + if ("FAIL".equals(status)) failed++; + if ("ERROR".equals(status)) error++; + } + + public boolean hasFailures() { + return failed > 0 || error > 0; + } + + @Override + public int compareTo(TestClass o) { + return this.name.compareTo(o.name); + } + } +} Modified: openejb/trunk/openejb3/tck/cdi-embedded/src/test/java/org/apache/openejb/tck/cdi/embedded/StandaloneContainersImpl.java URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/tck/cdi-embedded/src/test/java/org/apache/openejb/tck/cdi/embedded/StandaloneContainersImpl.java?rev=1130358&r1=1130357&r2=1130358&view=diff ============================================================================== --- openejb/trunk/openejb3/tck/cdi-embedded/src/test/java/org/apache/openejb/tck/cdi/embedded/StandaloneContainersImpl.java (original) +++ openejb/trunk/openejb3/tck/cdi-embedded/src/test/java/org/apache/openejb/tck/cdi/embedded/StandaloneContainersImpl.java Wed Jun 1 23:56:32 2011 @@ -16,128 +16,54 @@ */ package org.apache.openejb.tck.cdi.embedded; -import org.apache.openejb.AppContext; -import org.apache.openejb.assembler.classic.AppInfo; -import org.apache.openejb.assembler.classic.Assembler; -import org.apache.openejb.assembler.classic.EjbJarInfo; -import org.apache.openejb.assembler.classic.SecurityServiceInfo; -import org.apache.openejb.assembler.classic.TransactionServiceInfo; -import org.apache.openejb.cdi.ThreadSingletonServiceImpl; -import org.apache.openejb.config.AppModule; -import org.apache.openejb.config.ConfigurationFactory; -import org.apache.openejb.config.EjbModule; -import org.apache.openejb.jee.EjbJar; -import org.apache.openejb.util.LogCategory; -import org.apache.openejb.util.Logger; -import org.apache.webbeans.container.BeanManagerImpl; -import org.apache.xbean.finder.AnnotationFinder; -import org.apache.xbean.finder.ClassFinder; -import org.apache.xbean.finder.archive.ClassesArchive; -import org.jboss.testharness.api.DeploymentException; - -import javax.enterprise.inject.spi.BeanManager; -import java.io.File; import java.net.URL; -import java.util.ArrayList; import java.util.Collection; import java.util.Collections; -import java.util.List; -import java.util.Map; + +import org.jboss.testharness.api.DeploymentException; /** * @version $Rev$ $Date$ */ -public class StandaloneContainersImpl implements org.jboss.testharness.spi.StandaloneContainers { - - private static final Logger logger = Logger.getInstance(LogCategory.OPENEJB.createChild("tck"), StandaloneContainersImpl.class); - - private AppContext appContext; +public class StandaloneContainersImpl + implements org.jboss.testharness.spi.StandaloneContainers +{ - private DeploymentException deploymentException; + private final ContainersImpl containers = new ContainersImpl(); - public void deploy(Collection> classes) throws DeploymentException { - deploy(classes, Collections.emptyList()); + @Override + public void deploy(Collection> classes) + throws DeploymentException + { + deploy(classes, Collections.EMPTY_LIST); } - public boolean deploy(Collection> classes, Collection urls) { - logger.debug("StandaloneContainersImpl.deploy"); - - List classNames = new ArrayList(); - - for (Class clazz : classes) classNames.add(clazz.getName()); - - if (logger.isDebugEnabled()) { - Collections.sort(classNames); - - for (String clazz : classNames) { - logger.debug("clazz = " + clazz); - } - - for (URL url : urls) { - logger.debug("url = " + url); - } - } - - try { - EjbModule ejbModule = new EjbModule(new EjbJar("beans")); - ejbModule.setFinder(new AnnotationFinder(new ClassesArchive(classes))); - - Map dds = ejbModule.getAltDDs(); - - for (URL url : urls) { - final File file = new File(url.getFile()); - dds.put(file.getName(), url); - } - - Assembler assembler = new Assembler(); - ConfigurationFactory config = new ConfigurationFactory(); - assembler.createSecurityService(config.configureService(SecurityServiceInfo.class)); - assembler.createTransactionManager(config.configureService(TransactionServiceInfo.class)); - - final AppInfo appInfo = config.configureApplication(new AppModule(ejbModule)); - - for (EjbJarInfo ejbJar : appInfo.ejbJars) { - // TODO We need to improve our scanning so this isn't necessary - ejbJar.beans.managedClasses.addAll(classNames); - } - - appContext = assembler.createApplication(appInfo); - - // This must be set or the OWB static lookup code won't work and everything will fall apart - Thread.currentThread().setContextClassLoader(appContext.getClassLoader()); - } catch (Exception e) { - logger.debug("Deploy failed", e); - deploymentException = new DeploymentException("Deploy failed", e); - return false; - } - // logger.debug("StandaloneContainersImpl.deploy(classes, urls)"); - // for (Class clazz : classes) { - // logger.debug("clazz = " + clazz); - // } - // for (URL url : urls) { - // logger.debug("url = " + url); - // } - - - ThreadSingletonServiceImpl.enter(appContext.getWebBeansContext()); - - return true; + @Override + public boolean deploy(Collection> classes, Collection beansXmls) + { + final Archive archive = new Archive(beansXmls, classes); + return containers.deploy(archive.getIn(), archive.getName()); } - public DeploymentException getDeploymentException() { - logger.debug("StandaloneContainersImpl.getDeploymentException"); - return deploymentException; + @Override + public DeploymentException getDeploymentException() + { + return containers.getDeploymentException(); } - public void undeploy() { - logger.debug("StandaloneContainersImpl.undeploy"); + @Override + public void undeploy() + { + containers.undeploy(null); } - public void setup() { - logger.debug("StandaloneContainersImpl.setup"); + @Override + public void setup() + { } - public void cleanup() { - logger.debug("StandaloneContainersImpl.cleanup"); + @Override + public void cleanup() + { } } Modified: openejb/trunk/openejb3/tck/cdi-embedded/src/test/resources/META-INF/jboss-test-harness.properties URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/tck/cdi-embedded/src/test/resources/META-INF/jboss-test-harness.properties?rev=1130358&r1=1130357&r2=1130358&view=diff ============================================================================== --- openejb/trunk/openejb3/tck/cdi-embedded/src/test/resources/META-INF/jboss-test-harness.properties (original) +++ openejb/trunk/openejb3/tck/cdi-embedded/src/test/resources/META-INF/jboss-test-harness.properties Wed Jun 1 23:56:32 2011 @@ -20,6 +20,8 @@ org.jboss.jsr299.tck.spi.Beans=org.apach org.jboss.jsr299.tck.spi.Contexts=org.apache.openejb.tck.cdi.embedded.ContextsImpl org.jboss.jsr299.tck.spi.EL=org.apache.openejb.tck.cdi.embedded.ELImpl org.jboss.testharness.spi.StandaloneContainers=org.apache.openejb.tck.cdi.embedded.StandaloneContainersImpl +org.jboss.testharness.spi.Containers=org.apache.openejb.tck.cdi.embedded.ContainersImpl - -org.jboss.testharness.api.TestLauncher=org.jboss.testharness.impl.runner.local.LocalTestLauncher \ No newline at end of file +org.jboss.testharness.standalone=true +org.jboss.testharness.api.TestLauncher=org.jboss.testharness.impl.runner.local.LocalTestLauncher +org.jboss.testharness.runIntegrationTests=true \ No newline at end of file Modified: openejb/trunk/openejb3/tck/cdi-embedded/src/test/resources/failing.xml URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/tck/cdi-embedded/src/test/resources/failing.xml?rev=1130358&r1=1130357&r2=1130358&view=diff ============================================================================== --- openejb/trunk/openejb3/tck/cdi-embedded/src/test/resources/failing.xml (original) +++ openejb/trunk/openejb3/tck/cdi-embedded/src/test/resources/failing.xml Wed Jun 1 23:56:32 2011 @@ -1,8 +1,5 @@ - - @@ -11,46 +8,18 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -58,25 +27,19 @@ - - - - - - - + Modified: openejb/trunk/openejb3/tck/cdi-embedded/src/test/resources/passing.xml URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/tck/cdi-embedded/src/test/resources/passing.xml?rev=1130358&r1=1130357&r2=1130358&view=diff ============================================================================== --- openejb/trunk/openejb3/tck/cdi-embedded/src/test/resources/passing.xml (original) +++ openejb/trunk/openejb3/tck/cdi-embedded/src/test/resources/passing.xml Wed Jun 1 23:56:32 2011 @@ -5,6 +5,11 @@ + + + + + @@ -42,6 +47,7 @@ + @@ -66,15 +72,18 @@ + + + @@ -88,6 +97,7 @@ + @@ -107,6 +117,7 @@ + @@ -124,6 +135,7 @@ + @@ -137,6 +149,7 @@ + @@ -164,6 +177,7 @@ + @@ -172,11 +186,13 @@ + + @@ -186,15 +202,13 @@ - - - +