Weld SVN: r6312 - core/trunk/tests/src/test/java/org/jboss/weld/tests/unit/security.
by weld-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2010-05-26 08:20:25 -0400 (Wed, 26 May 2010)
New Revision: 6312
Modified:
core/trunk/tests/src/test/java/org/jboss/weld/tests/unit/security/SecurityTest.java
Log:
minor
Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/unit/security/SecurityTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/unit/security/SecurityTest.java 2010-05-26 12:20:18 UTC (rev 6311)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/unit/security/SecurityTest.java 2010-05-26 12:20:25 UTC (rev 6312)
@@ -37,6 +37,7 @@
field.setAccessible(true);
assert field.isAccessible();
assert !SecurityTest.class.getDeclaredField("foo").isAccessible();
+ assert SecurityTest.class.getDeclaredField("foo") != SecurityTest.class.getDeclaredField("foo");
}
}
13 years, 11 months
Weld SVN: r6311 - core/trunk/impl/src/main/java/org/jboss/weld/bootstrap.
by weld-commits@lists.jboss.org
Author: nickarls
Date: 2010-05-26 08:20:18 -0400 (Wed, 26 May 2010)
New Revision: 6311
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/AbstractBeanDeployer.java
Log:
WELD-532
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/AbstractBeanDeployer.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/AbstractBeanDeployer.java 2010-05-26 12:18:34 UTC (rev 6310)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/AbstractBeanDeployer.java 2010-05-26 12:20:18 UTC (rev 6311)
@@ -66,7 +66,6 @@
import org.jboss.weld.persistence.PersistenceApiAbstraction;
import org.jboss.weld.servlet.ServletApiAbstraction;
import org.jboss.weld.util.reflection.Reflections;
-import org.jboss.weld.util.reflection.instantiation.InstantiatorFactory;
import org.jboss.weld.ws.WSApiAbstraction;
import org.slf4j.cal10n.LocLogger;
@@ -305,7 +304,7 @@
!servletApiAbstraction.SERVLET_REQUEST_LISTENER_CLASS.isAssignableFrom(javaClass) &&
!ejbApiAbstraction.ENTERPRISE_BEAN_CLASS.isAssignableFrom(javaClass) &&
!jsfApiAbstraction.UICOMPONENT_CLASS.isAssignableFrom(javaClass) &&
- (hasSimpleWebBeanConstructor(clazz) || InstantiatorFactory.useInstantiators());
+ hasSimpleWebBeanConstructor(clazz);
}
protected boolean isEEResourceProducerField(WeldField<?, ?> field)
13 years, 11 months
Weld SVN: r6310 - cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/newBean.
by weld-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2010-05-26 08:18:34 -0400 (Wed, 26 May 2010)
New Revision: 6310
Modified:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/newBean/SimpleBean.java
Log:
CDITCK-164
Modified: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/newBean/SimpleBean.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/newBean/SimpleBean.java 2010-05-26 10:02:43 UTC (rev 6309)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/newBean/SimpleBean.java 2010-05-26 12:18:34 UTC (rev 6310)
@@ -16,7 +16,7 @@
*/
package org.jboss.jsr299.tck.tests.implementation.enterprise.newBean;
-class SimpleBean
+public class SimpleBean
{
}
13 years, 11 months
Weld SVN: r6309 - in core/trunk/impl/src/main/java/org/jboss/weld: bean/builtin/ee and 3 other directories.
by weld-commits@lists.jboss.org
Author: dallen6
Date: 2010-05-26 06:02:43 -0400 (Wed, 26 May 2010)
New Revision: 6309
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/ManagedBean.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/ee/AbstractEEBean.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/ee/EEResourceProducerField.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/ClientProxyProvider.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/DecoratorProxyFactory.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/EnterpriseProxyFactory.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/ProxyFactory.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/util/SerializableProxy.java
core/trunk/impl/src/main/java/org/jboss/weld/util/collections/ArraySet.java
Log:
Redesigned proxies to use only interfaces where possible and fixed serialization issues
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java 2010-05-25 22:03:31 UTC (rev 6308)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/AbstractClassBean.java 2010-05-26 10:02:43 UTC (rev 6309)
@@ -200,7 +200,7 @@
{
T proxy = null;
TargetBeanInstance beanInstance = new TargetBeanInstance(this, instance);
- ProxyFactory<T> proxyFactory = new ProxyFactory<T>(beanInstance);
+ ProxyFactory<T> proxyFactory = new ProxyFactory<T>(getType(), getTypes());
DecorationHelper<T> decorationHelper = new DecorationHelper<T>(beanInstance, proxyFactory.getProxyClass(), beanManager, decorators);
DecorationHelper.getHelperStack().push(decorationHelper);
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/ManagedBean.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/ManagedBean.java 2010-05-25 22:03:31 UTC (rev 6308)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/ManagedBean.java 2010-05-26 10:02:43 UTC (rev 6309)
@@ -585,7 +585,7 @@
MethodHandler methodHandler = interceptorProxyCreator.createMethodHandler(instance, getType(), getBeanManager().getServices().get(InterceptionMetadataService.class).getInterceptorMetadataRegistry().getInterceptorClassMetadata(WeldClassReference.of(getWeldAnnotated()), true));
TargetBeanInstance targetInstance = new TargetBeanInstance(this, instance);
targetInstance.setInterceptorsHandler(methodHandler);
- instance = new ProxyFactory<T>(targetInstance).create(targetInstance);
+ instance = new ProxyFactory<T>(getType(), getTypes()).create(targetInstance);
}
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/ee/AbstractEEBean.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/ee/AbstractEEBean.java 2010-05-25 22:03:31 UTC (rev 6308)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/ee/AbstractEEBean.java 2010-05-26 10:02:43 UTC (rev 6309)
@@ -43,7 +43,7 @@
this.types = new HashSet<Type>();
this.types.add(Object.class);
this.types.add(type);
- this.proxy = new ProxyFactory<T>(type).create(new EnterpriseTargetBeanInstance(type, new CallableMethodHandler(callable)));
+ this.proxy = new ProxyFactory<T>(type, types).create(new EnterpriseTargetBeanInstance(type, new CallableMethodHandler(callable)));
}
public T create(CreationalContext<T> creationalContext)
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/ee/EEResourceProducerField.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/ee/EEResourceProducerField.java 2010-05-25 22:03:31 UTC (rev 6308)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/ee/EEResourceProducerField.java 2010-05-26 10:02:43 UTC (rev 6309)
@@ -140,7 +140,7 @@
else
{
BeanInstance proxyBeanInstance = new EnterpriseTargetBeanInstance(getTypes(), new CallableMethodHandler(new EEResourceCallable<T>(getBeanManager(), this, creationalContext)));
- return new ProxyFactory<T>(proxyBeanInstance).create(proxyBeanInstance);
+ return new ProxyFactory<T>(getType(), getTypes()).create(proxyBeanInstance);
}
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/ClientProxyProvider.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/ClientProxyProvider.java 2010-05-25 22:03:31 UTC (rev 6308)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/ClientProxyProvider.java 2010-05-26 10:02:43 UTC (rev 6309)
@@ -84,28 +84,7 @@
private static <T> T createClientProxy(Bean<T> bean, String id) throws RuntimeException
{
ContextBeanInstance<T> beanInstance = new ContextBeanInstance<T>(bean, id);
- return new ProxyFactory<T>(beanInstance).create(beanInstance);
-// try
-// {
-// TypeInfo typeInfo;
-// if ((bean instanceof AbstractClassBean) && ((AbstractClassBean)bean).hasInterceptors())
-// {
-// typeInfo = TypeInfo.of(bean.getTypes()).add(Serializable.class).add(LifecycleMixin.class);
-// }
-// else
-// {
-// typeInfo = TypeInfo.of(bean.getTypes()).add(Serializable.class);
-// }
-// return Proxies.<T>createProxy(new ClientProxyMethodHandler(bean, id), typeInfo);
-// }
-// catch (InstantiationException e)
-// {
-// throw new WeldException(PROXY_INSTANTIATION_FAILED, e, bean);
-// }
-// catch (IllegalAccessException e)
-// {
-// throw new WeldException(PROXY_INSTANTIATION_BEAN_ACCESS_FAILED, e, bean);
-// }
+ return new ProxyFactory<T>(bean.getBeanClass(), bean.getTypes()).create(beanInstance);
}
/**
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/DecoratorProxyFactory.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/DecoratorProxyFactory.java 2010-05-25 22:03:31 UTC (rev 6308)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/DecoratorProxyFactory.java 2010-05-26 10:02:43 UTC (rev 6309)
@@ -20,6 +20,7 @@
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
+import java.util.Collections;
import javassist.CtClass;
import javassist.CtConstructor;
@@ -52,7 +53,7 @@
public DecoratorProxyFactory(Class<T> proxyType, WeldInjectionPoint<?, ?> delegateInjectionPoint)
{
- super(proxyType);
+ super(proxyType, Collections.EMPTY_SET);
this.delegateInjectionPoint = delegateInjectionPoint;
try
{
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/EnterpriseProxyFactory.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/EnterpriseProxyFactory.java 2010-05-25 22:03:31 UTC (rev 6308)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/EnterpriseProxyFactory.java 2010-05-26 10:02:43 UTC (rev 6309)
@@ -25,19 +25,16 @@
import javassist.CtNewMethod;
import org.jboss.weld.exceptions.WeldException;
-import org.jboss.weld.util.reflection.Reflections;
/**
- * This factory produces proxies specific for enterprise beans, in particular
- * session beans. It adds the interface {@link EnterpriseBeanInstance} to
- * each proxy class.
+ * This factory produces client proxies specific for enterprise beans, in
+ * particular session beans. It adds the interface
+ * {@link EnterpriseBeanInstance} on the proxy.
*
* @author David Allen
*/
public class EnterpriseProxyFactory<T> extends ProxyFactory<T>
{
- public static final String PROXY_SUFFIX = "EnterpriseProxy";
-
/**
* Produces a factory for a specific bean implementation.
*
@@ -45,29 +42,14 @@
*/
public EnterpriseProxyFactory(Class<T> proxiedBeanType, Set<Type> localBusinessInterfaces)
{
- super(proxiedBeanType);
- for (Type type : localBusinessInterfaces)
- {
- Class<?> c = Reflections.getRawType(type);
- // Ignore no-interface views, they are dealt with proxiedBeanType (pending redesign)
- if (c.isInterface())
- {
- addInterface(c);
- }
- }
+ super(proxiedBeanType, localBusinessInterfaces);
}
@Override
- protected String getProxyNameSuffix()
- {
- return PROXY_SUFFIX;
- }
-
- @Override
protected void addSpecialMethods(CtClass proxyClassType)
{
super.addSpecialMethods(proxyClassType);
-
+
// Add methods for the EnterpriseBeanInstance interface
try
{
@@ -83,6 +65,6 @@
{
throw new WeldException(e);
}
-
+
}
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/ProxyFactory.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/ProxyFactory.java 2010-05-25 22:03:31 UTC (rev 6308)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/ProxyFactory.java 2010-05-26 10:02:43 UTC (rev 6309)
@@ -27,9 +27,11 @@
import java.io.ObjectStreamException;
import java.io.Serializable;
import java.lang.reflect.Modifier;
+import java.lang.reflect.Type;
import java.security.ProtectionDomain;
-import java.util.ArrayList;
import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
import javassist.ClassPool;
import javassist.CtClass;
@@ -47,6 +49,9 @@
import org.jboss.weld.exceptions.DefinitionException;
import org.jboss.weld.exceptions.WeldException;
import org.jboss.weld.serialization.spi.ProxyServices;
+import org.jboss.weld.util.Proxies.TypeInfo;
+import org.jboss.weld.util.collections.ArraySet;
+import org.jboss.weld.util.reflection.Reflections;
import org.jboss.weld.util.reflection.SecureReflections;
import org.jboss.weld.util.reflection.instantiation.InstantiatorFactory;
import org.slf4j.cal10n.LocLogger;
@@ -61,41 +66,55 @@
public class ProxyFactory<T>
{
// The log provider
- protected static final LocLogger log = loggerFactory().getLogger(BEAN);
+ protected static final LocLogger log = loggerFactory().getLogger(BEAN);
// Default proxy class name suffix
- public static final String PROXY_SUFFIX = "Proxy";
+ public static final String PROXY_SUFFIX = "Proxy";
- private final Class<?> beanType;
- private final ArrayList<Class<?>> additionalInterfaces = new ArrayList<Class<?>>();
- private final ClassLoader classLoader;
- private final ProtectionDomain protectionDomain;
- private final ClassPool classPool;
+ private final Class<?> beanType;
+ private final Set<Class<?>> additionalInterfaces = new HashSet<Class<?>>();
+ private final ClassLoader classLoader;
+ private final ProtectionDomain protectionDomain;
+ private final ClassPool classPool;
+ private final String baseProxyName;
/**
- * Creates a new proxy factory from any type of BeanInstance. This bean
- * instance is only used for initialization information and is not associated
- * with this factory once created.
- *
- * @param instance a bean instance that will be used with the proxy
- */
- public ProxyFactory(BeanInstance beanInstance)
- {
- this(beanInstance.getInstanceType());
- }
-
- /**
* Creates a new proxy factory with only the type of proxy specified.
*
* @param proxiedBeanType the super-class for this proxy class
*/
- public ProxyFactory(Class<?> proxiedBeanType)
+ public ProxyFactory(Class<?> proxiedBeanType, Set<Type> businessInterfaces)
{
- this.beanType = proxiedBeanType;
- this.classLoader = Container.instance().services().get(ProxyServices.class).getClassLoader(beanType);
+ for (Type type : businessInterfaces)
+ {
+ Class<?> c = Reflections.getRawType(type);
+ // Ignore no-interface views, they are dealt with proxiedBeanType
+ // (pending redesign)
+ if (c.isInterface())
+ {
+ addInterface(c);
+ }
+ }
+ Class<?> superClass = TypeInfo.of(businessInterfaces).getSuperClass();
+ superClass = superClass == null ? Object.class : superClass;
+ if (superClass.equals(Object.class))
+ {
+ if (additionalInterfaces.isEmpty())
+ {
+ // No interface beans must use the bean impl as superclass
+ superClass = proxiedBeanType;
+ }
+ this.classLoader = Container.instance().services().get(ProxyServices.class).getClassLoader(proxiedBeanType);
+ }
+ else
+ {
+ this.classLoader = Container.instance().services().get(ProxyServices.class).getClassLoader(superClass);
+ }
+ this.beanType = superClass;
this.protectionDomain = Container.instance().services().get(ProxyServices.class).getProtectionDomain(beanType);
this.classPool = new ClassPool();
this.classPool.appendClassPath(new ClassloaderClassPath(classLoader));
addDefaultAdditionalInterfaces();
+ baseProxyName = proxiedBeanType.getName();
}
/**
@@ -153,7 +172,7 @@
@SuppressWarnings("unchecked")
public Class<T> getProxyClass()
{
- String proxyClassName = beanType.getName() + "_$$_Weld" + getProxyNameSuffix();
+ String proxyClassName = getBaseProxyName() + "_$$_Weld" + getProxyNameSuffix();
if (proxyClassName.startsWith("java"))
{
proxyClassName = proxyClassName.replaceFirst("java", "org.jboss.weld");
@@ -181,6 +200,16 @@
}
/**
+ * Returns the package and base name for the proxy class.
+ *
+ * @return base name without suffixes
+ */
+ protected String getBaseProxyName()
+ {
+ return baseProxyName;
+ }
+
+ /**
* Convenience method to determine if an object is a proxy generated by this
* factory or any derived factory.
*
@@ -227,6 +256,13 @@
@SuppressWarnings("unchecked")
private Class<T> createProxyClass(String proxyClassName) throws Exception
{
+ ArraySet<Class<?>> specialInterfaces = new ArraySet<Class<?>>(3);
+ specialInterfaces.add(Proxy.class);
+ specialInterfaces.add(LifecycleMixin.class);
+ specialInterfaces.add(TargetInstanceProxy.class);
+ // Remove special interfaces from main set (deserialization scenario)
+ additionalInterfaces.removeAll(specialInterfaces);
+
CtClass instanceType = classPool.get(beanType.getName());
CtClass proxyClassType = null;
if (instanceType.isInterface())
@@ -249,9 +285,10 @@
addMethods(proxyClassType);
// Additional interfaces whose methods require special handling
- proxyClassType.addInterface(classPool.get(Proxy.class.getName()));
- proxyClassType.addInterface(classPool.get(LifecycleMixin.class.getName()));
- proxyClassType.addInterface(classPool.get(TargetInstanceProxy.class.getName()));
+ for (Class<?> specialInterface : specialInterfaces)
+ {
+ proxyClassType.addInterface(classPool.get(specialInterface.getName()));
+ }
Class<T> proxyClass = proxyClassType.toClass(classLoader, protectionDomain);
proxyClassType.detach();
@@ -318,10 +355,10 @@
/**
* Adds special serialization code by providing a writeReplace() method on
- * the proxy. This method when first called will substitute the proxy
- * object with an instance of {@link org.jboss.weld.proxy.util.SerializableProxy}.
- * The next call will receive the proxy object itself permitting the substitute
- * object to serialize the proxy.
+ * the proxy. This method when first called will substitute the proxy object
+ * with an instance of {@link org.jboss.weld.proxy.util.SerializableProxy}.
+ * The next call will receive the proxy object itself permitting the
+ * substitute object to serialize the proxy.
*
* @param proxyClassType the Javassist class for the proxy class
*/
@@ -333,23 +370,18 @@
// replacement object and the subsequent call get the proxy object.
CtClass exception = classPool.get(ObjectStreamException.class.getName());
CtClass objectClass = classPool.get(Object.class.getName());
- String writeReplaceBody = "{ " +
- " if (firstSerializationPhaseComplete) {" +
- " firstSerializationPhaseComplete = false; " +
- " return $0; " +
- " } else {" +
- " firstSerializationPhaseComplete = true; " +
- " return ((org.jboss.weld.serialization.spi.ProxyServices)org.jboss.weld.Container.instance().services().get(org.jboss.weld.serialization.spi.ProxyServices.class)).wrapForSerialization($0);" +
- " } }";
+ String writeReplaceBody = "{ " + " if (firstSerializationPhaseComplete) {" + " firstSerializationPhaseComplete = false; " + " return $0; " + " } else {" + " firstSerializationPhaseComplete = true; " + " return ((org.jboss.weld.serialization.spi.ProxyServices)org.jboss.weld.Container.instance().services().get(org.jboss.weld.serialization.spi.ProxyServices.class)).wrapForSerialization($0);" + " } }";
proxyClassType.addMethod(CtNewMethod.make(objectClass, "writeReplace", null, new CtClass[] { exception }, writeReplaceBody, proxyClassType));
-
- // Also add a static method that can be used to deserialize a proxy object.
- // This causes the OO input stream to use the class loader from this class.
+
+ // Also add a static method that can be used to deserialize a proxy
+ // object.
+ // This causes the OO input stream to use the class loader from this
+ // class.
CtClass objectInputStreamClass = classPool.get(ObjectInputStream.class.getName());
CtClass cnfe = classPool.get(ClassNotFoundException.class.getName());
CtClass ioe = classPool.get(IOException.class.getName());
String deserializeProxyBody = "{ return $1.readObject(); }";
- proxyClassType.addMethod(CtNewMethod.make(Modifier.STATIC | Modifier.PUBLIC, objectClass, "deserializeProxy", new CtClass[]{objectInputStreamClass}, new CtClass[]{cnfe, ioe}, deserializeProxyBody, proxyClassType));
+ proxyClassType.addMethod(CtNewMethod.make(Modifier.STATIC | Modifier.PUBLIC, objectClass, "deserializeProxy", new CtClass[] { objectInputStreamClass }, new CtClass[] { cnfe, ioe }, deserializeProxyBody, proxyClassType));
}
catch (Exception e)
{
@@ -402,14 +434,14 @@
}
bodyString.append("beanInstance.invoke(");
+ bodyString.append(method.getDeclaringClass().getName());
if (Modifier.isPublic(method.getModifiers()))
{
- bodyString.append("beanInstance.getInstanceType().getMethod(\"");
+ bodyString.append(".class.getMethod(\"");
log.trace("Using getMethod in proxy for method " + method.getLongName());
}
else
{
- bodyString.append(method.getDeclaringClass().getName());
bodyString.append(".class.getDeclaredMethod(\"");
log.trace("Using getDeclaredMethod in proxy for method " + method.getLongName());
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/util/SerializableProxy.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/util/SerializableProxy.java 2010-05-25 22:03:31 UTC (rev 6308)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/util/SerializableProxy.java 2010-05-26 10:02:43 UTC (rev 6309)
@@ -25,12 +25,16 @@
import java.io.ObjectOutputStream;
import java.io.ObjectStreamException;
import java.io.Serializable;
+import java.lang.reflect.Type;
+import java.util.Arrays;
+import java.util.Set;
import org.jboss.weld.Container;
import org.jboss.weld.bean.proxy.ProxyFactory;
import org.jboss.weld.exceptions.ForbiddenStateException;
import org.jboss.weld.exceptions.WeldException;
import org.jboss.weld.serialization.spi.ProxyServices;
+import org.jboss.weld.util.collections.ArraySet;
/**
* A wrapper mostly for client proxies which provides header information useful
@@ -49,6 +53,7 @@
// Information required to generate client proxy classes
private final String proxyClassName;
private final String proxySuperClassName;
+ private final ArraySet<String> proxyInterfaces;
// The wrapped proxy object not serialized by default actions
private transient Object proxyObject;
@@ -62,6 +67,13 @@
}
this.proxyClassName = proxyObject.getClass().getName();
this.proxySuperClassName = proxyObject.getClass().getSuperclass().getName();
+ Class<?>[] proxyInterfaceClasses = proxyObject.getClass().getInterfaces();
+ proxyInterfaces = new ArraySet<String>(proxyInterfaceClasses.length);
+ for (int i = 0; i < proxyInterfaceClasses.length; i++)
+ {
+ proxyInterfaces.add(proxyInterfaceClasses[i].getName());
+ }
+ proxyInterfaces.add(proxySuperClassName);
this.proxyObject = proxyObject;
}
@@ -92,10 +104,11 @@
{
in.defaultReadObject();
Class<?> proxyBeanType = Container.instance().services().get(ProxyServices.class).loadProxySuperClass(proxySuperClassName);
+ ArraySet<Type> proxyBeanInterfaces = loadInterfaces();
Class<?> proxyClass = null;
if (proxyClassName.endsWith(ProxyFactory.PROXY_SUFFIX))
{
- proxyClass = generateClientProxyClass(proxyBeanType);
+ proxyClass = generateClientProxyClass(proxyBeanType, proxyBeanInterfaces);
}
else
{
@@ -112,6 +125,17 @@
}
}
+ private ArraySet<Type> loadInterfaces() throws ClassNotFoundException
+ {
+ ProxyServices proxyServices = Container.instance().services().get(ProxyServices.class);
+ ArraySet<Type> interfaceClasses = new ArraySet<Type>(proxyInterfaces.size());
+ for (String interfaceName : proxyInterfaces)
+ {
+ interfaceClasses.add(proxyServices.loadProxySuperClass(interfaceName));
+ }
+ return interfaceClasses;
+ }
+
/**
* Always returns the original proxy object that was serialized.
*
@@ -128,8 +152,8 @@
return writeProxy ? proxyObject : this;
}
- private <T> Class<?> generateClientProxyClass(Class<T> beanType)
+ private <T> Class<?> generateClientProxyClass(Class<T> beanType, Set<Type> interfaces)
{
- return new ProxyFactory<T>(beanType).getProxyClass();
+ return new ProxyFactory<T>(beanType, interfaces).getProxyClass();
}
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/util/collections/ArraySet.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/util/collections/ArraySet.java 2010-05-25 22:03:31 UTC (rev 6308)
+++ core/trunk/impl/src/main/java/org/jboss/weld/util/collections/ArraySet.java 2010-05-26 10:02:43 UTC (rev 6309)
@@ -17,6 +17,7 @@
package org.jboss.weld.util.collections;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
@@ -38,7 +39,7 @@
*
* @author David Allen
*/
-public class ArraySet<E> implements Set<E>
+public class ArraySet<E> implements Set<E>, Serializable
{
// Underlying array of set elements
private ArrayList<E> elements;
13 years, 11 months
Weld SVN: r6308 - in java-se/trunk/src/main/java/org/jboss/weld/environment/se: discovery and 1 other directories.
by weld-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2010-05-25 18:03:31 -0400 (Tue, 25 May 2010)
New Revision: 6308
Added:
java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/AbstractWeldSEBeanDeploymentArchive.java
java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/AbstractWeldSEDeployment.java
java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/ImmutableBeanDeploymentArchive.java
java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/MutableBeanDeploymentArchive.java
java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/url/ClasspathScanningException.java
java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/url/WeldSEUrlDeployment.java
Removed:
java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/Scanner.java
java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/WeldSEBeanDeploymentArchive.java
java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/WeldSEDeployment.java
java-se/trunk/src/main/java/org/jboss/weld/environment/se/exceptions/
Modified:
java-se/trunk/src/main/java/org/jboss/weld/environment/se/Weld.java
java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/url/FileSystemURLHandler.java
java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/url/URLScanner.java
Log:
Stop exposing the Scanner API at all, javadoc, add helper classes for creating BDAs and Deployments, cleanup now that we don't expose the scanner api
Modified: java-se/trunk/src/main/java/org/jboss/weld/environment/se/Weld.java
===================================================================
--- java-se/trunk/src/main/java/org/jboss/weld/environment/se/Weld.java 2010-05-25 21:27:58 UTC (rev 6307)
+++ java-se/trunk/src/main/java/org/jboss/weld/environment/se/Weld.java 2010-05-25 22:03:31 UTC (rev 6308)
@@ -19,7 +19,6 @@
import java.lang.annotation.Annotation;
import java.util.Arrays;
-import javax.annotation.PostConstruct;
import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.inject.UnsatisfiedResolutionException;
import javax.enterprise.inject.spi.Bean;
@@ -27,30 +26,35 @@
import org.jboss.weld.bootstrap.api.Bootstrap;
import org.jboss.weld.bootstrap.api.Environments;
+import org.jboss.weld.bootstrap.spi.Deployment;
import org.jboss.weld.context.api.BeanStore;
import org.jboss.weld.context.api.helpers.ConcurrentHashMapBeanStore;
-import org.jboss.weld.environment.se.discovery.WeldSEDeployment;
-import org.jboss.weld.environment.se.discovery.url.URLScanner;
import org.jboss.weld.environment.se.discovery.url.WeldSEResourceLoader;
+import org.jboss.weld.environment.se.discovery.url.WeldSEUrlDeployment;
import org.jboss.weld.resources.spi.ResourceLoader;
/**
- * An alternative means of booting WeldContainer form an arbitrary main method
- * within an SE application, <em>without</em> using the built-in
- * ContainerInitialized event. Typical usage of this API looks like this: <code>
+ * <p>
+ * The preferred method of booting Weld SE.
+ * </p>
+ *
+ * <p>
+ * Typical usage of this API looks like this:
+ * </p>
+ *
+ * <pre>
* WeldContainer weld = new Weld().initialize();
* weld.instance().select(Foo.class).get();
* weld.event().select(Bar.class).fire(new Bar());
* weld.shutdown();
- * </code>
+ * </pre>
*
* @author Peter Royle
+ * @author Pete Muir
*/
public class Weld
{
- protected static final String[] RESOURCES = { "META-INF/beans.xml" };
-
private static final String BOOTSTRAP_IMPL_CLASS_NAME = "org.jboss.weld.bootstrap.WeldBootstrap";
private ShutdownManager shutdownManager;
@@ -59,12 +63,11 @@
* Boots Weld and creates and returns a WeldContainer instance, through which
* beans and events can be accessed.
*/
- @PostConstruct
public WeldContainer initialize()
{
BeanStore applicationBeanStore = new ConcurrentHashMapBeanStore();
- WeldSEDeployment deployment = createDeployment();
+ Deployment deployment = createDeployment();
Bootstrap bootstrap = null;
try
@@ -80,13 +83,9 @@
throw new IllegalStateException("Error loading Weld bootstrap, check that Weld is on the classpath", ex);
}
-
- // Kick off the scan
- deployment.getScanner().scan(deployment.getServices().get(ResourceLoader.class));
-
// Set up the container
bootstrap.startContainer(Environments.SE, deployment, applicationBeanStore);
-
+
// Start the container
bootstrap.startInitialization();
bootstrap.deployBeans();
@@ -101,23 +100,60 @@
}
/**
- * Users can subclass and override this method to customise the deployment
- * before weld boots up. For example, to add a custom ResourceLoader, you
- * would subclass Weld like so: <code>
- * public class MyWeld extends Weld {
+ * <p>
+ * Extensions to Weld SE can subclass and override this method to customise
+ * the deployment before weld boots up. For example, to add a custom
+ * ResourceLoader, you would subclass Weld like so:
+ * </p>
*
- * @Override protected WeldSEDeployment createDeployment() { WeldSEDeployment
- * myDeployment = super.createDeployment();
- * deployment.getServices().add(ResourceLoader.class, new
- * OSGIResourceLoader()); } } </code>
+ * <pre>
+ * public class MyWeld extends Weld
+ * {
+ * protected Deployment createDeployment()
+ * {
+ * Deployment deployment = super.createDeployment();
+ * deployment.getServices().add(ResourceLoader.class, new MyResourceLoader());
+ * return deployment;
+ * }
+ * }
+ *</pre>
+ *
+ * <p>
+ * This could then be used as normal:
+ * </p>
+ *
+ * <pre>
+ * WeldContainer container = new MyWeld().initialize();
+ * </pre>
+ *
*/
- protected WeldSEDeployment createDeployment()
+ protected Deployment createDeployment()
{
- WeldSEDeployment deployment = new WeldSEDeployment(new URLScanner(RESOURCES));
- deployment.getServices().add(ResourceLoader.class, new WeldSEResourceLoader());
- return deployment;
+ return new WeldSEUrlDeployment(new WeldSEResourceLoader());
}
-
+
+ /**
+ * Utility method allowing managed instances of beans to provide entry points
+ * for non-managed beans (such as {@link WeldContainer}). Should only called
+ * once Weld has finished booting.
+ *
+ * @param manager the BeanManager to use to access the managed instance
+ * @param type the type of the Bean
+ * @param bindings the bean's qualifiers
+ * @return a managed instance of the bean
+ * @throws IllegalArgumentException if the given type represents a type
+ * variable
+ * @throws IllegalArgumentException if two instances of the same qualifier
+ * type are given
+ * @throws IllegalArgumentException if an instance of an annotation that is
+ * not a qualifier type is given
+ * @throws UnsatisfiedResolutionException if no beans can be resolved * @throws
+ * AmbiguousResolutionException if the ambiguous dependency
+ * resolution rules fail
+ * @throws IllegalArgumentException if the given type is not a bean type of
+ * the given bean
+ *
+ */
protected <T> T getInstanceByType(BeanManager manager, Class<T> type, Annotation... bindings)
{
final Bean<?> bean = manager.resolve(manager.getBeans(type));
Added: java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/AbstractWeldSEBeanDeploymentArchive.java
===================================================================
--- java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/AbstractWeldSEBeanDeploymentArchive.java (rev 0)
+++ java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/AbstractWeldSEBeanDeploymentArchive.java 2010-05-25 22:03:31 UTC (rev 6308)
@@ -0,0 +1,51 @@
+package org.jboss.weld.environment.se.discovery;
+
+import java.util.Collection;
+import java.util.Collections;
+
+import org.jboss.weld.bootstrap.api.ServiceRegistry;
+import org.jboss.weld.bootstrap.api.helpers.SimpleServiceRegistry;
+import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
+import org.jboss.weld.ejb.spi.EjbDescriptor;
+
+/**
+ * Implements the basic requirements of a {@link BeanDeploymentArchive} (bean
+ * archive id and service registry).
+ *
+ * Suitable for extension by those who need to build custom
+ * {@link BeanDeploymentArchive} implementations.
+ *
+ * @see MutableBeanDeploymentArchive
+ * @see ImmutableBeanDeploymentArchive
+ *
+ * @author Pete Muir
+ *
+ */
+public abstract class AbstractWeldSEBeanDeploymentArchive implements BeanDeploymentArchive
+{
+
+ private final ServiceRegistry serviceRegistry;
+ private final String id;
+
+ public AbstractWeldSEBeanDeploymentArchive(String id)
+ {
+ this.id = id;
+ this.serviceRegistry = new SimpleServiceRegistry();
+ }
+
+ public Collection<EjbDescriptor<?>> getEjbs()
+ {
+ return Collections.emptyList();
+ }
+
+ public String getId()
+ {
+ return id;
+ }
+
+ public ServiceRegistry getServices()
+ {
+ return serviceRegistry;
+ }
+
+}
\ No newline at end of file
Property changes on: java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/AbstractWeldSEBeanDeploymentArchive.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/AbstractWeldSEDeployment.java
===================================================================
--- java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/AbstractWeldSEDeployment.java (rev 0)
+++ java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/AbstractWeldSEDeployment.java 2010-05-25 22:03:31 UTC (rev 6308)
@@ -0,0 +1,34 @@
+package org.jboss.weld.environment.se.discovery;
+
+import org.jboss.weld.bootstrap.api.ServiceRegistry;
+import org.jboss.weld.bootstrap.api.helpers.SimpleServiceRegistry;
+import org.jboss.weld.bootstrap.spi.Deployment;
+
+/**
+ * Implements the basic requirements of a {@link Deployment}. Provides a service
+ * registry.
+ *
+ * Suitable for extension by those who need to build custom {@link Deployment}
+ * implementations.
+ *
+ * @author Pete Muir
+ *
+ */
+public abstract class AbstractWeldSEDeployment implements Deployment
+{
+
+ public static final String[] RESOURCES = { "META-INF/beans.xml" };
+
+ private final ServiceRegistry serviceRegistry;
+
+ public AbstractWeldSEDeployment()
+ {
+ this.serviceRegistry = new SimpleServiceRegistry();
+ }
+
+ public ServiceRegistry getServices()
+ {
+ return serviceRegistry;
+ }
+
+}
\ No newline at end of file
Property changes on: java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/AbstractWeldSEDeployment.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/ImmutableBeanDeploymentArchive.java
===================================================================
--- java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/ImmutableBeanDeploymentArchive.java (rev 0)
+++ java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/ImmutableBeanDeploymentArchive.java 2010-05-25 22:03:31 UTC (rev 6308)
@@ -0,0 +1,75 @@
+/**
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat, Inc. and/or its affiliates, 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.environment.se.discovery;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
+import org.jboss.weld.bootstrap.spi.Deployment;
+
+/**
+ * An immutable implementation of {@link BeanDeploymentArchive} which must have
+ * classes and beans.xml resources added to it via
+ * {@link ImmutableBeanDeploymentArchive#ImmutableBeanDeploymentArchive(String, Collection, Collection, List)}
+ * or
+ * {@link ImmutableBeanDeploymentArchive#ImmutableBeanDeploymentArchive(String, Collection, Collection)}
+ *
+ * See {@link Deployment} for more detailed information on creating deployment
+ * structures.
+ *
+ * @author Pete Muir
+ *
+ */
+public class ImmutableBeanDeploymentArchive extends AbstractWeldSEBeanDeploymentArchive
+{
+
+ private final Collection<Class<?>> beanClasses;
+ private final Collection<URL> beansXml;
+ private final Collection<BeanDeploymentArchive> beanDeploymentArchives;
+
+ public ImmutableBeanDeploymentArchive(String id, Collection<Class<?>> beanClasses, Collection<URL> beansXml, Collection<BeanDeploymentArchive> beanDeploymentArchives)
+ {
+ super(id);
+ this.beanClasses = beanClasses;
+ this.beansXml = beansXml;
+ this.beanDeploymentArchives = beanDeploymentArchives;
+ }
+
+ public ImmutableBeanDeploymentArchive(String id, Collection<Class<?>> beanClasses, Collection<URL> beansXml)
+ {
+ this(id, beanClasses, beansXml, new ArrayList<BeanDeploymentArchive>());
+ }
+
+ public Collection<Class<?>> getBeanClasses()
+ {
+ return Collections.unmodifiableCollection(beanClasses);
+ }
+
+ public Collection<BeanDeploymentArchive> getBeanDeploymentArchives()
+ {
+ return Collections.unmodifiableCollection(beanDeploymentArchives);
+ }
+
+ public Collection<URL> getBeansXml()
+ {
+ return Collections.unmodifiableCollection(beansXml);
+ }
+}
Property changes on: java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/ImmutableBeanDeploymentArchive.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Copied: java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/MutableBeanDeploymentArchive.java (from rev 6306, java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/WeldSEBeanDeploymentArchive.java)
===================================================================
--- java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/MutableBeanDeploymentArchive.java (rev 0)
+++ java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/MutableBeanDeploymentArchive.java 2010-05-25 22:03:31 UTC (rev 6308)
@@ -0,0 +1,71 @@
+/**
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat, Inc. and/or its affiliates, 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.environment.se.discovery;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+
+import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
+import org.jboss.weld.bootstrap.spi.Deployment;
+
+/**
+ * A mutable implementation of {@link BeanDeploymentArchive} which can have
+ * classes and beans.xml resources added to it by calling
+ * <code>getBeanClasses.add()</code> and <code>getBeansXml().add()</code>
+ * respectively.
+ *
+ * If you are building a complex deployment structure, you can also associate
+ * accessible {@link BeanDeploymentArchive}s by calling
+ * <code>getBeanDeploymentArchives().add()</code>. See {@link Deployment} for
+ * more detailed information on creating deployment structures.
+ *
+ * @author Pete Muir
+ *
+ */
+public class MutableBeanDeploymentArchive extends AbstractWeldSEBeanDeploymentArchive
+{
+
+ private final Collection<Class<?>> beanClasses;
+ private final Collection<URL> beansXml;
+ private final List<BeanDeploymentArchive> beanDeploymentArchives;
+
+ public MutableBeanDeploymentArchive(String id)
+ {
+ super(id);
+ this.beanClasses = new HashSet<Class<?>>();
+ this.beansXml = new HashSet<URL>();
+ this.beanDeploymentArchives = new ArrayList<BeanDeploymentArchive>();
+ }
+
+ public Collection<Class<?>> getBeanClasses()
+ {
+ return beanClasses;
+ }
+
+ public Collection<BeanDeploymentArchive> getBeanDeploymentArchives()
+ {
+ return beanDeploymentArchives;
+ }
+
+ public Collection<URL> getBeansXml()
+ {
+ return beansXml;
+ }
+}
Deleted: java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/Scanner.java
===================================================================
--- java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/Scanner.java 2010-05-25 21:27:58 UTC (rev 6307)
+++ java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/Scanner.java 2010-05-25 22:03:31 UTC (rev 6308)
@@ -1,46 +0,0 @@
-/**
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat, Inc. and/or its affiliates, 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.environment.se.discovery;
-
-import java.util.List;
-
-import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
-import org.jboss.weld.bootstrap.spi.Deployment;
-import org.jboss.weld.resources.spi.ResourceLoader;
-
-/**
- * The Scanner is used to find resources to be processed by Weld SE
- *
- * @author Pete Muir
- *
- */
-public interface Scanner
-{
-
- /**
- * Scan for structures which should be deployed by Weld. For example,
- * scanning for META-INF/beans.xml should return a graph of
- * {@link BeanDeploymentArchive}s, representing their accessibility. For more
- * on deployment structures see {@link Deployment}.
- */
- public void scan(ResourceLoader resourceLoader);
-
- public BeanDeploymentArchive getBeanDeploymentArchive(Class<?> clazz);
-
- public List<BeanDeploymentArchive> getBeanDeploymentArchives();
-
-}
Deleted: java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/WeldSEBeanDeploymentArchive.java
===================================================================
--- java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/WeldSEBeanDeploymentArchive.java 2010-05-25 21:27:58 UTC (rev 6307)
+++ java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/WeldSEBeanDeploymentArchive.java 2010-05-25 22:03:31 UTC (rev 6308)
@@ -1,95 +0,0 @@
-/**
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat, Inc. and/or its affiliates, 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.environment.se.discovery;
-
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-
-import org.jboss.weld.bootstrap.api.ServiceRegistry;
-import org.jboss.weld.bootstrap.api.helpers.SimpleServiceRegistry;
-import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
-import org.jboss.weld.ejb.spi.EjbDescriptor;
-
-/**
- * A deployment archive to registering classes and resources found in bean
- * archives on the classpath.
- *
- * @author Peter Royle
- * @author Pete Muir
- * @author Ales Justin
- */
-public class WeldSEBeanDeploymentArchive implements BeanDeploymentArchive
-{
-
- private final Collection<Class<?>> weldClasses;
- private final Collection<URL> weldUrls;
- private final ServiceRegistry serviceRegistry;
- private final List<BeanDeploymentArchive> beanDeploymentArchives;
- private final String id;
-
- public WeldSEBeanDeploymentArchive(String id)
- {
- this.id = id;
- this.weldClasses = new HashSet<Class<?>>();
- this.weldUrls = new HashSet<URL>();
- this.serviceRegistry = new SimpleServiceRegistry();
- this.beanDeploymentArchives = new ArrayList<BeanDeploymentArchive>();
- }
-
- /**
- * This is an alias for getBeansXml(), to make adding resources other than
- * beans.xml more natural.
- */
- public Collection<URL> getUrls()
- {
- return weldUrls;
- }
-
- public Collection<Class<?>> getBeanClasses()
- {
- return weldClasses;
- }
-
- public Collection<BeanDeploymentArchive> getBeanDeploymentArchives()
- {
- return this.beanDeploymentArchives;
- }
-
- public Collection<URL> getBeansXml()
- {
- return weldUrls;
- }
-
- public Collection<EjbDescriptor<?>> getEjbs()
- {
- return Collections.EMPTY_SET;
- }
-
- public String getId()
- {
- return this.id;
- }
-
- public ServiceRegistry getServices()
- {
- return this.serviceRegistry;
- }
-}
Deleted: java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/WeldSEDeployment.java
===================================================================
--- java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/WeldSEDeployment.java 2010-05-25 21:27:58 UTC (rev 6307)
+++ java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/WeldSEDeployment.java 2010-05-25 22:03:31 UTC (rev 6308)
@@ -1,70 +0,0 @@
-/**
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat, Inc. and/or its affiliates, 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.environment.se.discovery;
-
-import java.util.List;
-
-import org.jboss.weld.bootstrap.api.ServiceRegistry;
-import org.jboss.weld.bootstrap.api.helpers.SimpleServiceRegistry;
-import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
-import org.jboss.weld.bootstrap.spi.Deployment;
-
-/**
- * Weld Deployment for Java SE environment.
- *
- * @author Peter Royle
- */
-public class WeldSEDeployment implements Deployment
-{
-
- public static final String[] RESOURCES = { "META-INF/beans.xml" };
-
- private final ServiceRegistry serviceRegistry;
- private final Scanner scanner;
-
- public WeldSEDeployment(Scanner scanner)
- {
- this.serviceRegistry = new SimpleServiceRegistry();
- this.scanner = scanner;
- }
-
- public Scanner getScanner()
- {
- return scanner;
- }
-
- /*
- * Returns collection containing the singular logical BeanDeploymentArchive
- * consisting of all Bean classes and beans.xml descriptors in the current
- * classpath.
- */
- public List<BeanDeploymentArchive> getBeanDeploymentArchives()
- {
- return scanner.getBeanDeploymentArchives();
- }
-
- public BeanDeploymentArchive loadBeanDeploymentArchive(Class<?> beanClass)
- {
- return scanner.getBeanDeploymentArchive(beanClass);
- }
-
- public ServiceRegistry getServices()
- {
- return serviceRegistry;
- }
-
-}
Copied: java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/url/ClasspathScanningException.java (from rev 6305, java-se/trunk/src/main/java/org/jboss/weld/environment/se/exceptions/ClasspathScanningException.java)
===================================================================
--- java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/url/ClasspathScanningException.java (rev 0)
+++ java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/url/ClasspathScanningException.java 2010-05-25 22:03:31 UTC (rev 6308)
@@ -0,0 +1,38 @@
+/**
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat, Inc. and/or its affiliates, 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.environment.se.discovery.url;
+
+/**
+ * @author Peter Royle
+ */
+public class ClasspathScanningException extends RuntimeException {
+
+ /**
+ * Creates a new instance of <code>ClasspathScanningException</code> without detail message.
+ */
+ public ClasspathScanningException() {
+ }
+
+
+ /**
+ * Constructs an instance of <code>ClasspathScanningException</code> with the specified detail message.
+ * @param msg the detail message.
+ */
+ public ClasspathScanningException(String msg) {
+ super(msg);
+ }
+}
Modified: java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/url/FileSystemURLHandler.java
===================================================================
--- java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/url/FileSystemURLHandler.java 2010-05-25 21:27:58 UTC (rev 6307)
+++ java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/url/FileSystemURLHandler.java 2010-05-25 22:03:31 UTC (rev 6308)
@@ -26,7 +26,7 @@
import java.util.zip.ZipException;
import java.util.zip.ZipFile;
-import org.jboss.weld.environment.se.discovery.WeldSEBeanDeploymentArchive;
+import org.jboss.weld.environment.se.discovery.MutableBeanDeploymentArchive;
import org.jboss.weld.resources.spi.ResourceLoader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -48,7 +48,7 @@
this.resourceLoader = resourceLoader;
}
- public void handle(Collection<String> paths, WeldSEBeanDeploymentArchive beanDeploymentArchive)
+ public void handle(Collection<String> paths, MutableBeanDeploymentArchive beanDeploymentArchive)
{
for (String urlPath : paths)
{
@@ -82,7 +82,7 @@
}
}
- private void handleArchiveByFile(File file, WeldSEBeanDeploymentArchive beanDeploymentArchive) throws IOException
+ private void handleArchiveByFile(File file, MutableBeanDeploymentArchive beanDeploymentArchive) throws IOException
{
try
{
@@ -105,12 +105,12 @@
}
}
- protected void handleDirectory(File file, String path, WeldSEBeanDeploymentArchive beanDeploymentArchive)
+ protected void handleDirectory(File file, String path, MutableBeanDeploymentArchive beanDeploymentArchive)
{
handleDirectory(file, path, new File[0], beanDeploymentArchive);
}
- private void handleDirectory(File file, String path, File[] excludedDirectories, WeldSEBeanDeploymentArchive beanDeploymentArchive)
+ private void handleDirectory(File file, String path, File[] excludedDirectories, MutableBeanDeploymentArchive beanDeploymentArchive)
{
for (File excludedDirectory : excludedDirectories)
{
@@ -146,7 +146,7 @@
}
}
- protected void handle(String name, URL url, WeldSEBeanDeploymentArchive beanDeploymentArchive)
+ protected void handle(String name, URL url, MutableBeanDeploymentArchive beanDeploymentArchive)
{
if (name.endsWith(".class"))
{
@@ -162,7 +162,7 @@
}
else if (name.endsWith("beans.xml"))
{
- beanDeploymentArchive.getUrls().add(url);
+ beanDeploymentArchive.getBeansXml().add(url);
}
}
Modified: java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/url/URLScanner.java
===================================================================
--- java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/url/URLScanner.java 2010-05-25 21:27:58 UTC (rev 6307)
+++ java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/url/URLScanner.java 2010-05-25 22:03:31 UTC (rev 6308)
@@ -23,13 +23,9 @@
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
-import org.jboss.weld.environment.se.discovery.Scanner;
-import org.jboss.weld.environment.se.discovery.WeldSEBeanDeploymentArchive;
-import org.jboss.weld.environment.se.exceptions.ClasspathScanningException;
+import org.jboss.weld.environment.se.discovery.MutableBeanDeploymentArchive;
import org.jboss.weld.resources.spi.ResourceLoader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -44,22 +40,23 @@
* @author Peter Royle
*
*/
-public class URLScanner implements Scanner
+public class URLScanner
{
private static final Logger log = LoggerFactory.getLogger(URLScanner.class);
- private final WeldSEBeanDeploymentArchive beanDeploymentArchive;
private final String[] resources;
+ private final ResourceLoader resourceLoader;
- public URLScanner(String... resources)
+ public URLScanner(ResourceLoader resourceLoader, String... resources)
{
- this.beanDeploymentArchive = new WeldSEBeanDeploymentArchive("weld-se");
this.resources = resources;
+ this.resourceLoader = resourceLoader;
}
- public void scan(ResourceLoader resourceLoader)
+ public BeanDeploymentArchive scan()
{
FileSystemURLHandler handler = new FileSystemURLHandler(resourceLoader);
+ MutableBeanDeploymentArchive beanDeploymentArchive = new MutableBeanDeploymentArchive("classpath");
Collection<String> paths = new ArrayList<String>();
for (String resourceName : resources)
{
@@ -115,15 +112,7 @@
}
handler.handle(paths, beanDeploymentArchive);
}
- }
-
- public BeanDeploymentArchive getBeanDeploymentArchive(Class<?> clazz)
- {
return beanDeploymentArchive;
}
- public List<BeanDeploymentArchive> getBeanDeploymentArchives()
- {
- return Collections.<BeanDeploymentArchive>singletonList(beanDeploymentArchive);
- }
}
Copied: java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/url/WeldSEUrlDeployment.java (from rev 6306, java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/WeldSEDeployment.java)
===================================================================
--- java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/url/WeldSEUrlDeployment.java (rev 0)
+++ java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/url/WeldSEUrlDeployment.java 2010-05-25 22:03:31 UTC (rev 6308)
@@ -0,0 +1,52 @@
+/**
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat, Inc. and/or its affiliates, 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.environment.se.discovery.url;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
+import org.jboss.weld.environment.se.discovery.AbstractWeldSEDeployment;
+import org.jboss.weld.resources.spi.ResourceLoader;
+
+/**
+ * Weld Deployment for Java SE environment.
+ *
+ * @author Peter Royle
+ */
+public class WeldSEUrlDeployment extends AbstractWeldSEDeployment
+{
+
+ private final BeanDeploymentArchive beanDeploymentArchive;
+
+ public WeldSEUrlDeployment(ResourceLoader resourceLoader)
+ {
+ getServices().add(ResourceLoader.class, resourceLoader);
+ this.beanDeploymentArchive = new URLScanner(resourceLoader, RESOURCES).scan();
+ }
+
+ public List<BeanDeploymentArchive> getBeanDeploymentArchives()
+ {
+ return Collections.singletonList(beanDeploymentArchive);
+ }
+
+ public BeanDeploymentArchive loadBeanDeploymentArchive(Class<?> beanClass)
+ {
+ return beanDeploymentArchive;
+ }
+
+}
13 years, 11 months
Weld SVN: r6307 - java-se/trunk/src/main/java/org/jboss/weld/environment/se/beans.
by weld-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2010-05-25 17:27:58 -0400 (Tue, 25 May 2010)
New Revision: 6307
Modified:
java-se/trunk/src/main/java/org/jboss/weld/environment/se/beans/InstanceManager.java
Log:
minor
Modified: java-se/trunk/src/main/java/org/jboss/weld/environment/se/beans/InstanceManager.java
===================================================================
--- java-se/trunk/src/main/java/org/jboss/weld/environment/se/beans/InstanceManager.java 2010-05-25 17:52:01 UTC (rev 6306)
+++ java-se/trunk/src/main/java/org/jboss/weld/environment/se/beans/InstanceManager.java 2010-05-25 21:27:58 UTC (rev 6307)
@@ -19,11 +19,12 @@
import javax.enterprise.event.Event;
import javax.enterprise.inject.Instance;
import javax.inject.Inject;
+
import org.jboss.weld.environment.se.WeldContainer;
/**
* A managed bean which holds all of the injected instances of managed beans and
- * events. It is primarily used as a delegate for the WeldContainer class's instance()
+ * events. It is primarily used as a delegate for the {@link WeldContainer} class's instance()
* and event() methods.
*
* @see WeldContainer
13 years, 11 months
Weld SVN: r6306 - in java-se/trunk/src: main/java/org/jboss/weld/environment/se/discovery and 2 other directories.
by weld-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2010-05-25 13:52:01 -0400 (Tue, 25 May 2010)
New Revision: 6306
Added:
java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/WeldSEDeployment.java
java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/url/
java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/url/URLScanner.java
java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/url/WeldSEResourceLoader.java
Removed:
java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/AbstractScanner.java
java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/NewSEWeldDeployment.java
java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/URLScanner.java
java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/handlers/
java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/url/AbstractURLHandler.java
java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/url/URLHandler.java
java-se/trunk/src/main/java/org/jboss/weld/environment/se/util/
Modified:
java-se/trunk/src/main/java/org/jboss/weld/environment/se/Weld.java
java-se/trunk/src/main/java/org/jboss/weld/environment/se/WeldContainer.java
java-se/trunk/src/main/java/org/jboss/weld/environment/se/WeldSEBeanRegistrant.java
java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/Scanner.java
java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/WeldSEBeanDeploymentArchive.java
java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/url/FileSystemURLHandler.java
java-se/trunk/src/test/java/org/jboss/weld/environment/se/test/DecoratorsTest.java
Log:
expose Scanner directly for OSGi support
Modified: java-se/trunk/src/main/java/org/jboss/weld/environment/se/Weld.java
===================================================================
--- java-se/trunk/src/main/java/org/jboss/weld/environment/se/Weld.java 2010-05-25 14:53:56 UTC (rev 6305)
+++ java-se/trunk/src/main/java/org/jboss/weld/environment/se/Weld.java 2010-05-25 17:52:01 UTC (rev 6306)
@@ -16,44 +16,44 @@
*/
package org.jboss.weld.environment.se;
+import java.lang.annotation.Annotation;
+import java.util.Arrays;
+
import javax.annotation.PostConstruct;
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.UnsatisfiedResolutionException;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
+
import org.jboss.weld.bootstrap.api.Bootstrap;
import org.jboss.weld.bootstrap.api.Environments;
-import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
-import org.jboss.weld.bootstrap.spi.Deployment;
import org.jboss.weld.context.api.BeanStore;
import org.jboss.weld.context.api.helpers.ConcurrentHashMapBeanStore;
-import org.jboss.weld.environment.se.beans.InstanceManager;
-import org.jboss.weld.environment.se.discovery.NewSEWeldDeployment;
-import org.jboss.weld.environment.se.discovery.WeldSEBeanDeploymentArchive;
-import org.jboss.weld.environment.se.discovery.URLScanner;
-import org.jboss.weld.environment.se.util.WeldManagerUtils;
-import org.jboss.weld.manager.api.WeldManager;
-import org.jboss.weld.resources.DefaultResourceLoader;
+import org.jboss.weld.environment.se.discovery.WeldSEDeployment;
+import org.jboss.weld.environment.se.discovery.url.URLScanner;
+import org.jboss.weld.environment.se.discovery.url.WeldSEResourceLoader;
import org.jboss.weld.resources.spi.ResourceLoader;
/**
- * An alternative means of booting WeldContainer form an arbitrary main method within an
- * SE application, <em>without</em> using the built-in ContainerInitialized event.
- * Typical usage of this API looks like this:
- * <code>
+ * An alternative means of booting WeldContainer form an arbitrary main method
+ * within an SE application, <em>without</em> using the built-in
+ * ContainerInitialized event. Typical usage of this API looks like this: <code>
* WeldContainer weld = new Weld().initialize();
* weld.instance().select(Foo.class).get();
* weld.event().select(Bar.class).fire(new Bar());
* weld.shutdown();
* </code>
- *
+ *
* @author Peter Royle
*/
public class Weld
{
+ protected static final String[] RESOURCES = { "META-INF/beans.xml" };
+
private static final String BOOTSTRAP_IMPL_CLASS_NAME = "org.jboss.weld.bootstrap.WeldBootstrap";
- private WeldManager manager;
- public Weld()
- {
- }
+ private ShutdownManager shutdownManager;
/**
* Boots Weld and creates and returns a WeldContainer instance, through which
@@ -64,81 +64,76 @@
{
BeanStore applicationBeanStore = new ConcurrentHashMapBeanStore();
- Deployment deployment = createDeployment();
+ WeldSEDeployment deployment = createDeployment();
Bootstrap bootstrap = null;
try
{
bootstrap = (Bootstrap) deployment.getServices().get(ResourceLoader.class).classForName(BOOTSTRAP_IMPL_CLASS_NAME).newInstance();
- } catch (InstantiationException ex)
+ }
+ catch (InstantiationException ex)
{
throw new IllegalStateException("Error loading Weld bootstrap, check that Weld is on the classpath", ex);
- } catch (IllegalAccessException ex)
+ }
+ catch (IllegalAccessException ex)
{
throw new IllegalStateException("Error loading Weld bootstrap, check that Weld is on the classpath", ex);
}
- BeanDeploymentArchive discovery = discoverBeansAndResources(deployment);
- // transfer discovered classes and resources to the deployment in a single BeanDeploymentArchive
- deployment.getBeanDeploymentArchives().add(discovery);
-
+
+ // Kick off the scan
+ deployment.getScanner().scan(deployment.getServices().get(ResourceLoader.class));
+
+ // Set up the container
bootstrap.startContainer(Environments.SE, deployment, applicationBeanStore);
- final BeanDeploymentArchive mainBeanDepArch = deployment.getBeanDeploymentArchives().iterator().next();
- this.manager = bootstrap.getManager(mainBeanDepArch);
+
+ // Start the container
bootstrap.startInitialization();
bootstrap.deployBeans();
- WeldManagerUtils.getInstanceByType(manager, ShutdownManager.class).setBootstrap(bootstrap);
+ getInstanceByType(bootstrap.getManager(deployment.loadBeanDeploymentArchive(ShutdownManager.class)), ShutdownManager.class).setBootstrap(bootstrap);
bootstrap.validateBeans();
bootstrap.endInitialization();
- InstanceManager instanceManager = WeldManagerUtils.getInstanceByType(manager, InstanceManager.class);
+ // Set up the ShutdownManager for later
+ this.shutdownManager = getInstanceByType(bootstrap.getManager(deployment.loadBeanDeploymentArchive(ShutdownManager.class)), ShutdownManager.class);
- return new WeldContainer(instanceManager, manager);
-
+ return getInstanceByType(bootstrap.getManager(deployment.loadBeanDeploymentArchive(WeldContainer.class)), WeldContainer.class);
}
- /*
- * Users can subclass and override this method to customise the classes and
- * resources that Weld finds when it boots up.
- */
- protected BeanDeploymentArchive discoverBeansAndResources(Deployment deployment)
- {
- WeldSEBeanDeploymentArchive discovery = new WeldSEBeanDeploymentArchive("weld-se-main-archive");
- final ResourceLoader resourceLoader = deployment.getServices().get(ResourceLoader.class);
- URLScanner scanner = new URLScanner(resourceLoader, discovery);
- scanner.scanResources(new String[]
- {
- "META-INF/beans.xml"
- });
- return discovery;
- }
-
/**
* Users can subclass and override this method to customise the deployment
- * before weld boots up. For example, to add a custom ResourceLoader, you would
- * subclass Weld like so:
- * <code>
+ * before weld boots up. For example, to add a custom ResourceLoader, you
+ * would subclass Weld like so: <code>
* public class MyWeld extends Weld {
- * @Override
- * protected void createDeployment() {
- * Deployment myDeployment = new MyDeployment();
- * deployment.getServices().add(ResourceLoader.class, new OSGIResourceLoader());
- * }
- * }
- * </code>
+ *
+ * @Override protected WeldSEDeployment createDeployment() { WeldSEDeployment
+ * myDeployment = super.createDeployment();
+ * deployment.getServices().add(ResourceLoader.class, new
+ * OSGIResourceLoader()); } } </code>
*/
- private Deployment createDeployment()
+ protected WeldSEDeployment createDeployment()
{
- NewSEWeldDeployment deployment = new NewSEWeldDeployment();
- deployment.getServices().add(ResourceLoader.class, new DefaultResourceLoader());
+ WeldSEDeployment deployment = new WeldSEDeployment(new URLScanner(RESOURCES));
+ deployment.getServices().add(ResourceLoader.class, new WeldSEResourceLoader());
return deployment;
}
+
+ protected <T> T getInstanceByType(BeanManager manager, Class<T> type, Annotation... bindings)
+ {
+ final Bean<?> bean = manager.resolve(manager.getBeans(type));
+ if (bean == null)
+ {
+ throw new UnsatisfiedResolutionException("Unable to resolve a bean for " + type + " with bindings " + Arrays.asList(bindings));
+ }
+ CreationalContext<?> cc = manager.createCreationalContext(bean);
+ return type.cast(manager.getReference(bean, type, cc));
+ }
/**
* Shuts down Weld.
*/
public void shutdown()
{
- WeldManagerUtils.getInstanceByType(manager, ShutdownManager.class).shutdown();
+ shutdownManager.shutdown();
}
}
Modified: java-se/trunk/src/main/java/org/jboss/weld/environment/se/WeldContainer.java
===================================================================
--- java-se/trunk/src/main/java/org/jboss/weld/environment/se/WeldContainer.java 2010-05-25 14:53:56 UTC (rev 6305)
+++ java-se/trunk/src/main/java/org/jboss/weld/environment/se/WeldContainer.java 2010-05-25 17:52:01 UTC (rev 6306)
@@ -19,6 +19,8 @@
import javax.enterprise.event.Event;
import javax.enterprise.inject.Instance;
import javax.enterprise.inject.spi.BeanManager;
+import javax.inject.Inject;
+
import org.jboss.weld.environment.se.beans.InstanceManager;
/**
@@ -39,6 +41,7 @@
private final InstanceManager instanceManager;
private final BeanManager beanManager;
+ @Inject
protected WeldContainer(InstanceManager instanceManager, BeanManager beanManager)
{
this.instanceManager = instanceManager;
Modified: java-se/trunk/src/main/java/org/jboss/weld/environment/se/WeldSEBeanRegistrant.java
===================================================================
--- java-se/trunk/src/main/java/org/jboss/weld/environment/se/WeldSEBeanRegistrant.java 2010-05-25 14:53:56 UTC (rev 6305)
+++ java-se/trunk/src/main/java/org/jboss/weld/environment/se/WeldSEBeanRegistrant.java 2010-05-25 17:52:01 UTC (rev 6306)
@@ -16,17 +16,18 @@
*/
package org.jboss.weld.environment.se;
-import org.jboss.weld.environment.se.threading.RunnableDecorator;
import javax.enterprise.event.Observes;
import javax.enterprise.inject.spi.AfterBeanDiscovery;
import javax.enterprise.inject.spi.BeanManager;
import javax.enterprise.inject.spi.BeforeBeanDiscovery;
import javax.enterprise.inject.spi.Extension;
+
import org.jboss.weld.context.api.BeanStore;
import org.jboss.weld.context.beanstore.HashMapBeanStore;
import org.jboss.weld.environment.se.beans.InstanceManager;
import org.jboss.weld.environment.se.beans.ParametersFactory;
import org.jboss.weld.environment.se.contexts.ThreadContext;
+import org.jboss.weld.environment.se.threading.RunnableDecorator;
/**
* Explicitly registers all of the 'built-in' Java SE related beans and contexts.
@@ -42,8 +43,8 @@
event.addAnnotatedType(manager.createAnnotatedType(ShutdownManager.class));
event.addAnnotatedType(manager.createAnnotatedType(ParametersFactory.class));
event.addAnnotatedType(manager.createAnnotatedType(InstanceManager.class));
- event.addAnnotatedType(manager.createAnnotatedType(Weld.class));
event.addAnnotatedType(manager.createAnnotatedType(RunnableDecorator.class));
+ event.addAnnotatedType(manager.createAnnotatedType(WeldContainer.class));
}
public void registerWeldSEContexts(@Observes AfterBeanDiscovery event)
Deleted: java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/AbstractScanner.java
===================================================================
--- java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/AbstractScanner.java 2010-05-25 14:53:56 UTC (rev 6305)
+++ java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/AbstractScanner.java 2010-05-25 17:52:01 UTC (rev 6306)
@@ -1,51 +0,0 @@
-/**
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat, Inc. and/or its affiliates, 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.environment.se.discovery;
-
-import org.jboss.weld.resources.spi.ResourceLoader;
-
-/**
- *
- * @author Peter Royle
- */
-public abstract class AbstractScanner implements Scanner
-{
-
- private final ResourceLoader resourceLoader;
- private final WeldSEBeanDeploymentArchive weldDiscovery;
-
- public AbstractScanner(ResourceLoader resourceLoader, WeldSEBeanDeploymentArchive webBeanDiscovery)
- {
- this.resourceLoader = resourceLoader;
- this.weldDiscovery = webBeanDiscovery;
- }
-
-
- public ResourceLoader getResourceLoader()
- {
- return resourceLoader;
- }
-
- /**
- * @return the webBeanDiscovery
- */
- public WeldSEBeanDeploymentArchive getWebBeanDiscovery()
- {
- return weldDiscovery;
- }
-
-}
Deleted: java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/NewSEWeldDeployment.java
===================================================================
--- java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/NewSEWeldDeployment.java 2010-05-25 14:53:56 UTC (rev 6305)
+++ java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/NewSEWeldDeployment.java 2010-05-25 17:52:01 UTC (rev 6306)
@@ -1,68 +0,0 @@
-/**
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat, Inc. and/or its affiliates, 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.environment.se.discovery;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.jboss.weld.bootstrap.api.ServiceRegistry;
-import org.jboss.weld.bootstrap.api.helpers.SimpleServiceRegistry;
-import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
-import org.jboss.weld.bootstrap.spi.Deployment;
-
-/**
- * Weld Deployment for Java SE environment.
- *
- * @author Peter Royle
- */
-public class NewSEWeldDeployment implements Deployment
-{
-
- final List<BeanDeploymentArchive> beanDeploymentArchives = new ArrayList<BeanDeploymentArchive>();
- final ServiceRegistry serviceRegistry = new SimpleServiceRegistry();
-
- public NewSEWeldDeployment()
- {
- }
-
- /**
- * {@inheritDoc}
- *
- * @return A collection containing the singular logical BeanDeploymentArchive
- * consisting of all Bean classes and beans.xml descriptors in the
- * current classpath.
- */
- public List<BeanDeploymentArchive> getBeanDeploymentArchives()
- {
- return beanDeploymentArchives;
- }
-
- /**
- * {@inheritDoc}
- */
- public BeanDeploymentArchive loadBeanDeploymentArchive(Class<?> beanClass)
- {
- // TODO (PR) (WELDSE-26): This is just a hack. What do we really need to do here?
- return beanDeploymentArchives.get(0);
- }
-
- public ServiceRegistry getServices()
- {
- // TODO (PR) (WELDSE-26): Do I need to aggregate all services from all bean archives?
- return serviceRegistry;
- }
-
-}
Modified: java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/Scanner.java
===================================================================
--- java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/Scanner.java 2010-05-25 14:53:56 UTC (rev 6305)
+++ java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/Scanner.java 2010-05-25 17:52:01 UTC (rev 6306)
@@ -16,12 +16,15 @@
*/
package org.jboss.weld.environment.se.discovery;
+import java.util.List;
+import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
+import org.jboss.weld.bootstrap.spi.Deployment;
+import org.jboss.weld.resources.spi.ResourceLoader;
+
/**
- * The Scanner is used to find resources to be processed by Seam
+ * The Scanner is used to find resources to be processed by Weld SE
*
- * The processing is done by {@link DeploymentHandler}s
- *
* @author Pete Muir
*
*/
@@ -29,10 +32,15 @@
{
/**
- * Scan for structures which contain any of the given resources in their root
- *
- * @param resources The resources to scan for
+ * Scan for structures which should be deployed by Weld. For example,
+ * scanning for META-INF/beans.xml should return a graph of
+ * {@link BeanDeploymentArchive}s, representing their accessibility. For more
+ * on deployment structures see {@link Deployment}.
*/
- public void scanResources(String[] resources);
+ public void scan(ResourceLoader resourceLoader);
+ public BeanDeploymentArchive getBeanDeploymentArchive(Class<?> clazz);
+
+ public List<BeanDeploymentArchive> getBeanDeploymentArchives();
+
}
Deleted: java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/URLScanner.java
===================================================================
--- java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/URLScanner.java 2010-05-25 14:53:56 UTC (rev 6305)
+++ java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/URLScanner.java 2010-05-25 17:52:01 UTC (rev 6306)
@@ -1,137 +0,0 @@
-/**
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat, Inc. and/or its affiliates, 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.environment.se.discovery;
-
-import java.io.File;
-import java.io.UnsupportedEncodingException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.net.URLDecoder;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.jboss.weld.environment.se.discovery.handlers.FileSystemURLHandler;
-import org.jboss.weld.environment.se.discovery.handlers.URLHandler;
-import org.jboss.weld.environment.se.exceptions.ClasspathScanningException;
-import org.jboss.weld.resources.spi.ResourceLoader;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.collect.HashMultimap;
-import com.google.common.collect.Multimap;
-
-/**
- * Implementation of {@link Scanner} which can scan a {@link URLClassLoader}
- *
- * @author Thomas Heute
- * @author Gavin King
- * @author Norman Richards
- * @author Pete Muir
- * @author Peter Royle
- *
- */
-public class URLScanner extends AbstractScanner
-{
-
- private static final String FILE = "file";
- private static final String JAR = "jar";
- private final Map<String, URLHandler> urlHandlers = new HashMap<String, URLHandler>();
- private static final Logger log = LoggerFactory.getLogger(URLScanner.class);
-
- public URLScanner(ResourceLoader resourceLoader, WeldSEBeanDeploymentArchive weldDiscovery)
- {
- super(resourceLoader, weldDiscovery);
- URLHandler fileSysHandler = new FileSystemURLHandler(resourceLoader, weldDiscovery);
- urlHandlers.put(FILE, fileSysHandler);
- urlHandlers.put(JAR, fileSysHandler);
- }
-
- public void setURLHandler(String type, URLHandler handler)
- {
- urlHandlers.put(type, handler);
- }
-
- public void scanResources(String[] resources)
- {
- Multimap<String, String> paths = HashMultimap.create();
- for (String resourceName : resources)
- {
- // grab all the URLs for this resource
- Collection<URL> urlEnum = getResourceLoader().getResources(resourceName);
- for (URL url : urlEnum)
- {
-
- String urlPath = url.toExternalForm();
-
- // determin resource type (eg: jar, file, bundle)
- String urlType = "file";
- int colonIndex = urlPath.indexOf(":");
- if (colonIndex != -1)
- {
- urlType = urlPath.substring(0, colonIndex);
- }
-
- // Extra built-in support for simple file-based resources
- if ("file".equals(urlType) || "jar".equals(urlType))
- {
- // switch to using getPath() instead of toExternalForm()
- urlPath = url.getPath();
-
- if (urlPath.indexOf('!') > 0)
- {
- urlPath = urlPath.substring(0, urlPath.indexOf('!'));
- } else
- {
- // hack for /META-INF/beans.xml
- File dirOrArchive = new File(urlPath);
- if ((resourceName != null) && (resourceName.lastIndexOf('/') > 0))
- {
- dirOrArchive = dirOrArchive.getParentFile();
- }
- urlPath = dirOrArchive.getParent();
- }
- }
-
- try
- {
- urlPath = URLDecoder.decode(urlPath, "UTF-8");
- } catch (UnsupportedEncodingException ex)
- {
- throw new ClasspathScanningException("Error decoding URL using UTF-8");
- }
-
- log.debug("URL Type: " + urlType);
-
- paths.put(urlType, urlPath);
-
- }
- }
- for (String urlType : paths.keySet())
- {
- Collection<String> urlPaths = paths.get(urlType);
- URLHandler handler = urlHandlers.get(urlType);
- if (handler == null)
- {
- throw new ClasspathScanningException("No handler defined for URL type: " + urlType);
- } else
- {
- handler.handle(urlPaths);
- }
- }
- }
-}
Modified: java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/WeldSEBeanDeploymentArchive.java
===================================================================
--- java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/WeldSEBeanDeploymentArchive.java 2010-05-25 14:53:56 UTC (rev 6305)
+++ java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/WeldSEBeanDeploymentArchive.java 2010-05-25 17:52:01 UTC (rev 6306)
@@ -22,6 +22,7 @@
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
+
import org.jboss.weld.bootstrap.api.ServiceRegistry;
import org.jboss.weld.bootstrap.api.helpers.SimpleServiceRegistry;
import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
@@ -42,7 +43,7 @@
private final Collection<URL> weldUrls;
private final ServiceRegistry serviceRegistry;
private final List<BeanDeploymentArchive> beanDeploymentArchives;
- private String id;
+ private final String id;
public WeldSEBeanDeploymentArchive(String id)
{
@@ -87,14 +88,6 @@
return this.id;
}
- /**
- * @param id the id to set
- */
- public void setId(String id)
- {
- this.id = id;
- }
-
public ServiceRegistry getServices()
{
return this.serviceRegistry;
Copied: java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/WeldSEDeployment.java (from rev 6305, java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/NewSEWeldDeployment.java)
===================================================================
--- java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/WeldSEDeployment.java (rev 0)
+++ java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/WeldSEDeployment.java 2010-05-25 17:52:01 UTC (rev 6306)
@@ -0,0 +1,70 @@
+/**
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat, Inc. and/or its affiliates, 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.environment.se.discovery;
+
+import java.util.List;
+
+import org.jboss.weld.bootstrap.api.ServiceRegistry;
+import org.jboss.weld.bootstrap.api.helpers.SimpleServiceRegistry;
+import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
+import org.jboss.weld.bootstrap.spi.Deployment;
+
+/**
+ * Weld Deployment for Java SE environment.
+ *
+ * @author Peter Royle
+ */
+public class WeldSEDeployment implements Deployment
+{
+
+ public static final String[] RESOURCES = { "META-INF/beans.xml" };
+
+ private final ServiceRegistry serviceRegistry;
+ private final Scanner scanner;
+
+ public WeldSEDeployment(Scanner scanner)
+ {
+ this.serviceRegistry = new SimpleServiceRegistry();
+ this.scanner = scanner;
+ }
+
+ public Scanner getScanner()
+ {
+ return scanner;
+ }
+
+ /*
+ * Returns collection containing the singular logical BeanDeploymentArchive
+ * consisting of all Bean classes and beans.xml descriptors in the current
+ * classpath.
+ */
+ public List<BeanDeploymentArchive> getBeanDeploymentArchives()
+ {
+ return scanner.getBeanDeploymentArchives();
+ }
+
+ public BeanDeploymentArchive loadBeanDeploymentArchive(Class<?> beanClass)
+ {
+ return scanner.getBeanDeploymentArchive(beanClass);
+ }
+
+ public ServiceRegistry getServices()
+ {
+ return serviceRegistry;
+ }
+
+}
Copied: java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/url (from rev 6305, java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/handlers)
Deleted: java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/url/AbstractURLHandler.java
===================================================================
--- java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/handlers/AbstractURLHandler.java 2010-05-25 14:53:56 UTC (rev 6305)
+++ java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/url/AbstractURLHandler.java 2010-05-25 17:52:01 UTC (rev 6306)
@@ -1,54 +0,0 @@
-/**
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat, Inc. and/or its affiliates, 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.environment.se.discovery.handlers;
-
-import org.jboss.weld.environment.se.discovery.WeldSEBeanDeploymentArchive;
-import org.jboss.weld.resources.spi.ResourceLoader;
-
-/**
- *
- * @author Peter Royle
- */
-public abstract class AbstractURLHandler implements URLHandler
-{
-
- private final ResourceLoader resourceLoader;
- private final WeldSEBeanDeploymentArchive weldDiscovery;
-
- public AbstractURLHandler(ResourceLoader resourceLoader, WeldSEBeanDeploymentArchive webBeanDiscovery)
- {
- this.resourceLoader = resourceLoader;
- this.weldDiscovery = webBeanDiscovery;
- }
-
- /**
- * @return the resourceLoader
- */
- public ResourceLoader getResourceLoader()
- {
- return resourceLoader;
- }
-
- /**
- * @return the webBeanDiscovery
- */
- public WeldSEBeanDeploymentArchive getWeldDiscovery()
- {
- return weldDiscovery;
- }
-
-}
Modified: java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/url/FileSystemURLHandler.java
===================================================================
--- java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/handlers/FileSystemURLHandler.java 2010-05-25 14:53:56 UTC (rev 6305)
+++ java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/url/FileSystemURLHandler.java 2010-05-25 17:52:01 UTC (rev 6306)
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.jboss.weld.environment.se.discovery.handlers;
+package org.jboss.weld.environment.se.discovery.url;
import java.io.File;
import java.io.IOException;
@@ -27,30 +27,28 @@
import java.util.zip.ZipFile;
import org.jboss.weld.environment.se.discovery.WeldSEBeanDeploymentArchive;
-import org.jboss.weld.environment.se.discovery.Scanner;
import org.jboss.weld.resources.spi.ResourceLoader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * Abstract base class for {@link Scanner} providing common functionality
- *
* This class provides file-system orientated scanning
*
* @author Pete Muir
*
*/
-public class FileSystemURLHandler extends AbstractURLHandler
+public class FileSystemURLHandler
{
private static final Logger log = LoggerFactory.getLogger(FileSystemURLHandler.class);
+ private final ResourceLoader resourceLoader;
- public FileSystemURLHandler(ResourceLoader resourceLoader, WeldSEBeanDeploymentArchive webBeanDiscovery)
+ public FileSystemURLHandler(ResourceLoader resourceLoader)
{
- super(resourceLoader, webBeanDiscovery);
+ this.resourceLoader = resourceLoader;
}
- public void handle(Collection<String> paths)
+ public void handle(Collection<String> paths, WeldSEBeanDeploymentArchive beanDeploymentArchive)
{
for (String urlPath : paths)
{
@@ -70,19 +68,21 @@
File file = new File(urlPath);
if (file.isDirectory())
{
- handleDirectory(file, null);
- } else
+ handleDirectory(file, null, beanDeploymentArchive);
+ }
+ else
{
- handleArchiveByFile(file);
+ handleArchiveByFile(file, beanDeploymentArchive);
}
- } catch (IOException ioe)
+ }
+ catch (IOException ioe)
{
FileSystemURLHandler.log.warn("could not read entries", ioe);
}
}
}
- private void handleArchiveByFile(File file) throws IOException
+ private void handleArchiveByFile(File file, WeldSEBeanDeploymentArchive beanDeploymentArchive) throws IOException
{
try
{
@@ -96,20 +96,21 @@
{
ZipEntry entry = entries.nextElement();
String name = entry.getName();
- handle(name, new URL(archiveUrl + name));
+ handle(name, new URL(archiveUrl + name), beanDeploymentArchive);
}
- } catch (ZipException e)
+ }
+ catch (ZipException e)
{
throw new RuntimeException("Error handling file " + file, e);
}
}
- protected void handleDirectory(File file, String path)
+ protected void handleDirectory(File file, String path, WeldSEBeanDeploymentArchive beanDeploymentArchive)
{
- handleDirectory(file, path, new File[0]);
+ handleDirectory(file, path, new File[0], beanDeploymentArchive);
}
- private void handleDirectory(File file, String path, File[] excludedDirectories)
+ private void handleDirectory(File file, String path, File[] excludedDirectories, WeldSEBeanDeploymentArchive beanDeploymentArchive)
{
for (File excludedDirectory : excludedDirectories)
{
@@ -129,13 +130,15 @@
if (child.isDirectory())
{
- handleDirectory(child, newPath, excludedDirectories);
- } else
+ handleDirectory(child, newPath, excludedDirectories, beanDeploymentArchive);
+ }
+ else
{
try
{
- handle(newPath, child.toURI().toURL());
- } catch (MalformedURLException e)
+ handle(newPath, child.toURI().toURL(), beanDeploymentArchive);
+ }
+ catch (MalformedURLException e)
{
log.error("Error loading file " + newPath);
}
@@ -143,25 +146,35 @@
}
}
- protected void handle(String name, URL url)
+ protected void handle(String name, URL url, WeldSEBeanDeploymentArchive beanDeploymentArchive)
{
if (name.endsWith(".class"))
{
String className = filenameToClassname(name);
try
{
- getWeldDiscovery().getBeanClasses().add(getResourceLoader().classForName(className));
- } catch (NoClassDefFoundError e)
+ beanDeploymentArchive.getBeanClasses().add(getResourceLoader().classForName(className));
+ }
+ catch (NoClassDefFoundError e)
{
log.error("Error loading " + name, e);
}
- } else if (name.endsWith("beans.xml"))
+ }
+ else if (name.endsWith("beans.xml"))
{
- getWeldDiscovery().getUrls().add(url);
+ beanDeploymentArchive.getUrls().add(url);
}
}
/**
+ * @return the resourceLoader
+ */
+ public ResourceLoader getResourceLoader()
+ {
+ return resourceLoader;
+ }
+
+ /**
* Convert a path to a class file to a class name
*/
public static String filenameToClassname(String filename)
Deleted: java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/url/URLHandler.java
===================================================================
--- java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/handlers/URLHandler.java 2010-05-25 14:53:56 UTC (rev 6305)
+++ java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/url/URLHandler.java 2010-05-25 17:52:01 UTC (rev 6306)
@@ -1,29 +0,0 @@
-/**
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat, Inc. and/or its affiliates, 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.environment.se.discovery.handlers;
-
-import java.util.Collection;
-
-/**
- * Interface for handling URL resolving.
- * @author Peter Royle
- */
-public interface URLHandler {
-
- void handle(Collection<String> paths);
-
-}
Copied: java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/url/URLScanner.java (from rev 6305, java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/URLScanner.java)
===================================================================
--- java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/url/URLScanner.java (rev 0)
+++ java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/url/URLScanner.java 2010-05-25 17:52:01 UTC (rev 6306)
@@ -0,0 +1,129 @@
+/**
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat, Inc. and/or its affiliates, 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.environment.se.discovery.url;
+
+import java.io.File;
+import java.io.UnsupportedEncodingException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.net.URLDecoder;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
+import org.jboss.weld.environment.se.discovery.Scanner;
+import org.jboss.weld.environment.se.discovery.WeldSEBeanDeploymentArchive;
+import org.jboss.weld.environment.se.exceptions.ClasspathScanningException;
+import org.jboss.weld.resources.spi.ResourceLoader;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Implementation of {@link Scanner} which can scan a {@link URLClassLoader}
+ *
+ * @author Thomas Heute
+ * @author Gavin King
+ * @author Norman Richards
+ * @author Pete Muir
+ * @author Peter Royle
+ *
+ */
+public class URLScanner implements Scanner
+{
+
+ private static final Logger log = LoggerFactory.getLogger(URLScanner.class);
+ private final WeldSEBeanDeploymentArchive beanDeploymentArchive;
+ private final String[] resources;
+
+ public URLScanner(String... resources)
+ {
+ this.beanDeploymentArchive = new WeldSEBeanDeploymentArchive("weld-se");
+ this.resources = resources;
+ }
+
+ public void scan(ResourceLoader resourceLoader)
+ {
+ FileSystemURLHandler handler = new FileSystemURLHandler(resourceLoader);
+ Collection<String> paths = new ArrayList<String>();
+ for (String resourceName : resources)
+ {
+ // grab all the URLs for this resource
+ Collection<URL> urlEnum = resourceLoader.getResources(resourceName);
+ for (URL url : urlEnum)
+ {
+
+ String urlPath = url.toExternalForm();
+
+ // determin resource type (eg: jar, file, bundle)
+ String urlType = "file";
+ int colonIndex = urlPath.indexOf(":");
+ if (colonIndex != -1)
+ {
+ urlType = urlPath.substring(0, colonIndex);
+ }
+
+ // Extra built-in support for simple file-based resources
+ if ("file".equals(urlType) || "jar".equals(urlType))
+ {
+ // switch to using getPath() instead of toExternalForm()
+ urlPath = url.getPath();
+
+ if (urlPath.indexOf('!') > 0)
+ {
+ urlPath = urlPath.substring(0, urlPath.indexOf('!'));
+ }
+ else
+ {
+ // hack for /META-INF/beans.xml
+ File dirOrArchive = new File(urlPath);
+ if ((resourceName != null) && (resourceName.lastIndexOf('/') > 0))
+ {
+ dirOrArchive = dirOrArchive.getParentFile();
+ }
+ urlPath = dirOrArchive.getParent();
+ }
+ }
+
+ try
+ {
+ urlPath = URLDecoder.decode(urlPath, "UTF-8");
+ }
+ catch (UnsupportedEncodingException ex)
+ {
+ throw new ClasspathScanningException("Error decoding URL using UTF-8");
+ }
+
+ log.debug("URL Type: " + urlType);
+
+ paths.add(urlPath);
+ }
+ handler.handle(paths, beanDeploymentArchive);
+ }
+ }
+
+ public BeanDeploymentArchive getBeanDeploymentArchive(Class<?> clazz)
+ {
+ return beanDeploymentArchive;
+ }
+
+ public List<BeanDeploymentArchive> getBeanDeploymentArchives()
+ {
+ return Collections.<BeanDeploymentArchive>singletonList(beanDeploymentArchive);
+ }
+}
Added: java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/url/WeldSEResourceLoader.java
===================================================================
--- java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/url/WeldSEResourceLoader.java (rev 0)
+++ java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/url/WeldSEResourceLoader.java 2010-05-25 17:52:01 UTC (rev 6306)
@@ -0,0 +1,96 @@
+/*
+ * 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.environment.se.discovery.url;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.Collection;
+
+import org.jboss.weld.resources.spi.ResourceLoader;
+import org.jboss.weld.resources.spi.ResourceLoadingException;
+import org.jboss.weld.util.collections.EnumerationList;
+
+/**
+ * A simple resource loader.
+ *
+ * Uses {@link WeldSEResourceLoader}'s classloader if the Thread Context
+ * Classloader isn't available
+ *
+ * @author Pete Muir
+ *
+ */
+public class WeldSEResourceLoader implements ResourceLoader
+{
+
+ public Class<?> classForName(String name)
+ {
+
+ try
+ {
+ if (Thread.currentThread().getContextClassLoader() != null)
+ {
+ return Thread.currentThread().getContextClassLoader().loadClass(name);
+ }
+ else
+ {
+ return Class.forName(name);
+ }
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new ResourceLoadingException(e);
+ }
+ catch (NoClassDefFoundError e)
+ {
+ throw new ResourceLoadingException(e);
+ }
+ }
+
+ public URL getResource(String name)
+ {
+ if (Thread.currentThread().getContextClassLoader() != null)
+ {
+ return Thread.currentThread().getContextClassLoader().getResource(name);
+ }
+ else
+ {
+ return getClass().getResource(name);
+ }
+ }
+
+ public Collection<URL> getResources(String name)
+ {
+ try
+ {
+ if (Thread.currentThread().getContextClassLoader() != null)
+ {
+ return new EnumerationList<URL>(Thread.currentThread().getContextClassLoader().getResources(name));
+ }
+ else
+ {
+ return new EnumerationList<URL>(getClass().getClassLoader().getResources(name));
+ }
+ }
+ catch (IOException e)
+ {
+ throw new ResourceLoadingException(e);
+ }
+ }
+
+ public void cleanup() {}
+
+}
Property changes on: java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/url/WeldSEResourceLoader.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified: java-se/trunk/src/test/java/org/jboss/weld/environment/se/test/DecoratorsTest.java
===================================================================
--- java-se/trunk/src/test/java/org/jboss/weld/environment/se/test/DecoratorsTest.java 2010-05-25 14:53:56 UTC (rev 6305)
+++ java-se/trunk/src/test/java/org/jboss/weld/environment/se/test/DecoratorsTest.java 2010-05-25 17:52:01 UTC (rev 6306)
@@ -16,13 +16,11 @@
*/
package org.jboss.weld.environment.se.test;
-import javax.enterprise.inject.spi.BeanManager;
-
import org.jboss.weld.environment.se.ShutdownManager;
import org.jboss.weld.environment.se.Weld;
import org.jboss.weld.environment.se.WeldContainer;
-import org.jboss.weld.environment.se.test.decorators.CarDoor;
import org.jboss.weld.environment.se.test.decorators.AbstractDoor;
+import org.jboss.weld.environment.se.test.decorators.CarDoor;
import org.jboss.weld.environment.se.test.decorators.CarDoorAlarm;
import org.jboss.weld.environment.se.test.decorators.HouseDoor;
import org.testng.Assert;
@@ -41,9 +39,7 @@
@Test
public void testDecorators()
{
-
WeldContainer weld = new Weld().initialize();
- BeanManager manager = weld.getBeanManager();
CarDoor carDoor = weld.instance().select(CarDoor.class).get();
Assert.assertNotNull(carDoor);
13 years, 11 months
Weld SVN: r6305 - core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy.
by weld-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2010-05-25 10:53:56 -0400 (Tue, 25 May 2010)
New Revision: 6305
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/ProxyFactory.java
Log:
oops
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/ProxyFactory.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/ProxyFactory.java 2010-05-25 13:39:38 UTC (rev 6304)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/ProxyFactory.java 2010-05-25 14:53:56 UTC (rev 6305)
@@ -91,7 +91,6 @@
public ProxyFactory(Class<?> proxiedBeanType)
{
this.beanType = proxiedBeanType;
- ClassLoader originalClassLoader = proxiedBeanType.getClassLoader();
this.classLoader = Container.instance().services().get(ProxyServices.class).getClassLoader(beanType);
this.protectionDomain = Container.instance().services().get(ProxyServices.class).getProtectionDomain(beanType);
this.classPool = new ClassPool();
13 years, 11 months
Weld SVN: r6304 - in java-se/trunk/src/main/java/org/jboss/weld/environment/se: discovery and 1 other directories.
by weld-commits@lists.jboss.org
Author: peteroyle
Date: 2010-05-25 09:39:38 -0400 (Tue, 25 May 2010)
New Revision: 6304
Added:
java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/NewSEWeldDeployment.java
java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/WeldSEBeanDeploymentArchive.java
Removed:
java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/SEBeanDeploymentArchive.java
java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/SEWeldDeployment.java
java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/SEWeldDiscovery.java
Modified:
java-se/trunk/src/main/java/org/jboss/weld/environment/se/Weld.java
java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/AbstractScanner.java
java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/URLScanner.java
java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/handlers/AbstractURLHandler.java
java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/handlers/FileSystemURLHandler.java
Log:
WELDSE-25: changed customiseDeployment(...) to createDeployment(...)
WELDSE-25, WELDSE-26: Weld now exposes a discoverBeansAndResources(Deployment) method which can be overridden in order to pass a customised set of discovered bean classes and resources to the Weld bootstrap. The old file-based Scanner code is used by default.
Modified: java-se/trunk/src/main/java/org/jboss/weld/environment/se/Weld.java
===================================================================
--- java-se/trunk/src/main/java/org/jboss/weld/environment/se/Weld.java 2010-05-25 12:09:35 UTC (rev 6303)
+++ java-se/trunk/src/main/java/org/jboss/weld/environment/se/Weld.java 2010-05-25 13:39:38 UTC (rev 6304)
@@ -24,9 +24,8 @@
import org.jboss.weld.context.api.BeanStore;
import org.jboss.weld.context.api.helpers.ConcurrentHashMapBeanStore;
import org.jboss.weld.environment.se.beans.InstanceManager;
-import org.jboss.weld.environment.se.discovery.SEBeanDeploymentArchive;
-import org.jboss.weld.environment.se.discovery.SEWeldDeployment;
-import org.jboss.weld.environment.se.discovery.SEWeldDiscovery;
+import org.jboss.weld.environment.se.discovery.NewSEWeldDeployment;
+import org.jboss.weld.environment.se.discovery.WeldSEBeanDeploymentArchive;
import org.jboss.weld.environment.se.discovery.URLScanner;
import org.jboss.weld.environment.se.util.WeldManagerUtils;
import org.jboss.weld.manager.api.WeldManager;
@@ -50,11 +49,7 @@
{
private static final String BOOTSTRAP_IMPL_CLASS_NAME = "org.jboss.weld.bootstrap.WeldBootstrap";
- private Bootstrap bootstrap;
- private BeanStore applicationBeanStore;
private WeldManager manager;
- private SEWeldDiscovery discovery;
- private SEBeanDeploymentArchive beanDeploymentArchive;
public Weld()
{
@@ -62,15 +57,16 @@
/**
* Boots Weld and creates and returns a WeldContainer instance, through which
- * beans and events can be accesed.
+ * beans and events can be accessed.
*/
@PostConstruct
public WeldContainer initialize()
{
- this.applicationBeanStore = new ConcurrentHashMapBeanStore();
- SEWeldDeployment deployment = initDeployment();
+ BeanStore applicationBeanStore = new ConcurrentHashMapBeanStore();
+ Deployment deployment = createDeployment();
+ Bootstrap bootstrap = null;
try
{
bootstrap = (Bootstrap) deployment.getServices().get(ResourceLoader.class).classForName(BOOTSTRAP_IMPL_CLASS_NAME).newInstance();
@@ -82,16 +78,12 @@
throw new IllegalStateException("Error loading Weld bootstrap, check that Weld is on the classpath", ex);
}
- final ResourceLoader resourceLoader = deployment.getServices().get(ResourceLoader.class);
- URLScanner scanner = new URLScanner(resourceLoader, discovery);
- configureURLHandlers(scanner, resourceLoader, discovery);
- scanner.scanResources(new String[]
- {
- "META-INF/beans.xml"
- });
+ BeanDeploymentArchive discovery = discoverBeansAndResources(deployment);
+ // transfer discovered classes and resources to the deployment in a single BeanDeploymentArchive
+ deployment.getBeanDeploymentArchives().add(discovery);
- bootstrap.startContainer(Environments.SE, deployment, this.applicationBeanStore);
- final BeanDeploymentArchive mainBeanDepArch = deployment.getBeanDeploymentArchives().get(0);
+ bootstrap.startContainer(Environments.SE, deployment, applicationBeanStore);
+ final BeanDeploymentArchive mainBeanDepArch = deployment.getBeanDeploymentArchives().iterator().next();
this.manager = bootstrap.getManager(mainBeanDepArch);
bootstrap.startInitialization();
bootstrap.deployBeans();
@@ -105,53 +97,41 @@
}
- /**
- * Clients can subclass and override this method to add custom URL handlers
- * before weld boots up. For example, to set a custom URL handler for OSGi bundles,
- * you would subclass Weld like so:
- * <code>
- * public class MyWeld extends Weld {
- * @Override
- * public void configureURLHandlers(URLScanner scanner, ResourceLoader resourceLoader, SEWeldDiscovery discovery)
- * scanner.setURLHandler("bundle", new MyOSGiURLHandler(resourceLoader, discovery));
- * }
- * }
- * </code>
+ /*
+ * Users can subclass and override this method to customise the classes and
+ * resources that Weld finds when it boots up.
*/
- public void configureURLHandlers(URLScanner scanner, ResourceLoader resourceLoader, SEWeldDiscovery discovery)
+ protected BeanDeploymentArchive discoverBeansAndResources(Deployment deployment)
{
+ WeldSEBeanDeploymentArchive discovery = new WeldSEBeanDeploymentArchive("weld-se-main-archive");
+ final ResourceLoader resourceLoader = deployment.getServices().get(ResourceLoader.class);
+ URLScanner scanner = new URLScanner(resourceLoader, discovery);
+ scanner.scanResources(new String[]
+ {
+ "META-INF/beans.xml"
+ });
+ return discovery;
}
- private SEWeldDeployment initDeployment()
- {
- discovery = new SEWeldDiscovery();
- beanDeploymentArchive = new SEBeanDeploymentArchive(discovery);
- SEWeldDeployment deployment = new SEWeldDeployment(beanDeploymentArchive);
- configureDeployment(deployment);
- // configure a ResourceLoader if one hasn't been already
- if (deployment.getServices().get(ResourceLoader.class) == null)
- {
- deployment.getServices().add(ResourceLoader.class, new DefaultResourceLoader());
- }
- return deployment;
- }
-
/**
- * Clients can subclass and override this method to customise the deployment
+ * Users can subclass and override this method to customise the deployment
* before weld boots up. For example, to add a custom ResourceLoader, you would
* subclass Weld like so:
* <code>
* public class MyWeld extends Weld {
* @Override
- * protected void configureDeployment(Deployment deployment) {
+ * protected void createDeployment() {
+ * Deployment myDeployment = new MyDeployment();
* deployment.getServices().add(ResourceLoader.class, new OSGIResourceLoader());
* }
* }
* </code>
- * @param deployment
*/
- protected void configureDeployment(Deployment deployment)
+ private Deployment createDeployment()
{
+ NewSEWeldDeployment deployment = new NewSEWeldDeployment();
+ deployment.getServices().add(ResourceLoader.class, new DefaultResourceLoader());
+ return deployment;
}
/**
Modified: java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/AbstractScanner.java
===================================================================
--- java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/AbstractScanner.java 2010-05-25 12:09:35 UTC (rev 6303)
+++ java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/AbstractScanner.java 2010-05-25 13:39:38 UTC (rev 6304)
@@ -26,9 +26,9 @@
{
private final ResourceLoader resourceLoader;
- private final SEWeldDiscovery weldDiscovery;
+ private final WeldSEBeanDeploymentArchive weldDiscovery;
- public AbstractScanner(ResourceLoader resourceLoader, SEWeldDiscovery webBeanDiscovery)
+ public AbstractScanner(ResourceLoader resourceLoader, WeldSEBeanDeploymentArchive webBeanDiscovery)
{
this.resourceLoader = resourceLoader;
this.weldDiscovery = webBeanDiscovery;
@@ -43,7 +43,7 @@
/**
* @return the webBeanDiscovery
*/
- public SEWeldDiscovery getWebBeanDiscovery()
+ public WeldSEBeanDeploymentArchive getWebBeanDiscovery()
{
return weldDiscovery;
}
Added: java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/NewSEWeldDeployment.java
===================================================================
--- java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/NewSEWeldDeployment.java (rev 0)
+++ java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/NewSEWeldDeployment.java 2010-05-25 13:39:38 UTC (rev 6304)
@@ -0,0 +1,68 @@
+/**
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat, Inc. and/or its affiliates, 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.environment.se.discovery;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.jboss.weld.bootstrap.api.ServiceRegistry;
+import org.jboss.weld.bootstrap.api.helpers.SimpleServiceRegistry;
+import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
+import org.jboss.weld.bootstrap.spi.Deployment;
+
+/**
+ * Weld Deployment for Java SE environment.
+ *
+ * @author Peter Royle
+ */
+public class NewSEWeldDeployment implements Deployment
+{
+
+ final List<BeanDeploymentArchive> beanDeploymentArchives = new ArrayList<BeanDeploymentArchive>();
+ final ServiceRegistry serviceRegistry = new SimpleServiceRegistry();
+
+ public NewSEWeldDeployment()
+ {
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @return A collection containing the singular logical BeanDeploymentArchive
+ * consisting of all Bean classes and beans.xml descriptors in the
+ * current classpath.
+ */
+ public List<BeanDeploymentArchive> getBeanDeploymentArchives()
+ {
+ return beanDeploymentArchives;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public BeanDeploymentArchive loadBeanDeploymentArchive(Class<?> beanClass)
+ {
+ // TODO (PR) (WELDSE-26): This is just a hack. What do we really need to do here?
+ return beanDeploymentArchives.get(0);
+ }
+
+ public ServiceRegistry getServices()
+ {
+ // TODO (PR) (WELDSE-26): Do I need to aggregate all services from all bean archives?
+ return serviceRegistry;
+ }
+
+}
Deleted: java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/SEBeanDeploymentArchive.java
===================================================================
--- java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/SEBeanDeploymentArchive.java 2010-05-25 12:09:35 UTC (rev 6303)
+++ java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/SEBeanDeploymentArchive.java 2010-05-25 13:39:38 UTC (rev 6304)
@@ -1,96 +0,0 @@
-/**
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat, Inc. and/or its affiliates, 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.environment.se.discovery;
-
-import java.net.URL;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-
-import org.jboss.weld.bootstrap.api.ServiceRegistry;
-import org.jboss.weld.bootstrap.api.helpers.SimpleServiceRegistry;
-import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
-import org.jboss.weld.ejb.spi.EjbDescriptor;
-
-/**
- * A Java SE implementation of BeanDeploymentArchive. It is essentially an
- * adaptor from the SEWeldDiscovery to the BeanDeploymentArchive interface.
- * It returns, in a single logical archive, all Bean classes and beans.xml
- * descriptors. It always returns an empty collection of EJBs.
- *
- * @author Peter Royle
- */
-public class SEBeanDeploymentArchive implements BeanDeploymentArchive
-{
- private final SEWeldDiscovery wbDiscovery;
- private final ServiceRegistry serviceRegistry;
-
- /**
- * @param deployment Used to gain access to the ResourceLoader, in case one is defined.
- */
- public SEBeanDeploymentArchive(SEWeldDiscovery discovery)
- {
- this.wbDiscovery = discovery;
- {
- };
- this.serviceRegistry = new SimpleServiceRegistry();
- }
-
- /**
- * @return a collection of all Bean classes on the classpath.
- */
- public Collection<Class<?>> getBeanClasses()
- {
- return wbDiscovery.getWbClasses();
- }
-
- /**
- * @return an empty collection, since this instance is the only logical
- * archive for the current SE classloader.
- */
- public List<BeanDeploymentArchive> getBeanDeploymentArchives()
- {
- return Collections.EMPTY_LIST;
- }
-
- /**
- * @return all beans.xml decriptors found on the classpath.
- */
- public Collection<URL> getBeansXml()
- {
- return wbDiscovery.discoverWeldXml();
- }
-
- /**
- * @return an empty collection since there are no EJBs in Java SE.
- */
- public Collection<EjbDescriptor<?>> getEjbs()
- {
- return Collections.EMPTY_SET;
- }
-
- public ServiceRegistry getServices()
- {
- return this.serviceRegistry;
- }
-
- public String getId()
- {
- return "se-module";
- }
-
-}
Deleted: java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/SEWeldDeployment.java
===================================================================
--- java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/SEWeldDeployment.java 2010-05-25 12:09:35 UTC (rev 6303)
+++ java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/SEWeldDeployment.java 2010-05-25 13:39:38 UTC (rev 6304)
@@ -1,69 +0,0 @@
-/**
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat, Inc. and/or its affiliates, 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.environment.se.discovery;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.jboss.weld.bootstrap.api.ServiceRegistry;
-import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
-import org.jboss.weld.bootstrap.spi.Deployment;
-
-/**
- * Weld Deployment for Java SE environment.
- *
- * @author Peter Royle
- */
-public class SEWeldDeployment implements Deployment
-{
- private final SEBeanDeploymentArchive beanDeploymentArchive;
- private final List<BeanDeploymentArchive> archInCollection;
-
- public SEWeldDeployment(SEBeanDeploymentArchive beanDeploymentArchive)
- {
- this.beanDeploymentArchive = beanDeploymentArchive;
- this.archInCollection = new ArrayList<BeanDeploymentArchive>(1);
- this.archInCollection.add(this.beanDeploymentArchive);
- }
-
- /**
- * {@inheritDoc}
- *
- * @return A collection containing the singular logical BeanDeploymentArchive
- * consisting of all Bean classes and beans.xml descriptors in the
- * current classpath.
- */
- public List<BeanDeploymentArchive> getBeanDeploymentArchives()
- {
- return this.archInCollection;
- }
-
- /**
- * {@inheritDoc}
- *
- * @return The singular logical BeanDeploymentArchive consisting of all which
- * contains all Beans classes.
- */
- public BeanDeploymentArchive loadBeanDeploymentArchive(Class<?> beanClass)
- {
- return this.beanDeploymentArchive;
- }
-
- public ServiceRegistry getServices()
- {
- return this.beanDeploymentArchive.getServices();
- }
-}
Deleted: java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/SEWeldDiscovery.java
===================================================================
--- java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/SEWeldDiscovery.java 2010-05-25 12:09:35 UTC (rev 6303)
+++ java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/SEWeldDiscovery.java 2010-05-25 13:39:38 UTC (rev 6304)
@@ -1,66 +0,0 @@
-/**
- * JBoss, Home of Professional Open Source
- * Copyright 2009, Red Hat, Inc. and/or its affiliates, 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.environment.se.discovery;
-
-import java.net.URL;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
-
-/**
- * The means by which beans are discovered on the classpath. This will only
- * discover simple beans - there is no EJB/Servlet/JPA integration.
- *
- * @author Peter Royle
- * @author Pete Muir
- * @author Ales Justin
- */
-public class SEWeldDiscovery
-{
-
- private final Set<Class<?>> wbClasses;
- private final Set<URL> wbUrls;
-
- public SEWeldDiscovery()
- {
- this.wbClasses = new HashSet<Class<?>>();
- this.wbUrls = new HashSet<URL>();
- }
-
- public Iterable<Class<?>> discoverWeldClasses()
- {
- return Collections.unmodifiableSet(wbClasses);
- }
-
- public Collection<URL> discoverWeldXml()
- {
- return Collections.unmodifiableSet(wbUrls);
- }
-
- public Set<Class<?>> getWbClasses()
- {
- return wbClasses;
- }
-
- public Set<URL> getWbUrls()
- {
- return wbUrls;
- }
-
-}
Modified: java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/URLScanner.java
===================================================================
--- java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/URLScanner.java 2010-05-25 12:09:35 UTC (rev 6303)
+++ java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/URLScanner.java 2010-05-25 13:39:38 UTC (rev 6304)
@@ -53,7 +53,7 @@
private final Map<String, URLHandler> urlHandlers = new HashMap<String, URLHandler>();
private static final Logger log = LoggerFactory.getLogger(URLScanner.class);
- public URLScanner(ResourceLoader resourceLoader, SEWeldDiscovery weldDiscovery)
+ public URLScanner(ResourceLoader resourceLoader, WeldSEBeanDeploymentArchive weldDiscovery)
{
super(resourceLoader, weldDiscovery);
URLHandler fileSysHandler = new FileSystemURLHandler(resourceLoader, weldDiscovery);
Copied: java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/WeldSEBeanDeploymentArchive.java (from rev 6301, java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/SEWeldDiscovery.java)
===================================================================
--- java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/WeldSEBeanDeploymentArchive.java (rev 0)
+++ java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/WeldSEBeanDeploymentArchive.java 2010-05-25 13:39:38 UTC (rev 6304)
@@ -0,0 +1,102 @@
+/**
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat, Inc. and/or its affiliates, 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.environment.se.discovery;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import org.jboss.weld.bootstrap.api.ServiceRegistry;
+import org.jboss.weld.bootstrap.api.helpers.SimpleServiceRegistry;
+import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive;
+import org.jboss.weld.ejb.spi.EjbDescriptor;
+
+/**
+ * A deployment archive to registering classes and resources found in bean
+ * archives on the classpath.
+ *
+ * @author Peter Royle
+ * @author Pete Muir
+ * @author Ales Justin
+ */
+public class WeldSEBeanDeploymentArchive implements BeanDeploymentArchive
+{
+
+ private final Collection<Class<?>> weldClasses;
+ private final Collection<URL> weldUrls;
+ private final ServiceRegistry serviceRegistry;
+ private final List<BeanDeploymentArchive> beanDeploymentArchives;
+ private String id;
+
+ public WeldSEBeanDeploymentArchive(String id)
+ {
+ this.id = id;
+ this.weldClasses = new HashSet<Class<?>>();
+ this.weldUrls = new HashSet<URL>();
+ this.serviceRegistry = new SimpleServiceRegistry();
+ this.beanDeploymentArchives = new ArrayList<BeanDeploymentArchive>();
+ }
+
+ /**
+ * This is an alias for getBeansXml(), to make adding resources other than
+ * beans.xml more natural.
+ */
+ public Collection<URL> getUrls()
+ {
+ return weldUrls;
+ }
+
+ public Collection<Class<?>> getBeanClasses()
+ {
+ return weldClasses;
+ }
+
+ public Collection<BeanDeploymentArchive> getBeanDeploymentArchives()
+ {
+ return this.beanDeploymentArchives;
+ }
+
+ public Collection<URL> getBeansXml()
+ {
+ return weldUrls;
+ }
+
+ public Collection<EjbDescriptor<?>> getEjbs()
+ {
+ return Collections.EMPTY_SET;
+ }
+
+ public String getId()
+ {
+ return this.id;
+ }
+
+ /**
+ * @param id the id to set
+ */
+ public void setId(String id)
+ {
+ this.id = id;
+ }
+
+ public ServiceRegistry getServices()
+ {
+ return this.serviceRegistry;
+ }
+}
Modified: java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/handlers/AbstractURLHandler.java
===================================================================
--- java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/handlers/AbstractURLHandler.java 2010-05-25 12:09:35 UTC (rev 6303)
+++ java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/handlers/AbstractURLHandler.java 2010-05-25 13:39:38 UTC (rev 6304)
@@ -16,7 +16,7 @@
*/
package org.jboss.weld.environment.se.discovery.handlers;
-import org.jboss.weld.environment.se.discovery.SEWeldDiscovery;
+import org.jboss.weld.environment.se.discovery.WeldSEBeanDeploymentArchive;
import org.jboss.weld.resources.spi.ResourceLoader;
/**
@@ -27,9 +27,9 @@
{
private final ResourceLoader resourceLoader;
- private final SEWeldDiscovery weldDiscovery;
+ private final WeldSEBeanDeploymentArchive weldDiscovery;
- public AbstractURLHandler(ResourceLoader resourceLoader, SEWeldDiscovery webBeanDiscovery)
+ public AbstractURLHandler(ResourceLoader resourceLoader, WeldSEBeanDeploymentArchive webBeanDiscovery)
{
this.resourceLoader = resourceLoader;
this.weldDiscovery = webBeanDiscovery;
@@ -46,7 +46,7 @@
/**
* @return the webBeanDiscovery
*/
- public SEWeldDiscovery getWeldDiscovery()
+ public WeldSEBeanDeploymentArchive getWeldDiscovery()
{
return weldDiscovery;
}
Modified: java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/handlers/FileSystemURLHandler.java
===================================================================
--- java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/handlers/FileSystemURLHandler.java 2010-05-25 12:09:35 UTC (rev 6303)
+++ java-se/trunk/src/main/java/org/jboss/weld/environment/se/discovery/handlers/FileSystemURLHandler.java 2010-05-25 13:39:38 UTC (rev 6304)
@@ -26,7 +26,7 @@
import java.util.zip.ZipException;
import java.util.zip.ZipFile;
-import org.jboss.weld.environment.se.discovery.SEWeldDiscovery;
+import org.jboss.weld.environment.se.discovery.WeldSEBeanDeploymentArchive;
import org.jboss.weld.environment.se.discovery.Scanner;
import org.jboss.weld.resources.spi.ResourceLoader;
import org.slf4j.Logger;
@@ -45,7 +45,7 @@
private static final Logger log = LoggerFactory.getLogger(FileSystemURLHandler.class);
- public FileSystemURLHandler(ResourceLoader resourceLoader, SEWeldDiscovery webBeanDiscovery)
+ public FileSystemURLHandler(ResourceLoader resourceLoader, WeldSEBeanDeploymentArchive webBeanDiscovery)
{
super(resourceLoader, webBeanDiscovery);
}
@@ -150,14 +150,14 @@
String className = filenameToClassname(name);
try
{
- getWeldDiscovery().getWbClasses().add(getResourceLoader().classForName(className));
+ getWeldDiscovery().getBeanClasses().add(getResourceLoader().classForName(className));
} catch (NoClassDefFoundError e)
{
log.error("Error loading " + name, e);
}
} else if (name.endsWith("beans.xml"))
{
- getWeldDiscovery().getWbUrls().add(url);
+ getWeldDiscovery().getUrls().add(url);
}
}
13 years, 11 months
Weld SVN: r6303 - in cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/packaging/bundledLibrary: libraryBeans and 1 other directory.
by weld-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2010-05-25 08:09:35 -0400 (Tue, 25 May 2010)
New Revision: 6303
Added:
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/packaging/bundledLibrary/libraryBeans/
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/packaging/bundledLibrary/libraryBeans/Bar.java
Removed:
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/packaging/bundledLibrary/Bar.java
Modified:
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/packaging/bundledLibrary/LibraryInEarTest.java
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/packaging/bundledLibrary/LibraryInWarTest.java
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/packaging/bundledLibrary/LibraryMissingBeansXmlTest.java
Log:
Better fix for CDITCK-150
Deleted: cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/packaging/bundledLibrary/Bar.java
===================================================================
--- cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/packaging/bundledLibrary/Bar.java 2010-05-25 11:31:33 UTC (rev 6302)
+++ cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/packaging/bundledLibrary/Bar.java 2010-05-25 12:09:35 UTC (rev 6303)
@@ -1,26 +0,0 @@
-/*
- * 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.
- *
- * 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.jsr299.tck.tests.deployment.packaging.bundledLibrary;
-
-/**
- * @author pmuir
- *
- */
-public class Bar
-{
-
-}
Modified: cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/packaging/bundledLibrary/LibraryInEarTest.java
===================================================================
--- cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/packaging/bundledLibrary/LibraryInEarTest.java 2010-05-25 11:31:33 UTC (rev 6302)
+++ cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/packaging/bundledLibrary/LibraryInEarTest.java 2010-05-25 12:09:35 UTC (rev 6303)
@@ -18,14 +18,15 @@
package org.jboss.jsr299.tck.tests.deployment.packaging.bundledLibrary;
import java.io.IOException;
+import java.util.Arrays;
import org.jboss.jsr299.tck.AbstractJSR299Test;
+import org.jboss.jsr299.tck.tests.deployment.packaging.bundledLibrary.libraryBeans.Bar;
import org.jboss.test.audit.annotations.SpecAssertion;
import org.jboss.test.audit.annotations.SpecAssertions;
import org.jboss.test.audit.annotations.SpecVersion;
import org.jboss.testharness.impl.packaging.Artifact;
import org.jboss.testharness.impl.packaging.ArtifactDescriptor;
-import org.jboss.testharness.impl.packaging.Classes;
import org.jboss.testharness.impl.packaging.IntegrationTest;
import org.jboss.testharness.impl.packaging.Packaging;
import org.jboss.testharness.impl.packaging.PackagingType;
@@ -39,9 +40,7 @@
*
* @author David Allen
*/
-@Artifact(addCurrentPackage=false)
-// We put Foo in the ejb jar, but Bar goes in the library
-(a)Classes({LibraryInEarTest.class, Foo.class, Baz.class, BazLocal.class})
+@Artifact
@Test
@SpecVersion(spec="cdi", version="20091101")
@IntegrationTest
@@ -54,7 +53,7 @@
{
super.postCreate(artifact);
ArtifactDescriptor library = new ArtifactDescriptor(LibraryInEarTest.class);
- library.getClasses().add(Bar.class);
+ library.getClasses().addAll(Arrays.asList(Bar.class));
library.getResources().add(new ResourceDescriptorImpl(JSR299ArtifactDescriptor.BEANS_XML_DESTINATION, JSR299ArtifactDescriptor.STANDARD_BEANS_XML_FILE_NAME));
artifact.getLibraries().add(new ResourceDescriptorImpl("cdi-tck-beans.jar", library.getJarAsStream()));
return artifact;
Modified: cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/packaging/bundledLibrary/LibraryInWarTest.java
===================================================================
--- cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/packaging/bundledLibrary/LibraryInWarTest.java 2010-05-25 11:31:33 UTC (rev 6302)
+++ cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/packaging/bundledLibrary/LibraryInWarTest.java 2010-05-25 12:09:35 UTC (rev 6303)
@@ -20,6 +20,7 @@
import java.io.IOException;
import org.jboss.jsr299.tck.AbstractJSR299Test;
+import org.jboss.jsr299.tck.tests.deployment.packaging.bundledLibrary.libraryBeans.Bar;
import org.jboss.test.audit.annotations.SpecAssertion;
import org.jboss.test.audit.annotations.SpecAssertions;
import org.jboss.test.audit.annotations.SpecVersion;
Modified: cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/packaging/bundledLibrary/LibraryMissingBeansXmlTest.java
===================================================================
--- cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/packaging/bundledLibrary/LibraryMissingBeansXmlTest.java 2010-05-25 11:31:33 UTC (rev 6302)
+++ cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/packaging/bundledLibrary/LibraryMissingBeansXmlTest.java 2010-05-25 12:09:35 UTC (rev 6303)
@@ -20,6 +20,7 @@
import java.io.IOException;
import org.jboss.jsr299.tck.AbstractJSR299Test;
+import org.jboss.jsr299.tck.tests.deployment.packaging.bundledLibrary.libraryBeans.Bar;
import org.jboss.test.audit.annotations.SpecAssertion;
import org.jboss.test.audit.annotations.SpecAssertions;
import org.jboss.test.audit.annotations.SpecVersion;
Copied: cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/packaging/bundledLibrary/libraryBeans/Bar.java (from rev 6300, cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/packaging/bundledLibrary/Bar.java)
===================================================================
--- cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/packaging/bundledLibrary/libraryBeans/Bar.java (rev 0)
+++ cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/deployment/packaging/bundledLibrary/libraryBeans/Bar.java 2010-05-25 12:09:35 UTC (rev 6303)
@@ -0,0 +1,26 @@
+/*
+ * 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.
+ *
+ * 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.jsr299.tck.tests.deployment.packaging.bundledLibrary.libraryBeans;
+
+/**
+ * @author pmuir
+ *
+ */
+public class Bar
+{
+
+}
13 years, 11 months