[weld-commits] Weld SVN: r6199 - in extensions/trunk/src/main: java/org/jboss/weld/extensions/core and 2 other directories.

weld-commits at lists.jboss.org weld-commits at lists.jboss.org
Thu Apr 29 16:22:23 EDT 2010


Author: pete.muir at jboss.org
Date: 2010-04-29 16:22:21 -0400 (Thu, 29 Apr 2010)
New Revision: 6199

Added:
   extensions/trunk/src/main/java/org/jboss/weld/extensions/core/
   extensions/trunk/src/main/java/org/jboss/weld/extensions/core/Constructs.java
   extensions/trunk/src/main/java/org/jboss/weld/extensions/core/CoreExtension.java
   extensions/trunk/src/main/java/org/jboss/weld/extensions/core/DefaultLiteral.java
   extensions/trunk/src/main/java/org/jboss/weld/extensions/core/Exact.java
   extensions/trunk/src/main/java/org/jboss/weld/extensions/core/InjectLiteral.java
   extensions/trunk/src/main/java/org/jboss/weld/extensions/core/NamedLiteral.java
   extensions/trunk/src/main/java/org/jboss/weld/extensions/core/Veto.java
   extensions/trunk/src/main/java/org/jboss/weld/extensions/resourceLoader/Resource.java
Removed:
   extensions/trunk/src/main/java/org/jboss/weld/extensions/Constructs.java
   extensions/trunk/src/main/java/org/jboss/weld/extensions/CoreExtension.java
   extensions/trunk/src/main/java/org/jboss/weld/extensions/DefaultLiteral.java
   extensions/trunk/src/main/java/org/jboss/weld/extensions/Exact.java
   extensions/trunk/src/main/java/org/jboss/weld/extensions/InjectLiteral.java
   extensions/trunk/src/main/java/org/jboss/weld/extensions/NamedLiteral.java
   extensions/trunk/src/main/java/org/jboss/weld/extensions/Resource.java
   extensions/trunk/src/main/java/org/jboss/weld/extensions/Veto.java
Modified:
   extensions/trunk/src/main/java/org/jboss/weld/extensions/resourceLoader/ResourceProducer.java
   extensions/trunk/src/main/java/org/jboss/weld/extensions/resourceLoader/ResourceProvider.java
   extensions/trunk/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension
Log:
move core extensions to core

Deleted: extensions/trunk/src/main/java/org/jboss/weld/extensions/Constructs.java
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/Constructs.java	2010-04-29 20:14:14 UTC (rev 6198)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/Constructs.java	2010-04-29 20:22:21 UTC (rev 6199)
@@ -1,37 +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.weld.extensions;
-
-import static java.lang.annotation.ElementType.CONSTRUCTOR;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-/**
- * Allows a bean to be defined by annotating a constructor instead
- * of the bean class. There may be multiple beans defined using
- * <tt>@Constructs</tt> per bean class.
- * 
- * @author Gavin King
- *
- */
- at Retention(RUNTIME)
- at Target(CONSTRUCTOR)
- at Documented
-public @interface Constructs {}

