Author: scabanovich
Date: 2011-07-27 17:31:08 -0400 (Wed, 27 Jul 2011)
New Revision: 33276
Added:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/BuiltInBeanFactory.java
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDIConstants.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/el/CdiElResolver.java
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java
Log:
JBIDE-9401
https://issues.jboss.org/browse/JBIDE-9401
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDIConstants.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDIConstants.java 2011-07-27
21:25:36 UTC (rev 33275)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/core/CDIConstants.java 2011-07-27
21:31:08 UTC (rev 33276)
@@ -51,6 +51,9 @@
public String SESSION_SCOPED_ANNOTATION_TYPE_NAME =
"javax.enterprise.context.SessionScoped";
public String DEPENDENT_ANNOTATION_TYPE_NAME =
"javax.enterprise.context.Dependent";
+ public String CONVERSATION_TYPE_NAME =
"javax.enterprise.context.Conversation";
+ public String CONVERSATION_BEAN_NAME = CONVERSATION_TYPE_NAME.toLowerCase();
+
public String SPECIALIZES_ANNOTATION_TYPE_NAME =
"javax.enterprise.inject.Specializes";
public String NON_BINDING_ANNOTATION_TYPE_NAME
="javax.enterprise.util.Nonbinding";
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/el/CdiElResolver.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/el/CdiElResolver.java 2011-07-27
21:25:36 UTC (rev 33275)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/el/CdiElResolver.java 2011-07-27
21:31:08 UTC (rev 33276)
@@ -71,6 +71,8 @@
} else if(bean instanceof IBeanMember) {
IBeanMember beanMember = (IBeanMember)bean;
member = beanMember.getSourceMember();
+ } else {
+ member = bean.getBeanClass();
}
return TypeInfoCollector.createMemberInfo(member);
}
Added:
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
(rev 0)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/BuiltInBeanFactory.java 2011-07-27
21:31:08 UTC (rev 33276)
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * 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.internal.core.impl;
+
+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.IScope;
+import org.jboss.tools.common.java.IParametedType;
+
+/**
+ *
+ * @author Viacheslav Kabanovich
+ *
+ */
+public class BuiltInBeanFactory {
+
+ static Set<String> BUILT_IN = new HashSet<String>();
+ static {
+ BUILT_IN.add(CDIConstants.USER_TRANSACTION_TYPE_NAME);
+ BUILT_IN.add(CDIConstants.PRINCIPAL_TYPE_NAME);
+ BUILT_IN.add(CDIConstants.VALIDATION_FACTORY_TYPE_NAME);
+ BUILT_IN.add(CDIConstants.VALIDATOR_TYPE_NAME);
+ BUILT_IN.add(CDIConstants.BEAN_MANAGER_TYPE_NAME);
+ BUILT_IN.add(CDIConstants.CONVERSATION_TYPE_NAME);
+ }
+
+ public static boolean isBuiltIn(IType type) {
+ 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);
+ } else {
+ result = new BuiltInBean(type);
+ }
+ result.setParent(project);
+ result.setSourcePath(contextPath);
+ return result;
+ }
+
+ static class ConversationBuiltInBean extends BuiltInBean {
+ ConversationBuiltInBean(IParametedType type) {
+ super(type);
+ }
+
+ public String getName() {
+ return "javax.enterprise.context.conversation";
+ }
+
+ public IScope getScope() {
+ return getCDIProject().getScope(CDIConstants.REQUEST_SCOPED_ANNOTATION_TYPE_NAME);
+ }
+
+ }
+
+}
Property changes on:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/BuiltInBeanFactory.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
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-27
21:25:36 UTC (rev 33275)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java 2011-07-27
21:31:08 UTC (rev 33276)
@@ -341,13 +341,11 @@
}
}
- if(isBuiltIn(type.getType())) {
+ if(BuiltInBeanFactory.isBuiltIn(type.getType())) {
Set<IBean> rslt = null;
rslt = getBeans(attemptToResolveAmbiguousDependency, type, qs.toArray(new
IQualifierDeclaration[0]));
if(rslt.isEmpty()) {
- BuiltInBean builtInBean = new BuiltInBean(type);
- builtInBean.setParent(this);
- builtInBean.setSourcePath(injectionPoint.getSourcePath());
+ IBean builtInBean = BuiltInBeanFactory.newBean(this, type,
injectionPoint.getSourcePath());
result.add(builtInBean);
} else {
result = rslt;
@@ -400,18 +398,6 @@
return getResolvedBeans(result, attemptToResolveAmbiguousDependency);
}
- static Set<String> BUILT_IN = new HashSet<String>();
- static {
- BUILT_IN.add(CDIConstants.USER_TRANSACTION_TYPE_NAME);
- BUILT_IN.add(CDIConstants.PRINCIPAL_TYPE_NAME);
- BUILT_IN.add(CDIConstants.VALIDATION_FACTORY_TYPE_NAME);
- BUILT_IN.add(CDIConstants.VALIDATOR_TYPE_NAME);
- BUILT_IN.add(CDIConstants.BEAN_MANAGER_TYPE_NAME);
- }
- static boolean isBuiltIn(IType type) {
- return type != null && BUILT_IN.contains(type.getFullyQualifiedName());
- }
-
public static boolean containsType(Set<IParametedType> types, IParametedType type)
{
if(type == null) {
return false;
@@ -1187,13 +1173,26 @@
}
buildInjectionPoinsByType();
-
-// System.out.println("Project=" + getNature().getProject());
-// System.out.println("Qualifiers=" + qualifiers.size());
-// System.out.println("Stereotypes=" + stereotypes.size());
-// System.out.println("Scopes=" + scopes.size());
-// System.out.println("Named beans=" + beansByName.size());
-// System.out.println("Bean paths=" + beansByPath.size());
+
+ //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) {