Author: scabanovich
Date: 2007-07-19 06:09:03 -0400 (Thu, 19 Jul 2007)
New Revision: 2516
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/BeanType.java
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamJavaComponentDeclaration.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/BijectedAttribute.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamJavaComponentDeclaration.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/Util.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ComponentBuilder.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/SeamAnnotations.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ValueInfo.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/lib/ClassScanner.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/lib/TypeScanner.java
Log:
JBIDE-579
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/BeanType.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/BeanType.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/BeanType.java 2007-07-19
10:09:03 UTC (rev 2516)
@@ -0,0 +1,32 @@
+package org.jboss.tools.seam.core;
+
+import org.jboss.tools.seam.internal.core.scanner.java.SeamAnnotations;
+
+public enum BeanType implements SeamAnnotations {
+ ENTITY(ENTITY_ANNOTATION_TYPE, ScopeType.CONVERSATION, "entity"),
+ STATEFUL(STATEFUL_ANNOTATION_TYPE, ScopeType.CONVERSATION, "stateful"),
+ STATELESS(STATELESS_ANNOTATION_TYPE, ScopeType.STATELESS, "stateless"),
+ MESSAGE_DRIVEN(MESSAGE_DRIVEN_ANNOTATION_TYPE, ScopeType.STATELESS,
"message-driven");
+
+ String annotationType;
+ ScopeType defaultScope;
+ String path;
+ BeanType(String annotationType,ScopeType defaultScope, String path) {
+ this.annotationType = annotationType;
+ this.defaultScope = defaultScope;
+ this.path = path;
+ }
+
+ public String getAnnotationType() {
+ return annotationType;
+ }
+
+ ScopeType getDefaultScope() {
+ return defaultScope;
+ }
+
+ public String getPath() {
+ return path;
+ }
+
+}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamJavaComponentDeclaration.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamJavaComponentDeclaration.java 2007-07-19
07:52:31 UTC (rev 2515)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamJavaComponentDeclaration.java 2007-07-19
10:09:03 UTC (rev 2516)
@@ -61,6 +61,12 @@
public void removeBijectedAttribute(IBijectedAttribute attribute);
/**
+ * @param type
+ * @return true if class is marked with annotation referenced in type
+ */
+ public boolean isOfType(BeanType type);
+
+ /**
* @return true if class marked as Stateful
*/
public boolean isStateful();
@@ -71,11 +77,6 @@
public boolean isEntity();
/**
- * Set true if class marked as Entity
- */
- public void setEntity(boolean entity);
-
- /**
* @return roles of component which defined in this component class
*/
public Set<IRole> getRoles();
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/BijectedAttribute.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/BijectedAttribute.java 2007-07-19
07:52:31 UTC (rev 2515)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/BijectedAttribute.java 2007-07-19
10:09:03 UTC (rev 2516)
@@ -55,7 +55,7 @@
if(f instanceof BijectedAttribute) {
BijectedAttribute sf = (BijectedAttribute)f;
if(!typesAreEqual(types, sf.types)) {
- changes = Change.addChange(changes, new Change(this,
ISeamXmlComponentDeclaration.NAME, name, f.name));
+ changes = Change.addChange(changes, new Change(this, "types", types,
sf.types));
this.types = sf.types;
}
}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamJavaComponentDeclaration.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamJavaComponentDeclaration.java 2007-07-19
07:52:31 UTC (rev 2515)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamJavaComponentDeclaration.java 2007-07-19
10:09:03 UTC (rev 2516)
@@ -9,6 +9,7 @@
import org.eclipse.jdt.core.IMember;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.ui.JavaUI;
+import org.jboss.tools.seam.core.BeanType;
import org.jboss.tools.seam.core.BijectedAttributeType;
import org.jboss.tools.seam.core.IBijectedAttribute;
import org.jboss.tools.seam.core.IRole;
@@ -31,8 +32,7 @@
protected String className = null;
protected ScopeType scopeType = ScopeType.UNSPECIFIED;
- protected boolean stateful = false;
- protected boolean entity = false;
+ Map<BeanType, IValueInfo> types = null;
protected int precedence = SeamComponentPrecedenceType.DEFAULT;
protected IType type;
@@ -46,7 +46,16 @@
}
public ScopeType getScope() {
- return scopeType;
+ if(scopeType != null && scopeType != ScopeType.UNSPECIFIED) {
+ return scopeType;
+ }
+ if(isEntity() || isStateful()) {
+ return ScopeType.CONVERSATION;
+ }
+ if(isOfType(BeanType.STATELESS) || isOfType(BeanType.MESSAGE_DRIVEN)) {
+ return ScopeType.STATELESS;
+ }
+ return ScopeType.EVENT;
}
public void setScope(String scope) {
@@ -131,18 +140,18 @@
return roles;
}
+ public boolean isOfType(BeanType type) {
+ return types != null && types.containsKey(type);
+ }
+
public boolean isEntity() {
- return entity;
+ return isOfType(BeanType.ENTITY);
}
public boolean isStateful() {
- return stateful;
+ return isOfType(BeanType.STATEFUL);
}
- public void setStateful(boolean b) {
- stateful = b;
- }
-
public void removeBijectedAttribute(IBijectedAttribute attribute) {
bijectedAttributes.remove(attribute);
}
@@ -155,10 +164,6 @@
roles.remove(role);
}
- public void setEntity(boolean entity) {
- this.entity = entity;
- }
-
public IMember getSourceMember() {
return type;
}
@@ -186,14 +191,11 @@
}
if(type != jd.type) type = jd.type;
- if(stateful != jd.stateful) {
- changes = Change.addChange(changes, new Change(this, "stateful", stateful,
jd.stateful));
- stateful = jd.stateful;
+ if(!typesAreEqual(types, jd.types)) {
+ changes = Change.addChange(changes, new Change(this, "types", types,
jd.types));
}
- if(entity != jd.entity) {
- changes = Change.addChange(changes, new Change(this, "entity", entity,
jd.entity));
- entity = jd.entity;
- }
+ this.types = jd.types;
+
Change children = new Change(this, null, null, null);
mergeComponentMethods(jd, children);
@@ -305,6 +307,16 @@
}
+ boolean typesAreEqual(Map<BeanType, IValueInfo> types1, Map<BeanType,
IValueInfo> types2) {
+ if(types1 == null || types2 == null) return types2 == types1;
+ if(types1.size() != types2.size()) return false;
+ for (BeanType t : types1.keySet()) {
+ if(!types2.containsKey(t)) return false;
+ }
+ return true;
+
+ }
+
/**
* @see org.jboss.tools.seam.core.ISeamJavaComponentDeclaration#getPrecedence()
*/
@@ -333,17 +345,11 @@
//ignore - exact value is stored in ValueInfo
}
}
-
- public void setEntity(IValueInfo value) {
- attributes.put("entity", value);
- setEntity(value != null && "true".equals(value.getValue()));
+
+ public void setTypes(Map<BeanType, IValueInfo> types) {
+ this.types = types;
}
- public void setStateful(IValueInfo value) {
- attributes.put("stateful", value);
- setStateful(value != null && "true".equals(value.getValue()));
- }
-
public Set<ISeamContextVariable> getDeclaredVariables() {
Set<ISeamContextVariable> set = new HashSet<ISeamContextVariable>();
set.addAll(roles);
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/Util.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/Util.java 2007-07-19
07:52:31 UTC (rev 2515)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/Util.java 2007-07-19
10:09:03 UTC (rev 2516)
@@ -26,6 +26,8 @@
EJB_ANNOTATION_TYPES.add(STATEFUL_ANNOTATION_TYPE);
EJB_ANNOTATION_TYPES.add(ENTITY_ANNOTATION_TYPE);
EJB_ANNOTATION_TYPES.add(REMOVE_ANNOTATION_TYPE);
+ EJB_ANNOTATION_TYPES.add(STATELESS_ANNOTATION_TYPE);
+ EJB_ANNOTATION_TYPES.add(MESSAGE_DRIVEN_ANNOTATION_TYPE);
}
/**
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ComponentBuilder.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ComponentBuilder.java 2007-07-19
07:52:31 UTC (rev 2515)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ComponentBuilder.java 2007-07-19
10:09:03 UTC (rev 2516)
@@ -28,8 +28,10 @@
import org.eclipse.jdt.core.dom.NormalAnnotation;
import org.eclipse.jdt.core.dom.SingleMemberAnnotation;
import org.eclipse.jdt.core.dom.VariableDeclaration;
+import org.jboss.tools.seam.core.BeanType;
import org.jboss.tools.seam.core.BijectedAttributeType;
import org.jboss.tools.seam.core.ISeamXmlComponentDeclaration;
+import org.jboss.tools.seam.core.IValueInfo;
import org.jboss.tools.seam.core.SeamComponentMethodType;
import org.jboss.tools.seam.internal.core.BijectedAttribute;
import org.jboss.tools.seam.internal.core.Role;
@@ -85,21 +87,26 @@
component.setScope(scope);
} else if(INSTALL_ANNOTATION_TYPE.equals(type)) {
component.setPrecedence(ValueInfo.getValueInfo(as[i].getAnnotation(),
"precedence"));
- } else if(STATEFUL_ANNOTATION_TYPE.equals(type)) {
- ValueInfo stateful = new ValueInfo();
- stateful.value = "true";
- stateful.valueStartPosition = as[i].getAnnotation().getStartPosition();
- stateful.valueLength = as[i].getAnnotation().getLength();
- component.setStateful(stateful);
- } else if(ENTITY_ANNOTATION_TYPE.equals(type)) {
- ValueInfo entity = new ValueInfo();
- entity.value = "true";
- entity.valueStartPosition = as[i].getAnnotation().getStartPosition();
- entity.valueLength = as[i].getAnnotation().getLength();
- component.setEntity(entity);
}
}
+ if(as != null) {
+ Map<BeanType, IValueInfo> types = new HashMap<BeanType, IValueInfo>();
+ for (int i = 0; i < BeanType.values().length; i++) {
+ Annotation a = findAnnotation(annotatedType,
BeanType.values()[i].getAnnotationType());
+ if(a != null) {
+ ValueInfo v = new ValueInfo();
+ v.value = "true";
+ v.valueStartPosition = a.getStartPosition();
+ v.valueLength = a.getLength();
+ types.put(BeanType.values()[i], v);
+ }
+ }
+ if(types.size() > 0) {
+ component.setTypes(types);
+ }
+ }
+
processFactories();
processBijections();
processComponentMethods();
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/SeamAnnotations.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/SeamAnnotations.java 2007-07-19
07:52:31 UTC (rev 2515)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/SeamAnnotations.java 2007-07-19
10:09:03 UTC (rev 2516)
@@ -41,5 +41,7 @@
public static String ENTITY_ANNOTATION_TYPE = "javax.persistence.Entity";
public static String STATEFUL_ANNOTATION_TYPE = "javax.ejb.Stateful";
+ public static String STATELESS_ANNOTATION_TYPE = "javax.ejb.Stateless";
+ public static String MESSAGE_DRIVEN_ANNOTATION_TYPE =
"javax.ejb.MessageDriven";
}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ValueInfo.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ValueInfo.java 2007-07-19
07:52:31 UTC (rev 2515)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ValueInfo.java 2007-07-19
10:09:03 UTC (rev 2516)
@@ -78,5 +78,9 @@
}
return exp.toString();
}
+
+ public void setValue(String value) {
+ this.value = value;
+ }
}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/lib/ClassScanner.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/lib/ClassScanner.java 2007-07-19
07:52:31 UTC (rev 2515)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/lib/ClassScanner.java 2007-07-19
10:09:03 UTC (rev 2516)
@@ -22,7 +22,9 @@
import org.eclipse.jdt.core.IMember;
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.IType;
+import org.jboss.tools.seam.core.BeanType;
import org.jboss.tools.seam.core.BijectedAttributeType;
+import org.jboss.tools.seam.core.IValueInfo;
import org.jboss.tools.seam.core.SeamCorePlugin;
import org.jboss.tools.seam.internal.core.AbstractContextVariable;
import org.jboss.tools.seam.internal.core.BijectedAttribute;
@@ -31,6 +33,7 @@
import org.jboss.tools.seam.internal.core.scanner.LoadedDeclarations;
import org.jboss.tools.seam.internal.core.scanner.Util;
import org.jboss.tools.seam.internal.core.scanner.java.SeamAnnotations;
+import org.jboss.tools.seam.internal.core.scanner.java.ValueInfo;
/**
* Loads seam components from Class object.
@@ -124,15 +127,22 @@
Object precedence = getValue(a, "precedence");
if(precedence instanceof Integer) component.setPrecedence((Integer)precedence);
}
- a = map.get(STATEFUL_ANNOTATION_TYPE);
+ }
+
+ Map<BeanType, IValueInfo> types = new HashMap<BeanType, IValueInfo>();
+ for (int i = 0; i < BeanType.values().length; i++) {
+ BeanType t = BeanType.values()[i];
+ Annotation a = map.get(t.getAnnotationType());
if(a != null) {
- component.setStateful(true);
+ ValueInfo v = new ValueInfo();
+ v.setValue("true");
+ types.put(t, v);
}
- a = map.get(ENTITY_ANNOTATION_TYPE);
- if(a != null) {
- component.setEntity(true);
- }
}
+ if(types.size() > 0) {
+ component.setTypes(types);
+ }
+
Method[] ms = null;
try {
ms = cls.getMethods();
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/lib/TypeScanner.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/lib/TypeScanner.java 2007-07-19
07:52:31 UTC (rev 2515)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/lib/TypeScanner.java 2007-07-19
10:09:03 UTC (rev 2516)
@@ -22,7 +22,9 @@
import org.eclipse.jdt.internal.compiler.impl.Constant;
import org.eclipse.jdt.internal.compiler.impl.IntConstant;
import org.eclipse.jdt.internal.compiler.impl.StringConstant;
+import org.jboss.tools.seam.core.BeanType;
import org.jboss.tools.seam.core.BijectedAttributeType;
+import org.jboss.tools.seam.core.IValueInfo;
import org.jboss.tools.seam.core.SeamCorePlugin;
import org.jboss.tools.seam.internal.core.AbstractContextVariable;
import org.jboss.tools.seam.internal.core.BijectedAttribute;
@@ -31,6 +33,7 @@
import org.jboss.tools.seam.internal.core.scanner.LoadedDeclarations;
import org.jboss.tools.seam.internal.core.scanner.Util;
import org.jboss.tools.seam.internal.core.scanner.java.SeamAnnotations;
+import org.jboss.tools.seam.internal.core.scanner.java.ValueInfo;
public class TypeScanner implements SeamAnnotations {
@@ -135,15 +138,23 @@
//ignore
}
}
- a = map.get(STATEFUL_ANNOTATION_TYPE);
+ }
+
+ Map<BeanType, IValueInfo> types = new HashMap<BeanType, IValueInfo>();
+ for (int i = 0; i < BeanType.values().length; i++) {
+ BeanType t = BeanType.values()[i];
+ IBinaryAnnotation a = map.get(t.getAnnotationType());
if(a != null) {
- component.setStateful(true);
+ ValueInfo v = new ValueInfo();
+ v.setValue("true");
+ types.put(t, v);
}
- a = map.get(ENTITY_ANNOTATION_TYPE);
- if(a != null) {
- component.setEntity(true);
- }
}
+ if(types.size() > 0) {
+ component.setTypes(types);
+ }
+
+
IBinaryMethod[] ms = null;
try {
ms = cls.getMethods();