Author: scabanovich
Date: 2007-07-03 11:23:38 -0400 (Tue, 03 Jul 2007)
New Revision: 2258
Added:
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/SeamPropertiesDeclaration.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamXmlComponentDeclaration.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/core/ISeamPropertiesDeclaration.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamXmlComponentDeclaration.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamCoreBuilder.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponent.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/SeamProperty.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/IFileScanner.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/LibraryScanner.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/XMLScanner.java
Log:
EXIN-217
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-03
15:22:27 UTC (rev 2257)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamJavaComponentDeclaration.java 2007-07-03
15:23:38 UTC (rev 2258)
@@ -21,6 +21,8 @@
*
*/
public interface ISeamJavaComponentDeclaration extends ISeamComponentDeclaration {
+
+ public String getClassName();
/**
* @return bijected attributes
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamPropertiesDeclaration.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamPropertiesDeclaration.java 2007-07-03
15:22:27 UTC (rev 2257)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamPropertiesDeclaration.java 2007-07-03
15:23:38 UTC (rev 2258)
@@ -10,8 +10,8 @@
******************************************************************************/
package org.jboss.tools.seam.core;
+import java.util.Collection;
import java.util.List;
-import java.util.Set;
/**
* @author Alexey Kazakov
@@ -38,7 +38,7 @@
* @param propertyName
* @return
*/
- public Set<ISeamProperty> getProperties();
+ public Collection<ISeamProperty> getProperties();
/**
* Adds property to component.
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamXmlComponentDeclaration.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamXmlComponentDeclaration.java 2007-07-03
15:22:27 UTC (rev 2257)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamXmlComponentDeclaration.java 2007-07-03
15:23:38 UTC (rev 2258)
@@ -15,6 +15,13 @@
*
*/
public interface ISeamXmlComponentDeclaration extends ISeamPropertiesDeclaration {
+ public String NAME = "name";
+ public String CLASS = "class";
+ public String SCOPE = "scope";
+ public String PRECEDENCE = "precedence";
+ public String INSTALLED = "installed";
+ public String AUTO_CREATE = "auto-create";
+ public String JNDI_NAME = "jndi-name";
public ScopeType getScope();
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamCoreBuilder.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamCoreBuilder.java 2007-07-03
15:22:27 UTC (rev 2257)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamCoreBuilder.java 2007-07-03
15:23:38 UTC (rev 2258)
@@ -27,6 +27,7 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.jboss.tools.seam.internal.core.SeamComponent;
+import org.jboss.tools.seam.internal.core.SeamComponentDeclaration;
import org.jboss.tools.seam.internal.core.SeamProject;
import org.jboss.tools.seam.internal.core.scanner.IFileScanner;
import org.jboss.tools.seam.internal.core.scanner.java.JavaScanner;
@@ -85,7 +86,7 @@
IFileScanner scanner = FILE_SCANNERS[i];
if(scanner.isRelevant(f)) {
if(!scanner.isLikelyComponentSource(f)) return false;
- SeamComponent[] c = null;
+ SeamComponentDeclaration[] c = null;
try {
c = scanner.parse(f);
} catch (Exception e) {
@@ -100,7 +101,7 @@
}
}
- void componentsLoaded(SeamComponent[] c, IFile resource) {
+ void componentsLoaded(SeamComponentDeclaration[] c, IFile resource) {
if(c == null || c.length == 0) return;
SeamProject p = getSeamProject();
if(p == null) return;
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponent.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponent.java 2007-07-03
15:22:27 UTC (rev 2257)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponent.java 2007-07-03
15:23:38 UTC (rev 2258)
@@ -12,13 +12,10 @@
import java.util.ArrayList;
import java.util.Collection;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
-import java.util.Map;
import java.util.Set;
-import org.eclipse.core.runtime.IPath;
import org.jboss.tools.seam.core.BijectedAttributeType;
import org.jboss.tools.seam.core.IBijectedAttribute;
import org.jboss.tools.seam.core.IRole;
@@ -29,126 +26,36 @@
import org.jboss.tools.seam.core.ISeamJavaComponentDeclaration;
import org.jboss.tools.seam.core.ISeamPropertiesDeclaration;
import org.jboss.tools.seam.core.ISeamProperty;
-import org.jboss.tools.seam.core.ISeamTextSourceReference;
import org.jboss.tools.seam.core.ISeamXmlComponentDeclaration;
import org.jboss.tools.seam.core.ScopeType;
import org.jboss.tools.seam.core.SeamComponentMethodType;
public class SeamComponent implements ISeamComponent {
- protected ISeamComponent base = null;
protected String name = null;
- protected String className = null;
- protected ScopeType scopeType = ScopeType.UNSPECIFIED;
- protected boolean stateful = false;
- protected boolean entity = false;
-
- protected Map<String,ISeamProperty> properties = new HashMap<String,
ISeamProperty>();
- protected IPath source;
-
- protected Set<IBijectedAttribute> bijectedAttributes = new
HashSet<IBijectedAttribute>();
- protected Set<ISeamAnnotatedFactory> annotatedFactories = new
HashSet<ISeamAnnotatedFactory>();
- protected Set<ISeamComponentMethod> componentMethods = new
HashSet<ISeamComponentMethod>();
- protected Set<IRole> roles = new HashSet<IRole>();
+ Set<ISeamComponentDeclaration> allDeclarations = new
HashSet<ISeamComponentDeclaration>();
+ Set<ISeamJavaComponentDeclaration> javaDeclarations = new
HashSet<ISeamJavaComponentDeclaration>();
+ Set<ISeamXmlComponentDeclaration> xmlDeclarations = new
HashSet<ISeamXmlComponentDeclaration>();
+ Set<ISeamPropertiesDeclaration> propertyDeclarations = new
HashSet<ISeamPropertiesDeclaration>();
+
public SeamComponent () {
}
- public void setBaseComponent(ISeamComponent base) {
- this.base = base;
- }
-
- public ISeamComponent getBaseComponent() {
- return base;
- }
-
- public Set<String> getPropertyNames() {
- return properties.keySet();
- }
-
- public boolean getBooleanProperty(String propertyName) {
- ISeamProperty o = getProperty(propertyName);
- Object value = o.getValue();
- if(value instanceof Boolean) return ((Boolean)value).booleanValue();
- if(value instanceof String && "true".equals(value));
- return false;
- }
-
- public String getStringProperty(String propertyName) {
- ISeamProperty o = getProperty(propertyName);
- Object value = o.getValue();
- return value == null ? null : value.toString();
- }
-
- public ISeamProperty getProperty(String propertyName) {
- return properties.get(propertyName);
- }
-
- public void addProperty(ISeamProperty property) {
- properties.put(property.getName(), property);
- }
-
- public void setStringProperty(String propertyName, String value) {
- ISeamProperty p = getProperty(propertyName);
- if(p == null) {
- p = new SeamProperty(propertyName, value);
- } else {
- p.setValue(value);
- }
- properties.put(propertyName, p);
- }
-
- public void setSourcePath(IPath path) {
- source = path;
- }
-
/**
- * @see
org.jboss.tools.seam.core.ISeamComponent#addBijectedAttribute(org.jboss.tools.seam.core.IBijectedAttribute)
- */
- public void addBijectedAttribute(IBijectedAttribute attribute) {
- bijectedAttributes.add(attribute);
- }
-
- /**
- * @see
org.jboss.tools.seam.core.ISeamComponent#addFactory(org.jboss.tools.seam.core.ISeamAnnotatedFactory)
- */
- public void addFactory(ISeamAnnotatedFactory factory) {
- annotatedFactories.add(factory);
- }
-
- /**
- * @see
org.jboss.tools.seam.core.ISeamComponent#addMethod(org.jboss.tools.seam.core.ISeamComponentMethod)
- */
- public void addMethod(ISeamComponentMethod method) {
- componentMethods.add(method);
- }
-
- /**
- * @see
org.jboss.tools.seam.core.ISeamComponent#addRole(org.jboss.tools.seam.core.IRole)
- */
- public void addRole(IRole role) {
- roles.add(role);
- }
-
- /**
* @see org.jboss.tools.seam.core.ISeamComponent#getBijectedAttributes()
*/
public Set<IBijectedAttribute> getBijectedAttributes() {
- return base != null ? base.getBijectedAttributes() : bijectedAttributes;
+ ISeamJavaComponentDeclaration javaDeclaration = getJavaDeclaration();
+ return (javaDeclaration == null) ? null : javaDeclaration.getBijectedAttributes();
}
/**
* @see
org.jboss.tools.seam.core.ISeamComponent#getBijectedAttributesByName(java.lang.String)
*/
public Set<IBijectedAttribute> getBijectedAttributesByName(String name) {
- Set<IBijectedAttribute> result = null;
- for(IBijectedAttribute a: getBijectedAttributes()) {
- if(name.equals(a.getName())) {
- if(result == null) result = new HashSet<IBijectedAttribute>();
- result.add(a);
- }
- }
- return result;
+ ISeamJavaComponentDeclaration javaDeclaration = getJavaDeclaration();
+ return (javaDeclaration == null) ? null :
javaDeclaration.getBijectedAttributesByName(name);
}
/**
@@ -156,35 +63,37 @@
*/
public Set<IBijectedAttribute> getBijectedAttributesByType(
BijectedAttributeType type) {
- Set<IBijectedAttribute> result = null;
- for(IBijectedAttribute a: getBijectedAttributes()) {
- if(type.equals(a.getType())) {
- if(result == null) result = new HashSet<IBijectedAttribute>();
- result.add(a);
- }
- }
- return result;
+ ISeamJavaComponentDeclaration javaDeclaration = getJavaDeclaration();
+ return (javaDeclaration == null) ? null :
javaDeclaration.getBijectedAttributesByType(type);
}
/**
* @see org.jboss.tools.seam.core.ISeamComponent#getClassName()
*/
public String getClassName() {
- return className;
+ ISeamJavaComponentDeclaration javaDeclaration = getJavaDeclaration();
+ if(javaDeclaration != null) return javaDeclaration.getClassName();
+ Set<ISeamXmlComponentDeclaration> xml = getXmlDeclarations();
+ for(ISeamXmlComponentDeclaration d: xml) {
+ if(d.getClassName() != null) return d.getClassName();
+ }
+ return null;
}
/**
* @see org.jboss.tools.seam.core.ISeamComponent#getFactories()
*/
public Set<ISeamAnnotatedFactory> getFactories() {
- return base != null ? base.getFactories() : annotatedFactories;
+ ISeamJavaComponentDeclaration javaDeclaration = getJavaDeclaration();
+ return (javaDeclaration == null) ? null : javaDeclaration.getFactories();
}
/**
* @see org.jboss.tools.seam.core.ISeamComponent#getMethods()
*/
public Set<ISeamComponentMethod> getMethods() {
- return base != null ? base.getMethods() : componentMethods;
+ ISeamJavaComponentDeclaration javaDeclaration = getJavaDeclaration();
+ return (javaDeclaration == null) ? null : javaDeclaration.getMethods();
}
/**
@@ -192,93 +101,38 @@
*/
public Set<ISeamComponentMethod> getMethodsByType(
SeamComponentMethodType type) {
- Set<ISeamComponentMethod> result = null;
- for(ISeamComponentMethod a: getMethods()) {
- if(type.equals(a.getType())) {
- if(result == null) result = new HashSet<ISeamComponentMethod>();
- result.add(a);
- }
- }
- return result;
+ ISeamJavaComponentDeclaration javaDeclaration = getJavaDeclaration();
+ return (javaDeclaration == null) ? null : javaDeclaration.getMethodsByType(type);
}
/**
* @see org.jboss.tools.seam.core.ISeamComponent#getRoles()
*/
public Set<IRole> getRoles() {
- return base != null ? base.getRoles() : roles;
+ ISeamJavaComponentDeclaration javaDeclaration = getJavaDeclaration();
+ return (javaDeclaration == null) ? null : javaDeclaration.getRoles();
}
/**
* @see org.jboss.tools.seam.core.ISeamComponent#isEntity()
*/
public boolean isEntity() {
- return entity;
+ ISeamJavaComponentDeclaration javaDeclaration = getJavaDeclaration();
+ return (javaDeclaration != null) && javaDeclaration.isEntity();
}
/**
* @see org.jboss.tools.seam.core.ISeamComponent#isStateful()
*/
public boolean isStateful() {
- return stateful;
+ ISeamJavaComponentDeclaration javaDeclaration = getJavaDeclaration();
+ return (javaDeclaration != null) && javaDeclaration.isStateful();
}
/**
- * @see
org.jboss.tools.seam.core.ISeamComponent#removeBijectedAttribute(org.jboss.tools.seam.core.IBijectedAttribute)
- */
- public void removeBijectedAttribute(IBijectedAttribute attribute) {
- bijectedAttributes.remove(attribute);
- }
-
- /**
- * @see
org.jboss.tools.seam.core.ISeamComponent#removeFactory(org.jboss.tools.seam.core.ISeamAnnotatedFactory)
- */
- public void removeFactory(ISeamAnnotatedFactory factory) {
- annotatedFactories.remove(factory);
- }
-
- /**
- * @see
org.jboss.tools.seam.core.ISeamComponent#removeMethod(org.jboss.tools.seam.core.ISeamComponentMethod)
- */
- public void removeMethod(ISeamComponentMethod method) {
- componentMethods.remove(method);
- }
-
- /**
- * @see
org.jboss.tools.seam.core.ISeamComponent#removeRole(org.jboss.tools.seam.core.IRole)
- */
- public void removeRole(IRole role) {
- roles.remove(role);
- }
-
- /**
- * @see org.jboss.tools.seam.core.ISeamComponent#setClassName(java.lang.String)
- */
- public void setClassName(String className) {
- this.className = className;
- }
-
- /**
- * @see org.jboss.tools.seam.core.ISeamComponent#setEntity(boolean)
- */
- public void setEntity(boolean entity) {
- this.entity = entity;
- }
-
- /**
- * @see org.jboss.tools.seam.core.ISeamComponent#setStateful(boolean)
- */
- public void setStateful(boolean stateful) {
- this.stateful = stateful;
- }
-
- /**
* @see org.jboss.tools.seam.core.ISeamContextVariable#getName()
*/
public String getName() {
- if(name == null && base != null) {
- return base.getName();
- }
return name;
}
@@ -286,10 +140,8 @@
* @see org.jboss.tools.seam.core.ISeamContextVariable#getScope()
*/
public ScopeType getScope() {
- if(scopeType == ScopeType.UNSPECIFIED && base != null) {
- return base.getScope();
- }
- return scopeType;
+ //TODO
+ return null;
}
/**
@@ -303,7 +155,7 @@
* @see
org.jboss.tools.seam.core.ISeamContextVariable#setScope(org.jboss.tools.seam.core.ScopeType)
*/
public void setScope(ScopeType type) {
- this.scopeType = type;
+ //TODO
}
/**
@@ -311,8 +163,10 @@
*/
public List<ISeamProperty> getProperties(String propertyName) {
List<ISeamProperty> list = new ArrayList<ISeamProperty>();
- ISeamProperty p = properties.get(propertyName);
- if(p != null) list.add(p);
+ Collection<ISeamProperty> ps = getProperties();
+ for (ISeamProperty p: ps) {
+ if(propertyName.equals(p.getName())) list.add(p);
+ }
return list;
}
@@ -320,34 +174,33 @@
* @see org.jboss.tools.seam.core.ISeamComponent#getProperties()
*/
public Collection<ISeamProperty> getProperties() {
- return properties.values();
+ Set<ISeamProperty> ps = new HashSet<ISeamProperty>();
+ Set<ISeamXmlComponentDeclaration> xml = getXmlDeclarations();
+ for (ISeamXmlComponentDeclaration d: xml) {
+ ps.addAll(d.getProperties());
+ }
+ Set<ISeamPropertiesDeclaration> pd = getPropertiesDeclarations();
+ for (ISeamPropertiesDeclaration d: pd) {
+ ps.addAll(d.getProperties());
+ }
+ return ps;
}
- /**
- * @see
org.jboss.tools.seam.core.ISeamComponent#removeProperty(org.jboss.tools.seam.core.ISeamProperty)
- */
- public void removeProperty(ISeamProperty property) {
- properties.remove(property.getName());
- }
-
public Set<ISeamComponentDeclaration> getAllDeclarations() {
- // TODO Auto-generated method stub
- return null;
+ return allDeclarations;
}
public ISeamJavaComponentDeclaration getJavaDeclaration() {
- // TODO Auto-generated method stub
- return null;
+ if(javaDeclarations.size() == 0) return null;
+ return javaDeclarations.iterator().next();
}
public Set<ISeamPropertiesDeclaration> getPropertiesDeclarations() {
- // TODO Auto-generated method stub
- return null;
+ return propertyDeclarations;
}
public Set<ISeamXmlComponentDeclaration> getXmlDeclarations() {
- // TODO Auto-generated method stub
- return null;
+ return xmlDeclarations;
}
}
Added:
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
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponentDeclaration.java 2007-07-03
15:23:38 UTC (rev 2258)
@@ -0,0 +1,25 @@
+package org.jboss.tools.seam.internal.core;
+
+import org.eclipse.core.runtime.IPath;
+import org.jboss.tools.seam.core.ISeamComponentDeclaration;
+
+public abstract class SeamComponentDeclaration implements ISeamComponentDeclaration {
+
+ protected IPath source;
+
+ protected String name;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setSourcePath(IPath path) {
+ source = path;
+ }
+
+
+}
Added:
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
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamJavaComponentDeclaration.java 2007-07-03
15:23:38 UTC (rev 2258)
@@ -0,0 +1,131 @@
+package org.jboss.tools.seam.internal.core;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.jboss.tools.seam.core.BijectedAttributeType;
+import org.jboss.tools.seam.core.IBijectedAttribute;
+import org.jboss.tools.seam.core.IRole;
+import org.jboss.tools.seam.core.ISeamAnnotatedFactory;
+import org.jboss.tools.seam.core.ISeamComponentMethod;
+import org.jboss.tools.seam.core.ISeamJavaComponentDeclaration;
+import org.jboss.tools.seam.core.ScopeType;
+import org.jboss.tools.seam.core.SeamComponentMethodType;
+
+public class SeamJavaComponentDeclaration extends SeamComponentDeclaration
+ implements ISeamJavaComponentDeclaration {
+
+ protected String className = null;
+ protected ScopeType scopeType = ScopeType.UNSPECIFIED;
+ protected boolean stateful = false;
+ protected boolean entity = false;
+
+ protected Set<IBijectedAttribute> bijectedAttributes = new
HashSet<IBijectedAttribute>();
+ protected Set<ISeamAnnotatedFactory> annotatedFactories = new
HashSet<ISeamAnnotatedFactory>();
+ protected Set<ISeamComponentMethod> componentMethods = new
HashSet<ISeamComponentMethod>();
+ protected Set<IRole> roles = new HashSet<IRole>();
+
+ public String getClassName() {
+ return className;
+ }
+
+ public void setClassName(String className) {
+ this.className = className;
+ }
+
+ public void addBijectedAttribute(IBijectedAttribute attribute) {
+ bijectedAttributes.add(attribute);
+ }
+
+ public void addFactory(ISeamAnnotatedFactory factory) {
+ annotatedFactories.add(factory);
+ }
+
+ public void addMethod(ISeamComponentMethod method) {
+ componentMethods.add(method);
+ }
+
+ public void addRole(IRole role) {
+ roles.add(role);
+ }
+
+ public Set<IBijectedAttribute> getBijectedAttributes() {
+ return bijectedAttributes;
+ }
+
+ public Set<IBijectedAttribute> getBijectedAttributesByName(String name) {
+ Set<IBijectedAttribute> result = null;
+ for(IBijectedAttribute a: getBijectedAttributes()) {
+ if(name.equals(a.getName())) {
+ if(result == null) result = new HashSet<IBijectedAttribute>();
+ result.add(a);
+ }
+ }
+ return result;
+ }
+
+ public Set<IBijectedAttribute> getBijectedAttributesByType(
+ BijectedAttributeType type) {
+ Set<IBijectedAttribute> result = null;
+ for(IBijectedAttribute a: getBijectedAttributes()) {
+ if(type.equals(a.getType())) {
+ if(result == null) result = new HashSet<IBijectedAttribute>();
+ result.add(a);
+ }
+ }
+ return result;
+ }
+
+ public Set<ISeamAnnotatedFactory> getFactories() {
+ return annotatedFactories;
+ }
+
+ public Set<ISeamComponentMethod> getMethods() {
+ return componentMethods;
+ }
+
+ public Set<ISeamComponentMethod> getMethodsByType(
+ SeamComponentMethodType type) {
+ Set<ISeamComponentMethod> result = null;
+ for(ISeamComponentMethod a: getMethods()) {
+ if(type.equals(a.getType())) {
+ if(result == null) result = new HashSet<ISeamComponentMethod>();
+ result.add(a);
+ }
+ }
+ return result;
+ }
+
+ public Set<IRole> getRoles() {
+ return roles;
+ }
+
+ public boolean isEntity() {
+ return entity;
+ }
+
+ public boolean isStateful() {
+ return stateful;
+ }
+
+ public void removeBijectedAttribute(IBijectedAttribute attribute) {
+ bijectedAttributes.remove(attribute);
+ }
+
+ public void removeFactory(ISeamAnnotatedFactory factory) {
+ annotatedFactories.remove(factory);
+ }
+
+ public void removeMethod(ISeamComponentMethod method) {
+ componentMethods.remove(method);
+ }
+
+ public void removeRole(IRole role) {
+ roles.remove(role);
+ }
+
+ public void setEntity(boolean entity) {
+ this.entity = entity;
+ }
+
+}
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-03
15:22:27 UTC (rev 2257)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java 2007-07-03
15:23:38 UTC (rev 2258)
@@ -18,6 +18,7 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.jboss.tools.seam.core.ISeamComponent;
+import org.jboss.tools.seam.core.ISeamComponentDeclaration;
import org.jboss.tools.seam.core.ISeamProject;
import org.jboss.tools.seam.core.ISeamContextVariable;
import org.jboss.tools.seam.core.ScopeType;
@@ -76,12 +77,15 @@
* @param component
* @param source
*/
- public void registerComponents(SeamComponent[] list, IPath source) {
+ public void registerComponents(SeamComponentDeclaration[] list, IPath source) {
pathRemoved(source);
if(list == null) return;
+ //TODO
for (int i = 0; i < list.length; i++) {
- list[i].setSourcePath(source);
- allComponents.add(list[i]);
+// list[i].setSourcePath(source);
+
+ //TODO !!!
+// allComponents.add(list[i]);
}
}
@@ -92,8 +96,13 @@
public void pathRemoved(IPath source) {
Iterator<SeamComponent> iterator = allComponents.iterator();
while(iterator.hasNext()) {
- SeamComponent c = iterator.next();
- if(c.source != null && source.isPrefixOf(c.source)) {
+ ISeamComponent c = iterator.next();
+ Iterator<ISeamComponentDeclaration> ds = c.getAllDeclarations().iterator();
+ while (ds.hasNext()) {
+ SeamComponentDeclaration di = (SeamComponentDeclaration)ds.next();
+ if(di.source.equals(source)) ds.remove();
+ }
+ if(c.getAllDeclarations().size() == 0) {
iterator.remove();
}
}
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamPropertiesDeclaration.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamPropertiesDeclaration.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamPropertiesDeclaration.java 2007-07-03
15:23:38 UTC (rev 2258)
@@ -0,0 +1,45 @@
+package org.jboss.tools.seam.internal.core;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.tools.seam.core.ISeamPropertiesDeclaration;
+import org.jboss.tools.seam.core.ISeamProperty;
+
+public class SeamPropertiesDeclaration extends SeamComponentDeclaration
+ implements ISeamPropertiesDeclaration {
+
+ protected Map<String,ISeamProperty> properties = new HashMap<String,
ISeamProperty>();
+
+ public void addProperty(ISeamProperty property) {
+ properties.put(property.getName(), property);
+ }
+
+ public List<ISeamProperty> getProperties(String propertyName) {
+ List<ISeamProperty> list = new ArrayList<ISeamProperty>();
+ ISeamProperty p = properties.get(propertyName);
+ if(p != null) list.add(p);
+ return list;
+ }
+
+ public Collection<ISeamProperty> getProperties() {
+ return properties.values();
+ }
+
+ public ISeamProperty getProperty(String propertyName) {
+ return properties.get(propertyName);
+ }
+
+ public void removeProperty(ISeamProperty property) {
+ properties.remove(property.getName());
+ }
+
+ public void addStringProperty(String name, String value) {
+ SeamProperty p = new SeamProperty(name, value);
+ addProperty(p);
+ }
+
+}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProperty.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProperty.java 2007-07-03
15:22:27 UTC (rev 2257)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProperty.java 2007-07-03
15:23:38 UTC (rev 2258)
@@ -30,6 +30,11 @@
this.value = value;
}
+ public SeamProperty(String name, Object value) {
+ this.name = name;
+ this.value = value;
+ }
+
public String getName() {
return name;
}
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamXmlComponentDeclaration.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamXmlComponentDeclaration.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamXmlComponentDeclaration.java 2007-07-03
15:23:38 UTC (rev 2258)
@@ -0,0 +1,77 @@
+package org.jboss.tools.seam.internal.core;
+
+import org.jboss.tools.seam.core.ISeamXmlComponentDeclaration;
+import org.jboss.tools.seam.core.ScopeType;
+
+public class SeamXmlComponentDeclaration extends SeamPropertiesDeclaration
+ implements ISeamXmlComponentDeclaration {
+
+ String autoCreate = null;
+ String className = null;
+ String installed = null;
+ String jndiName = null;
+ String precedence = null;
+ String scope = null;
+
+ public String getAutoCreateAsString() {
+ return autoCreate;
+ }
+
+ public String getClassName() {
+ return className;
+ }
+
+ public boolean getInstalledAsString() {
+ return "true".equals(installed);
+ }
+
+ public String getJndiName() {
+ return jndiName;
+ }
+
+ public String getPrecedence() {
+ return precedence;
+ }
+
+ public ScopeType getScope() {
+ if(scope == null || scope.length() == 0) return ScopeType.UNSPECIFIED;
+ return ScopeType.valueOf(scope);
+ }
+
+ public String getScopeAsString() {
+ return scope;
+ }
+
+ public boolean isAutoCreate() {
+ return "true".equals(autoCreate);
+ }
+
+ public boolean isInstalled() {
+ return "true".equals(installed);
+ }
+
+ public void setClassName(String className) {
+ this.className = className;
+ }
+
+ public void setAutoCreate(String autoCreate) {
+ this.autoCreate = autoCreate;
+ }
+
+ public void setInstalled(String installed) {
+ this.installed = installed;
+ }
+
+ public void setJndiName(String jndiName) {
+ this.jndiName = jndiName;
+ }
+
+ public void setPrecedence(String precedence) {
+ this.precedence = precedence;
+ }
+
+ public void setScope(String scope) {
+ this.scope = scope;
+ }
+
+}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/IFileScanner.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/IFileScanner.java 2007-07-03
15:22:27 UTC (rev 2257)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/IFileScanner.java 2007-07-03
15:23:38 UTC (rev 2258)
@@ -12,6 +12,7 @@
import org.eclipse.core.resources.IFile;
import org.jboss.tools.seam.internal.core.SeamComponent;
+import org.jboss.tools.seam.internal.core.SeamComponentDeclaration;
public interface IFileScanner {
@@ -37,6 +38,6 @@
* @return
* @throws Exception
*/
- public SeamComponent[] parse(IFile f) throws Exception;
+ public SeamComponentDeclaration[] parse(IFile f) throws Exception;
}
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-03
15:22:27 UTC (rev 2257)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/JavaScanner.java 2007-07-03
15:23:38 UTC (rev 2258)
@@ -26,7 +26,8 @@
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
import org.jboss.tools.common.util.FileUtil;
-import org.jboss.tools.seam.internal.core.SeamComponent;
+import org.jboss.tools.seam.internal.core.SeamComponentDeclaration;
+import org.jboss.tools.seam.internal.core.SeamJavaComponentDeclaration;
import org.jboss.tools.seam.internal.core.scanner.IFileScanner;
public class JavaScanner implements IFileScanner {
@@ -67,14 +68,14 @@
* @return
* @throws Exception
*/
- public SeamComponent[] parse(IFile f) throws Exception {
+ public SeamComponentDeclaration[] parse(IFile f) throws Exception {
ICompilationUnit u = getCompilationUnit(f);
if(u == null) return null;
ASTRequestorImpl requestor = new ASTRequestorImpl();
ICompilationUnit[] us = new ICompilationUnit[]{u};
ASTParser.newParser(AST.JLS3).createASTs(us, new String[0], requestor, null);
- SeamComponent component = requestor.getComponent();
- return component == null ? new SeamComponent[0] : new SeamComponent[]{component};
+ SeamComponentDeclaration component = requestor.getComponent();
+ return component == null ? new SeamComponentDeclaration[0] : new
SeamComponentDeclaration[]{component};
}
private ICompilationUnit getCompilationUnit(IFile f) throws Exception {
@@ -96,9 +97,9 @@
class ASTRequestorImpl extends ASTRequestor {
private ASTVisitorImpl visitor = new ASTVisitorImpl();
- private SeamComponent component = null;
+ private SeamJavaComponentDeclaration component = null;
- public SeamComponent getComponent() {
+ public SeamComponentDeclaration getComponent() {
return component;
}
@@ -117,7 +118,7 @@
if(visitor.name != null && visitor.type != null) {
String n = visitor.type.getElementName();
n = getResolvedType(visitor.type, n);
- component = new SeamComponent();
+ component = new SeamJavaComponentDeclaration();
component.setClassName(n);
component.setName(visitor.name);
if(visitor.scope != null) {
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-03
15:22:27 UTC (rev 2257)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/lib/LibraryScanner.java 2007-07-03
15:23:38 UTC (rev 2258)
@@ -17,6 +17,7 @@
import org.jboss.tools.common.model.filesystems.impl.FileSystemsImpl;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
import org.jboss.tools.seam.internal.core.SeamComponent;
+import org.jboss.tools.seam.internal.core.SeamComponentDeclaration;
import org.jboss.tools.seam.internal.core.scanner.IFileScanner;
import org.jboss.tools.seam.internal.core.scanner.xml.XMLScanner;
@@ -40,7 +41,7 @@
return false;
}
- public SeamComponent[] parse(IFile f) throws Exception {
+ public SeamComponentDeclaration[] parse(IFile f) throws Exception {
XModelObject o = EclipseResourceUtil.getObjectByResource(f);
if(o == null) return null;
if(!o.getModelEntity().getName().equals("FileSystemJar")) {
@@ -52,12 +53,12 @@
XModelObject componentsXML = o.getChildByPath("META-INF/components.xml");
if(componentsXML == null && seamProperties == null) return null;
- ArrayList<SeamComponent> list = new ArrayList<SeamComponent>();
+ ArrayList<SeamComponentDeclaration> list = new
ArrayList<SeamComponentDeclaration>();
processJavaClasses(o, list);
if(componentsXML != null) {
- SeamComponent[] components = new XMLScanner().parse(componentsXML);
+ SeamComponentDeclaration[] components = new XMLScanner().parse(componentsXML);
if(components != null) {
for (int i = 0; i < components.length; i++) list.add(components[i]);
}
@@ -72,10 +73,10 @@
//TODO add components to list
}
- return list.toArray(new SeamComponent[0]);
+ return list.toArray(new SeamComponentDeclaration[0]);
}
- protected void processJavaClasses(XModelObject o, ArrayList<SeamComponent> list)
{
+ protected void processJavaClasses(XModelObject o,
ArrayList<SeamComponentDeclaration> list) {
//TODO
}
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-03
15:22:27 UTC (rev 2257)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/XMLScanner.java 2007-07-03
15:23:38 UTC (rev 2258)
@@ -22,7 +22,11 @@
import org.jboss.tools.common.meta.XModelEntity;
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
+import org.jboss.tools.seam.core.ISeamXmlComponentDeclaration;
import org.jboss.tools.seam.internal.core.SeamComponent;
+import org.jboss.tools.seam.internal.core.SeamComponentDeclaration;
+import org.jboss.tools.seam.internal.core.SeamProperty;
+import org.jboss.tools.seam.internal.core.SeamXmlComponentDeclaration;
import org.jboss.tools.seam.internal.core.scanner.IFileScanner;
public class XMLScanner implements IFileScanner {
@@ -63,7 +67,7 @@
* @return
* @throws Exception
*/
- public SeamComponent[] parse(IFile f) throws Exception {
+ public SeamComponentDeclaration[] parse(IFile f) throws Exception {
XModelObject o = EclipseResourceUtil.getObjectByResource(f);
return parse(o);
}
@@ -81,23 +85,22 @@
// COMMON_ATTRIBUTES.add(ISeamComponent.JNDI_NAME);
}
- public SeamComponent[] parse(XModelObject o) {
+ public SeamComponentDeclaration[] parse(XModelObject o) {
if(o == null) return null;
- ArrayList<SeamComponent> list = new ArrayList<SeamComponent>();
+ ArrayList<SeamComponentDeclaration> list = new
ArrayList<SeamComponentDeclaration>();
XModelObject[] os = o.getChildren();
for (int i = 0; i < os.length; i++) {
XModelEntity componentEntity = os[i].getModelEntity();
if(componentEntity.getAttribute("class") != null) {
- //This is a component model object
- SeamComponent component = new SeamComponent();
+ SeamXmlComponentDeclaration component = new SeamXmlComponentDeclaration();
//TODO
-// component.setName(os[i].getAttributeValue(ISeamComponent.NAME));
-// component.setClassName(os[i].getAttributeValue(ISeamComponent.CLASS));
-// component.setScope(os[i].getAttributeValue(ISeamComponent.SCOPE));
-// component.setPrecedence(os[i].getAttributeValue(ISeamComponent.PRECEDENCE));
-// component.setInstalled(os[i].getAttributeValue(ISeamComponent.INSTALLED));
-// component.setAutoCreate(os[i].getAttributeValue(ISeamComponent.AUTO_CREATE));
-// component.setJndiName(os[i].getAttributeValue(ISeamComponent.JNDI_NAME));
+ component.setName(os[i].getAttributeValue(ISeamXmlComponentDeclaration.NAME));
+ component.setClassName(os[i].getAttributeValue(ISeamXmlComponentDeclaration.CLASS));
+ component.setScope(os[i].getAttributeValue(ISeamXmlComponentDeclaration.SCOPE));
+ component.setPrecedence(os[i].getAttributeValue(ISeamXmlComponentDeclaration.PRECEDENCE));
+ component.setInstalled(os[i].getAttributeValue(ISeamXmlComponentDeclaration.INSTALLED));
+ component.setAutoCreate(os[i].getAttributeValue(ISeamXmlComponentDeclaration.AUTO_CREATE));
+ component.setJndiName(os[i].getAttributeValue(ISeamXmlComponentDeclaration.JNDI_NAME));
XAttribute[] attributes = componentEntity.getAttributes();
for (int ia = 0; ia < attributes.length; ia++) {
@@ -106,7 +109,7 @@
if(xml == null) continue;
if(COMMON_ATTRIBUTES.contains(xml)) continue;
String stringValue = os[i].getAttributeValue(a.getName());
- component.setStringProperty(xml, stringValue);
+ component.addStringProperty(xml, stringValue);
}
XModelObject[] properties = os[i].getChildren();
@@ -116,7 +119,7 @@
if(entity.getAttribute("value") != null) {
//this is simple value;
String value = properties[j].getAttributeValue("value");
- component.setStringProperty(propertyName, value);
+ component.addStringProperty(propertyName, value);
} else {
XModelObject[] entries = properties[j].getChildren();
if(entity.getChild("SeamListEntry") != null
@@ -126,7 +129,7 @@
for (int k = 0; k < entries.length; k++) {
listValues.add(entries[k].getAttributeValue("value"));
}
-// component.addProperty(new SeamProperty<List<String>>(propertyName,
listValues));
+ component.addProperty(new SeamProperty(propertyName, listValues));
} else {
//this is map value
Map<String,String> mapValues = new HashMap<String, String>();
@@ -135,7 +138,7 @@
String entryValue = entries[k].getAttributeValue("value");
mapValues.put(entryKey, entryValue);
}
-// component.addProperty(new
SeamProperty<Map<String,String>>(propertyName, mapValues));
+ component.addProperty(new SeamProperty(propertyName, mapValues));
}
}
//TODO assign positioning attributes to created ISeamProperty object
@@ -150,12 +153,12 @@
// component.setScope(os[i].getAttributeValue(ISeamComponent.SCOPE));
String value = os[i].getAttributeValue("value");
//TODO how should we resolve value?
- if(value != null) component.setStringProperty("value", value);
+// if(value != null) component.addStringProperty("value", value);
- list.add(component);
+// list.add(component);
}
}
- return list.toArray(new SeamComponent[0]);
+ return list.toArray(new SeamComponentDeclaration[0]);
}
}
\ No newline at end of file