update MAven tutorial (with XML and annotations)

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1470285 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ipojo/distributions/maven-tutorial/xml/hello.client.xml/pom.xml b/ipojo/distributions/maven-tutorial/xml/hello.client.xml/pom.xml
new file mode 100644
index 0000000..c0430fd
--- /dev/null
+++ b/ipojo/distributions/maven-tutorial/xml/hello.client.xml/pom.xml
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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 xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-tutorial</artifactId>
+        <version>1.9.0-SNAPSHOT</version>
+        <relativePath>../../pom.xml</relativePath>
+    </parent>
+
+    <packaging>bundle</packaging>
+
+    <artifactId>hello.client.xml</artifactId>
+
+    <dependencies>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>hello.service</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                        <Private-Package>
+                            ipojo.example.hello.client
+                        </Private-Package>
+                    </instructions>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-ipojo-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>ipojo-bundle</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+</project>
\ No newline at end of file
diff --git a/ipojo/distributions/maven-tutorial/xml/hello.client.xml/src/main/java/ipojo/example/hello/client/HelloClient.java b/ipojo/distributions/maven-tutorial/xml/hello.client.xml/src/main/java/ipojo/example/hello/client/HelloClient.java
new file mode 100644
index 0000000..85e2ff5
--- /dev/null
+++ b/ipojo/distributions/maven-tutorial/xml/hello.client.xml/src/main/java/ipojo/example/hello/client/HelloClient.java
@@ -0,0 +1,90 @@
+/*

+ * 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 ipojo.example.hello.client;

+

+import ipojo.example.hello.Hello;

+

+/**

+ * Hello Service simple client.

+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>

+ */

+public class HelloClient implements Runnable {

+

+    /**

+     *  Delay between two invocations. 

+     */

+    private static final int DELAY = 10000;

+    

+    /** 

+     * Hello services. 

+     * Injected by the container.

+     * */

+    private Hello[] hellos; // Service dependency

+

+    /** 

+     * End flag.

+     *  */

+    private boolean end;

+

+    /** 

+     * Name property.

+     * Injected by the container.

+     * */

+    private String name;

+

+    /**

+     * Run method.

+     * @see Runnable#run()

+     */

+    public void run() {

+        while (!end) {

+            try {

+                invokeHelloServices();

+                Thread.sleep(DELAY);

+            } catch (InterruptedException ie) {

+                /* will recheck end */

+            }

+        }

+    }

+

+    /**

+     * Invoke hello services.

+     */

+    public void invokeHelloServices() {

+        for (Hello hello : hellos) {

+            System.out.println(hello.sayHello(name));

+        }

+    }

+

+    /**

+     * Starting.

+     */

+    public void starting() {

+        Thread thread = new Thread(this);

+        end = false;

+        thread.start();

+    }

+

+    /**

+     * Stopping.

+     */

+    public void stopping() {

+        end = true;

+    }

+}

diff --git a/ipojo/distributions/maven-tutorial/xml/hello.client.xml/src/main/resources/metadata.xml b/ipojo/distributions/maven-tutorial/xml/hello.client.xml/src/main/resources/metadata.xml
new file mode 100644
index 0000000..3687ca4
--- /dev/null
+++ b/ipojo/distributions/maven-tutorial/xml/hello.client.xml/src/main/resources/metadata.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>

+<!--

+  ~ 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.

+  -->

+

+<ipojo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

+       xsi:schemaLocation="org.apache.felix.ipojo http://felix.apache.org/ipojo/schemas/CURRENT/core.xsd"

+       xmlns="org.apache.felix.ipojo">

+	<component classname="ipojo.example.hello.client.HelloClient"

+		architecture="true">

+        <!-- Declare the service dependency -->

+		<requires field="hellos" />

+

+        <!-- Lifecycle callbacks -->

+		<callback transition="validate" method="starting" />

+		<callback transition="invalidate" method="stopping" />

+

+        <!-- A simple property coming from the instance configuration -->

+        <properties>

+			<property field="name" name="name" />

+		</properties>

+	</component>

+

+    <!--

+    Declaration of an instance of the component specified above.

+    Notice the instance property 'name' setting the value of the component's property

+    -->

+	<instance component="ipojo.example.hello.client.HelloClient">

+		<property name="name" value="iPOJO" />

+	</instance>

+