Deleted: extensions/trunk/src/main/java/org/jboss/weld/extensions/CoreExtension.java
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/CoreExtension.java	2010-04-29 20:14:14 UTC (rev 6198)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/CoreExtension.java	2010-04-29 20:22:21 UTC (rev 6199)
@@ -1,200 +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.weld.extensions;
-
-import static org.jboss.weld.extensions.util.ReflectionUtils.getAnnotationsWithMetatype;
-import static org.jboss.weld.extensions.util.ReflectionUtils.getMemberType;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Member;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Set;
-
-import javax.enterprise.event.Observes;
-import javax.enterprise.inject.Produces;
-import javax.enterprise.inject.spi.AfterBeanDiscovery;
-import javax.enterprise.inject.spi.AnnotatedConstructor;
-import javax.enterprise.inject.spi.AnnotatedType;
-import javax.enterprise.inject.spi.Bean;
-import javax.enterprise.inject.spi.BeanManager;
-import javax.enterprise.inject.spi.Extension;
-import javax.enterprise.inject.spi.ProcessAnnotatedType;
-import javax.inject.Inject;
-import javax.inject.Named;
-import javax.inject.Qualifier;
-
-import org.jboss.weld.extensions.Exact.ExactLiteral;
-import org.jboss.weld.extensions.bean.CustomBeanBuilder;
-import org.jboss.weld.extensions.util.annotated.AnnotationBuilder;
-import org.jboss.weld.extensions.util.annotated.MemberAnnotationRedefiner;
-import org.jboss.weld.extensions.util.annotated.NewAnnotatedTypeBuilder;
-import org.jboss.weld.extensions.util.annotated.Parameter;
-import org.jboss.weld.extensions.util.annotated.ParameterAnnotationRedefiner;
-
-class CoreExtension implements Extension
-{
-
-   private final Collection<Bean<?>> additionalBeans;
-
-   CoreExtension()
-   {
-      this.additionalBeans = new ArrayList<Bean<?>>();
-   }
-
-   <X> void processAnnotatedType(@Observes final ProcessAnnotatedType<X> pat, BeanManager bm)
-   {
-      if (pat.getAnnotatedType().isAnnotationPresent(Veto.class))
-      {
-         pat.veto();
-         return;
-      }
-
-      final AnnotatedType<X> at = pat.getAnnotatedType();
-      NewAnnotatedTypeBuilder<X> builder = NewAnnotatedTypeBuilder.newInstance(at).readAnnotationsFromUnderlying();
-
-      // support for @Named packages
-      Package pkg = at.getJavaClass().getPackage();
-      if (pkg.isAnnotationPresent(Named.class))
-      {
-         final String packageName = getPackageName(pkg);
-
-         builder.redefineMembers(Named.class, new MemberAnnotationRedefiner<Named>()
-         {
-
-            public Named redefine(Named annotation, Member member, AnnotationBuilder annotations)
-            {
-               if (annotations.isAnnotationPresent(Produces.class))
-               {
-                  String memberName = member.getName();
-                  String beanName = getName(annotation, memberName);
-                  return new NamedLiteral(packageName + '.' + beanName);
-               }
-               else
-               {
-                  return annotation;
-               }
-            }
-
-         });
-
-         if (at.isAnnotationPresent(Named.class))
-         {
-            String className = at.getJavaClass().getSimpleName();
-            String beanName = getName(at.getAnnotation(Named.class), className);
-            builder.addToClass(new NamedLiteral(packageName + '.' + beanName));
-         }
-
-      }
-
-      // support for @Exact
-      Set<Annotation> qualfiers = getAnnotationsWithMetatype(at.getAnnotations(), Qualifier.class);
-      if (qualfiers.isEmpty() || (qualfiers.size() == 1 && qualfiers.iterator().next().annotationType() == Named.class))
-      {
-         builder.addToClass(DefaultLiteral.INSTANCE);
-      }
-      builder.addToClass(new Exact.ExactLiteral(at.getJavaClass()));
-      builder.redefineMembers(Exact.class, new MemberAnnotationRedefiner<Exact>()
-      {
-
-         public Exact redefine(Exact annotation, Member annotated, AnnotationBuilder annotations)
-         {
-            if (annotation.value() == void.class)
-            {
-               return new ExactLiteral(getMemberType(annotated));
-            }
-            else
-            {
-               return annotation;
-            }
-         }
-      });
-
-      builder.redefineMemberParameters(Exact.class, new ParameterAnnotationRedefiner<Exact>()
-      {
-
-         public Exact redefine(Exact annotation, Parameter annotated, AnnotationBuilder annotations)
-         {
-            if (annotation.value() == void.class)
-            {
-               return new ExactLiteral(getMemberType(annotated.getDeclaringMember()));
-            }
-            else
-            {
-               return annotation;
-            }
-         }
-
-      });
-
-      pat.setAnnotatedType(builder.create());
-
-      // support for @Constructs
-      for (AnnotatedConstructor<X> constructor : at.getConstructors())
-      {
-         if (constructor.isAnnotationPresent(Constructs.class))
-         {
-            NewAnnotatedTypeBuilder<X> annotatedTypeBuilder = NewAnnotatedTypeBuilder.newInstance(pat.getAnnotatedType()).readAnnotationsFromUnderlying();
-            // remove class-level @Named annotation
-            annotatedTypeBuilder.removeFromClass(Named.class);
-            // remove bean constructors annotated @Inject
-            for (AnnotatedConstructor<X> constructor2 : at.getConstructors())
-            {
-               annotatedTypeBuilder.removeFromConstructor(constructor2.getJavaMember(), Inject.class);
-            }
-            // make the constructor annotated @Constructs the bean constructor
-            annotatedTypeBuilder.addToConstructor(constructor.getJavaMember(), InjectLiteral.INSTANCE);
-            // add all the annotations of this constructor to the class
-            for (Annotation ann : constructor.getAnnotations())
-            {
-               annotatedTypeBuilder.addToClass(ann);
-            }
-            AnnotatedType<X> construtsAnnotatedType = builder.create();
-            additionalBeans.add(new CustomBeanBuilder<X>(construtsAnnotatedType, bm).build());
-         }
-      }
-   }
-
-   void afterBeanDiscovery(@Observes AfterBeanDiscovery abd)
-   {
-      for (Bean<?> bean : additionalBeans)
-      {
-         abd.addBean(bean);
-      }
-   }
-
-   private String getPackageName(Package pkg)
-   {
-      String packageName = pkg.getAnnotation(Named.class).value();
-      if (packageName.length() == 0)
-      {
-         packageName = pkg.getName();
-      }
-      return packageName;
-   }
-
-   private <X> String getName(Named named, String defaultName)
-   {
-      String beanName = named.value();
-      if (beanName.length() == 0)
-      {
-         beanName = defaultName.substring(0, 1).toLowerCase() + defaultName.substring(1);
-      }
-      return beanName;
-   }
-
-}

Deleted: extensions/trunk/src/main/java/org/jboss/weld/extensions/DefaultLiteral.java
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/DefaultLiteral.java	2010-04-29 20:14:14 UTC (rev 6198)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/DefaultLiteral.java	2010-04-29 20:22:21 UTC (rev 6199)
@@ -1,31 +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.weld.extensions;
-
-import javax.enterprise.inject.Default;
-import javax.enterprise.util.AnnotationLiteral;
-
-class DefaultLiteral extends AnnotationLiteral<Default> implements Default 
-{
-
-   private static final long serialVersionUID = 2768505716290514234L;
-   
-   public static final Default INSTANCE = new DefaultLiteral();
-   
-   private DefaultLiteral() {}
-
-}
\ No newline at end of file

Deleted: extensions/trunk/src/main/java/org/jboss/weld/extensions/Exact.java
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/Exact.java	2010-04-29 20:14:14 UTC (rev 6198)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/Exact.java	2010-04-29 20:22:21 UTC (rev 6199)
@@ -1,64 +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.weld.extensions;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import javax.enterprise.util.AnnotationLiteral;
-import javax.inject.Qualifier;
-
-/**
- * An injection point qualifier that may be used to select the exact bean to be
- * injected, by specifying its implementation class.
- * 
- * @author Gavin King
- * 
- */
- at Retention(RUNTIME)
- at Target( { METHOD, TYPE, FIELD, PARAMETER })
- at Documented
- at Qualifier
-public @interface Exact
-{
-   Class<?> value() default void.class;
-   
-   static class ExactLiteral extends AnnotationLiteral<Exact> implements Exact
-   {
-
-      private static final long serialVersionUID = 4907169607105615674L;
-      
-      final Class<?> clazz;
-
-      ExactLiteral(Class<?> clazz)
-      {
-         this.clazz = clazz;
-      }
-
-      public Class<?> value()
-      {
-         return clazz;
-      }
-   }
-}

