[weld-commits] Weld SVN: r6151 - in extensions/trunk/src/main: java/org/jboss/weld/extensions/beanManager and 3 other directories.

weld-commits at lists.jboss.org weld-commits at lists.jboss.org
Thu Apr 22 15:14:19 EDT 2010


Author: nickarls
Date: 2010-04-22 15:14:18 -0400 (Thu, 22 Apr 2010)
New Revision: 6151

Added:
   extensions/trunk/src/main/java/org/jboss/weld/extensions/beanManager/
   extensions/trunk/src/main/java/org/jboss/weld/extensions/beanManager/AbstractJndiBeanManagerProvider.java
   extensions/trunk/src/main/java/org/jboss/weld/extensions/beanManager/BeanManagerAware.java
   extensions/trunk/src/main/java/org/jboss/weld/extensions/beanManager/BeanManagerProvider.java
   extensions/trunk/src/main/java/org/jboss/weld/extensions/beanManager/DefaultJndiBeanManagerProvider.java
   extensions/trunk/src/main/java/org/jboss/weld/extensions/beanManager/JBossJndiBeanManagerProvider.java
   extensions/trunk/src/main/java/org/jboss/weld/extensions/util/service/
   extensions/trunk/src/main/java/org/jboss/weld/extensions/util/service/DefaultServiceLoader.java
   extensions/trunk/src/main/java/org/jboss/weld/extensions/util/service/DefaultServiceLoaderFactory.java
   extensions/trunk/src/main/java/org/jboss/weld/extensions/util/service/ServiceLoaderFactory.java
   extensions/trunk/src/main/resources/META-INF/services/org.jboss.weld.extensions.beanManager.BeanManagerProvider
Log:
BeanManagerAware infrastructure

Added: extensions/trunk/src/main/java/org/jboss/weld/extensions/beanManager/AbstractJndiBeanManagerProvider.java
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/beanManager/AbstractJndiBeanManagerProvider.java	                        (rev 0)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/beanManager/AbstractJndiBeanManagerProvider.java	2010-04-22 19:14:18 UTC (rev 6151)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.weld.extensions.beanManager;
+
+import javax.enterprise.inject.spi.BeanManager;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+/**
+ * A BeanManager provider for JNDI contexts
+ * 
+ * @author Nicklas Karlsson
+ *
+ */
+public abstract class AbstractJndiBeanManagerProvider implements BeanManagerProvider
+{
+   public BeanManager getBeanManager()
+   {
+      try
+      {
+         return (BeanManager) new InitialContext().lookup(getLocation());
+      }
+      catch (NamingException e)
+      {
+         // No panic, it's just not there
+      }
+      return null;
+   }
+   
+   protected abstract String getLocation();
+
+}

