Author: pete.muir(a)jboss.org
Date: 2010-04-29 17:41:13 -0400 (Thu, 29 Apr 2010)
New Revision: 6201
Added:
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/AnnotatedCallableImpl.java
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/AnnotatedConstructorImpl.java
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/AnnotatedFieldImpl.java
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/AnnotatedImpl.java
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/AnnotatedMemberImpl.java
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/AnnotatedMethodImpl.java
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/AnnotatedParameterImpl.java
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/AnnotatedTypeBuilder.java
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/AnnotatedTypeImpl.java
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/AnnotationBuilder.java
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/AnnotationRedefiner.java
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/AnnotationStore.java
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/MemberAnnotationRedefiner.java
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/Parameter.java
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/ParameterAnnotationRedefiner.java
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/TypeAnnotationRedefiner.java
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/TypeClosureBuilder.java
Removed:
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/AbstractNewAnnotatedCallable.java
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/AbstractNewAnnotatedElement.java
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/AbstractNewAnnotatedMember.java
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/AnnotationBuilder.java
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/AnnotationRedefiner.java
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/AnnotationStore.java
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/NewAnnotatedConstructor.java
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/NewAnnotatedField.java
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/NewAnnotatedMethod.java
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/NewAnnotatedParameter.java
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/NewAnnotatedType.java
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/NewAnnotatedTypeBuilder.java
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/TypeClosureBuilder.java
extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated/
Modified:
extensions/trunk/src/main/java/org/jboss/weld/extensions/bean/generic/GenericExtension.java
extensions/trunk/src/main/java/org/jboss/weld/extensions/core/CoreExtension.java
Log:
cleanup annotated
Copied: extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType (from rev
6191, extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated)
Deleted:
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/AbstractNewAnnotatedCallable.java
===================================================================
---
extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated/AbstractNewAnnotatedCallable.java 2010-04-28
16:45:31 UTC (rev 6191)
+++
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/AbstractNewAnnotatedCallable.java 2010-04-29
21:41:13 UTC (rev 6201)
@@ -1,79 +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.util.annotated;
-
-import java.lang.reflect.Member;
-import java.lang.reflect.Type;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-import javax.enterprise.inject.spi.AnnotatedCallable;
-import javax.enterprise.inject.spi.AnnotatedParameter;
-import javax.enterprise.inject.spi.AnnotatedType;
-
-/**
- *
- * @author Stuart Douglas
- *
- */
-abstract class AbstractNewAnnotatedCallable<X, Y extends Member> extends
AbstractNewAnnotatedMember<X, Y> implements AnnotatedCallable<X>
-{
-
- private final List<AnnotatedParameter<X>> parameters;
-
- protected AbstractNewAnnotatedCallable(AnnotatedType<X> declaringType, Y member,
Class<?> memberType, Class<?>[] parameterTypes, Type[] genericTypes,
AnnotationStore annotations, Map<Integer, AnnotationStore> parameterAnnotations,
Type genericType, Map<Integer, Type> parameterTypeOverrides)
- {
- super(declaringType, member, memberType, annotations, genericType, null);
- this.parameters = getAnnotatedParameters(this, parameterTypes, genericTypes,
parameterAnnotations, parameterTypeOverrides);
- }
-
- public List<AnnotatedParameter<X>> getParameters()
- {
- return Collections.unmodifiableList(parameters);
- }
-
- public AnnotatedParameter<X> getParameter(int index)
- {
- return parameters.get(index);
-
- }
-
- private static <X, Y extends Member> List<AnnotatedParameter<X>>
getAnnotatedParameters(AbstractNewAnnotatedCallable<X, Y> callable, Class<?>[]
parameterTypes, Type[] genericTypes, Map<Integer, AnnotationStore>
parameterAnnotations, Map<Integer, Type> parameterTypeOverrides)
- {
- List<AnnotatedParameter<X>> parameters = new
ArrayList<AnnotatedParameter<X>>();
- int len = parameterTypes.length;
- for (int i = 0; i < len; ++i)
- {
- AnnotationBuilder builder = new AnnotationBuilder();
- if (parameterAnnotations != null &&
parameterAnnotations.containsKey(i))
- {
- builder.addAll(parameterAnnotations.get(i));
- }
- Type over = null;
- if (parameterTypeOverrides != null)
- {
- over = parameterTypeOverrides.get(i);
- }
- NewAnnotatedParameter<X> p = new NewAnnotatedParameter<X>(callable,
parameterTypes[i], i, builder.create(), genericTypes[i], over);
- parameters.add(p);
- }
- return parameters;
- }
-
-}
Deleted:
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/AbstractNewAnnotatedElement.java
===================================================================
---
extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated/AbstractNewAnnotatedElement.java 2010-04-28
16:45:31 UTC (rev 6191)
+++
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/AbstractNewAnnotatedElement.java 2010-04-29
21:41:13 UTC (rev 6201)
@@ -1,98 +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.util.annotated;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Type;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.enterprise.inject.spi.Annotated;
-
-/**
- * The base class for all New Annotated types.
- *
- * @author Stuart Douglas
- *
- */
-abstract class AbstractNewAnnotatedElement implements Annotated
-{
-
- private final Type type;
- private final Set<Type> typeClosure;
- private final AnnotationStore annotations;
-
- protected AbstractNewAnnotatedElement(Class<?> type, AnnotationStore
annotations, Type genericType, Type overridenType)
- {
-
- if (overridenType == null)
- {
- this.typeClosure = new TypeClosureBuilder().add(type).getTypes();
- if (genericType != null)
- {
- typeClosure.add(genericType);
- this.type = genericType;
- }
- else
- {
- this.type = type;
- }
- }
- else
- {
- this.type = overridenType;
- this.typeClosure = Collections.singleton(overridenType);
- }
-
-
- if (annotations == null)
- {
- this.annotations = new AnnotationStore();
- }
- else
- {
- this.annotations = annotations;
- }
- }
-
- public <T extends Annotation> T getAnnotation(Class<T> annotationType)
- {
- return annotations.getAnnotation(annotationType);
- }
-
- public Set<Annotation> getAnnotations()
- {
- return annotations.getAnnotations();
- }
-
- public boolean isAnnotationPresent(Class<? extends Annotation> annotationType)
- {
- return annotations.isAnnotationPresent(annotationType);
- }
-
- public Set<Type> getTypeClosure()
- {
- return new HashSet<Type>(typeClosure);
- }
-
- public Type getBaseType()
- {
- return type;
- }
-
-}
Deleted:
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/AbstractNewAnnotatedMember.java
===================================================================
---
extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated/AbstractNewAnnotatedMember.java 2010-04-28
16:45:31 UTC (rev 6191)
+++
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/AbstractNewAnnotatedMember.java 2010-04-29
21:41:13 UTC (rev 6201)
@@ -1,58 +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.util.annotated;
-
-import java.lang.reflect.Member;
-import java.lang.reflect.Modifier;
-import java.lang.reflect.Type;
-
-import javax.enterprise.inject.spi.AnnotatedMember;
-import javax.enterprise.inject.spi.AnnotatedType;
-
-/**
- *
- * @author Stuart Douglas
- *
- */
-abstract class AbstractNewAnnotatedMember<X, M extends Member> extends
AbstractNewAnnotatedElement implements AnnotatedMember<X>
-{
- private final AnnotatedType<X> declaringType;
- private final M javaMember;
-
- protected AbstractNewAnnotatedMember(AnnotatedType<X> declaringType, M member,
Class<?> memberType, AnnotationStore annotations, Type genericType, Type
overridenType)
- {
- super(memberType, annotations, genericType, overridenType);
- this.declaringType = declaringType;
- this.javaMember = member;
- }
-
- public AnnotatedType<X> getDeclaringType()
- {
- return declaringType;
- }
-
- public M getJavaMember()
- {
- return javaMember;
- }
-
- public boolean isStatic()
- {
- return Modifier.isStatic(javaMember.getModifiers());
- }
-
-}
Copied:
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/AnnotatedCallableImpl.java
(from rev 6200,
extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated/AnnotatedCallableImpl.java)
===================================================================
---
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/AnnotatedCallableImpl.java
(rev 0)
+++
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/AnnotatedCallableImpl.java 2010-04-29
21:41:13 UTC (rev 6201)
@@ -0,0 +1,79 @@
+/*
+ * 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.annotatedType;
+
+import java.lang.reflect.Member;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import javax.enterprise.inject.spi.AnnotatedCallable;
+import javax.enterprise.inject.spi.AnnotatedParameter;
+import javax.enterprise.inject.spi.AnnotatedType;
+
+/**
+ *
+ * @author Stuart Douglas
+ *
+ */
+abstract class AnnotatedCallableImpl<X, Y extends Member> extends
AnnotatedMemberImpl<X, Y> implements AnnotatedCallable<X>
+{
+
+ private final List<AnnotatedParameter<X>> parameters;
+
+ protected AnnotatedCallableImpl(AnnotatedType<X> declaringType, Y member,
Class<?> memberType, Class<?>[] parameterTypes, Type[] genericTypes,
AnnotationStore annotations, Map<Integer, AnnotationStore> parameterAnnotations,
Type genericType, Map<Integer, Type> parameterTypeOverrides)
+ {
+ super(declaringType, member, memberType, annotations, genericType, null);
+ this.parameters = getAnnotatedParameters(this, parameterTypes, genericTypes,
parameterAnnotations, parameterTypeOverrides);
+ }
+
+ public List<AnnotatedParameter<X>> getParameters()
+ {
+ return Collections.unmodifiableList(parameters);
+ }
+
+ public AnnotatedParameter<X> getParameter(int index)
+ {
+ return parameters.get(index);
+
+ }
+
+ private static <X, Y extends Member> List<AnnotatedParameter<X>>
getAnnotatedParameters(AnnotatedCallableImpl<X, Y> callable, Class<?>[]
parameterTypes, Type[] genericTypes, Map<Integer, AnnotationStore>
parameterAnnotations, Map<Integer, Type> parameterTypeOverrides)
+ {
+ List<AnnotatedParameter<X>> parameters = new
ArrayList<AnnotatedParameter<X>>();
+ int len = parameterTypes.length;
+ for (int i = 0; i < len; ++i)
+ {
+ AnnotationBuilder builder = new AnnotationBuilder();
+ if (parameterAnnotations != null &&
parameterAnnotations.containsKey(i))
+ {
+ builder.addAll(parameterAnnotations.get(i));
+ }
+ Type over = null;
+ if (parameterTypeOverrides != null)
+ {
+ over = parameterTypeOverrides.get(i);
+ }
+ AnnotatedParameterImpl<X> p = new
AnnotatedParameterImpl<X>(callable, parameterTypes[i], i, builder.create(),
genericTypes[i], over);
+ parameters.add(p);
+ }
+ return parameters;
+ }
+
+}
Copied:
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/AnnotatedConstructorImpl.java
(from rev 6200,
extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated/AnnotatedConstructorImpl.java)
===================================================================
---
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/AnnotatedConstructorImpl.java
(rev 0)
+++
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/AnnotatedConstructorImpl.java 2010-04-29
21:41:13 UTC (rev 6201)
@@ -0,0 +1,58 @@
+/*
+ * 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.annotatedType;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Type;
+import java.util.Map;
+
+import javax.enterprise.inject.spi.AnnotatedConstructor;
+
+/**
+ *
+ * @author Stuart Douglas
+ *
+ */
+class AnnotatedConstructorImpl<X> extends AnnotatedCallableImpl<X,
Constructor<X>> implements AnnotatedConstructor<X>
+{
+
+ AnnotatedConstructorImpl(AnnotatedTypeImpl<X> type, Constructor<?>
constructor, AnnotationStore annotations, Map<Integer, AnnotationStore>
parameterAnnotations, Map<Integer, Type> typeOverrides)
+ {
+
+ super(type, (Constructor<X>) constructor, constructor.getDeclaringClass(),
constructor.getParameterTypes(), getGenericArray(constructor), annotations,
parameterAnnotations, null, typeOverrides);
+ }
+
+ private static Type[] getGenericArray(Constructor<?> constructor)
+ {
+ Type[] genericTypes = constructor.getGenericParameterTypes();
+ // for inner classes genericTypes and parameterTypes can be different
+ // length, this is a hack to fix this.
+ // TODO: investigate this behavior further, on different JVM's and
+ // compilers
+ if (genericTypes.length + 1 == constructor.getParameterTypes().length)
+ {
+ genericTypes = new Type[constructor.getGenericParameterTypes().length + 1];
+ genericTypes[0] = constructor.getParameterTypes()[0];
+ for (int i = 0; i < constructor.getGenericParameterTypes().length; ++i)
+ {
+ genericTypes[i + 1] = constructor.getGenericParameterTypes()[i];
+ }
+ }
+ return genericTypes;
+ }
+
+}
Copied:
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/AnnotatedFieldImpl.java
(from rev 6200,
extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated/AnnotatedFieldImpl.java)
===================================================================
---
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/AnnotatedFieldImpl.java
(rev 0)
+++
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/AnnotatedFieldImpl.java 2010-04-29
21:41:13 UTC (rev 6201)
@@ -0,0 +1,38 @@
+/*
+ * 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.annotatedType;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Type;
+
+import javax.enterprise.inject.spi.AnnotatedField;
+import javax.enterprise.inject.spi.AnnotatedType;
+
+/**
+ *
+ * @author Stuart Douglas
+ *
+ */
+class AnnotatedFieldImpl<X> extends AnnotatedMemberImpl<X, Field> implements
AnnotatedField<X>
+{
+
+ AnnotatedFieldImpl(AnnotatedType<X> declaringType, Field field, AnnotationStore
annotations, Type overridenType)
+ {
+ super(declaringType, field, field.getType(), annotations, field.getGenericType(),
overridenType);
+ }
+
+}
Copied:
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/AnnotatedImpl.java
(from rev 6200,
extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated/AnnotatedImpl.java)
===================================================================
---
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/AnnotatedImpl.java
(rev 0)
+++
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/AnnotatedImpl.java 2010-04-29
21:41:13 UTC (rev 6201)
@@ -0,0 +1,98 @@
+/*
+ * 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.annotatedType;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.enterprise.inject.spi.Annotated;
+
+/**
+ * The base class for all New Annotated types.
+ *
+ * @author Stuart Douglas
+ *
+ */
+abstract class AnnotatedImpl implements Annotated
+{
+
+ private final Type type;
+ private final Set<Type> typeClosure;
+ private final AnnotationStore annotations;
+
+ protected AnnotatedImpl(Class<?> type, AnnotationStore annotations, Type
genericType, Type overridenType)
+ {
+
+ if (overridenType == null)
+ {
+ this.typeClosure = new TypeClosureBuilder().add(type).getTypes();
+ if (genericType != null)
+ {
+ typeClosure.add(genericType);
+ this.type = genericType;
+ }
+ else
+ {
+ this.type = type;
+ }
+ }
+ else
+ {
+ this.type = overridenType;
+ this.typeClosure = Collections.singleton(overridenType);
+ }
+
+
+ if (annotations == null)
+ {
+ this.annotations = new AnnotationStore();
+ }
+ else
+ {
+ this.annotations = annotations;
+ }
+ }
+
+ public <T extends Annotation> T getAnnotation(Class<T> annotationType)
+ {
+ return annotations.getAnnotation(annotationType);
+ }
+
+ public Set<Annotation> getAnnotations()
+ {
+ return annotations.getAnnotations();
+ }
+
+ public boolean isAnnotationPresent(Class<? extends Annotation> annotationType)
+ {
+ return annotations.isAnnotationPresent(annotationType);
+ }
+
+ public Set<Type> getTypeClosure()
+ {
+ return new HashSet<Type>(typeClosure);
+ }
+
+ public Type getBaseType()
+ {
+ return type;
+ }
+
+}
Copied:
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/AnnotatedMemberImpl.java
(from rev 6200,
extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated/AnnotatedMemberImpl.java)
===================================================================
---
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/AnnotatedMemberImpl.java
(rev 0)
+++
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/AnnotatedMemberImpl.java 2010-04-29
21:41:13 UTC (rev 6201)
@@ -0,0 +1,58 @@
+/*
+ * 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.annotatedType;
+
+import java.lang.reflect.Member;
+import java.lang.reflect.Modifier;
+import java.lang.reflect.Type;
+
+import javax.enterprise.inject.spi.AnnotatedMember;
+import javax.enterprise.inject.spi.AnnotatedType;
+
+/**
+ *
+ * @author Stuart Douglas
+ *
+ */
+abstract class AnnotatedMemberImpl<X, M extends Member> extends AnnotatedImpl
implements AnnotatedMember<X>
+{
+ private final AnnotatedType<X> declaringType;
+ private final M javaMember;
+
+ protected AnnotatedMemberImpl(AnnotatedType<X> declaringType, M member,
Class<?> memberType, AnnotationStore annotations, Type genericType, Type
overridenType)
+ {
+ super(memberType, annotations, genericType, overridenType);
+ this.declaringType = declaringType;
+ this.javaMember = member;
+ }
+
+ public AnnotatedType<X> getDeclaringType()
+ {
+ return declaringType;
+ }
+
+ public M getJavaMember()
+ {
+ return javaMember;
+ }
+
+ public boolean isStatic()
+ {
+ return Modifier.isStatic(javaMember.getModifiers());
+ }
+
+}
Copied:
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/AnnotatedMethodImpl.java
(from rev 6200,
extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated/AnnotatedMethodImpl.java)
===================================================================
---
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/AnnotatedMethodImpl.java
(rev 0)
+++
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/AnnotatedMethodImpl.java 2010-04-29
21:41:13 UTC (rev 6201)
@@ -0,0 +1,38 @@
+/*
+ * 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.annotatedType;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+import java.util.Map;
+
+import javax.enterprise.inject.spi.AnnotatedMethod;
+import javax.enterprise.inject.spi.AnnotatedType;
+
+/**
+ *
+ * @author Stuart Douglas
+ *
+ */
+class AnnotatedMethodImpl<X> extends AnnotatedCallableImpl<X, Method>
implements AnnotatedMethod<X>
+{
+ AnnotatedMethodImpl(AnnotatedType<X> type, Method method, AnnotationStore
annotations, Map<Integer, AnnotationStore> parameterAnnotations, Map<Integer,
Type> parameterTypeOverrides)
+ {
+ super(type, method, method.getReturnType(), method.getParameterTypes(),
method.getGenericParameterTypes(), annotations, parameterAnnotations,
method.getGenericReturnType(), parameterTypeOverrides);
+ }
+
+}
Copied:
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/AnnotatedParameterImpl.java
(from rev 6200,
extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated/AnnotatedParameterImpl.java)
===================================================================
---
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/AnnotatedParameterImpl.java
(rev 0)
+++
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/AnnotatedParameterImpl.java 2010-04-29
21:41:13 UTC (rev 6201)
@@ -0,0 +1,52 @@
+/*
+ * 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.annotatedType;
+
+import java.lang.reflect.Type;
+
+import javax.enterprise.inject.spi.AnnotatedCallable;
+import javax.enterprise.inject.spi.AnnotatedParameter;
+
+/**
+ *
+ * @author Stuart Douglas
+ *
+ */
+class AnnotatedParameterImpl<X> extends AnnotatedImpl implements
AnnotatedParameter<X>
+{
+
+ private final int position;
+ private final AnnotatedCallable<X> declaringCallable;
+
+ AnnotatedParameterImpl(AnnotatedCallable<X> declaringCallable, Class<?>
type, int position, AnnotationStore annotations, Type genericType, Type typeOverride)
+ {
+ super(type, annotations, genericType, typeOverride);
+ this.declaringCallable = declaringCallable;
+ this.position = position;
+ }
+
+ public AnnotatedCallable<X> getDeclaringCallable()
+ {
+ return declaringCallable;
+ }
+
+ public int getPosition()
+ {
+ return position;
+ }
+
+}
Copied:
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/AnnotatedTypeBuilder.java
(from rev 6200,
extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated/AnnotatedTypeBuilder.java)
===================================================================
---
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/AnnotatedTypeBuilder.java
(rev 0)
+++
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/AnnotatedTypeBuilder.java 2010-04-29
21:41:13 UTC (rev 6201)
@@ -0,0 +1,525 @@
+/*
+ * 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.annotatedType;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import javax.enterprise.inject.spi.Annotated;
+import javax.enterprise.inject.spi.AnnotatedConstructor;
+import javax.enterprise.inject.spi.AnnotatedField;
+import javax.enterprise.inject.spi.AnnotatedMethod;
+import javax.enterprise.inject.spi.AnnotatedParameter;
+import javax.enterprise.inject.spi.AnnotatedType;
+
+import org.jboss.weld.extensions.util.ReflectionUtils;
+
+/**
+ * Class for constructing a new AnnotatedType. A new instance of builder must be
+ * used for each annotated type.
+ *
+ * In can either be created with no annotations, or the annotations can be read
+ * from the underlying class or an AnnotatedType
+ *
+ * @author Stuart Douglas
+ * @author Pete Muir
+ *
+ */
+public class AnnotatedTypeBuilder<X>
+{
+
+
+ public static <X> AnnotatedTypeBuilder<X> newInstance(Class<X>
underlying)
+ {
+ return new AnnotatedTypeBuilder<X>(underlying);
+ }
+
+ public static <X> AnnotatedTypeBuilder<X>
newInstance(AnnotatedType<X> underlying)
+ {
+ return new AnnotatedTypeBuilder<X>(underlying);
+ }
+
+ private final Class<X> underlyingType;
+ private final AnnotationBuilder typeAnnotations;
+
+ private final Map<Constructor<?>, AnnotationBuilder> constructors;
+ private final Map<Constructor<?>, Map<Integer, AnnotationBuilder>>
constructorParameters;
+ private Map<Constructor<?>, Map<Integer, Type>>
constructorParameterTypes;
+
+ private final Map<Field, AnnotationBuilder> fields;
+ private final Map<Field, Type> fieldTypes;
+
+ private final Map<Method, AnnotationBuilder> methods;
+ private final Map<Method, Map<Integer, AnnotationBuilder>>
methodParameters;
+ private final Map<Method, Map<Integer, Type>> methodParameterTypes;
+
+ protected AnnotatedTypeBuilder(Class<X> underlyingType)
+ {
+ this.underlyingType = underlyingType;
+ this.typeAnnotations = new AnnotationBuilder();
+ this.constructors = new HashMap<Constructor<?>, AnnotationBuilder>();
+ this.constructorParameters = new HashMap<Constructor<?>,
Map<Integer,AnnotationBuilder>>();
+ this.constructorParameterTypes = new HashMap<Constructor<?>,
Map<Integer,Type>>();
+ this.fields = new HashMap<Field, AnnotationBuilder>();
+ this.fieldTypes = new HashMap<Field, Type>();
+ this.methods = new HashMap<Method, AnnotationBuilder>();
+ this.methodParameters = new HashMap<Method,
Map<Integer,AnnotationBuilder>>();
+ this.methodParameterTypes = new HashMap<Method, Map<Integer,Type>>();
+ }
+
+ protected AnnotatedTypeBuilder(AnnotatedType<X> underlyingType)
+ {
+ this(underlyingType.getJavaClass());
+
+ }
+
+ public AnnotatedTypeBuilder<X> readAnnotationsFromUnderlyingType()
+ {
+ for (Annotation annotation : underlyingType.getAnnotations())
+ {
+ typeAnnotations.add(annotation);
+ }
+
+ for (Field field : ReflectionUtils.getFields(underlyingType))
+ {
+ AnnotationBuilder annotationBuilder = new AnnotationBuilder();
+ fields.put(field, annotationBuilder);
+ field.setAccessible(true);
+ for (Annotation annotation : field.getAnnotations())
+ {
+ annotationBuilder.add(annotation);
+ }
+ }
+
+ for (Method method : ReflectionUtils.getMethods(underlyingType))
+ {
+ AnnotationBuilder annotationBuilder = new AnnotationBuilder();
+ method.setAccessible(true);
+ methods.put(method, annotationBuilder);
+ for (Annotation annotation : method.getAnnotations())
+ {
+ annotationBuilder.add(annotation);
+ }
+ Map<Integer, AnnotationBuilder> parameters = new HashMap<Integer,
AnnotationBuilder>();
+ methodParameters.put(method, parameters);
+ for (int i = 0; i < method.getParameterTypes().length; ++i)
+ {
+ AnnotationBuilder parameterAnnotationBuilder = new AnnotationBuilder();
+ parameters.put(i, parameterAnnotationBuilder);
+ for (Annotation annotation : method.getParameterAnnotations()[i])
+ {
+ parameterAnnotationBuilder.add(annotation);
+ }
+ }
+ }
+
+ for (Constructor<?> constructor : underlyingType.getDeclaredConstructors())
+ {
+ AnnotationBuilder annotationBuilder = new AnnotationBuilder();
+ constructor.setAccessible(true);
+ constructors.put(constructor, annotationBuilder);
+ for (Annotation annotation : constructor.getAnnotations())
+ {
+ annotationBuilder.add(annotation);
+ }
+ Map<Integer, AnnotationBuilder> mparams = new HashMap<Integer,
AnnotationBuilder>();
+ constructorParameters.put(constructor, mparams);
+ for (int i = 0; i < constructor.getParameterTypes().length; ++i)
+ {
+ AnnotationBuilder parameterAnnotationBuilder = new AnnotationBuilder();
+ mparams.put(i, parameterAnnotationBuilder);
+ for (Annotation annotation : constructor.getParameterAnnotations()[i])
+ {
+ parameterAnnotationBuilder.add(annotation);
+ }
+ }
+ }
+ return this;
+ }
+
+ public AnnotatedTypeBuilder<X> addToClass(Annotation annotation)
+ {
+ typeAnnotations.add(annotation);
+ return this;
+ }
+
+ public AnnotatedTypeBuilder<X> removeFromClass(Class<? extends Annotation>
annotation)
+ {
+ typeAnnotations.remove(annotation);
+ return this;
+ }
+
+ public AnnotatedTypeBuilder<X> addToField(Field field, Annotation annotation)
+ {
+ if (fields.get(field) == null)
+ {
+ fields.put(field, new AnnotationBuilder());
+ }
+ fields.get(field).add(annotation);
+ return this;
+ }
+
+ public AnnotatedTypeBuilder<X> removeFromField(Field field, Class<? extends
Annotation> annotation)
+ {
+ if (fields.get(field) != null)
+ {
+ fields.get(field).remove(annotation);
+ }
+ return this;
+ }
+
+ public AnnotatedTypeBuilder<X> addToMethod(Method method, Annotation
annotation)
+ {
+ if (methods.get(method) == null)
+ {
+ methods.put(method, new AnnotationBuilder());
+ }
+ methods.get(method).add(annotation);
+ return this;
+ }
+
+ public AnnotatedTypeBuilder<X> removeFromMethod(Method method, Class<?
extends Annotation> annotation)
+ {
+ if (methods.get(method) != null)
+ {
+ methods.get(method).remove(annotation);
+ }
+ return this;
+ }
+
+ public AnnotatedTypeBuilder<X> addToMethodParameter(Method method, int position,
Annotation annotation)
+ {
+ if (!methods.containsKey(method))
+ {
+ methods.put(method, new AnnotationBuilder());
+ }
+ if (methodParameters.get(method) == null)
+ {
+ methodParameters.put(method, new HashMap<Integer, AnnotationBuilder>());
+ }
+ if (methodParameters.get(method).get(position) == null)
+ {
+ methodParameters.get(method).put(position, new AnnotationBuilder());
+ }
+ methodParameters.get(method).get(position).add(annotation);
+ return this;
+ }
+
+ public AnnotatedTypeBuilder<X> removeFromMethodParameter(Method method, int
position, Class<? extends Annotation> annotation)
+ {
+ if (methodParameters.get(method) != null)
+ {
+ if (methodParameters.get(method).get(position) != null)
+ {
+ methodParameters.get(method).get(position).remove(annotation);
+ }
+ }
+ return this;
+ }
+
+ public AnnotatedTypeBuilder<X> addToConstructor(Constructor<X>
constructor, Annotation annotation)
+ {
+ if (constructors.get(constructor) == null)
+ {
+ constructors.put(constructor, new AnnotationBuilder());
+ }
+ constructors.get(constructor).add(annotation);
+ return this;
+ }
+
+ public AnnotatedTypeBuilder<X> removeFromConstructor(Constructor<?>
constructor, Class<? extends Annotation> annotation)
+ {
+ if (constructors.get(constructor) != null)
+ {
+ constructors.get(constructor).remove(annotation);
+ }
+ return this;
+ }
+
+ public AnnotatedTypeBuilder<X> addToConstructorParameter(Constructor<X>
constructor, int position, Annotation annotation)
+ {
+ if (!constructors.containsKey(constructor))
+ {
+ constructors.put(constructor, new AnnotationBuilder());
+ }
+ if (constructorParameters.get(constructor) == null)
+ {
+ constructorParameters.put(constructor, new HashMap<Integer,
AnnotationBuilder>());
+ }
+ if (constructorParameters.get(constructor).get(position) == null)
+ {
+ constructorParameters.get(constructor).put(position, new AnnotationBuilder());
+ }
+ constructorParameters.get(constructor).get(position).add(annotation);
+ return this;
+ }
+
+ public AnnotatedTypeBuilder<X>
removeFromConstructorParameter(Constructor<X> constructor, int position, Class<?
extends Annotation> annotation)
+ {
+ if (constructorParameters.get(constructor) != null)
+ {
+ if (constructorParameters.get(constructor).get(position) != null)
+ {
+ constructorParameters.get(constructor).get(position).remove(annotation);
+ }
+ }
+ return this;
+ }
+
+ public AnnotatedTypeBuilder<X> removeFromAll(Class<? extends Annotation>
annotation)
+ {
+ removeFromClass(annotation);
+ for (Entry<Field, AnnotationBuilder> field : fields.entrySet())
+ {
+ field.getValue().remove(annotation);
+ }
+ for (Entry<Method, AnnotationBuilder> method : methods.entrySet())
+ {
+ method.getValue().remove(annotation);
+ if (methodParameters.get(method.getKey()) != null)
+ {
+ for (Entry<Integer, AnnotationBuilder> parameter :
methodParameters.get(method.getKey()).entrySet())
+ {
+ parameter.getValue().remove(annotation);
+ }
+ }
+ }
+ for (Entry<Constructor<?>, AnnotationBuilder> constructor :
constructors.entrySet())
+ {
+ constructor.getValue().remove(annotation);
+ if (constructorParameters.get(constructor.getKey()) != null)
+ {
+ for (Entry<Integer, AnnotationBuilder> parameter :
constructorParameters.get(constructor.getKey()).entrySet())
+ {
+ parameter.getValue().remove(annotation);
+ }
+ }
+ }
+ return this;
+ }
+
+ public <T extends Annotation> AnnotatedTypeBuilder<X>
redefineMemberParameters(Class<T> annotationType,
ParameterAnnotationRedefiner<T> redefinition)
+ {
+ for (Entry<Method, AnnotationBuilder> method : methods.entrySet())
+ {
+ if (methodParameters.get(method.getKey()) != null)
+ {
+ for (Entry<Integer, AnnotationBuilder> parameter :
methodParameters.get(method.getKey()).entrySet())
+ {
+ redefineAnnotationBuilder(annotationType, redefinition, new
Parameter(method.getKey(), parameter.getKey()), parameter.getValue());
+ }
+ }
+ }
+ for (Entry<Constructor<?>, AnnotationBuilder> constructor :
constructors.entrySet())
+ {
+ if (constructorParameters.get(constructor.getKey()) != null)
+ {
+ for (Entry<Integer, AnnotationBuilder> parameter :
constructorParameters.get(constructor.getKey()).entrySet())
+ {
+ redefineAnnotationBuilder(annotationType, redefinition, new
Parameter(constructor.getKey(), parameter.getKey()), parameter.getValue());
+ }
+ }
+ }
+ return this;
+ }
+
+ public <T extends Annotation> AnnotatedTypeBuilder<X>
redefineMembers(Class<T> annotationType, MemberAnnotationRedefiner<T>
redefinition)
+ {
+ for (Entry<Field, AnnotationBuilder> field : fields.entrySet())
+ {
+ redefineAnnotationBuilder(annotationType, redefinition, field.getKey(),
field.getValue());
+ }
+ for (Entry<Method, AnnotationBuilder> method : methods.entrySet())
+ {
+ redefineAnnotationBuilder(annotationType, redefinition, method.getKey(),
method.getValue());
+ }
+ for (Entry<Constructor<?>, AnnotationBuilder> constructor :
constructors.entrySet())
+ {
+ redefineAnnotationBuilder(annotationType, redefinition, constructor.getKey(),
constructor.getValue());
+ }
+ return this;
+ }
+
+ protected <T extends Annotation, A> void
redefineAnnotationBuilder(Class<T> annotationType, AnnotationRedefiner<T, A>
redefinition, A annotated, AnnotationBuilder builder)
+ {
+ if (builder.isAnnotationPresent(annotationType))
+ {
+ builder.remove(annotationType);
+ T redefinedAnnotation =
redefinition.redefine(builder.getAnnotation(annotationType), annotated, builder);
+ if (redefinedAnnotation != null)
+ {
+ builder.add(redefinedAnnotation);
+ }
+ }
+ }
+
+ /**
+ * merges the annotations from an existing AnnotatedType. If they both have
+ * the same annotation on an element overwriteExisting determines which one
+ * to keep
+ *
+ * @param type
+ * @param overwriteExisting
+ * @return
+ */
+ public AnnotatedTypeBuilder<X> mergeAnnotations(AnnotatedType<X> type,
boolean overwriteExisting)
+ {
+ mergeAnnotationsOnElement(type, overwriteExisting, typeAnnotations);
+ for (AnnotatedField<? super X> field : type.getFields())
+ {
+ if (fields.get(field.getJavaMember()) == null)
+ {
+ fields.put(field.getJavaMember(), new AnnotationBuilder());
+ }
+ mergeAnnotationsOnElement(field, overwriteExisting,
fields.get(field.getJavaMember()));
+ }
+ for (AnnotatedMethod<? super X> method : type.getMethods())
+ {
+ if (methods.get(method.getJavaMember()) == null)
+ {
+ methods.put(method.getJavaMember(), new AnnotationBuilder());
+ }
+ mergeAnnotationsOnElement(method, overwriteExisting,
methods.get(method.getJavaMember()));
+ for (AnnotatedParameter<? super X> p : method.getParameters())
+ {
+ if (methodParameters.get(method.getJavaMember()) == null)
+ {
+ methodParameters.put(method.getJavaMember(), new HashMap<Integer,
AnnotationBuilder>());
+ }
+ if (methodParameters.get(method.getJavaMember()).get(p.getPosition()) ==
null)
+ {
+ methodParameters.get(method.getJavaMember()).put(p.getPosition(), new
AnnotationBuilder());
+ }
+ mergeAnnotationsOnElement(p, overwriteExisting,
methodParameters.get(method.getJavaMember()).get(p.getPosition()));
+ }
+ }
+ for (AnnotatedConstructor<? super X> constructor : type.getConstructors())
+ {
+ if (constructors.get(constructor.getJavaMember()) == null)
+ {
+ constructors.put(constructor.getJavaMember(), new AnnotationBuilder());
+ }
+ mergeAnnotationsOnElement(constructor, overwriteExisting,
constructors.get(constructor.getJavaMember()));
+ for (AnnotatedParameter<? super X> p : constructor.getParameters())
+ {
+ if (constructorParameters.get(constructor.getJavaMember()) == null)
+ {
+ constructorParameters.put(constructor.getJavaMember(), new
HashMap<Integer, AnnotationBuilder>());
+ }
+ if
(constructorParameters.get(constructor.getJavaMember()).get(p.getPosition()) == null)
+ {
+
constructorParameters.get(constructor.getJavaMember()).put(p.getPosition(), new
AnnotationBuilder());
+ }
+ mergeAnnotationsOnElement(p, overwriteExisting,
constructorParameters.get(constructor.getJavaMember()).get(p.getPosition()));
+ }
+ }
+ return this;
+ }
+
+ protected void mergeAnnotationsOnElement(Annotated annotated, boolean
overwriteExisting, AnnotationBuilder typeAnnotations)
+ {
+ for (Annotation annotation : annotated.getAnnotations())
+ {
+ if (typeAnnotations.getAnnotation(annotation.annotationType()) != null)
+ {
+ if (overwriteExisting)
+ {
+ typeAnnotations.remove(annotation.annotationType());
+ typeAnnotations.add(annotation);
+ }
+ }
+ else
+ {
+ typeAnnotations.add(annotation);
+ }
+ }
+ }
+
+ public AnnotatedType<X> create()
+ {
+ Map<Constructor<?>, Map<Integer, AnnotationStore>>
constructorParameterAnnnotations = new HashMap<Constructor<?>, Map<Integer,
AnnotationStore>>();
+ Map<Constructor<?>, AnnotationStore> constructorAnnotations = new
HashMap<Constructor<?>, AnnotationStore>();
+ Map<Method, Map<Integer, AnnotationStore>> methodParameterAnnnotations
= new HashMap<Method, Map<Integer, AnnotationStore>>();
+ Map<Method, AnnotationStore> methodAnnotations = new HashMap<Method,
AnnotationStore>();
+ Map<Field, AnnotationStore> fieldAnnotations = new HashMap<Field,
AnnotationStore>();
+
+ for (Entry<Field, AnnotationBuilder> field : fields.entrySet())
+ {
+ fieldAnnotations.put(field.getKey(), field.getValue().create());
+ }
+
+ for (Entry<Method, AnnotationBuilder> method : methods.entrySet())
+ {
+ methodAnnotations.put(method.getKey(), method.getValue().create());
+ }
+ for (Entry<Method, Map<Integer, AnnotationBuilder>> parameters :
methodParameters.entrySet())
+ {
+ Map<Integer, AnnotationStore> parameterAnnotations = new
HashMap<Integer, AnnotationStore>();
+ methodParameterAnnnotations.put(parameters.getKey(), parameterAnnotations);
+ for (Entry<Integer, AnnotationBuilder> parameter :
parameters.getValue().entrySet())
+ {
+ parameterAnnotations.put(parameter.getKey(), parameter.getValue().create());
+ }
+ }
+
+ for (Entry<Constructor<?>, AnnotationBuilder> constructor :
constructors.entrySet())
+ {
+ constructorAnnotations.put(constructor.getKey(),
constructor.getValue().create());
+ }
+ for (Entry<Constructor<?>, Map<Integer, AnnotationBuilder>>
parameters : constructorParameters.entrySet())
+ {
+ Map<Integer, AnnotationStore> parameterAnnotations = new
HashMap<Integer, AnnotationStore>();
+ constructorParameterAnnnotations.put(parameters.getKey(),
parameterAnnotations);
+ for (Entry<Integer, AnnotationBuilder> parameter :
parameters.getValue().entrySet())
+ {
+ parameterAnnotations.put(parameter.getKey(), parameter.getValue().create());
+ }
+ }
+
+ return new AnnotatedTypeImpl<X>(underlyingType, typeAnnotations.create(),
fieldAnnotations, methodAnnotations, methodParameterAnnnotations, constructorAnnotations,
constructorParameterAnnnotations, fieldTypes, methodParameterTypes,
constructorParameterTypes);
+ }
+
+ public void overrideFieldType(Field field, Type type)
+ {
+ fieldTypes.put(field, type);
+ }
+
+ public void overrideMethodParameterType(Method method, Type type, int position)
+ {
+ if (methodParameterTypes.get(method) == null)
+ {
+ methodParameterTypes.put(method, new HashMap<Integer, Type>());
+ }
+ methodParameterTypes.get(method).put(position, type);
+ }
+
+ public void overrideConstructorParameterType(Constructor<?> constructor, Type
type, int position)
+ {
+ if (constructorParameterTypes.get(constructor) == null)
+ {
+ constructorParameterTypes.put(constructor, new HashMap<Integer, Type>());
+ }
+ constructorParameterTypes.get(constructor).put(position, type);
+ }
+
+}
Copied:
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/AnnotatedTypeImpl.java
(from rev 6200,
extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated/AnnotatedTypeImpl.java)
===================================================================
---
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/AnnotatedTypeImpl.java
(rev 0)
+++
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/AnnotatedTypeImpl.java 2010-04-29
21:41:13 UTC (rev 6201)
@@ -0,0 +1,130 @@
+/*
+ * 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.annotatedType;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
+
+import javax.enterprise.inject.spi.AnnotatedConstructor;
+import javax.enterprise.inject.spi.AnnotatedField;
+import javax.enterprise.inject.spi.AnnotatedMethod;
+import javax.enterprise.inject.spi.AnnotatedType;
+
+/**
+ * AnnotatedType implementation for adding beans in the BeforeBeanDiscovery
+ * event
+ *
+ * @author Stuart Douglas
+ *
+ */
+class AnnotatedTypeImpl<X> extends AnnotatedImpl implements AnnotatedType<X>
+{
+
+ private final Set<AnnotatedConstructor<X>> constructors;
+ private final Set<AnnotatedField<? super X>> fields;
+ private final Set<AnnotatedMethod<? super X>> methods;
+
+ private final Class<X> javaClass;
+
+ /**
+ * We make sure that there is a NewAnnotatedMember for every public
+ * method/field/constructor
+ *
+ * If annotation have been added to other methods as well we add them to
+ *
+ */
+ AnnotatedTypeImpl(Class<X> clazz, AnnotationStore typeAnnotations, Map<Field,
AnnotationStore> fieldAnnotations, Map<Method, AnnotationStore>
methodAnnotations, Map<Method, Map<Integer, AnnotationStore>>
methodParameterAnnotations, Map<Constructor<?>, AnnotationStore>
constructorAnnotations, Map<Constructor<?>, Map<Integer,
AnnotationStore>> constructorParameterAnnotations, Map<Field, Type>
fieldTypes, Map<Method, Map<Integer, Type>> methodParameterTypes,
Map<Constructor<?>, Map<Integer, Type>> constructorParameterTypes)
+ {
+ super(clazz, typeAnnotations, null, null);
+ this.javaClass = clazz;
+ this.constructors = new HashSet<AnnotatedConstructor<X>>();
+ Set<Constructor<?>> cset = new HashSet<Constructor<?>>();
+ Set<Method> mset = new HashSet<Method>();
+ Set<Field> fset = new HashSet<Field>();
+ for (Constructor<?> c : clazz.getConstructors())
+ {
+ AnnotatedConstructor<X> nc = new AnnotatedConstructorImpl<X>(this,
c, constructorAnnotations.get(c), constructorParameterAnnotations.get(c),
constructorParameterTypes.get(c));
+ constructors.add(nc);
+ cset.add(c);
+ }
+ for (Entry<Constructor<?>, AnnotationStore> c :
constructorAnnotations.entrySet())
+ {
+ if (!cset.contains(c.getKey()))
+ {
+ AnnotatedConstructor<X> nc = new
AnnotatedConstructorImpl<X>(this, c.getKey(), c.getValue(),
constructorParameterAnnotations.get(c.getKey()),
constructorParameterTypes.get(c.getKey()));
+ constructors.add(nc);
+ }
+ }
+ this.methods = new HashSet<AnnotatedMethod<? super X>>();
+ for (Method m : clazz.getMethods())
+ {
+ AnnotatedMethodImpl<X> met = new AnnotatedMethodImpl<X>(this, m,
methodAnnotations.get(m), methodParameterAnnotations.get(m),
methodParameterTypes.get(m));
+ methods.add(met);
+ mset.add(m);
+ }
+ for (Entry<Method, AnnotationStore> c : methodAnnotations.entrySet())
+ {
+ if (!mset.contains(c.getKey()))
+ {
+ AnnotatedMethodImpl<X> nc = new AnnotatedMethodImpl<X>(this,
c.getKey(), c.getValue(), methodParameterAnnotations.get(c.getKey()),
methodParameterTypes.get(c.getKey()));
+ methods.add(nc);
+ }
+ }
+ this.fields = new HashSet<AnnotatedField<? super X>>();
+ for (Field f : clazz.getFields())
+ {
+ AnnotatedField<X> b = new AnnotatedFieldImpl<X>(this, f,
fieldAnnotations.get(f), fieldTypes.get(f));
+ fields.add(b);
+ fset.add(f);
+ }
+ for (Entry<Field, AnnotationStore> e : fieldAnnotations.entrySet())
+ {
+ if (!fset.contains(e.getKey()))
+ {
+ fields.add(new AnnotatedFieldImpl<X>(this, e.getKey(), e.getValue(),
fieldTypes.get(e.getKey())));
+ }
+ }
+ }
+
+ public Set<AnnotatedConstructor<X>> getConstructors()
+ {
+ return Collections.unmodifiableSet(constructors);
+ }
+
+ public Set<AnnotatedField<? super X>> getFields()
+ {
+ return Collections.unmodifiableSet(fields);
+ }
+
+ public Class<X> getJavaClass()
+ {
+ return javaClass;
+ }
+
+ public Set<AnnotatedMethod<? super X>> getMethods()
+ {
+ return Collections.unmodifiableSet(methods);
+ }
+
+}
Deleted:
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/AnnotationBuilder.java
===================================================================
---
extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated/AnnotationBuilder.java 2010-04-28
16:45:31 UTC (rev 6191)
+++
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/AnnotationBuilder.java 2010-04-29
21:41:13 UTC (rev 6201)
@@ -1,94 +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.util.annotated;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.AnnotatedElement;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-/**
- *
- * @author Stuart Douglas
- *
- */
-class AnnotationBuilder
-{
- private HashMap<Class<? extends Annotation>, Annotation> annotationMap =
new HashMap<Class<? extends Annotation>, Annotation>();
- private Set<Annotation> annotationSet = new HashSet<Annotation>();
-
- public AnnotationBuilder add(Annotation a)
- {
- annotationSet.add(a);
- annotationMap.put(a.annotationType(), a);
- return this;
- }
-
- public void remove(Class<? extends Annotation> a)
- {
- Iterator<Annotation> it = annotationSet.iterator();
- while (it.hasNext())
- {
- Annotation an = it.next();
- if (a.isAssignableFrom(an.annotationType()))
- {
- it.remove();
- }
- }
- annotationMap.remove(a);
- }
-
- public AnnotationStore create()
- {
- return new AnnotationStore(annotationMap, annotationSet);
- }
-
- public AnnotationBuilder addAll(Set<Annotation> annotations)
- {
- for (Annotation annotation : annotations)
- {
- add(annotation);
- }
- return this;
- }
-
- public AnnotationBuilder addAll(AnnotationStore annotations)
- {
- for (Annotation annotation : annotations.getAnnotations())
- {
- add(annotation);
- }
- return this;
- }
-
- public AnnotationBuilder addAll(AnnotatedElement element)
- {
- for (Annotation a : element.getAnnotations())
- {
- add(a);
- }
- return this;
- }
-
- public <T extends Annotation> T getAnnotation(Class<T> anType)
- {
- return (T) annotationMap.get(anType);
- }
-
-}
Copied:
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/AnnotationBuilder.java
(from rev 6200,
extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated/AnnotationBuilder.java)
===================================================================
---
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/AnnotationBuilder.java
(rev 0)
+++
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/AnnotationBuilder.java 2010-04-29
21:41:13 UTC (rev 6201)
@@ -0,0 +1,105 @@
+/*
+ * 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.annotatedType;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AnnotatedElement;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+/**
+ *
+ * @author Stuart Douglas
+ *
+ */
+public class AnnotationBuilder
+{
+ private final HashMap<Class<? extends Annotation>, Annotation>
annotationMap = new HashMap<Class<? extends Annotation>, Annotation>();
+ private final Set<Annotation> annotationSet = new HashSet<Annotation>();
+
+ public AnnotationBuilder add(Annotation annotation)
+ {
+ annotationSet.add(annotation);
+ annotationMap.put(annotation.annotationType(), annotation);
+ return this;
+ }
+
+ public void remove(Class<? extends Annotation> annotation)
+ {
+ Iterator<Annotation> it = annotationSet.iterator();
+ while (it.hasNext())
+ {
+ Annotation an = it.next();
+ if (annotation.isAssignableFrom(an.annotationType()))
+ {
+ it.remove();
+ }
+ }
+ annotationMap.remove(annotation);
+ }
+
+ AnnotationStore create()
+ {
+ return new AnnotationStore(annotationMap, annotationSet);
+ }
+
+ public AnnotationBuilder addAll(Set<Annotation> annotations)
+ {
+ for (Annotation annotation : annotations)
+ {
+ add(annotation);
+ }
+ return this;
+ }
+
+ public AnnotationBuilder addAll(AnnotationStore annotations)
+ {
+ for (Annotation annotation : annotations.getAnnotations())
+ {
+ add(annotation);
+ }
+ return this;
+ }
+
+ public AnnotationBuilder addAll(AnnotatedElement element)
+ {
+ for (Annotation a : element.getAnnotations())
+ {
+ add(a);
+ }
+ return this;
+ }
+
+ public <T extends Annotation> T getAnnotation(Class<T> anType)
+ {
+ return (T) annotationMap.get(anType);
+ }
+
+ public boolean isAnnotationPresent(Class<?> annotationType)
+ {
+ return annotationMap.containsKey(annotationType);
+ }
+
+ @Override
+ public String toString()
+ {
+ return annotationSet.toString();
+ }
+
+}
Deleted:
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/AnnotationRedefiner.java
===================================================================
---
extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated/AnnotationRedefiner.java 2010-04-28
16:45:31 UTC (rev 6191)
+++
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/AnnotationRedefiner.java 2010-04-29
21:41:13 UTC (rev 6201)
@@ -1,24 +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.util.annotated;
-
-import java.lang.annotation.Annotation;
-
-public interface AnnotationRedefiner<X extends Annotation>
-{
- public X redefine(X annotation, AnnotationBuilder annotations);
-}
Copied:
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/AnnotationRedefiner.java
(from rev 6196,
extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated/AnnotationRedefiner.java)
===================================================================
---
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/AnnotationRedefiner.java
(rev 0)
+++
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/AnnotationRedefiner.java 2010-04-29
21:41:13 UTC (rev 6201)
@@ -0,0 +1,24 @@
+/*
+ * 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.annotatedType;
+
+import java.lang.annotation.Annotation;
+
+public interface AnnotationRedefiner<T extends Annotation, A>
+{
+ public T redefine(T annotation, A annotated, AnnotationBuilder annotations);
+}
Deleted:
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/AnnotationStore.java
===================================================================
---
extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated/AnnotationStore.java 2010-04-28
16:45:31 UTC (rev 6191)
+++
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/AnnotationStore.java 2010-04-29
21:41:13 UTC (rev 6201)
@@ -1,63 +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.util.annotated;
-
-import java.lang.annotation.Annotation;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- *
- * @author Stuart Douglas
- *
- */
-class AnnotationStore
-{
-
- private final HashMap<Class<? extends Annotation>, Annotation>
annotationMap;
- private final Set<Annotation> annotationSet;
-
- AnnotationStore(HashMap<Class<? extends Annotation>, Annotation>
annotationMap, Set<Annotation> annotationSet)
- {
- this.annotationMap = annotationMap;
- this.annotationSet = annotationSet;
- }
-
- AnnotationStore()
- {
- this.annotationMap = new HashMap<Class<? extends Annotation>,
Annotation>();
- this.annotationSet = new HashSet<Annotation>();
- }
-
- public <T extends Annotation> T getAnnotation(Class<T> annotationType)
- {
- return annotationType.cast(annotationMap.get(annotationType));
- }
-
- public Set<Annotation> getAnnotations()
- {
- return Collections.unmodifiableSet(annotationSet);
- }
-
- public boolean isAnnotationPresent(Class<? extends Annotation> annotationType)
- {
- return annotationMap.containsKey(annotationType);
- }
-
-}
Copied:
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/AnnotationStore.java
(from rev 6200,
extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated/AnnotationStore.java)
===================================================================
---
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/AnnotationStore.java
(rev 0)
+++
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/AnnotationStore.java 2010-04-29
21:41:13 UTC (rev 6201)
@@ -0,0 +1,63 @@
+/*
+ * 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.annotatedType;
+
+import java.lang.annotation.Annotation;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ *
+ * @author Stuart Douglas
+ *
+ */
+class AnnotationStore
+{
+
+ private final HashMap<Class<? extends Annotation>, Annotation>
annotationMap;
+ private final Set<Annotation> annotationSet;
+
+ AnnotationStore(HashMap<Class<? extends Annotation>, Annotation>
annotationMap, Set<Annotation> annotationSet)
+ {
+ this.annotationMap = annotationMap;
+ this.annotationSet = annotationSet;
+ }
+
+ AnnotationStore()
+ {
+ this.annotationMap = new HashMap<Class<? extends Annotation>,
Annotation>();
+ this.annotationSet = new HashSet<Annotation>();
+ }
+
+ <T extends Annotation> T getAnnotation(Class<T> annotationType)
+ {
+ return annotationType.cast(annotationMap.get(annotationType));
+ }
+
+ Set<Annotation> getAnnotations()
+ {
+ return Collections.unmodifiableSet(annotationSet);
+ }
+
+ boolean isAnnotationPresent(Class<? extends Annotation> annotationType)
+ {
+ return annotationMap.containsKey(annotationType);
+ }
+
+}
Copied:
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/MemberAnnotationRedefiner.java
(from rev 6198,
extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated/MemberAnnotationRedefiner.java)
===================================================================
---
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/MemberAnnotationRedefiner.java
(rev 0)
+++
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/MemberAnnotationRedefiner.java 2010-04-29
21:41:13 UTC (rev 6201)
@@ -0,0 +1,9 @@
+package org.jboss.weld.extensions.annotatedType;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Member;
+
+public interface MemberAnnotationRedefiner<T extends Annotation> extends
AnnotationRedefiner<T, Member>
+{
+
+}
Deleted:
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/NewAnnotatedConstructor.java
===================================================================
---
extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated/NewAnnotatedConstructor.java 2010-04-28
16:45:31 UTC (rev 6191)
+++
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/NewAnnotatedConstructor.java 2010-04-29
21:41:13 UTC (rev 6201)
@@ -1,58 +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.util.annotated;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Type;
-import java.util.Map;
-
-import javax.enterprise.inject.spi.AnnotatedConstructor;
-
-/**
- *
- * @author Stuart Douglas
- *
- */
-class NewAnnotatedConstructor<X> extends AbstractNewAnnotatedCallable<X,
Constructor<X>> implements AnnotatedConstructor<X>
-{
-
- NewAnnotatedConstructor(NewAnnotatedType<X> type, Constructor<?>
constructor, AnnotationStore annotations, Map<Integer, AnnotationStore>
parameterAnnotations, Map<Integer, Type> typeOverrides)
- {
-
- super(type, (Constructor<X>) constructor, constructor.getDeclaringClass(),
constructor.getParameterTypes(), getGenericArray(constructor), annotations,
parameterAnnotations, null, typeOverrides);
- }
-
- private static Type[] getGenericArray(Constructor<?> constructor)
- {
- Type[] genericTypes = constructor.getGenericParameterTypes();
- // for inner classes genericTypes and parameterTypes can be different
- // length, this is a hack to fix this.
- // TODO: investigate this behaviour further, on different JVM's and
- // compilers
- if (genericTypes.length + 1 == constructor.getParameterTypes().length)
- {
- genericTypes = new Type[constructor.getGenericParameterTypes().length + 1];
- genericTypes[0] = constructor.getParameterTypes()[0];
- for (int i = 0; i < constructor.getGenericParameterTypes().length; ++i)
- {
- genericTypes[i + 1] = constructor.getGenericParameterTypes()[i];
- }
- }
- return genericTypes;
- }
-
-}
Deleted:
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/NewAnnotatedField.java
===================================================================
---
extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated/NewAnnotatedField.java 2010-04-28
16:45:31 UTC (rev 6191)
+++
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/NewAnnotatedField.java 2010-04-29
21:41:13 UTC (rev 6201)
@@ -1,38 +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.util.annotated;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Type;
-
-import javax.enterprise.inject.spi.AnnotatedField;
-import javax.enterprise.inject.spi.AnnotatedType;
-
-/**
- *
- * @author Stuart Douglas
- *
- */
-class NewAnnotatedField<X> extends AbstractNewAnnotatedMember<X, Field>
implements AnnotatedField<X>
-{
-
- NewAnnotatedField(AnnotatedType<X> declaringType, Field field, AnnotationStore
annotations, Type overridenType)
- {
- super(declaringType, field, field.getType(), annotations, field.getGenericType(),
overridenType);
- }
-
-}
Deleted:
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/NewAnnotatedMethod.java
===================================================================
---
extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated/NewAnnotatedMethod.java 2010-04-28
16:45:31 UTC (rev 6191)
+++
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/NewAnnotatedMethod.java 2010-04-29
21:41:13 UTC (rev 6201)
@@ -1,38 +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.util.annotated;
-
-import java.lang.reflect.Method;
-import java.lang.reflect.Type;
-import java.util.Map;
-
-import javax.enterprise.inject.spi.AnnotatedMethod;
-import javax.enterprise.inject.spi.AnnotatedType;
-
-/**
- *
- * @author Stuart Douglas
- *
- */
-class NewAnnotatedMethod<X> extends AbstractNewAnnotatedCallable<X, Method>
implements AnnotatedMethod<X>
-{
- NewAnnotatedMethod(AnnotatedType<X> type, Method method, AnnotationStore
annotations, Map<Integer, AnnotationStore> parameterAnnotations, Map<Integer,
Type> parameterTypeOverrides)
- {
- super(type, method, method.getReturnType(), method.getParameterTypes(),
method.getGenericParameterTypes(), annotations, parameterAnnotations,
method.getGenericReturnType(), parameterTypeOverrides);
- }
-
-}
Deleted:
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/NewAnnotatedParameter.java
===================================================================
---
extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated/NewAnnotatedParameter.java 2010-04-28
16:45:31 UTC (rev 6191)
+++
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/NewAnnotatedParameter.java 2010-04-29
21:41:13 UTC (rev 6201)
@@ -1,52 +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.util.annotated;
-
-import java.lang.reflect.Type;
-
-import javax.enterprise.inject.spi.AnnotatedCallable;
-import javax.enterprise.inject.spi.AnnotatedParameter;
-
-/**
- *
- * @author Stuart Douglas
- *
- */
-class NewAnnotatedParameter<X> extends AbstractNewAnnotatedElement implements
AnnotatedParameter<X>
-{
-
- private final int position;
- private final AnnotatedCallable<X> declaringCallable;
-
- NewAnnotatedParameter(AnnotatedCallable<X> declaringCallable, Class<?>
type, int position, AnnotationStore annotations, Type genericType, Type typeOverride)
- {
- super(type, annotations, genericType, typeOverride);
- this.declaringCallable = declaringCallable;
- this.position = position;
- }
-
- public AnnotatedCallable<X> getDeclaringCallable()
- {
- return declaringCallable;
- }
-
- public int getPosition()
- {
- return position;
- }
-
-}
Deleted:
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/NewAnnotatedType.java
===================================================================
---
extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated/NewAnnotatedType.java 2010-04-28
16:45:31 UTC (rev 6191)
+++
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/NewAnnotatedType.java 2010-04-29
21:41:13 UTC (rev 6201)
@@ -1,130 +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.util.annotated;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.lang.reflect.Type;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.Map.Entry;
-
-import javax.enterprise.inject.spi.AnnotatedConstructor;
-import javax.enterprise.inject.spi.AnnotatedField;
-import javax.enterprise.inject.spi.AnnotatedMethod;
-import javax.enterprise.inject.spi.AnnotatedType;
-
-/**
- * AnnotatedType implementation for adding beans in the BeforeBeanDiscovery
- * event
- *
- * @author Stuart Douglas
- *
- */
-class NewAnnotatedType<X> extends AbstractNewAnnotatedElement implements
AnnotatedType<X>
-{
-
- private final Set<AnnotatedConstructor<X>> constructors;
- private final Set<AnnotatedField<? super X>> fields;
- private final Set<AnnotatedMethod<? super X>> methods;
-
- private final Class<X> javaClass;
-
- /**
- * We make sure that there is a NewAnnotatedMember for every public
- * method/field/constructor
- *
- * If annotation have been added to other methods as well we add them to
- *
- */
- NewAnnotatedType(Class<X> clazz, AnnotationStore typeAnnotations, Map<Field,
AnnotationStore> fieldAnnotations, Map<Method, AnnotationStore>
methodAnnotations, Map<Method, Map<Integer, AnnotationStore>>
methodParameterAnnotations, Map<Constructor<X>, AnnotationStore>
constructorAnnotations, Map<Constructor<X>, Map<Integer,
AnnotationStore>> constructorParameterAnnotations, Map<Field, Type>
fieldTypes, Map<Method, Map<Integer, Type>> methodParameterTypes,
Map<Constructor<?>, Map<Integer, Type>> constructorParameterTypes)
- {
- super(clazz, typeAnnotations, null, null);
- this.javaClass = clazz;
- this.constructors = new HashSet<AnnotatedConstructor<X>>();
- Set<Constructor<?>> cset = new HashSet<Constructor<?>>();
- Set<Method> mset = new HashSet<Method>();
- Set<Field> fset = new HashSet<Field>();
- for (Constructor<?> c : clazz.getConstructors())
- {
- NewAnnotatedConstructor<X> nc = new NewAnnotatedConstructor<X>(this,
c, constructorAnnotations.get(c), constructorParameterAnnotations.get(c),
constructorParameterTypes.get(c));
- constructors.add(nc);
- cset.add(c);
- }
- for (Entry<Constructor<X>, AnnotationStore> c :
constructorAnnotations.entrySet())
- {
- if (!cset.contains(c.getKey()))
- {
- NewAnnotatedConstructor<X> nc = new
NewAnnotatedConstructor<X>(this, c.getKey(), c.getValue(),
constructorParameterAnnotations.get(c.getKey()),
constructorParameterTypes.get(c.getKey()));
- constructors.add(nc);
- }
- }
- this.methods = new HashSet<AnnotatedMethod<? super X>>();
- for (Method m : clazz.getMethods())
- {
- NewAnnotatedMethod<X> met = new NewAnnotatedMethod<X>(this, m,
methodAnnotations.get(m), methodParameterAnnotations.get(m),
methodParameterTypes.get(m));
- methods.add(met);
- mset.add(m);
- }
- for (Entry<Method, AnnotationStore> c : methodAnnotations.entrySet())
- {
- if (!mset.contains(c.getKey()))
- {
- NewAnnotatedMethod<X> nc = new NewAnnotatedMethod<X>(this,
c.getKey(), c.getValue(), methodParameterAnnotations.get(c.getKey()),
methodParameterTypes.get(c.getKey()));
- methods.add(nc);
- }
- }
- this.fields = new HashSet<AnnotatedField<? super X>>();
- for (Field f : clazz.getFields())
- {
- NewAnnotatedField<X> b = new NewAnnotatedField<X>(this, f,
fieldAnnotations.get(f), fieldTypes.get(f));
- fields.add(b);
- fset.add(f);
- }
- for (Entry<Field, AnnotationStore> e : fieldAnnotations.entrySet())
- {
- if (!fset.contains(e.getKey()))
- {
- fields.add(new NewAnnotatedField<X>(this, e.getKey(), e.getValue(),
fieldTypes.get(e.getKey())));
- }
- }
- }
-
- public Set<AnnotatedConstructor<X>> getConstructors()
- {
- return Collections.unmodifiableSet(constructors);
- }
-
- public Set<AnnotatedField<? super X>> getFields()
- {
- return Collections.unmodifiableSet(fields);
- }
-
- public Class<X> getJavaClass()
- {
- return javaClass;
- }
-
- public Set<AnnotatedMethod<? super X>> getMethods()
- {
- return Collections.unmodifiableSet(methods);
- }
-
-}
Deleted:
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/NewAnnotatedTypeBuilder.java
===================================================================
---
extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated/NewAnnotatedTypeBuilder.java 2010-04-28
16:45:31 UTC (rev 6191)
+++
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/NewAnnotatedTypeBuilder.java 2010-04-29
21:41:13 UTC (rev 6201)
@@ -1,591 +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.util.annotated;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.lang.reflect.Type;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import javax.enterprise.inject.spi.Annotated;
-import javax.enterprise.inject.spi.AnnotatedConstructor;
-import javax.enterprise.inject.spi.AnnotatedField;
-import javax.enterprise.inject.spi.AnnotatedMethod;
-import javax.enterprise.inject.spi.AnnotatedParameter;
-import javax.enterprise.inject.spi.AnnotatedType;
-
-import org.jboss.weld.extensions.util.ReflectionUtils;
-
-/**
- * Class for constructing a new AnnotatedType. A new instance of builder must be
- * used for each annotated type.
- *
- * In can either be created with no annotations, or the annotations can be read
- * from the underlying class or an AnnotatedType
- *
- * @author Stuart Douglas
- * @author Pete Muir
- *
- */
-public class NewAnnotatedTypeBuilder<X>
-{
- private Map<Field, AnnotationBuilder> fields = new HashMap<Field,
AnnotationBuilder>();
- private Map<Method, AnnotationBuilder> methods = new HashMap<Method,
AnnotationBuilder>();
- private Map<Method, Map<Integer, AnnotationBuilder>> methodParameters =
new HashMap<Method, Map<Integer, AnnotationBuilder>>();
- private Map<Constructor<X>, AnnotationBuilder> constructors = new
HashMap<Constructor<X>, AnnotationBuilder>();
- private Map<Constructor<X>, Map<Integer, AnnotationBuilder>>
constructorParameters = new HashMap<Constructor<X>, Map<Integer,
AnnotationBuilder>>();
- private AnnotationBuilder typeAnnotations = new AnnotationBuilder();
- private Class<X> underlying;
-
- private Map<Field, Type> fieldTypes = new HashMap<Field, Type>();
- private Map<Method, Map<Integer, Type>> methodParameterTypes = new
HashMap<Method, Map<Integer, Type>>();
- private Map<Constructor<?>, Map<Integer, Type>>
constructorParameterTypes = new HashMap<Constructor<?>, Map<Integer,
Type>>();
-
- public NewAnnotatedTypeBuilder(Class<X> underlying)
- {
- this(underlying, false);
- }
-
- public NewAnnotatedTypeBuilder(Class<X> underlying, boolean readAnnotations)
- {
- this.underlying = underlying;
- if (readAnnotations)
- {
- for (Annotation a : underlying.getAnnotations())
- {
- typeAnnotations.add(a);
- }
-
- for (Field f : ReflectionUtils.getFields(underlying))
- {
- AnnotationBuilder ab = new AnnotationBuilder();
- fields.put(f, ab);
- for (Annotation a : f.getAnnotations())
- {
- ab.add(a);
- }
- }
-
- for (Method m : ReflectionUtils.getMethods(underlying))
- {
- AnnotationBuilder ab = new AnnotationBuilder();
- methods.put(m, ab);
- for (Annotation a : m.getAnnotations())
- {
- ab.add(a);
- }
- Map<Integer, AnnotationBuilder> mparams = new HashMap<Integer,
AnnotationBuilder>();
- methodParameters.put(m, mparams);
- for (int i = 0; i < m.getParameterTypes().length; ++i)
- {
- AnnotationBuilder mab = new AnnotationBuilder();
- mparams.put(i, mab);
- for (Annotation a : m.getParameterAnnotations()[i])
- {
- mab.add(a);
- }
- }
- }
-
- for (Constructor m : underlying.getConstructors())
- {
- AnnotationBuilder ab = new AnnotationBuilder();
- constructors.put(m, ab);
- for (Annotation a : m.getAnnotations())
- {
- ab.add(a);
- }
- Map<Integer, AnnotationBuilder> mparams = new HashMap<Integer,
AnnotationBuilder>();
- constructorParameters.put(m, mparams);
- for (int i = 0; i < m.getParameterTypes().length; ++i)
- {
- AnnotationBuilder mab = new AnnotationBuilder();
- mparams.put(i, mab);
- for (Annotation a : m.getParameterAnnotations()[i])
- {
- mab.add(a);
- }
- }
- }
-
- }
- }
-
- public NewAnnotatedTypeBuilder(AnnotatedType<X> type)
- {
- this.underlying = type.getJavaClass();
- for (Annotation a : type.getAnnotations())
- {
- typeAnnotations.add(a);
- }
-
- for (AnnotatedField<? super X> f : type.getFields())
- {
- AnnotationBuilder ab = new AnnotationBuilder();
- fields.put(f.getJavaMember(), ab);
- for (Annotation a : f.getAnnotations())
- {
- ab.add(a);
- }
- }
-
- for (AnnotatedMethod<? super X> m : type.getMethods())
- {
- AnnotationBuilder ab = new AnnotationBuilder();
- methods.put(m.getJavaMember(), ab);
- for (Annotation a : m.getAnnotations())
- {
- ab.add(a);
- }
- Map<Integer, AnnotationBuilder> mparams = new HashMap<Integer,
AnnotationBuilder>();
- methodParameters.put(m.getJavaMember(), mparams);
- for (AnnotatedParameter<? super X> p : m.getParameters())
- {
- AnnotationBuilder mab = new AnnotationBuilder();
- mparams.put(p.getPosition(), mab);
- for (Annotation a : p.getAnnotations())
- {
- mab.add(a);
- }
- }
- }
-
- for (AnnotatedConstructor<X> m : type.getConstructors())
- {
- AnnotationBuilder ab = new AnnotationBuilder();
- constructors.put(m.getJavaMember(), ab);
- for (Annotation a : m.getAnnotations())
- {
- ab.add(a);
- }
- Map<Integer, AnnotationBuilder> mparams = new HashMap<Integer,
AnnotationBuilder>();
- constructorParameters.put(m.getJavaMember(), mparams);
- for (AnnotatedParameter<? super X> p : m.getParameters())
- {
- AnnotationBuilder mab = new AnnotationBuilder();
- mparams.put(p.getPosition(), mab);
- for (Annotation a : p.getAnnotations())
- {
- mab.add(a);
- }
- }
- }
-
- }
-
- public NewAnnotatedTypeBuilder<X> addToClass(Annotation a)
- {
- typeAnnotations.add(a);
- return this;
- }
-
- public NewAnnotatedTypeBuilder<X> removeFromClass(Class<? extends
Annotation> annotation)
- {
- typeAnnotations.remove(annotation);
- return this;
- }
-
- public NewAnnotatedTypeBuilder<X> addToField(Field field, Annotation a)
- {
- AnnotationBuilder annotations = fields.get(field);
- if (annotations == null)
- {
- annotations = new AnnotationBuilder();
- fields.put(field, annotations);
- }
- annotations.add(a);
- return this;
- }
-
- public NewAnnotatedTypeBuilder<X> removeFromField(Field field, Class<?
extends Annotation> a)
- {
- AnnotationBuilder annotations = fields.get(field);
- if (annotations != null)
- {
- annotations.remove(a);
- }
- return this;
- }
-
- public NewAnnotatedTypeBuilder<X> addToMethod(Method method, Annotation a)
- {
- AnnotationBuilder annotations = methods.get(method);
- if (annotations == null)
- {
- annotations = new AnnotationBuilder();
- methods.put(method, annotations);
- }
- annotations.add(a);
- return this;
- }
-
- public NewAnnotatedTypeBuilder<X> removeFromMethod(Method method, Class<?
extends Annotation> a)
- {
- AnnotationBuilder annotations = methods.get(method);
- if (annotations != null)
- {
- annotations.remove(a);
- }
- return this;
- }
-
- public NewAnnotatedTypeBuilder<X> addToMethodParameter(Method method, int
parameter, Annotation a)
- {
- if (!methods.containsKey(method))
- {
- methods.put(method, new AnnotationBuilder());
- }
- Map<Integer, AnnotationBuilder> anmap = methodParameters.get(method);
- if (anmap == null)
- {
- anmap = new HashMap<Integer, AnnotationBuilder>();
- methodParameters.put(method, anmap);
- }
- AnnotationBuilder annotations = anmap.get(parameter);
- if (annotations == null)
- {
- annotations = new AnnotationBuilder();
- anmap.put(parameter, annotations);
- }
- annotations.add(a);
- return this;
- }
-
- public NewAnnotatedTypeBuilder<X> removeFromMethodParameter(Method method, int
parameter, Class<? extends Annotation> a)
- {
- Map<Integer, AnnotationBuilder> anmap = methodParameters.get(method);
- if (anmap != null)
- {
- AnnotationBuilder annotations = anmap.get(parameter);
- if (annotations != null)
- {
- annotations.remove(a);
- }
- }
- return this;
- }
-
- public NewAnnotatedTypeBuilder<X> addToConstructor(Constructor<X>
constructor, Annotation a)
- {
- AnnotationBuilder annotations = constructors.get(constructor);
- if (annotations == null)
- {
- annotations = new AnnotationBuilder();
- constructors.put(constructor, annotations);
- }
- annotations.add(a);
- return this;
- }
-
- public NewAnnotatedTypeBuilder<X> removeFromConstructor(Constructor<?>
constructor, Class<? extends Annotation> a)
- {
- AnnotationBuilder annotations = constructors.get(constructor);
- if (annotations != null)
- {
- annotations.remove(a);
- }
- return this;
- }
-
- public NewAnnotatedTypeBuilder<X> addToConstructorParameter(Constructor<X>
constructor, int parameter, Annotation a)
- {
- if (!constructors.containsKey(constructor))
- {
- constructors.put(constructor, new AnnotationBuilder());
- }
- Map<Integer, AnnotationBuilder> anmap =
constructorParameters.get(constructor);
- if (anmap == null)
- {
- anmap = new HashMap<Integer, AnnotationBuilder>();
- constructorParameters.put(constructor, anmap);
- }
- AnnotationBuilder annotations = anmap.get(parameter);
- if (annotations == null)
- {
- annotations = new AnnotationBuilder();
- anmap.put(parameter, annotations);
- }
- annotations.add(a);
- return this;
- }
-
- public NewAnnotatedTypeBuilder<X>
removeFromConstructorParameter(Constructor<X> constructor, int parameter, Class<?
extends Annotation> a)
- {
- Map<Integer, AnnotationBuilder> anmap =
constructorParameters.get(constructor);
- if (anmap != null)
- {
- AnnotationBuilder annotations = anmap.get(parameter);
- if (annotations != null)
- {
- annotations.remove(a);
- }
- }
- return this;
- }
-
- public NewAnnotatedTypeBuilder<X> removeFromAll(Class<? extends
Annotation> a)
- {
- removeFromClass(a);
- for (Entry<Field, AnnotationBuilder> e : fields.entrySet())
- {
- e.getValue().remove(a);
- }
- for (Entry<Method, AnnotationBuilder> e : methods.entrySet())
- {
- e.getValue().remove(a);
- Map<Integer, AnnotationBuilder> params =
methodParameters.get(e.getKey());
- if (params != null)
- {
- for (Entry<Integer, AnnotationBuilder> p : params.entrySet())
- {
- p.getValue().remove(a);
- }
- }
- }
- for (Entry<Constructor<X>, AnnotationBuilder> e :
constructors.entrySet())
- {
- e.getValue().remove(a);
- Map<Integer, AnnotationBuilder> params =
constructorParameters.get(e.getKey());
- if (params != null)
- {
- for (Entry<Integer, AnnotationBuilder> p : params.entrySet())
- {
- p.getValue().remove(a);
- }
- }
- }
- return this;
- }
-
- public <T extends Annotation> NewAnnotatedTypeBuilder<X>
redefine(Class<T> annotationType, AnnotationRedefiner<T> redefinition)
- {
- redefineAnnotationBuilder(annotationType, redefinition, typeAnnotations);
- for (Entry<Field, AnnotationBuilder> e : fields.entrySet())
- {
- redefineAnnotationBuilder(annotationType, redefinition, e.getValue());
- }
- for (Entry<Method, AnnotationBuilder> e : methods.entrySet())
- {
- redefineAnnotationBuilder(annotationType, redefinition, e.getValue());
- Map<Integer, AnnotationBuilder> params =
methodParameters.get(e.getKey());
- if (params != null)
- {
- for (Entry<Integer, AnnotationBuilder> p : params.entrySet())
- {
- redefineAnnotationBuilder(annotationType, redefinition, p.getValue());
- }
- }
- }
- for (Entry<Constructor<X>, AnnotationBuilder> e :
constructors.entrySet())
- {
- redefineAnnotationBuilder(annotationType, redefinition, e.getValue());
- Map<Integer, AnnotationBuilder> params =
constructorParameters.get(e.getKey());
- if (params != null)
- {
- for (Entry<Integer, AnnotationBuilder> p : params.entrySet())
- {
- redefineAnnotationBuilder(annotationType, redefinition, p.getValue());
- }
- }
- }
- return this;
- }
-
- protected <T extends Annotation> void redefineAnnotationBuilder(Class<T>
annotationType, AnnotationRedefiner<T> redefinition, AnnotationBuilder builder)
- {
- T an = builder.getAnnotation(annotationType);
- if(an != null)
- {
- builder.remove(annotationType);
- T newAn = redefinition.redefine(an, builder);
- if (newAn != null)
- {
- builder.add(newAn);
- }
- }
- }
-
- /**
- * merges the annotations from an existing AnnoatedType. If they both have the same
annotation
- * on an element overwriteExisting determines which one to keep
- * @param type
- * @param overwriteExisting
- * @return
- */
- public NewAnnotatedTypeBuilder<X> mergeAnnotations(AnnotatedType<X> type,
boolean overwriteExisting)
- {
- mergeAnnotationsOnElement(type, overwriteExisting, typeAnnotations);
- for (AnnotatedField<? super X> field : type.getFields())
- {
- AnnotationBuilder ans = fields.get(field.getJavaMember());
- if (ans == null)
- {
- ans = new AnnotationBuilder();
- fields.put(field.getJavaMember(), ans);
- }
- mergeAnnotationsOnElement(field, overwriteExisting, ans);
- }
- for (AnnotatedMethod<? super X> method : type.getMethods())
- {
- AnnotationBuilder ans = methods.get(method.getJavaMember());
- if (ans == null)
- {
- ans = new AnnotationBuilder();
- methods.put(method.getJavaMember(), ans);
- }
- mergeAnnotationsOnElement(method, overwriteExisting, ans);
- for (AnnotatedParameter<? super X> p : method.getParameters())
- {
- Map<Integer, AnnotationBuilder> params =
methodParameters.get(method.getJavaMember());
- if (params == null)
- {
- params = new HashMap<Integer, AnnotationBuilder>();
- methodParameters.put(method.getJavaMember(), params);
- }
- AnnotationBuilder builder = params.get(p.getPosition());
- if(builder == null)
- {
- builder = new AnnotationBuilder();
- params.put(p.getPosition(), builder);
- }
- mergeAnnotationsOnElement(p, overwriteExisting, builder);
- }
- }
- for (AnnotatedConstructor<? super X> constructor : type.getConstructors())
- {
- AnnotationBuilder ans = constructors.get(constructor.getJavaMember());
- if (ans == null)
- {
- ans = new AnnotationBuilder();
- constructors.put((Constructor) constructor.getJavaMember(), ans);
- }
- mergeAnnotationsOnElement(constructor, overwriteExisting, ans);
- for (AnnotatedParameter<? super X> p : constructor.getParameters())
- {
- Map<Integer, AnnotationBuilder> params =
constructorParameters.get(constructor.getJavaMember());
- if (params == null)
- {
- params = new HashMap<Integer, AnnotationBuilder>();
- constructorParameters.put((Constructor) constructor.getJavaMember(),
params);
- }
- AnnotationBuilder builder = params.get(p.getPosition());
- if (builder == null)
- {
- builder = new AnnotationBuilder();
- params.put(p.getPosition(), builder);
- }
- mergeAnnotationsOnElement(p, overwriteExisting, builder);
- }
- }
- return this;
- }
-
- protected void mergeAnnotationsOnElement(Annotated annotated, boolean
overwriteExisting, AnnotationBuilder typeAnnotations)
- {
- for (Annotation a : annotated.getAnnotations())
- {
- if (typeAnnotations.getAnnotation(a.annotationType()) != null)
- {
- if (overwriteExisting)
- {
- typeAnnotations.remove(a.annotationType());
- typeAnnotations.add(a);
- }
- }
- else
- {
- typeAnnotations.add(a);
- }
- }
- }
-
- public AnnotatedType<X> create()
- {
- Map<Constructor<X>, Map<Integer, AnnotationStore>>
constructorParameterAnnnotations = new HashMap<Constructor<X>,
Map<Integer,AnnotationStore>>();
- Map<Constructor<X>, AnnotationStore> constructorAnnotations = new
HashMap<Constructor<X>, AnnotationStore>();
- Map<Method, Map<Integer, AnnotationStore>> methodParameterAnnnotations
= new HashMap<Method, Map<Integer,AnnotationStore>>();
- Map<Method, AnnotationStore> methodAnnotations = new HashMap<Method,
AnnotationStore>();
- Map<Field, AnnotationStore> fieldAnnotations = new HashMap<Field,
AnnotationStore>();
-
- for (Entry<Field, AnnotationBuilder> e : fields.entrySet())
- {
- fieldAnnotations.put(e.getKey(), e.getValue().create());
- }
-
- for (Entry<Method, AnnotationBuilder> e : methods.entrySet())
- {
- methodAnnotations.put(e.getKey(), e.getValue().create());
- }
- for (Entry<Method, Map<Integer, AnnotationBuilder>> e :
methodParameters.entrySet())
- {
- Map<Integer, AnnotationStore> parameterAnnotations = new
HashMap<Integer, AnnotationStore>();
- methodParameterAnnnotations.put(e.getKey(), parameterAnnotations);
- for (Entry<Integer, AnnotationBuilder> pe : e.getValue().entrySet())
- {
- parameterAnnotations.put(pe.getKey(), pe.getValue().create());
- }
- }
-
- for (Entry<Constructor<X>, AnnotationBuilder> e :
constructors.entrySet())
- {
- constructorAnnotations.put(e.getKey(), e.getValue().create());
- }
- for (Entry<Constructor<X>, Map<Integer, AnnotationBuilder>> e :
constructorParameters.entrySet())
- {
- Map<Integer, AnnotationStore> parameterAnnotations = new
HashMap<Integer, AnnotationStore>();
- constructorParameterAnnnotations.put(e.getKey(), parameterAnnotations);
- for (Entry<Integer, AnnotationBuilder> pe : e.getValue().entrySet())
- {
- parameterAnnotations.put(pe.getKey(), pe.getValue().create());
- }
- }
-
- return new NewAnnotatedType<X>(underlying, typeAnnotations.create(),
fieldAnnotations, methodAnnotations, methodParameterAnnnotations, constructorAnnotations,
constructorParameterAnnnotations, fieldTypes, methodParameterTypes,
constructorParameterTypes);
- }
-
- public void overrideFieldType(Field field, Type type)
- {
- fieldTypes.put(field, type);
- }
-
- public void overrideMethodParameterType(Method method, Type type, int position)
- {
- Map<Integer, Type> t = methodParameterTypes.get(method);
- if (t == null)
- {
- t = new HashMap<Integer, Type>();
- methodParameterTypes.put(method, t);
- }
- t.put(position, type);
- }
-
- public void overrideConstructorParameterType(Constructor<?> constructor, Type
type, int position)
- {
- Map<Integer, Type> t = constructorParameterTypes.get(constructor);
- if (t == null)
- {
- t = new HashMap<Integer, Type>();
- constructorParameterTypes.put(constructor, t);
- }
- t.put(position, type);
- }
-
-}
Copied:
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/Parameter.java
(from rev 6198,
extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated/Parameter.java)
===================================================================
--- extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/Parameter.java
(rev 0)
+++
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/Parameter.java 2010-04-29
21:41:13 UTC (rev 6201)
@@ -0,0 +1,51 @@
+package org.jboss.weld.extensions.annotatedType;
+
+import java.lang.reflect.Member;
+
+public class Parameter
+{
+
+ private final Member declaringMember;
+ private final int position;
+
+ Parameter(Member declaringMember, int position)
+ {
+ this.declaringMember = declaringMember;
+ this.position = position;
+ }
+
+ public Member getDeclaringMember()
+ {
+ return declaringMember;
+ }
+
+ public int getPosition()
+ {
+ return position;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int hash = 1;
+ hash = hash * 31 + declaringMember.hashCode();
+ hash = hash * 31 + Integer.valueOf(position).hashCode();
+ return hash;
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof Parameter)
+ {
+ Parameter that = (Parameter) obj;
+ return this.getDeclaringMember().equals(that.getDeclaringMember()) &&
this.getPosition() == that.getPosition();
+ }
+ else
+ {
+ return false;
+ }
+
+ }
+
+}
Copied:
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/ParameterAnnotationRedefiner.java
(from rev 6198,
extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated/ParameterAnnotationRedefiner.java)
===================================================================
---
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/ParameterAnnotationRedefiner.java
(rev 0)
+++
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/ParameterAnnotationRedefiner.java 2010-04-29
21:41:13 UTC (rev 6201)
@@ -0,0 +1,8 @@
+package org.jboss.weld.extensions.annotatedType;
+
+import java.lang.annotation.Annotation;
+
+public interface ParameterAnnotationRedefiner<T extends Annotation> extends
AnnotationRedefiner<T, Parameter>
+{
+
+}
Copied:
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/TypeAnnotationRedefiner.java
(from rev 6198,
extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated/TypeAnnotationRedefiner.java)
===================================================================
---
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/TypeAnnotationRedefiner.java
(rev 0)
+++
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/TypeAnnotationRedefiner.java 2010-04-29
21:41:13 UTC (rev 6201)
@@ -0,0 +1,8 @@
+package org.jboss.weld.extensions.annotatedType;
+
+import java.lang.annotation.Annotation;
+
+public interface TypeAnnotationRedefiner<T extends Annotation> extends
AnnotationRedefiner<T, Class<?>>
+{
+
+}
Deleted:
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/TypeClosureBuilder.java
===================================================================
---
extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated/TypeClosureBuilder.java 2010-04-28
16:45:31 UTC (rev 6191)
+++
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/TypeClosureBuilder.java 2010-04-29
21:41:13 UTC (rev 6201)
@@ -1,70 +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.util.annotated;
-
-import java.lang.reflect.Type;
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * A type closure builder
- *
- * @author Stuart Douglas
- *
- */
-class TypeClosureBuilder
-{
-
- final Set<Type> types = new HashSet<Type>();
-
- public TypeClosureBuilder add(Type type)
- {
- types.add(type);
- return this;
- }
-
- public TypeClosureBuilder add(Class<?> beanType)
- {
- Class<?> c = beanType;
- do
- {
- types.add(c);
- c = c.getSuperclass();
- }
- while (c != null);
- for (Class<?> i : beanType.getInterfaces())
- {
- types.add(i);
- }
- return this;
- }
-
- public TypeClosureBuilder addInterfaces(Class<?> beanType)
- {
- for (Class<?> i : beanType.getInterfaces())
- {
- types.add(i);
- }
- return this;
- }
-
- public Set<Type> getTypes()
- {
- return types;
- }
-
-}
Copied:
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/TypeClosureBuilder.java
(from rev 6200,
extensions/trunk/src/main/java/org/jboss/weld/extensions/util/annotated/TypeClosureBuilder.java)
===================================================================
---
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/TypeClosureBuilder.java
(rev 0)
+++
extensions/trunk/src/main/java/org/jboss/weld/extensions/annotatedType/TypeClosureBuilder.java 2010-04-29
21:41:13 UTC (rev 6201)
@@ -0,0 +1,72 @@
+/*
+ * 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.annotatedType;
+
+import java.lang.reflect.Type;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * A type closure builder
+ *
+ * @author Stuart Douglas
+ *
+ */
+class TypeClosureBuilder
+{
+
+ private final Set<Type> types;
+
+ TypeClosureBuilder()
+ {
+ this.types = new HashSet<Type>();
+ }
+
+ TypeClosureBuilder add(Type type)
+ {
+ types.add(type);
+ return this;
+ }
+
+ TypeClosureBuilder add(Class<?> beanType)
+ {
+ for (Class<?> c = beanType; c != Object.class && c != null; c =
c.getSuperclass())
+ {
+ types.add(c);
+ }
+ for (Class<?> i : beanType.getInterfaces())
+ {
+ types.add(i);
+ }
+ return this;
+ }
+
+ TypeClosureBuilder addInterfaces(Class<?> beanType)
+ {
+ for (Class<?> i : beanType.getInterfaces())
+ {
+ types.add(i);
+ }
+ return this;
+ }
+
+ Set<Type> getTypes()
+ {
+ return types;
+ }
+
+}
Modified:
extensions/trunk/src/main/java/org/jboss/weld/extensions/bean/generic/GenericExtension.java
===================================================================
---
extensions/trunk/src/main/java/org/jboss/weld/extensions/bean/generic/GenericExtension.java 2010-04-29
21:36:09 UTC (rev 6200)
+++
extensions/trunk/src/main/java/org/jboss/weld/extensions/bean/generic/GenericExtension.java 2010-04-29
21:41:13 UTC (rev 6201)
@@ -43,9 +43,9 @@
import javax.enterprise.inject.spi.ProcessInjectionTarget;
import javax.inject.Inject;
+import org.jboss.weld.extensions.annotatedType.AnnotatedTypeBuilder;
import org.jboss.weld.extensions.bean.CustomBeanBuilder;
import org.jboss.weld.extensions.util.AnnotationInstanceProvider;
-import org.jboss.weld.extensions.util.annotated.AnnotatedTypeBuilder;
public class GenericExtension implements Extension
{
Modified:
extensions/trunk/src/main/java/org/jboss/weld/extensions/core/CoreExtension.java
===================================================================
---
extensions/trunk/src/main/java/org/jboss/weld/extensions/core/CoreExtension.java 2010-04-29
21:36:09 UTC (rev 6200)
+++
extensions/trunk/src/main/java/org/jboss/weld/extensions/core/CoreExtension.java 2010-04-29
21:41:13 UTC (rev 6201)
@@ -38,13 +38,13 @@
import javax.inject.Named;
import javax.inject.Qualifier;
+import org.jboss.weld.extensions.annotatedType.AnnotatedTypeBuilder;
+import org.jboss.weld.extensions.annotatedType.AnnotationBuilder;
+import org.jboss.weld.extensions.annotatedType.MemberAnnotationRedefiner;
+import org.jboss.weld.extensions.annotatedType.Parameter;
+import org.jboss.weld.extensions.annotatedType.ParameterAnnotationRedefiner;
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.AnnotatedTypeBuilder;
-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