Deleted: extensions/trunk/src/main/java/org/jboss/weld/extensions/InjectLiteral.java
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/InjectLiteral.java	2010-04-29 20:14:14 UTC (rev 6198)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/InjectLiteral.java	2010-04-29 20:22:21 UTC (rev 6199)
@@ -1,31 +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.weld.extensions;
-
-import javax.enterprise.util.AnnotationLiteral;
-import javax.inject.Inject;
-
-class InjectLiteral extends AnnotationLiteral<Inject> implements Inject 
-{
-   
-   private static final long serialVersionUID = 817936051028981316L;
-   
-   public static final Inject INSTANCE = new InjectLiteral();
-   
-   private InjectLiteral() {}
-
-}
\ No newline at end of file

Deleted: extensions/trunk/src/main/java/org/jboss/weld/extensions/NamedLiteral.java
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/NamedLiteral.java	2010-04-29 20:14:14 UTC (rev 6198)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/NamedLiteral.java	2010-04-29 20:22:21 UTC (rev 6199)
@@ -1,36 +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.weld.extensions;
-
-import javax.enterprise.util.AnnotationLiteral;
-import javax.inject.Named;
-
-class NamedLiteral extends AnnotationLiteral<Named> implements Named
-{
-   private static final long serialVersionUID = 2239690880420187044L;
-   final String name;
-
-   NamedLiteral(String name)
-   {
-      this.name = name;
-   }
-
-   public String value()
-   {
-      return name;
-   }
-}
\ No newline at end of file

Deleted: extensions/trunk/src/main/java/org/jboss/weld/extensions/Resource.java
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/Resource.java	2010-04-29 20:14:14 UTC (rev 6198)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/Resource.java	2010-04-29 20:22:21 UTC (rev 6199)
@@ -1,48 +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.weld.extensions;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import javax.enterprise.util.Nonbinding;
-import javax.inject.Qualifier;
-
-/**
- * An injection point qualifier that may be used to specify a resource to inject
- * 
- * @author Pete Muir
- * 
- */
- at Retention(RUNTIME)
- at Target( { METHOD, TYPE, FIELD, PARAMETER })
- at Documented
- at Qualifier
-public @interface Resource
-{
-   
-   @Nonbinding
-   String value();
-   
-}

Deleted: extensions/trunk/src/main/java/org/jboss/weld/extensions/Veto.java
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/Veto.java	2010-04-29 20:14:14 UTC (rev 6198)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/Veto.java	2010-04-29 20:22:21 UTC (rev 6199)
@@ -1,37 +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.weld.extensions;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Signifies that a bean should be vetoed at startup
- * 
- * @author Stuart Douglas
- * 
- */
- at Target(ElementType.TYPE)
- at Retention(RetentionPolicy.RUNTIME)
- at Documented
-public @interface Veto
-{
-
-}

Copied: extensions/trunk/src/main/java/org/jboss/weld/extensions/core/Constructs.java (from rev 6191, extensions/trunk/src/main/java/org/jboss/weld/extensions/Constructs.java)
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/core/Constructs.java	                        (rev 0)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/core/Constructs.java	2010-04-29 20:22:21 UTC (rev 6199)
@@ -0,0 +1,37 @@
+/*
+ * 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.weld.extensions.core;
+
+import static java.lang.annotation.ElementType.CONSTRUCTOR;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * Allows a bean to be defined by annotating a constructor instead
+ * of the bean class. There may be multiple beans defined using
+ * <tt>@Constructs</tt> per bean class.
+ * 
+ * @author Gavin King
+ *
+ */
+ at Retention(RUNTIME)
+ at Target(CONSTRUCTOR)
+ at Documented
+public @interface Constructs {}


Property changes on: extensions/trunk/src/main/java/org/jboss/weld/extensions/core/Constructs.java
___________________________________________________________________
Name: svn:eol-style
   + native