Added: extensions/trunk/src/main/java/org/jboss/weld/extensions/beanManager/BeanManagerAware.java
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/beanManager/BeanManagerAware.java	                        (rev 0)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/beanManager/BeanManagerAware.java	2010-04-22 19:14:18 UTC (rev 6151)
@@ -0,0 +1,104 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.weld.extensions.beanManager;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.Extension;
+import javax.inject.Inject;
+
+import org.jboss.weld.extensions.util.service.DefaultServiceLoader;
+
+/**
+ * Super-class for non-CDI-native components that need a reference to the
+ * {@link BeanManager}
+ * <p>
+ * <b>**WARNING**</b> This class is <b>NEVER</b> safe to use outside of specific
+ * seam-faces implementation classes, and should be <b>avoided at all costs</b>.
+ * If you need a handle to the {@link BeanManager} you should probably register
+ * an {@link Extension} instead of using this class; have you tried using @
+ * {@link Inject}?
+ * 
+ * @author Nicklas Karlsson
+ */
+public class BeanManagerAware
+{
+   private BeanManager beanManager;
+
+   private static final List<BeanManagerProvider> beanManagerProviders = new ArrayList<BeanManagerProvider>();
+
+   static
+   {
+      loadServices();
+      Collections.sort(beanManagerProviders, new ProviderWeightSorter());
+   }
+
+   private static class ProviderWeightSorter implements Comparator<BeanManagerProvider>
+   {
+      public int compare(BeanManagerProvider provider1, BeanManagerProvider provider2)
+      {
+         return Integer.valueOf(provider1.getPrecedence()).compareTo(Integer.valueOf(provider2.getPrecedence()));
+      }
+   }
+
+   private static void loadServices()
+   {
+      Iterator<BeanManagerProvider> providers = DefaultServiceLoader.load(BeanManagerProvider.class).iterator();
+      while (providers.hasNext())
+      {
+         beanManagerProviders.add(providers.next());
+      }
+   }
+
+   protected BeanManager getBeanManager()
+   {
+      if (beanManager == null)
+      {
+         beanManager = lookupBeanManager();
+      }
+      if (beanManager == null)
+      {
+         throw new IllegalStateException("Could not locate a BeanManager from the providers " + beanManagerProviders);
+      }
+      return beanManager;
+   }
+
+   private BeanManager lookupBeanManager()
+   {
+      BeanManager beanManager = null;
+
+      for (BeanManagerProvider provider : beanManagerProviders)
+      {
+         beanManager = provider.getBeanManager();
+         if (beanManager != null)
+         {
+            break;
+         }
+      }
+      return beanManager;
+   }
+}

Added: extensions/trunk/src/main/java/org/jboss/weld/extensions/beanManager/BeanManagerProvider.java
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/beanManager/BeanManagerProvider.java	                        (rev 0)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/beanManager/BeanManagerProvider.java	2010-04-22 19:14:18 UTC (rev 6151)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.weld.extensions.beanManager;
+
+import javax.enterprise.inject.spi.BeanManager;
+
+/**
+ * Provider for obtaining a BeanManager
+ * 
+ * @author Nicklas Karlsson
+ * 
+ */
+public interface BeanManagerProvider
+{
+   /**
+    * Try to obtain a BeanManager
+    * 
+    * @return The BeanManager (or null if non found at this location)
+    */
+   public abstract BeanManager getBeanManager();
+
+   /**
+    * An integer precedence value that indicates how favorable the implementation
+    * considers itself amongst alternatives. A higher value is a higher
+    * precedence.
+    */
+   public abstract int getPrecedence();
+}

Added: extensions/trunk/src/main/java/org/jboss/weld/extensions/beanManager/DefaultJndiBeanManagerProvider.java
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/beanManager/DefaultJndiBeanManagerProvider.java	                        (rev 0)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/beanManager/DefaultJndiBeanManagerProvider.java	2010-04-22 19:14:18 UTC (rev 6151)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.weld.extensions.beanManager;
+
+import javax.enterprise.inject.spi.Extension;
+
+/**
+ * A BeanManagerProvider that looks it up from the standard JNDI location
+ * 
+ * @author Nicklas Karlsson
+ *
+ */
+public class DefaultJndiBeanManagerProvider extends AbstractJndiBeanManagerProvider implements Extension
+{
+
+   @Override
+   protected String getLocation()
+   {
+      return "java:comp/BeanManager";
+   }
+
+   public int getPrecedence()
+   {
+      return 10;
+   }
+
+}

Added: extensions/trunk/src/main/java/org/jboss/weld/extensions/beanManager/JBossJndiBeanManagerProvider.java
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/beanManager/JBossJndiBeanManagerProvider.java	                        (rev 0)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/beanManager/JBossJndiBeanManagerProvider.java	2010-04-22 19:14:18 UTC (rev 6151)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.weld.extensions.beanManager;
+
+import javax.enterprise.inject.spi.Extension;
+
+/**
+ * A temp workaround BeanManagerProvider for JBoss AS 6 <M2 that bound it to a non-standard location 
+ *  
+ * @author Nicklas Karlsson
+ */
+public class JBossJndiBeanManagerProvider extends AbstractJndiBeanManagerProvider implements Extension
+{
+
+   @Override
+   protected String getLocation()
+   {
+      return "java:app/BeanManager";
+   }
+
+   public int getPrecedence()
+   {
+      return 11;
+   }
+
+}

