You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cz...@apache.org on 2009/03/31 19:12:42 UTC
svn commit: r760528 [2/2] - in /felix/trunk: scrplugin-annotations/
scrplugin-annotations/src/ scrplugin-annotations/src/main/
scrplugin-annotations/src/main/java/ scrplugin-annotations/src/main/java/org/
scrplugin-annotations/src/main/java/org/apache/...
Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/metatype/AttributeDefinition.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/metatype/AttributeDefinition.java?rev=760528&r1=760527&r2=760528&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/metatype/AttributeDefinition.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/metatype/AttributeDefinition.java Tue Mar 31 17:12:40 2009
@@ -38,7 +38,7 @@
protected Integer cardinality;
- protected Map options;
+ protected Map<String, String> options;
public String getId() {
return this.id;
@@ -108,11 +108,11 @@
this.cardinality = cardinality;
}
- public Map getOptions() {
+ public Map<String, String> getOptions() {
return this.options;
}
- public void setOptions(Map options) {
+ public void setOptions(Map<String, String> options) {
this.options = options;
}
}
Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/metatype/MetaData.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/metatype/MetaData.java?rev=760528&r1=760527&r2=760528&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/metatype/MetaData.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/metatype/MetaData.java Tue Mar 31 17:12:40 2009
@@ -18,14 +18,16 @@
*/
package org.apache.felix.scrplugin.om.metatype;
-import java.util.List;
import java.util.ArrayList;
+import java.util.List;
public class MetaData {
protected String localization;
- protected List descriptors = new ArrayList();
+ protected List<OCD> ocds = new ArrayList<OCD>();
+
+ protected List<Designate> designates = new ArrayList<Designate>();
public String getLocalization() {
return this.localization;
@@ -35,15 +37,19 @@
this.localization = localization;
}
- public List getDescriptors() {
- return this.descriptors;
+ public List<OCD> getOCDs() {
+ return this.ocds;
+ }
+
+ public List<Designate> getDesignates() {
+ return this.designates;
}
public void addOCD(OCD ocd) {
- this.descriptors.add(ocd);
+ this.ocds.add(ocd);
}
public void addDesignate(Designate d) {
- this.descriptors.add(d);
+ this.designates.add(d);
}
}
Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/metatype/OCD.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/metatype/OCD.java?rev=760528&r1=760527&r2=760528&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/metatype/OCD.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/om/metatype/OCD.java Tue Mar 31 17:12:40 2009
@@ -29,7 +29,7 @@
protected String description;
- protected List properties = new ArrayList();
+ protected List<AttributeDefinition> properties = new ArrayList<AttributeDefinition>();
public String getId() {
return this.id;
@@ -55,11 +55,11 @@
this.description = description;
}
- public List getProperties() {
+ public List<AttributeDefinition> getProperties() {
return this.properties;
}
- public void setProperties(List properties) {
+ public void setProperties(List<AttributeDefinition> properties) {
this.properties = properties;
}
}
Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescriptionInheritanceComparator.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescriptionInheritanceComparator.java?rev=760528&r1=760527&r2=760528&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescriptionInheritanceComparator.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescriptionInheritanceComparator.java Tue Mar 31 17:12:40 2009
@@ -37,14 +37,11 @@
* <li>Finally, the natural order of the class names is returned
* </ol>
*/
-public class JavaClassDescriptionInheritanceComparator implements Comparator
+public class JavaClassDescriptionInheritanceComparator implements Comparator<JavaClassDescription>
{
- public int compare( Object o1, Object o2 )
+ public int compare( JavaClassDescription cd1, JavaClassDescription cd2 )
{
- JavaClassDescription cd1 = ( JavaClassDescription ) o1;
- JavaClassDescription cd2 = ( JavaClassDescription ) o2;
-
// the descriptors are the same
if ( equals( cd1, cd2 ) )
{
Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescriptorManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescriptorManager.java?rev=760528&r1=760527&r2=760528&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescriptorManager.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescriptorManager.java Tue Mar 31 17:12:40 2009
@@ -27,6 +27,8 @@
import org.apache.felix.scrplugin.Constants;
import org.apache.felix.scrplugin.om.Component;
import org.apache.felix.scrplugin.om.Components;
+import org.apache.felix.scrplugin.tags.annotation.AnnotationJavaClassDescription;
+import org.apache.felix.scrplugin.tags.annotation.AnnotationTagProviderManager;
import org.apache.felix.scrplugin.tags.cl.ClassLoaderJavaClassDescription;
import org.apache.felix.scrplugin.tags.qdox.QDoxJavaClassDescription;
import org.apache.felix.scrplugin.xml.ComponentDescriptorIO;
@@ -59,41 +61,50 @@
protected final ClassLoader classloader;
/** A cache containing the java class descriptions hashed by classname. */
- protected final Map javaClassDescriptions = new HashMap();
+ protected final Map<String, JavaClassDescription> javaClassDescriptions = new HashMap<String, JavaClassDescription>();
/** The component definitions from other bundles hashed by classname. */
- protected final Map componentDescriptions = new HashMap();
+ protected final Map<String, Component> componentDescriptions = new HashMap<String, Component>();
/** The maven project. */
protected final MavenProject project;
/**
+ * Supports mapping of built-in and custom java anntoations to {@link JavaTag} implementations.
+ */
+ protected final AnnotationTagProviderManager annotationTagProviderManager;
+
+ /**
* Construct a new manager.
* @param log
* @param project
+ * @param annotationTagProviders List of annotation tag providers
* @throws MojoFailureException
* @throws MojoExecutionException
*/
public JavaClassDescriptorManager(final Log log,
final MavenProject project,
+ final String[] annotationTagProviders,
final String excludeString)
throws MojoFailureException, MojoExecutionException {
this.log = log;
this.project = project;
+ this.annotationTagProviderManager = new AnnotationTagProviderManager(annotationTagProviders);
this.classloader = this.getCompileClassLoader();
// get all the class sources through qdox
this.log.debug("Setting up QDox");
JavaDocBuilder builder = new JavaDocBuilder();
builder.getClassLibrary().addClassLoader(this.classloader);
- final Iterator i = project.getCompileSourceRoots().iterator();
+ @SuppressWarnings("unchecked")
+ final Iterator<String> i = project.getCompileSourceRoots().iterator();
// FELIX-509: check for excludes
if ( excludeString != null ) {
final String[] excludes = StringUtils.split(excludeString, ",");
final String[] includes = new String[] {"**/*.java"};
while ( i.hasNext() ) {
- final String tree = (String)i.next();
+ final String tree = i.next();
this.log.debug("Scanning source tree " + tree);
final File directory = new File(tree);
final DirectoryScanner scanner = new DirectoryScanner();
@@ -123,7 +134,7 @@
}
} else {
while ( i.hasNext() ) {
- final String tree = (String)i.next();
+ final String tree = i.next();
this.log.debug("Adding source tree " + tree);
final File directory = new File(tree);
builder.addSourceTree(directory);
@@ -132,19 +143,21 @@
this.sources = builder.getSources();
// and now scan artifacts
- final List components = new ArrayList();
- final Map resolved = project.getArtifactMap();
- final Set artifacts = project.getDependencyArtifacts();
- final Iterator it = artifacts.iterator();
+ final List<Component> components = new ArrayList<Component>();
+ @SuppressWarnings("unchecked")
+ final Map<String, Artifact> resolved = project.getArtifactMap();
+ @SuppressWarnings("unchecked")
+ final Set<Artifact> artifacts = project.getDependencyArtifacts();
+ final Iterator<Artifact> it = artifacts.iterator();
while ( it.hasNext() ) {
- final Artifact declared = (Artifact) it.next();
+ final Artifact declared = it.next();
this.log.debug("Checking artifact " + declared);
if ( this.isJavaArtifact(declared)) {
if (Artifact.SCOPE_COMPILE.equals(declared.getScope())
|| Artifact.SCOPE_RUNTIME.equals(declared.getScope())
|| Artifact.SCOPE_PROVIDED.equals(declared.getScope())) {
this.log.debug("Resolving artifact " + declared);
- final Artifact artifact = (Artifact) resolved.get(ArtifactUtils.versionlessKey(declared));
+ final Artifact artifact = resolved.get(ArtifactUtils.versionlessKey(declared));
if (artifact != null) {
this.log.debug("Trying to get manifest from artifact " + artifact);
try {
@@ -197,9 +210,7 @@
}
}
// now create map with component descriptions
- final Iterator cI = components.iterator();
- while ( cI.hasNext() ) {
- final Component component = (Component) cI.next();
+ for(final Component component : components) {
this.componentDescriptions.put(component.getImplementation().getClassame(), component);
}
}
@@ -239,6 +250,13 @@
}
/**
+ * @return Annotation tag provider manager
+ */
+ public AnnotationTagProviderManager getAnnotationTagProviderManager() {
+ return this.annotationTagProviderManager;
+ }
+
+ /**
* Read the service component description.
* @param artifact
* @param entry
@@ -272,11 +290,12 @@
protected ClassLoader getCompileClassLoader()
throws MojoFailureException {
- List artifacts = this.getProject().getCompileArtifacts();
+ @SuppressWarnings("unchecked")
+ List<Artifact> artifacts = this.getProject().getCompileArtifacts();
URL[] path = new URL[artifacts.size() + 1];
int i = 0;
- for (Iterator ai=artifacts.iterator(); ai.hasNext(); ) {
- Artifact a = (Artifact) ai.next();
+ for (Iterator<Artifact> ai=artifacts.iterator(); ai.hasNext(); ) {
+ Artifact a = ai.next();
try {
path[i++] = a.getFile().toURI().toURL();
} catch (IOException ioe) {
@@ -343,7 +362,13 @@
for(int i=0; i<this.sources.length; i++) {
final String className = this.sources[i].getClasses()[0].getFullyQualifiedName();
try {
- descs[i] = new QDoxJavaClassDescription(this.classloader.loadClass(className), this.sources[i], this);
+ // check for java annotation descriptions - fallback to QDox if none found
+ Class clazz = this.classloader.loadClass(className);
+ if (getAnnotationTagProviderManager().hasScrPluginAnnotation(clazz)) {
+ descs[i] = new AnnotationJavaClassDescription(clazz, this.sources[i], this);
+ } else {
+ descs[i] = new QDoxJavaClassDescription(clazz, this.sources[i], this);
+ }
} catch (ClassNotFoundException e) {
throw new MojoExecutionException("Unable to load class " + className);
}
@@ -359,15 +384,22 @@
*/
public JavaClassDescription getJavaClassDescription(String className)
throws MojoExecutionException {
- JavaClassDescription result = (JavaClassDescription) this.javaClassDescriptions.get(className);
+ JavaClassDescription result = this.javaClassDescriptions.get(className);
if ( result == null ) {
this.log.debug("Searching description for: " + className);
int index = 0;
while ( result == null && index < this.sources.length) {
if ( this.sources[index].getClasses()[0].getFullyQualifiedName().equals(className) ) {
try {
- this.log.debug("Found qdox description for: " + className);
- result = new QDoxJavaClassDescription(this.classloader.loadClass(className), this.sources[index], this);
+ // check for java annotation descriptions - fallback to QDox if none found
+ Class clazz = this.classloader.loadClass(className);
+ if (getAnnotationTagProviderManager().hasScrPluginAnnotation(clazz)) {
+ this.log.debug("Found java annotation description for: " + className);
+ result = new AnnotationJavaClassDescription(clazz, this.sources[index], this);
+ } else {
+ this.log.debug("Found qdox description for: " + className);
+ result = new QDoxJavaClassDescription(clazz, this.sources[index], this);
+ }
} catch (ClassNotFoundException e) {
throw new MojoExecutionException("Unable to load class " + className);
}
@@ -378,7 +410,7 @@
if ( result == null ) {
try {
this.log.debug("Generating classloader description for: " + className);
- result = new ClassLoaderJavaClassDescription(this.classloader.loadClass(className), (Component)this.componentDescriptions.get(className), this);
+ result = new ClassLoaderJavaClassDescription(this.classloader.loadClass(className), this.componentDescriptions.get(className), this);
} catch (ClassNotFoundException e) {
throw new MojoExecutionException("Unable to load class " + className);
}
Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaTag.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaTag.java?rev=760528&r1=760527&r2=760528&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaTag.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaTag.java Tue Mar 31 17:12:40 2009
@@ -38,5 +38,5 @@
JavaField getField();
- Map getNamedParameterMap();
+ Map<String, String> getNamedParameterMap();
}
Added: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationJavaClassDescription.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationJavaClassDescription.java?rev=760528&view=auto
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationJavaClassDescription.java (added)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationJavaClassDescription.java Tue Mar 31 17:12:40 2009
@@ -0,0 +1,134 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.scrplugin.tags.annotation;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.felix.scrplugin.tags.JavaClassDescription;
+import org.apache.felix.scrplugin.tags.JavaClassDescriptorManager;
+import org.apache.felix.scrplugin.tags.JavaField;
+import org.apache.felix.scrplugin.tags.JavaTag;
+import org.apache.felix.scrplugin.tags.qdox.QDoxJavaClassDescription;
+import org.apache.maven.plugin.MojoExecutionException;
+
+import com.thoughtworks.qdox.model.JavaSource;
+
+/**
+ * Reading class description based on java annotations. This extends
+ * {@link QDoxJavaClassDescription} to re-use annotation-independent logic and
+ * automatic generation of bind/unbind methods.
+ */
+public class AnnotationJavaClassDescription extends QDoxJavaClassDescription {
+
+ /**
+ * @param clazz Java class
+ * @param source QDox source
+ * @param manager description manager
+ */
+ public AnnotationJavaClassDescription(Class clazz, JavaSource source, JavaClassDescriptorManager manager) {
+ super(clazz, source, manager);
+ }
+
+ /**
+ * @see JavaClassDescription#getTagByName(String)
+ */
+ @Override
+ public JavaTag getTagByName(String name) {
+ for (Annotation annotation : this.clazz.getAnnotations()) {
+ List<JavaTag> tags = manager.getAnnotationTagProviderManager().getTags(annotation, this);
+ for (JavaTag tag : tags) {
+ if (tag.getName().equals(name)) {
+ return tag;
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @see JavaClassDescription#getTagsByName(String, boolean)
+ */
+ @Override
+ public JavaTag[] getTagsByName(String name, boolean inherited) throws MojoExecutionException {
+
+ List<JavaTag> tags = new ArrayList<JavaTag>();
+
+ for (Annotation annotation : this.clazz.getAnnotations()) {
+ List<JavaTag> annotationTags = manager.getAnnotationTagProviderManager().getTags(annotation, this);
+ for (JavaTag tag : annotationTags) {
+ if (tag.getName().equals(name)) {
+ tags.add(tag);
+ }
+ }
+ }
+
+ if (inherited && this.getSuperClass() != null) {
+ final JavaTag[] superTags = this.getSuperClass().getTagsByName(name, inherited);
+ if (superTags.length > 0) {
+ tags.addAll(Arrays.asList(superTags));
+ }
+ }
+
+ return tags.toArray(new JavaTag[tags.size()]);
+ }
+
+ /**
+ * @see JavaClassDescription#getFields()
+ */
+ @Override
+ public JavaField[] getFields() {
+ final Field[] fields = this.clazz.getDeclaredFields();
+ final JavaField[] javaFields = new JavaField[fields.length];
+ for (int i = 0; i < fields.length; i++) {
+ javaFields[i] = new AnnotationJavaField(fields[i], this);
+ }
+ return javaFields;
+ }
+
+ /**
+ * @see JavaClassDescription#getFieldByName(String)
+ */
+ @Override
+ public JavaField getFieldByName(String name) throws MojoExecutionException {
+ Field field = null;
+ try {
+ field = this.clazz.getField(name);
+ } catch (SecurityException e) {
+ // ignore
+ } catch (NoSuchFieldException e) {
+ // ignore
+ }
+ if (field != null) {
+ return new AnnotationJavaField(field, this);
+ }
+ if (this.getSuperClass() != null) {
+ this.getSuperClass().getFieldByName(name);
+ }
+ return null;
+ }
+
+ protected JavaClassDescriptorManager getManager() {
+ return this.manager;
+ }
+
+}
Propchange: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationJavaClassDescription.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationJavaClassDescription.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Propchange: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationJavaClassDescription.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationJavaField.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationJavaField.java?rev=760528&view=auto
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationJavaField.java (added)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationJavaField.java Tue Mar 31 17:12:40 2009
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.scrplugin.tags.annotation;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.util.List;
+
+import org.apache.felix.scrplugin.tags.ClassUtil;
+import org.apache.felix.scrplugin.tags.JavaField;
+import org.apache.felix.scrplugin.tags.JavaTag;
+
+/**
+ * Description of a java field
+ */
+public class AnnotationJavaField implements JavaField {
+
+ protected final Field field;
+
+ protected final AnnotationJavaClassDescription description;
+
+ /**
+ * @param field Field
+ * @param description description
+ */
+ public AnnotationJavaField(Field field, AnnotationJavaClassDescription description) {
+ this.field = field;
+ this.description = description;
+ }
+
+ /**
+ * @see JavaField#getInitializationExpression()
+ */
+ public String[] getInitializationExpression() {
+ return ClassUtil.getInitializationExpression(this.description.getCompiledClass(), this.getName());
+ }
+
+ /**
+ * @see JavaField#getName()
+ */
+ public String getName() {
+ return this.field.getName();
+ }
+
+ /**
+ * @see JavaField#getTagByName(String)
+ */
+ public JavaTag getTagByName(String name) {
+ for (Annotation annotation : this.field.getAnnotations()) {
+ List<JavaTag> tags = description.getManager().getAnnotationTagProviderManager().getTags(annotation,
+ this.description, this);
+ for (JavaTag tag : tags) {
+ if (tag.getName().equals(name)) {
+ return tag;
+ }
+
+ }
+ }
+ return null;
+ }
+
+ /**
+ * @see JavaField#getType()
+ */
+ public String getType() {
+ return this.field.getType().getName();
+ }
+
+}
Propchange: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationJavaField.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationJavaField.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Propchange: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationJavaField.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationTagProvider.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationTagProvider.java?rev=760528&view=auto
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationTagProvider.java (added)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationTagProvider.java Tue Mar 31 17:12:40 2009
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.scrplugin.tags.annotation;
+
+import java.lang.annotation.Annotation;
+import java.util.List;
+
+import org.apache.felix.scrplugin.tags.JavaField;
+import org.apache.felix.scrplugin.tags.JavaTag;
+
+/**
+ * Interface for provider classes, that map java annotations to {@link JavaTag}
+ * implementations.
+ */
+public interface AnnotationTagProvider {
+
+ /**
+ * Maps a annotation to one or many {@link JavaTag} implementations.
+ * @param pAnnotation Java annotation
+ * @param description Annotations-based java class description
+ * @param field Reference to field (set on field-level annotations, null on
+ * other annotations)
+ * @return List of tag implementations. Return empty list if this provider
+ * cannot map the annotation to any tag instance.
+ */
+ List<JavaTag> getTags(Annotation pAnnotation, AnnotationJavaClassDescription description, JavaField field);
+
+}
Propchange: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationTagProvider.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationTagProvider.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Propchange: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationTagProvider.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationTagProviderManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationTagProviderManager.java?rev=760528&view=auto
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationTagProviderManager.java (added)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationTagProviderManager.java Tue Mar 31 17:12:40 2009
@@ -0,0 +1,121 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.scrplugin.tags.annotation;
+
+import java.lang.annotation.Annotation;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.felix.scrplugin.tags.JavaField;
+import org.apache.felix.scrplugin.tags.JavaTag;
+import org.apache.felix.scrplugin.tags.annotation.defaulttag.DefaultAnnotationTagProvider;
+import org.apache.maven.plugin.MojoFailureException;
+
+/**
+ * Supports mapping of built-in and custom java anntoations to {@link JavaTag}
+ * implementations.
+ */
+public class AnnotationTagProviderManager {
+
+ /**
+ * Allows to define additional implementations of the interface
+ * {@link org.apache.felix.scrplugin.tags.annotation.AnnotationTagProvider}
+ * that provide mappings from custom annotations to
+ * {@link org.apache.felix.scrplugin.tags.JavaTag} implementations.
+ */
+ private final List<AnnotationTagProvider> annotationTagProviders = new ArrayList<AnnotationTagProvider>();
+
+ /**
+ * @param annotationTagProviderClasses List of classes that implements
+ * {@link AnnotationTagProvider} interface.
+ * @throws MojoFailureException
+ */
+ public AnnotationTagProviderManager(String[] annotationTagProviderClasses) throws MojoFailureException {
+
+ // always add provider supporting built-in SCR default properties
+ annotationTagProviders.add(new DefaultAnnotationTagProvider());
+
+ // add custom providers defined in pom
+ for (int i = 0; i < annotationTagProviderClasses.length; i++) {
+ try {
+ Class clazz = Class.forName(annotationTagProviderClasses[i]);
+ try {
+ annotationTagProviders.add((AnnotationTagProvider) clazz.newInstance());
+ } catch (ClassCastException e) {
+ throw new MojoFailureException("Class '" + clazz.getName() + "' "
+ + "does not implement interface '" + AnnotationTagProvider.class.getName() + "'.");
+ } catch (InstantiationException e) {
+ throw new MojoFailureException("Unable to instantiate class '" + clazz.getName() + "': "
+ + e.getMessage());
+ } catch (IllegalAccessException e) {
+ throw new MojoFailureException("Illegal access to class '" + clazz.getName() + "': "
+ + e.getMessage());
+ }
+ } catch (ClassNotFoundException ex) {
+ throw new MojoFailureException("Annotation provider class '" + annotationTagProviderClasses[i]
+ + "' not found.");
+ }
+ }
+
+ }
+
+ /**
+ * Converts a java annotation to {@link JavaTag} if a mapping can be found.
+ *
+ * @param annotation Java annotation
+ * @param description Description
+ * @return Tag declaration or null if no mapping found
+ */
+ public List<JavaTag> getTags(Annotation annotation, AnnotationJavaClassDescription description) {
+ return getTags(annotation, description, null);
+ }
+
+ /**
+ * Converts a java annotation to {@link JavaTag} if a mapping can be found.
+ *
+ * @param annotation Java annotation
+ * @param description Description
+ * @param field Field
+ * @return Tag declaration or null if no mapping found
+ */
+ public List<JavaTag> getTags(Annotation annotation, AnnotationJavaClassDescription description, JavaField field) {
+ List<JavaTag> tags = new ArrayList<JavaTag>();
+
+ for (AnnotationTagProvider provider : this.annotationTagProviders) {
+ tags.addAll(provider.getTags(annotation, description, field));
+ }
+
+ return tags;
+ }
+
+ /**
+ * Checks if the given class has any SCR plugin java annotations defined.
+ * @param pClass Class
+ * @return true if SCR plugin java annotation found
+ */
+ public boolean hasScrPluginAnnotation(Class pClass) {
+ for (Annotation annotation : pClass.getAnnotations()) {
+ if (getTags(annotation, null).size() > 0) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+}
Propchange: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationTagProviderManager.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationTagProviderManager.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Propchange: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/AnnotationTagProviderManager.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/AbstractTag.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/AbstractTag.java?rev=760528&view=auto
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/AbstractTag.java (added)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/AbstractTag.java Tue Mar 31 17:12:40 2009
@@ -0,0 +1,108 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.scrplugin.tags.annotation.defaulttag;
+
+import java.util.Map;
+
+import org.apache.felix.scrplugin.tags.*;
+
+/**
+ * Description of a java tag for components.
+ */
+public abstract class AbstractTag implements JavaTag {
+
+ protected final JavaClassDescription description;
+
+ protected final JavaField field;
+
+ /**
+ * @param desc Description
+ * @param field Field
+ */
+ public AbstractTag(JavaClassDescription desc, JavaField field) {
+ this.description = desc;
+ this.field = field;
+ }
+
+ /**
+ * @see JavaTag#getNamedParameter(String)
+ */
+ public String getNamedParameter(String name) {
+ final Map<String, String> map = this.getNamedParameterMap();
+ if (map != null) {
+ return map.get(name);
+ }
+ return null;
+ }
+
+ /**
+ * @see JavaTag#getParameters()
+ */
+ public String[] getParameters() {
+ final Map<?, ?> map = this.getNamedParameterMap();
+ if (map != null) {
+ return map.keySet().toArray(new String[5]);
+ }
+ return new String[0];
+ }
+
+ /**
+ * @see JavaTag#getSourceLocation()
+ */
+ public String getSourceLocation() {
+ return "Java annotations in " + this.description.getName();
+ }
+
+ /**
+ * @see JavaTag#getJavaClassDescription()
+ */
+ public JavaClassDescription getJavaClassDescription() {
+ return this.description;
+ }
+
+ /**
+ * @see JavaTag#getField()
+ */
+ public JavaField getField() {
+ return this.field;
+ }
+
+ /**
+ * Maps an empty or null string value to null
+ * @param value String value
+ * @return Non-empty string value or null
+ */
+ protected String emptyToNull(String value) {
+ if (value == null || value.length() == 0) {
+ return null;
+ }
+ return value;
+ }
+
+ /**
+ * @see JavaTag#getName()
+ */
+ public abstract String getName();
+
+ /**
+ * @see JavaTag#getNamedParameterMap()
+ */
+ public abstract Map<String, String> getNamedParameterMap();
+
+}
Propchange: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/AbstractTag.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/AbstractTag.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Propchange: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/AbstractTag.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ComponentTag.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ComponentTag.java?rev=760528&view=auto
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ComponentTag.java (added)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ComponentTag.java Tue Mar 31 17:12:40 2009
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.scrplugin.tags.annotation.defaulttag;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.felix.scrplugin.Constants;
+import org.apache.felix.scrplugin.annotations.Component;
+import org.apache.felix.scrplugin.tags.JavaClassDescription;
+
+/**
+ * Description of a java tag for components.
+ */
+public class ComponentTag extends AbstractTag {
+
+ protected final Component annotation;
+
+ /**
+ * @param annotation Annotation
+ * @param desc Description
+ */
+ public ComponentTag(Component annotation, JavaClassDescription desc) {
+ super(desc, null);
+ this.annotation = annotation;
+ }
+
+ @Override
+ public String getName() {
+ return Constants.COMPONENT;
+ }
+
+ @Override
+ public Map<String, String> getNamedParameterMap() {
+ final Map<String, String> map = new HashMap<String, String>();
+
+ map.put(Constants.COMPONENT_NAME, emptyToNull(this.annotation.name()));
+ map.put(Constants.COMPONENT_LABEL, emptyToNull(this.annotation.label()));
+ map.put(Constants.COMPONENT_DESCRIPTION, emptyToNull(this.annotation.description()));
+ map.put(Constants.COMPONENT_ENABLED, String.valueOf(this.annotation.enabled()));
+ map.put(Constants.COMPONENT_FACTORY, emptyToNull(this.annotation.factory()));
+ map.put(Constants.COMPONENT_IMMEDIATE, String.valueOf(this.annotation.immediate()));
+ map.put(Constants.COMPONENT_INHERIT, String.valueOf(this.annotation.inherit()));
+ map.put(Constants.COMPONENT_METATYPE, String.valueOf(this.annotation.metatype()));
+ map.put(Constants.COMPONENT_ABSTRACT, String.valueOf(this.annotation.componentAbstract()));
+ map.put(Constants.COMPONENT_DS, String.valueOf(this.annotation.ds()));
+ map.put(Constants.COMPONENT_CREATE_PID, String.valueOf(this.annotation.createPid()));
+
+ return map;
+ }
+
+}
Propchange: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ComponentTag.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ComponentTag.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Propchange: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ComponentTag.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/DefaultAnnotationTagProvider.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/DefaultAnnotationTagProvider.java?rev=760528&view=auto
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/DefaultAnnotationTagProvider.java (added)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/DefaultAnnotationTagProvider.java Tue Mar 31 17:12:40 2009
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.scrplugin.tags.annotation.defaulttag;
+
+import java.lang.annotation.Annotation;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.felix.scrplugin.annotations.Component;
+import org.apache.felix.scrplugin.annotations.Properties;
+import org.apache.felix.scrplugin.annotations.Property;
+import org.apache.felix.scrplugin.annotations.Reference;
+import org.apache.felix.scrplugin.annotations.References;
+import org.apache.felix.scrplugin.annotations.Service;
+import org.apache.felix.scrplugin.annotations.Services;
+import org.apache.felix.scrplugin.tags.JavaField;
+import org.apache.felix.scrplugin.tags.JavaTag;
+import org.apache.felix.scrplugin.tags.annotation.AnnotationJavaClassDescription;
+import org.apache.felix.scrplugin.tags.annotation.AnnotationTagProvider;
+
+/**
+ * Provides mapping of default SCR annotations to tag implementations.
+ */
+public class DefaultAnnotationTagProvider implements AnnotationTagProvider {
+
+ /**
+ * @see AnnotationTagProvider#getTags(Annotation,
+ * AnnotationJavaClassDescription, JavaField)
+ */
+ public List<JavaTag> getTags(Annotation annotation, AnnotationJavaClassDescription description, JavaField field) {
+ List<JavaTag> tags = new ArrayList<JavaTag>();
+
+ // check for single annotations
+ if (annotation instanceof Component) {
+ tags.add(new ComponentTag((Component) annotation, description));
+ } else if (annotation instanceof Property) {
+ tags.add(new PropertyTag((Property) annotation, description));
+ } else if (annotation instanceof Service) {
+ tags.add(new ServiceTag((Service) annotation, description));
+ } else if (annotation instanceof Reference) {
+ tags.add(new ReferenceTag((Reference) annotation, description, field));
+ }
+
+ // check for multi-annotations
+ else if (annotation instanceof Properties) {
+ for (Property property : ((Properties) annotation).value()) {
+ tags.add(new PropertyTag(property, description));
+ }
+ } else if (annotation instanceof Services) {
+ for (Service service : ((Services) annotation).value()) {
+ tags.add(new ServiceTag(service, description));
+ }
+ } else if (annotation instanceof References) {
+ for (Reference reference : ((References) annotation).value()) {
+ tags.add(new ReferenceTag(reference, description, field));
+ }
+ }
+
+ return tags;
+ }
+
+}
Propchange: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/DefaultAnnotationTagProvider.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/DefaultAnnotationTagProvider.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Propchange: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/DefaultAnnotationTagProvider.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/PropertyTag.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/PropertyTag.java?rev=760528&view=auto
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/PropertyTag.java (added)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/PropertyTag.java Tue Mar 31 17:12:40 2009
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.scrplugin.tags.annotation.defaulttag;
+
+import java.util.*;
+
+import org.apache.felix.scrplugin.Constants;
+import org.apache.felix.scrplugin.annotations.*;
+import org.apache.felix.scrplugin.tags.JavaClassDescription;
+
+/**
+ * Description of a java tag for components.
+ */
+public class PropertyTag extends AbstractTag {
+
+ protected final Property annotation;
+
+ /**
+ * @param annotation Annotation
+ * @param desc Description
+ */
+ public PropertyTag(Property annotation, JavaClassDescription desc) {
+ super(desc, null);
+ this.annotation = annotation;
+ }
+
+ @Override
+ public String getName() {
+ return Constants.PROPERTY;
+ }
+
+ @Override
+ public Map<String, String> getNamedParameterMap() {
+ final Map<String, String> map = new HashMap<String, String>();
+
+ map.put(Constants.PROPERTY_NAME, emptyToNull(this.annotation.name()));
+ map.put(Constants.PROPERTY_LABEL, emptyToNull(this.annotation.label()));
+ map.put(Constants.PROPERTY_DESCRIPTION, emptyToNull(this.annotation.description()));
+
+ String[] values = this.annotation.value();
+ if (values == null || values.length == 0) {
+ map.put(Constants.PROPERTY_VALUE, "");
+ } else if (values.length == 1) {
+ map.put(Constants.PROPERTY_VALUE, values[0]);
+ } else {
+ for (int i = 0; i < values.length; i++) {
+ map.put(Constants.PROPERTY_MULTIVALUE_PREFIX + '.' + i, values[i]);
+ }
+ }
+
+ String type = null;
+ if (this.annotation.type() != AutoDetect.class) {
+ type = this.annotation.type().getSimpleName();
+ }
+ map.put(Constants.PROPERTY_TYPE, type);
+
+ if (this.annotation.cardinality() != 0) {
+ map.put(Constants.PROPERTY_CARDINALITY, String.valueOf(this.annotation.cardinality()));
+ }
+
+ map.put(Constants.PROPERTY_PRIVATE, String.valueOf(this.annotation.propertyPrivate()));
+
+ return map;
+ }
+
+ @Override
+ public String[] getParameters() {
+ List<String> parameters = new ArrayList<String>();
+
+ String[] defaultParameters = super.getParameters();
+ if (defaultParameters != null) {
+ parameters.addAll(Arrays.asList(defaultParameters));
+ }
+
+ // if defined: add options as parameters to the end of parameter list
+ // (strange parsing due to qdox tag restrictions...)
+ if (this.annotation.options().length > 0) {
+ parameters.add(Constants.PROPERTY_OPTIONS);
+ for (PropertyOption option : this.annotation.options()) {
+ parameters.add(option.name());
+ parameters.add("=");
+ parameters.add(option.value());
+ }
+ }
+
+ return parameters.toArray(new String[parameters.size()]);
+ }
+
+}
Propchange: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/PropertyTag.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/PropertyTag.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Propchange: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/PropertyTag.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ReferenceTag.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ReferenceTag.java?rev=760528&view=auto
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ReferenceTag.java (added)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ReferenceTag.java Tue Mar 31 17:12:40 2009
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.scrplugin.tags.annotation.defaulttag;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.felix.scrplugin.Constants;
+import org.apache.felix.scrplugin.annotations.AutoDetect;
+import org.apache.felix.scrplugin.annotations.Reference;
+import org.apache.felix.scrplugin.tags.JavaClassDescription;
+import org.apache.felix.scrplugin.tags.JavaField;
+
+/**
+ * Description of a java tag for components.
+ */
+public class ReferenceTag extends AbstractTag {
+
+ protected final Reference annotation;
+
+ /**
+ * @param annotation Annotation
+ * @param desc Description
+ * @param field Field
+ */
+ public ReferenceTag(Reference annotation, JavaClassDescription desc, JavaField field) {
+ super(desc, field);
+ this.annotation = annotation;
+ }
+
+ @Override
+ public String getName() {
+ return Constants.REFERENCE;
+ }
+
+ @Override
+ public Map<String, String> getNamedParameterMap() {
+ final Map<String, String> map = new HashMap<String, String>();
+
+ map.put(Constants.REFERENCE_NAME, emptyToNull(this.annotation.name()));
+
+ String referenceInterface = null;
+ if (this.annotation.referenceInterface() != AutoDetect.class) {
+ referenceInterface = this.annotation.referenceInterface().getName();
+ }
+ map.put(Constants.REFERENCE_INTERFACE, referenceInterface);
+
+ map.put(Constants.REFERENCE_CARDINALITY, this.annotation.cardinality().getCardinalityString());
+ map.put(Constants.REFERENCE_POLICY, this.annotation.policy().getPolicyString());
+ map.put(Constants.REFERENCE_TARGET, emptyToNull(this.annotation.target()));
+ map.put(Constants.REFERENCE_BIND, emptyToNull(this.annotation.bind()));
+ map.put(Constants.REFERENCE_UNDBIND, emptyToNull(this.annotation.unbind()));
+ map.put(Constants.REFERENCE_CHECKED, String.valueOf(this.annotation.checked()));
+ map.put(Constants.REFERENCE_STRATEGY, emptyToNull(this.annotation.strategy()));
+
+ return map;
+ }
+
+}
Propchange: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ReferenceTag.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ReferenceTag.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Propchange: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ReferenceTag.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ServiceTag.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ServiceTag.java?rev=760528&view=auto
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ServiceTag.java (added)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ServiceTag.java Tue Mar 31 17:12:40 2009
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.scrplugin.tags.annotation.defaulttag;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.felix.scrplugin.Constants;
+import org.apache.felix.scrplugin.annotations.AutoDetect;
+import org.apache.felix.scrplugin.annotations.Service;
+import org.apache.felix.scrplugin.tags.JavaClassDescription;
+
+/**
+ * Description of a java tag for components.
+ */
+public class ServiceTag extends AbstractTag {
+
+ protected final Service annotation;
+
+ /**
+ * @param annotation Annotation
+ * @param desc Description
+ */
+ public ServiceTag(Service annotation, JavaClassDescription desc) {
+ super(desc, null);
+ this.annotation = annotation;
+ }
+
+ @Override
+ public String getName() {
+ return Constants.SERVICE;
+ }
+
+ @Override
+ public Map<String, String> getNamedParameterMap() {
+ final Map<String, String> map = new HashMap<String, String>();
+
+ String serviceInterface = null;
+ if (this.annotation.value() != AutoDetect.class) {
+ serviceInterface = this.annotation.value().getName();
+ }
+ map.put(Constants.SERVICE_INTERFACE, serviceInterface);
+
+ map.put(Constants.SERVICE_FACTORY, String.valueOf(this.annotation.serviceFactory()));
+
+ return map;
+ }
+
+}
Propchange: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ServiceTag.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ServiceTag.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Propchange: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/ServiceTag.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/package-info.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/package-info.java?rev=760528&view=auto
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/package-info.java (added)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/package-info.java Tue Mar 31 17:12:40 2009
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/**
+ * SCR plugin annotation tag provider default implementation for annotations provided in package
+ * <code>org.apache.felix.scrplugin.annotations</code>.
+ */
+package org.apache.felix.scrplugin.tags.annotation.defaulttag;
+
Propchange: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/package-info.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/package-info.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Propchange: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/defaulttag/package-info.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/package-info.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/package-info.java?rev=760528&view=auto
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/package-info.java (added)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/package-info.java Tue Mar 31 17:12:40 2009
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/**
+ * Extracting SCR tags from source file declared as Java 1.5 annotations.
+ */
+package org.apache.felix.scrplugin.tags.annotation;
+
Propchange: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/package-info.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/package-info.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Propchange: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/annotation/package-info.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/cl/ClassLoaderJavaClassDescription.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/cl/ClassLoaderJavaClassDescription.java?rev=760528&r1=760527&r2=760528&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/cl/ClassLoaderJavaClassDescription.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/cl/ClassLoaderJavaClassDescription.java Tue Mar 31 17:12:40 2009
@@ -22,7 +22,7 @@
import java.util.*;
import org.apache.felix.scrplugin.Constants;
-import org.apache.felix.scrplugin.om.*;
+import org.apache.felix.scrplugin.om.Component;
import org.apache.felix.scrplugin.tags.*;
import org.apache.maven.plugin.MojoExecutionException;
@@ -194,7 +194,7 @@
this.component.getService().getInterfaces().size() > 0 ) {
javaTags = new JavaTag[this.component.getService().getInterfaces().size()];
for(int i=0; i<this.component.getService().getInterfaces().size(); i++) {
- javaTags[i] = new ClassLoaderJavaTag(this, (Interface)this.component.getService().getInterfaces().get(i),
+ javaTags[i] = new ClassLoaderJavaTag(this, this.component.getService().getInterfaces().get(i),
this.component.getService().isServicefactory());
}
}
@@ -202,14 +202,14 @@
if ( this.component.getProperties().size() > 0 ) {
javaTags = new JavaTag[this.component.getProperties().size()];
for(int i=0; i<this.component.getProperties().size(); i++) {
- javaTags[i] = new ClassLoaderJavaTag(this, (Property)this.component.getProperties().get(i));
+ javaTags[i] = new ClassLoaderJavaTag(this, this.component.getProperties().get(i));
}
}
} else if ( Constants.REFERENCE.equals(name) ) {
if ( this.component.getReferences().size() > 0 ) {
javaTags = new JavaTag[this.component.getReferences().size()];
for(int i=0; i<this.component.getReferences().size(); i++) {
- javaTags[i] = new ClassLoaderJavaTag(this, (Reference)this.component.getReferences().get(i));
+ javaTags[i] = new ClassLoaderJavaTag(this, this.component.getReferences().get(i));
}
}
}
@@ -217,9 +217,9 @@
if ( inherited && this.getSuperClass() != null ) {
final JavaTag[] superTags = this.getSuperClass().getTagsByName(name, inherited);
if ( superTags.length > 0 ) {
- final List list = new ArrayList(Arrays.asList(javaTags));
+ final List<JavaTag> list = new ArrayList<JavaTag>(Arrays.asList(javaTags));
list.addAll(Arrays.asList(superTags));
- javaTags = (JavaTag[]) list.toArray(new JavaTag[list.size()]);
+ javaTags = list.toArray(new JavaTag[list.size()]);
}
}
return javaTags;
Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/cl/ClassLoaderJavaTag.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/cl/ClassLoaderJavaTag.java?rev=760528&r1=760527&r2=760528&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/cl/ClassLoaderJavaTag.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/cl/ClassLoaderJavaTag.java Tue Mar 31 17:12:40 2009
@@ -92,9 +92,9 @@
* @see org.apache.felix.scrplugin.tags.JavaTag#getNamedParameter(java.lang.String)
*/
public String getNamedParameter(String name) {
- final Map map = this.getNamedParameterMap();
+ final Map<String, String> map = this.getNamedParameterMap();
if ( map != null ) {
- return (String)map.get(name);
+ return map.get(name);
}
return null;
}
@@ -102,9 +102,9 @@
/**
* @see org.apache.felix.scrplugin.tags.JavaTag#getNamedParameterMap()
*/
- public Map getNamedParameterMap() {
+ public Map<String, String> getNamedParameterMap() {
if ( this.reference != null ) {
- final Map map = new HashMap();
+ final Map<String, String> map = new HashMap<String, String>();
map.put(Constants.REFERENCE_BIND, this.reference.getBind());
map.put(Constants.REFERENCE_CARDINALITY, this.reference.getCardinality());
map.put(Constants.REFERENCE_INTERFACE, this.reference.getInterfacename());
@@ -116,7 +116,7 @@
map.put(Constants.REFERENCE_STRATEGY, this.reference.getStrategy());
return map;
} else if ( this.property != null ) {
- final Map map = new HashMap();
+ final Map<String, String> map = new HashMap<String, String>();
map.put(Constants.PROPERTY_TYPE, this.property.getType());
map.put(Constants.PROPERTY_NAME, this.property.getName());
final String[] values = this.property.getMultiValue();
@@ -139,7 +139,7 @@
}
return map;
} else if ( this.interf != null ) {
- final Map map = new HashMap();
+ final Map<String, String> map = new HashMap<String, String>();
map.put(Constants.SERVICE_INTERFACE, this.interf.getInterfacename());
if ( this.isServiceFactory ) {
map.put(Constants.SERVICE_FACTORY, "true");
@@ -153,9 +153,9 @@
* @see org.apache.felix.scrplugin.tags.JavaTag#getParameters()
*/
public String[] getParameters() {
- final Map map = this.getNamedParameterMap();
+ final Map<String, String> map = this.getNamedParameterMap();
if ( map != null ) {
- return (String[])map.keySet().toArray(new String[5]);
+ return map.keySet().toArray(new String[5]);
}
return new String[0];
}
Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/qdox/QDoxJavaClassDescription.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/qdox/QDoxJavaClassDescription.java?rev=760528&r1=760527&r2=760528&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/qdox/QDoxJavaClassDescription.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/qdox/QDoxJavaClassDescription.java Tue Mar 31 17:12:40 2009
@@ -102,9 +102,9 @@
if ( inherited && this.getSuperClass() != null ) {
final JavaTag[] superTags = this.getSuperClass().getTagsByName(name, inherited);
if ( superTags.length > 0 ) {
- final List list = new ArrayList(Arrays.asList(javaTags));
+ final List<JavaTag> list = new ArrayList<JavaTag>(Arrays.asList(javaTags));
list.addAll(Arrays.asList(superTags));
- javaTags = (JavaTag[]) list.toArray(new JavaTag[list.size()]);
+ javaTags = list.toArray(new JavaTag[list.size()]);
}
}
return javaTags;
Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/qdox/QDoxJavaTag.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/qdox/QDoxJavaTag.java?rev=760528&r1=760527&r2=760528&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/qdox/QDoxJavaTag.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/qdox/QDoxJavaTag.java Tue Mar 31 17:12:40 2009
@@ -84,7 +84,8 @@
/**
* @see org.apache.felix.scrplugin.tags.JavaTag#getNamedParameterMap()
*/
- public Map getNamedParameterMap() {
+ @SuppressWarnings("unchecked")
+ public Map<String, String> getNamedParameterMap() {
return this.docletTag.getNamedParameterMap();
}
Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java?rev=760528&r1=760527&r2=760528&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/xml/ComponentDescriptorIO.java Tue Mar 31 17:12:40 2009
@@ -20,7 +20,6 @@
import java.io.File;
import java.io.IOException;
-import java.util.Iterator;
import java.util.StringTokenizer;
import javax.xml.transform.TransformerException;
@@ -119,9 +118,7 @@
contentHandler.startElement("", ComponentDescriptorIO.COMPONENTS, ComponentDescriptorIO.COMPONENTS, new AttributesImpl());
IOUtils.newline(contentHandler);
- final Iterator i = components.getComponents().iterator();
- while ( i.hasNext() ) {
- final Component component = (Component)i.next();
+ for(final Component component : components.getComponents()) {
generateXML(component, contentHandler, isScrPrivateFile);
}
// end wrapper element
@@ -153,16 +150,12 @@
generateXML(component.getService(), contentHandler);
}
if ( component.getProperties() != null ) {
- final Iterator i = component.getProperties().iterator();
- while ( i.hasNext() ) {
- final Property property = (Property)i.next();
+ for(final Property property : component.getProperties()) {
generateXML(property, contentHandler, isScrPrivateFile);
}
}
if ( component.getReferences() != null ) {
- final Iterator i = component.getReferences().iterator();
- while ( i.hasNext() ) {
- final Reference reference = (Reference)i.next();
+ for(final Reference reference : component.getReferences()) {
generateXML(reference, contentHandler, isScrPrivateFile);
}
}
@@ -201,9 +194,7 @@
contentHandler.startElement(INNER_NAMESPACE_URI, ComponentDescriptorIO.SERVICE, ComponentDescriptorIO.SERVICE_QNAME, ai);
if ( service.getInterfaces() != null && service.getInterfaces().size() > 0 ) {
IOUtils.newline(contentHandler);
- final Iterator i = service.getInterfaces().iterator();
- while ( i.hasNext() ) {
- final Interface interf = (Interface)i.next();
+ for(final Interface interf : service.getInterfaces()) {
generateXML(interf, contentHandler);
}
IOUtils.indent(contentHandler, 2);
Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/xml/IOUtils.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/xml/IOUtils.java?rev=760528&r1=760527&r2=760528&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/xml/IOUtils.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/xml/IOUtils.java Tue Mar 31 17:12:40 2009
@@ -133,19 +133,19 @@
/**
* The prefixes of startPrefixMapping() declarations for the coming element.
*/
- private List prefixList = new ArrayList();
+ private List<String> prefixList = new ArrayList<String>();
/**
* The URIs of startPrefixMapping() declarations for the coming element.
*/
- private List uriList = new ArrayList();
+ private List<String> uriList = new ArrayList<String>();
/**
* Maps of URI<->prefix mappings. Used to work around a bug in the Xalan
* serializer.
*/
- private Map uriToPrefixMap = new HashMap();
- private Map prefixToUriMap = new HashMap();
+ private Map<String, String> uriToPrefixMap = new HashMap<String, String>();
+ private Map<String, String> prefixToUriMap = new HashMap<String, String>();
/**
* True if there has been some startPrefixMapping() for the coming element.
@@ -215,8 +215,8 @@
for (int mapping = 0; mapping < mappingCount; mapping++) {
// Build infos for this namespace
- String uri = (String) this.uriList.get(mapping);
- String prefix = (String) this.prefixList.get(mapping);
+ String uri = this.uriList.get(mapping);
+ String prefix = this.prefixList.get(mapping);
String qName = prefix.length() == 0 ? "xmlns" : ("xmlns:" + prefix);
// Search for the corresponding xmlns* attribute
Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/xml/MetaTypeIO.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/xml/MetaTypeIO.java?rev=760528&r1=760527&r2=760528&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/xml/MetaTypeIO.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/xml/MetaTypeIO.java Tue Mar 31 17:12:40 2009
@@ -95,15 +95,13 @@
contentHandler.startElement(NAMESPACE_URI, METADATA_ELEMENT, METADATA_ELEMENT_QNAME, ai);
IOUtils.newline(contentHandler);
- final Iterator i = metaData.getDescriptors().iterator();
- while ( i.hasNext() ) {
- final Object obj = i.next();
- if ( obj instanceof OCD ) {
- generateXML((OCD)obj, contentHandler);
- } else {
- generateXML((Designate)obj, contentHandler);
- }
+ for(final OCD ocd : metaData.getOCDs()) {
+ generateXML(ocd, contentHandler);
+ }
+ for(final Designate d : metaData.getDesignates()) {
+ generateXML(d, contentHandler);
}
+
// end wrapper element
contentHandler.endElement(NAMESPACE_URI, METADATA_ELEMENT, METADATA_ELEMENT_QNAME);
IOUtils.newline(contentHandler);
@@ -122,9 +120,9 @@
if ( ocd.getProperties().size() > 0 ) {
IOUtils.newline(contentHandler);
- final Iterator i = ocd.getProperties().iterator();
+ final Iterator<AttributeDefinition> i = ocd.getProperties().iterator();
while ( i.hasNext() ) {
- final AttributeDefinition ad = (AttributeDefinition) i.next();
+ final AttributeDefinition ad = i.next();
generateXML(ad, contentHandler);
}
IOUtils.indent(contentHandler, 1);
@@ -159,11 +157,11 @@
if (ad.getOptions() != null && ad.getOptions().size() > 0) {
IOUtils.newline(contentHandler);
- for (Iterator oi=ad.getOptions().entrySet().iterator(); oi.hasNext(); ) {
- final Map.Entry entry = (Map.Entry) oi.next();
+ for (Iterator<Map.Entry<String, String>> oi=ad.getOptions().entrySet().iterator(); oi.hasNext(); ) {
+ final Map.Entry<String, String> entry = oi.next();
ai.clear();
- IOUtils.addAttribute(ai, "value", String.valueOf(entry.getKey()));
- IOUtils.addAttribute(ai, "label", String.valueOf(entry.getValue()));
+ IOUtils.addAttribute(ai, "value", entry.getKey());
+ IOUtils.addAttribute(ai, "label", entry.getValue());
IOUtils.indent(contentHandler, 3);
contentHandler.startElement(INNER_NAMESPACE_URI, OPTION_ELEMENT, OPTION_ELEMENT_QNAME, ai);
contentHandler.endElement(INNER_NAMESPACE_URI, OPTION_ELEMENT, OPTION_ELEMENT_QNAME);