Copied: extensions/trunk/src/main/java/org/jboss/weld/extensions/core/CoreExtension.java (from rev 6196, extensions/trunk/src/main/java/org/jboss/weld/extensions/CoreExtension.java)
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/core/CoreExtension.java	                        (rev 0)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/core/CoreExtension.java	2010-04-29 20:22:21 UTC (rev 6199)
@@ -0,0 +1,209 @@
+/*
+ * 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.weld.extensions.core;
+
+import static org.jboss.weld.extensions.util.ReflectionUtils.getAnnotationsWithMetatype;
+import static org.jboss.weld.extensions.util.ReflectionUtils.getMemberType;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Member;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Set;
+
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.Produces;
+import javax.enterprise.inject.spi.AfterBeanDiscovery;
+import javax.enterprise.inject.spi.AnnotatedConstructor;
+import javax.enterprise.inject.spi.AnnotatedType;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.Extension;
+import javax.enterprise.inject.spi.ProcessAnnotatedType;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Qualifier;
+
+import org.jboss.weld.extensions.bean.CustomBeanBuilder;
+import org.jboss.weld.extensions.core.Exact.ExactLiteral;
+import org.jboss.weld.extensions.util.annotated.AnnotationBuilder;
+import org.jboss.weld.extensions.util.annotated.MemberAnnotationRedefiner;
+import org.jboss.weld.extensions.util.annotated.NewAnnotatedTypeBuilder;
+import org.jboss.weld.extensions.util.annotated.Parameter;
+import org.jboss.weld.extensions.util.annotated.ParameterAnnotationRedefiner;
+
+/**
+ * Extension to install the "core" extensions. Core extensions are those that
+ * add additional abilities to CDI applications via annotations.
+ * 
+ * @author Stuart
+ * @author Pete Muir
+ * @author Gavin King
+ * 
+ */
+class CoreExtension implements Extension
+{
+
+   private final Collection<Bean<?>> additionalBeans;
+
+   CoreExtension()
+   {
+      this.additionalBeans = new ArrayList<Bean<?>>();
+   }
+
+   <X> void processAnnotatedType(@Observes final ProcessAnnotatedType<X> pat, BeanManager beanManager)
+   {
+      // Support for @Veto
+      if (pat.getAnnotatedType().isAnnotationPresent(Veto.class))
+      {
+         pat.veto();
+         return;
+      }
+
+      NewAnnotatedTypeBuilder<X> builder = NewAnnotatedTypeBuilder.newInstance(pat.getAnnotatedType()).readAnnotationsFromUnderlying();
+
+      // support for @Named packages
+      Package pkg = pat.getAnnotatedType().getJavaClass().getPackage();
+      if (pkg.isAnnotationPresent(Named.class))
+      {
+         final String packageName = getPackageName(pkg);
+
+         builder.redefineMembers(Named.class, new MemberAnnotationRedefiner<Named>()
+         {
+
+            public Named redefine(Named annotation, Member member, AnnotationBuilder annotations)
+            {
+               if (annotations.isAnnotationPresent(Produces.class))
+               {
+                  String memberName = member.getName();
+                  String beanName = getName(annotation, memberName);
+                  return new NamedLiteral(packageName + '.' + beanName);
+               }
+               else
+               {
+                  return annotation;
+               }
+            }
+
+         });
+
+         if (pat.getAnnotatedType().isAnnotationPresent(Named.class))
+         {
+            String className = pat.getAnnotatedType().getJavaClass().getSimpleName();
+            String beanName = getName(pat.getAnnotatedType().getAnnotation(Named.class), className);
+            builder.addToClass(new NamedLiteral(packageName + '.' + beanName));
+         }
+
+      }
+
+      // support for @Exact
+      Set<Annotation> qualfiers = getAnnotationsWithMetatype(pat.getAnnotatedType().getAnnotations(), Qualifier.class);
+      if (qualfiers.isEmpty() || (qualfiers.size() == 1 && qualfiers.iterator().next().annotationType() == Named.class))
+      {
+         builder.addToClass(DefaultLiteral.INSTANCE);
+      }
+      builder.addToClass(new Exact.ExactLiteral(pat.getAnnotatedType().getJavaClass()));
+      builder.redefineMembers(Exact.class, new MemberAnnotationRedefiner<Exact>()
+      {
+
+         public Exact redefine(Exact annotation, Member annotated, AnnotationBuilder annotations)
+         {
+            if (annotation.value() == void.class)
+            {
+               return new ExactLiteral(getMemberType(annotated));
+            }
+            else
+            {
+               return annotation;
+            }
+         }
+      });
+
+      builder.redefineMemberParameters(Exact.class, new ParameterAnnotationRedefiner<Exact>()
+      {
+
+         public Exact redefine(Exact annotation, Parameter annotated, AnnotationBuilder annotations)
+         {
+            if (annotation.value() == void.class)
+            {
+               return new ExactLiteral(getMemberType(annotated.getDeclaringMember()));
+            }
+            else
+            {
+               return annotation;
+            }
+         }
+
+      });
+
+      pat.setAnnotatedType(builder.create());
+
+      // support for @Constructs
+      for (AnnotatedConstructor<X> constructor : pat.getAnnotatedType().getConstructors())
+      {
+         if (constructor.isAnnotationPresent(Constructs.class))
+         {
+            NewAnnotatedTypeBuilder<X> annotatedTypeBuilder = NewAnnotatedTypeBuilder.newInstance(pat.getAnnotatedType()).readAnnotationsFromUnderlying();
+            // remove class-level @Named annotation
+            annotatedTypeBuilder.removeFromClass(Named.class);
+            // remove bean constructors annotated @Inject
+            for (AnnotatedConstructor<X> constructor2 : pat.getAnnotatedType().getConstructors())
+            {
+               annotatedTypeBuilder.removeFromConstructor(constructor2.getJavaMember(), Inject.class);
+            }
+            // make the constructor annotated @Constructs the bean constructor
+            annotatedTypeBuilder.addToConstructor(constructor.getJavaMember(), InjectLiteral.INSTANCE);
+            // add all the annotations of this constructor to the class
+            for (Annotation ann : constructor.getAnnotations())
+            {
+               annotatedTypeBuilder.addToClass(ann);
+            }
+            AnnotatedType<X> construtsAnnotatedType = builder.create();
+            additionalBeans.add(new CustomBeanBuilder<X>(construtsAnnotatedType, beanManager).build());
+         }
+      }
+   }
+
+   void afterBeanDiscovery(@Observes AfterBeanDiscovery abd)
+   {
+      for (Bean<?> bean : additionalBeans)
+      {
+         abd.addBean(bean);
+      }
+   }
+
+   private String getPackageName(Package pkg)
+   {
+      String packageName = pkg.getAnnotation(Named.class).value();
+      if (packageName.length() == 0)
+      {
+         packageName = pkg.getName();
+      }
+      return packageName;
+   }
+
+   private <X> String getName(Named named, String defaultName)
+   {
+      String beanName = named.value();
+      if (beanName.length() == 0)
+      {
+         beanName = defaultName.substring(0, 1).toLowerCase() + defaultName.substring(1);
+      }
+      return beanName;
+   }
+
+}


