Author: scabanovich
Date: 2011-07-28 18:14:14 -0400 (Thu, 28 Jul 2011)
New Revision: 33326
Added:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IBuiltInBean.java
Removed:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/BuiltInBean.java
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/BuiltInBeanFactory.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/scanner/lib/ClassPathMonitor.java
Log:
JBIDE-9401
https://issues.jboss.org/browse/JBIDE-9401
Added:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IBuiltInBean.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IBuiltInBean.java
(rev 0)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IBuiltInBean.java 2011-07-28
22:14:14 UTC (rev 33326)
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.cdi.core;
+
+/**
+ * 3.6. Additional built-in beans.
+ * A Java EE or embeddable EJB container must provide the following built-in beans, all
of which
+ * have qualifier @Default, scope @ Dependent, and have no bean EL name:
+ * UserTransaction, Principal, VlidationFactory, Validator, BeanManager.
+ *
+ * 6.7.5. The Conversation interface
+ * The container provides a built-in bean with bean type Conversation, scope
@RequestScoped, and qualifier @Default,
+ * named javax.enterprise.context.conversation.
+ *
+ * @author Viacheslav Kabanovich
+ *
+ */
+public interface IBuiltInBean {
+
+}
Property changes on:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/IBuiltInBean.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Deleted:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/BuiltInBean.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/BuiltInBean.java 2011-07-28
21:07:02 UTC (rev 33325)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/BuiltInBean.java 2011-07-28
22:14:14 UTC (rev 33326)
@@ -1,166 +0,0 @@
-package org.jboss.tools.cdi.internal.core.impl;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.jdt.core.IType;
-import org.jboss.tools.cdi.core.CDIConstants;
-import org.jboss.tools.cdi.core.IBean;
-import org.jboss.tools.cdi.core.IInjectionPoint;
-import org.jboss.tools.cdi.core.IQualifier;
-import org.jboss.tools.cdi.core.IQualifierDeclaration;
-import org.jboss.tools.cdi.core.IScope;
-import org.jboss.tools.cdi.core.IScopeDeclaration;
-import org.jboss.tools.cdi.core.IStereotypeDeclaration;
-import org.jboss.tools.common.java.IAnnotationDeclaration;
-import org.jboss.tools.common.java.IParametedType;
-import org.jboss.tools.common.java.ITypeDeclaration;
-import org.jboss.tools.common.text.ITextSourceReference;
-
-/**
- * 3.6. Additional built-in beans.
-
- * scope @ Dependent,
- * no bean EL name
- *
- * @author Viacheslav Kabanovich
- *
- */
-public class BuiltInBean extends CDIElement implements IBean {
- protected IParametedType type;
- protected Set<IQualifier> qualifiers = null;
-
- public BuiltInBean(IParametedType type) {
- this.type = type;
- }
-
- public IScope getScope() {
- return getCDIProject().getScope(CDIConstants.DEPENDENT_ANNOTATION_TYPE_NAME);
- }
-
- public Set<IScopeDeclaration> getScopeDeclarations() {
- return new HashSet<IScopeDeclaration>();
- }
-
- public Set<IStereotypeDeclaration> getStereotypeDeclarations() {
- return new HashSet<IStereotypeDeclaration>();
- }
-
- public List<IAnnotationDeclaration> getAnnotations() {
- return new ArrayList<IAnnotationDeclaration>();
- }
-
- public IAnnotationDeclaration getAnnotation(String annotationTypeName) {
- return null;
- }
-
- public ITextSourceReference getAnnotationPosition(String annotationTypeName) {
- return null;
- }
-
- public boolean isAnnotationPresent(String annotationTypeName) {
- return false;
- }
-
- public IType getBeanClass() {
- return type.getType();
- }
-
- public String getName() {
- return null;
- }
-
- public ITextSourceReference getNameLocation() {
- return null;
- }
-
- public Set<IParametedType> getLegalTypes() {
- return getAllTypes();
- }
-
- public Set<IParametedType> getAllTypes() {
- Set<IParametedType> result = new HashSet<IParametedType>();
- result.add(type);
- return result;
- }
-
- public Set<ITypeDeclaration> getAllTypeDeclarations() {
- return new HashSet<ITypeDeclaration>();
- }
-
- public Set<ITypeDeclaration> getRestrictedTypeDeclaratios() {
- return new HashSet<ITypeDeclaration>();
- }
-
- public Set<IQualifierDeclaration> getQualifierDeclarations() {
- return new HashSet<IQualifierDeclaration>();
- }
-
- public Set<IQualifierDeclaration> getQualifierDeclarations(boolean
includeInherited) {
- return new HashSet<IQualifierDeclaration>();
- }
-
- public Set<IQualifier> getQualifiers() {
- if(qualifiers == null) {
- computeQualifiers();
- }
- return qualifiers;
- }
-
- protected void computeQualifiers() {
- qualifiers = new HashSet<IQualifier>();
- }
-
- public boolean isAlternative() {
- return false;
- }
-
- public boolean isSelectedAlternative() {
- return false;
- }
-
- public IAnnotationDeclaration getAlternativeDeclaration() {
- return null;
- }
-
- public Set<IInjectionPoint> getInjectionPoints() {
- return new HashSet<IInjectionPoint>();
- }
-
- public IBean getSpecializedBean() {
- return null;
- }
-
- public IAnnotationDeclaration getSpecializesAnnotationDeclaration() {
- return null;
- }
-
- public boolean isSpecializing() {
- return false;
- }
-
- public boolean isDependent() {
- return true;
- }
-
- public boolean isEnabled() {
- return true;
- }
-
- public boolean isNullable() {
- return false;
- }
-
- /*
- * (non-Javadoc)
- * @see org.jboss.tools.cdi.core.IBean#getSimpleJavaName()
- */
- public String getSimpleJavaName() {
- if(type!=null) {
- return type.getSimpleName();
- }
- return "";
- }
-}
\ No newline at end of file
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/BuiltInBeanFactory.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/BuiltInBeanFactory.java 2011-07-28
21:07:02 UTC (rev 33325)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/BuiltInBeanFactory.java 2011-07-28
22:14:14 UTC (rev 33326)
@@ -13,21 +13,29 @@
import java.util.HashSet;
import java.util.Set;
-import org.eclipse.core.runtime.IPath;
import org.eclipse.jdt.core.IType;
import org.jboss.tools.cdi.core.CDIConstants;
-import org.jboss.tools.cdi.core.IBean;
+import org.jboss.tools.cdi.core.IBuiltInBean;
import org.jboss.tools.cdi.core.IScope;
-import org.jboss.tools.common.java.IParametedType;
+import org.jboss.tools.cdi.internal.core.impl.definition.TypeDefinition;
/**
+ * 3.6. Additional built-in beans.
+ * A Java EE or embeddable EJB container must provide the following built-in beans, all
of which
+ * have qualifier @Default, scope @ Dependent, and have no bean EL name:
+ * UserTransaction, Principal, VlidationFactory, Validator, BeanManager.
*
+ * 6.7.5. The Conversation interface
+ * The container provides a built-in bean with bean type Conversation, scope
@RequestScoped, and qualifier @Default,
+ * named javax.enterprise.context.conversation.
+ *
* @author Viacheslav Kabanovich
*
*/
public class BuiltInBeanFactory {
- static Set<String> BUILT_IN = new HashSet<String>();
+ public static final Set<String> BUILT_IN = new HashSet<String>();
+
static {
BUILT_IN.add(CDIConstants.USER_TRANSACTION_TYPE_NAME);
BUILT_IN.add(CDIConstants.PRINCIPAL_TYPE_NAME);
@@ -41,31 +49,44 @@
return type != null && BUILT_IN.contains(type.getFullyQualifiedName());
}
- public static IBean newBean(CDIProject project, IParametedType type, IPath contextPath)
{
- BuiltInBean result = null;
- if(type.getType().getFullyQualifiedName().equals(CDIConstants.CONVERSATION_TYPE_NAME))
{
- result = new ConversationBuiltInBean(type);
+ public static ClassBean newClassBean(CDIProject project, TypeDefinition def) {
+ ClassBean result = null;
+ if(def.getType().getFullyQualifiedName().equals(CDIConstants.CONVERSATION_TYPE_NAME))
{
+ result = new ConversationBuiltInBean();
} else {
- result = new BuiltInBean(type);
+ result = new BuiltInBean();
}
result.setParent(project);
- result.setSourcePath(contextPath);
+ result.setDefinition(def);
return result;
}
- static class ConversationBuiltInBean extends BuiltInBean {
- ConversationBuiltInBean(IParametedType type) {
- super(type);
- }
+}
- public String getName() {
- return "javax.enterprise.context.conversation";
- }
+class ConversationBuiltInBean extends ClassBean implements IBuiltInBean {
+ ConversationBuiltInBean() {
+ }
- public IScope getScope() {
- return getCDIProject().getScope(CDIConstants.REQUEST_SCOPED_ANNOTATION_TYPE_NAME);
- }
+ public String getName() {
+ return "javax.enterprise.context.conversation";
+ }
+ public IScope getScope() {
+ return getCDIProject().getScope(CDIConstants.REQUEST_SCOPED_ANNOTATION_TYPE_NAME);
}
}
+
+class BuiltInBean extends ClassBean implements IBuiltInBean {
+
+ public BuiltInBean() {
+ }
+
+ public IScope getScope() {
+ return getCDIProject().getScope(CDIConstants.DEPENDENT_ANNOTATION_TYPE_NAME);
+ }
+
+ public String getName() {
+ return null;
+ }
+}
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 2011-07-28
21:07:02 UTC (rev 33325)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java 2011-07-28
22:14:14 UTC (rev 33326)
@@ -40,6 +40,7 @@
import org.jboss.tools.cdi.core.IBean;
import org.jboss.tools.cdi.core.IBeanMember;
import org.jboss.tools.cdi.core.IBeanMethod;
+import org.jboss.tools.cdi.core.IBuiltInBean;
import org.jboss.tools.cdi.core.ICDIAnnotation;
import org.jboss.tools.cdi.core.ICDIProject;
import org.jboss.tools.cdi.core.IClassBean;
@@ -210,6 +211,15 @@
}
public Set<IBean> getResolvedBeans(Set<IBean> result, boolean
attemptToResolveAmbiguousness) {
+ if(result.size() > 1) {
+ Iterator<IBean> it = result.iterator();
+ while(it.hasNext()) {
+ IBean b = it.next();
+ if(b instanceof IBuiltInBean) {
+ it.remove();
+ }
+ }
+ }
if(result.size() < 1 || !attemptToResolveAmbiguousness) {
return result;
}
@@ -341,18 +351,6 @@
}
}
- if(BuiltInBeanFactory.isBuiltIn(type.getType())) {
- Set<IBean> rslt = null;
- rslt = getBeans(attemptToResolveAmbiguousDependency, type, qs.toArray(new
IQualifierDeclaration[0]));
- if(rslt.isEmpty()) {
- IBean builtInBean = BuiltInBeanFactory.newBean(this, type,
injectionPoint.getSourcePath());
- result.add(builtInBean);
- } else {
- result = rslt;
- }
- return result;
- }
-
Set<IBean> beans = new HashSet<IBean>();
synchronized(allBeans) {
beans.addAll(allBeans);
@@ -360,7 +358,7 @@
boolean delegateInjectionPoint = injectionPoint.isDelegate();
for (IBean b: beans) {
- if(b instanceof ClassBean) {
+ if(b instanceof ClassBean && !(b instanceof IBuiltInBean)) {
IType bType = b.getBeanClass();
try {
if(bType != null && Flags.isAbstract(bType.getFlags())) {
@@ -1135,6 +1133,17 @@
}
}
+ for (String builtin: BuiltInBeanFactory.BUILT_IN) {
+ IType type = n.getType(builtin);
+ if(type != null && !newClassBeans.containsKey(type)) {
+ TypeDefinition t = new TypeDefinition();
+ t.setType(type, n.getDefinitions(), TypeDefinition.FLAG_NO_ANNOTATIONS);
+ ClassBean bean = BuiltInBeanFactory.newClassBean(this, t);
+ newClassBeans.put(t.getType(), bean);
+ beans.add(bean);
+ }
+ }
+
for (IClassBean bean: newClassBeans.values()) {
IParametedType s = ((ClassBean)bean).getSuperType();
if(s != null && s.getType() != null) {
@@ -1174,25 +1183,6 @@
buildInjectionPoinsByType();
- //Provide built-in bean Conversation
- if(!beansByName.containsKey(CDIConstants.CONVERSATION_BEAN_NAME)) {
- IType type = n.getType(CDIConstants.CONVERSATION_TYPE_NAME);
- if(type != null) {
- TypeDefinition t = new TypeDefinition();
- t.setType(type, n.getDefinitions(), TypeDefinition.FLAG_NO_ANNOTATIONS);
- ClassBean bean = new ClassBean() {
- public String getName() {
- return "javax.enterprise.context.conversation";
- }
- public IScope getScope() {
- return getCDIProject().getScope(CDIConstants.REQUEST_SCOPED_ANNOTATION_TYPE_NAME);
- }
- };
- bean.setParent(this);
- bean.setDefinition(t);
- addBean(bean);
- }
- }
}
public void addBean(IBean bean) {
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/scanner/lib/ClassPathMonitor.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/scanner/lib/ClassPathMonitor.java 2011-07-28
21:07:02 UTC (rev 33325)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/scanner/lib/ClassPathMonitor.java 2011-07-28
22:14:14 UTC (rev 33326)
@@ -12,11 +12,8 @@
import java.io.File;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
-import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
@@ -27,7 +24,6 @@
import org.eclipse.core.runtime.Path;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaCore;
import org.jboss.tools.cdi.core.CDICoreNature;
import org.jboss.tools.cdi.core.CDICorePlugin;
import org.jboss.tools.common.model.XModelObject;
@@ -74,7 +70,7 @@
newJars.getFileSystems().put(p, o);
XModelObject b = o.getChildByPath("META-INF/beans.xml");
- if(b == null && !isWeldJar(fileName)) {
+ if(b == null) {
continue;
}
newJars.getBeanModules().put(p, b);
@@ -93,14 +89,6 @@
}
}
- private boolean isWeldJar(String fileName) {
- if(!fileName.startsWith("weld-") &&
fileName.indexOf("-weld") < 0) return false;
- if(fileName.startsWith("weld-extensions")) return false;
- if(fileName.indexOf("-javadoc") > 0) return false;
- if(fileName.indexOf("-sources") > 0) return false;
- return true;
- }
-
public IProject getProjectResource() {
return project.getProject();
}