Author: scabanovich
Date: 2011-05-18 20:46:30 -0400 (Wed, 18 May 2011)
New Revision: 31364
Added:
trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/src/org/jboss/tools/cdi/seam/solder/core/definition/
trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/src/org/jboss/tools/cdi/seam/solder/core/definition/InterfaceDefinition.java
trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/src/org/jboss/tools/cdi/seam/solder/core/generic/
trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/src/org/jboss/tools/cdi/seam/solder/core/generic/CDISeamSolderGenericBeanExtension.java
trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/src/org/jboss/tools/cdi/seam/solder/core/generic/GenericBeanDefinitionContext.java
trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/src/org/jboss/tools/cdi/seam/solder/core/generic/GenericConfiguration.java
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/plugin.xml
trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/src/org/jboss/tools/cdi/seam/solder/core/CDISeamSolderConstants.java
trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/src/org/jboss/tools/cdi/seam/solder/core/CDISeamSolderCoreExtension.java
trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/src/org/jboss/tools/cdi/seam/solder/core/CDISeamSolderLoggerExtension.java
trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/src/org/jboss/tools/cdi/seam/solder/core/CDISeamSolderServiceHandlerExtension.java
Log:
JBIDE-8674
https://issues.jboss.org/browse/JBIDE-8674
Modified: trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/plugin.xml
===================================================================
--- trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/plugin.xml 2011-05-19 00:45:22
UTC (rev 31363)
+++ trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/plugin.xml 2011-05-19 00:46:30
UTC (rev 31364)
@@ -28,5 +28,10 @@
runtime="org.jboss.seam.solder.unwraps.UnwrapsExtension">
</cdiextension>
+ <cdiextension
+
class="org.jboss.tools.cdi.seam.solder.core.generic.CDISeamSolderGenericBeanExtension"
+
runtime="org.jboss.seam.solder.bean.generic.GenericBeanExtension">
+ </cdiextension>
+
</extension>
</plugin>
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/src/org/jboss/tools/cdi/seam/solder/core/CDISeamSolderConstants.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/src/org/jboss/tools/cdi/seam/solder/core/CDISeamSolderConstants.java 2011-05-19
00:45:22 UTC (rev 31363)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/src/org/jboss/tools/cdi/seam/solder/core/CDISeamSolderConstants.java 2011-05-19
00:46:30 UTC (rev 31364)
@@ -1,3 +1,13 @@
+/*******************************************************************************
+ * 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
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
package org.jboss.tools.cdi.seam.solder.core;
import org.jboss.tools.cdi.core.CDIConstants;
@@ -2,2 +12,7 @@
+/**
+ *
+ * @author Viacheslav Kabanovich
+ *
+ */
public interface CDISeamSolderConstants extends CDIConstants {
@@ -17,4 +32,10 @@
public String DEFAULT_BEAN_ANNOTATION_TYPE_NAME =
"org.jboss.seam.solder.bean.defaultbean.DefaultBean";
public String UNWRAPS_ANNOTATION_TYPE_NAME =
"org.jboss.seam.solder.unwraps.Unwraps";
+
+ public String GENERIC_TYPE_ANNOTATION_TYPE_NAME =
"org.jboss.seam.solder.bean.generic.GenericType";
+ public String GENERIC_ANNOTATION_KIND = "genericAnnotation";
+ public String GENERIC_QUALIFIER_TYPE_NAME =
"org.jboss.seam.solder.bean.generic.Generic";
+ public String GENERIC_CONFIGURATION_ANNOTATION_TYPE_NAME =
"org.jboss.seam.solder.bean.generic.GenericConfiguration";
+
}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/src/org/jboss/tools/cdi/seam/solder/core/CDISeamSolderCoreExtension.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/src/org/jboss/tools/cdi/seam/solder/core/CDISeamSolderCoreExtension.java 2011-05-19
00:45:22 UTC (rev 31363)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/src/org/jboss/tools/cdi/seam/solder/core/CDISeamSolderCoreExtension.java 2011-05-19
00:46:30 UTC (rev 31364)
@@ -85,14 +85,11 @@
// @Requires
private boolean processRequires(TypeDefinition typeDefinition, IRootDefinitionContext
context) {
Set<String> requiredClasses = new HashSet<String>();
- List<String> typeRequiredClasses = getRequiredClasses(typeDefinition);
- if (typeRequiredClasses != null)
- requiredClasses.addAll(typeRequiredClasses);
- List<String> packageRequiredClasses = getRequiredClasses(typeDefinition
- .getPackageDefinition());
- ;
- if (packageRequiredClasses != null)
- requiredClasses.addAll(packageRequiredClasses);
+ requiredClasses.addAll(getRequiredClasses(typeDefinition));
+ PackageDefinition pkg = typeDefinition.getPackageDefinition();
+ if(pkg != null) {
+ requiredClasses.addAll(getRequiredClasses(pkg));
+ }
if (!requiredClasses.isEmpty()) {
for (String c : requiredClasses) {
if (context.getProject().getType(c) == null) {
@@ -161,13 +158,10 @@
}
-
private List<String> getRequiredClasses(IAnnotated d) {
- if (d == null)
- return null;
IAnnotationDeclaration requires = d
.getAnnotation(CDISeamSolderConstants.REQUIRES_ANNOTATION_TYPE_NAME);
- return requires != null ? getArrayValue(requires) : null;
+ return requires != null ? getArrayValue(requires) : new ArrayList<String>();
}
private List<String> getArrayValue(IAnnotationDeclaration d) {
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/src/org/jboss/tools/cdi/seam/solder/core/CDISeamSolderLoggerExtension.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/src/org/jboss/tools/cdi/seam/solder/core/CDISeamSolderLoggerExtension.java 2011-05-19
00:45:22 UTC (rev 31363)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/src/org/jboss/tools/cdi/seam/solder/core/CDISeamSolderLoggerExtension.java 2011-05-19
00:46:30 UTC (rev 31364)
@@ -28,9 +28,9 @@
import org.jboss.tools.cdi.internal.core.impl.AnnotationLiteral;
import org.jboss.tools.cdi.internal.core.impl.CDIProject;
import org.jboss.tools.cdi.internal.core.impl.ClassBean;
-import org.jboss.tools.cdi.internal.core.impl.definition.AbstractMemberDefinition;
import org.jboss.tools.cdi.internal.core.impl.definition.TypeDefinition;
import org.jboss.tools.cdi.internal.core.scanner.FileSet;
+import org.jboss.tools.cdi.seam.solder.core.definition.InterfaceDefinition;
import org.jboss.tools.common.model.XModelObject;
/**
@@ -69,7 +69,7 @@
for (IPath path: is.keySet()) {
Set<IType> ts = is.get(path);
for (IType t: ts) {
- InterfaceDefinition i = new InterfaceDefinition(t);
+ InterfaceDefinition i = new InterfaceDefinition(t, context);
if(i.isAnnotationPresent(CDISeamSolderConstants.MESSAGE_LOGGER_ANNOTATION_TYPE_NAME))
{
TypeDefinition d = new TypeDefinition();
d.setType(t, workingCopy.getRootContext(), 0);
@@ -170,10 +170,4 @@
}
- class InterfaceDefinition extends AbstractMemberDefinition {
- InterfaceDefinition(IType type) {
- setAnnotatable(type, type, context.getRootContext(), 0);
- }
- }
-
}
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/src/org/jboss/tools/cdi/seam/solder/core/CDISeamSolderServiceHandlerExtension.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/src/org/jboss/tools/cdi/seam/solder/core/CDISeamSolderServiceHandlerExtension.java 2011-05-19
00:45:22 UTC (rev 31363)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/src/org/jboss/tools/cdi/seam/solder/core/CDISeamSolderServiceHandlerExtension.java 2011-05-19
00:46:30 UTC (rev 31364)
@@ -28,10 +28,10 @@
import org.jboss.tools.cdi.core.extension.feature.IBuildParticipantFeature;
import org.jboss.tools.cdi.internal.core.impl.CDIProject;
import org.jboss.tools.cdi.internal.core.impl.ClassBean;
-import org.jboss.tools.cdi.internal.core.impl.definition.AbstractMemberDefinition;
import org.jboss.tools.cdi.internal.core.impl.definition.AnnotationDefinition;
import org.jboss.tools.cdi.internal.core.impl.definition.TypeDefinition;
import org.jboss.tools.cdi.internal.core.scanner.FileSet;
+import org.jboss.tools.cdi.seam.solder.core.definition.InterfaceDefinition;
import org.jboss.tools.common.model.XModelObject;
/**
@@ -77,7 +77,7 @@
for (IPath path: is.keySet()) {
Set<IType> ts = is.get(path);
for (IType t: ts) {
- InterfaceDefinition i = new InterfaceDefinition(t);
+ InterfaceDefinition i = new InterfaceDefinition(t, context);
List<IAnnotationDeclaration> as = i.getAnnotations();
for (IAnnotationDeclaration a: as) {
if(workingCopy.isServiceAnnotation(a.getType())) {
@@ -157,10 +157,4 @@
}
- class InterfaceDefinition extends AbstractMemberDefinition {
- InterfaceDefinition(IType type) {
- setAnnotatable(type, type, context.getRootContext(), 0);
- }
- }
-
}
Added:
trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/src/org/jboss/tools/cdi/seam/solder/core/definition/InterfaceDefinition.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/src/org/jboss/tools/cdi/seam/solder/core/definition/InterfaceDefinition.java
(rev 0)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/src/org/jboss/tools/cdi/seam/solder/core/definition/InterfaceDefinition.java 2011-05-19
00:46:30 UTC (rev 31364)
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * 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
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.cdi.seam.solder.core.definition;
+
+import org.eclipse.jdt.core.IType;
+import org.jboss.tools.cdi.core.extension.IDefinitionContextExtension;
+import org.jboss.tools.cdi.internal.core.impl.definition.AbstractMemberDefinition;
+import org.jboss.tools.cdi.internal.core.impl.definition.AbstractTypeDefinition;
+
+/**
+ *
+ * @author Viacheslav Kabanovich
+ *
+ */
+public class InterfaceDefinition extends AbstractTypeDefinition {
+ public InterfaceDefinition(IType type, IDefinitionContextExtension context) {
+ setAnnotatable(type, type, context.getRootContext(), 0);
+ }
+}
Property changes on:
trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/src/org/jboss/tools/cdi/seam/solder/core/definition/InterfaceDefinition.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/src/org/jboss/tools/cdi/seam/solder/core/generic/CDISeamSolderGenericBeanExtension.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/src/org/jboss/tools/cdi/seam/solder/core/generic/CDISeamSolderGenericBeanExtension.java
(rev 0)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/src/org/jboss/tools/cdi/seam/solder/core/generic/CDISeamSolderGenericBeanExtension.java 2011-05-19
00:46:30 UTC (rev 31364)
@@ -0,0 +1,212 @@
+/*******************************************************************************
+ * 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
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.cdi.seam.solder.core.generic;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
+import org.jboss.tools.cdi.core.CDICoreNature;
+import org.jboss.tools.cdi.core.IAnnotationDeclaration;
+import org.jboss.tools.cdi.core.IProducer;
+import org.jboss.tools.cdi.core.IQualifierDeclaration;
+import org.jboss.tools.cdi.core.IRootDefinitionContext;
+import org.jboss.tools.cdi.core.extension.ICDIExtension;
+import org.jboss.tools.cdi.core.extension.IDefinitionContextExtension;
+import org.jboss.tools.cdi.core.extension.feature.IBuildParticipantFeature;
+import org.jboss.tools.cdi.core.extension.feature.IProcessAnnotatedTypeFeature;
+import org.jboss.tools.cdi.internal.core.impl.AnnotationDeclaration;
+import org.jboss.tools.cdi.internal.core.impl.AnnotationLiteral;
+import org.jboss.tools.cdi.internal.core.impl.CDIProject;
+import org.jboss.tools.cdi.internal.core.impl.ClassBean;
+import org.jboss.tools.cdi.internal.core.impl.ParametedType;
+import org.jboss.tools.cdi.internal.core.impl.definition.AbstractMemberDefinition;
+import org.jboss.tools.cdi.internal.core.impl.definition.AnnotationDefinition;
+import org.jboss.tools.cdi.internal.core.impl.definition.FieldDefinition;
+import org.jboss.tools.cdi.internal.core.impl.definition.MethodDefinition;
+import org.jboss.tools.cdi.internal.core.impl.definition.TypeDefinition;
+import org.jboss.tools.cdi.internal.core.scanner.FileSet;
+import org.jboss.tools.cdi.seam.solder.core.CDISeamSolderConstants;
+import org.jboss.tools.cdi.seam.solder.core.CDISeamSolderCorePlugin;
+import org.jboss.tools.common.model.XModelObject;
+
+/**
+ *
+ * @author Viacheslav Kabanovich
+ *
+ */
+public class CDISeamSolderGenericBeanExtension implements ICDIExtension,
IBuildParticipantFeature, IProcessAnnotatedTypeFeature, CDISeamSolderConstants {
+ CDICoreNature project;
+ GenericBeanDefinitionContext context = new GenericBeanDefinitionContext();
+
+ public void setProject(CDICoreNature n) {
+ project = n;
+ }
+
+ public IDefinitionContextExtension getContext() {
+ return context;
+ }
+
+ public void beginVisiting() {
+ }
+
+ public void visitJar(IPath path, IPackageFragmentRoot root, XModelObject beansXML) {
+ }
+
+ public void visit(IFile file, IPath src, IPath webinf) {
+ }
+
+ public void buildDefinitions() {
+ }
+
+ public void buildDefinitions(FileSet fileSet) {
+ }
+
+ public void buildBeans() {
+ CDIProject p = ((CDIProject)project.getDelegate());
+
+ for (GenericConfiguration c: context.getGenericConfigurations().values()) {
+ Map<AbstractMemberDefinition, List<IAnnotationDeclaration>> ms =
c.getGenericProducerBeans();
+
+ //TODO scopes!
+
+ Set<TypeDefinition> ts = c.getGenericConfigurationBeans();
+ for (List<IAnnotationDeclaration> list: ms.values()) {
+ for (TypeDefinition t: ts) {
+ TypeDefinition ti = new TypeDefinition();
+ ti.setType(t.getType(), context.getRootContext(), 0);
+ List<MethodDefinition> ps = ti.getMethods();
+ for (MethodDefinition m: ps) {
+ if(m.isAnnotationPresent(PRODUCES_ANNOTATION_TYPE_NAME)) {
+ for (IAnnotationDeclaration d: list) {
+ m.addAnnotation(((AnnotationDeclaration)d).getDeclaration(),
context.getRootContext());
+ }
+ }
+ }
+ ClassBean cb = new ClassBean();
+ cb.setParent(p);
+ cb.setDefinition(ti);
+ Set<IProducer> producers = cb.getProducers();
+ for (IProducer producer: producers) {
+ p.addBean(producer);
+ }
+ }
+ }
+ }
+ }
+
+ @Override
+ public void processAnnotatedType(TypeDefinition typeDefinition, IRootDefinitionContext
context) {
+ if(typeDefinition.isAnnotationPresent(GENERIC_CONFIGURATION_ANNOTATION_TYPE_NAME)) {
+ IAnnotationDeclaration d =
typeDefinition.getAnnotation(GENERIC_CONFIGURATION_ANNOTATION_TYPE_NAME);
+ Object o = d.getMemberValue(null);
+ if(o != null) {
+ String s = o.toString();
+ if(s.length() > 0) {
+ try {
+ ParametedType p =
context.getProject().getTypeFactory().getParametedType(typeDefinition.getType(),
"Q" + s + ";");
+ if(p != null && p.getType() != null) {
+ GenericConfiguration c =
((GenericBeanDefinitionContext)this.context.getWorkingCopy()).getGenericConfiguration(p.getType().getFullyQualifiedName());
+ c.getGenericConfigurationBeans().add(typeDefinition);
+ }
+ } catch (JavaModelException e) {
+ CDISeamSolderCorePlugin.getDefault().logError(e);
+ }
+ }
+ }
+ List<MethodDefinition> ms = typeDefinition.getMethods();
+ for (MethodDefinition m: ms) {
+ if(m.isAnnotationPresent(PRODUCES_ANNOTATION_TYPE_NAME)) {
+ IType q = project.getType(GENERIC_QUALIFIER_TYPE_NAME);
+ if(q != null) {
+ AnnotationLiteral a = new AnnotationLiteral(m.getResource(), 0, 0, null, 0, q);
+ m.addAnnotation(a, context);
+ }
+ }
+ }
+ } else {
+ IAnnotationDeclaration d = findAnnotationAnnotatedWithGenericType(typeDefinition);
+ if(d != null) {
+ addGenericProducerBean(typeDefinition,
findAnnotationAnnotatedWithGenericType(typeDefinition).getTypeName());
+ }
+ List<MethodDefinition> ms = typeDefinition.getMethods();
+ for (MethodDefinition m: ms) {
+ if(m.isAnnotationPresent(PRODUCES_ANNOTATION_TYPE_NAME)) {
+ d = findAnnotationAnnotatedWithGenericType(m);
+ if(d != null) {
+ addGenericProducerBean(m, d.getTypeName());
+ }
+ }
+ }
+ List<FieldDefinition> fs = typeDefinition.getFields();
+ for (FieldDefinition f: fs) {
+ if(f.isAnnotationPresent(PRODUCES_ANNOTATION_TYPE_NAME)) {
+ d = findAnnotationAnnotatedWithGenericType(f);
+ if(d != null) {
+ addGenericProducerBean(f, d.getTypeName());
+ }
+ }
+ }
+ }
+
+ }
+
+ private void addGenericProducerBean(AbstractMemberDefinition def, String genericType) {
+ GenericConfiguration c =
((GenericBeanDefinitionContext)this.context.getWorkingCopy()).getGenericConfiguration(genericType);
+
+ List<IAnnotationDeclaration> list = new
ArrayList<IAnnotationDeclaration>();
+ List<IAnnotationDeclaration> ds = def.getAnnotations();
+ for (IAnnotationDeclaration d: ds) {
+ if(d instanceof IQualifierDeclaration) {
+ list.add(d);
+ }
+ }
+ c.getGenericProducerBeans().put(def, list);
+ if(c.getGenericProducerBeans().size() == 1) {
+ IType q = project.getType(GENERIC_QUALIFIER_TYPE_NAME);
+ if(q != null) {
+ AnnotationLiteral a = new AnnotationLiteral(def.getResource(), 0, 0, null, 0, q);
+ def.addAnnotation(a, context.getRootContext());
+ }
+ }
+ IResource r = def.getResource();
+ if(r != null && r.exists() &&
!c.getInvolvedTypes().contains(r.getFullPath())) {
+ IPath newPath = r.getFullPath();
+ Set<IPath> ps = c.getInvolvedTypes();
+ for (IPath p: ps) {
+ context.getRootContext().addDependency(p, newPath);
+ context.getRootContext().addDependency(newPath, p);
+ }
+ ps.add(newPath);
+ }
+ }
+
+ private IAnnotationDeclaration
findAnnotationAnnotatedWithGenericType(AbstractMemberDefinition m) {
+ List<IAnnotationDeclaration> ds = m.getAnnotations();
+ for (IAnnotationDeclaration d: ds) {
+ if(d.getTypeName() != null) {
+ AnnotationDefinition a = context.getRootContext().getAnnotation(d.getTypeName());
+ if(a != null && a.isAnnotationPresent(GENERIC_TYPE_ANNOTATION_TYPE_NAME)) {
+ return d;
+ }
+ }
+ }
+ return null;
+ }
+
+}
Property changes on:
trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/src/org/jboss/tools/cdi/seam/solder/core/generic/CDISeamSolderGenericBeanExtension.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/src/org/jboss/tools/cdi/seam/solder/core/generic/GenericBeanDefinitionContext.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/src/org/jboss/tools/cdi/seam/solder/core/generic/GenericBeanDefinitionContext.java
(rev 0)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/src/org/jboss/tools/cdi/seam/solder/core/generic/GenericBeanDefinitionContext.java 2011-05-19
00:46:30 UTC (rev 31364)
@@ -0,0 +1,82 @@
+/*******************************************************************************
+ * 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
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.cdi.seam.solder.core.generic;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.jdt.core.IType;
+import org.jboss.tools.cdi.core.extension.AbstractDefinitionContextExtension;
+import org.jboss.tools.cdi.internal.core.impl.definition.AnnotationDefinition;
+import org.jboss.tools.cdi.seam.solder.core.CDISeamSolderConstants;
+
+/**
+ *
+ * @author Viacheslav Kabanovich
+ *
+ */
+public class GenericBeanDefinitionContext extends AbstractDefinitionContextExtension {
+ Map<String, GenericConfiguration> genericConfiguartions = new HashMap<String,
GenericConfiguration>();
+
+ protected AbstractDefinitionContextExtension copy(boolean clean) {
+ GenericBeanDefinitionContext copy = new GenericBeanDefinitionContext();
+ copy.root = root;
+ if(!clean) {
+ copy.genericConfiguartions.putAll(genericConfiguartions);
+ //
+ }
+ return copy;
+ }
+
+ protected void doApplyWorkingCopy() {
+ genericConfiguartions =
((GenericBeanDefinitionContext)workingCopy).genericConfiguartions;
+ //
+ }
+
+ public void clean() {
+ genericConfiguartions.clear();
+ //
+ }
+
+ public void clean(String typeName) {
+ genericConfiguartions.remove(typeName);
+ for (GenericConfiguration c: genericConfiguartions.values()) {
+ c.clear(typeName);
+ }
+ //
+ }
+
+ public void computeAnnotationKind(AnnotationDefinition annotation) {
+ if(annotation.isAnnotationPresent(CDISeamSolderConstants.GENERIC_TYPE_ANNOTATION_TYPE_NAME))
{
+ annotation.setExtendedKind(CDISeamSolderConstants.GENERIC_ANNOTATION_KIND);
+ String qn = annotation.getType().getFullyQualifiedName();
+ getGenericConfiguration(qn).setGenericTypeDefinition(annotation);
+ }
+ }
+
+ public boolean isGenericTypeAnnotation(IType type) {
+ return (genericConfiguartions.containsKey(type.getFullyQualifiedName()));
+ }
+
+ public Map<String, GenericConfiguration> getGenericConfigurations() {
+ return genericConfiguartions;
+ }
+
+ public GenericConfiguration getGenericConfiguration(String typeName) {
+ GenericConfiguration result = genericConfiguartions.get(typeName);
+ if(result == null) {
+ result = new GenericConfiguration(typeName);
+ genericConfiguartions.put(typeName, result);
+ }
+ return result;
+ }
+
+}
Property changes on:
trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/src/org/jboss/tools/cdi/seam/solder/core/generic/GenericBeanDefinitionContext.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/src/org/jboss/tools/cdi/seam/solder/core/generic/GenericConfiguration.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/src/org/jboss/tools/cdi/seam/solder/core/generic/GenericConfiguration.java
(rev 0)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/src/org/jboss/tools/cdi/seam/solder/core/generic/GenericConfiguration.java 2011-05-19
00:46:30 UTC (rev 31364)
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * 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
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.cdi.seam.solder.core.generic;
+
+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 org.eclipse.core.runtime.IPath;
+import org.jboss.tools.cdi.core.IAnnotationDeclaration;
+import org.jboss.tools.cdi.internal.core.impl.definition.AbstractMemberDefinition;
+import org.jboss.tools.cdi.internal.core.impl.definition.AnnotationDefinition;
+import org.jboss.tools.cdi.internal.core.impl.definition.TypeDefinition;
+
+/**
+ *
+ * @author Viacheslav Kabanovich
+ *
+ */
+public class GenericConfiguration {
+ String genericTypeName;
+ AnnotationDefinition genericType;
+
+ Map<AbstractMemberDefinition, List<IAnnotationDeclaration>>
genericProducerBeans = new HashMap<AbstractMemberDefinition,
List<IAnnotationDeclaration>>();
+ Set<TypeDefinition> genericConfigurationBeans = new
HashSet<TypeDefinition>();
+
+ Set<IPath> involvedResources = new HashSet<IPath>();
+
+ public GenericConfiguration(String genericTypeName) {
+ this.genericTypeName = genericTypeName;
+ }
+
+ public void setGenericTypeDefinition(AnnotationDefinition genericType) {
+ this.genericType = genericType;
+ }
+
+ public void clear(String typeName) {
+ Iterator<AbstractMemberDefinition> it =
genericProducerBeans.keySet().iterator();
+ while(it.hasNext()) {
+ if(typeName.equals(it.next().getTypeDefinition().getQualifiedName())) {
+ it.remove();
+ }
+ }
+ Iterator<TypeDefinition> it2 = genericConfigurationBeans.iterator();
+ while(it2.hasNext()) {
+ if(typeName.equals(it2.next().getTypeDefinition().getQualifiedName())) {
+ it2.remove();
+ }
+ }
+ }
+
+ public Map<AbstractMemberDefinition, List<IAnnotationDeclaration>>
getGenericProducerBeans() {
+ return genericProducerBeans;
+ }
+
+ public String getGenericTypeName() {
+ return genericTypeName;
+ }
+
+ public AnnotationDefinition getGenericTypeDefinition() {
+ return genericType;
+ }
+
+ public Set<TypeDefinition> getGenericConfigurationBeans() {
+ return genericConfigurationBeans;
+ }
+
+ public Set<IPath> getInvolvedTypes() {
+ return involvedResources;
+ }
+
+}
Property changes on:
trunk/cdi/plugins/org.jboss.tools.cdi.seam.solder.core/src/org/jboss/tools/cdi/seam/solder/core/generic/GenericConfiguration.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain