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/examples/property-handler/PropertyHandlerTest/metadata.xml b/ipojo/examples/property-handler/PropertyHandlerTest/metadata.xml
new file mode 100644
index 0000000..dcc9c16
--- /dev/null
+++ b/ipojo/examples/property-handler/PropertyHandlerTest/metadata.xml
@@ -0,0 +1,21 @@
+<ipojo xmlns:props="example.handler.properties">
+
+ <!-- Declare a component using your handler -->
+ <component
+ classname="org.apache.felix.ipojo.handler.properties.example.PropertiesTester">
+ <callback transition="validate" method="start" />
+ <callback transition="invalidate" method="stop" />
+ <!-- declare our handler -->
+ <props:properties file="props\properties.txt" />
+ </component>
+
+ <!-- Declare an instance -->
+ <instance component="annotationTester" />
+ <instance
+ component="org.apache.felix.ipojo.handler.properties.example.PropertiesTester"
+ name="i1">
+ <property name="properties.file"
+ value="props\properties-i1.txt" />
+ </instance>
+
+</ipojo>
diff --git a/ipojo/examples/property-handler/PropertyHandlerTest/pom.xml b/ipojo/examples/property-handler/PropertyHandlerTest/pom.xml
new file mode 100644
index 0000000..dc28218
--- /dev/null
+++ b/ipojo/examples/property-handler/PropertyHandlerTest/pom.xml
@@ -0,0 +1,83 @@
+<!--
+ 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>ipojo.examples</groupId>
+ <artifactId>ipojo.examples.property.handler</artifactId>
+ <version>0.7.6-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <packaging>bundle</packaging>
+ <name>Apache Felix iPOJO Property Handler Test</name>
+ <artifactId>
+ org.apache.felix.ipojo.example.handler.property.test
+ </artifactId>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.ipojo.annotations</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>ipojo.examples</groupId>
+ <artifactId>
+ org.apache.felix.ipojo.example.handler.property
+ </artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>1.4.0</version>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Private-Package>
+ org.apache.felix.ipojo.handler.properties.example
+ </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>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/ipojo/examples/property-handler/PropertyHandlerTest/props/properties-i1.txt b/ipojo/examples/property-handler/PropertyHandlerTest/props/properties-i1.txt
new file mode 100644
index 0000000..7d688d2
--- /dev/null
+++ b/ipojo/examples/property-handler/PropertyHandlerTest/props/properties-i1.txt
@@ -0,0 +1,4 @@
+#
+#Sun Nov 18 20:33:54 CET 2007
+m_property2=foo - 18 nov. 2007 20\:32\:55 - 18 nov. 2007 20\:33\:51
+m_property1=bar - 18 nov. 2007 20\:32\:55 - 18 nov. 2007 20\:33\:51
diff --git a/ipojo/examples/property-handler/PropertyHandlerTest/props/properties.txt b/ipojo/examples/property-handler/PropertyHandlerTest/props/properties.txt
new file mode 100644
index 0000000..2d46de8
--- /dev/null
+++ b/ipojo/examples/property-handler/PropertyHandlerTest/props/properties.txt
@@ -0,0 +1,4 @@
+#
+#Sun Nov 18 20:33:54 CET 2007
+m_property2=prop2 - 18 nov. 2007 20\:32\:55 - 18 nov. 2007 20\:33\:51
+m_property1=prop1 - 18 nov. 2007 20\:32\:55 - 18 nov. 2007 20\:33\:51
diff --git a/ipojo/examples/property-handler/PropertyHandlerTest/src/main/java/org/apache/felix/ipojo/handler/properties/example/AnnotationPropertiesTester.java b/ipojo/examples/property-handler/PropertyHandlerTest/src/main/java/org/apache/felix/ipojo/handler/properties/example/AnnotationPropertiesTester.java
new file mode 100644
index 0000000..0f3df8d
--- /dev/null
+++ b/ipojo/examples/property-handler/PropertyHandlerTest/src/main/java/org/apache/felix/ipojo/handler/properties/example/AnnotationPropertiesTester.java
@@ -0,0 +1,83 @@
+/*
+ * 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.ipojo.handler.properties.example;
+
+import java.text.DateFormat;
+import java.util.Date;
+
+import org.apache.felix.ipojo.annotations.Component;
+import org.apache.felix.ipojo.annotations.Invalidate;
+import org.apache.felix.ipojo.annotations.Validate;
+
+import example.handler.properties.Properties;
+
+/**
+ * A simple component implementation using the property handler.
+ *@author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+@Component(name = "annotationTester")
+@Properties(file = "props\\properties.txt")
+public class AnnotationPropertiesTester {
+
+ /**
+ * Property 1 : injected.
+ */
+ private String m_property1;
+
+ /**
+ * Property 1 : injected.
+ */
+ private String m_property2;
+
+ /**
+ * Start method :
+ * displays loaded & injected properties before modifying them.
+ */
+ @Validate
+ public void start() {
+ System.out.println("AnnotationPropertiesTester is starting ...");
+ System.out.println("Property 1 : " + m_property1);
+ System.out.println("Property 2 : " + m_property2);
+
+ updateProperties();
+ }
+
+ /**
+ * Stop method :
+ * displays properties values.
+ */
+ @Invalidate
+ public void stop() {
+ System.out.println("AnnotationPropertiesTester is stopping ...");
+ System.out.println("Property 1 : " + m_property1);
+ System.out.println("Property 2 : " + m_property2);
+ }
+
+ /**
+ * Update property value.
+ */
+ private void updateProperties() {
+ System.out.println("Update properties");
+ Date date = new Date();
+ DateFormat df = DateFormat.getDateTimeInstance();
+ m_property1 = m_property1 + " - " + df.format(date);
+ m_property2 = m_property2 + " - " + df.format(date);
+
+ }
+}
diff --git a/ipojo/examples/property-handler/PropertyHandlerTest/src/main/java/org/apache/felix/ipojo/handler/properties/example/PropertiesTester.java b/ipojo/examples/property-handler/PropertyHandlerTest/src/main/java/org/apache/felix/ipojo/handler/properties/example/PropertiesTester.java
new file mode 100644
index 0000000..37872db
--- /dev/null
+++ b/ipojo/examples/property-handler/PropertyHandlerTest/src/main/java/org/apache/felix/ipojo/handler/properties/example/PropertiesTester.java
@@ -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.ipojo.handler.properties.example;
+
+import java.text.DateFormat;
+import java.util.Date;
+
+public class PropertiesTester {
+
+ // These two fields will be injected.
+ private String property1;
+ private String property2;
+
+ /**
+ * Starting method.
+ * This method will be called when the instance starts.
+ */
+ public void start() {
+ System.out.println("PropertiesTester is starting ...");
+ // Read the injected properties.
+ System.out.println("Property 1 : " + property1);
+ System.out.println("Property 2 : " + property2);
+
+ // Update the properties.
+ updateProperties();
+ }
+
+ /**
+ * Stopping method.
+ * This method will be called when the instance stops.
+ */
+ public void stop() {
+ System.out.println("PropertiesTester is stopping ...");
+ System.out.println("Property 1 : " + property1);
+ System.out.println("Property 2 : " + property2);
+ }
+
+ /**
+ * This method just updates managed properties.
+ * It appends the current date to the actual property value.
+ */
+ private void updateProperties() {
+ System.out.println("Update properties");
+ Date date = new Date();
+ DateFormat df = DateFormat.getDateTimeInstance();
+ // The properties will be updated in the property file
+ property1 = property1 + " - " + df.format(date);
+ property2 = property2 + " - " + df.format(date);
+
+ }
+
+}