Property changes on: extensions/trunk/src/main/java/org/jboss/weld/extensions/core/CoreExtension.java
___________________________________________________________________
Name: svn:eol-style
   + native

Copied: extensions/trunk/src/main/java/org/jboss/weld/extensions/core/DefaultLiteral.java (from rev 6198, extensions/trunk/src/main/java/org/jboss/weld/extensions/DefaultLiteral.java)
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/core/DefaultLiteral.java	                        (rev 0)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/core/DefaultLiteral.java	2010-04-29 20:22:21 UTC (rev 6199)
@@ -0,0 +1,31 @@
+/*
+ * 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.weld.extensions.core;
+
+import javax.enterprise.inject.Default;
+import javax.enterprise.util.AnnotationLiteral;
+
+class DefaultLiteral extends AnnotationLiteral<Default> implements Default 
+{
+
+   private static final long serialVersionUID = 2768505716290514234L;
+   
+   static final Default INSTANCE = new DefaultLiteral();
+   
+   private DefaultLiteral() {}
+
+}
\ No newline at end of file


Property changes on: extensions/trunk/src/main/java/org/jboss/weld/extensions/core/DefaultLiteral.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:eol-style
   + native

Copied: extensions/trunk/src/main/java/org/jboss/weld/extensions/core/Exact.java (from rev 6196, extensions/trunk/src/main/java/org/jboss/weld/extensions/Exact.java)
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/core/Exact.java	                        (rev 0)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/core/Exact.java	2010-04-29 20:22:21 UTC (rev 6199)
@@ -0,0 +1,64 @@
+/*
+ * 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.weld.extensions.core;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.enterprise.util.AnnotationLiteral;
+import javax.inject.Qualifier;
+
+/**
+ * An injection point qualifier that may be used to select the exact bean to be
+ * injected, by specifying its implementation class.
+ * 
+ * @author Gavin King
+ * 
+ */
+ at Retention(RUNTIME)
+ at Target( { METHOD, TYPE, FIELD, PARAMETER })
+ at Documented
+ at Qualifier
+public @interface Exact
+{
+   Class<?> value() default void.class;
+   
+   static class ExactLiteral extends AnnotationLiteral<Exact> implements Exact
+   {
+
+      private static final long serialVersionUID = 4907169607105615674L;
+      
+      final Class<?> clazz;
+
+      ExactLiteral(Class<?> clazz)
+      {
+         this.clazz = clazz;
+      }
+
+      public Class<?> value()
+      {
+         return clazz;
+      }
+   }
+}


