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 2007/08/03 16:47:35 UTC
svn commit: r562487 - in
/felix/sandbox/cziegeler/maven-scr-plugin/src/main/java/org/apache/felix/sandbox/scrplugin:
./ om/
Author: cziegeler
Date: Fri Aug 3 07:47:31 2007
New Revision: 562487
URL: http://svn.apache.org/viewvc?view=rev&rev=562487
Log:
Start new object model implementation to unify the currently used two approaches into a single one.
Added:
felix/sandbox/cziegeler/maven-scr-plugin/src/main/java/org/apache/felix/sandbox/scrplugin/om/
felix/sandbox/cziegeler/maven-scr-plugin/src/main/java/org/apache/felix/sandbox/scrplugin/om/AbstractObject.java (with props)
felix/sandbox/cziegeler/maven-scr-plugin/src/main/java/org/apache/felix/sandbox/scrplugin/om/Component.java (with props)
felix/sandbox/cziegeler/maven-scr-plugin/src/main/java/org/apache/felix/sandbox/scrplugin/om/Components.java (with props)
felix/sandbox/cziegeler/maven-scr-plugin/src/main/java/org/apache/felix/sandbox/scrplugin/om/Implementation.java (with props)
felix/sandbox/cziegeler/maven-scr-plugin/src/main/java/org/apache/felix/sandbox/scrplugin/om/Interface.java (with props)
felix/sandbox/cziegeler/maven-scr-plugin/src/main/java/org/apache/felix/sandbox/scrplugin/om/Property.java (with props)
felix/sandbox/cziegeler/maven-scr-plugin/src/main/java/org/apache/felix/sandbox/scrplugin/om/Reference.java (with props)
felix/sandbox/cziegeler/maven-scr-plugin/src/main/java/org/apache/felix/sandbox/scrplugin/om/Service.java (with props)
Modified:
felix/sandbox/cziegeler/maven-scr-plugin/src/main/java/org/apache/felix/sandbox/scrplugin/SCRDescriptorMojo.java
Modified: felix/sandbox/cziegeler/maven-scr-plugin/src/main/java/org/apache/felix/sandbox/scrplugin/SCRDescriptorMojo.java
URL: http://svn.apache.org/viewvc/felix/sandbox/cziegeler/maven-scr-plugin/src/main/java/org/apache/felix/sandbox/scrplugin/SCRDescriptorMojo.java?view=diff&rev=562487&r1=562486&r2=562487
==============================================================================
--- felix/sandbox/cziegeler/maven-scr-plugin/src/main/java/org/apache/felix/sandbox/scrplugin/SCRDescriptorMojo.java (original)
+++ felix/sandbox/cziegeler/maven-scr-plugin/src/main/java/org/apache/felix/sandbox/scrplugin/SCRDescriptorMojo.java Fri Aug 3 07:47:31 2007
@@ -27,6 +27,9 @@
import java.util.List;
import java.util.Map;
+import org.apache.felix.sandbox.scrplugin.om.Component;
+import org.apache.felix.sandbox.scrplugin.om.Implementation;
+import org.apache.felix.sandbox.scrplugin.om.Interface;
import org.apache.felix.sandbox.scrplugin.tags.JavaClassDescription;
import org.apache.felix.sandbox.scrplugin.tags.JavaClassDescriptorManager;
import org.apache.felix.sandbox.scrplugin.tags.JavaField;
@@ -240,6 +243,151 @@
return sd.validate() ? sd : null;
}
+ /**
+ * Create a component for the java class description.
+ * @param description
+ * @return The generated component descriptor or null if any error occurs.
+ * @throws MojoExecutionException
+ */
+ protected Component createComponent(JavaClassDescription description)
+ throws MojoExecutionException {
+
+ final JavaTag componentTag = description.getTagByName(SCRDescriptor.COMPONENT);
+ final Component component = new Component(componentTag);
+
+ // set implementation
+ component.setImplementation(new Implementation(description.getName()));
+
+ this.doComponent(componentTag, component);
+
+ boolean inherited = this.getBoolean(componentTag, SCRDescriptor.COMPONENT_INHERIT, false);
+ boolean serviceFactory = this.doServices(description.getTagsByName(SCRDescriptor.SERVICE, inherited), component, description);
+ component.setServiceFactory(serviceFactory);
+
+ // properties
+ final JavaTag[] properties = description.getTagsByName(SCRDescriptor.PROPERTY, inherited);
+ if (properties != null && properties.length > 0) {
+ for (int i=0; i < properties.length; i++) {
+ this.doProperty(properties[i], null, component);
+ }
+ }
+
+ // references
+ final JavaTag[] references = description.getTagsByName(SCRDescriptor.REFERENCE, inherited);
+ if (references != null || references.length > 0) {
+ for (int i=0; i < references.length; i++) {
+ this.doReference(references[i], null, component);
+ }
+ }
+
+ // fields
+ do {
+ JavaField[] fields = description.getFields();
+ for (int i=0; fields != null && i < fields.length; i++) {
+ JavaTag tag = fields[i].getTagByName(SCRDescriptor.REFERENCE);
+ if (tag != null) {
+ // this.doReference(tag, fields[i].getName(), sd);
+ }
+
+ tag = fields[i].getTagByName(SCRDescriptor.PROPERTY);
+ if (tag != null) {
+ this.doProperty(tag, fields[i].getInitializationExpression(), component);
+ }
+ }
+
+ description = description.getSuperClass();
+ } while (inherited && description != null);
+
+ final List issues = new ArrayList();
+ final List warnings = new ArrayList();
+ component.validate(issues, warnings);
+
+ // now log warnings and errors (warnings first)
+ Iterator i = warnings.iterator();
+ while ( i.hasNext() ) {
+ this.getLog().warn((String)i.next());
+ }
+ i = issues.iterator();
+ while ( i.hasNext() ) {
+ this.getLog().error((String)i.next());
+ }
+
+ // return nothing if validation fails
+ return issues.size() == 0 ? component : null;
+ }
+
+ /**
+ * Fill the component object with the information from the tag.
+ * @param tag
+ * @param component
+ */
+ protected void doComponent(JavaTag tag, Component component) {
+
+ // check if this is an abstract definition
+ String abstractType = tag.getNamedParameter(SCRDescriptor.COMPONENT_ABSTRACT);
+ component.setAbstract((abstractType == null ? false : "yes".equalsIgnoreCase(abstractType) || "true".equalsIgnoreCase(abstractType)));
+
+ String name = tag.getNamedParameter(SCRDescriptor.COMPONENT_NAME);
+ component.setName(StringUtils.isEmpty(name) ? component.getImplementation().getClassame() : name);
+
+ component.setEnabled(Boolean.valueOf(this.getBoolean(tag, SCRDescriptor.COMPONENT_ENABLED, true)));
+ component.setFactory(tag.getNamedParameter(SCRDescriptor.COMPONENT_FACTORY));
+ component.setImmediate(Boolean.valueOf(this.getBoolean(tag, SCRDescriptor.COMPONENT_IMMEDIATE, true)));
+
+ // whether metatype information is to generated for the component
+ String metaType = tag.getNamedParameter(SCRDescriptor.COMPONENT_METATYPE);
+ boolean hasMetaType = metaType == null || "yes".equalsIgnoreCase(metaType)
+ || "true".equalsIgnoreCase(metaType);
+ component.setHasMetaType(hasMetaType);
+ component.setLabel(tag.getNamedParameter(SCRDescriptor.COMPONENT_LABEL));
+ component.setDescription(tag.getNamedParameter(SCRDescriptor.COMPONENT_DESCRIPTION));
+ }
+
+ /**
+ * Process the service annotations
+ * @param services
+ * @param component
+ * @param description
+ * @return
+ * @throws MojoExecutionException
+ */
+ protected boolean doServices(JavaTag[] services, Component component, JavaClassDescription description)
+ throws MojoExecutionException {
+ // no services, hence certainly no service factory
+ if (services == null || services.length == 0) {
+ return false;
+ }
+
+ org.apache.felix.sandbox.scrplugin.om.Service service = new org.apache.felix.sandbox.scrplugin.om.Service();
+ component.setService(service);
+ boolean serviceFactory = false;
+ for (int i=0; i < services.length; i++) {
+ String name = services[i].getNamedParameter(SCRDescriptor.SERVICE_INTERFACE);
+ if (StringUtils.isEmpty(name)) {
+
+ while (description != null) {
+ JavaClassDescription[] interfaces = description.getImplementedInterfaces();
+ for (int j=0; interfaces != null && j < interfaces.length; j++) {
+ final Interface interf = new Interface(services[i]);
+ interf.setInterfacename(interfaces[j].getName());
+ service.addInterface(interf);
+ }
+
+ // try super class
+ description = description.getSuperClass();
+ }
+ } else {
+ final Interface interf = new Interface(services[i]);
+ interf.setInterfacename(name);
+ service.addInterface(interf);
+ }
+
+ serviceFactory |= this.getBoolean(services[i], SCRDescriptor.SERVICE_FACTORY, false);
+ }
+
+ return serviceFactory;
+ }
+
private void doComponent(JavaTag comp, SCRDescriptor sd) {
String name = comp.getNamedParameter(SCRDescriptor.COMPONENT_NAME);
sd.setName(StringUtils.isEmpty(name) ? sd.getImplClass() : name);
@@ -341,6 +489,86 @@
}
}
+ /**
+ * @param property
+ * @param defaultName
+ * @param component
+ */
+ protected void doProperty(JavaTag property, String defaultName, Component component) {
+ String name = property.getNamedParameter(SCRDescriptor.PROPERTY_NAME);
+ if (StringUtils.isEmpty(name) && defaultName!= null) {
+ name = defaultName.trim();
+ if (name.startsWith("\"")) name = name.substring(1);
+ if (name.endsWith("\"")) name = name.substring(0, name.length()-1);
+ }
+
+ if (!StringUtils.isEmpty(name)) {
+ org.apache.felix.sandbox.scrplugin.om.Property prop = new org.apache.felix.sandbox.scrplugin.om.Property(property);
+ prop.setName(name);
+ prop.setLabel(property.getNamedParameter(SCRDescriptor.PROPERTY_LABEL));
+ prop.setDescription(property.getNamedParameter(SCRDescriptor.PROPERTY_DESCRIPTION));
+ prop.setValue(property.getNamedParameter(SCRDescriptor.PROPERTY_VALUE));
+ prop.setType(property.getNamedParameter(SCRDescriptor.PROPERTY_TYPE));
+ //prop.setPrivateProperty(this.getBoolean(property,
+ // SCRDescriptor.PROPERTY_PRIVATE, prop.isPrivateProperty()));
+
+ // set optional multivalues, cardinality might be overwritten by setValues !!
+ //prop.setCardinality(property.getNamedParameter(SCRDescriptor.PROPERTY_CARDINALITY));
+ //prop.setValues(property.getNamedParameterMap());
+
+ // check options
+ String[] parameters = property.getParameters();
+ Map options = null;
+ for (int j=0; j < parameters.length; j++) {
+ if (SCRDescriptor.PROPERTY_OPTIONS.equals(parameters[j])) {
+ options = new LinkedHashMap();
+ } else if (options != null) {
+ String optionLabel = parameters[j];
+ String optionValue = (j < parameters.length-2) ? parameters[j+2] : null;
+ if (optionValue != null) {
+ options.put(optionLabel, optionValue);
+ }
+ j += 2;
+ }
+ }
+ //prop.setOptions(options);
+
+ component.addProperty(prop);
+ }
+ }
+
+ /**
+ * @param reference
+ * @param defaultName
+ * @param component
+ */
+ protected void doReference(JavaTag reference, String defaultName, Component component) {
+ String name = reference.getNamedParameter(SCRDescriptor.REFERENCE_NAME);
+ if (StringUtils.isEmpty(name)) {
+ name = defaultName;
+ }
+
+ // ensure interface
+ String type = reference.getNamedParameter(SCRDescriptor.REFERENCE_INTERFACE);
+ if (StringUtils.isEmpty(type)) {
+ if ( reference.getField() != null ) {
+ type = reference.getField().getType();
+ }
+ }
+
+ if (!StringUtils.isEmpty(name)) {
+ org.apache.felix.sandbox.scrplugin.om.Reference ref = new org.apache.felix.sandbox.scrplugin.om.Reference(reference);
+ ref.setName(name);
+ ref.setInterfacename(type);
+ ref.setCardinality(reference.getNamedParameter(SCRDescriptor.REFERENCE_CARDINALITY));
+ ref.setPolicy(reference.getNamedParameter(SCRDescriptor.REFERENCE_POLICY));
+ ref.setTarget(reference.getNamedParameter(SCRDescriptor.REFERENCE_TARGET));
+ ref.setBind(reference.getNamedParameter(SCRDescriptor.REFERENCE_BIND));
+ ref.setUnbind(reference.getNamedParameter(SCRDescriptor.REFERENCE_UNDBIND));
+ component.addReference(ref);
+ }
+ }
+
private void doReferences(JavaTag[] references, SCRDescriptor sd) {
if (references == null || references.length == 0) {
return;
@@ -378,7 +606,7 @@
}
}
- private boolean getBoolean(JavaTag tag, String name, boolean defaultValue) {
+ protected boolean getBoolean(JavaTag tag, String name, boolean defaultValue) {
String value = tag.getNamedParameter(name);
return (value == null) ? defaultValue : Boolean.valueOf(value).booleanValue();
}
Added: felix/sandbox/cziegeler/maven-scr-plugin/src/main/java/org/apache/felix/sandbox/scrplugin/om/AbstractObject.java
URL: http://svn.apache.org/viewvc/felix/sandbox/cziegeler/maven-scr-plugin/src/main/java/org/apache/felix/sandbox/scrplugin/om/AbstractObject.java?view=auto&rev=562487
==============================================================================
--- felix/sandbox/cziegeler/maven-scr-plugin/src/main/java/org/apache/felix/sandbox/scrplugin/om/AbstractObject.java (added)
+++ felix/sandbox/cziegeler/maven-scr-plugin/src/main/java/org/apache/felix/sandbox/scrplugin/om/AbstractObject.java Fri Aug 3 07:47:31 2007
@@ -0,0 +1,42 @@
+/*
+ * 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.sandbox.scrplugin.om;
+
+import org.apache.felix.sandbox.scrplugin.tags.JavaTag;
+
+/**
+ * The <code>AbstractObject</code>
+ * is the base class for the all classes of the scr om.
+ */
+abstract class AbstractObject {
+
+ protected final JavaTag tag;
+
+ protected AbstractObject(JavaTag tag) {
+ this.tag = tag;
+ }
+
+ protected String getMessage(String message) {
+ if ( this.tag == null ) {
+ return message;
+ } else {
+ return "@" + this.tag.getName() + ": " + message + " (" + this.tag.getSourceLocation() + ")";
+ }
+ }
+}
Propchange: felix/sandbox/cziegeler/maven-scr-plugin/src/main/java/org/apache/felix/sandbox/scrplugin/om/AbstractObject.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: felix/sandbox/cziegeler/maven-scr-plugin/src/main/java/org/apache/felix/sandbox/scrplugin/om/AbstractObject.java
------------------------------------------------------------------------------
svn:keywords = author date id revision url
Added: felix/sandbox/cziegeler/maven-scr-plugin/src/main/java/org/apache/felix/sandbox/scrplugin/om/Component.java
URL: http://svn.apache.org/viewvc/felix/sandbox/cziegeler/maven-scr-plugin/src/main/java/org/apache/felix/sandbox/scrplugin/om/Component.java?view=auto&rev=562487
==============================================================================
--- felix/sandbox/cziegeler/maven-scr-plugin/src/main/java/org/apache/felix/sandbox/scrplugin/om/Component.java (added)
+++ felix/sandbox/cziegeler/maven-scr-plugin/src/main/java/org/apache/felix/sandbox/scrplugin/om/Component.java Fri Aug 3 07:47:31 2007
@@ -0,0 +1,324 @@
+/*
+ * 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.sandbox.scrplugin.om;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.felix.sandbox.scrplugin.tags.JavaClassDescription;
+import org.apache.felix.sandbox.scrplugin.tags.JavaMethod;
+import org.apache.felix.sandbox.scrplugin.tags.JavaParameter;
+import org.apache.felix.sandbox.scrplugin.tags.JavaTag;
+import org.apache.maven.plugin.MojoExecutionException;
+
+/**
+ * <code>Component</code>
+ * is a described component.
+ *
+ */
+public class Component extends AbstractObject {
+
+ /** The name of the component. */
+ protected String name;
+
+ /** Is this component enabled? */
+ protected Boolean enabled;
+
+ /** Is this component immediately started. */
+ protected Boolean immediate;
+
+ /** The factory. */
+ protected String factory;
+
+ /** The implementation. */
+ protected Implementation implementation;
+
+ /** All properties. */
+ protected List properties = new ArrayList();
+
+ /** The corresponding service. */
+ protected Service service;
+
+ /** The references. */
+ protected List references = new ArrayList();
+
+ /** The label. */
+ protected String label;
+
+ /** The description. */
+ protected String description;
+
+ /** Is this an abstract description? */
+ protected boolean isAbstract;
+
+ protected boolean hasMetatype;
+
+ protected boolean serviceFactory;
+
+ /**
+ * Default constructor.
+ */
+ public Component() {
+ this(null);
+ }
+
+ /**
+ * Constructor from java source.
+ */
+ public Component(JavaTag t) {
+ super(t);
+ }
+
+ /**
+ * @return
+ */
+ public List getProperties() {
+ return this.properties;
+ }
+
+ public void setProperties(List properties) {
+ this.properties = properties;
+ }
+
+ public void addProperty(Property property) {
+ this.properties.add(property);
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getFactory() {
+ return this.factory;
+ }
+
+ public void setFactory(String factory) {
+ this.factory = factory;
+ }
+
+ public Boolean isEnabled() {
+ return this.enabled;
+ }
+
+ public void setEnabled(Boolean enabled) {
+ this.enabled = enabled;
+ }
+
+ public Boolean isImmediate() {
+ return this.immediate;
+ }
+
+ public void setImmediate(Boolean immediate) {
+ this.immediate = immediate;
+ }
+
+ public Implementation getImplementation() {
+ return this.implementation;
+ }
+
+ public void setImplementation(Implementation implementation) {
+ this.implementation = implementation;
+ }
+
+ public Service getService() {
+ return this.service;
+ }
+
+ public void setService(Service service) {
+ this.service = service;
+ }
+
+ public List getReferences() {
+ return this.references;
+ }
+
+ public void setReferences(List references) {
+ this.references = references;
+ }
+
+ public void addReference(Reference ref) {
+ this.references.add(ref);
+ }
+
+ public String getLabel() {
+ return this.label;
+ }
+
+ public void setLabel(String label) {
+ this.label = label;
+ }
+
+ public String getDescription() {
+ return this.description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public boolean isAbstract() {
+ return this.isAbstract;
+ }
+
+ public void setAbstract(boolean isAbstract) {
+ this.isAbstract = isAbstract;
+ }
+
+ public boolean isHasMetaType() {
+ return this.hasMetatype;
+ }
+
+ public void setHasMetaType(boolean hasMetatype) {
+ this.hasMetatype = hasMetatype;
+ }
+
+ public boolean isServiceFactory() {
+ return this.serviceFactory;
+ }
+
+ public void setServiceFactory(boolean serviceFactory) {
+ this.serviceFactory = serviceFactory;
+ }
+
+ /**
+ * Validate the component description.
+ * If errors occur a message is added to the issues list,
+ * warnings can be added to the warnings list.
+ */
+ public void validate(List issues, List warnings)
+ throws MojoExecutionException {
+ final JavaClassDescription javaClass = this.tag.getJavaClassDescription();
+ if (javaClass == null) {
+ issues.add(this.getMessage("Tag not declared in a Java Class"));
+ } else {
+
+ // if the service is abstract, we do not validate everything
+ if ( !this.isAbstract ) {
+ // ensure non-abstract, public class
+ if (!javaClass.isPublic()) {
+ issues.add(this.getMessage("Class must be pubic: " + javaClass.getName()));
+ }
+ if (javaClass.isAbstract() || javaClass.isInterface()) {
+ issues.add(this.getMessage("Class must be concrete class (not abstract or interface) : " + javaClass.getName()));
+ }
+
+ // no errors so far, let's continue
+ if ( issues.size() == 0 ) {
+ // check activate and deactivate methods
+ this.checkActivationMethod(javaClass, "activate", warnings);
+ this.checkActivationMethod(javaClass, "deactivate", warnings);
+
+ // ensure public default constructor
+ boolean constructorFound = true;
+ JavaMethod[] methods = javaClass.getMethods();
+ for (int i = 0; methods != null && i < methods.length; i++) {
+ if (methods[i].isConstructor()) {
+ // if public default, succeed
+ if (methods[i].isPublic()
+ && (methods[i].getParameters() == null || methods[i].getParameters().length == 0)) {
+ constructorFound = true;
+ break;
+ }
+
+ // non-public/non-default constructor found, must have explicit
+ constructorFound = false;
+ }
+ }
+ if (!constructorFound) {
+ issues.add(this.getMessage("Class must have public default constructor: " + javaClass.getName()));
+ }
+
+ // verify properties
+ for (Iterator pi = this.getProperties().iterator(); pi.hasNext();) {
+ Property prop = (Property) pi.next();
+ prop.validate(issues, warnings);
+ }
+
+ // verify service
+ this.getService().validate(issues, warnings);
+
+ // serviceFactory must not be true for immediate of component factory
+ if (this.isServiceFactory() && this.isImmediate() != null && this.isImmediate().booleanValue() && this.getFactory() != null) {
+ issues.add(this.getMessage("Component must not be a ServiceFactory, if immediate and/or component factory: " + javaClass.getName()));
+ }
+
+ // verify references
+ for (Iterator ri = this.getReferences().iterator(); ri.hasNext();) {
+ final Reference ref = (Reference) ri.next();
+ ref.validate(issues, warnings);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Check methods.
+ * @param javaClass
+ * @param methodName
+ */
+ protected void checkActivationMethod(JavaClassDescription javaClass, String methodName, List warnings) {
+ JavaMethod[] methods = javaClass.getMethods();
+ JavaMethod activation = null;
+ for (int i=0; i < methods.length; i++) {
+ // ignore method not matching the name
+ if (!methodName.equals(methods[i].getName())) {
+ continue;
+ }
+
+ // if the method has the correct parameter type, check protected
+ JavaParameter[] params = methods[i].getParameters();
+ if (params == null || params.length != 1) {
+ continue;
+ }
+
+ // this might be considered, if it is an overload, drop out of check
+ if (activation != null) {
+ return;
+ }
+
+ // consider this method for further checks
+ activation = methods[i];
+ }
+
+ // no activation method found
+ if (activation == null) {
+ return;
+ }
+
+ // check protected
+ if (activation.isPublic()) {
+ warnings.add(this.getMessage("Activation method " + activation.getName() + " should be declared protected"));
+ } else if (!activation.isProtected()) {
+ warnings.add(this.getMessage("Activation method " + activation.getName() + " has wrong qualifier, public or protected required"));
+ }
+
+ // check paramter (we know there is exactly one)
+ JavaParameter param = activation.getParameters()[0];
+ if (!"org.osgi.service.component.ComponentContext".equals(param.getType())) {
+ warnings.add(this.getMessage("Activation method " + methodName + " has wrong argument type " + param.getType()));
+ }
+ }
+
+}
Propchange: felix/sandbox/cziegeler/maven-scr-plugin/src/main/java/org/apache/felix/sandbox/scrplugin/om/Component.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: felix/sandbox/cziegeler/maven-scr-plugin/src/main/java/org/apache/felix/sandbox/scrplugin/om/Component.java
------------------------------------------------------------------------------
svn:keywords = author date id revision url
Added: felix/sandbox/cziegeler/maven-scr-plugin/src/main/java/org/apache/felix/sandbox/scrplugin/om/Components.java
URL: http://svn.apache.org/viewvc/felix/sandbox/cziegeler/maven-scr-plugin/src/main/java/org/apache/felix/sandbox/scrplugin/om/Components.java?view=auto&rev=562487
==============================================================================
--- felix/sandbox/cziegeler/maven-scr-plugin/src/main/java/org/apache/felix/sandbox/scrplugin/om/Components.java (added)
+++ felix/sandbox/cziegeler/maven-scr-plugin/src/main/java/org/apache/felix/sandbox/scrplugin/om/Components.java Fri Aug 3 07:47:31 2007
@@ -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.sandbox.scrplugin.om;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * <code>Components</code>...
+ *
+ * Components is just a collection of {@link Component}s.
+ */
+public class Components {
+
+ protected List components = new ArrayList();
+
+ public List getComponents() {
+ return this.components;
+ }
+
+ public void setComponents(List components) {
+ this.components = components;
+ }
+
+ public void addComponent(Component component) {
+ this.components.add(component);
+ }
+}
Propchange: felix/sandbox/cziegeler/maven-scr-plugin/src/main/java/org/apache/felix/sandbox/scrplugin/om/Components.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: felix/sandbox/cziegeler/maven-scr-plugin/src/main/java/org/apache/felix/sandbox/scrplugin/om/Components.java
------------------------------------------------------------------------------
svn:keywords = author date id revision url
Added: felix/sandbox/cziegeler/maven-scr-plugin/src/main/java/org/apache/felix/sandbox/scrplugin/om/Implementation.java
URL: http://svn.apache.org/viewvc/felix/sandbox/cziegeler/maven-scr-plugin/src/main/java/org/apache/felix/sandbox/scrplugin/om/Implementation.java?view=auto&rev=562487
==============================================================================
--- felix/sandbox/cziegeler/maven-scr-plugin/src/main/java/org/apache/felix/sandbox/scrplugin/om/Implementation.java (added)
+++ felix/sandbox/cziegeler/maven-scr-plugin/src/main/java/org/apache/felix/sandbox/scrplugin/om/Implementation.java Fri Aug 3 07:47:31 2007
@@ -0,0 +1,48 @@
+/*
+ * 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.sandbox.scrplugin.om;
+
+/**
+ * <code>Implementation</code>...
+ *
+ * contains the class name implementing the component.
+ */
+public class Implementation {
+
+ /** The class name. */
+ protected String classname;
+
+ public Implementation() {
+ // nothing to do
+ }
+
+ public Implementation(String name) {
+ this.classname = name;
+ }
+
+ public String getClassame() {
+ return this.classname;
+ }
+
+ public void setClassname(String name) {
+ this.classname = name;
+ }
+
+
+}
Propchange: felix/sandbox/cziegeler/maven-scr-plugin/src/main/java/org/apache/felix/sandbox/scrplugin/om/Implementation.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: felix/sandbox/cziegeler/maven-scr-plugin/src/main/java/org/apache/felix/sandbox/scrplugin/om/Implementation.java
------------------------------------------------------------------------------
svn:keywords = author date id revision url
Added: felix/sandbox/cziegeler/maven-scr-plugin/src/main/java/org/apache/felix/sandbox/scrplugin/om/Interface.java
URL: http://svn.apache.org/viewvc/felix/sandbox/cziegeler/maven-scr-plugin/src/main/java/org/apache/felix/sandbox/scrplugin/om/Interface.java?view=auto&rev=562487
==============================================================================
--- felix/sandbox/cziegeler/maven-scr-plugin/src/main/java/org/apache/felix/sandbox/scrplugin/om/Interface.java (added)
+++ felix/sandbox/cziegeler/maven-scr-plugin/src/main/java/org/apache/felix/sandbox/scrplugin/om/Interface.java Fri Aug 3 07:47:31 2007
@@ -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.sandbox.scrplugin.om;
+
+import java.util.List;
+
+import org.apache.felix.sandbox.scrplugin.tags.JavaClassDescription;
+import org.apache.felix.sandbox.scrplugin.tags.JavaTag;
+import org.apache.maven.plugin.MojoExecutionException;
+
+/**
+ * <code>Interface.java</code>...
+ *
+ */
+public class Interface extends AbstractObject {
+
+ protected String interfacename;
+
+ /**
+ * Default constructor.
+ */
+ public Interface() {
+ this(null);
+ }
+
+ /**
+ * Constructor from java source.
+ */
+ public Interface(JavaTag t) {
+ super(t);
+ }
+
+ public String getInterfacename() {
+ return this.interfacename;
+ }
+
+ public void setInterfacename(String name) {
+ this.interfacename = name;
+ }
+
+ /**
+ * Validate the interface.
+ * If errors occur a message is added to the issues list,
+ * warnings can be added to the warnings list.
+ */
+ public void validate(List issues, List warnings)
+ throws MojoExecutionException {
+ final JavaClassDescription javaClass = this.tag.getJavaClassDescription();
+ if (javaClass == null) {
+ issues.add(this.getMessage("Must be declared in a Java class"));
+ } else {
+
+ if ( !javaClass.isA(this.getInterfacename()) ) {
+ // interface not implemented
+ issues.add(this.getMessage("Class must implement provided interface " + this.getInterfacename()));
+ }
+ }
+ }
+}
Propchange: felix/sandbox/cziegeler/maven-scr-plugin/src/main/java/org/apache/felix/sandbox/scrplugin/om/Interface.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: felix/sandbox/cziegeler/maven-scr-plugin/src/main/java/org/apache/felix/sandbox/scrplugin/om/Interface.java
------------------------------------------------------------------------------
svn:keywords = author date id revision url
Added: felix/sandbox/cziegeler/maven-scr-plugin/src/main/java/org/apache/felix/sandbox/scrplugin/om/Property.java
URL: http://svn.apache.org/viewvc/felix/sandbox/cziegeler/maven-scr-plugin/src/main/java/org/apache/felix/sandbox/scrplugin/om/Property.java?view=auto&rev=562487
==============================================================================
--- felix/sandbox/cziegeler/maven-scr-plugin/src/main/java/org/apache/felix/sandbox/scrplugin/om/Property.java (added)
+++ felix/sandbox/cziegeler/maven-scr-plugin/src/main/java/org/apache/felix/sandbox/scrplugin/om/Property.java Fri Aug 3 07:47:31 2007
@@ -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.sandbox.scrplugin.om;
+
+import java.util.List;
+
+import org.apache.felix.sandbox.scrplugin.tags.JavaTag;
+
+/**
+ * <code>Property.java</code>...
+ *
+ */
+public class Property extends AbstractObject {
+
+ protected String name;
+ protected String value;
+ protected String type;
+ protected String text;
+
+ protected String label;
+ protected String description;
+
+ /**
+ * Default constructor.
+ */
+ public Property() {
+ this(null);
+ }
+
+ /**
+ * Constructor from java source.
+ */
+ public Property(JavaTag t) {
+ super(t);
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getValue() {
+ return this.value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ public String getType() {
+ return this.type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getText() {
+ return this.text;
+ }
+
+ public void setText(String text) {
+ this.text = text;
+ }
+
+ public String getLabel() {
+ return this.label;
+ }
+
+ public void setLabel(String label) {
+ this.label = label;
+ }
+
+ public String getDescription() {
+ return this.description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ /**
+ * Validate the property.
+ * If errors occur a message is added to the issues list,
+ * warnings can be added to the warnings list.
+ */
+ public void validate(List issues, List warnings) {
+ }
+}
Propchange: felix/sandbox/cziegeler/maven-scr-plugin/src/main/java/org/apache/felix/sandbox/scrplugin/om/Property.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: felix/sandbox/cziegeler/maven-scr-plugin/src/main/java/org/apache/felix/sandbox/scrplugin/om/Property.java
------------------------------------------------------------------------------
svn:keywords = author date id revision url
Added: felix/sandbox/cziegeler/maven-scr-plugin/src/main/java/org/apache/felix/sandbox/scrplugin/om/Reference.java
URL: http://svn.apache.org/viewvc/felix/sandbox/cziegeler/maven-scr-plugin/src/main/java/org/apache/felix/sandbox/scrplugin/om/Reference.java?view=auto&rev=562487
==============================================================================
--- felix/sandbox/cziegeler/maven-scr-plugin/src/main/java/org/apache/felix/sandbox/scrplugin/om/Reference.java (added)
+++ felix/sandbox/cziegeler/maven-scr-plugin/src/main/java/org/apache/felix/sandbox/scrplugin/om/Reference.java Fri Aug 3 07:47:31 2007
@@ -0,0 +1,104 @@
+/*
+ * 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.sandbox.scrplugin.om;
+
+import java.util.List;
+
+import org.apache.felix.sandbox.scrplugin.tags.JavaTag;
+
+/**
+ * <code>Reference.java</code>...
+ *
+ */
+public class Reference extends AbstractObject {
+
+ protected String name;
+ protected String interfacename;
+ protected String target;
+ protected String cardinality;
+ protected String policy;
+ protected String bind;
+ protected String unbind;
+
+ /**
+ * Default constructor.
+ */
+ public Reference() {
+ this(null);
+ }
+
+ /**
+ * Constructor from java source.
+ */
+ public Reference(JavaTag t) {
+ super(t);
+ }
+
+ public String getName() {
+ return this.name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+ public String getInterfacename() {
+ return this.interfacename;
+ }
+ public void setInterfacename(String interfacename) {
+ this.interfacename = interfacename;
+ }
+ public String getTarget() {
+ return this.target;
+ }
+ public void setTarget(String target) {
+ this.target = target;
+ }
+ public String getCardinality() {
+ return this.cardinality;
+ }
+ public void setCardinality(String cardinality) {
+ this.cardinality = cardinality;
+ }
+ public String getPolicy() {
+ return this.policy;
+ }
+ public void setPolicy(String policy) {
+ this.policy = policy;
+ }
+ public String getBind() {
+ return this.bind;
+ }
+ public void setBind(String bind) {
+ this.bind = bind;
+ }
+ public String getUnbind() {
+ return this.unbind;
+ }
+ public void setUnbind(String unbind) {
+ this.unbind = unbind;
+ }
+
+ /**
+ * Validate the property.
+ * If errors occur a message is added to the issues list,
+ * warnings can be added to the warnings list.
+ */
+ public void validate(List issues, List warnings) {
+ }
+
+}
Propchange: felix/sandbox/cziegeler/maven-scr-plugin/src/main/java/org/apache/felix/sandbox/scrplugin/om/Reference.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: felix/sandbox/cziegeler/maven-scr-plugin/src/main/java/org/apache/felix/sandbox/scrplugin/om/Reference.java
------------------------------------------------------------------------------
svn:keywords = author date id revision url
Added: felix/sandbox/cziegeler/maven-scr-plugin/src/main/java/org/apache/felix/sandbox/scrplugin/om/Service.java
URL: http://svn.apache.org/viewvc/felix/sandbox/cziegeler/maven-scr-plugin/src/main/java/org/apache/felix/sandbox/scrplugin/om/Service.java?view=auto&rev=562487
==============================================================================
--- felix/sandbox/cziegeler/maven-scr-plugin/src/main/java/org/apache/felix/sandbox/scrplugin/om/Service.java (added)
+++ felix/sandbox/cziegeler/maven-scr-plugin/src/main/java/org/apache/felix/sandbox/scrplugin/om/Service.java Fri Aug 3 07:47:31 2007
@@ -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.sandbox.scrplugin.om;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.maven.plugin.MojoExecutionException;
+
+/**
+ * <code>Service</code>...
+ *
+ */
+public class Service {
+
+ protected String servicefactory;
+
+ protected List interfaces = new ArrayList();
+
+ /**
+ * Default constructor.
+ */
+ public Service() {
+ // nothing to do
+ }
+
+ public String getServicefactory() {
+ return this.servicefactory;
+ }
+
+ public void setServicefactory(String servicefactory) {
+ this.servicefactory = servicefactory;
+ }
+
+ public List getInterfaces() {
+ return this.interfaces;
+ }
+
+ public void setInterfaces(List interfaces) {
+ this.interfaces = interfaces;
+ }
+
+ public void addInterface(Interface interf) {
+ this.interfaces.add(interf);
+ }
+
+ /**
+ * Validate the service.
+ * If errors occur a message is added to the issues list,
+ * warnings can be added to the warnings list.
+ */
+ public void validate(List issues, List warnings)
+ throws MojoExecutionException {
+ final Iterator i = this.interfaces.iterator();
+ while ( i.hasNext() ) {
+ final Interface interf = (Interface)i.next();
+ interf.validate(issues, warnings);
+ }
+ }
+
+}
Propchange: felix/sandbox/cziegeler/maven-scr-plugin/src/main/java/org/apache/felix/sandbox/scrplugin/om/Service.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: felix/sandbox/cziegeler/maven-scr-plugin/src/main/java/org/apache/felix/sandbox/scrplugin/om/Service.java
------------------------------------------------------------------------------
svn:keywords = author date id revision url