Author: scabanovich
Date: 2007-07-06 10:37:22 -0400 (Fri, 06 Jul 2007)
New Revision: 2343
Removed:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamFactory.java
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/IBijectedAttribute.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamComponentMethod.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/SeamAnnotatedFactory.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponentDeclaration.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/SeamProject.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamXmlFactory.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/LoadedDeclarations.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/JavaScanner.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/LibraryScanner.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/XMLScanner.java
Log:
EXIN-217 Implementations of model interfaces added
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/IBijectedAttribute.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/IBijectedAttribute.java 2007-07-06
14:08:17 UTC (rev 2342)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/IBijectedAttribute.java 2007-07-06
14:37:22 UTC (rev 2343)
@@ -19,5 +19,13 @@
/**
* @return type of attribute
*/
- public BijectedAttributeType getType();
+ public BijectedAttributeType[] getTypes();
+
+ /**
+ * Checks if type is contained in list of types.
+ * @param type
+ * @return
+ */
+ public boolean isOfType(BijectedAttributeType type);
+
}
\ No newline at end of file
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamComponentMethod.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamComponentMethod.java 2007-07-06
14:08:17 UTC (rev 2342)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamComponentMethod.java 2007-07-06
14:37:22 UTC (rev 2343)
@@ -18,7 +18,20 @@
public interface ISeamComponentMethod extends ISeamJavaSourceReference {
/**
- * @return method type
+ * @return is @ Create method
*/
- public SeamComponentMethodType getType();
+ public boolean isCreate();
+
+ /**
+ * @return is @ Destroy method
+ */
+ public boolean isDestroy();
+
+ /**
+ * Returns create or destroy depending on type
+ * @param type
+ * @return
+ */
+ public boolean isOfType(SeamComponentMethodType type);
+
}
\ No newline at end of file
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-06
14:08:17 UTC (rev 2342)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/BijectedAttribute.java 2007-07-06
14:37:22 UTC (rev 2343)
@@ -10,74 +10,37 @@
******************************************************************************/
package org.jboss.tools.seam.internal.core;
-import org.eclipse.core.resources.IResource;
import org.eclipse.jdt.core.IMember;
-import org.eclipse.jdt.core.JavaModelException;
import org.jboss.tools.seam.core.BijectedAttributeType;
import org.jboss.tools.seam.core.IBijectedAttribute;
-import org.jboss.tools.seam.core.ScopeType;
/**
* @author Viacheslav Kabanovich
*/
-public class BijectedAttribute implements IBijectedAttribute {
- IMember javaSource = null;
- BijectedAttributeType type = null;
- String name = null;
- ScopeType scopeType = ScopeType.UNSPECIFIED;
+public class BijectedAttribute extends SeamJavaContextVariable implements
IBijectedAttribute {
+ BijectedAttributeType[] types = null;
+
+ public BijectedAttribute() {
+ }
public void setMember(IMember javaSource) {
this.javaSource = javaSource;
}
- public BijectedAttributeType getType() {
- return type;
+ public BijectedAttributeType[] getTypes() {
+ return types;
}
-
- public String getName() {
- return name;
- }
-
- public ScopeType getScope() {
- return scopeType;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public void setScope(ScopeType type) {
- this.scopeType = type;
- }
-
- public IMember getSourceMember() {
- return javaSource;
- }
-
- public int getLength() {
- if(javaSource == null) return 0;
- try {
- if(javaSource.getSourceRange() == null) return 0;
- return javaSource.getSourceRange().getLength();
- } catch (JavaModelException e) {
- //ignore
- return 0;
+
+ public boolean isOfType(BijectedAttributeType type) {
+ if(types == null) return false;
+ for (int i = 0; i < types.length; i++) {
+ if(types[i] == type) return true;
}
+ return false;
}
- public IResource getResource() {
- return javaSource == null ? null : javaSource.getTypeRoot().getResource();
+ public void setTypes(BijectedAttributeType[] types) {
+ this.types = types;
}
- public int getStartPosition() {
- if(javaSource == null) return 0;
- try {
- if(javaSource.getSourceRange() == null) return 0;
- return javaSource.getSourceRange().getOffset();
- } catch (JavaModelException e) {
- //ignore
- return 0;
- }
- }
-
}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamAnnotatedFactory.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamAnnotatedFactory.java 2007-07-06
14:08:17 UTC (rev 2342)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamAnnotatedFactory.java 2007-07-06
14:37:22 UTC (rev 2343)
@@ -12,10 +12,7 @@
import java.util.List;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.jdt.core.IMember;
import org.eclipse.jdt.core.IMethod;
-import org.eclipse.jdt.core.JavaModelException;
import org.jboss.tools.seam.core.ISeamAnnotatedFactory;
import org.jboss.tools.seam.core.ISeamXmlComponentDeclaration;
import org.jboss.tools.seam.core.event.Change;
@@ -23,22 +20,17 @@
/**
* @author Viacheslav Kabanovich
*/
-public class SeamAnnotatedFactory extends SeamFactory implements ISeamAnnotatedFactory {
- IMethod javaSource = null;
+public class SeamAnnotatedFactory extends SeamJavaContextVariable implements
ISeamAnnotatedFactory {
boolean autoCreate = false;
public IMethod getSourceMethod() {
- return javaSource;
+ return (IMethod)javaSource;
}
public void setMethod(IMethod method) {
this.javaSource = method;
}
- public IMember getSourceMember() {
- return javaSource;
- }
-
public boolean isAutoCreate() {
return autoCreate;
}
@@ -47,33 +39,7 @@
this.autoCreate = autoCreate;
}
- public int getLength() {
- if(javaSource == null) return 0;
- try {
- if(javaSource.getSourceRange() == null) return 0;
- return javaSource.getSourceRange().getLength();
- } catch (JavaModelException e) {
- //ignore
- return 0;
- }
- }
-
- public IResource getResource() {
- return javaSource == null ? null : javaSource.getTypeRoot().getResource();
- }
-
- public int getStartPosition() {
- if(javaSource == null) return 0;
- try {
- if(javaSource.getSourceRange() == null) return 0;
- return javaSource.getSourceRange().getOffset();
- } catch (JavaModelException e) {
- //ignore
- return 0;
- }
- }
-
- public List<Change> merge(SeamFactory f) {
+ public List<Change> merge(AbstractContextVariable f) {
List<Change> changes = super.merge(f);
SeamAnnotatedFactory af = (SeamAnnotatedFactory)f;
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponentDeclaration.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponentDeclaration.java 2007-07-06
14:08:17 UTC (rev 2342)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponentDeclaration.java 2007-07-06
14:37:22 UTC (rev 2343)
@@ -13,9 +13,11 @@
import java.util.List;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.jboss.tools.seam.core.ISeamComponentDeclaration;
import org.jboss.tools.seam.core.ISeamTextSourceReference;
+import org.jboss.tools.seam.core.SeamCorePlugin;
import org.jboss.tools.seam.core.event.Change;
/**
@@ -29,6 +31,8 @@
* Path of resource where this component is declared.
*/
protected IPath source;
+
+ protected IResource resource;
/**
* Object that allows to identify this declaration.
@@ -70,9 +74,15 @@
}
public IResource getResource() {
- // TODO Auto-generated method stub
- return null;
+ if(resource == null && source != null) {
+ resource = ResourcesPlugin.getWorkspace().getRoot().getFile(source);
+ }
+ return resource;
}
+
+ public void setResource(IResource resource) {
+ this.resource = resource;
+ }
public int getStartPosition() {
// TODO Auto-generated method stub
Deleted:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamFactory.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamFactory.java 2007-07-06
14:08:17 UTC (rev 2342)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamFactory.java 2007-07-06
14:37:22 UTC (rev 2343)
@@ -1,96 +0,0 @@
-package org.jboss.tools.seam.internal.core;
-
-import java.util.List;
-
-import org.eclipse.core.runtime.IPath;
-import org.jboss.tools.seam.core.ISeamFactory;
-import org.jboss.tools.seam.core.ISeamXmlComponentDeclaration;
-import org.jboss.tools.seam.core.ScopeType;
-import org.jboss.tools.seam.core.event.Change;
-
-public class SeamFactory implements ISeamFactory {
- /**
- * Path of resource where this factory is declared.
- */
- protected IPath source;
- /**
- * Object that allows to identify this declaration.
- */
- protected Object id;
-
- String name = null;
- String scope = null;
- ScopeType scopeType = ScopeType.UNSPECIFIED;
-
- public Object getId() {
- return id;
- }
-
- public void setId(Object id) {
- this.id = id;
- }
-
- public void setSourcePath(IPath path) {
- source = path;
- }
-
- public IPath getSourcePath() {
- return source;
- }
-
- public String getName() {
- return name;
- }
-
- public ScopeType getScope() {
- return scopeType;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public void setScope(ScopeType type) {
- this.scopeType = type;
- scope = scopeType.toString();
- }
-
- public void setScopeAsString(String scope) {
- this.scope = scope;
- try {
- this.scopeType = scope == null || scope.length() == 0 ? ScopeType.UNSPECIFIED :
ScopeType.valueOf(scope.toUpperCase());
- } catch (Exception e) {
- //ignore
- }
- }
-
- /**
- * Merges loaded data into currently used declaration.
- * If changes were done returns a list of changes.
- * @param f
- * @return list of changes
- */
- public List<Change> merge(SeamFactory f) {
- List<Change> changes = null;
-
- source = f.source;
- id = f.id;
-
- if(!stringsEqual(name, f.name)) {
- changes = Change.addChange(changes, new Change(this,
ISeamXmlComponentDeclaration.NAME, name, f.name));
- name = f.name;
- }
- if(!stringsEqual(scope, f.scope)) {
- changes = Change.addChange(changes, new Change(this,
ISeamXmlComponentDeclaration.SCOPE, scope, f.scope));
- scope = f.scope;
- scopeType = f.scopeType;
- }
-
- return changes;
- }
-
- boolean stringsEqual(String s1, String s2) {
- return s1 == null ? s2 == null : s1.equals(s2);
- }
-
-}
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-06
14:08:17 UTC (rev 2342)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamJavaComponentDeclaration.java 2007-07-06
14:37:22 UTC (rev 2343)
@@ -86,7 +86,7 @@
BijectedAttributeType type) {
Set<IBijectedAttribute> result = null;
for(IBijectedAttribute a: getBijectedAttributes()) {
- if(type.equals(a.getType())) {
+ if(a.isOfType(type)) {
if(result == null) result = new HashSet<IBijectedAttribute>();
result.add(a);
}
@@ -102,7 +102,7 @@
SeamComponentMethodType type) {
Set<ISeamComponentMethod> result = null;
for(ISeamComponentMethod a: getMethods()) {
- if(type.equals(a.getType())) {
+ if(a.isOfType(type)) {
if(result == null) result = new HashSet<ISeamComponentMethod>();
result.add(a);
}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java 2007-07-06
14:08:17 UTC (rev 2342)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java 2007-07-06
14:37:22 UTC (rev 2343)
@@ -11,7 +11,6 @@
package org.jboss.tools.seam.internal.core;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@@ -104,7 +103,7 @@
public void registerComponents(LoadedDeclarations ds, IPath source) {
SeamComponentDeclaration[] components = ds.getComponents().toArray(new
SeamComponentDeclaration[0]);
- SeamFactory[] factories = ds.getFactories().toArray(new SeamFactory[0]);
+ ISeamFactory[] factories = ds.getFactories().toArray(new ISeamFactory[0]);
if(components.length == 0 && factories.length == 0) {
pathRemoved(source);
@@ -173,15 +172,15 @@
Map<Object, ISeamFactory> currentFactories = findFactoryDeclarations(source);
List<Change> addedFactories = null;
for (int i = 0; i < factories.length; i++) {
- SeamFactory loaded = factories[i];
- SeamFactory current = (SeamFactory)currentFactories.remove(loaded.getId());
+ AbstractContextVariable loaded = (AbstractContextVariable)factories[i];
+ AbstractContextVariable current =
(AbstractContextVariable)currentFactories.remove(loaded.getId());
if(current != null) {
List<Change> changes = current.merge(loaded);
fireChanges(changes);
continue;
}
- allFactories.add(loaded);
- allVariables.add(loaded);
+ allFactories.add(factories[i]);
+ allVariables.add(factories[i]);
addedFactories = Change.addChange(addedFactories, new Change(this, null, null,
loaded));
}
fireChanges(addedFactories);
@@ -220,7 +219,7 @@
}
Iterator<ISeamFactory> factories = allFactories.iterator();
while(factories.hasNext()) {
- SeamFactory f = (SeamFactory)factories.next();
+ AbstractContextVariable f = (AbstractContextVariable)factories.next();
if(source.equals(f.getSourcePath())) {
List<Change> changes = Change.addChange(null, new Change(this, null, f,
null));
factories.remove();
@@ -269,8 +268,8 @@
public Map<Object,ISeamFactory> findFactoryDeclarations(IPath source) {
Map<Object,ISeamFactory> map = new HashMap<Object, ISeamFactory>();
for (ISeamFactory c: allFactories) {
- SeamFactory ci = (SeamFactory)c;
- if(source.equals(ci.getSourcePath())) map.put(ci.getId(), ci);
+ AbstractContextVariable ci = (AbstractContextVariable)c;
+ if(source.equals(ci.getSourcePath())) map.put(ci.getId(), c);
}
return map;
}
@@ -279,7 +278,7 @@
Iterator<ISeamFactory> iterator = allFactories.iterator();
List<Change> changes = null;
while(iterator.hasNext()) {
- SeamFactory c = (SeamFactory)iterator.next();
+ AbstractContextVariable c = (AbstractContextVariable)iterator.next();
if(removed.containsKey(c.getId())) {
iterator.remove();
allVariables.remove(c);
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamXmlFactory.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamXmlFactory.java 2007-07-06
14:08:17 UTC (rev 2342)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamXmlFactory.java 2007-07-06
14:37:22 UTC (rev 2343)
@@ -12,14 +12,13 @@
import java.util.List;
-import org.eclipse.core.resources.IResource;
import org.jboss.tools.seam.core.ISeamXmlFactory;
import org.jboss.tools.seam.core.event.Change;
/**
* @author Viacheslav Kabanovich
*/
-public class SeamXmlFactory extends SeamFactory implements ISeamXmlFactory {
+public class SeamXmlFactory extends AbstractContextVariable implements ISeamXmlFactory {
String method = null;
String value = null;
@@ -39,22 +38,7 @@
this.value = value;
}
- public int getLength() {
- // TODO Auto-generated method stub
- return 0;
- }
-
- public IResource getResource() {
- // TODO Auto-generated method stub
- return null;
- }
-
- public int getStartPosition() {
- // TODO Auto-generated method stub
- return 0;
- }
-
- public List<Change> merge(SeamFactory f) {
+ public List<Change> merge(AbstractContextVariable f) {
List<Change> changes = super.merge(f);
SeamXmlFactory xf = (SeamXmlFactory)f;
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/LoadedDeclarations.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/LoadedDeclarations.java 2007-07-06
14:08:17 UTC (rev 2342)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/LoadedDeclarations.java 2007-07-06
14:37:22 UTC (rev 2343)
@@ -13,8 +13,8 @@
import java.util.ArrayList;
import java.util.List;
+import org.jboss.tools.seam.core.ISeamFactory;
import org.jboss.tools.seam.internal.core.SeamComponentDeclaration;
-import org.jboss.tools.seam.internal.core.SeamFactory;
/**
* This object keeps all declarations loaded from one source.
@@ -23,13 +23,13 @@
*/
public class LoadedDeclarations {
List<SeamComponentDeclaration> components = new
ArrayList<SeamComponentDeclaration>();
- List<SeamFactory> factories = new ArrayList<SeamFactory>();
+ List<ISeamFactory> factories = new ArrayList<ISeamFactory>();
public List<SeamComponentDeclaration> getComponents() {
return components;
}
- public List<SeamFactory> getFactories() {
+ public List<ISeamFactory> getFactories() {
return factories;
}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/JavaScanner.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/JavaScanner.java 2007-07-06
14:08:17 UTC (rev 2342)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/JavaScanner.java 2007-07-06
14:37:22 UTC (rev 2343)
@@ -75,7 +75,7 @@
public LoadedDeclarations parse(IFile f) throws Exception {
ICompilationUnit u = getCompilationUnit(f);
if(u == null) return null;
- ASTRequestorImpl requestor = new ASTRequestorImpl(f.getFullPath());
+ ASTRequestorImpl requestor = new ASTRequestorImpl(f);
ICompilationUnit[] us = new ICompilationUnit[]{u};
ASTParser.newParser(AST.JLS3).createASTs(us, new String[0], requestor, null);
return requestor.getDeclarations();
@@ -101,10 +101,12 @@
class ASTRequestorImpl extends ASTRequestor {
private ASTVisitorImpl visitor = new ASTVisitorImpl();
LoadedDeclarations ds = new LoadedDeclarations();
+ IResource resource;
IPath sourcePath;
- public ASTRequestorImpl(IPath sourcePath) {
- this.sourcePath = sourcePath;
+ public ASTRequestorImpl(IResource resource) {
+ this.resource = resource;
+ this.sourcePath = resource.getFullPath();
}
public LoadedDeclarations getDeclarations() {
@@ -130,6 +132,7 @@
component.setId(visitor.type);
component.setSourcePath(sourcePath);
+ component.setResource(resource);
ds.getComponents().add(component);
component.setType(visitor.type);
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-06
14:08:17 UTC (rev 2342)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/lib/ClassScanner.java 2007-07-06
14:37:22 UTC (rev 2343)
@@ -11,13 +11,22 @@
package org.jboss.tools.seam.internal.core.scanner.lib;
import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.jdt.core.IField;
+import org.eclipse.jdt.core.IMember;
+import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.IType;
+import org.jboss.tools.seam.core.BijectedAttributeType;
import org.jboss.tools.seam.core.SeamCorePlugin;
+import org.jboss.tools.seam.internal.core.AbstractContextVariable;
+import org.jboss.tools.seam.internal.core.BijectedAttribute;
+import org.jboss.tools.seam.internal.core.SeamAnnotatedFactory;
import org.jboss.tools.seam.internal.core.SeamJavaComponentDeclaration;
import org.jboss.tools.seam.internal.core.scanner.LoadedDeclarations;
import org.jboss.tools.seam.internal.core.scanner.java.SeamAnnotations;
@@ -53,10 +62,16 @@
SeamJavaComponentDeclaration component = new SeamJavaComponentDeclaration();
component.setSourcePath(path);
component.setId(type);
+ component.setType(type);
component.setClassName(type.getFullyQualifiedName());
process(cls, component, ds);
ds.getComponents().add(component);
+ for (int i = 0; i < ds.getFactories().size(); i++) {
+ AbstractContextVariable f = (AbstractContextVariable)ds.getFactories().get(i);
+ f.setSourcePath(path);
+ f.getId();
+ }
return ds;
}
@@ -109,8 +124,13 @@
if(precedence instanceof Integer) component.setPrecedence((Integer)precedence);
}
}
- Method[] ms = cls.getMethods();
- for (int i = 0; i < ms.length; i++) {
+ Method[] ms = null;
+ try {
+ ms = cls.getMethods();
+ } catch (NoClassDefFoundError e) {
+ //ignore
+ }
+ if(ms != null) for (int i = 0; i < ms.length; i++) {
process(ms[i], component, ds);
}
}
@@ -118,9 +138,62 @@
private void process(Method m, SeamJavaComponentDeclaration component,
LoadedDeclarations ds) {
Map<String,Annotation> map = getSeamAnnotations(m.getAnnotations());
if(map == null || map.isEmpty()) return;
+ Annotation a = map.get(FACTORY_ANNOTATION_TYPE);
+ if(a != null) {
+ processFactory(m, a, component, ds);
+ }
+ Annotation in = map.get(IN_ANNOTATION_TYPE);
+ Annotation out = map.get(OUT_ANNOTATION_TYPE);
+ if(in != null || out != null) {
+ processBijection(m, in, out, component, ds);
+ }
+ }
+
+ private void processFactory(Method m, Annotation a, SeamJavaComponentDeclaration
component, LoadedDeclarations ds) {
+ if(a == null) return;
+ String name = (String)getValue(a, "value");
+ if(name == null || name.length() == 0) {
+ name = m.getName();
+ }
+ SeamAnnotatedFactory factory = new SeamAnnotatedFactory();
+ ds.getFactories().add(factory);
+ IMethod im = findIMethod(component, m);
+ factory.setId(im);
+ factory.setMethod(im);
+ factory.setName(name);
+
+ Object scope = getValue(a, "scope");
+ if(scope != null) factory.setScopeAsString(scope.toString());
+ Object autoCreate = getValue(a, "autoCreate");
+ if(autoCreate instanceof Boolean) {
+ factory.setAutoCreate((Boolean)autoCreate);
+ }
}
+
+ private void processBijection(Member m, Annotation in, Annotation out,
SeamJavaComponentDeclaration component, LoadedDeclarations ds) {
+ if(in == null && out == null) return;
+ BijectedAttribute att = new BijectedAttribute();
+ component.getBijectedAttributes().add(att);
+ BijectedAttributeType[] types = (in == null) ? new
BijectedAttributeType[]{BijectedAttributeType.OUT}
+ : (out == null) ? new BijectedAttributeType[]{BijectedAttributeType.IN}
+ : new BijectedAttributeType[]{BijectedAttributeType.IN, BijectedAttributeType.OUT};
+ att.setTypes(types);
+
+ String name = (String)getValue(in != null ? in : out, "value");
+ if(name == null || name.length() == 0) {
+ name = m.getName();
+ }
+ att.setName(name);
+ Object scope = getValue(in != null ? in : out, "scope");
+ if(scope != null) att.setScopeAsString(scope.toString());
+
+ IMember im = findIMember(component, m);
+ att.setMember(im);
+
+ }
+
private Object getValue(Annotation a, String method) {
try {
Method m = a.annotationType().getMethod(method, new Class[0]);
@@ -132,4 +205,23 @@
return null;
}
+ private IMember findIMember(SeamJavaComponentDeclaration component, Member m) {
+ if(m instanceof Field) return findIField(component, (Field)m);
+ if(m instanceof Method) return findIMethod(component, (Method)m);
+ return null;
+ }
+
+ private IMethod findIMethod(SeamJavaComponentDeclaration component, Method m) {
+ IType type = (IType)component.getSourceMember();
+ Class<?>[] ps = m.getParameterTypes();
+ String[] params = new String[ps == null ? 0 : ps.length];
+ for (int i = 0; i < ps.length; i++) params[i] = ps[i].getName();
+ return type.getMethod(m.getName(), params);
+ }
+
+ private IField findIField(SeamJavaComponentDeclaration component, Field m) {
+ IType type = (IType)component.getSourceMember();
+ return type.getField(m.getName());
+ }
+
}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/lib/LibraryScanner.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/lib/LibraryScanner.java 2007-07-06
14:08:17 UTC (rev 2342)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/lib/LibraryScanner.java 2007-07-06
14:37:22 UTC (rev 2343)
@@ -155,6 +155,9 @@
IClassFile typeRoot = (IClassFile)es[i];
IType type = typeRoot.getType();
String className = type.getFullyQualifiedName();
+ if(className.indexOf("ProcessInstanceF") >= 0) {
+ System.out.println("!!");
+ }
Class<?> cls = null;
try {
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/XMLScanner.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/XMLScanner.java 2007-07-06
14:08:17 UTC (rev 2342)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/XMLScanner.java 2007-07-06
14:37:22 UTC (rev 2343)
@@ -25,7 +25,6 @@
import org.jboss.tools.common.model.util.EclipseResourceUtil;
import org.jboss.tools.seam.core.ISeamXmlComponentDeclaration;
import org.jboss.tools.seam.core.ISeamXmlFactory;
-import org.jboss.tools.seam.internal.core.SeamFactory;
import org.jboss.tools.seam.internal.core.SeamProperty;
import org.jboss.tools.seam.internal.core.SeamXmlComponentDeclaration;
import org.jboss.tools.seam.internal.core.SeamXmlFactory;