Property changes on: extensions/trunk/src/main/java/org/jboss/weld/extensions/core/Exact.java
___________________________________________________________________
Name: svn:eol-style
   + native

Copied: extensions/trunk/src/main/java/org/jboss/weld/extensions/core/InjectLiteral.java (from rev 6198, extensions/trunk/src/main/java/org/jboss/weld/extensions/InjectLiteral.java)
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/core/InjectLiteral.java	                        (rev 0)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/core/InjectLiteral.java	2010-04-29 20:22:21 UTC (rev 6199)
@@ -0,0 +1,31 @@
+/*
+ * 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.weld.extensions.core;
+
+import javax.enterprise.util.AnnotationLiteral;
+import javax.inject.Inject;
+
+class InjectLiteral extends AnnotationLiteral<Inject> implements Inject 
+{
+   
+   private static final long serialVersionUID = 817936051028981316L;
+   
+   static final Inject INSTANCE = new InjectLiteral();
+   
+   private InjectLiteral() {}
+
+}
\ No newline at end of file


Property changes on: extensions/trunk/src/main/java/org/jboss/weld/extensions/core/InjectLiteral.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:eol-style
   + native

Copied: extensions/trunk/src/main/java/org/jboss/weld/extensions/core/NamedLiteral.java (from rev 6191, extensions/trunk/src/main/java/org/jboss/weld/extensions/NamedLiteral.java)
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/core/NamedLiteral.java	                        (rev 0)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/core/NamedLiteral.java	2010-04-29 20:22:21 UTC (rev 6199)
@@ -0,0 +1,36 @@
+/*
+ * 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.weld.extensions.core;
+
+import javax.enterprise.util.AnnotationLiteral;
+import javax.inject.Named;
+
+class NamedLiteral extends AnnotationLiteral<Named> implements Named
+{
+   private static final long serialVersionUID = 2239690880420187044L;
+   final String name;
+
+   NamedLiteral(String name)
+   {
+      this.name = name;
+   }
+
+   public String value()
+   {
+      return name;
+   }
+}
\ No newline at end of file


Property changes on: extensions/trunk/src/main/java/org/jboss/weld/extensions/core/NamedLiteral.java
___________________________________________________________________
Name: svn:eol-style
   + native

Copied: extensions/trunk/src/main/java/org/jboss/weld/extensions/core/Veto.java (from rev 6191, extensions/trunk/src/main/java/org/jboss/weld/extensions/Veto.java)
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/core/Veto.java	                        (rev 0)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/core/Veto.java	2010-04-29 20:22:21 UTC (rev 6199)
@@ -0,0 +1,37 @@
+/*
+ * 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.weld.extensions.core;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Instructs the CDI container not to deploy the class as a bean
+ * 
+ * @author Stuart Douglas
+ * 
+ */
+ at Target(ElementType.TYPE)
+ at Retention(RetentionPolicy.RUNTIME)
+ at Documented
+public @interface Veto
+{
+
+}

