You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cl...@apache.org on 2007/06/24 19:44:57 UTC
svn commit: r550265 [2/2] - in /felix/trunk: ./ ipojo/arch/
ipojo/arch/src/main/resources/ ipojo/core/
ipojo/core/src/main/java/org/apache/felix/ipojo/
ipojo/core/src/main/java/org/apache/felix/ipojo/composite/service/importer/
ipojo/core/src/main/java...
Modified: felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedServiceHandler.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedServiceHandler.java?view=diff&rev=550265&r1=550264&r2=550265
==============================================================================
--- felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedServiceHandler.java (original)
+++ felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedServiceHandler.java Sun Jun 24 10:44:53 2007
@@ -27,6 +27,8 @@
import org.apache.felix.ipojo.architecture.HandlerDescription;
import org.apache.felix.ipojo.architecture.PropertyDescription;
import org.apache.felix.ipojo.metadata.Element;
+import org.apache.felix.ipojo.parser.FieldMetadata;
+import org.apache.felix.ipojo.parser.ManipulationMetadata;
import org.apache.felix.ipojo.parser.ParseUtils;
import org.apache.felix.ipojo.util.Logger;
import org.osgi.framework.Constants;
@@ -97,13 +99,14 @@
public void configure(InstanceManager im, Element componentMetadata, Dictionary configuration) {
// Fix the instance manager & clean the provided service list
m_manager = im;
+
+ ManipulationMetadata manipulation = new ManipulationMetadata(componentMetadata);
ComponentDescription cd = im.getComponentDescription();
m_providedServices = new ProvidedService[0];
// Create the dependency according to the component metadata
Element[] providedServices = componentMetadata.getElements("Provides");
- Element manipulation = componentMetadata.getElements("Manipulation")[0];
for (int i = 0; i < providedServices.length; i++) {
// Create a ProvidedServiceMetadata object
@@ -111,13 +114,9 @@
String[] serviceSpecification = new String[0];
if (providedServices[i].containsAttribute("interface")) {
String serviceSpecificationStr = providedServices[i].getAttribute("interface");
- // Get serviceSpecification if exist in the metadata
serviceSpecification = ParseUtils.parseArrays(serviceSpecificationStr);
} else {
- serviceSpecification = new String[manipulation.getElements("Interface").length];
- for (int j = 0; j < manipulation.getElements("Interface").length; j++) {
- serviceSpecification[j] = manipulation.getElements("Interface")[j].getAttribute("name");
- }
+ serviceSpecification = manipulation.getInterfaces();
}
if (serviceSpecification.length == 0) {
m_manager.getFactory().getLogger().log(Logger.ERROR,
@@ -194,7 +193,7 @@
}
if (providedServices.length > 0) {
- String[] fields = new String[0];
+ FieldMetadata[] fields = new FieldMetadata[0];
for (int i = 0; i < m_providedServices.length; i++) {
ProvidedService ps = m_providedServices[i];
for (int j = 0; j < ps.getProperties().length; j++) {
@@ -210,15 +209,15 @@
}
}
if (prop.getField() != null) {
- String[] newFields = new String[fields.length + 1];
+ FieldMetadata[] newFields = new FieldMetadata[fields.length + 1];
System.arraycopy(fields, 0, newFields, 0, fields.length);
- newFields[fields.length] = prop.getField();
+ newFields[fields.length] = manipulation.getField(prop.getField());
fields = newFields;
}
}
}
- m_manager.register(this, fields);
+ m_manager.register(this, fields, null);
}
}
@@ -230,48 +229,39 @@
* @param manipulation : componenet-type manipulation metadata.
* @return true if the provided service is correct
*/
- private boolean checkProvidedService(ProvidedService ps, Element manipulation) {
+ private boolean checkProvidedService(ProvidedService ps, ManipulationMetadata manipulation) {
for (int i = 0; i < ps.getServiceSpecification().length; i++) {
- boolean b = false;
- for (int ii = 0; ii < manipulation.getElements("Interface").length; ii++) {
- if (manipulation.getElements("Interface")[ii].getAttribute("name").equals(ps.getServiceSpecification()[i])) {
- b = true;
- }
- }
- if (!b) {
- m_manager.getFactory().getLogger().log(
- Logger.ERROR,
- "[" + m_manager.getClassName() + "] The service specification " + ps.getServiceSpecification()[i]
+ if (! manipulation.isInterfaceImplemented(ps.getServiceSpecification()[i])) {
+ m_manager.getFactory().getLogger().log(Logger.ERROR, "[" + m_manager.getClassName() + "] The service specification " + ps.getServiceSpecification()[i]
+ " is not implemented by the component class");
return false;
}
-
}
- // Fix internal property type
- for (int i = 0; i < ps.getProperties().length; i++) {
- Property prop = ps.getProperties()[i];
- String field = prop.getField();
-
- if (field == null) {
- return true; // Static dependency -> Nothing to check
- } else {
- String type = null;
- for (int j = 0; j < manipulation.getElements("Field").length; j++) {
- if (field.equals(manipulation.getElements("Field")[j].getAttribute("name"))) {
- type = manipulation.getElements("Field")[j].getAttribute("type");
- break;
- }
- }
- if (type == null) {
- m_manager.getFactory().getLogger().log(Logger.ERROR,
- "[" + m_manager.getClassName() + "] A declared property was not found in the class : " + prop.getField());
- return false;
- }
- prop.setType(type); // Set the type
- }
- }
+// // Fix internal property type
+// for (int i = 0; i < ps.getProperties().length; i++) {
+// Property prop = ps.getProperties()[i];
+// String field = prop.getField();
+//
+// if (field == null) {
+// return true; // Static property -> Nothing to check
+// } else {
+// String type = null;
+// for (int j = 0; j < manipulation.getElements("Field").length; j++) {
+// if (field.equals(manipulation.getElements("Field")[j].getAttribute("name"))) {
+// type = manipulation.getElements("Field")[j].getAttribute("type");
+// break;
+// }
+// }
+// if (type == null) {
+// m_manager.getFactory().getLogger().log(Logger.ERROR,
+// "[" + m_manager.getClassName() + "] A declared property was not found in the class : " + prop.getField());
+// return false;
+// }
+// prop.setType(type); // Set the type
+// }
+// }
return true;
}
Modified: felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/parser/MethodMetadata.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/parser/MethodMetadata.java?view=diff&rev=550265&r1=550264&r2=550265
==============================================================================
--- felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/parser/MethodMetadata.java (original)
+++ felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/parser/MethodMetadata.java Sun Jun 24 10:44:53 2007
@@ -62,5 +62,22 @@
public String[] getMethodArguments() { return m_arguments; }
public String getMethodReturn() { return m_return; }
+
+ /**
+ * Get the method unique identifier. For internal usage only.
+ * @return the method identifier.
+ */
+ public String getMethodIdentifier() {
+ String id = m_name;
+ for (int i = 0; i < m_arguments.length; i++) {
+ String cn = m_arguments[i];
+ if (cn.endsWith("[]")) {
+ cn = cn.replace("[]", "$");
+ }
+ cn = cn.replace(".", "_");
+ id += cn;
+ }
+ return id;
+ }
}
Modified: felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/util/Callback.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/util/Callback.java?view=diff&rev=550265&r1=550264&r2=550265
==============================================================================
--- felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/util/Callback.java (original)
+++ felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/util/Callback.java Sun Jun 24 10:44:53 2007
@@ -316,4 +316,8 @@
return m_methodObj.invoke(instance, arg);
}
+
+ public String getMethod() {
+ return m_method;
+ }
}
Modified: felix/trunk/ipojo/plugin/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/plugin/pom.xml?view=diff&rev=550265&r1=550264&r2=550265
==============================================================================
--- felix/trunk/ipojo/plugin/pom.xml (original)
+++ felix/trunk/ipojo/plugin/pom.xml Sun Jun 24 10:44:53 2007
@@ -6,7 +6,7 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.apache.felix.ipojo.plugin</artifactId>
- <version>0.7.1-incubator-SNAPSHOT</version>
+ <version>0.7.3-incubator-SNAPSHOT</version>
<name>Apache Felix iPOJO Maven Plugin</name>
<packaging>maven-plugin</packaging>
<dependencies>
@@ -44,6 +44,11 @@
<groupId>${pom.groupId}</groupId>
<artifactId>org.apache.felix.ipojo.metadata</artifactId>
<version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>org.apache.felix.ipojo.manipulator</artifactId>
+ <version>0.7.3-incubator-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
Added: felix/trunk/ipojo/plugin/src/main/java/org/apache/felix/ipojo/plugin/ManipulatorMojo.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/plugin/src/main/java/org/apache/felix/ipojo/plugin/ManipulatorMojo.java?view=auto&rev=550265
==============================================================================
--- felix/trunk/ipojo/plugin/src/main/java/org/apache/felix/ipojo/plugin/ManipulatorMojo.java (added)
+++ felix/trunk/ipojo/plugin/src/main/java/org/apache/felix/ipojo/plugin/ManipulatorMojo.java Sun Jun 24 10:44:53 2007
@@ -0,0 +1,82 @@
+package org.apache.felix.ipojo.plugin;
+
+import java.io.File;
+
+import org.apache.felix.ipojo.manipulator.Pojoization;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+
+/**
+ * Package an OSGi jar "bundle."
+ *
+ * @author <a href="mailto:felix-dev@incubator.apache.org">Apache Felix Project</a>
+ * @version $Rev$, $Date$
+ * @goal ipojo-bundle
+ * @phase package
+ * @requiresDependencyResolution runtime
+ * @description manipulate an OSGi bundle jar to build an iPOJO bundle
+ */
+public class ManipulatorMojo extends AbstractMojo {
+
+ /**
+ * The directory for the generated JAR.
+ *
+ * @parameter expression="${project.build.directory}"
+ * @required
+ */
+ private String buildDirectory;
+
+ /**
+ * The directory containing generated classes.
+ *
+ * @parameter expression="${project.build.outputDirectory}"
+ * @required
+ * @readonly
+ */
+ private File outputDirectory;
+
+ /**
+ * The name of the generated JAR file.
+ *
+ * @parameter alias="jarName" expression="${project.build.finalName}"
+ * @required
+ */
+ private String jarName;
+
+ /**
+ * @parameter expression="${metadata}" default-value="metadata.xml"
+ */
+ private String metadata;
+
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ getLog().info("Start bundle manipulation");
+
+ // Get metadata file
+ File meta = new File(outputDirectory + "\\" + metadata);
+ getLog().info("Metadata File : " + meta.getAbsolutePath());
+ if(!meta.exists()) {
+ throw new MojoExecutionException("the specified metadata file does not exists");
+ }
+
+ // Get input bundle
+ File in = new File(buildDirectory + "\\" + jarName + ".jar" );
+ getLog().info("Input Bundle File : " + in.getAbsolutePath());
+ if(!in.exists()) {
+ throw new MojoExecutionException("the specified bundle file does not exists");
+ }
+
+ File out = new File(buildDirectory + "\\_out.jar");
+
+ Pojoization pojo = new Pojoization();
+ pojo.pojoization(in, out, meta);
+ for(int i = 0; i < pojo.getWarnings().size(); i++) {
+ getLog().warn((String) pojo.getWarnings().get(i));
+ }
+ if(pojo.getErrors().size() > 0 ) { throw new MojoExecutionException((String) pojo.getErrors().get(0)); }
+ in.delete();
+ out.renameTo(in);
+ getLog().info("Bundle manipulation - SUCCESS");
+ }
+
+}
Modified: felix/trunk/ipojo/plugin/src/main/resources/archetype-resources/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/plugin/src/main/resources/archetype-resources/pom.xml?view=diff&rev=550265&r1=550264&r2=550265
==============================================================================
--- felix/trunk/ipojo/plugin/src/main/resources/archetype-resources/pom.xml (original)
+++ felix/trunk/ipojo/plugin/src/main/resources/archetype-resources/pom.xml Sun Jun 24 10:44:53 2007
@@ -10,15 +10,27 @@
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.plugin</artifactId>
+ <artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
- <osgiManifest>
- <bundleName>${pom.name}</bundleName>
- <bundleDescription>$YOUR_BUNDLE_DESCRIPTION</bundleDescription>
- <iPOJOMetadata>metadata.xml</iPOJOMetadata>
- </osgiManifest>
+ <instructions>
+ <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
+ <Private-Package>YOUR_PRIVATE_PACKAGES</Private-Package>
+ <Import-Package>*</Import-Package> <!-- YOUR_IMPORTED_PACKAGES -->
+ <Export-Package>*</Export-Package> <!-- YOUR_EXPORTED_PACKAGES -->
+ </instructions>
</configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.ipojo.plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>ipojo-bundle</goal>
+ </goals>
+ </execution>
+ </executions>
</plugin>
</plugins>
</build>
Modified: felix/trunk/ipojo/plugin/src/main/resources/archetype-resources/src/main/resources/metadata.xml
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/plugin/src/main/resources/archetype-resources/src/main/resources/metadata.xml?view=diff&rev=550265&r1=550264&r2=550265
==============================================================================
--- felix/trunk/ipojo/plugin/src/main/resources/archetype-resources/src/main/resources/metadata.xml (original)
+++ felix/trunk/ipojo/plugin/src/main/resources/archetype-resources/src/main/resources/metadata.xml Sun Jun 24 10:44:53 2007
@@ -3,4 +3,5 @@
<component className="$YOUR_COMPONENT_CLASS">
</component>
+ <instance component="$YOUR_COMPONENT_CLASS"/>
</iPOJO>
Modified: felix/trunk/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/pom.xml?view=diff&rev=550265&r1=550264&r2=550265
==============================================================================
--- felix/trunk/pom.xml (original)
+++ felix/trunk/pom.xml Sun Jun 24 10:44:53 2007
@@ -97,6 +97,8 @@
<modules>
<module>bundleplugin</module>
<module>tools/maven2/maven-osgi-plugin</module>
+ <module>ipojo/metadata</module>
+ <module>ipojo/manipulator</module>
<module>ipojo/plugin</module>
</modules>
</profile>
@@ -110,7 +112,7 @@
</property>
</activation>
<modules>
- <module>ipojo/arch</module>
+ <!--<module>ipojo/arch</module>-->
</modules>
</profile>
@@ -145,7 +147,7 @@
<module>wireadmin</module>
<module>ipojo/core</module>
- <module>ipojo/metadata</module>
+ <module>ipojo/arch</module>
</modules>
</profile>