openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject svn commit: r1153495 - in /openwebbeans/trunk: ./ webbeans-impl/src/main/java/org/apache/webbeans/config/ webbeans-impl/src/main/java/org/apache/webbeans/plugins/ webbeans-impl/src/main/java/org/apache/webbeans/portable/events/ webbeans-impl/src/main/j...
Date Wed, 03 Aug 2011 14:06:25 GMT
Author: gpetracek
Date: Wed Aug  3 14:06:23 2011
New Revision: 1153495

URL: http://svn.apache.org/viewvc?rev=1153495&view=rev
Log:
OWB-582 custom service-loader which allows java 1.5 support

Added:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/service/
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/service/DefaultImplementationLoaderService.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/service/ManualImplementationLoaderService.java
    openwebbeans/trunk/webbeans-spi/src/main/java/org/apache/webbeans/spi/ImplementationLoaderService.java
Modified:
    openwebbeans/trunk/pom.xml
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContext.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/plugins/PluginLoader.java
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/ExtensionLoader.java
    openwebbeans/trunk/webbeans-impl/src/main/resources/META-INF/openwebbeans/openwebbeans.properties
    openwebbeans/trunk/webbeans-jee5-ejb-resource/src/main/java/org/apache/webbeans/resource/spi/ee/ExtendedStandaloneResourceInjectionService.java
    openwebbeans/trunk/webbeans-test/cditest/src/main/java/org/apache/webbeans/cditest/CdiTestContainerLoader.java

Modified: openwebbeans/trunk/pom.xml
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/pom.xml?rev=1153495&r1=1153494&r2=1153495&view=diff
==============================================================================
--- openwebbeans/trunk/pom.xml (original)
+++ openwebbeans/trunk/pom.xml Wed Aug  3 14:06:23 2011
@@ -314,8 +314,8 @@
                 <artifactId>maven-compiler-plugin</artifactId>
                 <version>2.3.2</version>
                 <configuration>
-                    <source>1.6</source>
-                    <target>1.6</target>
+                    <source>1.5</source>
+                    <target>1.5</target>
                 </configuration>
             </plugin>
             <plugin>

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContext.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContext.java?rev=1153495&r1=1153494&r2=1153495&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContext.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/config/WebBeansContext.java
Wed Aug  3 14:06:23 2011
@@ -47,6 +47,7 @@ import org.apache.webbeans.portable.Anno
 import org.apache.webbeans.portable.events.ExtensionLoader;
 import org.apache.webbeans.proxy.JavassistProxyFactory;
 import org.apache.webbeans.spi.ContextsService;
+import org.apache.webbeans.spi.ImplementationLoaderService;
 import org.apache.webbeans.spi.ScannerService;
 import org.apache.webbeans.spi.SecurityService;
 import org.apache.webbeans.spi.plugins.OpenWebBeansPlugin;
@@ -89,6 +90,7 @@ public class WebBeansContext
     private final WebBeansAnnotatedTypeUtil annotatedTypeUtil = new WebBeansAnnotatedTypeUtil(this);
     private final ManagedBeanConfigurator managedBeanConfigurator = new ManagedBeanConfigurator(this);
     private final SecurityService securityService;
+    private final ImplementationLoaderService implementationLoaderService;
 
     public WebBeansContext()
     {
@@ -103,6 +105,13 @@ public class WebBeansContext
     private WebBeansContext(Map<Class<?>, Object> initialServices, OpenWebBeansConfiguration
openWebBeansConfiguration)
     {
         this.openWebBeansConfiguration = openWebBeansConfiguration;
+
+        //pluggable service-loader
+        String implementationLoaderServiceName =
+                openWebBeansConfiguration.getProperty(ImplementationLoaderService.class.getName());
+        implementationLoaderService = ImplementationLoaderService.class.cast(get(implementationLoaderServiceName));
+        registerService(ImplementationLoaderService.class, implementationLoaderService);
+
         if (initialServices != null)
         {
             for (Map.Entry<Class<?>, Object> entry: initialServices.entrySet())
@@ -416,4 +425,9 @@ public class WebBeansContext
     {
         managerMap.clear();
     }
+
+    public ImplementationLoaderService getImplementationLoaderService()
+    {
+        return this.implementationLoaderService;
+    }
 }

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/plugins/PluginLoader.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/plugins/PluginLoader.java?rev=1153495&r1=1153494&r2=1153495&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/plugins/PluginLoader.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/plugins/PluginLoader.java
Wed Aug  3 14:06:23 2011
@@ -20,9 +20,7 @@ package org.apache.webbeans.plugins;
 
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.Iterator;
 import java.util.List;
-import java.util.ServiceLoader;
 import java.util.concurrent.atomic.AtomicBoolean;
 
 import org.apache.webbeans.config.OWBLogConst;
@@ -83,24 +81,22 @@ public class PluginLoader
             logger.debug("PluginLoader startUp called.");
             ArrayList<OpenWebBeansPlugin> ps = new ArrayList<OpenWebBeansPlugin>();
 
-            ServiceLoader<OpenWebBeansPlugin> owbPluginsLoader = ServiceLoader.load(OpenWebBeansPlugin.class);
-            Iterator<OpenWebBeansPlugin> pluginIter = owbPluginsLoader.iterator();
-            while(pluginIter.hasNext()) 
+            List<OpenWebBeansPlugin> pluginList = WebBeansContext.getInstance().getImplementationLoaderService().load(OpenWebBeansPlugin.class);
+            for (OpenWebBeansPlugin plugin : pluginList)
             {
-              OpenWebBeansPlugin plugin = pluginIter.next();
-              if (logger.wblWillLogInfo())
-              {
-                  logger.info(OWBLogConst.INFO_0004, plugin.getClass().getSimpleName());
-              }
-              try
-            {
-                plugin.startUp();
-            }
-            catch (Exception e)
-            {
-                throwsException(e);
-            }
-              ps.add(plugin);
+                if (logger.wblWillLogInfo())
+                {
+                    logger.info(OWBLogConst.INFO_0004, plugin.getClass().getSimpleName());
+                }
+                try
+                {
+                    plugin.startUp();
+                }
+                catch (Exception e)
+                {
+                    throwsException(e);
+                }
+                ps.add(plugin);
             }   
             
             // just to make sure the plugins aren't modified afterwards

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/ExtensionLoader.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/ExtensionLoader.java?rev=1153495&r1=1153494&r2=1153495&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/ExtensionLoader.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/events/ExtensionLoader.java
Wed Aug  3 14:06:23 2011
@@ -19,9 +19,8 @@
 package org.apache.webbeans.portable.events;
 
 import java.util.HashSet;
-import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
-import java.util.ServiceLoader;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 
@@ -86,21 +85,19 @@ public class ExtensionLoader
      */
     public void loadExtensionServices(ClassLoader classLoader)
     {
-        ServiceLoader<Extension> loader = ServiceLoader.load(Extension.class, classLoader);
-        Iterator<Extension> iterator = loader.iterator();
-        while(iterator.hasNext())
+        List<Extension> loader = this.webBeansContext.getImplementationLoaderService().load(Extension.class);
+        for (Extension extension : loader)
         {
-            Extension ext = iterator.next();
-            if (!extensionClasses.contains(ext.getClass()))
+            if (!extensionClasses.contains(extension.getClass()))
             {
-                extensionClasses.add(ext.getClass());
+                extensionClasses.add(extension.getClass());
                 try
                 {
-                    addExtension(ext);
+                    addExtension(extension);
                 }
                 catch (Exception e)
                 {
-                    throw new WebBeansException("Error occurred while reading Extension service
list",e);
+                    throw new WebBeansException("Error occurred while reading Extension service
list", e);
                 }
             }
         }        

Added: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/service/DefaultImplementationLoaderService.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/service/DefaultImplementationLoaderService.java?rev=1153495&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/service/DefaultImplementationLoaderService.java
(added)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/service/DefaultImplementationLoaderService.java
Wed Aug  3 14:06:23 2011
@@ -0,0 +1,71 @@
+/*
+ * 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.webbeans.service;
+
+import org.apache.webbeans.logger.WebBeansLogger;
+import org.apache.webbeans.spi.ImplementationLoaderService;
+import org.apache.webbeans.util.WebBeansUtil;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.ServiceLoader;
+
+/**
+ * Default implementation which delegates to the s{@link ServiceLoader} of Java 1.6 and
+ * uses a fallback for Java 1.5
+ */
+public class DefaultImplementationLoaderService implements ImplementationLoaderService
+{
+    private static final WebBeansLogger logger = WebBeansLogger.getLogger(DefaultImplementationLoaderService.class);
+
+    private static final boolean JAVA_6_AVAILABLE = isJava6();
+
+    public <T> List<T> load(Class<T> serviceType)
+    {
+        if(JAVA_6_AVAILABLE)
+        {
+            List<T> result = new ArrayList<T>();
+            ServiceLoader<T> services = ServiceLoader.load(serviceType, WebBeansUtil.getCurrentClassLoader());
+
+            for (T service : services)
+            {
+                result.add(service);
+            }
+
+            return result;
+        }
+
+        return new ManualImplementationLoaderService<T>
+                (serviceType, WebBeansUtil.getCurrentClassLoader()).loadServiceImplementations();
+    }
+
+    private static boolean isJava6()
+    {
+        try
+        {
+            ServiceLoader.class.getName();
+            return true;
+        }
+        catch (NoClassDefFoundError error)
+        {
+            logger.info("Using Java 5 compatibility mode, because didn't find ServiceLoader:
" + error);
+            return false;
+        }
+    }
+}

Added: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/service/ManualImplementationLoaderService.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/service/ManualImplementationLoaderService.java?rev=1153495&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/service/ManualImplementationLoaderService.java
(added)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/service/ManualImplementationLoaderService.java
Wed Aug  3 14:06:23 2011
@@ -0,0 +1,228 @@
+/*
+ * 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.webbeans.service;
+
+import org.apache.webbeans.util.ClassUtil;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.lang.reflect.Constructor;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.List;
+
+/**
+ * Manual service loader as fallback for Java 1.5
+ */
+class ManualImplementationLoaderService<T>
+{
+    private static final String SERVICE_CONFIG = "META-INF/services/";
+    private static final String FILE_ENCODING = "UTF-8";
+
+    protected List<Class<?>> foundServiceClasses = new ArrayList<Class<?>>();
+    private Class<T> serviceType;
+    private ClassLoader currentClassLoader;
+
+    ManualImplementationLoaderService(Class<T> serviceType, ClassLoader currentClassLoader)
+    {
+        this.serviceType = serviceType;
+        this.currentClassLoader = currentClassLoader;
+    }
+
+    List<T> loadServiceImplementations()
+    {
+        List<Class<?>> result = resolveServiceImplementations();
+
+        if (result == null)
+        {
+            return Collections.emptyList();
+        }
+
+        List<T> foundServices = new ArrayList<T>();
+
+        for (Class<?> serviceClass : result)
+        {
+            foundServices.add(createInstance(serviceClass));
+        }
+
+        return foundServices;
+    }
+
+    private List<Class<?>> resolveServiceImplementations()
+    {
+        for (URL configFile : getConfigFileList())
+        {
+            loadConfiguredServices(configFile);
+        }
+
+        return this.foundServiceClasses;
+    }
+
+    private List<URL> getConfigFileList()
+    {
+        List<URL> serviceFiles = new ArrayList<URL>();
+
+        try
+        {
+            Enumeration<URL> serviceFileEnumerator = this.currentClassLoader.getResources(getConfigFileLocation());
+
+            while (serviceFileEnumerator.hasMoreElements())
+            {
+                serviceFiles.add(serviceFileEnumerator.nextElement());
+            }
+        }
+        catch (Exception e)
+        {
+            throw new IllegalStateException(
+                    "Failed to load " + this.serviceType.getName() + " configured in " +
getConfigFileLocation(), e);
+        }
+        return serviceFiles;
+    }
+
+    private String getConfigFileLocation()
+    {
+        return SERVICE_CONFIG + this.serviceType.getName();
+    }
+
+    private void loadConfiguredServices(URL serviceFile)
+    {
+        InputStream inputStream = null;
+
+        try
+        {
+            String serviceClassName;
+            inputStream = serviceFile.openStream();
+            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream,
FILE_ENCODING));
+
+            while ((serviceClassName = bufferedReader.readLine()) != null)
+            {
+                serviceClassName = extractConfiguredServiceClassName(serviceClassName);
+                if (!"".equals(serviceClassName))
+                {
+                    loadService(serviceClassName);
+                }
+            }
+        }
+        catch (Exception e)
+        {
+            throw new IllegalStateException("Failed to process service-config: " + serviceFile,
e);
+        }
+        finally
+        {
+            if (inputStream != null)
+            {
+                try
+                {
+                    inputStream.close();
+                }
+                catch (Exception e)
+                {
+                    throw new IllegalStateException("Failed to close " + serviceFile, e);
+                }
+            }
+        }
+    }
+
+    private String extractConfiguredServiceClassName(String currentConfigLine)
+    {
+        int startOfComment = currentConfigLine.indexOf('#');
+
+        if (startOfComment > -1)
+        {
+            currentConfigLine = currentConfigLine.substring(0, startOfComment);
+        }
+        return currentConfigLine.trim();
+    }
+
+    private void loadService(String serviceClassName)
+    {
+        Class<T> serviceClass = (Class<T>) loadClass(serviceClassName);
+
+        if (serviceClass != null && !this.foundServiceClasses.contains(serviceClass))
+        {
+            this.foundServiceClasses.add(serviceClass);
+        }
+        else if (serviceClass == null)
+        {
+            throw new IllegalStateException(serviceClassName + " couldn't be loaded. " +
+                    "Please ensure that this class is in the classpath or remove the entry
from "
+                    + getConfigFileLocation() + ".");
+        }
+    }
+
+    private Class<? extends T> loadClass(String serviceClassName)
+    {
+        Class<?> targetClass = ClassUtil.getClassFromName(serviceClassName);
+
+        if (targetClass == null)
+        {
+            targetClass = loadClassForName(serviceClassName, this.currentClassLoader);
+
+            if (targetClass == null)
+            {
+                return null;
+            }
+        }
+
+        return targetClass.asSubclass(this.serviceType);
+    }
+
+    private static Class<?> loadClassForName(String serviceClassName, ClassLoader classLoader)
+    {
+        if (classLoader == null)
+        {
+            return null;
+        }
+
+        try
+        {
+            return classLoader.loadClass(serviceClassName);
+        }
+        catch (Exception e)
+        {
+            return loadClassForName(serviceClassName, classLoader.getParent());
+        }
+    }
+
+    private T createInstance(Class<?> serviceClass)
+    {
+        try
+        {
+            Constructor<?> constructor = serviceClass.getDeclaredConstructor();
+            constructor.setAccessible(true);
+            return (T) constructor.newInstance();
+        }
+        catch (Exception e)
+        {
+            return null;
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public String toString()
+    {
+        return "Config file: " + getConfigFileLocation();
+    }
+}

Modified: openwebbeans/trunk/webbeans-impl/src/main/resources/META-INF/openwebbeans/openwebbeans.properties
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/resources/META-INF/openwebbeans/openwebbeans.properties?rev=1153495&r1=1153494&r2=1153495&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/resources/META-INF/openwebbeans/openwebbeans.properties
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/resources/META-INF/openwebbeans/openwebbeans.properties
Wed Aug  3 14:06:23 2011
@@ -61,6 +61,10 @@ org.apache.webbeans.spi.ContextsService=
 org.apache.webbeans.spi.SecurityService=org.apache.webbeans.corespi.security.SimpleSecurityService
 ################################################################################################
 
+################################ Default Implementation-Loader Service ###########################################
+# Service which encapsulates the Service-Loader of Java 1.6+ to allow custom implementations
to support Java 1.5
+org.apache.webbeans.spi.ImplementationLoaderService=org.apache.webbeans.service.DefaultImplementationLoaderService
+
 ################################################################################################

 #################################### SEVERAL CONFIGURATION PARAMETERS ##########################
 ################################################################################################

Modified: openwebbeans/trunk/webbeans-jee5-ejb-resource/src/main/java/org/apache/webbeans/resource/spi/ee/ExtendedStandaloneResourceInjectionService.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-jee5-ejb-resource/src/main/java/org/apache/webbeans/resource/spi/ee/ExtendedStandaloneResourceInjectionService.java?rev=1153495&r1=1153494&r2=1153495&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-jee5-ejb-resource/src/main/java/org/apache/webbeans/resource/spi/ee/ExtendedStandaloneResourceInjectionService.java
(original)
+++ openwebbeans/trunk/webbeans-jee5-ejb-resource/src/main/java/org/apache/webbeans/resource/spi/ee/ExtendedStandaloneResourceInjectionService.java
Wed Aug  3 14:06:23 2011
@@ -24,7 +24,6 @@ import org.apache.webbeans.container.Bea
 import org.apache.webbeans.logger.WebBeansLogger;
 import org.apache.webbeans.resource.spi.se.StandaloneResourceInjectionService;
 import org.apache.webbeans.spi.api.ResourceReference;
-import org.apache.webbeans.util.WebBeansUtil;
 
 import javax.ejb.EJB;
 import javax.enterprise.inject.spi.Bean;
@@ -35,7 +34,6 @@ import java.lang.annotation.Annotation;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
-import java.util.ServiceLoader;
 
 /**
  * Allows to use @EJB in JEE 5 app servers
@@ -50,8 +48,8 @@ public class ExtendedStandaloneResourceI
     {
         super(webBeansContext);
 
-        ServiceLoader<EjbResolver> ejbResolverServiceLoader =
-                ServiceLoader.load(EjbResolver.class, WebBeansUtil.getCurrentClassLoader());
+        List<EjbResolver> ejbResolverServiceLoader =
+                webBeansContext.getImplementationLoaderService().load(EjbResolver.class);
 
         for (EjbResolver ejbResolver : ejbResolverServiceLoader)
         {

Added: openwebbeans/trunk/webbeans-spi/src/main/java/org/apache/webbeans/spi/ImplementationLoaderService.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-spi/src/main/java/org/apache/webbeans/spi/ImplementationLoaderService.java?rev=1153495&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-spi/src/main/java/org/apache/webbeans/spi/ImplementationLoaderService.java
(added)
+++ openwebbeans/trunk/webbeans-spi/src/main/java/org/apache/webbeans/spi/ImplementationLoaderService.java
Wed Aug  3 14:06:23 2011
@@ -0,0 +1,36 @@
+/*
+ * 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.webbeans.spi;
+
+import java.util.List;
+
+/**
+ * Decouples OpenWebBeans from the Service-Loader approach.
+ * It allows to provide custom loaders with custom mechanisms as well as support for Java
1.5
+ */
+public interface ImplementationLoaderService
+{
+    /**
+     * Loads all active implementations for the given service-type
+     * @param serviceType base type of the services which should be loaded
+     * @param <T> current type
+     * @return all active implementations for the given service-type
+     */
+    <T> List<T> load(Class<T> serviceType);
+}

Modified: openwebbeans/trunk/webbeans-test/cditest/src/main/java/org/apache/webbeans/cditest/CdiTestContainerLoader.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-test/cditest/src/main/java/org/apache/webbeans/cditest/CdiTestContainerLoader.java?rev=1153495&r1=1153494&r2=1153495&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-test/cditest/src/main/java/org/apache/webbeans/cditest/CdiTestContainerLoader.java
(original)
+++ openwebbeans/trunk/webbeans-test/cditest/src/main/java/org/apache/webbeans/cditest/CdiTestContainerLoader.java
Wed Aug  3 14:06:23 2011
@@ -34,7 +34,8 @@ public class CdiTestContainerLoader 
     public static CdiTestContainer getCdiContainer() 
     {
         CdiTestContainer testContainer = null;
-        
+
+        //doesn't support the implementation loader (there is no dependency to owb-impl
         ServiceLoader<CdiTestContainer> cdiContainerLoader = ServiceLoader.load(CdiTestContainer.class);
         Iterator<CdiTestContainer> cdiIt = cdiContainerLoader.iterator();
         if (cdiIt.hasNext())



Mime
View raw message