Copied: extensions/trunk/src/main/java/org/jboss/weld/extensions/resourceLoader/Resource.java (from rev 6191, extensions/trunk/src/main/java/org/jboss/weld/extensions/Resource.java)
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/resourceLoader/Resource.java	                        (rev 0)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/resourceLoader/Resource.java	2010-04-29 20:22:21 UTC (rev 6199)
@@ -0,0 +1,48 @@
+/*
+ * 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.weld.extensions.resourceLoader;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.enterprise.util.Nonbinding;
+import javax.inject.Qualifier;
+
+/**
+ * An injection point qualifier that may be used to specify a resource to inject
+ * 
+ * @author Pete Muir
+ * 
+ */
+ at Retention(RUNTIME)
+ at Target( { METHOD, TYPE, FIELD, PARAMETER })
+ at Documented
+ at Qualifier
+public @interface Resource
+{
+   
+   @Nonbinding
+   String value();
+   
+}


Property changes on: extensions/trunk/src/main/java/org/jboss/weld/extensions/resourceLoader/Resource.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:eol-style
   + native

Modified: extensions/trunk/src/main/java/org/jboss/weld/extensions/resourceLoader/ResourceProducer.java
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/resourceLoader/ResourceProducer.java	2010-04-29 20:14:14 UTC (rev 6198)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/resourceLoader/ResourceProducer.java	2010-04-29 20:22:21 UTC (rev 6199)
@@ -27,7 +27,6 @@
 import javax.enterprise.inject.spi.InjectionPoint;
 import javax.inject.Inject;
 
-import org.jboss.weld.extensions.Resource;
 
 /**
  * Resource producer allows injecting of resources

Modified: extensions/trunk/src/main/java/org/jboss/weld/extensions/resourceLoader/ResourceProvider.java
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/resourceLoader/ResourceProvider.java	2010-04-29 20:14:14 UTC (rev 6198)
+++ extensions/trunk/src/main/java/org/jboss/weld/extensions/resourceLoader/ResourceProvider.java	2010-04-29 20:22:21 UTC (rev 6199)
@@ -30,7 +30,6 @@
 import javax.enterprise.inject.Instance;
 import javax.inject.Inject;
 
-import org.jboss.weld.extensions.Resource;
 import org.jboss.weld.extensions.util.AnnotationInstanceProvider;
 
 /**

Modified: extensions/trunk/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension
===================================================================
--- extensions/trunk/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension	2010-04-29 20:14:14 UTC (rev 6198)
+++ extensions/trunk/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension	2010-04-29 20:22:21 UTC (rev 6199)
@@ -1,5 +1,5 @@
 org.jboss.weld.extensions.bean.generic.GenericExtension
 org.jboss.weld.extensions.resourceLoader.servlet.ServletResourceExtension
 org.jboss.weld.extensions.bean.lookup.IdentifiableBeanExtension
-org.jboss.weld.extensions.CoreExtension
+org.jboss.weld.extensions.core.CoreExtension
 org.jboss.weld.extensions.interceptor.InterceptorExtension
\ No newline at end of file



More information about the weld-commits mailing list