Added: extensions/trunk/src/main/java/org/jboss/weld/extensions/util/service/DefaultServiceLoader.java
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/util/service/DefaultServiceLoader.java	                        (rev 0)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/util/service/DefaultServiceLoader.java	2010-04-22 19:14:18 UTC (rev 6151)
@@ -0,0 +1,336 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed 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.jboss.weld.extensions.util.service;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This class handles looking up service providers on the class path. It
+ * implements the <a href="http://java.sun.com/javase/6/docs/technotes/guides/jar/jar.html#Service%20Provider"
+ * >Service Provider section of the JAR File Specification</a>.
+ * 
+ * The Service Provider programmatic lookup was not specified prior to Java 6 so
+ * this interface allows use of the specification prior to Java 6.
+ * 
+ * The API is copied from <a
+ * href="http://java.sun.com/javase/6/docs/api/java/util/ServiceLoader.html"
+ * >java.util.ServiceLoader</a>
+ * 
+ * @author Pete Muir
+ * @author <a href="mailto:dev at avalon.apache.org">Avalon Development Team</a>
+ * @author Nicklas Karlsson
+ */
+public class DefaultServiceLoader<S> implements Iterable<S>
+{
+   private static final String SERVICES = "META-INF/services";
+
+   private static final Logger log = LoggerFactory.getLogger(DefaultServiceLoader.class);
+
+   /**
+    * Creates a new service loader for the given service type, using the current
+    * thread's context class loader.
+    * 
+    * An invocation of this convenience method of the form
+    * 
+    * {@code ServiceLoader.load(service)</code>}
+    * 
+    * is equivalent to
+    * 
+    * <code>ServiceLoader.load(service,
+    *                   Thread.currentThread().getContextClassLoader())</code>
+    * 
+    * @param service The interface or abstract class representing the service
+    * @return A new service loader
+    */
+   public static <S> DefaultServiceLoader<S> load(Class<S> service)
+   {
+      return load(SERVICES, service, Thread.currentThread().getContextClassLoader());
+   }
+
+   public static <S> DefaultServiceLoader<S> load(String directoryName, Class<S> service)
+   {
+      return load(directoryName, service, Thread.currentThread().getContextClassLoader());
+   }
+
+   public static <S> DefaultServiceLoader<S> load(String directoryName, Class<S> service, ClassLoader loader)
+   {
+      if (loader == null)
+      {
+         loader = service.getClassLoader();
+      }
+      return new DefaultServiceLoader<S>(directoryName, service, loader);
+   }
+
+   /**
+    * Creates a new service loader for the given service type and class loader.
+    * 
+    * @param service The interface or abstract class representing the service
+    * @param loader The class loader to be used to load provider-configuration
+    *           files and provider classes, or null if the system class loader
+    *           (or, failing that, the bootstrap class loader) is to be used
+    * @return A new service loader
+    */
+   public static <S> DefaultServiceLoader<S> load(Class<S> service, ClassLoader loader)
+   {
+      return load(SERVICES, service, loader);
+   }
+
+   /**
+    * Creates a new service loader for the given service type, using the
+    * extension class loader.
+    * 
+    * This convenience method simply locates the extension class loader, call it
+    * extClassLoader, and then returns
+    * 
+    * <code>ServiceLoader.load(service, extClassLoader)</code>
+    * 
+    * If the extension class loader cannot be found then the system class loader
+    * is used; if there is no system class loader then the bootstrap class
+    * loader is used.
+    * 
+    * This method is intended for use when only installed providers are desired.
+    * The resulting service will only find and load providers that have been
+    * installed into the current Java virtual machine; providers on the
+    * application's class path will be ignored.
+    * 
+    * @param service The interface or abstract class representing the service
+    * @return A new service loader
+    */
+   public static <S> DefaultServiceLoader<S> loadInstalled(Class<S> service)
+   {
+      throw new UnsupportedOperationException("Not implemented");
+   }
+
+   private final String serviceFile;
+   private Class<S> expectedType;
+   private final ClassLoader loader;
+
+   private Set<S> providers;
+
+   private DefaultServiceLoader(String prefix, Class<S> service, ClassLoader loader)
+   {
+      this.loader = loader;
+      this.serviceFile = prefix + "/" + service.getName();
+      this.expectedType = service;
+   }
+
+   /**
+    * Clear this loader's provider cache so that all providers will be reloaded.
+    * 
+    * After invoking this method, subsequent invocations of the iterator method
+    * will lazily look up and instantiate providers from scratch, just as is
+    * done by a newly-created loader.
+    * 
+    * This method is intended for use in situations in which new providers can
+    * be installed into a running Java virtual machine.
+    */
+   public void reload()
+   {
+      providers = new HashSet<S>();
+
+      for (URL serviceFile : loadServiceFiles())
+      {
+         loadServiceFile(serviceFile);
+      }
+   }
+
+   private List<URL> loadServiceFiles()
+   {
+      List<URL> serviceFiles = new ArrayList<URL>();
+      try
+      {
+         Enumeration<URL> serviceFileEnumerator = loader.getResources(serviceFile);
+         while (serviceFileEnumerator.hasMoreElements())
+         {
+            serviceFiles.add(serviceFileEnumerator.nextElement());
+         }
+      }
+      catch (IOException e)
+      {
+         throw new RuntimeException("Could not load resources from " + serviceFile, e);
+      }
+      return serviceFiles;
+   }
+
+   private void loadServiceFile(URL serviceFile)
+   {
+      InputStream is = null;
+      try
+      {
+         is = serviceFile.openStream();
+         BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
+         String serviceClassName = null;
+         while ((serviceClassName = reader.readLine()) != null)
+         {
+            serviceClassName = trim(serviceClassName);
+            if (serviceClassName.length() > 0)
+            {
+               loadService(serviceClassName);
+            }
+         }
+      }
+      catch (IOException e)
+      {
+         // FIXME: correct exception
+         throw new RuntimeException("Could not read services file " + serviceFile);
+      }
+      finally
+      {
+         if (is != null)
+         {
+            try
+            {
+               is.close();
+            }
+            catch (IOException e)
+            {
+               // FIXME: correct exception
+               throw new RuntimeException("Could not close services file " + serviceFile, e);
+            }
+         }
+      }
+   }
+
+   private String trim(String line)
+   {
+      final int comment = line.indexOf('#');
+
+      if (comment > -1)
+      {
+         line = line.substring(0, comment);
+      }
+      return line.trim();
+   }
+
+   private void loadService(String serviceClassName)
+   {
+      Class<? extends S> serviceClass = loadClass(serviceClassName);
+      if (serviceClass == null)
+      {
+         return;
+      }
+      S serviceInstance = prepareInstance(serviceClass);
+      if (serviceInstance == null)
+      {
+         return;
+      }
+      providers.add(serviceInstance);
+   }
+
+   private Class<? extends S> loadClass(String serviceClassName)
+   {
+      Class<?> clazz = null;
+      Class<? extends S> serviceClass = null;
+      try
+      {
+         clazz = loader.loadClass(serviceClassName);
+         serviceClass = clazz.asSubclass(expectedType);
+      }
+      catch (ClassNotFoundException e)
+      {
+         log.warn("Could not load service class " + serviceClassName);
+      }
+      catch (ClassCastException e)
+      {
+         log.warn("Service class " + serviceClassName + " didn't implement the Extension interface");
+      }
+      return serviceClass;
+   }
+
+   private S prepareInstance(Class<? extends S> serviceClass)
+   {
+      try
+      {
+         // FIXME: SM compatible instatiation
+         return serviceClass.newInstance();
+      }
+      catch (Exception e)
+      {
+         log.warn("Could not instantiate service class " + serviceClass.getName(), e);
+      }
+      return null;
+   }
+
+   /**
+    * Lazily loads the available providers of this loader's service.
+    * 
+    * The iterator returned by this method first yields all of the elements of
+    * the provider cache, in instantiation order. It then lazily loads and
+    * instantiates any remaining providers, adding each one to the cache in
+    * turn.
+    * 
+    * To achieve laziness the actual work of parsing the available
+    * provider-configuration files and instantiating providers must be done by
+    * the iterator itself. Its hasNext and next methods can therefore throw a
+    * ServiceConfigurationError if a provider-configuration file violates the
+    * specified format, or if it names a provider class that cannot be found and
+    * instantiated, or if the result of instantiating the class is not
+    * assignable to the service type, or if any other kind of exception or error
+    * is thrown as the next provider is located and instantiated. To write
+    * robust code it is only necessary to catch ServiceConfigurationError when
+    * using a service iterator.
+    * 
+    * If such an error is thrown then subsequent invocations of the iterator
+    * will make a best effort to locate and instantiate the next available
+    * provider, but in general such recovery cannot be guaranteed.
+    * 
+    * Design Note Throwing an error in these cases may seem extreme. The
+    * rationale for this behavior is that a malformed provider-configuration
+    * file, like a malformed class file, indicates a serious problem with the
+    * way the Java virtual machine is configured or is being used. As such it is
+    * preferable to throw an error rather than try to recover or, even worse,
+    * fail silently.
+    * 
+    * The iterator returned by this method does not support removal. Invoking
+    * its remove method will cause an UnsupportedOperationException to be
+    * thrown.
+    * 
+    * @return An iterator that lazily loads providers for this loader's service
+    */
+   public Iterator<S> iterator()
+   {
+      if (providers == null)
+      {
+         reload();
+      }
+      return providers.iterator();
+   }
+
+   /**
+    * Returns a string describing this service.
+    * 
+    * @return A descriptive string
+    */
+   @Override
+   public String toString()
+   {
+      return "Services for " + serviceFile;
+   }
+}

