Commit the new iPOJO version (0.7.6).
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@642265 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ipojo/arch/pom.xml b/ipojo/arch/pom.xml
index f2505e9..bd4b56b 100644
--- a/ipojo/arch/pom.xml
+++ b/ipojo/arch/pom.xml
@@ -1,80 +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.
+ 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.
-->
<project>
- <parent>
- <groupId>org.apache.felix</groupId>
- <artifactId>felix</artifactId>
- <version>1.0.2</version>
- <relativePath>../../pom/pom.xml</relativePath>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <packaging>bundle</packaging>
- <name>Apache Felix iPOJO Arch Command</name>
- <version>0.7.5-SNAPSHOT</version>
- <artifactId>org.apache.felix.ipojo.arch</artifactId>
- <dependencies>
- <dependency>
- <groupId>${pom.groupId}</groupId>
- <artifactId>org.apache.felix.ipojo</artifactId>
- <version>${pom.version}</version>
- </dependency>
- <dependency>
- <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.shell</artifactId>
- <version>1.1.0-SNAPSHOT</version>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <version>1.4.0</version>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Bundle-Name>iPOJO Arch Command</Bundle-Name>
- <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
- <Private-Package>org.apache.felix.ipojo.arch</Private-Package>
- </instructions>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-ipojo-plugin</artifactId>
- <version>${pom.version}</version>
- <executions>
- <execution>
- <goals>
- <goal>ipojo-bundle</goal>
- </goals>
- <configuration>
- <ignoreAnnotations>true</ignoreAnnotations>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
+ <parent>
+ <artifactId>iPOJO</artifactId>
+ <groupId>org.apache.felix</groupId>
+ <version>0.7.6-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <packaging>bundle</packaging>
+ <name>Apache Felix iPOJO Arch Command</name>
+ <artifactId>org.apache.felix.ipojo.arch</artifactId>
+ <dependencies>
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>org.apache.felix.ipojo</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <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.shell</artifactId>
+ <version>1.0.0</version>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>1.4.0</version>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Bundle-Name>
+ iPOJO Arch Felix Command
+ </Bundle-Name>
+ <Bundle-SymbolicName>
+ ${pom.artifactId}
+ </Bundle-SymbolicName>
+ <Private-Package>
+ org.apache.felix.ipojo.arch
+ </Private-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-ipojo-plugin</artifactId>
+ <version>${pom.version}</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>ipojo-bundle</goal>
+ </goals>
+ <configuration>
+ <ignoreAnnotations>true</ignoreAnnotations>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
</project>
diff --git a/ipojo/arch/src/main/java/org/apache/felix/ipojo/arch/ArchCommandImpl.java b/ipojo/arch/src/main/java/org/apache/felix/ipojo/arch/ArchCommandImpl.java
index d26522f..26b528d 100644
--- a/ipojo/arch/src/main/java/org/apache/felix/ipojo/arch/ArchCommandImpl.java
+++ b/ipojo/arch/src/main/java/org/apache/felix/ipojo/arch/ArchCommandImpl.java
@@ -19,7 +19,10 @@
package org.apache.felix.ipojo.arch;
import java.io.PrintStream;
+import java.lang.reflect.Field;
+import java.util.List;
+import org.apache.felix.ipojo.IPojoFactory;
import org.apache.felix.ipojo.ComponentInstance;
import org.apache.felix.ipojo.Factory;
import org.apache.felix.ipojo.HandlerFactory;
@@ -29,25 +32,17 @@
/**
* Implementation of the arch command printing the actual architecture.
- *
* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
*/
public class ArchCommandImpl implements Command {
- /**
- * List of arch service.
- */
+ /** List of arch services. */
private Architecture[] m_archs;
- /**
- * Factory services.
- */
+ /** Factory services. */
private Factory[] m_factories;
-
- /**
- * Handler Factories.
- */
+ /** Handler Factories. */
private Factory[] m_handlers;
/**
@@ -60,7 +55,7 @@
}
/**
- * Get help message.
+ * Gets help message.
* @return the command usage.
* @see org.apache.felix.shell.Command#getUsage()
*/
@@ -69,7 +64,7 @@
}
/**
- * Get a small description.
+ * Gets a small description.
* @return get a description.
* @see org.apache.felix.shell.Command#getShortDescription()
*/
@@ -78,7 +73,7 @@
}
/**
- * Execute the arch command.
+ * Executes the arch command.
* @param line : command line
* @param out : the default output stream
* @param err : the error output stream
@@ -113,15 +108,41 @@
printHandlers(out);
return;
}
+
+ if (line2.startsWith("-stats")) {
+ printStats(out);
+ return;
+ }
err.println(getUsage());
}
/**
- * Print instance list.
- *
- * @param out :
- * default print stream
+ * Prints the statistics.
+ * @param out the out
+ */
+ private void printStats(PrintStream out) {
+ try {
+ Field field = IPojoFactory.class.getDeclaredField("m_instancesName");
+ field.setAccessible(true); // The field is not accessible.
+ List names = (List) field.get(null);
+ out.println("Number of living instances : " + names.size());
+ out.println("Created instances : " + names);
+ } catch (SecurityException e) {
+ out.println("Cannot compute stats : " + e.getMessage());
+ } catch (IllegalArgumentException e) {
+ out.println("Cannot compute stats : " + e.getMessage());
+ } catch (IllegalAccessException e) {
+ out.println("Cannot compute stats : " + e.getMessage());
+ } catch (NoSuchFieldException e) {
+ out.println("Cannot compute stats : " + e.getMessage());
+ }
+
+ }
+
+ /**
+ * Prints instance list.
+ * @param out : default print stream
*/
private void printInstances(PrintStream out) {
for (int i = 0; i < m_archs.length; i++) {
@@ -139,7 +160,7 @@
}
/**
- * Print instance description.
+ * Prints instance description.
* @param name : instance name
* @param out : default print stream
* @param err : error print stream (if the instance is not found)
@@ -156,7 +177,7 @@
}
/**
- * Print Factory information.
+ * Prints factories.
* @param out : output stream
*/
private void printFactories(PrintStream out) {
@@ -170,7 +191,7 @@
}
/**
- * Print factory description.
+ * Prints factory description.
* @param name : factory name
* @param out : default print stream
* @param err : error print stream (if the factory is not found)
@@ -186,7 +207,7 @@
}
/**
- * Print the list of available handlers (and validity).
+ * Prints the list of available handlers (and validity).
* @param out : default print stream
*/
private void printHandlers(PrintStream out) {
diff --git a/ipojo/arch/src/main/resources/metadata.xml b/ipojo/arch/src/main/resources/metadata.xml
index f605ec4..d49d553 100644
--- a/ipojo/arch/src/main/resources/metadata.xml
+++ b/ipojo/arch/src/main/resources/metadata.xml
@@ -1,10 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<iPOJO>
- <Component className="org.apache.felix.ipojo.arch.ArchCommandImpl" factory="false">
- <Provides/>
- <Requires field="m_archs" optional="true"/>
- <Requires field="m_factories" optional="true" filter="(!(handler.name=*))"/>
- <Requires field="m_handlers" optional="true" filter="(handler.name=*)"/>
+ <Component className="org.apache.felix.ipojo.arch.ArchCommandImpl"
+ factory="false">
+ <Provides />
+ <Requires field="m_archs" optional="true" />
+ <Requires field="m_factories" optional="true"
+ filter="(!(handler.name=*))" />
+ <Requires field="m_handlers" optional="true"
+ filter="(handler.name=*)" />
</Component>
- <instance component="org.apache.felix.ipojo.arch.ArchCommandImpl" name="ArchCommand"/>
+ <instance component="org.apache.felix.ipojo.arch.ArchCommandImpl"
+ name="ArchCommand" />
</iPOJO>
\ No newline at end of file