+</ipojo>
\ No newline at end of file
diff --git a/ipojo/distributions/maven-tutorial/xml/hello.felix.xml/pom.xml b/ipojo/distributions/maven-tutorial/xml/hello.felix.xml/pom.xml
new file mode 100644
index 0000000..136b908
--- /dev/null
+++ b/ipojo/distributions/maven-tutorial/xml/hello.felix.xml/pom.xml
@@ -0,0 +1,103 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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 xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-tutorial</artifactId>
+        <version>1.9.0-SNAPSHOT</version>
+        <relativePath>../../pom.xml</relativePath>
+    </parent>
+
+    <artifactId>hello.felix.xml</artifactId>
+
+    <description>A project building a Felix with the XML Hello service and client</description>
+
+    <packaging>pom</packaging>
+
+    <dependencies>
+        <!-- our project  -->
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>hello.service</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>hello.impl.xml</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>hello.client.xml</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-dependency-plugin</artifactId>
+                <version>2.7</version>
+                <executions>
+
+                    <execution>
+                        <id>unpack-felix</id>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>unpack-dependencies</goal>
+                        </goals>
+                        <configuration>
+                            <includeArtifactIds>org.apache.felix.main.distribution</includeArtifactIds>
+                            <outputDirectory>${project.build.directory}</outputDirectory>
+                        </configuration>
+                    </execution>
+
+                    <execution>
+                        <id>copy-bundles</id>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>copy-dependencies</goal>
+                        </goals>
+                        <configuration>
+                            <includeArtifactIds>
+                                hello.service,
+                                hello.impl.xml,
+                                hello.client.xml,
+                                org.apache.felix.log,org.apache.felix.ipojo,
+                                org.apache.felix.ipojo.arch.gogo
+                            </includeArtifactIds>
+                            <outputDirectory>${project.build.directory}/felix-framework-${felix.version}/bundle
+                            </outputDirectory>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+
+        </plugins>
+    </build>
+
+    
+</project>
\ No newline at end of file
diff --git a/ipojo/distributions/maven-tutorial/xml/hello.impl.xml/pom.xml b/ipojo/distributions/maven-tutorial/xml/hello.impl.xml/pom.xml
new file mode 100644
index 0000000..41eabf3
--- /dev/null
+++ b/ipojo/distributions/maven-tutorial/xml/hello.impl.xml/pom.xml
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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 xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-tutorial</artifactId>
+        <version>1.9.0-SNAPSHOT</version>
+        <relativePath>../../pom.xml</relativePath>
+    </parent>
+
+    <artifactId>hello.impl.xml</artifactId>
+
+    <packaging>bundle</packaging>
+
+    <dependencies>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>hello.service</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                        <Private-Package>
+                            ipojo.example.hello.impl
+                        </Private-Package>
+                    </instructions>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-ipojo-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>ipojo-bundle</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+</project>
\ No newline at end of file
diff --git a/ipojo/distributions/maven-tutorial/xml/hello.impl.xml/src/main/java/ipojo/example/hello/impl/HelloImpl.java b/ipojo/distributions/maven-tutorial/xml/hello.impl.xml/src/main/java/ipojo/example/hello/impl/HelloImpl.java
new file mode 100644
index 0000000..6fd36e3
--- /dev/null
+++ b/ipojo/distributions/maven-tutorial/xml/hello.impl.xml/src/main/java/ipojo/example/hello/impl/HelloImpl.java
@@ -0,0 +1,36 @@
+/*

+ * 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 ipojo.example.hello.impl;

+

+import ipojo.example.hello.Hello;

+

+/**

+ * Component implementing the Hello service.

+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>

+ */

+public class HelloImpl implements Hello {

+    

+    /**

+     * Returns an 'Hello' message.

+     * @param name : name

+     * @return Hello message

+     * @see ipojo.example.hello.Hello#sayHello(String)

+     */

+    public String sayHello(String name) { return "hello " + name;  }

+}

diff --git a/ipojo/distributions/maven-tutorial/xml/hello.impl.xml/src/main/resources/metadata.xml b/ipojo/distributions/maven-tutorial/xml/hello.impl.xml/src/main/resources/metadata.xml
new file mode 100644
index 0000000..59d9666
--- /dev/null
+++ b/ipojo/distributions/maven-tutorial/xml/hello.impl.xml/src/main/resources/metadata.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>

+<iPOJO>

+	<component className="ipojo.example.hello.impl.HelloImpl"

+		name="HelloProvider" architecture="true">

+		<provides />

+	</component>

+	<instance component="HelloProvider" name="HelloService" />

+</iPOJO>
\ No newline at end of file