Added: extensions/trunk/src/main/java/org/jboss/weld/extensions/util/service/DefaultServiceLoaderFactory.java
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/util/service/DefaultServiceLoaderFactory.java	                        (rev 0)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/util/service/DefaultServiceLoaderFactory.java	2010-04-22 19:14:18 UTC (rev 6151)
@@ -0,0 +1,30 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed 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.jboss.weld.extensions.util.service;
+
+public class DefaultServiceLoaderFactory implements ServiceLoaderFactory
+{
+   public <S> DefaultServiceLoader<S> load(Class<S> service)
+   {
+      return DefaultServiceLoader.load(service);
+   }
+
+   public <S> DefaultServiceLoader<S> load(Class<S> service, ClassLoader loader)
+   {
+      return DefaultServiceLoader.load(service, loader);
+   }
+}

Added: extensions/trunk/src/main/java/org/jboss/weld/extensions/util/service/ServiceLoaderFactory.java
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/util/service/ServiceLoaderFactory.java	                        (rev 0)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/util/service/ServiceLoaderFactory.java	2010-04-22 19:14:18 UTC (rev 6151)
@@ -0,0 +1,24 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed 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.jboss.weld.extensions.util.service;
+
+public interface ServiceLoaderFactory
+{
+   public <S> DefaultServiceLoader<S> load(Class<S> service);
+
+   public <S> DefaultServiceLoader<S> load(Class<S> service, ClassLoader loader);
+}

Added: extensions/trunk/src/main/resources/META-INF/services/org.jboss.weld.extensions.beanManager.BeanManagerProvider
===================================================================
--- extensions/trunk/src/main/resources/META-INF/services/org.jboss.weld.extensions.beanManager.BeanManagerProvider	                        (rev 0)
+++ extensions/trunk/src/main/resources/META-INF/services/org.jboss.weld.extensions.beanManager.BeanManagerProvider	2010-04-22 19:14:18 UTC (rev 6151)
@@ -0,0 +1,2 @@
+org.jboss.weld.extensions.beanManager.DefaultJndiBeanManagerProvider
+org.jboss.weld.extensions.beanManager.JBossJndiBeanManagerProvider



More information about the weld-commits mailing list