Author: scabanovich
Date: 2009-12-15 10:42:55 -0500 (Tue, 15 Dec 2009)
New Revision: 19280
Added:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/SessionBean.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/BeanMemberDefinition.java
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDIConstants.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IInjectionPoint.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/AbstractBeanElement.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/BeanField.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/BeanMember.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ClassBean.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/DecoratorBean.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/InjectionPointField.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/InterceptorBean.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/InterceptorBindingElement.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerField.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerMethod.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/StereotypeElement.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/AbstractMemberDefinition.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/AnnotationHelper.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/DefinitionContext.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/FieldDefinition.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/MethodDefinition.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/TypeDefinition.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-4943
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDIConstants.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDIConstants.java 2009-12-15
15:37:35 UTC (rev 19279)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDIConstants.java 2009-12-15
15:42:55 UTC (rev 19280)
@@ -15,6 +15,7 @@
public String STEREOTYPE_ANNOTATION_TYPE_NAME =
"javax.enterprise.inject.Stereotype";
public String MODEL_STEREOTYPE_TYPE_NAME = "javax.enterprise.inject.Model";
public String DECORATOR_STEREOTYPE_TYPE_NAME = "javax.decorator.Decorator";
+ public String DELEGATE_STEREOTYPE_TYPE_NAME = "javax.decorator.Delegate";
public String TYPED_ANNOTATION_TYPE_NAME = "javax.enterprise.inject.Typed";
@@ -40,6 +41,7 @@
public String SPECIALIZES_ANNOTATION_TYPE_NAME =
"javax.enterprise.inject.Specializes";
- public String DELEGATE_STEREOTYPE_TYPE_NAME = "javax.decorator.Delegate";
+ public String STATEFUL_ANNOTATION_TYPE_NAME = "javax.ejb.Stateful";
+ public String STATELESS_ANNOTATION_TYPE_NAME = "javax.ejb.Stateless";
}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IInjectionPoint.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IInjectionPoint.java 2009-12-15
15:37:35 UTC (rev 19279)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IInjectionPoint.java 2009-12-15
15:42:55 UTC (rev 19280)
@@ -45,12 +45,12 @@
boolean isDelegate();
/**
- * Returns the @Decorator annotation of this injection point field or
+ * Returns the @Delegate annotation of this injection point field or
* parameter of injection point method. Should not return null if
* isDelegate() returns "true".
*
- * @return the @Decorator annotation of this injection point field or
+ * @return the @Delegate annotation of this injection point field or
* parameter of injection point method. May be null.
*/
- IAnnotationDeclaration getDecoratorAnnotation();
+ IAnnotationDeclaration getDelegateAnnotation();
}
\ No newline at end of file
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/AbstractBeanElement.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/AbstractBeanElement.java 2009-12-15
15:37:35 UTC (rev 19279)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/AbstractBeanElement.java 2009-12-15
15:42:55 UTC (rev 19280)
@@ -14,11 +14,17 @@
import java.util.List;
import java.util.Set;
-import org.jboss.tools.cdi.core.CDIConstants;
+import org.eclipse.jdt.core.IAnnotation;
+import org.eclipse.jdt.core.IMemberValuePair;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
+import org.jboss.tools.cdi.core.CDICorePlugin;
import org.jboss.tools.cdi.core.IAnnotationDeclaration;
import org.jboss.tools.cdi.core.IStereotypeDeclaration;
+import org.jboss.tools.cdi.core.ITypeDeclaration;
import org.jboss.tools.cdi.internal.core.impl.definition.AbstractMemberDefinition;
import org.jboss.tools.cdi.internal.core.impl.definition.AnnotationDefinition;
+import org.jboss.tools.common.model.util.EclipseJavaUtil;
/**
*
@@ -28,43 +34,18 @@
public class AbstractBeanElement extends CDIElement {
protected AbstractMemberDefinition definition;
- protected AnnotationDeclaration named;
- protected AnnotationDeclaration alternative;
- protected AnnotationDeclaration specializes;
- protected AnnotationDeclaration typed;
- protected AnnotationDeclaration decorator;
- protected AnnotationDeclaration interceptor;
- protected AnnotationDeclaration delegate;
-
public AbstractBeanElement() {}
public void setDefinition(AbstractMemberDefinition definition) {
this.definition = definition;
- setAnnotations(definition.getAnnotations());
}
- protected void setAnnotations(List<AnnotationDeclaration> ds) {
- for (AnnotationDeclaration d: ds) {
- String typeName = d.getTypeName();
- if(CDIConstants.NAMED_QUALIFIER_TYPE_NAME.equals(typeName)) {
- named = d;
- } else if(CDIConstants.ALTERNATIVE_ANNOTATION_TYPE_NAME.equals(typeName)) {
- alternative = d;
- } else if(CDIConstants.SPECIALIZES_ANNOTATION_TYPE_NAME.equals(typeName)) {
- specializes = d;
- } else if(CDIConstants.TYPED_ANNOTATION_TYPE_NAME.equals(typeName)) {
- typed = d;
- } else if(CDIConstants.DECORATOR_STEREOTYPE_TYPE_NAME.equals(typeName)) {
- decorator = d;
- } else if(CDIConstants.DELEGATE_STEREOTYPE_TYPE_NAME.equals(typeName)) {
- delegate = d;
- } else if(CDIConstants.INTERCEPTOR_ANNOTATION_TYPE_NAME.equals(typeName)) {
- interceptor = d;
- }
- }
+ public AbstractMemberDefinition getDefinition() {
+ return definition;
}
protected AnnotationDeclaration findNamedAnnotation() {
+ AnnotationDeclaration named = getDefinition().getNamedAnnotation();
if(named != null) return named;
Set<IStereotypeDeclaration> ds = getStereotypeDeclarations();
for (IStereotypeDeclaration d: ds) {
@@ -98,4 +79,36 @@
return result;
}
+ public Set<ITypeDeclaration> getRestrictedTypeDeclaratios() {
+ Set<ITypeDeclaration> result = new HashSet<ITypeDeclaration>();
+ AnnotationDeclaration typed = getDefinition().getTypedAnnotation();
+ if(typed != null) {
+ IAnnotation a = typed.getDeclaration();
+ try {
+ IMemberValuePair[] ps = a.getMemberValuePairs();
+ if(ps == null || ps.length == 0) return result;
+ Object value = ps[0].getValue();
+ if(value instanceof Object[]) {
+ Object[] os = (Object[])value;
+ for (int i = 0; i < os.length; i++) {
+ String typeName = os[i].toString();
+ IType type =
EclipseJavaUtil.findType(getCDIProject().getNature().getDefinitions().getJavaProject(),
typeName);
+ if(type != null) {
+ result.add(new TypeDeclaration(type, -1, 0));
+ }
+ }
+ } else if(value != null) {
+ String typeName = value.toString();
+ IType type =
EclipseJavaUtil.findType(getCDIProject().getNature().getDefinitions().getJavaProject(),
typeName);
+ if(type != null) {
+ result.add(new TypeDeclaration(type, -1, 0));
+ }
+ }
+ } catch (JavaModelException e) {
+ CDICorePlugin.getDefault().logError(e);
+ }
+ }
+ return result;
+ }
+
}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/BeanField.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/BeanField.java 2009-12-15
15:37:35 UTC (rev 19279)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/BeanField.java 2009-12-15
15:42:55 UTC (rev 19280)
@@ -30,6 +30,10 @@
setField(definition.getField());
}
+ public FieldDefinition getDefinition() {
+ return (FieldDefinition)definition;
+ }
+
public IField getField() {
return field;
}
@@ -43,7 +47,4 @@
return getField();
}
- public FieldDefinition getDefinition() {
- return (FieldDefinition)definition;
- }
}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/BeanMember.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/BeanMember.java 2009-12-15
15:37:35 UTC (rev 19279)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/BeanMember.java 2009-12-15
15:42:55 UTC (rev 19280)
@@ -18,6 +18,7 @@
import org.jboss.tools.cdi.core.IBeanMember;
import org.jboss.tools.cdi.core.IClassBean;
import org.jboss.tools.cdi.core.ITypeDeclaration;
+import org.jboss.tools.cdi.internal.core.impl.definition.BeanMemberDefinition;
import org.jboss.tools.common.model.util.EclipseJavaUtil;
/**
@@ -31,6 +32,10 @@
public BeanMember() {}
+ public BeanMemberDefinition getDefinition() {
+ return (BeanMemberDefinition)definition;
+ }
+
protected void setMember(IMember member) {
try {
String returnType = EclipseJavaUtil.getMemberTypeAsString(member);
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java 2009-12-15
15:37:35 UTC (rev 19279)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java 2009-12-15
15:42:55 UTC (rev 19280)
@@ -380,6 +380,9 @@
synchronized (beansByName) {
beansByName.clear();
}
+ synchronized (namedBeans) {
+ namedBeans.clear();
+ }
List<TypeDefinition> typeDefinitions = n.getDefinitions().getTypeDefinitions();
for (TypeDefinition typeDefinition : typeDefinitions) {
ClassBean bean = null;
@@ -387,9 +390,12 @@
bean = new InterceptorBean();
} else if(typeDefinition.getDecoratorAnnotation() != null) {
bean = new DecoratorBean();
+ } else if(typeDefinition.getStatefulAnnotation() != null ||
typeDefinition.getStatelessAnnotation() != null) {
+ bean = new SessionBean();
} else {
bean = new ClassBean();
}
+ bean.setParent(this);
bean.setDefinition(typeDefinition);
addBean(bean);
Set<IProducer> ps = bean.getProducers();
@@ -397,6 +403,9 @@
addBean(producer);
}
}
+ System.out.println("Project=" + getNature().getProject());
+ System.out.println("Named beans=" + beansByName.size());
+ System.out.println("Bean paths=" + beansByPath.size());
}
void addBean(IBean bean) {
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ClassBean.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ClassBean.java 2009-12-15
15:37:35 UTC (rev 19279)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ClassBean.java 2009-12-15
15:42:55 UTC (rev 19280)
@@ -53,7 +53,6 @@
public void setDefinition(TypeDefinition definition) {
setSourcePath(definition.getType().getPath());
super.setDefinition(definition);
- setAnnotations(definition.getAnnotations());
List<MethodDefinition> ms = definition.getMethods();
for (MethodDefinition m: ms) {
BeanMethod bm = null;
@@ -84,6 +83,10 @@
}
}
+ public TypeDefinition getDefinition() {
+ return (TypeDefinition)definition;
+ }
+
public Set<IBeanMethod> getBeanConstructor() {
Set<IBeanMethod> result = new HashSet<IBeanMethod>();
for (BeanMethod m: methods) {
@@ -141,7 +144,7 @@
}
public IAnnotationDeclaration getAlternativeDeclaration() {
- return alternative;
+ return getDefinition().getAlternativeAnnotation();
}
public IType getBeanClass() {
@@ -191,29 +194,27 @@
}
public ITextSourceReference getNameLocation() {
+ AnnotationDeclaration named = getDefinition().getNamedAnnotation();
if(named != null) {
return ValueInfo.getValueInfo(named.getDeclaration(), null);
}
return null;
}
- public Set<ITypeDeclaration> getRestrictedTypeDeclaratios() {
- // TODO Auto-generated method stub
- return null;
- }
-
public IBean getSpecializedBean() {
+ if(getDefinition().getSpecializesAnnotation() == null) {
+ return null;
+ }
// TODO Auto-generated method stub
return null;
}
public IAnnotationDeclaration getSpecializesAnnotationDeclaration() {
- // TODO Auto-generated method stub
- return null;
+ return getDefinition().getSpecializesAnnotation();
}
public boolean isAlternative() {
- if(alternative != null) return true;
+ if(getDefinition().getAlternativeAnnotation() != null) return true;
Set<IStereotypeDeclaration> ds = getStereotypeDeclarations();
for (IStereotypeDeclaration d: ds) {
IStereotype s = d.getStereotype();
@@ -233,7 +234,7 @@
}
public boolean isSpecializing() {
- return specializes != null;
+ return getDefinition().getSpecializesAnnotation() != null;
}
public IType getScope() {
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/DecoratorBean.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/DecoratorBean.java 2009-12-15
15:37:35 UTC (rev 19279)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/DecoratorBean.java 2009-12-15
15:42:55 UTC (rev 19280)
@@ -30,7 +30,7 @@
}
public IAnnotationDeclaration getDecoratorAnnotation() {
- return decorator;
+ return getDefinition().getDecoratorAnnotation();
}
}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/InjectionPointField.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/InjectionPointField.java 2009-12-15
15:37:35 UTC (rev 19279)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/InjectionPointField.java 2009-12-15
15:42:55 UTC (rev 19280)
@@ -23,8 +23,8 @@
public InjectionPointField() {}
- public IAnnotationDeclaration getDecoratorAnnotation() {
- return decorator;
+ public IAnnotationDeclaration getDelegateAnnotation() {
+ return getDefinition().getDelegateAnnotation();
}
public IType getType() {
@@ -32,7 +32,7 @@
}
public boolean isDelegate() {
- return delegate != null;
+ return getDelegateAnnotation() != null;
}
}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/InterceptorBean.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/InterceptorBean.java 2009-12-15
15:37:35 UTC (rev 19279)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/InterceptorBean.java 2009-12-15
15:42:55 UTC (rev 19280)
@@ -23,7 +23,7 @@
public InterceptorBean() {}
public IAnnotationDeclaration getInterceptorAnnotation() {
- return interceptor;
+ return getDefinition().getInterceptorAnnotation();
}
}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/InterceptorBindingElement.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/InterceptorBindingElement.java 2009-12-15
15:37:35 UTC (rev 19279)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/InterceptorBindingElement.java 2009-12-15
15:42:55 UTC (rev 19280)
@@ -31,7 +31,6 @@
public void setDefinition(AnnotationDefinition definition) {
this.definition = definition;
-// setAnnotations(definition.getAnnotations());
}
public Set<IInterceptorBindingDeclaration> getInterceptorBindingDeclarations() {
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerField.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerField.java 2009-12-15
15:37:35 UTC (rev 19279)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerField.java 2009-12-15
15:42:55 UTC (rev 19280)
@@ -52,7 +52,7 @@
}
public IAnnotationDeclaration getAlternativeDeclaration() {
- return alternative;
+ return getDefinition().getAlternativeAnnotation();
}
public IType getBeanClass() {
@@ -98,37 +98,6 @@
return null;
}
- public Set<ITypeDeclaration> getRestrictedTypeDeclaratios() {
- Set<ITypeDeclaration> result = new HashSet<ITypeDeclaration>();
- if(typed != null) {
- IAnnotation a = typed.getDeclaration();
- try {
- IMemberValuePair[] ps = a.getMemberValuePairs();
- if(ps == null || ps.length == 0) return result;
- Object value = ps[0].getValue();
- if(value instanceof Object[]) {
- Object[] os = (Object[])value;
- for (int i = 0; i < os.length; i++) {
- String typeName = os[i].toString();
- IType type = EclipseJavaUtil.findType(getField().getJavaProject(), typeName);
- if(type != null) {
- result.add(new TypeDeclaration(type, -1, 0));
- }
- }
- } else if(value != null) {
- String typeName = value.toString();
- IType type = EclipseJavaUtil.findType(getField().getJavaProject(), typeName);
- if(type != null) {
- result.add(new TypeDeclaration(type, -1, 0));
- }
- }
- } catch (JavaModelException e) {
- CDICorePlugin.getDefault().logError(e);
- }
- }
- return result;
- }
-
public IBean getSpecializedBean() {
return null;
}
@@ -138,7 +107,7 @@
}
public boolean isAlternative() {
- if(alternative != null) return true;
+ if(getDefinition().getAlternativeAnnotation() != null) return true;
Set<IStereotypeDeclaration> ds = getStereotypeDeclarations();
for (IStereotypeDeclaration d: ds) {
IStereotype s = d.getStereotype();
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerMethod.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerMethod.java 2009-12-15
15:37:35 UTC (rev 19279)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/ProducerMethod.java 2009-12-15
15:42:55 UTC (rev 19280)
@@ -58,7 +58,7 @@
}
public IAnnotationDeclaration getAlternativeDeclaration() {
- return alternative;
+ return getDefinition().getAlternativeAnnotation();
}
public IType getBeanClass() {
@@ -109,40 +109,8 @@
return null;
}
- //similar to ProducerField.getRestrictedTypeDeclaratios
- public Set<ITypeDeclaration> getRestrictedTypeDeclaratios() {
- Set<ITypeDeclaration> result = new HashSet<ITypeDeclaration>();
- if(typed != null) {
- IAnnotation a = typed.getDeclaration();
- try {
- IMemberValuePair[] ps = a.getMemberValuePairs();
- if(ps == null || ps.length == 0) return result;
- Object value = ps[0].getValue();
- if(value instanceof Object[]) {
- Object[] os = (Object[])value;
- for (int i = 0; i < os.length; i++) {
- String typeName = os[i].toString();
- IType type = EclipseJavaUtil.findType(getMethod().getJavaProject(), typeName);
- if(type != null) {
- result.add(new TypeDeclaration(type, -1, 0));
- }
- }
- } else if(value != null) {
- String typeName = value.toString();
- IType type = EclipseJavaUtil.findType(getMethod().getJavaProject(), typeName);
- if(type != null) {
- result.add(new TypeDeclaration(type, -1, 0));
- }
- }
- } catch (JavaModelException e) {
- CDICorePlugin.getDefault().logError(e);
- }
- }
- return result;
- }
-
public IBean getSpecializedBean() {
- if(specializes == null) {
+ if(getDefinition().getSpecializesAnnotation() == null) {
return null;
}
//TODO find producer method in super type
@@ -151,11 +119,11 @@
}
public IAnnotationDeclaration getSpecializesAnnotationDeclaration() {
- return specializes;
+ return getDefinition().getSpecializesAnnotation();
}
public boolean isAlternative() {
- if(alternative != null) return true;
+ if(getDefinition().getAlternativeAnnotation() != null) return true;
Set<IStereotypeDeclaration> ds = getStereotypeDeclarations();
for (IStereotypeDeclaration d: ds) {
IStereotype s = d.getStereotype();
@@ -175,7 +143,7 @@
}
public boolean isSpecializing() {
- return specializes != null;
+ return getDefinition().getSpecializesAnnotation() != null;
}
//same as ProducerField.getScope
Added:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/SessionBean.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/SessionBean.java
(rev 0)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/SessionBean.java 2009-12-15
15:42:55 UTC (rev 19280)
@@ -0,0 +1,18 @@
+package org.jboss.tools.cdi.internal.core.impl;
+
+import org.eclipse.jdt.core.IAnnotation;
+import org.jboss.tools.cdi.core.ISessionBean;
+
+public class SessionBean extends ClassBean implements ISessionBean {
+
+ public IAnnotation getStatefulDeclaration() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public boolean isStateful() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+}
Property changes on:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/SessionBean.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/StereotypeElement.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/StereotypeElement.java 2009-12-15
15:37:35 UTC (rev 19279)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/StereotypeElement.java 2009-12-15
15:42:55 UTC (rev 19280)
@@ -30,33 +30,19 @@
*/
public class StereotypeElement extends CDIElement implements IStereotype {
AnnotationDefinition definition;
- protected AnnotationDeclaration named;
- protected AnnotationDeclaration alternative;
public StereotypeElement() {}
public void setDefinition(AnnotationDefinition definition) {
this.definition = definition;
- setAnnotations(definition.getAnnotations());
}
- protected void setAnnotations(List<AnnotationDeclaration> ds) {
- for (AnnotationDeclaration d: ds) {
- String typeName = d.getTypeName();
- if(CDIConstants.NAMED_QUALIFIER_TYPE_NAME.equals(typeName)) {
- named = d;
- } else if(CDIConstants.ALTERNATIVE_ANNOTATION_TYPE_NAME.equals(typeName)) {
- alternative = d;
- }
- }
- }
-
public AnnotationDeclaration getAlternativeDeclaration() {
- return alternative;
+ return definition.getAlternativeAnnotation();
}
public AnnotationDeclaration getNameDeclaration() {
- return named;
+ return definition.getNamedAnnotation();
}
public Set<IInterceptorBindingDeclaration> getInterceptorBindingDeclarations() {
@@ -71,7 +57,7 @@
}
public IAnnotation getNameLocation() {
- return named != null ? named.getDeclaration() : null;
+ return getNameDeclaration() != null ? getNameDeclaration().getDeclaration() : null;
}
public IType getSourceType() {
@@ -89,7 +75,7 @@
}
public boolean isAlternative() {
- if(alternative != null) return true;
+ if(getAlternativeDeclaration() != null) return true;
Set<IStereotypeDeclaration> ds = getStereotypeDeclarations();
for (IStereotypeDeclaration d: ds) {
IStereotype s = d.getStereotype();
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/AbstractMemberDefinition.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/AbstractMemberDefinition.java 2009-12-15
15:37:35 UTC (rev 19279)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/AbstractMemberDefinition.java 2009-12-15
15:42:55 UTC (rev 19280)
@@ -11,7 +11,9 @@
package org.jboss.tools.cdi.internal.core.impl.definition;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.core.IAnnotatable;
@@ -31,8 +33,7 @@
public abstract class AbstractMemberDefinition {
protected List<AnnotationDeclaration> annotations = new
ArrayList<AnnotationDeclaration>();
protected IAnnotatable member;
- protected AnnotationDeclaration injectAnnotation;
- protected AnnotationDeclaration producesAnnotation;
+ protected Map<String, AnnotationDeclaration> annotationsByType = new
HashMap<String, AnnotationDeclaration>();
public AbstractMemberDefinition() {}
@@ -57,11 +58,7 @@
a = new InterceptorBindingDeclaration(a);
}
annotations.add(a);
- if(CDIConstants.INJECT_ANNOTATION_TYPE_NAME.equals(a.getTypeName())) {
- injectAnnotation = a;
- } else if(CDIConstants.PRODUCES_ANNOTATION_TYPE_NAME.equals(a.getTypeName())) {
- producesAnnotation = a;
- }
+ annotationsByType.put(a.getTypeName(), a);
}
}
@@ -69,16 +66,20 @@
return annotations;
}
- public boolean isCDIAnnotated() {
- return injectAnnotation != null || producesAnnotation != null;
+ public AnnotationDeclaration getNamedAnnotation() {
+ return annotationsByType.get(CDIConstants.NAMED_QUALIFIER_TYPE_NAME);
}
- public AnnotationDeclaration getProducesAnnotation() {
- return producesAnnotation;
+ public AnnotationDeclaration getTypedAnnotation() {
+ return annotationsByType.get(CDIConstants.TYPED_ANNOTATION_TYPE_NAME);
}
- public AnnotationDeclaration getInjectAnnotation() {
- return injectAnnotation;
+ public AnnotationDeclaration getAlternativeAnnotation() {
+ return annotationsByType.get(CDIConstants.ALTERNATIVE_ANNOTATION_TYPE_NAME);
}
+ public AnnotationDeclaration getSpecializesAnnotation() {
+ return annotationsByType.get(CDIConstants.SPECIALIZES_ANNOTATION_TYPE_NAME);
+ }
+
}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/AnnotationHelper.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/AnnotationHelper.java 2009-12-15
15:37:35 UTC (rev 19279)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/AnnotationHelper.java 2009-12-15
15:42:55 UTC (rev 19280)
@@ -31,6 +31,9 @@
BASIC_ANNOTATION_TYPES.add(TARGET_ANNOTATION_TYPE_NAME);
BASIC_ANNOTATION_TYPES.add(RETENTION_ANNOTATION_TYPE_NAME);
+ BASIC_ANNOTATION_TYPES.add(STATEFUL_ANNOTATION_TYPE_NAME);
+ BASIC_ANNOTATION_TYPES.add(STATELESS_ANNOTATION_TYPE_NAME);
+
SCOPE_ANNOTATION_TYPES.add(APPLICATION_SCOPED_ANNOTATION_TYPE_NAME);
SCOPE_ANNOTATION_TYPES.add(CONVERSATION_SCOPED_ANNOTATION_TYPE_NAME);
SCOPE_ANNOTATION_TYPES.add(REQUEST_SCOPED_ANNOTATION_TYPE_NAME);
@@ -39,6 +42,7 @@
STEREOTYPE_ANNOTATION_TYPES.add(MODEL_STEREOTYPE_TYPE_NAME);
STEREOTYPE_ANNOTATION_TYPES.add(DECORATOR_STEREOTYPE_TYPE_NAME);
+ STEREOTYPE_ANNOTATION_TYPES.add(DELEGATE_STEREOTYPE_TYPE_NAME);
CDI_ANNOTATION_TYPES.add(QUALIFIER_ANNOTATION_TYPE_NAME);
CDI_ANNOTATION_TYPES.add(NAMED_QUALIFIER_TYPE_NAME);
Added:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/BeanMemberDefinition.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/BeanMemberDefinition.java
(rev 0)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/BeanMemberDefinition.java 2009-12-15
15:42:55 UTC (rev 19280)
@@ -0,0 +1,22 @@
+package org.jboss.tools.cdi.internal.core.impl.definition;
+
+import org.jboss.tools.cdi.core.CDIConstants;
+import org.jboss.tools.cdi.internal.core.impl.AnnotationDeclaration;
+
+public class BeanMemberDefinition extends AbstractMemberDefinition {
+
+ public BeanMemberDefinition() {}
+
+ public boolean isCDIAnnotated() {
+ return getInjectAnnotation() != null || getProducesAnnotation() != null;
+ }
+
+ public AnnotationDeclaration getProducesAnnotation() {
+ return annotationsByType.get(CDIConstants.PRODUCES_ANNOTATION_TYPE_NAME);
+ }
+
+ public AnnotationDeclaration getInjectAnnotation() {
+ return annotationsByType.get(CDIConstants.INJECT_ANNOTATION_TYPE_NAME);
+ }
+
+}
Property changes on:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/BeanMemberDefinition.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/DefinitionContext.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/DefinitionContext.java 2009-12-15
15:37:35 UTC (rev 19279)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/DefinitionContext.java 2009-12-15
15:42:55 UTC (rev 19280)
@@ -168,7 +168,6 @@
if(underConstruction.contains(name)) {
return AnnotationDefinition.BASIC;
}
- System.out.println(name);
return createAnnotation(annotationType, name);
}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/FieldDefinition.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/FieldDefinition.java 2009-12-15
15:37:35 UTC (rev 19279)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/FieldDefinition.java 2009-12-15
15:42:55 UTC (rev 19280)
@@ -11,13 +11,15 @@
package org.jboss.tools.cdi.internal.core.impl.definition;
import org.eclipse.jdt.core.IField;
+import org.jboss.tools.cdi.core.CDIConstants;
+import org.jboss.tools.cdi.internal.core.impl.AnnotationDeclaration;
/**
*
* @author Viacheslav Kabanovich
*
*/
-public class FieldDefinition extends AbstractMemberDefinition {
+public class FieldDefinition extends BeanMemberDefinition {
IField field;
public FieldDefinition() {}
@@ -31,4 +33,8 @@
return field;
}
+ public AnnotationDeclaration getDelegateAnnotation() {
+ return annotationsByType.get(CDIConstants.DELEGATE_STEREOTYPE_TYPE_NAME);
+ }
+
}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/MethodDefinition.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/MethodDefinition.java 2009-12-15
15:37:35 UTC (rev 19279)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/MethodDefinition.java 2009-12-15
15:42:55 UTC (rev 19280)
@@ -19,7 +19,7 @@
* @author Viacheslav Kabanovich
*
*/
-public class MethodDefinition extends AbstractMemberDefinition {
+public class MethodDefinition extends BeanMemberDefinition {
IMethod method;
boolean isConstructor;
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/TypeDefinition.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/TypeDefinition.java 2009-12-15
15:37:35 UTC (rev 19279)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/definition/TypeDefinition.java 2009-12-15
15:42:55 UTC (rev 19280)
@@ -32,6 +32,8 @@
List<MethodDefinition> methods = new ArrayList<MethodDefinition>();
AnnotationDeclaration decoratorAnnotation;
AnnotationDeclaration interceptorAnnotation;
+ AnnotationDeclaration statefulAnnotation;
+ AnnotationDeclaration statelessAnnotation;
public TypeDefinition() {
}
@@ -41,13 +43,8 @@
super.init(contextType, context);
isAbstract = Flags.isAbstract(type.getFlags());
for (AnnotationDeclaration a: annotations) {
- int kind = context.getAnnotationKind(a.getType());
- //TODO do we need to create members for specific annotations?
- if(CDIConstants.DECORATOR_STEREOTYPE_TYPE_NAME.equals(a.getTypeName())) {
- decoratorAnnotation = a;
- } else if(CDIConstants.INTERCEPTOR_ANNOTATION_TYPE_NAME.equals(a.getTypeName())) {
- interceptorAnnotation = a;
- }
+ //provide initialization
+ context.getAnnotationKind(a.getType());
}
IField[] fs = getType().getFields();
for (int i = 0; i < fs.length; i++) {
@@ -80,11 +77,19 @@
}
public AnnotationDeclaration getDecoratorAnnotation() {
- return decoratorAnnotation;
+ return annotationsByType.get(CDIConstants.DECORATOR_STEREOTYPE_TYPE_NAME);
}
public AnnotationDeclaration getInterceptorAnnotation() {
- return interceptorAnnotation;
+ return annotationsByType.get(CDIConstants.INTERCEPTOR_ANNOTATION_TYPE_NAME);
}
+ public AnnotationDeclaration getStatefulAnnotation() {
+ return annotationsByType.get(CDIConstants.STATEFUL_ANNOTATION_TYPE_NAME);
+ }
+
+ public AnnotationDeclaration getStatelessAnnotation() {
+ return annotationsByType.get(CDIConstants.STATELESS_ANNOTATION_TYPE_NAME);
+ }
+
}