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/annotations/hello.client.annotations/pom.xml b/ipojo/distributions/maven-tutorial/annotations/hello.client.annotations/pom.xml
new file mode 100644
index 0000000..b4d6c95
--- /dev/null
+++ b/ipojo/distributions/maven-tutorial/annotations/hello.client.annotations/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.annotations</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/annotations/hello.client.annotations/src/main/java/ipojo/example/hello/client/HelloClient.java b/ipojo/distributions/maven-tutorial/annotations/hello.client.annotations/src/main/java/ipojo/example/hello/client/HelloClient.java
new file mode 100644
index 0000000..1170f3c
--- /dev/null
+++ b/ipojo/distributions/maven-tutorial/annotations/hello.client.annotations/src/main/java/ipojo/example/hello/client/HelloClient.java
@@ -0,0 +1,88 @@
+/*
+ * 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;
+import org.apache.felix.ipojo.annotations.*;
+
+/**
+ * A simple Hello service client. This client use annotation instead of XML metadata.
+ * If no Hello provider are available, it uses a default implementation.
+ *
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+@Component(name = "AnnotatedHelloClient")
+@Instantiate
+public class HelloClient implements Runnable {
+
+ /**
+ * Delay between two invocations.
+ */
+ private static final int DELAY = 10000;
+ /**
+ * Hello services. Injected by the container.
+ */
+ @Requires(optional = true, defaultimplementation = MyDummyHello.class)
+ private Hello hello;
+ /**
+ * End flag.
+ */
+ private boolean m_end;
+
+ /**
+ * Run method.
+ *
+ * @see Runnable#run()
+ */
+ public void run() {
+ while (!m_end) {
+ try {
+ invokeHelloServices();
+ Thread.sleep(DELAY);
+ } catch (InterruptedException ie) {
+ /* will recheck end */
+ }
+ }
+ }
+
+ /**
+ * Invoke hello services.
+ */
+ public void invokeHelloServices() {
+ System.out.println(hello.sayHello("Clement "));
+ }
+
+ /**
+ * Starting.
+ */
+ @Validate
+ public void starting() {
+ Thread thread = new Thread(this);
+ m_end = false;
+ thread.start();
+ }
+
+ /**
+ * Stopping.
+ */
+ @Invalidate
+ public void stopping() {
+ m_end = true;
+ }
+}
diff --git a/ipojo/distributions/maven-tutorial/annotations/hello.client.annotations/src/main/java/ipojo/example/hello/client/MyDummyHello.java b/ipojo/distributions/maven-tutorial/annotations/hello.client.annotations/src/main/java/ipojo/example/hello/client/MyDummyHello.java
new file mode 100644
index 0000000..16e09c3
--- /dev/null
+++ b/ipojo/distributions/maven-tutorial/annotations/hello.client.annotations/src/main/java/ipojo/example/hello/client/MyDummyHello.java
@@ -0,0 +1,30 @@
+/*
+ * 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;
+
+public class MyDummyHello implements Hello {
+
+ public String sayHello(String name) {
+ return "Bonjour";
+ }
+
+}
diff --git a/ipojo/distributions/maven-tutorial/annotations/hello.felix.annotations/pom.xml b/ipojo/distributions/maven-tutorial/annotations/hello.felix.annotations/pom.xml
new file mode 100644
index 0000000..60ac6f4
--- /dev/null
+++ b/ipojo/distributions/maven-tutorial/annotations/hello.felix.annotations/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.annotations</artifactId>
+
+ <description>A project building a Felix with the annotated 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.annotations</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>hello.client.annotations</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.annotations,
+ hello.client.annotations,
+ 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/annotations/hello.impl.annotations/pom.xml b/ipojo/distributions/maven-tutorial/annotations/hello.impl.annotations/pom.xml
new file mode 100644
index 0000000..3aa6684
--- /dev/null
+++ b/ipojo/distributions/maven-tutorial/annotations/hello.impl.annotations/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.annotations</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/annotations/hello.impl.annotations/src/main/java/ipojo/example/hello/impl/HelloImpl.java b/ipojo/distributions/maven-tutorial/annotations/hello.impl.annotations/src/main/java/ipojo/example/hello/impl/HelloImpl.java
new file mode 100644
index 0000000..93ccaa9
--- /dev/null
+++ b/ipojo/distributions/maven-tutorial/annotations/hello.impl.annotations/src/main/java/ipojo/example/hello/impl/HelloImpl.java
@@ -0,0 +1,53 @@
+/*
+ * 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;
+
+import org.apache.felix.ipojo.annotations.Component;
+import org.apache.felix.ipojo.annotations.Instantiate;
+import org.apache.felix.ipojo.annotations.Provides;
+import org.apache.felix.ipojo.annotations.ServiceProperty;
+
+/**
+ * Component implementing the Hello service.
+ * This class used annotations to describe the component type.
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+@Component
+@Provides
+@Instantiate // Declare an instance of the component
+public class HelloImpl implements Hello {
+
+
+ @ServiceProperty
+ public String boo = "boo";
+
+ @ServiceProperty
+ public String bla = "bla";
+
+
+ /**
+ * 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 + " @"; }
+}