You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by cs...@apache.org on 2016/05/09 14:48:20 UTC
[01/35] karaf-boot git commit: Initial proposal
Repository: karaf-boot
Updated Branches:
refs/heads/master [created] d941e8643
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/a0248b78/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..2c7f8ac
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+
+ <!--
+
+ 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.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-build</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+ <description>
+ Apache Karaf Boot provides a simple way to create artifacts ready to be deployed in Karaf.
+ </description>
+
+ <modules>
+ <module>karaf-boot</module>
+ <module>karaf-boot-starter</module>
+ <module>karaf-boot-tools</module>
+
+ <module>karaf-boot-parent</module>
+
+ <!-- Samples -->
+ <module>karaf-boot-samples/karaf-boot-sample-simple</module>
+ </modules>
+
+</project>
[21/35] karaf-boot git commit: [ds] add ds processor
Posted by cs...@apache.org.
[ds] add ds processor
Project: http://git-wip-us.apache.org/repos/asf/karaf-boot/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-boot/commit/52bc6849
Tree: http://git-wip-us.apache.org/repos/asf/karaf-boot/tree/52bc6849
Diff: http://git-wip-us.apache.org/repos/asf/karaf-boot/diff/52bc6849
Branch: refs/heads/master
Commit: 52bc684953128ccde771e23282173ea4238672db
Parents: 9d68baa
Author: Guillaume Nodet <gn...@apache.org>
Authored: Fri Apr 15 18:27:18 2016 +0200
Committer: Guillaume Nodet <gn...@apache.org>
Committed: Fri Apr 15 18:27:18 2016 +0200
----------------------------------------------------------------------
.../karaf-boot-starter-ds/pom.xml | 11 +++
.../apache/karaf/boot/ds/impl/DsProcessor.java | 72 ++++++++++++++++++++
.../javax.annotation.processing.Processor | 1 +
3 files changed, 84 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/52bc6849/karaf-boot-starters/karaf-boot-starter-ds/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-starters/karaf-boot-starter-ds/pom.xml b/karaf-boot-starters/karaf-boot-starter-ds/pom.xml
index 09eb983..331c8e2 100644
--- a/karaf-boot-starters/karaf-boot-starter-ds/pom.xml
+++ b/karaf-boot-starters/karaf-boot-starter-ds/pom.xml
@@ -38,4 +38,15 @@
</dependency>
</dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <compilerArgument>-proc:none</compilerArgument>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/52bc6849/karaf-boot-starters/karaf-boot-starter-ds/src/main/java/org/apache/karaf/boot/ds/impl/DsProcessor.java
----------------------------------------------------------------------
diff --git a/karaf-boot-starters/karaf-boot-starter-ds/src/main/java/org/apache/karaf/boot/ds/impl/DsProcessor.java b/karaf-boot-starters/karaf-boot-starter-ds/src/main/java/org/apache/karaf/boot/ds/impl/DsProcessor.java
new file mode 100644
index 0000000..49baa70
--- /dev/null
+++ b/karaf-boot-starters/karaf-boot-starter-ds/src/main/java/org/apache/karaf/boot/ds/impl/DsProcessor.java
@@ -0,0 +1,72 @@
+package org.apache.karaf.boot.ds.impl;
+
+import javax.annotation.processing.AbstractProcessor;
+import javax.annotation.processing.RoundEnvironment;
+import javax.lang.model.element.TypeElement;
+import javax.tools.Diagnostic.Kind;
+import javax.tools.FileObject;
+import javax.tools.StandardLocation;
+import java.io.CharArrayWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.Reader;
+import java.io.Writer;
+import java.util.HashSet;
+import java.util.Set;
+
+public class DsProcessor extends AbstractProcessor {
+
+ boolean hasRun;
+
+ public DsProcessor() {
+ }
+
+ @Override
+ public Set<String> getSupportedAnnotationTypes() {
+ Set<String> set = new HashSet<String>();
+ set.add(org.osgi.service.component.annotations.Component.class.getName());
+ return set;
+ }
+
+ @Override
+ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+ if (!hasRun) {
+ hasRun = true;
+ // Add the Karaf embedded package
+ try (PrintWriter w = appendResource("META-INF/org.apache.karaf.boot.bnd")) {
+ w.println("_dsannotations: *");
+ } catch (Exception e) {
+ processingEnv.getMessager().printMessage(Kind.ERROR, "Error: " + e.getMessage());
+ }
+ }
+ return true;
+ }
+
+ private PrintWriter appendResource(String resource) throws IOException {
+ try {
+ FileObject o = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", resource);
+ return new PrintWriter(o.openWriter());
+ } catch (Exception e) {
+ try {
+ FileObject o = processingEnv.getFiler().getResource(StandardLocation.CLASS_OUTPUT, "", resource);
+ CharArrayWriter baos = new CharArrayWriter();
+ try (Reader r = o.openReader(true)) {
+ char[] buf = new char[4096];
+ int l;
+ while ((l = r.read(buf)) > 0) {
+ baos.write(buf, 0, l);
+ }
+ }
+ o.delete();
+ o = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", resource);
+ Writer w = o.openWriter();
+ w.write(baos.toCharArray());
+ return new PrintWriter(w);
+ } catch (Exception e2) {
+ e2.addSuppressed(e);
+ e2.printStackTrace();
+ throw e2;
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/52bc6849/karaf-boot-starters/karaf-boot-starter-ds/src/main/resources/META-INF/services/javax.annotation.processing.Processor
----------------------------------------------------------------------
diff --git a/karaf-boot-starters/karaf-boot-starter-ds/src/main/resources/META-INF/services/javax.annotation.processing.Processor b/karaf-boot-starters/karaf-boot-starter-ds/src/main/resources/META-INF/services/javax.annotation.processing.Processor
new file mode 100644
index 0000000..11ef8af
--- /dev/null
+++ b/karaf-boot-starters/karaf-boot-starter-ds/src/main/resources/META-INF/services/javax.annotation.processing.Processor
@@ -0,0 +1 @@
+org.apache.karaf.boot.ds.impl.DsProcessor
[15/35] karaf-boot git commit: [jpa] Make annotations a bit more
coherent
Posted by cs...@apache.org.
[jpa] Make annotations a bit more coherent
Project: http://git-wip-us.apache.org/repos/asf/karaf-boot/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-boot/commit/dceec8d5
Tree: http://git-wip-us.apache.org/repos/asf/karaf-boot/tree/dceec8d5
Diff: http://git-wip-us.apache.org/repos/asf/karaf-boot/diff/dceec8d5
Branch: refs/heads/master
Commit: dceec8d5da3c942f34cdeacbfa3ec97d38055baa
Parents: 19a1877
Author: Guillaume Nodet <gn...@apache.org>
Authored: Fri Apr 15 10:58:15 2016 +0200
Committer: Guillaume Nodet <gn...@apache.org>
Committed: Fri Apr 15 10:58:15 2016 +0200
----------------------------------------------------------------------
.../src/main/java/sample/jpa/Task.java | 3 +-
.../org/apache/karaf/boot/jpa/Hibernate.java | 118 +++++++++----------
2 files changed, 60 insertions(+), 61 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/dceec8d5/karaf-boot-samples/karaf-boot-sample-jpa/src/main/java/sample/jpa/Task.java
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-jpa/src/main/java/sample/jpa/Task.java b/karaf-boot-samples/karaf-boot-sample-jpa/src/main/java/sample/jpa/Task.java
index 63995c0..cd431a7 100644
--- a/karaf-boot-samples/karaf-boot-sample-jpa/src/main/java/sample/jpa/Task.java
+++ b/karaf-boot-samples/karaf-boot-sample-jpa/src/main/java/sample/jpa/Task.java
@@ -28,7 +28,8 @@ import org.apache.karaf.boot.jpa.Provider;
@PersistentUnit(name = "tasklist", provider = Provider.Hibernate, properties = {
@Property(name = "hibernate.hbm2ddl.auto", value = "create-drop")
})
-@Hibernate.Dialect(Hibernate.DialectType.HSQL)
+@Hibernate.Dialect(Hibernate.Dialect.Value.HSQL)
+@Hibernate.Hbm2DdlAuto(Hibernate.Hbm2DdlAuto.Value.CreateDrop)
@Entity
@XmlRootElement
public class Task {
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/dceec8d5/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/Hibernate.java
----------------------------------------------------------------------
diff --git a/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/Hibernate.java b/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/Hibernate.java
index 06361d4..ae4dab3 100644
--- a/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/Hibernate.java
+++ b/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/Hibernate.java
@@ -20,73 +20,71 @@ public interface Hibernate {
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.SOURCE)
@interface Hbm2DdlAuto {
- Hbm2DdlAutoType value();
+ Value value();
+ enum Value {
+ Validate,
+ Update,
+ Create,
+ CreateDrop;
+
+ public String toString() {
+ return super.toString().toLowerCase();
+ }
+ }
}
@ProviderProperty("hibernate.dialect")
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.SOURCE)
@interface Dialect {
- DialectType value();
- }
-
- enum DialectType {
- Cache71,
- DataDirectOracle9,
- DB2390,
- DB2400,
- DB2,
- Derby,
- Firebird,
- FrontBase,
- H2,
- HSQL,
- Informix,
- Ingres10,
- Ingres9,
- Ingres,
- Interbase,
- JDataStore,
- Mckoi,
- MimerSQL,
- MySQL5,
- MySQL5InnoDB,
- MySQL,
- MySQLInnoDB,
- MySQLMyISAM,
- Oracle10g,
- Oracle8i,
- Oracle9,
- Oracle9i,
- Oracle,
- Pointbase,
- PostgresPlus,
- PostgreSQL,
- Progress,
- RDMSOS2200,
- SAPDB,
- SQLServer2008,
- SQLServer,
- Sybase11,
- SybaseAnywhere,
- SybaseASE15,
- Sybase,
- Teradata,
- TimesTen;
-
- public String toString() {
- return "org.hibernate.dialect." + super.toString() + "Dialect";
- }
- }
-
- enum Hbm2DdlAutoType {
- Validate,
- Update,
- Create,
- CreateDrop;
+ Value value();
+ enum Value {
+ Cache71,
+ DataDirectOracle9,
+ DB2390,
+ DB2400,
+ DB2,
+ Derby,
+ Firebird,
+ FrontBase,
+ H2,
+ HSQL,
+ Informix,
+ Ingres10,
+ Ingres9,
+ Ingres,
+ Interbase,
+ JDataStore,
+ Mckoi,
+ MimerSQL,
+ MySQL5,
+ MySQL5InnoDB,
+ MySQL,
+ MySQLInnoDB,
+ MySQLMyISAM,
+ Oracle10g,
+ Oracle8i,
+ Oracle9,
+ Oracle9i,
+ Oracle,
+ Pointbase,
+ PostgresPlus,
+ PostgreSQL,
+ Progress,
+ RDMSOS2200,
+ SAPDB,
+ SQLServer2008,
+ SQLServer,
+ Sybase11,
+ SybaseAnywhere,
+ SybaseASE15,
+ Sybase,
+ Teradata,
+ TimesTen;
- public String toString() {
- return super.toString().toLowerCase();
+ public String toString() {
+ return "org.hibernate.dialect." + super.toString() + "Dialect";
+ }
}
}
[30/35] karaf-boot git commit: Use stax for file generation
Posted by cs...@apache.org.
Use stax for file generation
Project: http://git-wip-us.apache.org/repos/asf/karaf-boot/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-boot/commit/af6327ca
Tree: http://git-wip-us.apache.org/repos/asf/karaf-boot/tree/af6327ca
Diff: http://git-wip-us.apache.org/repos/asf/karaf-boot/diff/af6327ca
Branch: refs/heads/master
Commit: af6327ca53b12afc27e573aab9dce0ddc76d9a27
Parents: 5e0846f
Author: Christian Schneider <ch...@die-schneider.net>
Authored: Mon Apr 25 18:30:19 2016 +0200
Committer: Christian Schneider <ch...@die-schneider.net>
Committed: Mon Apr 25 18:30:19 2016 +0200
----------------------------------------------------------------------
samples/jpa/pom.xml | 33 ++--
starters/karaf-boot-starter-jpa/pom.xml | 61 +++---
.../karaf/boot/jpa/impl/JpaProcessor.java | 198 +++++++++++--------
.../karaf/boot/jpa/impl/JpaProcessorTest.java | 64 ++++++
.../src/test/resources/expected_persistence.xml | 11 ++
5 files changed, 241 insertions(+), 126 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/af6327ca/samples/jpa/pom.xml
----------------------------------------------------------------------
diff --git a/samples/jpa/pom.xml b/samples/jpa/pom.xml
index 032396f..1c51404 100644
--- a/samples/jpa/pom.xml
+++ b/samples/jpa/pom.xml
@@ -1,23 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
-<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">
-
- <!--
-
- 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">
+
+ <!-- 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. -->
<modelVersion>4.0.0</modelVersion>
@@ -41,6 +35,7 @@
<version>${project.version}</version>
<extensions>true</extensions>
</plugin>
+
</plugins>
</build>
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/af6327ca/starters/karaf-boot-starter-jpa/pom.xml
----------------------------------------------------------------------
diff --git a/starters/karaf-boot-starter-jpa/pom.xml b/starters/karaf-boot-starter-jpa/pom.xml
index c0ce5b8..734714b 100644
--- a/starters/karaf-boot-starter-jpa/pom.xml
+++ b/starters/karaf-boot-starter-jpa/pom.xml
@@ -1,23 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
-<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">
+<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">
- <!--
-
- 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. -->
<modelVersion>4.0.0</modelVersion>
@@ -32,15 +26,36 @@
<dependencies>
<dependency>
- <groupId>org.osgi</groupId>
- <artifactId>osgi.cmpn</artifactId>
- <version>${osgi.version}</version>
- </dependency>
- <dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jpa_2.0_spec</artifactId>
<version>1.1</version>
</dependency>
+ <!--
+ <dependency>
+ <groupId>net.java.dev.stax-utils</groupId>
+ <artifactId>stax-utils</artifactId>
+ <version>20070216</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>jsr173-ri</artifactId>
+ <groupId>com.bea.xml</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ -->
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.12</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <version>1.10.19</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/af6327ca/starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/impl/JpaProcessor.java
----------------------------------------------------------------------
diff --git a/starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/impl/JpaProcessor.java b/starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/impl/JpaProcessor.java
index 4becbc2..ed52850 100644
--- a/starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/impl/JpaProcessor.java
+++ b/starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/impl/JpaProcessor.java
@@ -1,27 +1,26 @@
package org.apache.karaf.boot.jpa.impl;
-import javax.annotation.processing.AbstractProcessor;
-import javax.annotation.processing.Messager;
-import javax.annotation.processing.RoundEnvironment;
-import javax.lang.model.element.AnnotationMirror;
-import javax.lang.model.element.AnnotationValue;
-import javax.lang.model.element.Element;
-import javax.lang.model.element.TypeElement;
-import javax.tools.Diagnostic.Kind;
-import javax.tools.FileObject;
-import javax.tools.StandardLocation;
import java.io.IOException;
-import java.io.PrintWriter;
import java.io.Writer;
-import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import javax.annotation.processing.AbstractProcessor;
+import javax.annotation.processing.RoundEnvironment;
+import javax.lang.model.element.AnnotationMirror;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.TypeElement;
+import javax.tools.Diagnostic.Kind;
+import javax.tools.FileObject;
+import javax.tools.StandardLocation;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
import org.apache.karaf.boot.jpa.PersistentUnit;
import org.apache.karaf.boot.jpa.Property;
import org.apache.karaf.boot.jpa.Provider;
@@ -41,76 +40,93 @@ public class JpaProcessor extends AbstractProcessor {
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
Map<PersistentUnit, List<? extends AnnotationMirror>> units = new HashMap<PersistentUnit, List<? extends AnnotationMirror>>();
-
-
for (Element elem : roundEnv.getElementsAnnotatedWith(PersistentUnit.class)) {
PersistentUnit pu = elem.getAnnotation(PersistentUnit.class);
units.put(pu, elem.getAnnotationMirrors());
}
if (!units.isEmpty()) {
try {
- Set<String> puNames = new HashSet<String>();
FileObject o = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT,
- "", "META-INF/persistence.xml");
- PrintWriter w = new PrintWriter(o.openWriter());
- w.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
- w.println("<persistence version=\"2.0\" xmlns=\"http://java.sun.com/xml/ns/persistence\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd\">");
- for (PersistentUnit pu : units.keySet()) {
- if (pu.name() == null || pu.name().isEmpty()) {
- throw new IOException("Missing persistent unit name");
- }
- if (!puNames.add(pu.name())) {
- throw new IOException("Duplicate persistent unit name: " + pu.name());
- }
- w.println(" <persistence-unit name=\"" + pu.name() + "\" transaction-type=\"" + pu.transactionType().toString() + "\">");
- if (!pu.description().isEmpty()) {
- w.println(" <description>" + pu.description() + "</description>");
- }
- if (pu.provider() != Provider.Default || !pu.providerName().isEmpty()) {
- if (pu.provider() != Provider.Default && !pu.providerName().isEmpty()) {
- throw new IOException("At most one of provider and providerName can be used");
- }
- String name;
- if (!pu.providerName().isEmpty()) {
- name = pu.providerName();
- } else {
- switch (pu.provider()) {
- case Hibernate:
- name = "org.hibernate.jpa.HibernatePersistenceProvider";
- break;
- default:
- // TODO
- throw new IOException("Unsupported provider: " + pu.provider());
- }
- }
- w.println(" <provider>" + name + "</provider>");
- }
- if (!pu.jtaDataSource().isEmpty()) {
- w.println(" <jta-data-source>" + pu.jtaDataSource() + "</jta-data-source>");
- }
- if (!pu.nonJtaDataSource().isEmpty()) {
- w.println(" <non-jta-data-source>" + pu.nonJtaDataSource() + "</non-jta-data-source>");
- }
- if (pu.properties().length > 0) {
- w.println(" <properties>");
- for (Property property : pu.properties()) {
- w.println(" <property name=\"" + property.name() + "\" value=\"" + property.value() + "\"/>");
- }
+ "", "META-INF/persistence.xml");
+ process(o.openWriter(), units);
+ processingEnv.getMessager().printMessage(Kind.NOTE, "Generated META-INF/persistence.xml");
+ } catch (Exception e) {
+ processingEnv.getMessager().printMessage(Kind.ERROR, "Error: " + e.getMessage());
+ }
+ }
+ return true;
+ }
+
+ public void process(Writer writer, Map<PersistentUnit, List<? extends AnnotationMirror>> units) throws Exception {
+ Set<String> puNames = new HashSet<String>();
+ XMLOutputFactory xof = XMLOutputFactory.newInstance();
+ //XMLStreamWriter w = new IndentingXMLStreamWriter(xof.createXMLStreamWriter(writer));
+ XMLStreamWriter w = xof.createXMLStreamWriter(writer);
+ w.setDefaultNamespace("http://java.sun.com/xml/ns/persistence");
+ w.writeStartDocument();
+ w.writeStartElement("persistence");
+ w.writeAttribute("verson", "2.0");
+
+ //w.println("<persistence version=\"2.0\" xmlns=\"http://java.sun.com/xml/ns/persistence\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd\">");
+ for (PersistentUnit pu : units.keySet()) {
+ if (pu.name() == null || pu.name().isEmpty()) {
+ throw new IOException("Missing persistent unit name");
+ }
+ if (!puNames.add(pu.name())) {
+ throw new IOException("Duplicate persistent unit name: " + pu.name());
+ }
+ w.writeStartElement("persistence-unit");
+ w.writeAttribute("name", pu.name());
+ w.writeAttribute("transaction-type", pu.transactionType().toString());
+ writeElement(w, "description", pu.description());
+ String providerName = getProvider(pu);
+ writeElement(w, "provider", providerName);
+ writeElement(w, "jta-data-source", pu.jtaDataSource());
+ writeElement(w, "non-jta-data-source", pu.nonJtaDataSource());
+ Map<String, String> props = new HashMap<>();
+ addProperties(pu, props);
+ addAnnProperties(units.get(pu), props);
+ if (props.size() > 0) {
+ w.writeStartElement("properties");
+ for (String key : props.keySet()) {
+ w.writeEmptyElement("property");
+ w.writeAttribute("name", key);
+ w.writeAttribute("value", props.get(key));
+ }
+ w.writeEndElement();
+ }
+ w.writeEndElement();
+ }
+ w.writeEndElement();
+ w.writeEndDocument();
+ w.flush();
+ w.close();
+ }
+ private void addProperties(PersistentUnit pu, Map<String, String> props) {
+ if (pu.properties() == null) {
+ return;
+ }
+ for (Property property : pu.properties()) {
+ props.put(property.name(), property.value());
+ }
+ }
- for (AnnotationMirror annMirror : units.get(pu)) {
+ private void addAnnProperties(List<? extends AnnotationMirror> annotations, Map<String, String> props)
+ throws XMLStreamException {
+ for (AnnotationMirror annMirror : annotations) {
- String name = null;
- for (AnnotationMirror a : processingEnv.getElementUtils().getAllAnnotationMirrors(annMirror.getAnnotationType().asElement())) {
- if (a.toString().startsWith("@org.apache.karaf.boot.jpa.PersistentUnit.ProviderProperty")) {
- name = a.getElementValues().values().iterator().next().getValue().toString();
- break;
- }
- }
- if (name != null) {
- String value = annMirror.getElementValues().values().iterator().next().getValue().toString();
- w.println(" <property name=\"" + name + "\" value=\"" + value + "\"/>");
- }
+ String name = null;
+ for (AnnotationMirror a : processingEnv.getElementUtils().getAllAnnotationMirrors(annMirror.getAnnotationType().asElement())) {
+ if (a.toString().startsWith("@org.apache.karaf.boot.jpa.PersistentUnit.ProviderProperty")) {
+ name = a.getElementValues().values().iterator().next().getValue().toString();
+ break;
+ }
+ }
+ if (name != null) {
+ String value = annMirror.getElementValues().values().iterator().next().getValue().toString();
+ props.put(name, value);
+ }
// processingEnv.getMessager().printMessage(Kind.MANDATORY_WARNING, "Annotation: " + annMirror);
// processingEnv.getMessager().printMessage(Kind.MANDATORY_WARNING, "Annotation type: " + annMirror.getAnnotationType());
// processingEnv.getMessager().printMessage(Kind.MANDATORY_WARNING, "Annotation annot: " + annMirror.getAnnotationType().getAnnotationMirrors());
@@ -121,20 +137,34 @@ public class JpaProcessor extends AbstractProcessor {
// } else {
// processingEnv.getMessager().printMessage(Kind.MANDATORY_WARNING, "Annotation nok");
// }
- }
+ }
+ }
- w.println(" </properties>");
- }
- w.println(" </persistence-unit>");
- }
- w.println("</persistence>");
- w.close();
- processingEnv.getMessager().printMessage(Kind.NOTE, "Generated META-INF/persistence.xml");
- } catch (IOException e) {
- processingEnv.getMessager().printMessage(Kind.ERROR, "Error: " + e.getMessage());
+ private void writeElement(XMLStreamWriter w, String localName, String content) throws XMLStreamException {
+ if (content != null && !content.isEmpty()) {
+ w.writeStartElement(localName);
+ w.writeCharacters(content);
+ w.writeEndElement();
+ }
+ }
+
+ private String getProvider(PersistentUnit pu) throws IOException {
+ if (pu.provider() != Provider.Default && pu.providerName() != null && !pu.providerName().isEmpty()) {
+ throw new IOException("At most one of provider and providerName can be used");
+ }
+ if (pu.provider() != null) {
+ switch (pu.provider()) {
+ case Hibernate:
+ return "org.hibernate.jpa.HibernatePersistenceProvider";
+ default:
+ // TODO
+ throw new IOException("Unsupported provider: " + pu.provider());
}
+ } else if (pu.providerName() != null) {
+ return pu.providerName();
+ } else {
+ return null;
}
- return true;
}
}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/af6327ca/starters/karaf-boot-starter-jpa/src/test/java/org/apache/karaf/boot/jpa/impl/JpaProcessorTest.java
----------------------------------------------------------------------
diff --git a/starters/karaf-boot-starter-jpa/src/test/java/org/apache/karaf/boot/jpa/impl/JpaProcessorTest.java b/starters/karaf-boot-starter-jpa/src/test/java/org/apache/karaf/boot/jpa/impl/JpaProcessorTest.java
new file mode 100644
index 0000000..d3e683a
--- /dev/null
+++ b/starters/karaf-boot-starter-jpa/src/test/java/org/apache/karaf/boot/jpa/impl/JpaProcessorTest.java
@@ -0,0 +1,64 @@
+package org.apache.karaf.boot.jpa.impl;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.io.File;
+import java.io.StringWriter;
+import java.net.URL;
+import java.nio.charset.Charset;
+import java.nio.file.Files;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.lang.model.element.AnnotationMirror;
+
+import org.apache.karaf.boot.jpa.PersistentUnit;
+import org.apache.karaf.boot.jpa.Property;
+import org.apache.karaf.boot.jpa.Provider;
+import org.apache.karaf.boot.jpa.TransactionType;
+import org.junit.Assert;
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class JpaProcessorTest {
+
+ @Ignore
+ @Test
+ public void testProcess() throws Exception {
+ JpaProcessor processor = new JpaProcessor();
+ Map<PersistentUnit, List<? extends AnnotationMirror>> units = new HashMap<>();
+ PersistentUnit pu = getTestPersitentUnit();
+ units.put(pu, Collections.emptyList());
+ URL url = this.getClass().getResource("/expected_persistence.xml");
+ byte[] encoded = Files.readAllBytes(new File(url.toURI()).toPath());
+ String expected = new String(encoded, Charset.forName("utf-8"));
+ StringWriter writer = new StringWriter();
+ processor.process(writer, units);
+ Assert.assertEquals(expected, writer.getBuffer().toString());
+ }
+
+ private PersistentUnit getTestPersitentUnit() {
+ PersistentUnit pu = mock(PersistentUnit.class);
+ when(pu.name()).thenReturn("test-pu");
+ when(pu.provider()).thenReturn(Provider.Hibernate);
+ when(pu.transactionType()).thenReturn(TransactionType.JTA);
+ when(pu.description()).thenReturn("Some description");
+ when(pu.jtaDataSource()).thenReturn("myds");
+ Property dialect = prop("hibernate.dialect", "org.hibernate.dialect.DerbyDialect");
+ Property[] props = new Property[] { dialect };
+ when(pu.properties()).thenReturn(props);
+ return pu;
+ }
+
+ private Property prop(String name, String value) {
+ Property dialect = mock(Property.class);
+ when(dialect.name()).thenReturn(name);
+ when(dialect.value()).thenReturn(value);
+ return dialect;
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/af6327ca/starters/karaf-boot-starter-jpa/src/test/resources/expected_persistence.xml
----------------------------------------------------------------------
diff --git a/starters/karaf-boot-starter-jpa/src/test/resources/expected_persistence.xml b/starters/karaf-boot-starter-jpa/src/test/resources/expected_persistence.xml
new file mode 100644
index 0000000..8002eba
--- /dev/null
+++ b/starters/karaf-boot-starter-jpa/src/test/resources/expected_persistence.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" ?>
+<persistence verson="2.0">
+ <persistence-unit name="test-pu" transaction-type="JTA">
+ <description>Some description</description>
+ <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
+ <jta-data-source>myds</jta-data-source>
+ <properties>
+ <property name="hibernate.dialect" value="org.hibernate.dialect.DerbyDialect"/>
+ </properties>
+ </persistence-unit>
+</persistence>
[09/35] karaf-boot git commit: Fix Maven coordonates in README. Add
servlet sample
Posted by cs...@apache.org.
Fix Maven coordonates in README.
Add servlet sample
Project: http://git-wip-us.apache.org/repos/asf/karaf-boot/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-boot/commit/eb034f88
Tree: http://git-wip-us.apache.org/repos/asf/karaf-boot/tree/eb034f88
Diff: http://git-wip-us.apache.org/repos/asf/karaf-boot/diff/eb034f88
Branch: refs/heads/master
Commit: eb034f882affdf895de7bc6306de7bcbebaa1223
Parents: 1ea096c
Author: Jean-Baptiste Onofr� <jb...@apache.org>
Authored: Wed Oct 14 16:45:25 2015 +0200
Committer: Jean-Baptiste Onofr� <jb...@apache.org>
Committed: Wed Oct 14 16:45:25 2015 +0200
----------------------------------------------------------------------
.../karaf-boot-sample-config/README.md | 2 +-
.../README.md | 2 +-
.../README.md | 2 +-
.../README.md | 2 +-
.../README.md | 2 +-
.../karaf-boot-sample-servlet/README.md | 30 +++++++++++++
.../karaf-boot-sample-servlet/pom.xml | 47 ++++++++++++++++++++
.../main/java/sample/servlet/SampleServlet.java | 44 ++++++++++++++++++
.../karaf-boot-sample-shell/README.md | 2 +-
.../karaf-boot-starter-web/pom.xml | 41 +++++++++++++++++
karaf-boot-starters/pom.xml | 1 +
pom.xml | 8 ++--
12 files changed, 174 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/eb034f88/karaf-boot-samples/karaf-boot-sample-config/README.md
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-config/README.md b/karaf-boot-samples/karaf-boot-sample-config/README.md
index 6f571d5..1c8dbc5 100644
--- a/karaf-boot-samples/karaf-boot-sample-config/README.md
+++ b/karaf-boot-samples/karaf-boot-sample-config/README.md
@@ -28,4 +28,4 @@ Once scr feature installed:
Karaf deploy folder
* in the Karaf shell console, do:
- bundle:install -s mvn:karaf-boot-samples/karaf-boot-sample-config/1.0
\ No newline at end of file
+ bundle:install -s mvn:org.apache.karaf.boot/karaf-boot-sample-config/1.0
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/eb034f88/karaf-boot-samples/karaf-boot-sample-service-consumer-ds/README.md
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-service-consumer-ds/README.md b/karaf-boot-samples/karaf-boot-sample-service-consumer-ds/README.md
index f1f6370..ae04875 100644
--- a/karaf-boot-samples/karaf-boot-sample-service-consumer-ds/README.md
+++ b/karaf-boot-samples/karaf-boot-sample-service-consumer-ds/README.md
@@ -33,4 +33,4 @@ Once the service provider is installed:
Karaf deploy folder
* in the Karaf shell console, do:
- bundle:install -s mvn:karaf-boot-samples/karaf-boot-sample-service-consumer-ds/1.0
\ No newline at end of file
+ bundle:install -s mvn:org.apache.karaf.boot/karaf-boot-sample-service-consumer-ds/1.0
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/eb034f88/karaf-boot-samples/karaf-boot-sample-service-consumer-osgi/README.md
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-service-consumer-osgi/README.md b/karaf-boot-samples/karaf-boot-sample-service-consumer-osgi/README.md
index 02523d8..062348f 100644
--- a/karaf-boot-samples/karaf-boot-sample-service-consumer-osgi/README.md
+++ b/karaf-boot-samples/karaf-boot-sample-service-consumer-osgi/README.md
@@ -27,4 +27,4 @@ To deploy in Karaf:
Karaf deploy folder
* in the Karaf shell console, do:
- bundle:install -s mvn:karaf-boot-samples/karaf-boot-sample-service-consumer-osgi/1.0
\ No newline at end of file
+ bundle:install -s mvn:org.apache.karaf.boot/karaf-boot-sample-service-consumer-osgi/1.0
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/eb034f88/karaf-boot-samples/karaf-boot-sample-service-provider-ds/README.md
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-service-provider-ds/README.md b/karaf-boot-samples/karaf-boot-sample-service-provider-ds/README.md
index 0206a7b..94066f1 100644
--- a/karaf-boot-samples/karaf-boot-sample-service-provider-ds/README.md
+++ b/karaf-boot-samples/karaf-boot-sample-service-provider-ds/README.md
@@ -32,4 +32,4 @@ Once scr feature installed:
Karaf deploy folder
* in the Karaf shell console, do:
- bundle:install -s mvn:karaf-boot-samples/karaf-boot-sample-service-provider-ds/1.0
\ No newline at end of file
+ bundle:install -s mvn:org.apache.karaf.boot/karaf-boot-sample-service-provider-ds/1.0
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/eb034f88/karaf-boot-samples/karaf-boot-sample-service-provider-osgi/README.md
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-service-provider-osgi/README.md b/karaf-boot-samples/karaf-boot-sample-service-provider-osgi/README.md
index 3cd81c6..092d350 100644
--- a/karaf-boot-samples/karaf-boot-sample-service-provider-osgi/README.md
+++ b/karaf-boot-samples/karaf-boot-sample-service-provider-osgi/README.md
@@ -30,4 +30,4 @@ To deploy in Karaf:
Karaf deploy folder
* in the Karaf shell console, do:
- bundle:install -s mvn:karaf-boot-samples/karaf-boot-sample-service-provider-osgi/1.0
\ No newline at end of file
+ bundle:install -s mvn:org.apache.karaf.boot/karaf-boot-sample-service-provider-osgi/1.0
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/eb034f88/karaf-boot-samples/karaf-boot-sample-servlet/README.md
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-servlet/README.md b/karaf-boot-samples/karaf-boot-sample-servlet/README.md
new file mode 100644
index 0000000..75f940f
--- /dev/null
+++ b/karaf-boot-samples/karaf-boot-sample-servlet/README.md
@@ -0,0 +1,30 @@
+== karaf-boot-sample-servlet ==
+
+This sample shows how to easily create a servlet, ready to be deployed in Karaf.
+
+= Design
+
+The SampleServlet is servlet containing the @WebServlet annotation.
+
+This servlet is directly deployed by Karaf as soon as it's deployed.
+
+= Build
+
+To build, simply do:
+
+ mvn clean install
+
+= Deploy
+
+To deploy in Karaf, you have to enable the web support by installing the http and http-whiteboard features:
+
+ feature:install http
+ feature:install http-whiteboard
+
+Once http features installed:
+
+* you can drop the generated jar file (target/karaf-boot-sample-servlet-1.0.jar) in the
+Karaf deploy folder
+* in the Karaf shell console, do:
+
+ bundle:install -s mvn:org.apache.karaf.boot/karaf-boot-sample-servlet/1.0
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/eb034f88/karaf-boot-samples/karaf-boot-sample-servlet/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-servlet/pom.xml b/karaf-boot-samples/karaf-boot-sample-servlet/pom.xml
new file mode 100644
index 0000000..773b00a
--- /dev/null
+++ b/karaf-boot-samples/karaf-boot-sample-servlet/pom.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+
+ <!--
+
+ 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.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-sample-servlet</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-starter-web</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-maven-plugin</artifactId>
+ <version>${project.version}</version>
+ <extensions>true</extensions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/eb034f88/karaf-boot-samples/karaf-boot-sample-servlet/src/main/java/sample/servlet/SampleServlet.java
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-servlet/src/main/java/sample/servlet/SampleServlet.java b/karaf-boot-samples/karaf-boot-sample-servlet/src/main/java/sample/servlet/SampleServlet.java
new file mode 100644
index 0000000..d0069af
--- /dev/null
+++ b/karaf-boot-samples/karaf-boot-sample-servlet/src/main/java/sample/servlet/SampleServlet.java
@@ -0,0 +1,44 @@
+/*
+ * 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 sample.servlet;
+
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+@WebServlet(name = "SampleServlet", urlPatterns = {"/sample"})
+public class SampleServlet extends HttpServlet {
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ final PrintWriter writer = response.getWriter();
+ writer.println("<html>");
+ writer.println("<head>");
+ writer.println("<title>Sample</title>");
+ writer.println("</head>");
+ writer.println("<body align='center'>");
+ writer.println("<h1>Sample karaf-boot</h1>");
+ writer.println("</body>");
+ writer.println("</html>");
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/eb034f88/karaf-boot-samples/karaf-boot-sample-shell/README.md
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-shell/README.md b/karaf-boot-samples/karaf-boot-sample-shell/README.md
index 5c9e40b..dc6b380 100644
--- a/karaf-boot-samples/karaf-boot-sample-shell/README.md
+++ b/karaf-boot-samples/karaf-boot-sample-shell/README.md
@@ -28,7 +28,7 @@ To deploy in Karaf:
Karaf deploy folder
* in the Karaf shell console, do:
- bundle:install -s mvn:karaf-boot-samples/karaf-boot-sample-shell/1.0
+ bundle:install -s mvn:org.apache.karaf.boot/karaf-boot-sample-shell/1.0
= Usage
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/eb034f88/karaf-boot-starters/karaf-boot-starter-web/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-starters/karaf-boot-starter-web/pom.xml b/karaf-boot-starters/karaf-boot-starter-web/pom.xml
new file mode 100644
index 0000000..54bc3c5
--- /dev/null
+++ b/karaf-boot-starters/karaf-boot-starter-web/pom.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+
+ <!--
+
+ 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.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-starters</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>karaf-boot-starter-web</artifactId>
+
+ <dependencies>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>javax.servlet-api</artifactId>
+ <version>3.1.0</version>
+ </dependency>
+ </dependencies>
+
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/eb034f88/karaf-boot-starters/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-starters/pom.xml b/karaf-boot-starters/pom.xml
index 379f140..caa5d44 100644
--- a/karaf-boot-starters/pom.xml
+++ b/karaf-boot-starters/pom.xml
@@ -35,6 +35,7 @@
<module>karaf-boot-starter</module>
<module>karaf-boot-starter-ds</module>
<module>karaf-boot-starter-shell</module>
+ <module>karaf-boot-starter-web</module>
</modules>
</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/eb034f88/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index b1bab33..8a42a00 100644
--- a/pom.xml
+++ b/pom.xml
@@ -35,12 +35,13 @@
</properties>
<modules>
+ <!-- Core karaf-boot -->
<module>karaf-boot-starters</module>
<module>karaf-boot-tools</module>
-
- <!-- TODO reuse @Services & @Reference shell annotations for generic use cases -->
+ <!-- embedded mode -->
<!-- Archetypes -->
+ <!-- TODO archetypes -->
<!-- Samples -->
<!-- services -->
@@ -56,13 +57,14 @@
<module>karaf-boot-samples/karaf-boot-sample-config</module>
<!-- jpa -->
<!-- servlet -->
+ <module>karaf-boot-samples/karaf-boot-sample-servlet</module>
<!-- webui / angular -->
<!-- test -->
<!-- rest & soap -->
<!-- camel -->
<!-- Demos -->
- <!-- complete library demos -->
+ <!-- TODO complete library demos -->
</modules>
</project>
[06/35] karaf-boot git commit: Refactoring of karaf-boot
Posted by cs...@apache.org.
Refactoring of karaf-boot
Project: http://git-wip-us.apache.org/repos/asf/karaf-boot/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-boot/commit/87577122
Tree: http://git-wip-us.apache.org/repos/asf/karaf-boot/tree/87577122
Diff: http://git-wip-us.apache.org/repos/asf/karaf-boot/diff/87577122
Branch: refs/heads/master
Commit: 875771223463745d13b96856b6b3fe2e9866af7c
Parents: a0248b7
Author: Jean-Baptiste Onofr� <jb...@apache.org>
Authored: Tue Sep 29 15:04:55 2015 +0200
Committer: Jean-Baptiste Onofr� <jb...@apache.org>
Committed: Tue Sep 29 15:04:55 2015 +0200
----------------------------------------------------------------------
.../sample.osgi.service.provider.Activator | 1 +
karaf-boot-parent/pom.xml | 73 ------
karaf-boot-samples/README.md | 21 +-
.../README.md | 33 +++
.../pom.xml | 52 +++++
.../ds/service/consumer/HelloServiceClient.java | 59 +++++
.../README.md | 28 +++
.../pom.xml | 52 +++++
.../sample/osgi/service/consumer/Activator.java | 48 ++++
.../README.md | 35 +++
.../pom.xml | 47 ++++
.../ds/service/provider/HelloService.java | 26 +++
.../ds/service/provider/HelloServiceImpl.java | 31 +++
.../README.md | 33 +++
.../pom.xml | 47 ++++
.../sample/osgi/service/provider/Activator.java | 41 ++++
.../osgi/service/provider/HelloService.java | 26 +++
.../osgi/service/provider/HelloServiceImpl.java | 28 +++
.../karaf-boot-sample-simple/pom.xml | 33 ---
.../karaf/boot/sample/simple/SimpleBean.java | 14 --
karaf-boot-starter/README.md | 11 -
karaf-boot-starter/pom.xml | 34 ---
.../karaf-boot-starter-ds/pom.xml | 41 ++++
karaf-boot-starters/karaf-boot-starter/pom.xml | 46 ++++
karaf-boot-starters/pom.xml | 39 ++++
.../karaf-boot-maven-plugin/pom.xml | 100 +++++----
.../apache/karaf/boot/maven/GenerateMojo.java | 87 ++++++++
.../tools/maven/plugin/FilteredClassFinder.java | 60 -----
.../boot/tools/maven/plugin/GenerateMojo.java | 107 ---------
.../boot/tools/maven/plugin/Generator.java | 223 -------------------
.../maven/plugin/OsgiServiceProviderWriter.java | 86 -------
.../boot/tools/maven/plugin/model/Bean.java | 152 -------------
.../boot/tools/maven/plugin/model/BeanRef.java | 69 ------
.../boot/tools/maven/plugin/model/Context.java | 121 ----------
.../plugin/model/JavaxTransactionFactory.java | 40 ----
.../boot/tools/maven/plugin/model/Matcher.java | 23 --
.../maven/plugin/model/OsgiServiceRef.java | 41 ----
.../tools/maven/plugin/model/ProducedBean.java | 13 --
.../boot/tools/maven/plugin/model/Property.java | 90 --------
.../maven/plugin/model/PropertyWriter.java | 23 --
.../plugin/model/SpringTransactionFactory.java | 40 ----
.../maven/plugin/model/TransactionalDef.java | 39 ----
.../resources/META-INF/plexus/components.xml | 61 +++++
.../boot/tools/maven/plugin/GeneratorTest.java | 99 --------
.../boot/tools/maven/plugin/Namespaces.java | 54 -----
.../boot/tools/maven/plugin/model/BeanTest.java | 92 --------
.../tools/maven/plugin/model/ContextTest.java | 84 -------
.../tools/maven/plugin/model/PropertyTest.java | 73 ------
.../maven/plugin/model/TestBeanForRef.java | 39 ----
.../boot/tools/maven/plugin/test/MyBean1.java | 52 -----
.../boot/tools/maven/plugin/test/MyBean3.java | 50 -----
.../boot/tools/maven/plugin/test/MyBean4.java | 13 --
.../tools/maven/plugin/test/MyFactoryBean.java | 17 --
.../tools/maven/plugin/test/MyProduced.java | 18 --
.../tools/maven/plugin/test/ParentBean.java | 33 ---
.../boot/tools/maven/plugin/test/ServiceA.java | 23 --
.../tools/maven/plugin/test/ServiceAImpl1.java | 28 ---
.../tools/maven/plugin/test/ServiceAImpl2.java | 34 ---
.../boot/tools/maven/plugin/test/ServiceB.java | 23 --
.../maven/plugin/test/ServiceReferences.java | 33 ---
karaf-boot/README.md | 5 -
karaf-boot/pom.xml | 33 ---
.../main/java/org/apache/karaf/boot/Arg.java | 53 -----
.../main/java/org/apache/karaf/boot/Bean.java | 79 -------
.../main/java/org/apache/karaf/boot/Bind.java | 31 ---
.../java/org/apache/karaf/boot/Destroy.java | 31 ---
.../java/org/apache/karaf/boot/Element.java | 43 ----
.../main/java/org/apache/karaf/boot/Init.java | 31 ---
.../main/java/org/apache/karaf/boot/Inject.java | 32 ---
.../main/java/org/apache/karaf/boot/List.java | 36 ---
.../java/org/apache/karaf/boot/Reference.java | 69 ------
.../org/apache/karaf/boot/ReferenceList.java | 67 ------
.../apache/karaf/boot/ReferenceListener.java | 28 ---
.../java/org/apache/karaf/boot/Register.java | 31 ---
.../apache/karaf/boot/RegistrationListener.java | 29 ---
.../java/org/apache/karaf/boot/Service.java | 56 -----
.../org/apache/karaf/boot/ServiceProperty.java | 36 ---
.../main/java/org/apache/karaf/boot/Unbind.java | 31 ---
.../java/org/apache/karaf/boot/Unregister.java | 31 ---
pom.xml | 24 +-
80 files changed, 949 insertions(+), 2866 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/OSGI-INF/karaf-tracker/sample.osgi.service.provider.Activator
----------------------------------------------------------------------
diff --git a/OSGI-INF/karaf-tracker/sample.osgi.service.provider.Activator b/OSGI-INF/karaf-tracker/sample.osgi.service.provider.Activator
new file mode 100644
index 0000000..12b26d7
--- /dev/null
+++ b/OSGI-INF/karaf-tracker/sample.osgi.service.provider.Activator
@@ -0,0 +1 @@
+#Thu Sep 24 22:02:56 CEST 2015
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot-parent/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-parent/pom.xml b/karaf-boot-parent/pom.xml
deleted file mode 100644
index 9142128..0000000
--- a/karaf-boot-parent/pom.xml
+++ /dev/null
@@ -1,73 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<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>
-
- <groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-parent</artifactId>
- <version>1.0.0-SNAPSHOT</version>
- <packaging>pom</packaging>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot</artifactId>
- <version>1.0.0-SNAPSHOT</version>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-maven-plugin</artifactId>
- <version>1.0.0-SNAPSHOT</version>
- <inherited>true</inherited>
- <extensions>true</extensions>
- <executions>
- <execution>
- <phase>generate-resources</phase>
- <goals>
- <goal>generate</goal>
- </goals>
- <configuration>
- <scanPaths>
- <scanPath>${project.build.sourceDirectory}</scanPath>
- </scanPaths>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <version>2.5.4</version>
- <inherited>true</inherited>
- <extensions>true</extensions>
- <configuration>
- <supportedProjectTypes>
- <supportedProjectType>jar</supportedProjectType>
- <supportedProjectType>war</supportedProjectType>
- </supportedProjectTypes>
- </configuration>
- <executions>
- <execution>
- <phase>package</phase>
- <goals>
- <goal>bundle</goal>
- </goals>
- <configuration>
- <instructions>
- <Import-Package>
- org.apache.karaf.boot*;resolution:=optional,
- *
- </Import-Package>
- </instructions>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
-</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot-samples/README.md
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/README.md b/karaf-boot-samples/README.md
index 31be07a..d65c349 100644
--- a/karaf-boot-samples/README.md
+++ b/karaf-boot-samples/README.md
@@ -1,9 +1,16 @@
-* karaf-boot-simple
- Simple bean
-* karaf-boot-service-provider
- Service provider
-* karaf-boot-service-consumer
- Service consumer
+* karaf-boot-sample-service-provider-osgi
+ Expose a service using the "native" Karaf OSGi layer (low level)
+* karaf-boot-sample-service-consumer-osgi
+ Use a service using the "native" Karaf OSGi layer (low level)
+
+* karaf-boot-services-osgi
+ Simple services using OSGi
+* karaf-boot-services-blueprint
+ Simple services using blueprint
+* karaf-boot-services-ds
+ Simple services using DS/SCR
+* karaf-boot-services-cdi
+ Simple services using CDI
* karaf-boot-config-managed
Managed by configuration (reload)
* karaf-boot-servlet
@@ -17,4 +24,4 @@
* karaf-boot-profile
Build a profile based on karaf-boot definition
* karaf-boot-starter
- Package and configure Karaf as a ready to run artifact
\ No newline at end of file
+ Package and configure Karaf as a ready to run artifact
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot-samples/karaf-boot-sample-service-consumer-ds/README.md
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-service-consumer-ds/README.md b/karaf-boot-samples/karaf-boot-sample-service-consumer-ds/README.md
new file mode 100644
index 0000000..93f69f7
--- /dev/null
+++ b/karaf-boot-samples/karaf-boot-sample-service-consumer-ds/README.md
@@ -0,0 +1,33 @@
+== karaf-boot-sample-service-provider-osgi ==
+
+This sample exposes an OSGi service using the Karaf util classe and annotation.
+
+= Design
+
+This artifact uses the hello service provided by another artifact (karaf-boot-sample-service-provider-ds for instance).
+
+It uses the DS annotations to create a bean with a reference (@Reference) to the hello service.
+In the HelloServiceClient bean, we use the @Activate annotation to execute a specific method.
+
+You don't think anything else: karaf-boot will generate all the plumbing for you, and you will directly have a ready
+to use artifact.
+
+= Build
+
+To build, simply do:
+
+ mvn clean install
+
+= Deploy
+
+To deploy in Karaf, you have to enable the DS support first. For that, you have to install the scr feature:
+
+ feature:install scr
+
+Once scr feature installed:
+
+* you can drop the generated jar file (target/karaf-boot-sample-service-consumer-ds-1.0.jar) in the
+Karaf deploy folder
+* in the Karaf shell console, do:
+
+ bundle:install -s mvn:karaf-boot-samples/karaf-boot-sample-service-consumer-ds/1.0
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot-samples/karaf-boot-sample-service-consumer-ds/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-service-consumer-ds/pom.xml b/karaf-boot-samples/karaf-boot-sample-service-consumer-ds/pom.xml
new file mode 100644
index 0000000..c6b85c0
--- /dev/null
+++ b/karaf-boot-samples/karaf-boot-sample-service-consumer-ds/pom.xml
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+
+ <!--
+
+ 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.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-sample-service-consumer-ds</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-starter-ds</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-sample-service-provider-ds</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-maven-plugin</artifactId>
+ <version>${project.version}</version>
+ <extensions>true</extensions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot-samples/karaf-boot-sample-service-consumer-ds/src/main/java/sample/ds/service/consumer/HelloServiceClient.java
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-service-consumer-ds/src/main/java/sample/ds/service/consumer/HelloServiceClient.java b/karaf-boot-samples/karaf-boot-sample-service-consumer-ds/src/main/java/sample/ds/service/consumer/HelloServiceClient.java
new file mode 100644
index 0000000..f70ebf7
--- /dev/null
+++ b/karaf-boot-samples/karaf-boot-sample-service-consumer-ds/src/main/java/sample/ds/service/consumer/HelloServiceClient.java
@@ -0,0 +1,59 @@
+/**
+ * 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 sample.ds.service.consumer;
+
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Deactivate;
+import org.osgi.service.component.annotations.Reference;
+import sample.ds.service.provider.HelloService;
+
+@Component
+public class HelloServiceClient implements Runnable {
+
+ private HelloService helloService;
+
+ private Thread thread;
+
+ @Activate
+ public void start() {
+ thread = new Thread(this);
+ thread.start();
+ }
+
+ @Deactivate
+ public void stop() {
+ thread.interrupt();
+ }
+
+ public void run() {
+ while (true) {
+ System.out.println(helloService.hello("World"));
+ try {
+ Thread.sleep(5000);
+ } catch (Exception e) {
+ // nothing to do
+ }
+ }
+ }
+
+ @Reference
+ public void setHelloService(HelloService helloService) {
+ this.helloService = helloService;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot-samples/karaf-boot-sample-service-consumer-osgi/README.md
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-service-consumer-osgi/README.md b/karaf-boot-samples/karaf-boot-sample-service-consumer-osgi/README.md
new file mode 100644
index 0000000..1684c81
--- /dev/null
+++ b/karaf-boot-samples/karaf-boot-sample-service-consumer-osgi/README.md
@@ -0,0 +1,28 @@
+== karaf-boot-sample-service-consumer-osgi ==
+
+This sample uses an OSGi service using the Karaf util classe and annotation.
+
+= Design
+
+The service "contract" is exposed by another artifact (the karaf-boot-sample-service-provider-osgi module).
+
+The hello service is retrieved in the Activator of this artifact, and uses it directly.
+
+This Activator overrides the doStart() method, where we retrieve the HelloService using the getTrackedService() method. Karaf
+deals with all service lookup and tracking.
+
+= Build
+
+To build, simply do:
+
+ mvn clean install
+
+= Deploy
+
+To deploy in Karaf:
+
+* you can drop the generated jar file (target/karaf-boot-sample-service-provider-osgi-1.0.jar) in the
+Karaf deploy folder
+* in the Karaf shell console, do:
+
+ bundle:install -s mvn:karaf-boot-samples/karaf-boot-sample-service-consumer-osgi/1.0
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot-samples/karaf-boot-sample-service-consumer-osgi/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-service-consumer-osgi/pom.xml b/karaf-boot-samples/karaf-boot-sample-service-consumer-osgi/pom.xml
new file mode 100644
index 0000000..c26cfbf
--- /dev/null
+++ b/karaf-boot-samples/karaf-boot-sample-service-consumer-osgi/pom.xml
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+
+ <!--
+
+ 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.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-sample-service-consumer-osgi</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-starter</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-sample-service-provider-osgi</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-maven-plugin</artifactId>
+ <version>${project.version}</version>
+ <extensions>true</extensions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot-samples/karaf-boot-sample-service-consumer-osgi/src/main/java/sample/osgi/service/consumer/Activator.java
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-service-consumer-osgi/src/main/java/sample/osgi/service/consumer/Activator.java b/karaf-boot-samples/karaf-boot-sample-service-consumer-osgi/src/main/java/sample/osgi/service/consumer/Activator.java
new file mode 100644
index 0000000..fffd850
--- /dev/null
+++ b/karaf-boot-samples/karaf-boot-sample-service-consumer-osgi/src/main/java/sample/osgi/service/consumer/Activator.java
@@ -0,0 +1,48 @@
+/**
+ * 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 sample.osgi.service.consumer;
+
+import org.apache.karaf.util.tracker.BaseActivator;
+import org.apache.karaf.util.tracker.annotation.RequireService;
+import org.apache.karaf.util.tracker.annotation.Services;
+import sample.osgi.service.provider.HelloService;
+
+/**
+ * Simple activator that retrieve the hello service and use it.
+ */
+@Services(
+ requires = {
+ @RequireService(HelloService.class)
+ }
+)
+public class Activator extends BaseActivator {
+
+ @Override
+ public void doStart() throws Exception {
+ HelloService helloService = getTrackedService(HelloService.class);
+
+ // basic usage, in real life, it could be injected and used in a bean or whatever
+ System.out.println("Hello " + helloService.hello("World"));
+ }
+
+ @Override
+ public void doStop() {
+ super.doStop();
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot-samples/karaf-boot-sample-service-provider-ds/README.md
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-service-provider-ds/README.md b/karaf-boot-samples/karaf-boot-sample-service-provider-ds/README.md
new file mode 100644
index 0000000..0206a7b
--- /dev/null
+++ b/karaf-boot-samples/karaf-boot-sample-service-provider-ds/README.md
@@ -0,0 +1,35 @@
+== karaf-boot-sample-service-provider-ds ==
+
+This sample exposes an OSGi service using the Karaf util classe and annotation.
+
+= Design
+
+The service "contract" is describe by the Hello interface. It's a very simple service that expose one operation (hello).
+The service client send a message (String) to the hello service and he gets a response.
+
+The HelloServiceImpl is very simple: it prefixes the message with "Hello".
+
+We use the @Component DS annotation on HelloServiceImpl implementation in order to expose the service.
+
+You don't think anything else: karaf-boot will generate all the plumbing for you, and you will directly have a ready
+to use artifact.
+
+= Build
+
+To build, simply do:
+
+ mvn clean install
+
+= Deploy
+
+To deploy in Karaf, you have to enable the DS support first. For that, you have to install the scr feature:
+
+ feature:install scr
+
+Once scr feature installed:
+
+* you can drop the generated jar file (target/karaf-boot-sample-service-provider-ds-1.0.jar) in the
+Karaf deploy folder
+* in the Karaf shell console, do:
+
+ bundle:install -s mvn:karaf-boot-samples/karaf-boot-sample-service-provider-ds/1.0
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot-samples/karaf-boot-sample-service-provider-ds/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-service-provider-ds/pom.xml b/karaf-boot-samples/karaf-boot-sample-service-provider-ds/pom.xml
new file mode 100644
index 0000000..854a780
--- /dev/null
+++ b/karaf-boot-samples/karaf-boot-sample-service-provider-ds/pom.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+
+ <!--
+
+ 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.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-sample-service-provider-ds</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-starter-ds</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-maven-plugin</artifactId>
+ <version>${project.version}</version>
+ <extensions>true</extensions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot-samples/karaf-boot-sample-service-provider-ds/src/main/java/sample/ds/service/provider/HelloService.java
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-service-provider-ds/src/main/java/sample/ds/service/provider/HelloService.java b/karaf-boot-samples/karaf-boot-sample-service-provider-ds/src/main/java/sample/ds/service/provider/HelloService.java
new file mode 100644
index 0000000..50c2d30
--- /dev/null
+++ b/karaf-boot-samples/karaf-boot-sample-service-provider-ds/src/main/java/sample/ds/service/provider/HelloService.java
@@ -0,0 +1,26 @@
+/**
+ * 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 sample.ds.service.provider;
+
+/**
+ * Simple hello service contract.
+ */
+public interface HelloService {
+
+ public String hello(String message);
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot-samples/karaf-boot-sample-service-provider-ds/src/main/java/sample/ds/service/provider/HelloServiceImpl.java
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-service-provider-ds/src/main/java/sample/ds/service/provider/HelloServiceImpl.java b/karaf-boot-samples/karaf-boot-sample-service-provider-ds/src/main/java/sample/ds/service/provider/HelloServiceImpl.java
new file mode 100644
index 0000000..5319a47
--- /dev/null
+++ b/karaf-boot-samples/karaf-boot-sample-service-provider-ds/src/main/java/sample/ds/service/provider/HelloServiceImpl.java
@@ -0,0 +1,31 @@
+/**
+ * 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 sample.ds.service.provider;
+
+import org.osgi.service.component.annotations.Component;
+
+/**
+ * Simple implementation of the hello service..
+ */
+@Component
+public class HelloServiceImpl implements HelloService {
+
+ public String hello(String message) {
+ return "Hello " + message + " !";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot-samples/karaf-boot-sample-service-provider-osgi/README.md
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-service-provider-osgi/README.md b/karaf-boot-samples/karaf-boot-sample-service-provider-osgi/README.md
new file mode 100644
index 0000000..3cd81c6
--- /dev/null
+++ b/karaf-boot-samples/karaf-boot-sample-service-provider-osgi/README.md
@@ -0,0 +1,33 @@
+== karaf-boot-sample-service-provider-osgi ==
+
+This sample exposes an OSGi service using the Karaf util classe and annotation.
+
+= Design
+
+The service "contract" is describe by the Hello interface. It's a very simple service that expose one operation (hello).
+The service client send a message (String) to the hello service and he gets a response.
+
+The HelloServiceImpl is very simple: it prefixes the message with "Hello".
+
+In order to expose this service, we create an Activator, extending Karaf util BaseActivator.
+Our activator contains the @Services annotation describing the provided services (@ProvideService annotation).
+
+In this activator, we override the doStart() method, where we instantiate the HelloServiceImpl bean and register the
+HelloService service using the register() method (provided by Karaf). The Karaf BaseActivator manages the service
+registration, so you don't have to take care about the unregistration of the service, etc.
+
+= Build
+
+To build, simply do:
+
+ mvn clean install
+
+= Deploy
+
+To deploy in Karaf:
+
+* you can drop the generated jar file (target/karaf-boot-sample-service-provider-osgi-1.0.jar) in the
+Karaf deploy folder
+* in the Karaf shell console, do:
+
+ bundle:install -s mvn:karaf-boot-samples/karaf-boot-sample-service-provider-osgi/1.0
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot-samples/karaf-boot-sample-service-provider-osgi/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-service-provider-osgi/pom.xml b/karaf-boot-samples/karaf-boot-sample-service-provider-osgi/pom.xml
new file mode 100644
index 0000000..d1bb116
--- /dev/null
+++ b/karaf-boot-samples/karaf-boot-sample-service-provider-osgi/pom.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+
+ <!--
+
+ 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.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-sample-service-provider-osgi</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-starter</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-maven-plugin</artifactId>
+ <version>${project.version}</version>
+ <extensions>true</extensions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot-samples/karaf-boot-sample-service-provider-osgi/src/main/java/sample/osgi/service/provider/Activator.java
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-service-provider-osgi/src/main/java/sample/osgi/service/provider/Activator.java b/karaf-boot-samples/karaf-boot-sample-service-provider-osgi/src/main/java/sample/osgi/service/provider/Activator.java
new file mode 100644
index 0000000..9bc9b20
--- /dev/null
+++ b/karaf-boot-samples/karaf-boot-sample-service-provider-osgi/src/main/java/sample/osgi/service/provider/Activator.java
@@ -0,0 +1,41 @@
+/**
+ * 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 sample.osgi.service.provider;
+
+import org.apache.karaf.util.tracker.BaseActivator;
+import org.apache.karaf.util.tracker.annotation.ProvideService;
+import org.apache.karaf.util.tracker.annotation.Services;
+
+/**
+ * Simple activator registering the hello service.
+ */
+@Services(
+ provides = {
+ @ProvideService(HelloService.class)
+ }
+)
+public class Activator extends BaseActivator {
+
+ @Override
+ public void doStart() throws Exception {
+ // create hello service bean
+ HelloServiceImpl bean = new HelloServiceImpl();
+ // register the hello service
+ register(HelloService.class, bean);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot-samples/karaf-boot-sample-service-provider-osgi/src/main/java/sample/osgi/service/provider/HelloService.java
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-service-provider-osgi/src/main/java/sample/osgi/service/provider/HelloService.java b/karaf-boot-samples/karaf-boot-sample-service-provider-osgi/src/main/java/sample/osgi/service/provider/HelloService.java
new file mode 100644
index 0000000..fc0a357
--- /dev/null
+++ b/karaf-boot-samples/karaf-boot-sample-service-provider-osgi/src/main/java/sample/osgi/service/provider/HelloService.java
@@ -0,0 +1,26 @@
+/**
+ * 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 sample.osgi.service.provider;
+
+/**
+ * Simple hello service contract.
+ */
+public interface HelloService {
+
+ public String hello(String message);
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot-samples/karaf-boot-sample-service-provider-osgi/src/main/java/sample/osgi/service/provider/HelloServiceImpl.java
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-service-provider-osgi/src/main/java/sample/osgi/service/provider/HelloServiceImpl.java b/karaf-boot-samples/karaf-boot-sample-service-provider-osgi/src/main/java/sample/osgi/service/provider/HelloServiceImpl.java
new file mode 100644
index 0000000..c212205
--- /dev/null
+++ b/karaf-boot-samples/karaf-boot-sample-service-provider-osgi/src/main/java/sample/osgi/service/provider/HelloServiceImpl.java
@@ -0,0 +1,28 @@
+/**
+ * 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 sample.osgi.service.provider;
+
+/**
+ * Simple implementation of the hello service..
+ */
+public class HelloServiceImpl implements HelloService {
+
+ public String hello(String message) {
+ return "Hello " + message + " !";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot-samples/karaf-boot-sample-simple/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-simple/pom.xml b/karaf-boot-samples/karaf-boot-sample-simple/pom.xml
deleted file mode 100644
index 538503d..0000000
--- a/karaf-boot-samples/karaf-boot-sample-simple/pom.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<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">
-
- <!--
-
- 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.
- -->
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-parent</artifactId>
- <version>1.0.0-SNAPSHOT</version>
- </parent>
-
- <artifactId>karaf-boot-sample-simple</artifactId>
- <version>1.0.0-SNAPSHOT</version>
-
-</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot-samples/karaf-boot-sample-simple/src/main/java/org/apache/karaf/boot/sample/simple/SimpleBean.java
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-simple/src/main/java/org/apache/karaf/boot/sample/simple/SimpleBean.java b/karaf-boot-samples/karaf-boot-sample-simple/src/main/java/org/apache/karaf/boot/sample/simple/SimpleBean.java
deleted file mode 100644
index b89f733..0000000
--- a/karaf-boot-samples/karaf-boot-sample-simple/src/main/java/org/apache/karaf/boot/sample/simple/SimpleBean.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package org.apache.karaf.boot.sample.simple;
-
-import org.apache.karaf.boot.Bean;
-import org.apache.karaf.boot.Init;
-
-@Bean(id = "simple-bean")
-public class SimpleBean {
-
- @Init
- public void simple() {
- System.out.println("Hello world");
- }
-
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot-starter/README.md
----------------------------------------------------------------------
diff --git a/karaf-boot-starter/README.md b/karaf-boot-starter/README.md
deleted file mode 100644
index 43dc8e3..0000000
--- a/karaf-boot-starter/README.md
+++ /dev/null
@@ -1,11 +0,0 @@
-Karaf Boot Starter
-------------------
-Karaf Boot Starter provides a convenient way to create a ready to execute artifact, embedding Karaf.
-
-You just have to extend the KarafApplication class. In the config() method, you can define:
-- the configuration
-- the bundles
-- the features
-of your embedded Karaf instance.
-
-The Karaf Boot Starter Maven plugin will create the "key turn" jar that you can execute directly, on any machine.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot-starter/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-starter/pom.xml b/karaf-boot-starter/pom.xml
deleted file mode 100644
index 20fd28e..0000000
--- a/karaf-boot-starter/pom.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<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">
-
- <!--
-
- 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.
- -->
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-build</artifactId>
- <version>1.0.0-SNAPSHOT</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
-
- <artifactId>karaf-boot-starter</artifactId>
- <packaging>pom</packaging>
-
-</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot-starters/karaf-boot-starter-ds/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-starters/karaf-boot-starter-ds/pom.xml b/karaf-boot-starters/karaf-boot-starter-ds/pom.xml
new file mode 100644
index 0000000..9add66a
--- /dev/null
+++ b/karaf-boot-starters/karaf-boot-starter-ds/pom.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+
+ <!--
+
+ 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.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-starters</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>karaf-boot-starter-ds</artifactId>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ <version>5.0.0</version>
+ </dependency>
+ </dependencies>
+
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot-starters/karaf-boot-starter/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-starters/karaf-boot-starter/pom.xml b/karaf-boot-starters/karaf-boot-starter/pom.xml
new file mode 100644
index 0000000..21c0d07
--- /dev/null
+++ b/karaf-boot-starters/karaf-boot-starter/pom.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+
+ <!--
+
+ 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.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-starters</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>karaf-boot-starter</artifactId>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <version>${osgi.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.karaf</groupId>
+ <artifactId>org.apache.karaf.util</artifactId>
+ <version>${karaf.version}</version>
+ </dependency>
+ </dependencies>
+
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot-starters/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-starters/pom.xml b/karaf-boot-starters/pom.xml
new file mode 100644
index 0000000..04f6ff4
--- /dev/null
+++ b/karaf-boot-starters/pom.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+
+ <!--
+
+ 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.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-build</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>karaf-boot-starters</artifactId>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>karaf-boot-starter</module>
+ <module>karaf-boot-starter-ds</module>
+ </modules>
+
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot-tools/karaf-boot-maven-plugin/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/pom.xml b/karaf-boot-tools/karaf-boot-maven-plugin/pom.xml
index 19bb184..8897be1 100644
--- a/karaf-boot-tools/karaf-boot-maven-plugin/pom.xml
+++ b/karaf-boot-tools/karaf-boot-maven-plugin/pom.xml
@@ -1,6 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
+ <!--
+
+ 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.
+ -->
+
<modelVersion>4.0.0</modelVersion>
<parent>
@@ -15,63 +33,53 @@
<dependencies>
<dependency>
- <groupId>javax.inject</groupId>
- <artifactId>javax.inject</artifactId>
- <version>1</version>
- </dependency>
- <dependency>
- <groupId>org.apache.xbean</groupId>
- <artifactId>xbean-finder-shaded</artifactId>
- <version>4.0</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-context</artifactId>
- <version>4.1.0.RELEASE</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-tx</artifactId>
- <version>4.1.0.RELEASE</version>
- </dependency>
- <dependency>
- <groupId>javax.persistence</groupId>
- <artifactId>persistence-api</artifactId>
- <version>1.0.2</version>
- </dependency>
- <dependency>
- <groupId>javax.transaction</groupId>
- <artifactId>javax.transaction-api</artifactId>
- <version>1.2</version>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.cdi</groupId>
- <artifactId>pax-cdi-api</artifactId>
- <version>0.9.0</version>
- </dependency>
- <dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>3.1.1</version>
</dependency>
<dependency>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-annotations</artifactId>
+ <version>3.3</version>
+ </dependency>
+ <dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>3.1.1</version>
</dependency>
-
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.12</version>
- <scope>test</scope>
- </dependency>
<dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- <version>2.4</version>
- <scope>test</scope>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-model</artifactId>
+ <version>3.2.1</version>
</dependency>
</dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-plugin-plugin</artifactId>
+ <version>3.3</version>
+ <configuration>
+ <goalPrefix>karaf-boot</goalPrefix>
+ <skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
+ </configuration>
+ <executions>
+ <execution>
+ <id>generate-descriptor</id>
+ <goals>
+ <goal>descriptor</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>generate-helpmojo</id>
+ <goals>
+ <goal>helpmojo</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/maven/GenerateMojo.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/maven/GenerateMojo.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/maven/GenerateMojo.java
new file mode 100644
index 0000000..da9414d
--- /dev/null
+++ b/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/maven/GenerateMojo.java
@@ -0,0 +1,87 @@
+package org.apache.karaf.boot.maven;
+
+import org.apache.maven.execution.MavenSession;
+import org.apache.maven.model.Plugin;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.BuildPluginManager;
+import org.apache.maven.plugin.MojoExecution;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.descriptor.*;
+import org.apache.maven.plugins.annotations.*;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.project.MavenProject;
+import org.codehaus.plexus.util.xml.Xpp3Dom;
+import org.codehaus.plexus.util.xml.Xpp3DomBuilder;
+
+import java.io.ByteArrayInputStream;
+
+@Mojo(name = "generate", threadSafe = true, defaultPhase = LifecyclePhase.PROCESS_CLASSES, requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME, inheritByDefault = false)
+public class GenerateMojo extends AbstractMojo {
+
+ @Parameter(defaultValue = "${project}", required = true, readonly = true)
+ private MavenProject mavenProject;
+
+ @Parameter(defaultValue = "${session}", required = true, readonly = true)
+ private MavenSession mavenSession;
+
+ @Component
+ private BuildPluginManager pluginManager;
+
+ public void execute() throws MojoExecutionException {
+ try {
+ // invoke Karaf services plugin
+ getLog().info("Invoking karaf-services-maven-plugin");
+ Plugin karafServicesPlugin = new Plugin();
+ karafServicesPlugin.setGroupId("org.apache.karaf.tooling");
+ karafServicesPlugin.setArtifactId("karaf-services-maven-plugin");
+ karafServicesPlugin.setVersion("4.0.1");
+ karafServicesPlugin.setInherited(false);
+ karafServicesPlugin.setExtensions(true);
+ Xpp3Dom configuration = Xpp3DomBuilder.build(new ByteArrayInputStream(("<configuration>" +
+ "<project>${project}</project>" +
+ "<activatorProperty>BNDExtension-Bundle-Activator</activatorProperty>" +
+ "<requirementsProperty>BNDExtension-Require-Capability</requirementsProperty>" +
+ "<capabilitiesProperty>BNDExtension-Provide-Capability</capabilitiesProperty>" +
+ "<outputDirectory>${project.build.directory}/generated/karaf-tracker</outputDirectory>" +
+ "<classLoader>project</classLoader>" +
+ "</configuration>").getBytes()), "UTF-8");
+ PluginDescriptor karafServicesPluginDescriptor = pluginManager.loadPlugin(karafServicesPlugin, mavenProject.getRemotePluginRepositories(), mavenSession.getRepositorySession());
+ MojoDescriptor karafServicesMojoDescriptor = karafServicesPluginDescriptor.getMojo("service-metadata-generate");
+ MojoExecution execution = new MojoExecution(karafServicesMojoDescriptor, configuration);
+ pluginManager.executeMojo(mavenSession, execution);
+
+ // invoke Felix bundle plugin
+ getLog().info("Invoking maven-bundle-plugin");
+ Plugin felixBundlePlugin = new Plugin();
+ felixBundlePlugin.setGroupId("org.apache.felix");
+ felixBundlePlugin.setArtifactId("maven-bundle-plugin");
+ felixBundlePlugin.setVersion("3.0.0");
+ felixBundlePlugin.setInherited(true);
+ felixBundlePlugin.setExtensions(true);
+ // TODO if jpa-start is provided as persistence.xml location
+ configuration = Xpp3DomBuilder.build(new ByteArrayInputStream(("<configuration>" +
+ "<finalName>${project.build.finalName}</finalName>" +
+ "<outputDirectory>${project.build.outputDirectory}</outputDirectory>" +
+ "<m_mavenSession>${session}</m_mavenSession>" +
+ "<project>${project}</project>" +
+ "<buildDirectory>${project.build.directory}</buildDirectory>" +
+ "<supportedProjectTypes>" +
+ "<supportedProjectType>jar</supportedProjectType>" +
+ "<supportedProjectType>bundle</supportedProjectType>" +
+ "<supportedProjectType>war</supportedProjectType>" +
+ "</supportedProjectTypes>" +
+ "<instructions>" +
+ "<Private-Package>org.apache.karaf.util.tracker</Private-Package>" +
+ "<_dsannotations>*</_dsannotations>" +
+ "</instructions>" +
+ "</configuration>").getBytes()), "UTF-8");
+ PluginDescriptor felixBundlePluginDescriptor = pluginManager.loadPlugin(felixBundlePlugin, mavenProject.getRemotePluginRepositories(), mavenSession.getRepositorySession());
+ MojoDescriptor felixBundleMojoDescriptor = felixBundlePluginDescriptor.getMojo("bundle");
+ execution = new MojoExecution(felixBundleMojoDescriptor, configuration);
+ pluginManager.executeMojo(mavenSession, execution);
+ } catch (Exception e) {
+ throw new MojoExecutionException("karaf-boot-maven-plugin failed", e);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/FilteredClassFinder.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/FilteredClassFinder.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/FilteredClassFinder.java
deleted file mode 100644
index 7ba607b..0000000
--- a/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/FilteredClassFinder.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- * 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.karaf.boot.tools.maven.plugin;
-
-import java.lang.annotation.Annotation;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.inject.Singleton;
-
-import org.apache.xbean.finder.ClassFinder;
-import org.springframework.stereotype.Component;
-
-public class FilteredClassFinder {
-
- @SuppressWarnings("unchecked")
- public static Set<Class<?>> findClasses(ClassFinder finder, Collection<String> packageNames) {
- return findClasses(finder, packageNames, new Class[]{Singleton.class, Component.class});
- }
-
- public static Set<Class<?>> findClasses(ClassFinder finder, Collection<String> packageNames, Class<? extends Annotation>[] annotations) {
- Set<Class<?>> rawClasses = new HashSet<Class<?>>();
- for (Class<? extends Annotation> annotation : annotations) {
- rawClasses.addAll(finder.findAnnotatedClasses(annotation));
- }
- return filterByBasePackages(rawClasses, packageNames);
- }
-
- private static Set<Class<?>> filterByBasePackages(Set<Class<?>> rawClasses, Collection<String> packageNames) {
- Set<Class<?>> filteredClasses = new HashSet<Class<?>>();
- for (Class<?> clazz : rawClasses) {
- for (String packageName : packageNames) {
- if (clazz.getPackage().getName().startsWith(packageName)) {
- filteredClasses.add(clazz);
- continue;
- }
- }
- }
- //System.out.println("Raw: " + rawClasses);
- //System.out.println("Filtered: " + beanClasses);
- return filteredClasses;
- }
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/GenerateMojo.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/GenerateMojo.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/GenerateMojo.java
deleted file mode 100644
index 72d5f28..0000000
--- a/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/GenerateMojo.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/**
- * 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.karaf.boot.tools.maven.plugin;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.karaf.boot.tools.maven.plugin.model.Context;
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.model.Resource;
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.project.MavenProject;
-import org.apache.xbean.finder.ClassFinder;
-
-/**
- * Generates blueprint from spring annotations
- * @goal generate
- * @phase process-classes
- * @requiresDependencyResolution compile
- * @inheritByDefault false
- * @description Generates artifact using karaf-boot annotations and supporting spring annotations @Component, @Autowire and @Value
- */
-public class GenerateMojo extends AbstractMojo {
-
- /**
- * The maven project.
- *
- * @parameter default-value="${project}"
- * @required
- */
- protected MavenProject project;
-
- /**
- * @parameter
- * @required
- */
- protected List<String> scanPaths;
-
- /**
- * true: Purely annotated mode (needs jpa 2.1.0 and transaction-blueprint 1.1.0)
- * false: XML based mode for JPA 1.x and transaction-blueprint < 1.1.0
- * @parameter default-value="true"
- * @required
- */
- protected boolean persistenceAnnotated;
-
- public void execute() throws MojoExecutionException, MojoFailureException {
- try {
- String buildDir = project.getBuild().getDirectory();
- String generatedDir = buildDir + "/generated-resources";
- Resource resource = new Resource();
- resource.setDirectory(generatedDir);
- project.addResource(resource);
- ClassFinder finder = createProjectScopeFinder();
-
- File file = new File(generatedDir, "OSGI-INF/blueprint/autowire.xml");
- file.getParentFile().mkdirs();
- System.out.println("Generating blueprint to " + file);
- Set<Class<?>> classes = FilteredClassFinder.findClasses(finder, scanPaths);
- Context context = new Context(classes);
- context.resolve();
- new Generator(context, new FileOutputStream(file), persistenceAnnotated).generate();
- } catch (Exception e) {
- throw new MojoExecutionException("Error building commands help", e);
- }
- }
-
- private ClassFinder createProjectScopeFinder() throws MalformedURLException {
- List<URL> urls = new ArrayList<URL>();
-
- urls.add( new File(project.getBuild().getOutputDirectory()).toURI().toURL() );
- for ( Object artifactO : project.getArtifacts() ) {
- Artifact artifact = (Artifact)artifactO;
- File file = artifact.getFile();
- if ( file != null ) {
- urls.add( file.toURI().toURL() );
- }
- }
- ClassLoader loader = new URLClassLoader(urls.toArray(new URL[urls.size()]), getClass().getClassLoader());
- return new ClassFinder(loader, urls);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/Generator.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/Generator.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/Generator.java
deleted file mode 100644
index 8806d05..0000000
--- a/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/Generator.java
+++ /dev/null
@@ -1,223 +0,0 @@
-/**
- * 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.karaf.boot.tools.maven.plugin;
-
-import java.io.OutputStream;
-import java.lang.reflect.Field;
-
-import javax.persistence.PersistenceContext;
-import javax.persistence.PersistenceUnit;
-import javax.xml.stream.XMLOutputFactory;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamWriter;
-
-import org.apache.karaf.boot.tools.maven.plugin.model.Bean;
-import org.apache.karaf.boot.tools.maven.plugin.model.Context;
-import org.apache.karaf.boot.tools.maven.plugin.model.OsgiServiceRef;
-import org.apache.karaf.boot.tools.maven.plugin.model.ProducedBean;
-import org.apache.karaf.boot.tools.maven.plugin.model.Property;
-import org.apache.karaf.boot.tools.maven.plugin.model.PropertyWriter;
-import org.apache.karaf.boot.tools.maven.plugin.model.TransactionalDef;
-
-public class Generator implements PropertyWriter {
- private static final String NS_BLUEPRINT = "http://www.osgi.org/xmlns/blueprint/v1.0.0";
- private static final String NS_EXT = "http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0";
- private static final String NS_JPA = "http://aries.apache.org/xmlns/jpa/v1.1.0";
- private static final String NS_JPA2 = "http://aries.apache.org/xmlns/jpan/v1.0.0";
- private static final String NS_TX = "http://aries.apache.org/xmlns/transactions/v1.2.0";
-
- private Context context;
- private XMLStreamWriter writer;
- private boolean persistenceAnnotated;
-
- public Generator(Context context, OutputStream os, boolean persistenceAnnotated) throws XMLStreamException {
- this.context = context;
- this.persistenceAnnotated = persistenceAnnotated;
-
- XMLOutputFactory factory = XMLOutputFactory.newInstance();
- writer = factory.createXMLStreamWriter(os);
- }
-
- public void generate() {
- try {
- writer.writeStartDocument();
- writer.writeCharacters("\n");
- writeBlueprint();
-
- if (persistenceAnnotated) {
- if (isJpaUsed()) {
- writer.writeEmptyElement(NS_JPA2, "enable");
- writer.writeCharacters("\n");
- }
- writer.writeEmptyElement(NS_TX, "enable-annotations");
- writer.writeCharacters("\n");
- //if (isJtaUsed()) {
-// writer.writeEmptyElement(NS_TX, "enable-annotations");
- //}
- }
- for (Bean bean : context.getBeans()) {
- writeBeanStart(bean);
- bean.writeProperties(this);
- writer.writeEndElement();
- writer.writeCharacters("\n");
- }
-
- writeServiceRefs();
- new OsgiServiceProviderWriter(writer).write(context.getBeans());
-
- writer.writeEndElement();
- writer.writeCharacters("\n");
- writer.writeEndDocument();
- writer.writeCharacters("\n");
- writer.close();
- } catch (XMLStreamException e) {
- throw new RuntimeException(e.getMessage(), e);
- }
- }
-
- private boolean isJpaUsed() {
- boolean jpaUsed = false;
- for (Bean bean : context.getBeans()) {
- if (bean.persistenceFields.length > 0) {
- jpaUsed = true;
- }
- }
- return jpaUsed;
- }
-
- private boolean isJtaUsed() {
- boolean jtaUsed = false;
- for (Bean bean : context.getBeans()) {
- if (bean.transactionDef != null) {
- jtaUsed = true;
- }
-
- }
- return jtaUsed;
- }
-
- private void writeBlueprint() throws XMLStreamException {
- writer.writeStartElement("blueprint");
- writer.writeDefaultNamespace(NS_BLUEPRINT);
- writer.writeNamespace("ext", NS_EXT);
- if (persistenceAnnotated) {
- writer.writeNamespace("jpa", NS_JPA2);
- } else {
- writer.writeNamespace("jpa", NS_JPA);
- }
- writer.writeNamespace("tx", NS_TX);
- }
-
- public void writeBeanStart(Bean bean) throws XMLStreamException {
- writer.writeStartElement("bean");
- writer.writeAttribute("id", bean.id);
- writer.writeAttribute("class", bean.clazz.getName());
- writer.writeAttribute("ext", NS_EXT, "field-injection", "true");
- if (bean instanceof ProducedBean) {
- writeFactory((ProducedBean)bean);
- }
- if (bean.initMethod != null) {
- writer.writeAttribute("init-method", bean.initMethod);
- }
- if (bean.destroyMethod != null) {
- writer.writeAttribute("destroy-method", bean.destroyMethod);
- }
- writer.writeCharacters("\n");
-
- if (!persistenceAnnotated) {
- writeTransactional(bean.transactionDef);
- writePersistenceFields(bean.persistenceFields);
- }
- }
-
- private void writeFactory(ProducedBean bean) throws XMLStreamException {
- writer.writeAttribute("factory-ref", bean.factoryBeanId);
- writer.writeAttribute("factory-method", bean.factoryMethod);
- }
-
- private void writeTransactional(TransactionalDef transactionDef)
- throws XMLStreamException {
- if (transactionDef != null) {
- writer.writeCharacters(" ");
- writer.writeEmptyElement("tx", "transaction", NS_TX);
- writer.writeAttribute("method", transactionDef.getMethod());
- writer.writeAttribute("value", transactionDef.getType());
- writer.writeCharacters("\n");
- }
- }
-
-
- private void writePersistenceFields(Field[] fields) throws XMLStreamException {
- for (Field field : fields) {
- writePersistenceField(field);
- }
- }
-
- private void writePersistenceField(Field field) throws XMLStreamException {
- PersistenceContext persistenceContext = field.getAnnotation(PersistenceContext.class);
- if (persistenceContext != null) {
- writer.writeCharacters(" ");
- writer.writeEmptyElement("jpa", "context", NS_JPA);
- writer.writeAttribute("unitname", persistenceContext.unitName());
- writer.writeAttribute("property", field.getName());
- writer.writeCharacters("\n");
- }
- PersistenceUnit persistenceUnit = field.getAnnotation(PersistenceUnit.class);
- if (persistenceUnit != null) {
- writer.writeCharacters(" ");
- writer.writeEmptyElement("jpa", "unit", NS_JPA);
- writer.writeAttribute("unitname", persistenceUnit.unitName());
- writer.writeAttribute("property", field.getName());
- writer.writeCharacters("\n");
- }
- }
-
- private void writeServiceRefs() throws XMLStreamException {
- for (OsgiServiceRef serviceBean : context.getServiceRefs()) {
- writeServiceRef(serviceBean);
- }
- }
-
- private void writeServiceRef(OsgiServiceRef serviceBean) throws XMLStreamException {
- writer.writeEmptyElement("reference");
- writer.writeAttribute("id", serviceBean.id);
- writer.writeAttribute("interface", serviceBean.clazz.getName());
- if (serviceBean.filter != null && !"".equals(serviceBean.filter)) {
- writer.writeAttribute("filter", serviceBean.filter);
- }
- writer.writeCharacters("\n");
- }
-
- public void writeProperty(Property property) {
- try {
- writer.writeCharacters(" ");
- writer.writeEmptyElement("property");
- writer.writeAttribute("name", property.name);
- if (property.ref != null) {
- writer.writeAttribute("ref", property.ref);
- } else if (property.value != null) {
- writer.writeAttribute("value", property.value);
- }
- writer.writeCharacters("\n");
- } catch (XMLStreamException e) {
- throw new RuntimeException(e.getMessage(), e);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/OsgiServiceProviderWriter.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/OsgiServiceProviderWriter.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/OsgiServiceProviderWriter.java
deleted file mode 100644
index 95d57df..0000000
--- a/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/OsgiServiceProviderWriter.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/**
- * 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.karaf.boot.tools.maven.plugin;
-
-import java.util.Collection;
-
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamWriter;
-
-import org.apache.karaf.boot.tools.maven.plugin.model.Bean;
-import org.ops4j.pax.cdi.api.OsgiServiceProvider;
-import org.ops4j.pax.cdi.api.Properties;
-import org.ops4j.pax.cdi.api.Property;
-
-public class OsgiServiceProviderWriter {
- private XMLStreamWriter writer;
-
- public OsgiServiceProviderWriter(XMLStreamWriter writer) {
- this.writer = writer;
- }
-
- public void write(Collection<Bean> beans) throws XMLStreamException {
- for (Bean bean : beans) {
- write(bean);
- }
- }
-
- public void write(Bean bean) throws XMLStreamException {
- OsgiServiceProvider serviceProvider = bean.clazz.getAnnotation(OsgiServiceProvider.class);
- if (serviceProvider == null) {
- return;
- }
- if (serviceProvider.classes().length == 0) {
- throw new IllegalArgumentException("Need to provide the interface class in the @OsgiServiceProvider(classes={...}) annotation on " + bean.clazz);
- }
- Properties properties = bean.clazz.getAnnotation(Properties.class);
- if (properties == null) {
- writer.writeEmptyElement("service");
- } else {
- writer.writeStartElement("service");
- }
- writer.writeAttribute("ref", bean.id);
- Class<?> serviceIf = serviceProvider.classes()[0];
- writer.writeAttribute("interface", serviceIf.getName());
- writer.writeCharacters("\n");
- if (properties != null) {
- writeProperties(properties);
- writer.writeEndElement();
- writer.writeCharacters("\n");
- }
- }
-
- private void writeProperties(Properties properties) throws XMLStreamException {
- writer.writeCharacters(" ");
- writer.writeStartElement("service-properties");
- writer.writeCharacters("\n");
- for (Property property : properties.value()) {
- writer.writeCharacters(" ");
- writer.writeEmptyElement("entry");
- writer.writeAttribute("key", property.name());
- writer.writeAttribute("value", property.value());
- writer.writeCharacters("\n");
- }
- writer.writeCharacters(" ");
- writer.writeEndElement();
- writer.writeCharacters("\n");
- }
-
-
-}
[34/35] karaf-boot git commit: Working jpa example with hibernate
Posted by cs...@apache.org.
Working jpa example with hibernate
Project: http://git-wip-us.apache.org/repos/asf/karaf-boot/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-boot/commit/6e4e7ed2
Tree: http://git-wip-us.apache.org/repos/asf/karaf-boot/tree/6e4e7ed2
Diff: http://git-wip-us.apache.org/repos/asf/karaf-boot/diff/6e4e7ed2
Branch: refs/heads/master
Commit: 6e4e7ed2e93845485a26e48dcdabdec6f7c9e3e2
Parents: af03889
Author: Christian Schneider <ch...@die-schneider.net>
Authored: Wed Apr 27 14:15:01 2016 +0200
Committer: Christian Schneider <ch...@die-schneider.net>
Committed: Wed Apr 27 14:15:01 2016 +0200
----------------------------------------------------------------------
samples/jpa/src/main/java/sample/jpa/Task.java | 14 +++++++-------
starters/karaf-boot-starter-blueprint/pom.xml | 18 ++++++++++++++----
starters/karaf-boot-starter-jpa/pom.xml | 13 ++++++++++---
.../java/org/apache/karaf/boot/jpa/Hibernate.java | 16 +++++++++++-----
.../apache/karaf/boot/jpa/impl/JpaProcessor.java | 9 ++++++++-
5 files changed, 50 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/6e4e7ed2/samples/jpa/src/main/java/sample/jpa/Task.java
----------------------------------------------------------------------
diff --git a/samples/jpa/src/main/java/sample/jpa/Task.java b/samples/jpa/src/main/java/sample/jpa/Task.java
index cd431a7..2391d2a 100644
--- a/samples/jpa/src/main/java/sample/jpa/Task.java
+++ b/samples/jpa/src/main/java/sample/jpa/Task.java
@@ -18,20 +18,21 @@ package sample.jpa;
import javax.persistence.Entity;
import javax.persistence.Id;
-import javax.xml.bind.annotation.XmlRootElement;
import org.apache.karaf.boot.jpa.Hibernate;
import org.apache.karaf.boot.jpa.PersistentUnit;
import org.apache.karaf.boot.jpa.Property;
import org.apache.karaf.boot.jpa.Provider;
-@PersistentUnit(name = "tasklist", provider = Provider.Hibernate, properties = {
- @Property(name = "hibernate.hbm2ddl.auto", value = "create-drop")
-})
+@PersistentUnit( //
+ name = "task", provider = Provider.Hibernate, properties = //
+ {
+ @Property(name = "hibernate.hbm2ddl.auto", value = "create-drop"),
+ @Property(name = "javax.persistence.jdbc.driver", value = "org.apache.derby.jdbc.EmbeddedDriver"),
+ @Property(name = "javax.persistence.jdbc.url", value = "jdbc:derby:memory:DSFTEST;create=true")
+ })
@Hibernate.Dialect(Hibernate.Dialect.Value.HSQL)
-@Hibernate.Hbm2DdlAuto(Hibernate.Hbm2DdlAuto.Value.CreateDrop)
@Entity
-@XmlRootElement
public class Task {
@Id
Integer id;
@@ -40,7 +41,6 @@ public class Task {
public Task() {
}
-
public Task(Integer id, String title) {
super();
this.id = id;
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/6e4e7ed2/starters/karaf-boot-starter-blueprint/pom.xml
----------------------------------------------------------------------
diff --git a/starters/karaf-boot-starter-blueprint/pom.xml b/starters/karaf-boot-starter-blueprint/pom.xml
index 14db02e..e958058 100644
--- a/starters/karaf-boot-starter-blueprint/pom.xml
+++ b/starters/karaf-boot-starter-blueprint/pom.xml
@@ -42,14 +42,24 @@
<version>1.0.0</version>
</dependency>
<dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>osgi.cmpn</artifactId>
+ <version>${osgi.version}</version>
+ </dependency>
+ <dependency>
<groupId>org.ops4j.pax.cdi</groupId>
<artifactId>pax-cdi-api</artifactId>
- <version>0.5.0</version>
+ <version>${pax.cdi.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.enterprise</groupId>
+ <artifactId>cdi-api</artifactId>
+ <version>1.2</version>
</dependency>
<dependency>
- <groupId>javax.inject</groupId>
- <artifactId>javax.inject</artifactId>
- <version>1</version>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-atinject_1.0_spec</artifactId>
+ <version>1.0</version>
</dependency>
</dependencies>
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/6e4e7ed2/starters/karaf-boot-starter-jpa/pom.xml
----------------------------------------------------------------------
diff --git a/starters/karaf-boot-starter-jpa/pom.xml b/starters/karaf-boot-starter-jpa/pom.xml
index 7a89d90..6db476f 100644
--- a/starters/karaf-boot-starter-jpa/pom.xml
+++ b/starters/karaf-boot-starter-jpa/pom.xml
@@ -26,11 +26,18 @@
<dependencies>
<dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-jpa_2.0_spec</artifactId>
- <version>1.1</version>
+ <groupId>org.hibernate.javax.persistence</groupId>
+ <artifactId>hibernate-jpa-2.1-api</artifactId>
+ <version>1.0.0.Final</version>
</dependency>
<dependency>
+ <groupId>org.apache.aries.jpa</groupId>
+ <artifactId>org.apache.aries.jpa.api</artifactId>
+ <version>2.3.0</version>
+ </dependency>
+
+ <!-- For the stax indenting -->
+ <dependency>
<groupId>net.java.dev.stax-utils</groupId>
<artifactId>stax-utils</artifactId>
<version>20070216</version>
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/6e4e7ed2/starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/Hibernate.java
----------------------------------------------------------------------
diff --git a/starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/Hibernate.java b/starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/Hibernate.java
index ae4dab3..0944c20 100644
--- a/starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/Hibernate.java
+++ b/starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/Hibernate.java
@@ -22,13 +22,19 @@ public interface Hibernate {
@interface Hbm2DdlAuto {
Value value();
enum Value {
- Validate,
- Update,
- Create,
- CreateDrop;
+ Validate("validate"),
+ Update("update"),
+ Create("create"),
+ CreateDrop("create-drop");
+
+ private String value;
+
+ private Value(String value) {
+ this.value = value;
+ }
public String toString() {
- return super.toString().toLowerCase();
+ return value;
}
}
}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/6e4e7ed2/starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/impl/JpaProcessor.java
----------------------------------------------------------------------
diff --git a/starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/impl/JpaProcessor.java b/starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/impl/JpaProcessor.java
index f160fec..622643b 100644
--- a/starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/impl/JpaProcessor.java
+++ b/starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/impl/JpaProcessor.java
@@ -32,6 +32,8 @@ import javanet.staxutils.IndentingXMLStreamWriter;
public class JpaProcessor extends AbstractProcessor {
+ private boolean useHibernate;
+
public JpaProcessor() {
}
@@ -59,7 +61,11 @@ public class JpaProcessor extends AbstractProcessor {
processingEnv.getMessager().printMessage(Kind.ERROR, "Error: " + e.getMessage());
}
try (PrintWriter w = appendResource("META-INF/org.apache.karaf.boot.bnd")) {
- w.println("Private-Package: META-INF");
+ w.println("Private-Package: META-INF.*");
+ w.println("Meta-Persistence: META-INF/persistence.xml");
+ if (useHibernate) {
+ w.println("Import-Package: org.hibernate.proxy, javassist.util.proxy");
+ }
} catch (Exception e) {
processingEnv.getMessager().printMessage(Kind.ERROR, "Error writing to META-INF/org.apache.karaf.boot.bnd: " + e.getMessage());
}
@@ -164,6 +170,7 @@ public class JpaProcessor extends AbstractProcessor {
if (pu.provider() != null) {
switch (pu.provider()) {
case Hibernate:
+ useHibernate = true;
return "org.hibernate.jpa.HibernatePersistenceProvider";
default:
// TODO
[27/35] karaf-boot git commit: Remove start-ds as it already works
with the main starter
Posted by cs...@apache.org.
Remove start-ds as it already works with the main starter
Project: http://git-wip-us.apache.org/repos/asf/karaf-boot/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-boot/commit/1d8892a2
Tree: http://git-wip-us.apache.org/repos/asf/karaf-boot/tree/1d8892a2
Diff: http://git-wip-us.apache.org/repos/asf/karaf-boot/diff/1d8892a2
Branch: refs/heads/master
Commit: 1d8892a27143e019756085ad6396856cb260e82a
Parents: 137222a
Author: Christian Schneider <ch...@die-schneider.net>
Authored: Mon Apr 25 12:35:52 2016 +0200
Committer: Christian Schneider <ch...@die-schneider.net>
Committed: Mon Apr 25 12:35:52 2016 +0200
----------------------------------------------------------------------
samples/ds/service-consumer/pom.xml | 2 +-
samples/ds/service-provider/pom.xml | 2 +-
starters/karaf-boot-starter-ds/pom.xml | 52 --------------
.../apache/karaf/boot/ds/impl/DsProcessor.java | 72 --------------------
.../javax.annotation.processing.Processor | 1 -
starters/karaf-boot-starter/pom.xml | 5 ++
starters/pom.xml | 3 +-
7 files changed, 8 insertions(+), 129 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/1d8892a2/samples/ds/service-consumer/pom.xml
----------------------------------------------------------------------
diff --git a/samples/ds/service-consumer/pom.xml b/samples/ds/service-consumer/pom.xml
index c6b85c0..3048e77 100644
--- a/samples/ds/service-consumer/pom.xml
+++ b/samples/ds/service-consumer/pom.xml
@@ -28,7 +28,7 @@
<dependencies>
<dependency>
<groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-starter-ds</artifactId>
+ <artifactId>karaf-boot-starter</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/1d8892a2/samples/ds/service-provider/pom.xml
----------------------------------------------------------------------
diff --git a/samples/ds/service-provider/pom.xml b/samples/ds/service-provider/pom.xml
index 854a780..3340b34 100644
--- a/samples/ds/service-provider/pom.xml
+++ b/samples/ds/service-provider/pom.xml
@@ -28,7 +28,7 @@
<dependencies>
<dependency>
<groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-starter-ds</artifactId>
+ <artifactId>karaf-boot-starter</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/1d8892a2/starters/karaf-boot-starter-ds/pom.xml
----------------------------------------------------------------------
diff --git a/starters/karaf-boot-starter-ds/pom.xml b/starters/karaf-boot-starter-ds/pom.xml
deleted file mode 100644
index 331c8e2..0000000
--- a/starters/karaf-boot-starter-ds/pom.xml
+++ /dev/null
@@ -1,52 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<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">
-
- <!--
-
- 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.
- -->
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-starters</artifactId>
- <version>1.0.0-SNAPSHOT</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
-
- <artifactId>karaf-boot-starter-ds</artifactId>
-
- <dependencies>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>osgi.cmpn</artifactId>
- <version>${osgi.version}</version>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <compilerArgument>-proc:none</compilerArgument>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/1d8892a2/starters/karaf-boot-starter-ds/src/main/java/org/apache/karaf/boot/ds/impl/DsProcessor.java
----------------------------------------------------------------------
diff --git a/starters/karaf-boot-starter-ds/src/main/java/org/apache/karaf/boot/ds/impl/DsProcessor.java b/starters/karaf-boot-starter-ds/src/main/java/org/apache/karaf/boot/ds/impl/DsProcessor.java
deleted file mode 100644
index 49baa70..0000000
--- a/starters/karaf-boot-starter-ds/src/main/java/org/apache/karaf/boot/ds/impl/DsProcessor.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package org.apache.karaf.boot.ds.impl;
-
-import javax.annotation.processing.AbstractProcessor;
-import javax.annotation.processing.RoundEnvironment;
-import javax.lang.model.element.TypeElement;
-import javax.tools.Diagnostic.Kind;
-import javax.tools.FileObject;
-import javax.tools.StandardLocation;
-import java.io.CharArrayWriter;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.Reader;
-import java.io.Writer;
-import java.util.HashSet;
-import java.util.Set;
-
-public class DsProcessor extends AbstractProcessor {
-
- boolean hasRun;
-
- public DsProcessor() {
- }
-
- @Override
- public Set<String> getSupportedAnnotationTypes() {
- Set<String> set = new HashSet<String>();
- set.add(org.osgi.service.component.annotations.Component.class.getName());
- return set;
- }
-
- @Override
- public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
- if (!hasRun) {
- hasRun = true;
- // Add the Karaf embedded package
- try (PrintWriter w = appendResource("META-INF/org.apache.karaf.boot.bnd")) {
- w.println("_dsannotations: *");
- } catch (Exception e) {
- processingEnv.getMessager().printMessage(Kind.ERROR, "Error: " + e.getMessage());
- }
- }
- return true;
- }
-
- private PrintWriter appendResource(String resource) throws IOException {
- try {
- FileObject o = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", resource);
- return new PrintWriter(o.openWriter());
- } catch (Exception e) {
- try {
- FileObject o = processingEnv.getFiler().getResource(StandardLocation.CLASS_OUTPUT, "", resource);
- CharArrayWriter baos = new CharArrayWriter();
- try (Reader r = o.openReader(true)) {
- char[] buf = new char[4096];
- int l;
- while ((l = r.read(buf)) > 0) {
- baos.write(buf, 0, l);
- }
- }
- o.delete();
- o = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", resource);
- Writer w = o.openWriter();
- w.write(baos.toCharArray());
- return new PrintWriter(w);
- } catch (Exception e2) {
- e2.addSuppressed(e);
- e2.printStackTrace();
- throw e2;
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/1d8892a2/starters/karaf-boot-starter-ds/src/main/resources/META-INF/services/javax.annotation.processing.Processor
----------------------------------------------------------------------
diff --git a/starters/karaf-boot-starter-ds/src/main/resources/META-INF/services/javax.annotation.processing.Processor b/starters/karaf-boot-starter-ds/src/main/resources/META-INF/services/javax.annotation.processing.Processor
deleted file mode 100644
index 11ef8af..0000000
--- a/starters/karaf-boot-starter-ds/src/main/resources/META-INF/services/javax.annotation.processing.Processor
+++ /dev/null
@@ -1 +0,0 @@
-org.apache.karaf.boot.ds.impl.DsProcessor
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/1d8892a2/starters/karaf-boot-starter/pom.xml
----------------------------------------------------------------------
diff --git a/starters/karaf-boot-starter/pom.xml b/starters/karaf-boot-starter/pom.xml
index e5b2742..1c5380a 100644
--- a/starters/karaf-boot-starter/pom.xml
+++ b/starters/karaf-boot-starter/pom.xml
@@ -36,6 +36,11 @@
<artifactId>org.osgi.core</artifactId>
<version>${osgi.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>osgi.cmpn</artifactId>
+ <version>${osgi.version}</version>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/1d8892a2/starters/pom.xml
----------------------------------------------------------------------
diff --git a/starters/pom.xml b/starters/pom.xml
index 57dbd39..9a4adf1 100644
--- a/starters/pom.xml
+++ b/starters/pom.xml
@@ -34,7 +34,6 @@
<modules>
<module>karaf-boot-starter</module>
<module>karaf-boot-starter-karaf</module>
- <module>karaf-boot-starter-ds</module>
<module>karaf-boot-starter-shell</module>
<module>karaf-boot-starter-web</module>
<module>karaf-boot-starter-jpa</module>
@@ -42,4 +41,4 @@
<module>karaf-boot-starter-blueprint</module>
</modules>
-</project>
\ No newline at end of file
+</project>
[28/35] karaf-boot git commit: Add config support for service
provider and remove config module
Posted by cs...@apache.org.
Add config support for service provider and remove config module
Project: http://git-wip-us.apache.org/repos/asf/karaf-boot/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-boot/commit/c615578e
Tree: http://git-wip-us.apache.org/repos/asf/karaf-boot/tree/c615578e
Diff: http://git-wip-us.apache.org/repos/asf/karaf-boot/diff/c615578e
Branch: refs/heads/master
Commit: c615578e45a5e70e6a60efedc547d021346a1681
Parents: 1d8892a
Author: Christian Schneider <ch...@die-schneider.net>
Authored: Mon Apr 25 13:03:42 2016 +0200
Committer: Christian Schneider <ch...@die-schneider.net>
Committed: Mon Apr 25 13:03:42 2016 +0200
----------------------------------------------------------------------
samples/ds/config/README.md | 31 -------------
samples/ds/config/pom.xml | 47 --------------------
.../java/sample/config/ConfigComponent.java | 43 ------------------
samples/ds/pom.xml | 3 +-
samples/ds/service-consumer/README.md | 25 +++--------
samples/ds/service-consumer/pom.xml | 4 +-
.../ds/service/consumer/HelloServiceClient.java | 8 +---
samples/ds/service-provider/README.md | 27 ++++-------
samples/ds/service-provider/pom.xml | 2 +-
.../ds/service/provider/HelloServiceImpl.java | 22 ++++++++-
samples/ds/shell/pom.xml | 2 +-
11 files changed, 43 insertions(+), 171 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/c615578e/samples/ds/config/README.md
----------------------------------------------------------------------
diff --git a/samples/ds/config/README.md b/samples/ds/config/README.md
deleted file mode 100644
index 1c8dbc5..0000000
--- a/samples/ds/config/README.md
+++ /dev/null
@@ -1,31 +0,0 @@
-== karaf-boot-sample-config ==
-
-This sample shows how to use a configuration provided in the etc folder of Karaf, and directly use the
-properties values in your code.
-
-= Design
-
-The ConfigComponent use a SampleConfig configuration. The SampleConfig configuration is "injected" at activation
-time of the component.
-
-The component just displays the values of the properties.
-
-= Build
-
-To build, simply do:
-
- mvn clean install
-
-= Deploy
-
-To deploy in Karaf, you have to enable the DS support first. For that, you have to install the scr feature:
-
- feature:install scr
-
-Once scr feature installed:
-
-* you can drop the generated jar file (target/karaf-boot-sample-config-1.0.jar) in the
-Karaf deploy folder
-* in the Karaf shell console, do:
-
- bundle:install -s mvn:org.apache.karaf.boot/karaf-boot-sample-config/1.0
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/c615578e/samples/ds/config/pom.xml
----------------------------------------------------------------------
diff --git a/samples/ds/config/pom.xml b/samples/ds/config/pom.xml
deleted file mode 100644
index 688150b..0000000
--- a/samples/ds/config/pom.xml
+++ /dev/null
@@ -1,47 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<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">
-
- <!--
-
- 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.
- -->
-
- <modelVersion>4.0.0</modelVersion>
-
- <groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-sample-config</artifactId>
- <version>1.0.0-SNAPSHOT</version>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-starter-ds</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-maven-plugin</artifactId>
- <version>${project.version}</version>
- <extensions>true</extensions>
- </plugin>
- </plugins>
- </build>
-
-</project>
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/c615578e/samples/ds/config/src/main/java/sample/config/ConfigComponent.java
----------------------------------------------------------------------
diff --git a/samples/ds/config/src/main/java/sample/config/ConfigComponent.java b/samples/ds/config/src/main/java/sample/config/ConfigComponent.java
deleted file mode 100644
index 52cf369..0000000
--- a/samples/ds/config/src/main/java/sample/config/ConfigComponent.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * 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 sample.config;
-
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.metatype.annotations.Designate;
-import org.osgi.service.metatype.annotations.ObjectClassDefinition;
-
-@ObjectClassDefinition(name = "Sample Configuration", pid = "org.apache.karaf.boot.sample.config")
-@interface SampleConfig {
- String stringProperty() default "default";
- int intProperty() default 0;
- boolean booleanProperty() default false;
-}
-
-@Component
-@Designate(ocd = SampleConfig.class)
-public class ConfigComponent {
-
- @Activate
- public void activate(SampleConfig sampleConfig) {
- System.out.println("We use the property there");
- System.out.println("stringProperty:" + sampleConfig.stringProperty());
- System.out.println("intProperty: " + sampleConfig.intProperty());
- System.out.println("booleanProperty: " + sampleConfig.booleanProperty());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/c615578e/samples/ds/pom.xml
----------------------------------------------------------------------
diff --git a/samples/ds/pom.xml b/samples/ds/pom.xml
index f031e88..7005d78 100644
--- a/samples/ds/pom.xml
+++ b/samples/ds/pom.xml
@@ -22,12 +22,11 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-samples-ds</artifactId>
+ <artifactId>karaf-boot-sample-ds</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
- <module>config</module>
<module>service-consumer</module>
<module>service-provider</module>
<module>shell</module>
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/c615578e/samples/ds/service-consumer/README.md
----------------------------------------------------------------------
diff --git a/samples/ds/service-consumer/README.md b/samples/ds/service-consumer/README.md
index ae04875..1f2b683 100644
--- a/samples/ds/service-consumer/README.md
+++ b/samples/ds/service-consumer/README.md
@@ -1,36 +1,23 @@
-== karaf-boot-sample-service-provider-osgi ==
+== karaf-boot-sample-ds-service-consumer ==
-This sample exposes an OSGi service using the Karaf util classe and annotation.
+This sample binds and uses an OSGi service using declarative services (DS).
= Design
-This artifact uses the hello service provided by another artifact (karaf-boot-sample-service-provider-ds for instance).
+This artifact uses the hello service.
It uses the DS annotations to create a bean with a reference (@Reference) to the hello service.
In the HelloServiceClient bean, we use the @Activate annotation to execute a specific method.
-You don't think anything else: karaf-boot will generate all the plumbing for you, and you will directly have a ready
-to use artifact.
-
= Build
-To build, simply do:
-
mvn clean install
= Deploy
-To deploy in Karaf, you have to enable the DS support first. For that, you have to install the scr feature:
+We need to enable DS support and install the service as well as the consumer
feature:install scr
+ bundle:install -s mvn:org.apache.karaf.boot/karaf-boot-sample-ds-service-consumer/1.0.0-SNAPSHOT
+ bundle:install -s mvn:org.apache.karaf.boot/karaf-boot-sample-ds-service-consumer/1.0.0-SNAPSHOT
-Once scr feature installed, you have to install a hello service provider. Please use any of karaf-boot-sample-service-provider-*
-deployment first.
-
-Once the service provider is installed:
-
-* you can drop the generated jar file (target/karaf-boot-sample-service-consumer-ds-1.0.jar) in the
-Karaf deploy folder
-* in the Karaf shell console, do:
-
- bundle:install -s mvn:org.apache.karaf.boot/karaf-boot-sample-service-consumer-ds/1.0
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/c615578e/samples/ds/service-consumer/pom.xml
----------------------------------------------------------------------
diff --git a/samples/ds/service-consumer/pom.xml b/samples/ds/service-consumer/pom.xml
index 3048e77..0324230 100644
--- a/samples/ds/service-consumer/pom.xml
+++ b/samples/ds/service-consumer/pom.xml
@@ -22,7 +22,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-sample-service-consumer-ds</artifactId>
+ <artifactId>karaf-boot-sample-ds-service-consumer</artifactId>
<version>1.0.0-SNAPSHOT</version>
<dependencies>
@@ -33,7 +33,7 @@
</dependency>
<dependency>
<groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-sample-service-provider-ds</artifactId>
+ <artifactId>karaf-boot-sample-ds-service-provider</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/c615578e/samples/ds/service-consumer/src/main/java/sample/ds/service/consumer/HelloServiceClient.java
----------------------------------------------------------------------
diff --git a/samples/ds/service-consumer/src/main/java/sample/ds/service/consumer/HelloServiceClient.java b/samples/ds/service-consumer/src/main/java/sample/ds/service/consumer/HelloServiceClient.java
index f70ebf7..f4ac3fd 100644
--- a/samples/ds/service-consumer/src/main/java/sample/ds/service/consumer/HelloServiceClient.java
+++ b/samples/ds/service-consumer/src/main/java/sample/ds/service/consumer/HelloServiceClient.java
@@ -25,7 +25,8 @@ import sample.ds.service.provider.HelloService;
@Component
public class HelloServiceClient implements Runnable {
- private HelloService helloService;
+ @Reference
+ HelloService helloService;
private Thread thread;
@@ -51,9 +52,4 @@ public class HelloServiceClient implements Runnable {
}
}
- @Reference
- public void setHelloService(HelloService helloService) {
- this.helloService = helloService;
- }
-
}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/c615578e/samples/ds/service-provider/README.md
----------------------------------------------------------------------
diff --git a/samples/ds/service-provider/README.md b/samples/ds/service-provider/README.md
index 94066f1..a97bee8 100644
--- a/samples/ds/service-provider/README.md
+++ b/samples/ds/service-provider/README.md
@@ -1,35 +1,26 @@
-== karaf-boot-sample-service-provider-ds ==
+== karaf-boot-sample-ds-service-provider ==
-This sample exposes an OSGi service using the Karaf util classe and annotation.
+Exposes and configures a service using declarative services
= Design
-The service "contract" is describe by the Hello interface. It's a very simple service that expose one operation (hello).
-The service client send a message (String) to the hello service and he gets a response.
+The service "contract" is described by the Hello interface. It's a very simple service that expose one operation (hello).
+The service client sends a message (String) to the hello service and he gets a response.
-The HelloServiceImpl is very simple: it prefixes the message with "Hello".
+Additionally the example shows how to inject configuration into a service by using the type safe configurations of DS 1.3.
-We use the @Component DS annotation on HelloServiceImpl implementation in order to expose the service.
+The HelloServiceImpl is very simple: it prefixes the message with "Hello" and adds the configured name.
-You don't think anything else: karaf-boot will generate all the plumbing for you, and you will directly have a ready
-to use artifact.
+We use the @Component DS annotation on HelloServiceImpl implementation in order to expose the service.
= Build
-To build, simply do:
-
mvn clean install
= Deploy
-To deploy in Karaf, you have to enable the DS support first. For that, you have to install the scr feature:
+We enable DS support and install the example
feature:install scr
+ bundle:install -s mvn:org.apache.karaf.boot/karaf-boot-sample-service-provider-ds/1.0
-Once scr feature installed:
-
-* you can drop the generated jar file (target/karaf-boot-sample-service-provider-ds-1.0.jar) in the
-Karaf deploy folder
-* in the Karaf shell console, do:
-
- bundle:install -s mvn:org.apache.karaf.boot/karaf-boot-sample-service-provider-ds/1.0
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/c615578e/samples/ds/service-provider/pom.xml
----------------------------------------------------------------------
diff --git a/samples/ds/service-provider/pom.xml b/samples/ds/service-provider/pom.xml
index 3340b34..f24cb81 100644
--- a/samples/ds/service-provider/pom.xml
+++ b/samples/ds/service-provider/pom.xml
@@ -22,7 +22,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-sample-service-provider-ds</artifactId>
+ <artifactId>karaf-boot-sample-ds-service-provider</artifactId>
<version>1.0.0-SNAPSHOT</version>
<dependencies>
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/c615578e/samples/ds/service-provider/src/main/java/sample/ds/service/provider/HelloServiceImpl.java
----------------------------------------------------------------------
diff --git a/samples/ds/service-provider/src/main/java/sample/ds/service/provider/HelloServiceImpl.java b/samples/ds/service-provider/src/main/java/sample/ds/service/provider/HelloServiceImpl.java
index 5319a47..c316a3f 100644
--- a/samples/ds/service-provider/src/main/java/sample/ds/service/provider/HelloServiceImpl.java
+++ b/samples/ds/service-provider/src/main/java/sample/ds/service/provider/HelloServiceImpl.java
@@ -16,16 +16,36 @@
*/
package sample.ds.service.provider;
+import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
+import org.osgi.service.metatype.annotations.Designate;
+import org.osgi.service.metatype.annotations.ObjectClassDefinition;
/**
* Simple implementation of the hello service..
*/
@Component
+@Designate(ocd = SampleConfig.class)
public class HelloServiceImpl implements HelloService {
+ private String name;
+
public String hello(String message) {
- return "Hello " + message + " !";
+ return String.format("Hello %s my name is %s!", message, name);
+ }
+
+ @Activate
+
+ public void activate(SampleConfig sampleConfig) {
+ this.name = sampleConfig.name();
}
+
}
+
+@ObjectClassDefinition(name = "Sample Configuration", pid = "org.apache.karaf.boot.sample.config")
+@interface SampleConfig {
+ String name() default "default";
+ int intProperty() default 0;
+ boolean booleanProperty() default false;
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/c615578e/samples/ds/shell/pom.xml
----------------------------------------------------------------------
diff --git a/samples/ds/shell/pom.xml b/samples/ds/shell/pom.xml
index 1df8632..20c8cd3 100644
--- a/samples/ds/shell/pom.xml
+++ b/samples/ds/shell/pom.xml
@@ -22,7 +22,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-sample-shell</artifactId>
+ <artifactId>karaf-boot-sample-ds-shell</artifactId>
<version>1.0.0-SNAPSHOT</version>
<dependencies>
[03/35] karaf-boot git commit: Initial proposal
Posted by cs...@apache.org.
Initial proposal
Project: http://git-wip-us.apache.org/repos/asf/karaf-boot/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-boot/commit/a0248b78
Tree: http://git-wip-us.apache.org/repos/asf/karaf-boot/tree/a0248b78
Diff: http://git-wip-us.apache.org/repos/asf/karaf-boot/diff/a0248b78
Branch: refs/heads/master
Commit: a0248b78854b61535c55bf748a9159a093a624c9
Parents:
Author: Jean-Baptiste Onofr� <jb...@apache.org>
Authored: Wed Sep 9 16:09:55 2015 +0200
Committer: Jean-Baptiste Onofr� <jb...@apache.org>
Committed: Wed Sep 9 16:09:55 2015 +0200
----------------------------------------------------------------------
.gitignore | 10 +
LICENSE | 475 +++++++++++++++++++
README.md | 12 +
karaf-boot-parent/pom.xml | 73 +++
karaf-boot-samples/README.md | 20 +
.../karaf-boot-sample-simple/pom.xml | 33 ++
.../karaf/boot/sample/simple/SimpleBean.java | 14 +
karaf-boot-starter/README.md | 11 +
karaf-boot-starter/pom.xml | 34 ++
.../karaf-boot-maven-plugin/pom.xml | 77 +++
.../tools/maven/plugin/FilteredClassFinder.java | 60 +++
.../boot/tools/maven/plugin/GenerateMojo.java | 107 +++++
.../boot/tools/maven/plugin/Generator.java | 223 +++++++++
.../maven/plugin/OsgiServiceProviderWriter.java | 86 ++++
.../boot/tools/maven/plugin/model/Bean.java | 152 ++++++
.../boot/tools/maven/plugin/model/BeanRef.java | 69 +++
.../boot/tools/maven/plugin/model/Context.java | 121 +++++
.../plugin/model/JavaxTransactionFactory.java | 40 ++
.../boot/tools/maven/plugin/model/Matcher.java | 23 +
.../maven/plugin/model/OsgiServiceRef.java | 41 ++
.../tools/maven/plugin/model/ProducedBean.java | 13 +
.../boot/tools/maven/plugin/model/Property.java | 90 ++++
.../maven/plugin/model/PropertyWriter.java | 23 +
.../plugin/model/SpringTransactionFactory.java | 40 ++
.../maven/plugin/model/TransactionalDef.java | 39 ++
.../boot/tools/maven/plugin/GeneratorTest.java | 99 ++++
.../boot/tools/maven/plugin/Namespaces.java | 54 +++
.../boot/tools/maven/plugin/model/BeanTest.java | 92 ++++
.../tools/maven/plugin/model/ContextTest.java | 84 ++++
.../tools/maven/plugin/model/PropertyTest.java | 73 +++
.../maven/plugin/model/TestBeanForRef.java | 39 ++
.../boot/tools/maven/plugin/test/MyBean1.java | 52 ++
.../boot/tools/maven/plugin/test/MyBean3.java | 50 ++
.../boot/tools/maven/plugin/test/MyBean4.java | 13 +
.../tools/maven/plugin/test/MyFactoryBean.java | 17 +
.../tools/maven/plugin/test/MyProduced.java | 18 +
.../tools/maven/plugin/test/ParentBean.java | 33 ++
.../boot/tools/maven/plugin/test/ServiceA.java | 23 +
.../tools/maven/plugin/test/ServiceAImpl1.java | 28 ++
.../tools/maven/plugin/test/ServiceAImpl2.java | 34 ++
.../boot/tools/maven/plugin/test/ServiceB.java | 23 +
.../maven/plugin/test/ServiceReferences.java | 33 ++
karaf-boot-tools/pom.xml | 38 ++
karaf-boot/README.md | 5 +
karaf-boot/pom.xml | 33 ++
.../main/java/org/apache/karaf/boot/Arg.java | 53 +++
.../main/java/org/apache/karaf/boot/Bean.java | 79 +++
.../main/java/org/apache/karaf/boot/Bind.java | 31 ++
.../java/org/apache/karaf/boot/Destroy.java | 31 ++
.../java/org/apache/karaf/boot/Element.java | 43 ++
.../main/java/org/apache/karaf/boot/Init.java | 31 ++
.../main/java/org/apache/karaf/boot/Inject.java | 32 ++
.../main/java/org/apache/karaf/boot/List.java | 36 ++
.../java/org/apache/karaf/boot/Reference.java | 69 +++
.../org/apache/karaf/boot/ReferenceList.java | 67 +++
.../apache/karaf/boot/ReferenceListener.java | 28 ++
.../java/org/apache/karaf/boot/Register.java | 31 ++
.../apache/karaf/boot/RegistrationListener.java | 29 ++
.../java/org/apache/karaf/boot/Service.java | 56 +++
.../org/apache/karaf/boot/ServiceProperty.java | 36 ++
.../main/java/org/apache/karaf/boot/Unbind.java | 31 ++
.../java/org/apache/karaf/boot/Unregister.java | 31 ++
pom.xml | 43 ++
63 files changed, 3484 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/a0248b78/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..22d0ed1
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,10 @@
+*.i??
+.idea
+.project
+.classpath
+.settings
+target
+eclipse-classes
+atlassian-ide-plugin.xml
+bin
+dependency-reduced-pom.xml
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/a0248b78/LICENSE
----------------------------------------------------------------------
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..b36a53d
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,475 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed 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.
+
+For asm:
+Copyright (c) 2000-2011 INRIA, France Telecom
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+3. Neither the name of the copyright holders nor the names of its
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+THE POSSIBILITY OF SUCH DAMAGE.
+
+For equinox:
+Eclipse Public License - v 1.0
+
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT").
+ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
+
+1. DEFINITIONS
+
+"Contribution" means:
+
+a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and
+
+b) in the case of each subsequent Contributor:
+
+i) changes to the Program, and
+
+ii) additions to the Program;
+
+where such changes and/or additions to the Program originate from and are distributed by that particular Contributor.
+A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone
+acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate
+modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not
+derivative works of the Program.
+
+"Contributor" means any person or entity that distributes the Program.
+
+"Licensed Patents" mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale
+of its Contribution alone or when combined with the Program.
+
+"Program" means the Contributions distributed in accordance with this Agreement.
+
+"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.
+
+2. GRANT OF RIGHTS
+
+a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide,
+royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform,
+distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code
+and object code form.
+
+b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide,
+royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer
+the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to
+the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such
+addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall
+not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.
+
+c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no
+assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property
+rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity
+based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses
+granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights
+needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program,
+it is Recipient's responsibility to acquire that license before distributing the Program.
+
+d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any,
+to grant the copyright license set forth in this Agreement.
+
+3. REQUIREMENTS
+
+A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:
+
+a) it complies with the terms and conditions of this Agreement; and
+
+b) its license agreement:
+
+i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including
+warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and
+fitness for a particular purpose;
+
+ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special,
+incidental and consequential damages, such as lost profits;
+
+iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any
+other party; and
+
+iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain
+it in a reasonable manner on or through a medium customarily used for software exchange.
+
+When the Program is made available in source code form:
+
+a) it must be made available under this Agreement; and
+
+b) a copy of this Agreement must be included with each copy of the Program.
+
+Contributors may not remove or alter any copyright notices contained within the Program.
+
+Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably
+allows subsequent Recipients to identify the originator of the Contribution.
+
+4. COMMERCIAL DISTRIBUTION
+
+Commercial distributors of software may accept certain responsibilities with respect to end users, business partners
+and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who
+includes the Program in a commercial product offering should do so in a manner which does not create potential
+liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering,
+such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor
+("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims,
+lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused
+by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a
+commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any
+actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly
+notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and
+cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The
+Indemnified Contributor may participate in any such claim at its own expense.
+
+For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is
+then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties
+related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone.
+Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to
+those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result,
+the Commercial Contributor must pay those damages.
+
+5. NO WARRANTY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
+CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE,
+NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for
+determining the appropriateness of using and distributing the Program and assumes all risks associated with its
+exercise of rights under this Agreement , including but not limited to the risks and costs of program errors,
+compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption
+of operations.
+
+6. DISCLAIMER OF LIABILITY
+
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST
+PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS
+GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+7. GENERAL
+
+If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity
+or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto,
+such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
+
+If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit)
+alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes
+such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date
+such litigation is filed.
+
+All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or
+conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of
+such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and
+distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement
+and any licenses granted by Recipient relating to the Program shall continue and survive.
+
+Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the
+Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right
+to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement
+Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse
+Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new
+version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may
+always be distributed subject to the version of the Agreement under which it was received. In addition, after a new
+version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions)
+under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or
+licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication,
+estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.
+
+This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States
+of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the
+cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.
+
+For Java Service Wrapper:
+Copyright (c) 1999, 2006 Tanuki Software, Inc.
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of the Java Service Wrapper and associated
+documentation files (the "Software"), to deal in the Software
+without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sub-license,
+and/or sell copies of the Software, and to permit persons to
+whom the Software is furnished to do so, subject to the
+following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+
+Portions of the Software have been derived from source code
+developed by Silver Egg Technology under the following license:
+
+BEGIN Silver Egg Techology License -----------------------------------
+
+ Copyright (c) 2001 Silver Egg Technology
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation
+ files (the "Software"), to deal in the Software without
+ restriction, including without limitation the rights to use,
+ copy, modify, merge, publish, distribute, sub-license, and/or
+ sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following
+ conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ OTHER DEALINGS IN THE SOFTWARE.
+
+END Silver Egg Techology License -------------------------------------
+
+For slf4j
+Copyright (c) 2004-2011 QOS.ch
+All rights reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/a0248b78/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..40eb582
--- /dev/null
+++ b/README.md
@@ -0,0 +1,12 @@
+Apache Karaf Boot
+-----------------
+
+Karaf Boot provides an easy way to create artifacts ready to be deployed in Karaf, and also possibility to embed, configure, and bootstrap Karaf in a ready to run artifact.
+
+You focus on your business, and Karaf Boot deals with all the "plumbing" for you.
+
+Karaf Boot provides:
+
+* set of dependencies providing annotations that you can use directly in your code: you focus on your business code, Karaf Boot does the rest
+* a Maven plugin processing the annotations to create key turn artifacts
+* an utility start to easily embed, configure, and bootstrap Karaf
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/a0248b78/karaf-boot-parent/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-parent/pom.xml b/karaf-boot-parent/pom.xml
new file mode 100644
index 0000000..9142128
--- /dev/null
+++ b/karaf-boot-parent/pom.xml
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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>
+
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-parent</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-maven-plugin</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <inherited>true</inherited>
+ <extensions>true</extensions>
+ <executions>
+ <execution>
+ <phase>generate-resources</phase>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ <configuration>
+ <scanPaths>
+ <scanPath>${project.build.sourceDirectory}</scanPath>
+ </scanPaths>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>2.5.4</version>
+ <inherited>true</inherited>
+ <extensions>true</extensions>
+ <configuration>
+ <supportedProjectTypes>
+ <supportedProjectType>jar</supportedProjectType>
+ <supportedProjectType>war</supportedProjectType>
+ </supportedProjectTypes>
+ </configuration>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>bundle</goal>
+ </goals>
+ <configuration>
+ <instructions>
+ <Import-Package>
+ org.apache.karaf.boot*;resolution:=optional,
+ *
+ </Import-Package>
+ </instructions>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/a0248b78/karaf-boot-samples/README.md
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/README.md b/karaf-boot-samples/README.md
new file mode 100644
index 0000000..31be07a
--- /dev/null
+++ b/karaf-boot-samples/README.md
@@ -0,0 +1,20 @@
+* karaf-boot-simple
+ Simple bean
+* karaf-boot-service-provider
+ Service provider
+* karaf-boot-service-consumer
+ Service consumer
+* karaf-boot-config-managed
+ Managed by configuration (reload)
+* karaf-boot-servlet
+ Servlet provider
+* karaf-boot-rest
+ REST service provider
+* karaf-boot-soap
+ SOAP service provider
+* karaf-boot-jpa
+ JPA implementation
+* karaf-boot-profile
+ Build a profile based on karaf-boot definition
+* karaf-boot-starter
+ Package and configure Karaf as a ready to run artifact
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/a0248b78/karaf-boot-samples/karaf-boot-sample-simple/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-simple/pom.xml b/karaf-boot-samples/karaf-boot-sample-simple/pom.xml
new file mode 100644
index 0000000..538503d
--- /dev/null
+++ b/karaf-boot-samples/karaf-boot-sample-simple/pom.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+
+ <!--
+
+ 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.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-parent</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>karaf-boot-sample-simple</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/a0248b78/karaf-boot-samples/karaf-boot-sample-simple/src/main/java/org/apache/karaf/boot/sample/simple/SimpleBean.java
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-simple/src/main/java/org/apache/karaf/boot/sample/simple/SimpleBean.java b/karaf-boot-samples/karaf-boot-sample-simple/src/main/java/org/apache/karaf/boot/sample/simple/SimpleBean.java
new file mode 100644
index 0000000..b89f733
--- /dev/null
+++ b/karaf-boot-samples/karaf-boot-sample-simple/src/main/java/org/apache/karaf/boot/sample/simple/SimpleBean.java
@@ -0,0 +1,14 @@
+package org.apache.karaf.boot.sample.simple;
+
+import org.apache.karaf.boot.Bean;
+import org.apache.karaf.boot.Init;
+
+@Bean(id = "simple-bean")
+public class SimpleBean {
+
+ @Init
+ public void simple() {
+ System.out.println("Hello world");
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/a0248b78/karaf-boot-starter/README.md
----------------------------------------------------------------------
diff --git a/karaf-boot-starter/README.md b/karaf-boot-starter/README.md
new file mode 100644
index 0000000..43dc8e3
--- /dev/null
+++ b/karaf-boot-starter/README.md
@@ -0,0 +1,11 @@
+Karaf Boot Starter
+------------------
+Karaf Boot Starter provides a convenient way to create a ready to execute artifact, embedding Karaf.
+
+You just have to extend the KarafApplication class. In the config() method, you can define:
+- the configuration
+- the bundles
+- the features
+of your embedded Karaf instance.
+
+The Karaf Boot Starter Maven plugin will create the "key turn" jar that you can execute directly, on any machine.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/a0248b78/karaf-boot-starter/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-starter/pom.xml b/karaf-boot-starter/pom.xml
new file mode 100644
index 0000000..20fd28e
--- /dev/null
+++ b/karaf-boot-starter/pom.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+
+ <!--
+
+ 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.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-build</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>karaf-boot-starter</artifactId>
+ <packaging>pom</packaging>
+
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/a0248b78/karaf-boot-tools/karaf-boot-maven-plugin/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/pom.xml b/karaf-boot-tools/karaf-boot-maven-plugin/pom.xml
new file mode 100644
index 0000000..19bb184
--- /dev/null
+++ b/karaf-boot-tools/karaf-boot-maven-plugin/pom.xml
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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.karaf.boot</groupId>
+ <artifactId>karaf-boot-tools</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>karaf-boot-maven-plugin</artifactId>
+ <packaging>maven-plugin</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>javax.inject</groupId>
+ <artifactId>javax.inject</artifactId>
+ <version>1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.xbean</groupId>
+ <artifactId>xbean-finder-shaded</artifactId>
+ <version>4.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ <version>4.1.0.RELEASE</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-tx</artifactId>
+ <version>4.1.0.RELEASE</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.persistence</groupId>
+ <artifactId>persistence-api</artifactId>
+ <version>1.0.2</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.transaction</groupId>
+ <artifactId>javax.transaction-api</artifactId>
+ <version>1.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.cdi</groupId>
+ <artifactId>pax-cdi-api</artifactId>
+ <version>0.9.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-api</artifactId>
+ <version>3.1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-core</artifactId>
+ <version>3.1.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.12</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>2.4</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/a0248b78/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/FilteredClassFinder.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/FilteredClassFinder.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/FilteredClassFinder.java
new file mode 100644
index 0000000..7ba607b
--- /dev/null
+++ b/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/FilteredClassFinder.java
@@ -0,0 +1,60 @@
+/**
+ * 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.karaf.boot.tools.maven.plugin;
+
+import java.lang.annotation.Annotation;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.inject.Singleton;
+
+import org.apache.xbean.finder.ClassFinder;
+import org.springframework.stereotype.Component;
+
+public class FilteredClassFinder {
+
+ @SuppressWarnings("unchecked")
+ public static Set<Class<?>> findClasses(ClassFinder finder, Collection<String> packageNames) {
+ return findClasses(finder, packageNames, new Class[]{Singleton.class, Component.class});
+ }
+
+ public static Set<Class<?>> findClasses(ClassFinder finder, Collection<String> packageNames, Class<? extends Annotation>[] annotations) {
+ Set<Class<?>> rawClasses = new HashSet<Class<?>>();
+ for (Class<? extends Annotation> annotation : annotations) {
+ rawClasses.addAll(finder.findAnnotatedClasses(annotation));
+ }
+ return filterByBasePackages(rawClasses, packageNames);
+ }
+
+ private static Set<Class<?>> filterByBasePackages(Set<Class<?>> rawClasses, Collection<String> packageNames) {
+ Set<Class<?>> filteredClasses = new HashSet<Class<?>>();
+ for (Class<?> clazz : rawClasses) {
+ for (String packageName : packageNames) {
+ if (clazz.getPackage().getName().startsWith(packageName)) {
+ filteredClasses.add(clazz);
+ continue;
+ }
+ }
+ }
+ //System.out.println("Raw: " + rawClasses);
+ //System.out.println("Filtered: " + beanClasses);
+ return filteredClasses;
+ }
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/a0248b78/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/GenerateMojo.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/GenerateMojo.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/GenerateMojo.java
new file mode 100644
index 0000000..72d5f28
--- /dev/null
+++ b/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/GenerateMojo.java
@@ -0,0 +1,107 @@
+/**
+ * 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.karaf.boot.tools.maven.plugin;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.karaf.boot.tools.maven.plugin.model.Context;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.model.Resource;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.project.MavenProject;
+import org.apache.xbean.finder.ClassFinder;
+
+/**
+ * Generates blueprint from spring annotations
+ * @goal generate
+ * @phase process-classes
+ * @requiresDependencyResolution compile
+ * @inheritByDefault false
+ * @description Generates artifact using karaf-boot annotations and supporting spring annotations @Component, @Autowire and @Value
+ */
+public class GenerateMojo extends AbstractMojo {
+
+ /**
+ * The maven project.
+ *
+ * @parameter default-value="${project}"
+ * @required
+ */
+ protected MavenProject project;
+
+ /**
+ * @parameter
+ * @required
+ */
+ protected List<String> scanPaths;
+
+ /**
+ * true: Purely annotated mode (needs jpa 2.1.0 and transaction-blueprint 1.1.0)
+ * false: XML based mode for JPA 1.x and transaction-blueprint < 1.1.0
+ * @parameter default-value="true"
+ * @required
+ */
+ protected boolean persistenceAnnotated;
+
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ try {
+ String buildDir = project.getBuild().getDirectory();
+ String generatedDir = buildDir + "/generated-resources";
+ Resource resource = new Resource();
+ resource.setDirectory(generatedDir);
+ project.addResource(resource);
+ ClassFinder finder = createProjectScopeFinder();
+
+ File file = new File(generatedDir, "OSGI-INF/blueprint/autowire.xml");
+ file.getParentFile().mkdirs();
+ System.out.println("Generating blueprint to " + file);
+ Set<Class<?>> classes = FilteredClassFinder.findClasses(finder, scanPaths);
+ Context context = new Context(classes);
+ context.resolve();
+ new Generator(context, new FileOutputStream(file), persistenceAnnotated).generate();
+ } catch (Exception e) {
+ throw new MojoExecutionException("Error building commands help", e);
+ }
+ }
+
+ private ClassFinder createProjectScopeFinder() throws MalformedURLException {
+ List<URL> urls = new ArrayList<URL>();
+
+ urls.add( new File(project.getBuild().getOutputDirectory()).toURI().toURL() );
+ for ( Object artifactO : project.getArtifacts() ) {
+ Artifact artifact = (Artifact)artifactO;
+ File file = artifact.getFile();
+ if ( file != null ) {
+ urls.add( file.toURI().toURL() );
+ }
+ }
+ ClassLoader loader = new URLClassLoader(urls.toArray(new URL[urls.size()]), getClass().getClassLoader());
+ return new ClassFinder(loader, urls);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/a0248b78/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/Generator.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/Generator.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/Generator.java
new file mode 100644
index 0000000..8806d05
--- /dev/null
+++ b/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/Generator.java
@@ -0,0 +1,223 @@
+/**
+ * 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.karaf.boot.tools.maven.plugin;
+
+import java.io.OutputStream;
+import java.lang.reflect.Field;
+
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceUnit;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.karaf.boot.tools.maven.plugin.model.Bean;
+import org.apache.karaf.boot.tools.maven.plugin.model.Context;
+import org.apache.karaf.boot.tools.maven.plugin.model.OsgiServiceRef;
+import org.apache.karaf.boot.tools.maven.plugin.model.ProducedBean;
+import org.apache.karaf.boot.tools.maven.plugin.model.Property;
+import org.apache.karaf.boot.tools.maven.plugin.model.PropertyWriter;
+import org.apache.karaf.boot.tools.maven.plugin.model.TransactionalDef;
+
+public class Generator implements PropertyWriter {
+ private static final String NS_BLUEPRINT = "http://www.osgi.org/xmlns/blueprint/v1.0.0";
+ private static final String NS_EXT = "http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0";
+ private static final String NS_JPA = "http://aries.apache.org/xmlns/jpa/v1.1.0";
+ private static final String NS_JPA2 = "http://aries.apache.org/xmlns/jpan/v1.0.0";
+ private static final String NS_TX = "http://aries.apache.org/xmlns/transactions/v1.2.0";
+
+ private Context context;
+ private XMLStreamWriter writer;
+ private boolean persistenceAnnotated;
+
+ public Generator(Context context, OutputStream os, boolean persistenceAnnotated) throws XMLStreamException {
+ this.context = context;
+ this.persistenceAnnotated = persistenceAnnotated;
+
+ XMLOutputFactory factory = XMLOutputFactory.newInstance();
+ writer = factory.createXMLStreamWriter(os);
+ }
+
+ public void generate() {
+ try {
+ writer.writeStartDocument();
+ writer.writeCharacters("\n");
+ writeBlueprint();
+
+ if (persistenceAnnotated) {
+ if (isJpaUsed()) {
+ writer.writeEmptyElement(NS_JPA2, "enable");
+ writer.writeCharacters("\n");
+ }
+ writer.writeEmptyElement(NS_TX, "enable-annotations");
+ writer.writeCharacters("\n");
+ //if (isJtaUsed()) {
+// writer.writeEmptyElement(NS_TX, "enable-annotations");
+ //}
+ }
+ for (Bean bean : context.getBeans()) {
+ writeBeanStart(bean);
+ bean.writeProperties(this);
+ writer.writeEndElement();
+ writer.writeCharacters("\n");
+ }
+
+ writeServiceRefs();
+ new OsgiServiceProviderWriter(writer).write(context.getBeans());
+
+ writer.writeEndElement();
+ writer.writeCharacters("\n");
+ writer.writeEndDocument();
+ writer.writeCharacters("\n");
+ writer.close();
+ } catch (XMLStreamException e) {
+ throw new RuntimeException(e.getMessage(), e);
+ }
+ }
+
+ private boolean isJpaUsed() {
+ boolean jpaUsed = false;
+ for (Bean bean : context.getBeans()) {
+ if (bean.persistenceFields.length > 0) {
+ jpaUsed = true;
+ }
+ }
+ return jpaUsed;
+ }
+
+ private boolean isJtaUsed() {
+ boolean jtaUsed = false;
+ for (Bean bean : context.getBeans()) {
+ if (bean.transactionDef != null) {
+ jtaUsed = true;
+ }
+
+ }
+ return jtaUsed;
+ }
+
+ private void writeBlueprint() throws XMLStreamException {
+ writer.writeStartElement("blueprint");
+ writer.writeDefaultNamespace(NS_BLUEPRINT);
+ writer.writeNamespace("ext", NS_EXT);
+ if (persistenceAnnotated) {
+ writer.writeNamespace("jpa", NS_JPA2);
+ } else {
+ writer.writeNamespace("jpa", NS_JPA);
+ }
+ writer.writeNamespace("tx", NS_TX);
+ }
+
+ public void writeBeanStart(Bean bean) throws XMLStreamException {
+ writer.writeStartElement("bean");
+ writer.writeAttribute("id", bean.id);
+ writer.writeAttribute("class", bean.clazz.getName());
+ writer.writeAttribute("ext", NS_EXT, "field-injection", "true");
+ if (bean instanceof ProducedBean) {
+ writeFactory((ProducedBean)bean);
+ }
+ if (bean.initMethod != null) {
+ writer.writeAttribute("init-method", bean.initMethod);
+ }
+ if (bean.destroyMethod != null) {
+ writer.writeAttribute("destroy-method", bean.destroyMethod);
+ }
+ writer.writeCharacters("\n");
+
+ if (!persistenceAnnotated) {
+ writeTransactional(bean.transactionDef);
+ writePersistenceFields(bean.persistenceFields);
+ }
+ }
+
+ private void writeFactory(ProducedBean bean) throws XMLStreamException {
+ writer.writeAttribute("factory-ref", bean.factoryBeanId);
+ writer.writeAttribute("factory-method", bean.factoryMethod);
+ }
+
+ private void writeTransactional(TransactionalDef transactionDef)
+ throws XMLStreamException {
+ if (transactionDef != null) {
+ writer.writeCharacters(" ");
+ writer.writeEmptyElement("tx", "transaction", NS_TX);
+ writer.writeAttribute("method", transactionDef.getMethod());
+ writer.writeAttribute("value", transactionDef.getType());
+ writer.writeCharacters("\n");
+ }
+ }
+
+
+ private void writePersistenceFields(Field[] fields) throws XMLStreamException {
+ for (Field field : fields) {
+ writePersistenceField(field);
+ }
+ }
+
+ private void writePersistenceField(Field field) throws XMLStreamException {
+ PersistenceContext persistenceContext = field.getAnnotation(PersistenceContext.class);
+ if (persistenceContext != null) {
+ writer.writeCharacters(" ");
+ writer.writeEmptyElement("jpa", "context", NS_JPA);
+ writer.writeAttribute("unitname", persistenceContext.unitName());
+ writer.writeAttribute("property", field.getName());
+ writer.writeCharacters("\n");
+ }
+ PersistenceUnit persistenceUnit = field.getAnnotation(PersistenceUnit.class);
+ if (persistenceUnit != null) {
+ writer.writeCharacters(" ");
+ writer.writeEmptyElement("jpa", "unit", NS_JPA);
+ writer.writeAttribute("unitname", persistenceUnit.unitName());
+ writer.writeAttribute("property", field.getName());
+ writer.writeCharacters("\n");
+ }
+ }
+
+ private void writeServiceRefs() throws XMLStreamException {
+ for (OsgiServiceRef serviceBean : context.getServiceRefs()) {
+ writeServiceRef(serviceBean);
+ }
+ }
+
+ private void writeServiceRef(OsgiServiceRef serviceBean) throws XMLStreamException {
+ writer.writeEmptyElement("reference");
+ writer.writeAttribute("id", serviceBean.id);
+ writer.writeAttribute("interface", serviceBean.clazz.getName());
+ if (serviceBean.filter != null && !"".equals(serviceBean.filter)) {
+ writer.writeAttribute("filter", serviceBean.filter);
+ }
+ writer.writeCharacters("\n");
+ }
+
+ public void writeProperty(Property property) {
+ try {
+ writer.writeCharacters(" ");
+ writer.writeEmptyElement("property");
+ writer.writeAttribute("name", property.name);
+ if (property.ref != null) {
+ writer.writeAttribute("ref", property.ref);
+ } else if (property.value != null) {
+ writer.writeAttribute("value", property.value);
+ }
+ writer.writeCharacters("\n");
+ } catch (XMLStreamException e) {
+ throw new RuntimeException(e.getMessage(), e);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/a0248b78/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/OsgiServiceProviderWriter.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/OsgiServiceProviderWriter.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/OsgiServiceProviderWriter.java
new file mode 100644
index 0000000..95d57df
--- /dev/null
+++ b/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/OsgiServiceProviderWriter.java
@@ -0,0 +1,86 @@
+/**
+ * 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.karaf.boot.tools.maven.plugin;
+
+import java.util.Collection;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.karaf.boot.tools.maven.plugin.model.Bean;
+import org.ops4j.pax.cdi.api.OsgiServiceProvider;
+import org.ops4j.pax.cdi.api.Properties;
+import org.ops4j.pax.cdi.api.Property;
+
+public class OsgiServiceProviderWriter {
+ private XMLStreamWriter writer;
+
+ public OsgiServiceProviderWriter(XMLStreamWriter writer) {
+ this.writer = writer;
+ }
+
+ public void write(Collection<Bean> beans) throws XMLStreamException {
+ for (Bean bean : beans) {
+ write(bean);
+ }
+ }
+
+ public void write(Bean bean) throws XMLStreamException {
+ OsgiServiceProvider serviceProvider = bean.clazz.getAnnotation(OsgiServiceProvider.class);
+ if (serviceProvider == null) {
+ return;
+ }
+ if (serviceProvider.classes().length == 0) {
+ throw new IllegalArgumentException("Need to provide the interface class in the @OsgiServiceProvider(classes={...}) annotation on " + bean.clazz);
+ }
+ Properties properties = bean.clazz.getAnnotation(Properties.class);
+ if (properties == null) {
+ writer.writeEmptyElement("service");
+ } else {
+ writer.writeStartElement("service");
+ }
+ writer.writeAttribute("ref", bean.id);
+ Class<?> serviceIf = serviceProvider.classes()[0];
+ writer.writeAttribute("interface", serviceIf.getName());
+ writer.writeCharacters("\n");
+ if (properties != null) {
+ writeProperties(properties);
+ writer.writeEndElement();
+ writer.writeCharacters("\n");
+ }
+ }
+
+ private void writeProperties(Properties properties) throws XMLStreamException {
+ writer.writeCharacters(" ");
+ writer.writeStartElement("service-properties");
+ writer.writeCharacters("\n");
+ for (Property property : properties.value()) {
+ writer.writeCharacters(" ");
+ writer.writeEmptyElement("entry");
+ writer.writeAttribute("key", property.name());
+ writer.writeAttribute("value", property.value());
+ writer.writeCharacters("\n");
+ }
+ writer.writeCharacters(" ");
+ writer.writeEndElement();
+ writer.writeCharacters("\n");
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/a0248b78/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/Bean.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/Bean.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/Bean.java
new file mode 100644
index 0000000..995649c
--- /dev/null
+++ b/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/Bean.java
@@ -0,0 +1,152 @@
+/**
+ * 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.karaf.boot.tools.maven.plugin.model;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceUnit;
+
+public class Bean extends BeanRef {
+ public String initMethod;
+ public String destroyMethod;
+ public SortedSet<Property> properties;
+ public Field[] persistenceFields;
+ public TransactionalDef transactionDef;
+
+ public Bean(Class<?> clazz) {
+ super(clazz);
+
+ for (Method method : clazz.getDeclaredMethods()) {
+ PostConstruct postConstruct = getEffectiveAnnotation(method, PostConstruct.class);
+ if (postConstruct != null) {
+ this.initMethod = method.getName();
+ }
+ PreDestroy preDestroy = getEffectiveAnnotation(method, PreDestroy.class);
+ if (preDestroy != null) {
+ this.destroyMethod = method.getName();
+ }
+ }
+ this.persistenceFields = getPersistenceFields();
+ this.transactionDef = new JavaxTransactionFactory().create(clazz);
+ if (this.transactionDef == null) {
+ this.transactionDef = new SpringTransactionFactory().create(clazz);
+ }
+ properties = new TreeSet<Property>();
+ }
+
+ private Field[] getPersistenceFields() {
+ List<Field> persistenceFields = new ArrayList<Field>();
+ Field[] fields = clazz.getDeclaredFields();
+ for (Field field : fields) {
+ PersistenceContext persistenceContext = field.getAnnotation(PersistenceContext.class);
+ PersistenceUnit persistenceUnit = field.getAnnotation(PersistenceUnit.class);
+ if (persistenceContext !=null || persistenceUnit != null) {
+ persistenceFields.add(field);
+ }
+ }
+ return persistenceFields.toArray(new Field[]{});
+ }
+
+ public void resolve(Matcher matcher) {
+ Class<?> curClass = this.clazz;
+ while (curClass != null && curClass != Object.class) {
+ resolveProperties(matcher, curClass);
+ curClass = curClass.getSuperclass();
+ }
+ }
+
+ private void resolveProperties(Matcher matcher, Class<?> curClass) {
+ for (Field field : curClass.getDeclaredFields()) {
+ Property prop = Property.create(matcher, field);
+ if (prop != null) {
+ properties.add(prop);
+ }
+ }
+ }
+
+ private static <T extends Annotation> T getEffectiveAnnotation(Method method, Class<T> annotationClass) {
+ final Class<?> methodClass = method.getDeclaringClass();
+ final String name = method.getName();
+ final Class<?>[] params = method.getParameterTypes();
+
+ // 1. Current class
+ final T rootAnnotation = method.getAnnotation(annotationClass);
+ if (rootAnnotation != null) {
+ return rootAnnotation;
+ }
+
+ // 2. Superclass
+ final Class<?> superclass = methodClass.getSuperclass();
+ if (superclass != null) {
+ final T annotation = getMethodAnnotation(superclass, name, params, annotationClass);
+ if (annotation != null)
+ return annotation;
+ }
+
+ // 3. Interfaces
+ for (final Class<?> intfs : methodClass.getInterfaces()) {
+ final T annotation = getMethodAnnotation(intfs, name, params, annotationClass);
+ if (annotation != null)
+ return annotation;
+ }
+
+ return null;
+ }
+
+ private static <T extends Annotation> T getMethodAnnotation(Class<?> searchClass, String name, Class<?>[] params,
+ Class<T> annotationClass) {
+ try {
+ Method method = searchClass.getMethod(name, params);
+ return getEffectiveAnnotation(method, annotationClass);
+ } catch (NoSuchMethodException e) {
+ return null;
+ }
+ }
+
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((clazz == null) ? 0 : clazz.getName().hashCode());
+ result = prime * result + ((id == null) ? 0 : id.hashCode());
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ return clazz.getName();
+ }
+
+ public void writeProperties(PropertyWriter writer) {
+ for (Property property : properties) {
+ writer.writeProperty(property);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/a0248b78/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/BeanRef.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/BeanRef.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/BeanRef.java
new file mode 100644
index 0000000..ba67f33
--- /dev/null
+++ b/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/BeanRef.java
@@ -0,0 +1,69 @@
+package org.apache.karaf.boot.tools.maven.plugin.model;
+
+import java.lang.reflect.Field;
+
+import javax.inject.Named;
+
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.stereotype.Component;
+
+public class BeanRef implements Comparable<BeanRef> {
+ public String id;
+ public Class<?> clazz;
+
+ /**
+ *
+ * @param clazz interface or implementation class
+ */
+ public BeanRef(Class<?> clazz) {
+ this.clazz = clazz;
+ this.id = getBeanName(clazz);
+ }
+
+ public BeanRef(Class<?> type, String id) {
+ this.clazz = type;
+ this.id = id;
+ }
+
+ public BeanRef(Field field) {
+ this(field.getType(), getDestinationId(field));
+ }
+
+ private static String getDestinationId(Field field) {
+ Named named = field.getAnnotation(Named.class);
+ if (named != null) {
+ return named.value();
+ }
+ Qualifier qualifier = field.getAnnotation(Qualifier.class);
+ if (qualifier != null) {
+ return qualifier.value();
+ }
+ return null;
+ }
+
+ public static String getBeanName(Class<?> clazz) {
+ Component component = clazz.getAnnotation(Component.class);
+ Named named = clazz.getAnnotation(Named.class);
+ if (component != null && !"".equals(component.value())) {
+ return component.value();
+ } else if (named != null && !"".equals(named.value())) {
+ return named.value();
+ } else {
+ String name = clazz.getSimpleName();
+ return getBeanNameFromSimpleName(name);
+ }
+ }
+
+ private static String getBeanNameFromSimpleName(String name) {
+ return name.substring(0, 1).toLowerCase() + name.substring(1, name.length());
+ }
+
+ public boolean matches(BeanRef template) {
+ boolean assignable = template.clazz.isAssignableFrom(this.clazz);
+ return assignable && ((template.id == null) || id.equals(template.id));
+ }
+
+ public int compareTo(BeanRef other) {
+ return this.id.compareTo(other.id);
+ }
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/a0248b78/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/Context.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/Context.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/Context.java
new file mode 100644
index 0000000..442bc6e
--- /dev/null
+++ b/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/Context.java
@@ -0,0 +1,121 @@
+/**
+ * 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.karaf.boot.tools.maven.plugin.model;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+import javax.enterprise.inject.Produces;
+
+import org.ops4j.pax.cdi.api.OsgiService;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.blueprint.container.BlueprintContainer;
+import org.osgi.service.blueprint.container.Converter;
+
+public class Context implements Matcher {
+
+ SortedSet<Bean> beans;
+ SortedSet<OsgiServiceRef> serviceRefs;
+
+ public Context(Class<?>... beanClasses) {
+ this(Arrays.asList(beanClasses));
+ }
+
+ public Context(Collection<Class<?>> beanClasses) {
+ this.beans = new TreeSet<Bean>();
+ this.serviceRefs = new TreeSet<OsgiServiceRef>();
+ addBeans(beanClasses);
+ }
+
+ private void addBeans(Collection<Class<?>> beanClasses) {
+ for (Class<?> clazz : beanClasses) {
+ Bean bean = new Bean(clazz);
+ beans.add(bean);
+ addServiceRefs(clazz);
+ addProducedBeans(clazz, bean.id);
+ }
+ }
+
+ private void addProducedBeans(Class<?> clazz, String factoryBeanId) {
+ for (Method method : clazz.getMethods()) {
+ Produces produces = method.getAnnotation(Produces.class);
+ if (produces != null) {
+ Class<?> producedClass = method.getReturnType();
+ ProducedBean producedBean = new ProducedBean(producedClass, factoryBeanId, method.getName());
+ beans.add(producedBean);
+ }
+ }
+ }
+
+ private void addServiceRefs(Class<?> clazz) {
+ for (Field field : clazz.getDeclaredFields()) {
+ OsgiService osgiService = field.getAnnotation(OsgiService.class);
+ if (osgiService != null) {
+ serviceRefs.add(new OsgiServiceRef(field));
+ }
+ }
+ }
+
+ public void resolve() {
+ for (Bean bean : beans) {
+ bean.resolve(this);
+ }
+ }
+
+ public BeanRef getMatching(BeanRef template) {
+ for (Bean bean : beans) {
+ if (bean.matches(template)) {
+ return bean;
+ }
+ }
+ for (BeanRef bean : serviceRefs) {
+ if (bean.matches(template)) {
+ return bean;
+ }
+ }
+ if (template.clazz == BundleContext.class) {
+ return new BeanRef(BundleContext.class, "blueprintBundleContext");
+ }
+ if (template.clazz == Bundle.class) {
+ return new BeanRef(Bundle.class, "blueprintBundle");
+ }
+ if (template.clazz == BlueprintContainer.class) {
+ return new BeanRef(BlueprintContainer.class, "blueprintContainer");
+ }
+ if (template.clazz == Converter.class) {
+ return new BeanRef(Converter.class, "blueprintConverter");
+ }
+
+ return null;
+ }
+
+ public SortedSet<Bean> getBeans() {
+ return beans;
+ }
+
+ public SortedSet<OsgiServiceRef> getServiceRefs() {
+ return serviceRefs;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/a0248b78/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/JavaxTransactionFactory.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/JavaxTransactionFactory.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/JavaxTransactionFactory.java
new file mode 100644
index 0000000..c00a54c
--- /dev/null
+++ b/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/JavaxTransactionFactory.java
@@ -0,0 +1,40 @@
+/**
+ * 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.karaf.boot.tools.maven.plugin.model;
+
+import java.util.HashMap;
+
+import javax.transaction.Transactional;
+import javax.transaction.Transactional.TxType;
+
+public class JavaxTransactionFactory {
+ private static HashMap<TxType, String> txTypeNames;
+
+ static {
+ txTypeNames = new HashMap<TxType, String>();
+ txTypeNames.put(TxType.REQUIRED, TransactionalDef.TYPE_REQUIRED);
+ txTypeNames.put(TxType.REQUIRES_NEW, TransactionalDef.TYPE_REQUIRES_NEW);
+ }
+
+ TransactionalDef create(Class<?> clazz) {
+ Transactional transactional = clazz.getAnnotation(Transactional.class);
+ return transactional != null ?
+ new TransactionalDef("*", txTypeNames.get(transactional.value())) : null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/a0248b78/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/Matcher.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/Matcher.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/Matcher.java
new file mode 100644
index 0000000..f703ed1
--- /dev/null
+++ b/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/Matcher.java
@@ -0,0 +1,23 @@
+/**
+ * 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.karaf.boot.tools.maven.plugin.model;
+
+public interface Matcher {
+ BeanRef getMatching(BeanRef template);
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/a0248b78/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/OsgiServiceRef.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/OsgiServiceRef.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/OsgiServiceRef.java
new file mode 100644
index 0000000..5069663
--- /dev/null
+++ b/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/OsgiServiceRef.java
@@ -0,0 +1,41 @@
+/**
+ * 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.karaf.boot.tools.maven.plugin.model;
+
+import java.lang.reflect.Field;
+
+import org.ops4j.pax.cdi.api.OsgiService;
+
+/**
+ * Synthetic bean that refers to an OSGi service
+ */
+public class OsgiServiceRef extends BeanRef {
+
+ public String filter;
+
+ public OsgiServiceRef(Field field) {
+ super(field);
+ if (id == null) {
+ id = getBeanName(clazz);
+ }
+ OsgiService osgiService = field.getAnnotation(OsgiService.class);
+ filter = osgiService.filter();
+ }
+
+}
[17/35] karaf-boot git commit: Switch to JDK 8
Posted by cs...@apache.org.
Switch to JDK 8
Project: http://git-wip-us.apache.org/repos/asf/karaf-boot/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-boot/commit/7f6469ee
Tree: http://git-wip-us.apache.org/repos/asf/karaf-boot/tree/7f6469ee
Diff: http://git-wip-us.apache.org/repos/asf/karaf-boot/diff/7f6469ee
Branch: refs/heads/master
Commit: 7f6469eea5c0434ed441bb0a546dc1ef58de6aec
Parents: 222b024
Author: Guillaume Nodet <gn...@apache.org>
Authored: Fri Apr 15 16:38:44 2016 +0200
Committer: Guillaume Nodet <gn...@apache.org>
Committed: Fri Apr 15 16:38:44 2016 +0200
----------------------------------------------------------------------
pom.xml | 14 ++++++++++++++
1 file changed, 14 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/7f6469ee/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index afd1bd6..5e1e5c8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -47,6 +47,19 @@
<!-- TODO complete library demos -->
</modules>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <inherited>true</inherited>
+ <configuration>
+ <source>1.8</source>
+ <target>1.8</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
<profiles>
<profile>
<id>samples</id>
@@ -61,6 +74,7 @@
<module>karaf-boot-samples/karaf-boot-sample-service-provider-blueprint</module>
<module>karaf-boot-samples/karaf-boot-sample-service-consumer-blueprint</module>
<!-- cdi -->
+ <module>karaf-boot-samples/karaf-boot-sample-cdi</module>
<!-- shell -->
<module>karaf-boot-samples/karaf-boot-sample-shell</module>
<!-- config -->
[33/35] karaf-boot git commit: Add CDI annotations to
blueprint-starter
Posted by cs...@apache.org.
Add CDI annotations to blueprint-starter
Project: http://git-wip-us.apache.org/repos/asf/karaf-boot/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-boot/commit/af038891
Tree: http://git-wip-us.apache.org/repos/asf/karaf-boot/tree/af038891
Diff: http://git-wip-us.apache.org/repos/asf/karaf-boot/diff/af038891
Branch: refs/heads/master
Commit: af03889117a6f4faafb81402bb2bb944471bf637
Parents: 4860b60
Author: Christian Schneider <ch...@die-schneider.net>
Authored: Tue Apr 26 14:46:36 2016 +0200
Committer: Christian Schneider <ch...@die-schneider.net>
Committed: Tue Apr 26 14:46:36 2016 +0200
----------------------------------------------------------------------
samples/blueprint/service-consumer/pom.xml | 14 +-------------
samples/blueprint/service-provider/pom.xml | 14 +-------------
starters/karaf-boot-starter-blueprint/pom.xml | 10 ++++++++++
.../karaf/boot/blueprint/impl/BlueprintProcessor.java | 5 +++--
4 files changed, 15 insertions(+), 28 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/af038891/samples/blueprint/service-consumer/pom.xml
----------------------------------------------------------------------
diff --git a/samples/blueprint/service-consumer/pom.xml b/samples/blueprint/service-consumer/pom.xml
index d482686..cffe223 100644
--- a/samples/blueprint/service-consumer/pom.xml
+++ b/samples/blueprint/service-consumer/pom.xml
@@ -27,22 +27,10 @@
<dependencies>
<dependency>
<groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-starter</artifactId>
+ <artifactId>karaf-boot-starter-blueprint</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>org.ops4j.pax.cdi</groupId>
- <artifactId>pax-cdi-api</artifactId>
- <version>0.5.0</version>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>javax.inject</groupId>
- <artifactId>javax.inject</artifactId>
- <version>1</version>
- <optional>true</optional>
- </dependency>
- <dependency>
<groupId>org.apache.karaf.boot</groupId>
<artifactId>karaf-boot-sample-service-provider-blueprint</artifactId>
<version>${project.version}</version>
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/af038891/samples/blueprint/service-provider/pom.xml
----------------------------------------------------------------------
diff --git a/samples/blueprint/service-provider/pom.xml b/samples/blueprint/service-provider/pom.xml
index de9ab62..08b0912 100644
--- a/samples/blueprint/service-provider/pom.xml
+++ b/samples/blueprint/service-provider/pom.xml
@@ -22,21 +22,9 @@
<dependencies>
<dependency>
<groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-starter</artifactId>
+ <artifactId>karaf-boot-starter-blueprint</artifactId>
<version>${project.version}</version>
</dependency>
- <dependency>
- <groupId>org.ops4j.pax.cdi</groupId>
- <artifactId>pax-cdi-api</artifactId>
- <version>0.5.0</version>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>javax.inject</groupId>
- <artifactId>javax.inject</artifactId>
- <version>1</version>
- <optional>true</optional>
- </dependency>
</dependencies>
<build>
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/af038891/starters/karaf-boot-starter-blueprint/pom.xml
----------------------------------------------------------------------
diff --git a/starters/karaf-boot-starter-blueprint/pom.xml b/starters/karaf-boot-starter-blueprint/pom.xml
index 9f48c60..14db02e 100644
--- a/starters/karaf-boot-starter-blueprint/pom.xml
+++ b/starters/karaf-boot-starter-blueprint/pom.xml
@@ -41,6 +41,16 @@
<artifactId>org.apache.aries.blueprint.annotation.api</artifactId>
<version>1.0.0</version>
</dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.cdi</groupId>
+ <artifactId>pax-cdi-api</artifactId>
+ <version>0.5.0</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.inject</groupId>
+ <artifactId>javax.inject</artifactId>
+ <version>1</version>
+ </dependency>
</dependencies>
<build>
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/af038891/starters/karaf-boot-starter-blueprint/src/main/java/org/apache/karaf/boot/blueprint/impl/BlueprintProcessor.java
----------------------------------------------------------------------
diff --git a/starters/karaf-boot-starter-blueprint/src/main/java/org/apache/karaf/boot/blueprint/impl/BlueprintProcessor.java b/starters/karaf-boot-starter-blueprint/src/main/java/org/apache/karaf/boot/blueprint/impl/BlueprintProcessor.java
index 896a161..aebcfca 100644
--- a/starters/karaf-boot-starter-blueprint/src/main/java/org/apache/karaf/boot/blueprint/impl/BlueprintProcessor.java
+++ b/starters/karaf-boot-starter-blueprint/src/main/java/org/apache/karaf/boot/blueprint/impl/BlueprintProcessor.java
@@ -6,6 +6,9 @@ import javax.lang.model.element.TypeElement;
import javax.tools.Diagnostic.Kind;
import javax.tools.FileObject;
import javax.tools.StandardLocation;
+
+import org.apache.aries.blueprint.annotation.Bean;
+
import java.io.ByteArrayOutputStream;
import java.io.CharArrayWriter;
import java.io.IOException;
@@ -16,8 +19,6 @@ import java.io.Writer;
import java.util.HashSet;
import java.util.Set;
-import org.apache.aries.blueprint.annotation.Bean;
-
public class BlueprintProcessor extends AbstractProcessor {
boolean hasRun;
[20/35] karaf-boot git commit: [karaf] fix karaf extensions
Posted by cs...@apache.org.
[karaf] fix karaf extensions
Project: http://git-wip-us.apache.org/repos/asf/karaf-boot/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-boot/commit/9d68baae
Tree: http://git-wip-us.apache.org/repos/asf/karaf-boot/tree/9d68baae
Diff: http://git-wip-us.apache.org/repos/asf/karaf-boot/diff/9d68baae
Branch: refs/heads/master
Commit: 9d68baae7b1e36124fd70196e739aa393036d470
Parents: 1d2b774
Author: Guillaume Nodet <gn...@apache.org>
Authored: Fri Apr 15 18:26:30 2016 +0200
Committer: Guillaume Nodet <gn...@apache.org>
Committed: Fri Apr 15 18:26:30 2016 +0200
----------------------------------------------------------------------
.../pom.xml | 2 +-
.../pom.xml | 2 +-
.../karaf-boot-starter-karaf/pom.xml | 57 +++++++
.../karaf/boot/karaf/impl/KarafProcessor.java | 154 +++++++++++++++++++
.../javax.annotation.processing.Processor | 1 +
.../karaf-boot-starter-shell/pom.xml | 11 ++
.../karaf/boot/shell/impl/ShellProcessor.java | 84 ++++++++++
.../javax.annotation.processing.Processor | 1 +
karaf-boot-starters/karaf-boot-starter/pom.xml | 5 -
karaf-boot-starters/pom.xml | 1 +
.../apache/karaf/boot/maven/GenerateMojo.java | 114 ++++++--------
11 files changed, 356 insertions(+), 76 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/9d68baae/karaf-boot-samples/karaf-boot-sample-service-consumer-osgi/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-service-consumer-osgi/pom.xml b/karaf-boot-samples/karaf-boot-sample-service-consumer-osgi/pom.xml
index c26cfbf..2a18273 100644
--- a/karaf-boot-samples/karaf-boot-sample-service-consumer-osgi/pom.xml
+++ b/karaf-boot-samples/karaf-boot-sample-service-consumer-osgi/pom.xml
@@ -28,7 +28,7 @@
<dependencies>
<dependency>
<groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-starter</artifactId>
+ <artifactId>karaf-boot-starter-karaf</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/9d68baae/karaf-boot-samples/karaf-boot-sample-service-provider-osgi/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-service-provider-osgi/pom.xml b/karaf-boot-samples/karaf-boot-sample-service-provider-osgi/pom.xml
index d1bb116..507828a 100644
--- a/karaf-boot-samples/karaf-boot-sample-service-provider-osgi/pom.xml
+++ b/karaf-boot-samples/karaf-boot-sample-service-provider-osgi/pom.xml
@@ -28,7 +28,7 @@
<dependencies>
<dependency>
<groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-starter</artifactId>
+ <artifactId>karaf-boot-starter-karaf</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/9d68baae/karaf-boot-starters/karaf-boot-starter-karaf/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-starters/karaf-boot-starter-karaf/pom.xml b/karaf-boot-starters/karaf-boot-starter-karaf/pom.xml
new file mode 100644
index 0000000..32bec48
--- /dev/null
+++ b/karaf-boot-starters/karaf-boot-starter-karaf/pom.xml
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+
+ <!--
+
+ 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.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-starters</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>karaf-boot-starter-karaf</artifactId>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <version>${osgi.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.karaf</groupId>
+ <artifactId>org.apache.karaf.util</artifactId>
+ <version>${karaf.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <compilerArgument>-proc:none</compilerArgument>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/9d68baae/karaf-boot-starters/karaf-boot-starter-karaf/src/main/java/org/apache/karaf/boot/karaf/impl/KarafProcessor.java
----------------------------------------------------------------------
diff --git a/karaf-boot-starters/karaf-boot-starter-karaf/src/main/java/org/apache/karaf/boot/karaf/impl/KarafProcessor.java b/karaf-boot-starters/karaf-boot-starter-karaf/src/main/java/org/apache/karaf/boot/karaf/impl/KarafProcessor.java
new file mode 100644
index 0000000..e51380e
--- /dev/null
+++ b/karaf-boot-starters/karaf-boot-starter-karaf/src/main/java/org/apache/karaf/boot/karaf/impl/KarafProcessor.java
@@ -0,0 +1,154 @@
+package org.apache.karaf.boot.karaf.impl;
+
+import javax.annotation.processing.AbstractProcessor;
+import javax.annotation.processing.RoundEnvironment;
+import javax.lang.model.element.AnnotationMirror;
+import javax.lang.model.element.AnnotationValue;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.ExecutableElement;
+import javax.lang.model.element.TypeElement;
+import javax.tools.Diagnostic.Kind;
+import javax.tools.FileObject;
+import javax.tools.StandardLocation;
+import java.io.CharArrayWriter;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+import java.io.Reader;
+import java.io.Writer;
+import java.lang.annotation.Annotation;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import org.apache.karaf.util.tracker.annotation.Managed;
+import org.apache.karaf.util.tracker.annotation.ProvideService;
+import org.apache.karaf.util.tracker.annotation.RequireService;
+import org.apache.karaf.util.tracker.annotation.Services;
+
+public class KarafProcessor extends AbstractProcessor {
+
+ boolean hasRun;
+
+ public KarafProcessor() {
+ }
+
+ @Override
+ public Set<String> getSupportedAnnotationTypes() {
+ Set<String> set = new HashSet<String>();
+ set.add(Services.class.getName());
+ set.add(Managed.class.getName());
+ return set;
+ }
+
+ @Override
+ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+ List<String> instructions = new ArrayList<>();
+ Properties props = new Properties();
+
+ for (Element elem : roundEnv.getElementsAnnotatedWith(Services.class)) {
+ for (AnnotationMirror mirror : elem.getAnnotationMirrors()) {
+ if (Services.class.getName().equals(((TypeElement) mirror.getAnnotationType().asElement()).getQualifiedName().toString())) {
+ Map<String, Object> values = getAnnotationValues(mirror);
+ if (values.containsKey("provides")) {
+ for (AnnotationMirror p : (List<AnnotationMirror>) values.get("provides")) {
+ Map<String, Object> pv = getAnnotationValues(p);
+ String n = pv.get("value").toString();
+ instructions.add("Provide-Capability: osgi.service;effective:=active;objectClass=" + n);
+ }
+ }
+ if (values.containsKey("requires")) {
+ for (AnnotationMirror r : (List<AnnotationMirror>) values.get("requires")) {
+ Map<String, Object> rv = getAnnotationValues(r);
+ String value = rv.get("value").toString();
+ String filter = (String) rv.getOrDefault("filter", "");
+ boolean opt = ((Boolean) rv.getOrDefault("optional", false));
+
+ String fltWithClass = combine(filter, "(objectClass=" + value + ")");
+ instructions.add("Require-Capability: osgi.service;effective:=active;filter:=\"" + fltWithClass + "\"");
+ props.setProperty(value, filter);
+ }
+ }
+ }
+ }
+ instructions.add("Bundle-Activator: " + ((TypeElement) elem).getQualifiedName().toString());
+
+ Managed managed = elem.getAnnotation(Managed.class);
+ if (managed != null) {
+ props.setProperty("pid", managed.value());
+ }
+
+ String name = "OSGI-INF/karaf-tracker/" + ((TypeElement) elem).getQualifiedName().toString();
+ try (OutputStream os = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", name).openOutputStream()) {
+ props.store(os, null);
+ } catch (IOException e) {
+ processingEnv.getMessager().printMessage(Kind.ERROR, "Error writing to " + name + ": " + e.getMessage());
+ }
+ }
+
+ instructions.add("Private-Package: org.apache.karaf.util.tracker");
+ instructions.add("PREPEND-Import-Package: !org.apache.karaf.util.tracker.annotation");
+
+ if (!hasRun) {
+ hasRun = true;
+ // Add the Karaf embedded package
+ try (PrintWriter w = appendResource("META-INF/org.apache.karaf.boot.bnd")) {
+ for (String instr : instructions) {
+ w.println(instr);
+ }
+ } catch (Exception e) {
+ processingEnv.getMessager().printMessage(Kind.ERROR, "Error writing to META-INF/org.apache.karaf.boot.bnd: " + e.getMessage());
+ }
+ }
+
+ return true;
+ }
+
+ private Map<String, Object> getAnnotationValues(AnnotationMirror mirror) {
+ Map<String, Object> map = new HashMap<>();
+ for (Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> entry : mirror.getElementValues().entrySet()) {
+ map.put(entry.getKey().getSimpleName().toString(), entry.getValue().getValue());
+ }
+ return map;
+ }
+
+ private String combine(String filter1, String filter2) {
+ if (filter1!=null && !filter1.isEmpty()) {
+ return "(&" + filter2 + filter1 + ")";
+ } else {
+ return filter2;
+ }
+ }
+
+ private PrintWriter appendResource(String resource) throws IOException {
+ try {
+ FileObject o = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", resource);
+ return new PrintWriter(o.openWriter());
+ } catch (Exception e) {
+ try {
+ FileObject o = processingEnv.getFiler().getResource(StandardLocation.CLASS_OUTPUT, "", resource);
+ CharArrayWriter baos = new CharArrayWriter();
+ try (Reader r = o.openReader(true)) {
+ char[] buf = new char[4096];
+ int l;
+ while ((l = r.read(buf)) > 0) {
+ baos.write(buf, 0, l);
+ }
+ }
+ o.delete();
+ o = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", resource);
+ Writer w = o.openWriter();
+ w.write(baos.toCharArray());
+ return new PrintWriter(w);
+ } catch (Exception e2) {
+ e2.addSuppressed(e);
+ e2.printStackTrace();
+ throw e2;
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/9d68baae/karaf-boot-starters/karaf-boot-starter-karaf/src/main/resources/META-INF/services/javax.annotation.processing.Processor
----------------------------------------------------------------------
diff --git a/karaf-boot-starters/karaf-boot-starter-karaf/src/main/resources/META-INF/services/javax.annotation.processing.Processor b/karaf-boot-starters/karaf-boot-starter-karaf/src/main/resources/META-INF/services/javax.annotation.processing.Processor
new file mode 100644
index 0000000..c45090b
--- /dev/null
+++ b/karaf-boot-starters/karaf-boot-starter-karaf/src/main/resources/META-INF/services/javax.annotation.processing.Processor
@@ -0,0 +1 @@
+org.apache.karaf.boot.karaf.impl.KarafProcessor
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/9d68baae/karaf-boot-starters/karaf-boot-starter-shell/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-starters/karaf-boot-starter-shell/pom.xml b/karaf-boot-starters/karaf-boot-starter-shell/pom.xml
index 4c413a8..28523c7 100644
--- a/karaf-boot-starters/karaf-boot-starter-shell/pom.xml
+++ b/karaf-boot-starters/karaf-boot-starter-shell/pom.xml
@@ -38,4 +38,15 @@
</dependency>
</dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <compilerArgument>-proc:none</compilerArgument>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/9d68baae/karaf-boot-starters/karaf-boot-starter-shell/src/main/java/org/apache/karaf/boot/shell/impl/ShellProcessor.java
----------------------------------------------------------------------
diff --git a/karaf-boot-starters/karaf-boot-starter-shell/src/main/java/org/apache/karaf/boot/shell/impl/ShellProcessor.java b/karaf-boot-starters/karaf-boot-starter-shell/src/main/java/org/apache/karaf/boot/shell/impl/ShellProcessor.java
new file mode 100644
index 0000000..3de3bfb
--- /dev/null
+++ b/karaf-boot-starters/karaf-boot-starter-shell/src/main/java/org/apache/karaf/boot/shell/impl/ShellProcessor.java
@@ -0,0 +1,84 @@
+package org.apache.karaf.boot.shell.impl;
+
+import javax.annotation.processing.AbstractProcessor;
+import javax.annotation.processing.RoundEnvironment;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.TypeElement;
+import javax.tools.Diagnostic.Kind;
+import javax.tools.FileObject;
+import javax.tools.StandardLocation;
+import java.io.CharArrayWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.Reader;
+import java.io.Writer;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.TreeSet;
+
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+
+public class ShellProcessor extends AbstractProcessor {
+
+ boolean hasRun;
+
+ public ShellProcessor() {
+ }
+
+ @Override
+ public Set<String> getSupportedAnnotationTypes() {
+ Set<String> set = new HashSet<String>();
+ set.add(Service.class.getName());
+ return set;
+ }
+
+ @Override
+ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+ Set<String> packages = new TreeSet<>();
+ for (Element elem : roundEnv.getElementsAnnotatedWith(Service.class)) {
+ packages.add(elem.getEnclosingElement().toString());
+ }
+
+ if (!packages.isEmpty()) {
+ if (!hasRun) {
+ hasRun = true;
+ // Add the Karaf embedded package
+ try (PrintWriter w = appendResource("META-INF/org.apache.karaf.boot.bnd")) {
+ w.println("Karaf-Commands: " + String.join(",", packages));
+ } catch (Exception e) {
+ processingEnv.getMessager().printMessage(Kind.ERROR, "Error writing to META-INF/org.apache.karaf.boot.bnd: " + e.getMessage());
+ }
+ }
+ }
+
+ return true;
+ }
+
+ private PrintWriter appendResource(String resource) throws IOException {
+ try {
+ FileObject o = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", resource);
+ return new PrintWriter(o.openWriter());
+ } catch (Exception e) {
+ try {
+ FileObject o = processingEnv.getFiler().getResource(StandardLocation.CLASS_OUTPUT, "", resource);
+ CharArrayWriter baos = new CharArrayWriter();
+ try (Reader r = o.openReader(true)) {
+ char[] buf = new char[4096];
+ int l;
+ while ((l = r.read(buf)) > 0) {
+ baos.write(buf, 0, l);
+ }
+ }
+ o.delete();
+ o = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", resource);
+ Writer w = o.openWriter();
+ w.write(baos.toCharArray());
+ return new PrintWriter(w);
+ } catch (Exception e2) {
+ e2.addSuppressed(e);
+ e2.printStackTrace();
+ throw e2;
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/9d68baae/karaf-boot-starters/karaf-boot-starter-shell/src/main/resources/META-INF/services/javax.annotation.processing.Processor
----------------------------------------------------------------------
diff --git a/karaf-boot-starters/karaf-boot-starter-shell/src/main/resources/META-INF/services/javax.annotation.processing.Processor b/karaf-boot-starters/karaf-boot-starter-shell/src/main/resources/META-INF/services/javax.annotation.processing.Processor
new file mode 100644
index 0000000..3ebe726
--- /dev/null
+++ b/karaf-boot-starters/karaf-boot-starter-shell/src/main/resources/META-INF/services/javax.annotation.processing.Processor
@@ -0,0 +1 @@
+org.apache.karaf.boot.shell.impl.ShellProcessor
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/9d68baae/karaf-boot-starters/karaf-boot-starter/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-starters/karaf-boot-starter/pom.xml b/karaf-boot-starters/karaf-boot-starter/pom.xml
index 21c0d07..e5b2742 100644
--- a/karaf-boot-starters/karaf-boot-starter/pom.xml
+++ b/karaf-boot-starters/karaf-boot-starter/pom.xml
@@ -36,11 +36,6 @@
<artifactId>org.osgi.core</artifactId>
<version>${osgi.version}</version>
</dependency>
- <dependency>
- <groupId>org.apache.karaf</groupId>
- <artifactId>org.apache.karaf.util</artifactId>
- <version>${karaf.version}</version>
- </dependency>
</dependencies>
</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/9d68baae/karaf-boot-starters/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-starters/pom.xml b/karaf-boot-starters/pom.xml
index e50f6c2..127874e 100644
--- a/karaf-boot-starters/pom.xml
+++ b/karaf-boot-starters/pom.xml
@@ -33,6 +33,7 @@
<modules>
<module>karaf-boot-starter</module>
+ <module>karaf-boot-starter-karaf</module>
<module>karaf-boot-starter-ds</module>
<module>karaf-boot-starter-shell</module>
<module>karaf-boot-starter-web</module>
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/9d68baae/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/maven/GenerateMojo.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/maven/GenerateMojo.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/maven/GenerateMojo.java
index d7fcdcb..dd88688 100644
--- a/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/maven/GenerateMojo.java
+++ b/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/maven/GenerateMojo.java
@@ -15,6 +15,7 @@ import org.codehaus.plexus.util.xml.Xpp3DomBuilder;
import java.io.ByteArrayInputStream;
import java.io.File;
+import java.io.IOException;
import java.io.StringReader;
import java.nio.file.Files;
import java.util.LinkedHashMap;
@@ -35,86 +36,27 @@ public class GenerateMojo extends AbstractMojo {
public void execute() throws MojoExecutionException {
try {
- // invoke Karaf services plugin
- getLog().info("Invoking karaf-services-maven-plugin");
- Plugin karafServicesPlugin = new Plugin();
- karafServicesPlugin.setGroupId("org.apache.karaf.tooling");
- karafServicesPlugin.setArtifactId("karaf-services-maven-plugin");
- karafServicesPlugin.setVersion("4.0.1");
- karafServicesPlugin.setInherited(false);
- karafServicesPlugin.setExtensions(true);
- Xpp3Dom configuration = Xpp3DomBuilder.build(new ByteArrayInputStream(("<configuration>" +
- "<project>${project}</project>" +
- "<activatorProperty>BNDExtension-Bundle-Activator</activatorProperty>" +
- "<requirementsProperty>BNDExtension-Require-Capability</requirementsProperty>" +
- "<capabilitiesProperty>BNDExtension-Provide-Capability</capabilitiesProperty>" +
- "<outputDirectory>${project.build.directory}/generated/karaf-tracker</outputDirectory>" +
- "<classLoader>project</classLoader>" +
- "</configuration>").getBytes()), "UTF-8");
- PluginDescriptor karafServicesPluginDescriptor = pluginManager.loadPlugin(karafServicesPlugin, mavenProject.getRemotePluginRepositories(), mavenSession.getRepositorySession());
- MojoDescriptor karafServicesMojoDescriptor = karafServicesPluginDescriptor.getMojo("service-metadata-generate");
- MojoExecution execution = new MojoExecution(karafServicesMojoDescriptor, configuration);
- pluginManager.executeMojo(mavenSession, execution);
-
- // invoke Felix bundle plugin
- getLog().info("Invoking maven-bundle-plugin");
- Plugin felixBundlePlugin = new Plugin();
- felixBundlePlugin.setGroupId("org.apache.felix");
- felixBundlePlugin.setArtifactId("maven-bundle-plugin");
- felixBundlePlugin.setVersion("3.0.0");
- felixBundlePlugin.setInherited(true);
- felixBundlePlugin.setExtensions(true);
-
-
//
- // Bundle plugin
+ // Felix Bundle plugin
//
Map<String, String> instructions = new LinkedHashMap<>();
- instructions.put("Private-Package", "org.apache.karaf.util.tracker");
- instructions.put("_dsannotations", "*");
-
- //
// Starters supplied instructions
- //
File bndInst = new File(mavenProject.getBasedir(), "target/classes/META-INF/org.apache.karaf.boot.bnd");
if (bndInst.isFile()) {
- List<String> lines = Files.readAllLines(bndInst.toPath());
- for (String line : lines) {
- if (!line.contains(":")) {
- continue;
- }
- String name = line.substring(0, line.indexOf(':')).trim();
- String value = line.substring(line.indexOf(':') + 1).trim();
- if (instructions.containsKey(name)) {
- instructions.put(name, instructions.get(name) + "," + value);
- } else {
- instructions.put(name, value);
- }
- }
+ complete(instructions, bndInst);
bndInst.delete();
}
-
- //
// User supplied instructions
- //
bndInst = new File(mavenProject.getBasedir(), "osgi.bnd");
if (bndInst.isFile()) {
- List<String> lines = Files.readAllLines(bndInst.toPath());
- for (String line : lines) {
- if (!line.contains(":")) {
- continue;
- }
- String name = line.substring(0, line.indexOf(':')).trim();
- String value = line.substring(line.indexOf(':') + 1).trim();
- if (instructions.containsKey(name)) {
- instructions.put(name, instructions.get(name) + "," + value);
- } else {
- instructions.put(name, value);
- }
- }
+ complete(instructions, bndInst);
}
-
+ // Verify and use defaults
+ if (instructions.containsKey("Import-Package")) {
+ instructions.put("Import-Package", instructions.get("Import-Package") + ",*");
+ }
+ // Build config
StringBuilder config = new StringBuilder();
config.append("<configuration>" +
"<finalName>${project.build.finalName}</finalName>" +
@@ -135,14 +77,48 @@ public class GenerateMojo extends AbstractMojo {
}
config.append("</instructions>" +
"</configuration>");
- configuration = Xpp3DomBuilder.build(new StringReader(config.toString()));
+ Xpp3Dom configuration = Xpp3DomBuilder.build(new StringReader(config.toString()));
+ // Invoke plugin
+ getLog().info("Invoking maven-bundle-plugin");
+ Plugin felixBundlePlugin = new Plugin();
+ felixBundlePlugin.setGroupId("org.apache.felix");
+ felixBundlePlugin.setArtifactId("maven-bundle-plugin");
+ felixBundlePlugin.setVersion("3.0.0");
+ felixBundlePlugin.setInherited(true);
+ felixBundlePlugin.setExtensions(true);
PluginDescriptor felixBundlePluginDescriptor = pluginManager.loadPlugin(felixBundlePlugin, mavenProject.getRemotePluginRepositories(), mavenSession.getRepositorySession());
MojoDescriptor felixBundleMojoDescriptor = felixBundlePluginDescriptor.getMojo("bundle");
- execution = new MojoExecution(felixBundleMojoDescriptor, configuration);
+ MojoExecution execution = new MojoExecution(felixBundleMojoDescriptor, configuration);
pluginManager.executeMojo(mavenSession, execution);
+
} catch (Exception e) {
throw new MojoExecutionException("karaf-boot-maven-plugin failed", e);
}
}
+ private void complete(Map<String, String> instructions, File bndInst) throws IOException {
+ List<String> lines = Files.readAllLines(bndInst.toPath());
+ for (String line : lines) {
+ if (!line.contains(":")) {
+ continue;
+ }
+ String name = line.substring(0, line.indexOf(':')).trim();
+ String value = line.substring(line.indexOf(':') + 1).trim();
+ boolean prepend = false;
+ if (name.startsWith("PREPEND-")) {
+ prepend = true;
+ name = name.substring("PREPEND-".length());
+ }
+ if (instructions.containsKey(name)) {
+ if (prepend) {
+ instructions.put(name, value + "," + instructions.get(name));
+ } else {
+ instructions.put(name, instructions.get(name) + "," + value);
+ }
+ } else {
+ instructions.put(name, value);
+ }
+ }
+ }
+
}
[07/35] karaf-boot git commit: Add shell command support
Posted by cs...@apache.org.
Add shell command support
Project: http://git-wip-us.apache.org/repos/asf/karaf-boot/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-boot/commit/1683f3c2
Tree: http://git-wip-us.apache.org/repos/asf/karaf-boot/tree/1683f3c2
Diff: http://git-wip-us.apache.org/repos/asf/karaf-boot/diff/1683f3c2
Branch: refs/heads/master
Commit: 1683f3c21489fd97eae4c5244cd65fe2f2e55c6a
Parents: 8757712
Author: Jean-Baptiste Onofr� <jb...@apache.org>
Authored: Tue Sep 29 15:38:51 2015 +0200
Committer: Jean-Baptiste Onofr� <jb...@apache.org>
Committed: Tue Sep 29 15:38:51 2015 +0200
----------------------------------------------------------------------
.../README.md | 5 +-
.../README.md | 2 +
.../karaf-boot-sample-shell/README.md | 38 ++++++++++++++
.../karaf-boot-sample-shell/pom.xml | 53 ++++++++++++++++++++
.../main/java/sample/shell/HelloCommand.java | 47 +++++++++++++++++
.../karaf-boot-starter-shell/pom.xml | 41 +++++++++++++++
karaf-boot-starters/pom.xml | 1 +
pom.xml | 1 +
8 files changed, 187 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/1683f3c2/karaf-boot-samples/karaf-boot-sample-service-consumer-ds/README.md
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-service-consumer-ds/README.md b/karaf-boot-samples/karaf-boot-sample-service-consumer-ds/README.md
index 93f69f7..f1f6370 100644
--- a/karaf-boot-samples/karaf-boot-sample-service-consumer-ds/README.md
+++ b/karaf-boot-samples/karaf-boot-sample-service-consumer-ds/README.md
@@ -24,7 +24,10 @@ To deploy in Karaf, you have to enable the DS support first. For that, you have
feature:install scr
-Once scr feature installed:
+Once scr feature installed, you have to install a hello service provider. Please use any of karaf-boot-sample-service-provider-*
+deployment first.
+
+Once the service provider is installed:
* you can drop the generated jar file (target/karaf-boot-sample-service-consumer-ds-1.0.jar) in the
Karaf deploy folder
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/1683f3c2/karaf-boot-samples/karaf-boot-sample-service-consumer-osgi/README.md
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-service-consumer-osgi/README.md b/karaf-boot-samples/karaf-boot-sample-service-consumer-osgi/README.md
index 1684c81..02523d8 100644
--- a/karaf-boot-samples/karaf-boot-sample-service-consumer-osgi/README.md
+++ b/karaf-boot-samples/karaf-boot-sample-service-consumer-osgi/README.md
@@ -19,6 +19,8 @@ To build, simply do:
= Deploy
+You have to install a hello service provider first. Please deploy the karaf-boot-sample-service-provider-osgi first.
+
To deploy in Karaf:
* you can drop the generated jar file (target/karaf-boot-sample-service-provider-osgi-1.0.jar) in the
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/1683f3c2/karaf-boot-samples/karaf-boot-sample-shell/README.md
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-shell/README.md b/karaf-boot-samples/karaf-boot-sample-shell/README.md
new file mode 100644
index 0000000..5c9e40b
--- /dev/null
+++ b/karaf-boot-samples/karaf-boot-sample-shell/README.md
@@ -0,0 +1,38 @@
+== karaf-boot-sample-shell ==
+
+This sample provides new shell command in the Karaf shell console, that uses the hello service, provided by another
+artifact (as karaf-boot-sample-service-provider-ds for instance).
+
+= Design
+
+The shell commands are exposed using the Karaf shell annotations.
+
+A command is basically a class implementing Action interface, and we use @Service, @Command, @Argument, @Option Karaf
+shell annotations.
+
+The @Reference annotation uses the hello service.
+
+= Build
+
+To build, simply do:
+
+ mvn clean install
+
+= Deploy
+
+You have to install a hello service provider first. Please deploy karaf-boot-sample-service-provider-ds first.
+
+To deploy in Karaf:
+
+* you can drop the generated jar file (target/karaf-boot-sample-shell-1.0.jar) in the
+Karaf deploy folder
+* in the Karaf shell console, do:
+
+ bundle:install -s mvn:karaf-boot-samples/karaf-boot-sample-shell/1.0
+
+= Usage
+
+Once deployed, you can use the sample:hello command like:
+
+karaf@root()> sample:hello world
+Hello world !
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/1683f3c2/karaf-boot-samples/karaf-boot-sample-shell/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-shell/pom.xml b/karaf-boot-samples/karaf-boot-sample-shell/pom.xml
new file mode 100644
index 0000000..1df8632
--- /dev/null
+++ b/karaf-boot-samples/karaf-boot-sample-shell/pom.xml
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+
+ <!--
+
+ 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.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-sample-shell</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-starter-shell</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-sample-service-provider-ds</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-maven-plugin</artifactId>
+ <version>${project.version}</version>
+ <inherited>true</inherited>
+ <extensions>true</extensions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/1683f3c2/karaf-boot-samples/karaf-boot-sample-shell/src/main/java/sample/shell/HelloCommand.java
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-shell/src/main/java/sample/shell/HelloCommand.java b/karaf-boot-samples/karaf-boot-sample-shell/src/main/java/sample/shell/HelloCommand.java
new file mode 100644
index 0000000..eb4a730
--- /dev/null
+++ b/karaf-boot-samples/karaf-boot-sample-shell/src/main/java/sample/shell/HelloCommand.java
@@ -0,0 +1,47 @@
+/**
+ * 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 sample.shell;
+
+import org.apache.karaf.shell.api.action.Action;
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.Option;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import sample.ds.service.provider.HelloService;
+
+@Service
+@Command(scope = "sample", name = "hello", description = "The hello command")
+public class HelloCommand implements Action {
+
+ @Reference
+ public HelloService helloService;
+
+ @Argument(index = 0, name = "arg", description = "This is the message argument", required = true, multiValued = false)
+ public String arg;
+
+ @Option(name = "opt", description = "This is an option", required = false, multiValued = false)
+ public String opt;
+
+ public Object execute() throws Exception {
+ if (opt != null)
+ System.out.println("Opt is " + opt);
+ System.out.println(helloService.hello(arg));
+ return null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/1683f3c2/karaf-boot-starters/karaf-boot-starter-shell/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-starters/karaf-boot-starter-shell/pom.xml b/karaf-boot-starters/karaf-boot-starter-shell/pom.xml
new file mode 100644
index 0000000..4c413a8
--- /dev/null
+++ b/karaf-boot-starters/karaf-boot-starter-shell/pom.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+
+ <!--
+
+ 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.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-starters</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>karaf-boot-starter-shell</artifactId>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.karaf.shell</groupId>
+ <artifactId>org.apache.karaf.shell.core</artifactId>
+ <version>${karaf.version}</version>
+ </dependency>
+ </dependencies>
+
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/1683f3c2/karaf-boot-starters/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-starters/pom.xml b/karaf-boot-starters/pom.xml
index 04f6ff4..379f140 100644
--- a/karaf-boot-starters/pom.xml
+++ b/karaf-boot-starters/pom.xml
@@ -34,6 +34,7 @@
<modules>
<module>karaf-boot-starter</module>
<module>karaf-boot-starter-ds</module>
+ <module>karaf-boot-starter-shell</module>
</modules>
</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/1683f3c2/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 3650256..cb5e826 100644
--- a/pom.xml
+++ b/pom.xml
@@ -48,6 +48,7 @@
<!-- blueprint -->
<!-- cdi -->
<!-- shell -->
+ <module>karaf-boot-samples/karaf-boot-sample-shell</module>
<!-- config -->
<!-- jpa -->
<!-- servlet -->
[04/35] karaf-boot git commit: Refactoring of karaf-boot
Posted by cs...@apache.org.
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot/src/main/java/org/apache/karaf/boot/Inject.java
----------------------------------------------------------------------
diff --git a/karaf-boot/src/main/java/org/apache/karaf/boot/Inject.java b/karaf-boot/src/main/java/org/apache/karaf/boot/Inject.java
deleted file mode 100644
index e0a0bd7..0000000
--- a/karaf-boot/src/main/java/org/apache/karaf/boot/Inject.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/**
- * 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.karaf.boot;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Target({ElementType.FIELD, ElementType.METHOD, ElementType.CONSTRUCTOR})
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Inject {
- String value() default "";
- String name() default "";
- String description() default "";
- String ref() default "";
- String[] values() default {};
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot/src/main/java/org/apache/karaf/boot/List.java
----------------------------------------------------------------------
diff --git a/karaf-boot/src/main/java/org/apache/karaf/boot/List.java b/karaf-boot/src/main/java/org/apache/karaf/boot/List.java
deleted file mode 100644
index f171908..0000000
--- a/karaf-boot/src/main/java/org/apache/karaf/boot/List.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * 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.karaf.boot;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * used to annotate list value in property
- * I am not convinced that we want to support this via annotation
- *
- */
-@Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})
-@Retention(RetentionPolicy.RUNTIME)
-public @interface List {
-
- // the element of the list
- public Element[] value();
-
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot/src/main/java/org/apache/karaf/boot/Reference.java
----------------------------------------------------------------------
diff --git a/karaf-boot/src/main/java/org/apache/karaf/boot/Reference.java b/karaf-boot/src/main/java/org/apache/karaf/boot/Reference.java
deleted file mode 100644
index ee8d474..0000000
--- a/karaf-boot/src/main/java/org/apache/karaf/boot/Reference.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/**
- * 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.karaf.boot;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Target(ElementType.FIELD)
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Reference
-{
- /**
- * the description property of the service reference
- */
- String description() default "";
-
- /**
- * the interface type that a matching service must support.
- */
- Class<?> serviceInterface() default Object.class;
-
- /**
- * the filter expression that a matching service must match.
- */
- String filter() default "";
-
- /**
- * the <code>component-name</code> attribute of the service reference.
- */
- String componentName() default "";
-
- /**
- * whether or not a matching service is required at all times. either optional or mandatory.
- */
- String availability() default "";
-
- /**
- * the reference listeners for the service reference, to receive bind and unbind events.
- */
- ReferenceListener[] referenceListeners() default {};
-
- /**
- * the timeout property. If the timeout is not specified,
- * the default-timeout value is inherited from the encapsulating
- * <code><blueprint></code> definition.
- */
- int timeout() default 0;
-
- /**
- * the id for the reference
- */
- String id() default "";
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot/src/main/java/org/apache/karaf/boot/ReferenceList.java
----------------------------------------------------------------------
diff --git a/karaf-boot/src/main/java/org/apache/karaf/boot/ReferenceList.java b/karaf-boot/src/main/java/org/apache/karaf/boot/ReferenceList.java
deleted file mode 100644
index 9c1378a..0000000
--- a/karaf-boot/src/main/java/org/apache/karaf/boot/ReferenceList.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/**
- * 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.karaf.boot;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Target(ElementType.FIELD)
-@Retention(RetentionPolicy.RUNTIME)
-public @interface ReferenceList
-{
- /**
- * the description property of the service reference
- */
- String description() default "";
-
- /**
- * the interface type that a matching service must support.
- */
- Class<?> serviceInterface() default Object.class;
-
- /**
- * the filter expression that a matching service must match.
- */
- String filter() default "";
-
- /**
- * the <code>component-name</code> attribute of the service reference.
- */
- String componentName() default "";
-
- /**
- * whether or not a matching service is required at all times. either optional or mandatory.
- */
- String availability() default "";
-
- /**
- * the reference listeners for the service reference, to receive bind and unbind events.
- */
- ReferenceListener[] referenceListeners() default {};
-
- /**
- * the value of the memberType property.
- */
- String memberType() default "service-object";
-
- /**
- * the id for the referencelist
- */
- String id() default "";
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot/src/main/java/org/apache/karaf/boot/ReferenceListener.java
----------------------------------------------------------------------
diff --git a/karaf-boot/src/main/java/org/apache/karaf/boot/ReferenceListener.java b/karaf-boot/src/main/java/org/apache/karaf/boot/ReferenceListener.java
deleted file mode 100644
index 725a220..0000000
--- a/karaf-boot/src/main/java/org/apache/karaf/boot/ReferenceListener.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/**
- * 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.karaf.boot;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Target(ElementType.TYPE)
-@Retention(RetentionPolicy.RUNTIME)
-public @interface ReferenceListener {
- String ref() default "";
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot/src/main/java/org/apache/karaf/boot/Register.java
----------------------------------------------------------------------
diff --git a/karaf-boot/src/main/java/org/apache/karaf/boot/Register.java b/karaf-boot/src/main/java/org/apache/karaf/boot/Register.java
deleted file mode 100644
index 41bb50d..0000000
--- a/karaf-boot/src/main/java/org/apache/karaf/boot/Register.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * 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.karaf.boot;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * used to annotation register-method in blueprint registration listeners
- *
- */
-@Target(ElementType.METHOD)
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Register {
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot/src/main/java/org/apache/karaf/boot/RegistrationListener.java
----------------------------------------------------------------------
diff --git a/karaf-boot/src/main/java/org/apache/karaf/boot/RegistrationListener.java b/karaf-boot/src/main/java/org/apache/karaf/boot/RegistrationListener.java
deleted file mode 100644
index 793e2dd..0000000
--- a/karaf-boot/src/main/java/org/apache/karaf/boot/RegistrationListener.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * 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.karaf.boot;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Target(ElementType.TYPE)
-@Retention(RetentionPolicy.RUNTIME)
-public @interface RegistrationListener {
-
- String ref() default "";
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot/src/main/java/org/apache/karaf/boot/Service.java
----------------------------------------------------------------------
diff --git a/karaf-boot/src/main/java/org/apache/karaf/boot/Service.java b/karaf-boot/src/main/java/org/apache/karaf/boot/Service.java
deleted file mode 100644
index 09b6293..0000000
--- a/karaf-boot/src/main/java/org/apache/karaf/boot/Service.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/**
- * 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.karaf.boot;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Target(ElementType.TYPE)
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Service {
-
- /**
- * the registration listeners to be notified when the service is
- * registered and unregistered with the framework.
- */
- RegistrationListener[] registerationListeners() default {};
-
- /**
- * the ranking value to use when advertising the service. If the
- * ranking value is zero, the service must be registered without a
- * <code>service.ranking</code> service property.
- */
- int ranking() default 0;
-
- /**
- * the auto-export mode for the service.
- * possible values are disabled, interfaces, class_hierarchy, all_classes
- */
- String autoExport() default "";
-
- /**
- * the interfaces that the service should be advertised as supporting.
- */
- Class<?>[] interfaces() default {};
-
- /**
- * the user declared properties to be advertised with the service.
- */
- ServiceProperty[] serviceProperties() default {};
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot/src/main/java/org/apache/karaf/boot/ServiceProperty.java
----------------------------------------------------------------------
diff --git a/karaf-boot/src/main/java/org/apache/karaf/boot/ServiceProperty.java b/karaf-boot/src/main/java/org/apache/karaf/boot/ServiceProperty.java
deleted file mode 100644
index a6ca33d..0000000
--- a/karaf-boot/src/main/java/org/apache/karaf/boot/ServiceProperty.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * 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.karaf.boot;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Target(ElementType.TYPE)
-@Retention(RetentionPolicy.RUNTIME)
-public @interface ServiceProperty {
- /**
- * the key of the property
- */
- String key() default "";
-
- /**
- * the value of the property
- */
- String value() default "";
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot/src/main/java/org/apache/karaf/boot/Unbind.java
----------------------------------------------------------------------
diff --git a/karaf-boot/src/main/java/org/apache/karaf/boot/Unbind.java b/karaf-boot/src/main/java/org/apache/karaf/boot/Unbind.java
deleted file mode 100644
index dbe15d1..0000000
--- a/karaf-boot/src/main/java/org/apache/karaf/boot/Unbind.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * 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.karaf.boot;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * used to annotation unbind-method in blueprint reference listeners
- *
- */
-@Target(ElementType.METHOD)
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Unbind {
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot/src/main/java/org/apache/karaf/boot/Unregister.java
----------------------------------------------------------------------
diff --git a/karaf-boot/src/main/java/org/apache/karaf/boot/Unregister.java b/karaf-boot/src/main/java/org/apache/karaf/boot/Unregister.java
deleted file mode 100644
index 04ea698..0000000
--- a/karaf-boot/src/main/java/org/apache/karaf/boot/Unregister.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * 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.karaf.boot;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * used to annotation unregister-method in blueprint registration listeners
- *
- */
-@Target(ElementType.METHOD)
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Unregister {
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 2c7f8ac..3650256 100644
--- a/pom.xml
+++ b/pom.xml
@@ -29,15 +29,31 @@
Apache Karaf Boot provides a simple way to create artifacts ready to be deployed in Karaf.
</description>
+ <properties>
+ <karaf.version>4.0.1</karaf.version>
+ <osgi.version>6.0.0</osgi.version>
+ </properties>
+
<modules>
- <module>karaf-boot</module>
- <module>karaf-boot-starter</module>
+ <module>karaf-boot-starters</module>
<module>karaf-boot-tools</module>
- <module>karaf-boot-parent</module>
+ <!-- TODO reuse @Services & @Reference shell annotations for generic use cases -->
<!-- Samples -->
- <module>karaf-boot-samples/karaf-boot-sample-simple</module>
+ <module>karaf-boot-samples/karaf-boot-sample-service-provider-osgi</module>
+ <module>karaf-boot-samples/karaf-boot-sample-service-consumer-osgi</module>
+ <module>karaf-boot-samples/karaf-boot-sample-service-provider-ds</module>
+ <module>karaf-boot-samples/karaf-boot-sample-service-consumer-ds</module>
+ <!-- blueprint -->
+ <!-- cdi -->
+ <!-- shell -->
+ <!-- config -->
+ <!-- jpa -->
+ <!-- servlet -->
+ <!-- test -->
+ <!-- rest & soap -->
+ <!-- camel -->
</modules>
</project>
[14/35] karaf-boot git commit: Add a JPA sample
Posted by cs...@apache.org.
Add a JPA sample
Project: http://git-wip-us.apache.org/repos/asf/karaf-boot/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-boot/commit/19a1877c
Tree: http://git-wip-us.apache.org/repos/asf/karaf-boot/tree/19a1877c
Diff: http://git-wip-us.apache.org/repos/asf/karaf-boot/diff/19a1877c
Branch: refs/heads/master
Commit: 19a1877cc571586ad28263c78669e1237a6bf71c
Parents: dd56eb8
Author: Guillaume Nodet <gn...@apache.org>
Authored: Thu Apr 14 20:43:53 2016 +0200
Committer: Guillaume Nodet <gn...@apache.org>
Committed: Thu Apr 14 20:43:53 2016 +0200
----------------------------------------------------------------------
.../karaf-boot-sample-jpa/README.md | 23 +++++++
.../karaf-boot-sample-jpa/pom.xml | 47 ++++++++++++++
.../src/main/java/sample/jpa/Task.java | 65 ++++++++++++++++++++
3 files changed, 135 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/19a1877c/karaf-boot-samples/karaf-boot-sample-jpa/README.md
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-jpa/README.md b/karaf-boot-samples/karaf-boot-sample-jpa/README.md
new file mode 100644
index 0000000..3a3f6a3
--- /dev/null
+++ b/karaf-boot-samples/karaf-boot-sample-jpa/README.md
@@ -0,0 +1,23 @@
+== karaf-boot-sample-jpa ==
+
+This sample shows how to define a JPA bundle and generate the persistent unit.
+
+= Design
+
+A Task entity is defined and annotated with the persistent unit annotations.
+
+= Build
+
+To build, simply do:
+
+ mvn clean install
+
+= Deploy
+
+To deploy i:
+
+* you can drop the generated jar file (target/karaf-boot-sample-jpa-1.0.jar) in the
+Karaf deploy folder
+* in the Karaf shell console, do:
+
+ bundle:install -s mvn:org.apache.karaf.boot/karaf-boot-sample-jpa/1.0
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/19a1877c/karaf-boot-samples/karaf-boot-sample-jpa/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-jpa/pom.xml b/karaf-boot-samples/karaf-boot-sample-jpa/pom.xml
new file mode 100644
index 0000000..032396f
--- /dev/null
+++ b/karaf-boot-samples/karaf-boot-sample-jpa/pom.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+
+ <!--
+
+ 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.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-sample-jpa</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-starter-jpa</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-maven-plugin</artifactId>
+ <version>${project.version}</version>
+ <extensions>true</extensions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/19a1877c/karaf-boot-samples/karaf-boot-sample-jpa/src/main/java/sample/jpa/Task.java
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-jpa/src/main/java/sample/jpa/Task.java b/karaf-boot-samples/karaf-boot-sample-jpa/src/main/java/sample/jpa/Task.java
new file mode 100644
index 0000000..63995c0
--- /dev/null
+++ b/karaf-boot-samples/karaf-boot-sample-jpa/src/main/java/sample/jpa/Task.java
@@ -0,0 +1,65 @@
+/**
+ * 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 sample.jpa;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.karaf.boot.jpa.Hibernate;
+import org.apache.karaf.boot.jpa.PersistentUnit;
+import org.apache.karaf.boot.jpa.Property;
+import org.apache.karaf.boot.jpa.Provider;
+
+@PersistentUnit(name = "tasklist", provider = Provider.Hibernate, properties = {
+ @Property(name = "hibernate.hbm2ddl.auto", value = "create-drop")
+})
+@Hibernate.Dialect(Hibernate.DialectType.HSQL)
+@Entity
+@XmlRootElement
+public class Task {
+ @Id
+ Integer id;
+ String title;
+
+ public Task() {
+ }
+
+
+ public Task(Integer id, String title) {
+ super();
+ this.id = id;
+ this.title = title;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = new Integer(id);
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+}
[05/35] karaf-boot git commit: Refactoring of karaf-boot
Posted by cs...@apache.org.
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/Bean.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/Bean.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/Bean.java
deleted file mode 100644
index 995649c..0000000
--- a/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/Bean.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/**
- * 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.karaf.boot.tools.maven.plugin.model;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.SortedSet;
-import java.util.TreeSet;
-
-import javax.annotation.PostConstruct;
-import javax.annotation.PreDestroy;
-import javax.persistence.PersistenceContext;
-import javax.persistence.PersistenceUnit;
-
-public class Bean extends BeanRef {
- public String initMethod;
- public String destroyMethod;
- public SortedSet<Property> properties;
- public Field[] persistenceFields;
- public TransactionalDef transactionDef;
-
- public Bean(Class<?> clazz) {
- super(clazz);
-
- for (Method method : clazz.getDeclaredMethods()) {
- PostConstruct postConstruct = getEffectiveAnnotation(method, PostConstruct.class);
- if (postConstruct != null) {
- this.initMethod = method.getName();
- }
- PreDestroy preDestroy = getEffectiveAnnotation(method, PreDestroy.class);
- if (preDestroy != null) {
- this.destroyMethod = method.getName();
- }
- }
- this.persistenceFields = getPersistenceFields();
- this.transactionDef = new JavaxTransactionFactory().create(clazz);
- if (this.transactionDef == null) {
- this.transactionDef = new SpringTransactionFactory().create(clazz);
- }
- properties = new TreeSet<Property>();
- }
-
- private Field[] getPersistenceFields() {
- List<Field> persistenceFields = new ArrayList<Field>();
- Field[] fields = clazz.getDeclaredFields();
- for (Field field : fields) {
- PersistenceContext persistenceContext = field.getAnnotation(PersistenceContext.class);
- PersistenceUnit persistenceUnit = field.getAnnotation(PersistenceUnit.class);
- if (persistenceContext !=null || persistenceUnit != null) {
- persistenceFields.add(field);
- }
- }
- return persistenceFields.toArray(new Field[]{});
- }
-
- public void resolve(Matcher matcher) {
- Class<?> curClass = this.clazz;
- while (curClass != null && curClass != Object.class) {
- resolveProperties(matcher, curClass);
- curClass = curClass.getSuperclass();
- }
- }
-
- private void resolveProperties(Matcher matcher, Class<?> curClass) {
- for (Field field : curClass.getDeclaredFields()) {
- Property prop = Property.create(matcher, field);
- if (prop != null) {
- properties.add(prop);
- }
- }
- }
-
- private static <T extends Annotation> T getEffectiveAnnotation(Method method, Class<T> annotationClass) {
- final Class<?> methodClass = method.getDeclaringClass();
- final String name = method.getName();
- final Class<?>[] params = method.getParameterTypes();
-
- // 1. Current class
- final T rootAnnotation = method.getAnnotation(annotationClass);
- if (rootAnnotation != null) {
- return rootAnnotation;
- }
-
- // 2. Superclass
- final Class<?> superclass = methodClass.getSuperclass();
- if (superclass != null) {
- final T annotation = getMethodAnnotation(superclass, name, params, annotationClass);
- if (annotation != null)
- return annotation;
- }
-
- // 3. Interfaces
- for (final Class<?> intfs : methodClass.getInterfaces()) {
- final T annotation = getMethodAnnotation(intfs, name, params, annotationClass);
- if (annotation != null)
- return annotation;
- }
-
- return null;
- }
-
- private static <T extends Annotation> T getMethodAnnotation(Class<?> searchClass, String name, Class<?>[] params,
- Class<T> annotationClass) {
- try {
- Method method = searchClass.getMethod(name, params);
- return getEffectiveAnnotation(method, annotationClass);
- } catch (NoSuchMethodException e) {
- return null;
- }
- }
-
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((clazz == null) ? 0 : clazz.getName().hashCode());
- result = prime * result + ((id == null) ? 0 : id.hashCode());
- return result;
- }
-
- @Override
- public String toString() {
- return clazz.getName();
- }
-
- public void writeProperties(PropertyWriter writer) {
- for (Property property : properties) {
- writer.writeProperty(property);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/BeanRef.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/BeanRef.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/BeanRef.java
deleted file mode 100644
index ba67f33..0000000
--- a/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/BeanRef.java
+++ /dev/null
@@ -1,69 +0,0 @@
-package org.apache.karaf.boot.tools.maven.plugin.model;
-
-import java.lang.reflect.Field;
-
-import javax.inject.Named;
-
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.stereotype.Component;
-
-public class BeanRef implements Comparable<BeanRef> {
- public String id;
- public Class<?> clazz;
-
- /**
- *
- * @param clazz interface or implementation class
- */
- public BeanRef(Class<?> clazz) {
- this.clazz = clazz;
- this.id = getBeanName(clazz);
- }
-
- public BeanRef(Class<?> type, String id) {
- this.clazz = type;
- this.id = id;
- }
-
- public BeanRef(Field field) {
- this(field.getType(), getDestinationId(field));
- }
-
- private static String getDestinationId(Field field) {
- Named named = field.getAnnotation(Named.class);
- if (named != null) {
- return named.value();
- }
- Qualifier qualifier = field.getAnnotation(Qualifier.class);
- if (qualifier != null) {
- return qualifier.value();
- }
- return null;
- }
-
- public static String getBeanName(Class<?> clazz) {
- Component component = clazz.getAnnotation(Component.class);
- Named named = clazz.getAnnotation(Named.class);
- if (component != null && !"".equals(component.value())) {
- return component.value();
- } else if (named != null && !"".equals(named.value())) {
- return named.value();
- } else {
- String name = clazz.getSimpleName();
- return getBeanNameFromSimpleName(name);
- }
- }
-
- private static String getBeanNameFromSimpleName(String name) {
- return name.substring(0, 1).toLowerCase() + name.substring(1, name.length());
- }
-
- public boolean matches(BeanRef template) {
- boolean assignable = template.clazz.isAssignableFrom(this.clazz);
- return assignable && ((template.id == null) || id.equals(template.id));
- }
-
- public int compareTo(BeanRef other) {
- return this.id.compareTo(other.id);
- }
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/Context.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/Context.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/Context.java
deleted file mode 100644
index 442bc6e..0000000
--- a/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/Context.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/**
- * 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.karaf.boot.tools.maven.plugin.model;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.SortedSet;
-import java.util.TreeSet;
-
-import javax.enterprise.inject.Produces;
-
-import org.ops4j.pax.cdi.api.OsgiService;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.service.blueprint.container.BlueprintContainer;
-import org.osgi.service.blueprint.container.Converter;
-
-public class Context implements Matcher {
-
- SortedSet<Bean> beans;
- SortedSet<OsgiServiceRef> serviceRefs;
-
- public Context(Class<?>... beanClasses) {
- this(Arrays.asList(beanClasses));
- }
-
- public Context(Collection<Class<?>> beanClasses) {
- this.beans = new TreeSet<Bean>();
- this.serviceRefs = new TreeSet<OsgiServiceRef>();
- addBeans(beanClasses);
- }
-
- private void addBeans(Collection<Class<?>> beanClasses) {
- for (Class<?> clazz : beanClasses) {
- Bean bean = new Bean(clazz);
- beans.add(bean);
- addServiceRefs(clazz);
- addProducedBeans(clazz, bean.id);
- }
- }
-
- private void addProducedBeans(Class<?> clazz, String factoryBeanId) {
- for (Method method : clazz.getMethods()) {
- Produces produces = method.getAnnotation(Produces.class);
- if (produces != null) {
- Class<?> producedClass = method.getReturnType();
- ProducedBean producedBean = new ProducedBean(producedClass, factoryBeanId, method.getName());
- beans.add(producedBean);
- }
- }
- }
-
- private void addServiceRefs(Class<?> clazz) {
- for (Field field : clazz.getDeclaredFields()) {
- OsgiService osgiService = field.getAnnotation(OsgiService.class);
- if (osgiService != null) {
- serviceRefs.add(new OsgiServiceRef(field));
- }
- }
- }
-
- public void resolve() {
- for (Bean bean : beans) {
- bean.resolve(this);
- }
- }
-
- public BeanRef getMatching(BeanRef template) {
- for (Bean bean : beans) {
- if (bean.matches(template)) {
- return bean;
- }
- }
- for (BeanRef bean : serviceRefs) {
- if (bean.matches(template)) {
- return bean;
- }
- }
- if (template.clazz == BundleContext.class) {
- return new BeanRef(BundleContext.class, "blueprintBundleContext");
- }
- if (template.clazz == Bundle.class) {
- return new BeanRef(Bundle.class, "blueprintBundle");
- }
- if (template.clazz == BlueprintContainer.class) {
- return new BeanRef(BlueprintContainer.class, "blueprintContainer");
- }
- if (template.clazz == Converter.class) {
- return new BeanRef(Converter.class, "blueprintConverter");
- }
-
- return null;
- }
-
- public SortedSet<Bean> getBeans() {
- return beans;
- }
-
- public SortedSet<OsgiServiceRef> getServiceRefs() {
- return serviceRefs;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/JavaxTransactionFactory.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/JavaxTransactionFactory.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/JavaxTransactionFactory.java
deleted file mode 100644
index c00a54c..0000000
--- a/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/JavaxTransactionFactory.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * 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.karaf.boot.tools.maven.plugin.model;
-
-import java.util.HashMap;
-
-import javax.transaction.Transactional;
-import javax.transaction.Transactional.TxType;
-
-public class JavaxTransactionFactory {
- private static HashMap<TxType, String> txTypeNames;
-
- static {
- txTypeNames = new HashMap<TxType, String>();
- txTypeNames.put(TxType.REQUIRED, TransactionalDef.TYPE_REQUIRED);
- txTypeNames.put(TxType.REQUIRES_NEW, TransactionalDef.TYPE_REQUIRES_NEW);
- }
-
- TransactionalDef create(Class<?> clazz) {
- Transactional transactional = clazz.getAnnotation(Transactional.class);
- return transactional != null ?
- new TransactionalDef("*", txTypeNames.get(transactional.value())) : null;
- }
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/Matcher.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/Matcher.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/Matcher.java
deleted file mode 100644
index f703ed1..0000000
--- a/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/Matcher.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/**
- * 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.karaf.boot.tools.maven.plugin.model;
-
-public interface Matcher {
- BeanRef getMatching(BeanRef template);
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/OsgiServiceRef.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/OsgiServiceRef.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/OsgiServiceRef.java
deleted file mode 100644
index 5069663..0000000
--- a/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/OsgiServiceRef.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * 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.karaf.boot.tools.maven.plugin.model;
-
-import java.lang.reflect.Field;
-
-import org.ops4j.pax.cdi.api.OsgiService;
-
-/**
- * Synthetic bean that refers to an OSGi service
- */
-public class OsgiServiceRef extends BeanRef {
-
- public String filter;
-
- public OsgiServiceRef(Field field) {
- super(field);
- if (id == null) {
- id = getBeanName(clazz);
- }
- OsgiService osgiService = field.getAnnotation(OsgiService.class);
- filter = osgiService.filter();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/ProducedBean.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/ProducedBean.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/ProducedBean.java
deleted file mode 100644
index b5e8b11..0000000
--- a/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/ProducedBean.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package org.apache.karaf.boot.tools.maven.plugin.model;
-
-public class ProducedBean extends Bean {
- public String factoryMethod;
- public String factoryBeanId;
-
- public ProducedBean(Class<?> clazz, String factoryBeanId, String factoryMethod) {
- super(clazz);
- this.factoryBeanId = factoryBeanId;
- this.factoryMethod = factoryMethod;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/Property.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/Property.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/Property.java
deleted file mode 100644
index 4ec7e5a..0000000
--- a/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/Property.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/**
- * 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.karaf.boot.tools.maven.plugin.model;
-
-import java.lang.reflect.Field;
-
-import javax.inject.Inject;
-import javax.inject.Named;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.beans.factory.annotation.Value;
-
-public class Property implements Comparable<Property> {
- public String name;
- public String ref;
- public String value;
-
- public Property(String name, String ref, String value) {
- this.name = name;
- this.ref = ref;
- this.value = value;
- }
-
- public static Property create(Matcher matcher, Field field) {
- Value value = field.getAnnotation(Value.class);
- if (needsInject(field)) {
- BeanRef matching = matcher.getMatching(new BeanRef(field));
- String ref = (matching == null) ? getRefName(field) : matching.id;
- return new Property(field.getName(), ref, null);
- } else if (value != null){
- return new Property(field.getName(), null, cleanValue(value.value()));
- } else {
- // Field is not a property
- return null;
- }
- }
-
- /**
- * Assume it is defined in another manually created blueprint context with default name
- * @param field
- * @return
- */
- private static String getRefName(Field field) {
- Named named = field.getAnnotation(Named.class);
- if (named != null) {
- return named.value();
- }
- Qualifier qualifier = field.getAnnotation(Qualifier.class);
- if (qualifier != null) {
- return qualifier.value();
- }
- return Bean.getBeanName(field.getType());
- }
-
- private static boolean needsInject(Field field) {
- return field.getAnnotation(Autowired.class) != null || field.getAnnotation(Inject.class) != null;
- }
-
- /**
- * Remove default value definition
- *
- * @param value
- * @return
- */
- private static String cleanValue(String value) {
- return value.replaceAll("\\:.*\\}", "}");
- }
-
- public int compareTo(Property other) {
- return name.compareTo(other.name);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/PropertyWriter.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/PropertyWriter.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/PropertyWriter.java
deleted file mode 100644
index e8e6bda..0000000
--- a/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/PropertyWriter.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/**
- * 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.karaf.boot.tools.maven.plugin.model;
-
-public interface PropertyWriter {
- void writeProperty(Property property);
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/SpringTransactionFactory.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/SpringTransactionFactory.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/SpringTransactionFactory.java
deleted file mode 100644
index 4d65261..0000000
--- a/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/SpringTransactionFactory.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * 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.karaf.boot.tools.maven.plugin.model;
-
-import java.util.HashMap;
-
-import org.springframework.transaction.annotation.Propagation;
-import org.springframework.transaction.annotation.Transactional;
-
-public class SpringTransactionFactory {
- private static HashMap<Propagation, String> txTypeNames;
-
- static {
- txTypeNames = new HashMap<Propagation, String>();
- txTypeNames.put(Propagation.REQUIRED, TransactionalDef.TYPE_REQUIRED);
- txTypeNames.put(Propagation.REQUIRES_NEW, TransactionalDef.TYPE_REQUIRES_NEW);
- }
-
- TransactionalDef create(Class<?> clazz) {
- Transactional transactional = clazz.getAnnotation(Transactional.class);
- return transactional != null ?
- new TransactionalDef("*", txTypeNames.get(transactional.propagation())) : null;
- }
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/TransactionalDef.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/TransactionalDef.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/TransactionalDef.java
deleted file mode 100644
index 7be6a67..0000000
--- a/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/TransactionalDef.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * 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.karaf.boot.tools.maven.plugin.model;
-
-public class TransactionalDef {
- public static final String TYPE_REQUIRED = "Required";
- public static final String TYPE_REQUIRES_NEW = "RequiresNew";
- private String method;
- private String type;
-
- public TransactionalDef(String method, String type) {
- this.method = method;
- this.type = type;
- }
-
- public String getMethod() {
- return method;
- }
-
- public String getType() {
- return type;
- }
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot-tools/karaf-boot-maven-plugin/src/main/resources/META-INF/plexus/components.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/main/resources/META-INF/plexus/components.xml b/karaf-boot-tools/karaf-boot-maven-plugin/src/main/resources/META-INF/plexus/components.xml
new file mode 100644
index 0000000..6fa2eeb
--- /dev/null
+++ b/karaf-boot-tools/karaf-boot-maven-plugin/src/main/resources/META-INF/plexus/components.xml
@@ -0,0 +1,61 @@
+<!--
+ 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.
+-->
+<component-set>
+ <components>
+ <component>
+ <role>org.apache.maven.lifecycle.mapping.LifecycleMapping</role>
+ <role-hint>jar</role-hint>
+ <implementation>org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping</implementation>
+ <configuration>
+ <lifecycles>
+ <lifecycle>
+ <id>default</id>
+ <phases>
+ <process-resources>org.apache.maven.plugins:maven-resources-plugin:resources</process-resources>
+ <compile>org.apache.maven.plugins:maven-compiler-plugin:compile</compile>
+ <process-classes>org.apache.karaf.boot:karaf-boot-maven-plugin:generate</process-classes>
+ <process-test-resources>org.apache.maven.plugins:maven-resources-plugin:testResources</process-test-resources>
+ <test-compile>org.apache.maven.plugins:maven-compiler-plugin:testCompile</test-compile>
+ <test>org.apache.maven.plugins:maven-surefire-plugin:test</test>
+ <install>
+ org.apache.maven.plugins:maven-install-plugin:install
+ </install>
+ <deploy>
+ org.apache.maven.plugins:maven-deploy-plugin:deploy
+ </deploy>
+ </phases>
+ </lifecycle>
+ </lifecycles>
+ </configuration>
+ </component>
+ <component>
+ <role>org.apache.maven.artifact.handler.ArtifactHandler</role>
+ <role-hint>bundle</role-hint>
+ <implementation>org.apache.maven.artifact.handler.DefaultArtifactHandler</implementation>
+ <configuration>
+ <type>jar</type>
+ <includesDependencies>false</includesDependencies>
+ <language>java</language>
+ <extension>jar</extension>
+ <addedToClasspath>true</addedToClasspath>
+ <packaging>jar</packaging>
+ </configuration>
+ </component>
+ </components>
+</component-set>
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/GeneratorTest.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/GeneratorTest.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/GeneratorTest.java
deleted file mode 100644
index ff009b3..0000000
--- a/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/GeneratorTest.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/**
- * 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.karaf.boot.tools.maven.plugin;
-
-import static java.util.Arrays.asList;
-import static org.apache.karaf.boot.tools.maven.plugin.FilteredClassFinder.findClasses;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Set;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.xpath.XPath;
-import javax.xml.xpath.XPathConstants;
-import javax.xml.xpath.XPathFactory;
-
-import org.apache.karaf.boot.tools.maven.plugin.model.Context;
-import org.apache.karaf.boot.tools.maven.plugin.test.MyBean1;
-import org.apache.commons.io.output.ByteArrayOutputStream;
-import org.apache.xbean.finder.ClassFinder;
-import org.junit.Assert;
-import org.junit.Test;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.xml.sax.SAXException;
-
-public class GeneratorTest {
-
- private XPath xpath;
- private Document document;
-
- @Test
- public void testGenerate() throws Exception {
- ClassFinder classFinder = new ClassFinder(this.getClass().getClassLoader());
- String packageName = MyBean1.class.getPackage().getName();
- Set<Class<?>> beanClasses = findClasses(classFinder, asList(packageName));
- Context context = new Context(beanClasses);
- context.resolve();
- ByteArrayOutputStream os = new ByteArrayOutputStream();
- new Generator(context, os, false).generate();
- System.out.println(os.toString("UTF-8"));
-
- document = readToDocument(os);
- xpath = XPathFactory.newInstance().newXPath();
- //xpath.setNamespaceContext(new NameSpaces(document));
- Node bean1 = (Node) xpath.evaluate("/blueprint/bean[@id='myBean1']", document, XPathConstants.NODE);
-
- // Bean
- Assert.assertEquals(MyBean1.class.getName(), xpath.evaluate("@class", bean1));
- Assert.assertEquals("init", xpath.evaluate("@init-method", bean1));
- Assert.assertEquals("destroy", xpath.evaluate("@destroy-method", bean1));
- Assert.assertEquals("true", xpath.evaluate("@field-injection", bean1));
-
- // @Transactional
- Assert.assertEquals("*", xpath.evaluate("transaction/@method", bean1));
- Assert.assertEquals("Required", xpath.evaluate("transaction/@value", bean1));
-
- // @PersistenceContext
- Assert.assertEquals("person", xpath.evaluate("context/@unitname", bean1));
- Assert.assertEquals("em", xpath.evaluate("context/@property", bean1));
-
- // @PersistenceUnit
- Assert.assertEquals("person", xpath.evaluate("unit/@unitname", bean1));
- Assert.assertEquals("emf", xpath.evaluate("unit/@property", bean1));
-
- // @Autowired
- Assert.assertEquals("my1", xpath.evaluate("property[@name='bean2']/@ref", bean1));
-
-
- }
-
- private Document readToDocument(ByteArrayOutputStream os) throws ParserConfigurationException,
- SAXException, IOException {
- InputStream is = new ByteArrayInputStream(os.toByteArray());
- DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
- DocumentBuilder builder = builderFactory.newDocumentBuilder();
- return builder.parse(is);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/Namespaces.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/Namespaces.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/Namespaces.java
deleted file mode 100644
index c4224ce..0000000
--- a/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/Namespaces.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/**
- * 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.karaf.boot.tools.maven.plugin;
-
-import java.util.Iterator;
-
-import javax.xml.XMLConstants;
-import javax.xml.namespace.NamespaceContext;
-
-import org.w3c.dom.Document;
-
-
-public class Namespaces implements NamespaceContext {
- private Document doc;
-
- public Namespaces(Document doc) {
- this.doc = doc;
- }
-
- @Override
- public String getNamespaceURI(String prefix) {
- if (prefix.equals(XMLConstants.DEFAULT_NS_PREFIX)) {
- return doc.lookupNamespaceURI(null);
- } else {
- return doc.lookupNamespaceURI(prefix);
- }
- }
-
- @Override
- public String getPrefix(String namespaceURI) {
- return doc.lookupPrefix(namespaceURI);
- }
-
- @Override
- public Iterator<String> getPrefixes(String namespaceURI) {
- return null;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/model/BeanTest.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/model/BeanTest.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/model/BeanTest.java
deleted file mode 100644
index 9f6470f..0000000
--- a/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/model/BeanTest.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/**
- * 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.karaf.boot.tools.maven.plugin.model;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-
-import javax.inject.Named;
-
-import org.apache.karaf.boot.tools.maven.plugin.test.MyBean1;
-import org.apache.karaf.boot.tools.maven.plugin.test.MyBean3;
-import org.apache.karaf.boot.tools.maven.plugin.test.MyBean4;
-import org.apache.karaf.boot.tools.maven.plugin.test.ServiceAImpl1;
-import org.junit.Assert;
-import org.junit.Test;
-
-
-public class BeanTest {
-
- @Test
- public void testParseMyBean1() {
- Bean bean = new Bean(MyBean1.class);
- bean.resolve(new Context());
- assertEquals(MyBean1.class, bean.clazz);
- assertEquals("myBean1", bean.id); // Name derived from class name
- assertEquals("init", bean.initMethod);
- assertEquals("destroy", bean.destroyMethod);
- Assert.assertEquals(2, bean.persistenceFields.length);
- assertEquals("em", bean.persistenceFields[0].getName());
- assertEquals("emf", bean.persistenceFields[1].getName());
- assertEquals("*", bean.transactionDef.getMethod());
- assertEquals("Required", bean.transactionDef.getType());
- assertEquals(1, bean.properties.size());
- Property prop = bean.properties.iterator().next();
- assertEquals("bean2", prop.name);
- assertEquals("serviceA", prop.ref);
- }
-
- @Test
- public void testParseMyBean3() {
- Bean bean = new Bean(MyBean3.class);
- bean.resolve(new Context());
- assertEquals(MyBean3.class, bean.clazz);
- assertEquals("myBean3", bean.id); // Name derived from class name
- assertNull("There should be no initMethod", bean.initMethod);
- assertNull("There should be no destroyMethod", bean.destroyMethod);
- assertEquals("There should be no persistence fields", 0, bean.persistenceFields.length);
- assertEquals("*", bean.transactionDef.getMethod());
- assertEquals("RequiresNew", bean.transactionDef.getType());
- assertEquals(5, bean.properties.size());
- }
-
- @Test
- public void testParseNamedBean() {
- Bean bean = new Bean(ServiceAImpl1.class);
- bean.resolve(new Context());
- String definedName = ServiceAImpl1.class.getAnnotation(Named.class).value();
- assertEquals("my1", definedName);
- assertEquals("Name should be defined using @Named", definedName, bean.id);
- assertNull("There should be no initMethod", bean.initMethod);
- assertNull("There should be no destroyMethod", bean.destroyMethod);
- assertEquals("There should be no persistence fields", 0, bean.persistenceFields.length);
- assertNull("There should be no transaction definition", bean.transactionDef);
- assertEquals("There should be no properties", 0, bean.properties.size());
- }
-
- @Test
- public void testBlueprintBundleContext() {
- Bean bean = new Bean(MyBean4.class);
- bean.resolve(new Context());
- Property bcProp = bean.properties.iterator().next();
- assertEquals("bundleContext", bcProp.name);
- assertEquals("blueprintBundleContext", bcProp.ref);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/model/ContextTest.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/model/ContextTest.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/model/ContextTest.java
deleted file mode 100644
index e9a1d12..0000000
--- a/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/model/ContextTest.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/**
- * 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.karaf.boot.tools.maven.plugin.model;
-
-import static org.junit.Assert.assertEquals;
-
-import org.apache.karaf.boot.tools.maven.plugin.test.MyBean3;
-import org.apache.karaf.boot.tools.maven.plugin.test.MyFactoryBean;
-import org.apache.karaf.boot.tools.maven.plugin.test.MyProduced;
-import org.apache.karaf.boot.tools.maven.plugin.test.ServiceB;
-import org.apache.karaf.boot.tools.maven.plugin.test.ServiceReferences;
-import org.junit.Assert;
-import org.junit.Test;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.service.blueprint.container.BlueprintContainer;
-import org.osgi.service.blueprint.container.Converter;
-
-public class ContextTest {
-
- @Test
- public void testLists() {
- Context context = new Context(MyBean3.class);
- Assert.assertEquals(1, context.getBeans().size());
- Assert.assertEquals(0, context.getServiceRefs().size());
- }
-
- @Test
- public void testLists2() {
- Context context = new Context(ServiceReferences.class);
- Assert.assertEquals(1, context.getBeans().size());
- Assert.assertEquals(2, context.getServiceRefs().size());
- }
-
- @Test
- public void testMatching() throws NoSuchFieldException, SecurityException {
- Context context = new Context(ServiceReferences.class);
- BeanRef matching = context.getMatching(new BeanRef(ServiceB.class));
- Assert.assertEquals(OsgiServiceRef.class, matching.getClass());
- Assert.assertEquals(ServiceB.class, matching.clazz);
- Assert.assertEquals("serviceB", matching.id);
- }
-
- private void assertSpecialRef(String expectedId, Class<?> clazz) {
- Context context = new Context();
- BeanRef ref = context.getMatching(new BeanRef(clazz));
- assertEquals(expectedId, ref.id);
- }
-
- @Test
- public void testSpecialRefs() {
- assertSpecialRef("blueprintBundleContext", BundleContext.class);
- assertSpecialRef("blueprintBundle", Bundle.class);
- assertSpecialRef("blueprintContainer", BlueprintContainer.class);
- assertSpecialRef("blueprintConverter", Converter.class);
- }
-
- @Test
- public void testProduced() throws NoSuchFieldException, SecurityException {
- Context context = new Context(MyFactoryBean.class);
-
- ProducedBean matching = (ProducedBean)context.getMatching(new BeanRef(MyProduced.class));
- Assert.assertEquals(MyProduced.class, matching.clazz);
- Assert.assertEquals("myFactoryBean", matching.factoryBeanId);
- Assert.assertEquals("create", matching.factoryMethod);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/model/PropertyTest.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/model/PropertyTest.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/model/PropertyTest.java
deleted file mode 100644
index 772af11..0000000
--- a/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/model/PropertyTest.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/**
- * 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.karaf.boot.tools.maven.plugin.model;
-
-import java.lang.reflect.Field;
-
-import javax.xml.stream.XMLStreamException;
-
-import org.apache.karaf.boot.tools.maven.plugin.test.ServiceAImpl1;
-import org.junit.Assert;
-import org.junit.Test;
-
-public class PropertyTest {
- @Test
- public void testRefInject() throws XMLStreamException {
- Field field = TestBeanForRef.class.getDeclaredFields()[0];
- Matcher matcher = new Matcher() {
- public Bean getMatching(BeanRef template) {
- return new Bean(ServiceAImpl1.class);
- }
- };
- Property property = Property.create(matcher, field);
- Assert.assertEquals("serviceA", property.name);
- Assert.assertNull("Value should be null", property.value);
- Assert.assertEquals("my1", property.ref);
- }
-
- @Test
- public void testRefAutowired() throws XMLStreamException {
- Field field = TestBeanForRef.class.getDeclaredFields()[1];
- Matcher matcher = new Matcher() {
- public Bean getMatching(BeanRef template) {
- return null;
- }
- };
- Property property = Property.create(matcher, field);
- Assert.assertEquals("serviceB", property.name);
- Assert.assertNull("Value should be null", property.value);
- Assert.assertEquals("Should be default name as no match is found", "serviceB", property.ref);
- }
-
- @Test
- public void testValue() throws XMLStreamException {
- Field field = TestBeanForRef.class.getDeclaredFields()[2];
- Property property = Property.create(null, field);
- Assert.assertEquals("name", property.name);
- Assert.assertEquals("${name}", property.value);
- Assert.assertNull("Ref should be null", property.ref);
- }
-
- @Test
- public void testNoProperty() throws XMLStreamException {
- Field field = TestBeanForRef.class.getDeclaredFields()[3];
- Property property = Property.create(null, field);
- Assert.assertNull("Should not be a property", property);
- }
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/model/TestBeanForRef.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/model/TestBeanForRef.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/model/TestBeanForRef.java
deleted file mode 100644
index 2a96d05..0000000
--- a/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/model/TestBeanForRef.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * 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.karaf.boot.tools.maven.plugin.model;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceUnit;
-
-import org.apache.karaf.boot.tools.maven.plugin.test.ServiceA;
-import org.apache.karaf.boot.tools.maven.plugin.test.ServiceB;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-
-@Singleton
-public class TestBeanForRef {
- @Inject
- ServiceA serviceA;
- @Autowired
- ServiceB serviceB;
- @Value("${name:default}") String name;
- @PersistenceUnit(unitName="myunit") EntityManager em;
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/MyBean1.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/MyBean1.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/MyBean1.java
deleted file mode 100644
index 248578a..0000000
--- a/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/MyBean1.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- * 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.karaf.boot.tools.maven.plugin.test;
-
-import javax.inject.Singleton;
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceContext;
-import javax.persistence.PersistenceUnit;
-import javax.transaction.Transactional;
-import javax.transaction.Transactional.TxType;
-
-import org.springframework.beans.factory.annotation.Autowired;
-
-@Singleton
-@Transactional(value=TxType.REQUIRED)
-public class MyBean1 extends ParentBean {
-
- @Autowired
- ServiceA bean2;
-
- @PersistenceContext(unitName="person")
- EntityManager em;
-
- @PersistenceUnit(unitName="person")
- EntityManager emf;
-
- public void init() {
- }
-
- public void destroy() {
- }
-
- public void saveData() {
-
- }
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/MyBean3.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/MyBean3.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/MyBean3.java
deleted file mode 100644
index d96f6c6..0000000
--- a/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/MyBean3.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * 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.karaf.boot.tools.maven.plugin.test;
-
-import javax.inject.Inject;
-import javax.inject.Named;
-import javax.inject.Singleton;
-
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.transaction.annotation.Propagation;
-import org.springframework.transaction.annotation.Transactional;
-
-@Singleton
-@Transactional(propagation=Propagation.REQUIRES_NEW)
-public class MyBean3 {
-
- @Inject
- @Named("my1")
- ServiceA serviceA1;
-
- @Inject
- @Qualifier("my2")
- ServiceA serviceA2;
-
- @Inject
- ServiceB serviceB;
-
- @Inject
- @Named("serviceB2Id")
- ServiceB serviceB2;
-
- @Inject
- MyProduced myProduced;
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/MyBean4.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/MyBean4.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/MyBean4.java
deleted file mode 100644
index 83a2244..0000000
--- a/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/MyBean4.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package org.apache.karaf.boot.tools.maven.plugin.test;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.osgi.framework.BundleContext;
-
-@Singleton
-public class MyBean4 {
-
- @Inject
- BundleContext bundleContext;
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/MyFactoryBean.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/MyFactoryBean.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/MyFactoryBean.java
deleted file mode 100644
index 6442100..0000000
--- a/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/MyFactoryBean.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package org.apache.karaf.boot.tools.maven.plugin.test;
-
-import javax.enterprise.inject.Produces;
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-@Singleton
-public class MyFactoryBean {
-
- @Inject
- ServiceB serviceB;
-
- @Produces
- public MyProduced create() {
- return new MyProduced("My message");
- }
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/MyProduced.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/MyProduced.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/MyProduced.java
deleted file mode 100644
index 9426aea..0000000
--- a/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/MyProduced.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package org.apache.karaf.boot.tools.maven.plugin.test;
-
-import javax.inject.Inject;
-
-public class MyProduced {
- private String message;
-
- @Inject
- ServiceA serviceA;
-
- public MyProduced(String message) {
- this.message = message;
- }
-
- public String getMessage() {
- return message;
- }
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/ParentBean.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/ParentBean.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/ParentBean.java
deleted file mode 100644
index dc8f515..0000000
--- a/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/ParentBean.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/**
- * 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.karaf.boot.tools.maven.plugin.test;
-
-import javax.annotation.PostConstruct;
-import javax.annotation.PreDestroy;
-
-public class ParentBean {
-
- @PostConstruct
- public void init() {
- }
-
- @PreDestroy
- public void destroy() {
- }
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/ServiceA.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/ServiceA.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/ServiceA.java
deleted file mode 100644
index 1897163..0000000
--- a/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/ServiceA.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/**
- * 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.karaf.boot.tools.maven.plugin.test;
-
-public interface ServiceA {
-
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/ServiceAImpl1.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/ServiceAImpl1.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/ServiceAImpl1.java
deleted file mode 100644
index 7b6f405..0000000
--- a/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/ServiceAImpl1.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/**
- * 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.karaf.boot.tools.maven.plugin.test;
-
-import javax.inject.Named;
-import javax.inject.Singleton;
-
-@Singleton
-@Named("my1")
-public class ServiceAImpl1 implements ServiceA {
-
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/ServiceAImpl2.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/ServiceAImpl2.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/ServiceAImpl2.java
deleted file mode 100644
index 5c17339..0000000
--- a/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/ServiceAImpl2.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * 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.karaf.boot.tools.maven.plugin.test;
-
-import javax.inject.Named;
-import javax.inject.Singleton;
-
-import org.ops4j.pax.cdi.api.OsgiServiceProvider;
-import org.springframework.beans.factory.annotation.Value;
-
-@Singleton
-@Named("my2")
-@OsgiServiceProvider(classes={ServiceA.class})
-public class ServiceAImpl2 implements ServiceA {
- @Value("${url:http://default}")
- String url;
-
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/ServiceB.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/ServiceB.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/ServiceB.java
deleted file mode 100644
index e931307..0000000
--- a/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/ServiceB.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/**
- * 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.karaf.boot.tools.maven.plugin.test;
-
-public interface ServiceB {
-
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/ServiceReferences.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/ServiceReferences.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/ServiceReferences.java
deleted file mode 100644
index 4824bcb..0000000
--- a/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/ServiceReferences.java
+++ /dev/null
@@ -1,33 +0,0 @@
-
-/**
- * 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.karaf.boot.tools.maven.plugin.test;
-
-import javax.inject.Inject;
-import javax.inject.Named;
-
-import org.ops4j.pax.cdi.api.OsgiService;
-import org.springframework.stereotype.Component;
-
-@Component
-public class ServiceReferences {
- @Inject @OsgiService ServiceB serviceB;
-
- @Named("serviceB2Id") @Inject @OsgiService ServiceB serviceB2;
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot/README.md
----------------------------------------------------------------------
diff --git a/karaf-boot/README.md b/karaf-boot/README.md
deleted file mode 100644
index d428147..0000000
--- a/karaf-boot/README.md
+++ /dev/null
@@ -1,5 +0,0 @@
-Karaf Boot Annotations
------------------------
-
-Karaf Boot provides annotations allowing you to focus on your business code, and let Karaf Boot deals with all the
-plumbing for you.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot/pom.xml b/karaf-boot/pom.xml
deleted file mode 100644
index 22421fa..0000000
--- a/karaf-boot/pom.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<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">
-
- <!--
-
- 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.
- -->
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-build</artifactId>
- <version>1.0.0-SNAPSHOT</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
-
- <artifactId>karaf-boot</artifactId>
-
-</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot/src/main/java/org/apache/karaf/boot/Arg.java
----------------------------------------------------------------------
diff --git a/karaf-boot/src/main/java/org/apache/karaf/boot/Arg.java b/karaf-boot/src/main/java/org/apache/karaf/boot/Arg.java
deleted file mode 100644
index 89e7d0f..0000000
--- a/karaf-boot/src/main/java/org/apache/karaf/boot/Arg.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
- * 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.karaf.boot;
-
-
-/**
- * used to describe argument of the bean constructor
- * or the argument of the factory method for the bean
- *
- * this is mapped to Targument for the Tbean
- *
- */
-public @interface Arg {
-
- /**
- * the value of the argument
- */
- String value() default "";
-
- /**
- * the value of the ref attribute of the argument
- */
- String ref() default "";
-
- /**
- * the description of the argument
- */
- String description() default "";
-
- /**
- * the zero-based index into the parameter list of the factory method
- * or constructor to be invoked for this argument. This is determined by
- * specifying the <code>index</code> attribute for the bean. If not
- * explicitly set, this will return -1 and the initial ordering is defined
- * by its position in the args[] list.
- */
- int index() default -1;
-
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot/src/main/java/org/apache/karaf/boot/Bean.java
----------------------------------------------------------------------
diff --git a/karaf-boot/src/main/java/org/apache/karaf/boot/Bean.java b/karaf-boot/src/main/java/org/apache/karaf/boot/Bean.java
deleted file mode 100644
index 0a6ebbf..0000000
--- a/karaf-boot/src/main/java/org/apache/karaf/boot/Bean.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/**
- * 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.karaf.boot;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/*
- * To annotate a bean as a blueprint bean, use @Bean
- */
-@Target(ElementType.TYPE)
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Bean {
-
- /**
- * id, activation, dependsOn comes from Tcomponent
- * the id property for the bean
- * should this be auto generated if none is specified?
- */
- String id();
-
- /**
- * the activation property for the bean
- * This can either be "eager" or "lazy". If not specified, it
- * defaults to default-activation attribute of the enclosing
- * <blueprint> element.
- */
- String activation() default "";
-
- /**
- * the components that the bean depends on
- */
- String[] dependsOn() default "";
-
- /**
- * the description property for the bean
- */
- String description() default "";
-
- /**
- * the scope property for the bean. value can be prototype or singleton
- */
- String scope() default "";
-
- /**
- * the reference to the factory component on which to invoke the
- * factory method for the bean.
- */
- String factoryRef() default "";
-
- /**
- * the factory method in the factoryRef referred factory component
- * @return
- */
- String factoryMethod() default "";
-
- /**
- * arguments for the bean constructor or the factory method of the bean
- * @return
- */
- Arg[] args() default {};
-
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot/src/main/java/org/apache/karaf/boot/Bind.java
----------------------------------------------------------------------
diff --git a/karaf-boot/src/main/java/org/apache/karaf/boot/Bind.java b/karaf-boot/src/main/java/org/apache/karaf/boot/Bind.java
deleted file mode 100644
index f7a3938..0000000
--- a/karaf-boot/src/main/java/org/apache/karaf/boot/Bind.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * 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.karaf.boot;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * used to annotation bind-method in blueprint reference listeners
- *
- */
-@Target(ElementType.METHOD)
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Bind {
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot/src/main/java/org/apache/karaf/boot/Destroy.java
----------------------------------------------------------------------
diff --git a/karaf-boot/src/main/java/org/apache/karaf/boot/Destroy.java b/karaf-boot/src/main/java/org/apache/karaf/boot/Destroy.java
deleted file mode 100644
index a8e1258..0000000
--- a/karaf-boot/src/main/java/org/apache/karaf/boot/Destroy.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * 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.karaf.boot;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * used to annotation destroy-method in blueprint beans
- *
- */
-@Target(ElementType.METHOD)
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Destroy {
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot/src/main/java/org/apache/karaf/boot/Element.java
----------------------------------------------------------------------
diff --git a/karaf-boot/src/main/java/org/apache/karaf/boot/Element.java b/karaf-boot/src/main/java/org/apache/karaf/boot/Element.java
deleted file mode 100644
index 3259c80..0000000
--- a/karaf-boot/src/main/java/org/apache/karaf/boot/Element.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * 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.karaf.boot;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * used to annotate the element of the list.
- *
- */
-@Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Element {
- ElementType type() default ElementType.STRING;
- String value() default "";
-
- public enum ElementType {
- STRING,
- LONG,
- BYTE,
- BOOLEAN,
- INT,
- SHORT
- }
-
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/87577122/karaf-boot/src/main/java/org/apache/karaf/boot/Init.java
----------------------------------------------------------------------
diff --git a/karaf-boot/src/main/java/org/apache/karaf/boot/Init.java b/karaf-boot/src/main/java/org/apache/karaf/boot/Init.java
deleted file mode 100644
index 437ca8c..0000000
--- a/karaf-boot/src/main/java/org/apache/karaf/boot/Init.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * 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.karaf.boot;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * used to annotation init-method in blueprint beans
- *
- */
-@Target(ElementType.METHOD)
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Init {
-}
[22/35] karaf-boot git commit: [blueprint] Add blueprint annotation
support
Posted by cs...@apache.org.
[blueprint] Add blueprint annotation support
Project: http://git-wip-us.apache.org/repos/asf/karaf-boot/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-boot/commit/18a2cfab
Tree: http://git-wip-us.apache.org/repos/asf/karaf-boot/tree/18a2cfab
Diff: http://git-wip-us.apache.org/repos/asf/karaf-boot/diff/18a2cfab
Branch: refs/heads/master
Commit: 18a2cfab13be3acfbf72ce6fe014831d20173490
Parents: 52bc684
Author: Guillaume Nodet <gn...@apache.org>
Authored: Fri Apr 15 20:48:32 2016 +0200
Committer: Guillaume Nodet <gn...@apache.org>
Committed: Fri Apr 15 20:48:32 2016 +0200
----------------------------------------------------------------------
.../README.md | 21 ++++++
.../pom.xml | 49 +++++++++++++
.../service/provider/HelloService.java | 25 +++++++
.../service/provider/HelloServiceImpl.java | 35 +++++++++
.../karaf-boot-starter-blueprint/pom.xml | 57 +++++++++++++++
.../boot/blueprint/impl/BlueprintProcessor.java | 76 ++++++++++++++++++++
.../javax.annotation.processing.Processor | 1 +
karaf-boot-starters/pom.xml | 1 +
pom.xml | 2 +
9 files changed, 267 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/18a2cfab/karaf-boot-samples/karaf-boot-sample-service-blueprint-annotation/README.md
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-service-blueprint-annotation/README.md b/karaf-boot-samples/karaf-boot-sample-service-blueprint-annotation/README.md
new file mode 100644
index 0000000..02f255e
--- /dev/null
+++ b/karaf-boot-samples/karaf-boot-sample-service-blueprint-annotation/README.md
@@ -0,0 +1,21 @@
+== karaf-boot-sample-service-blueprint-annotation ==
+
+This sample exposes an OSGi service using blueprint annotations.
+
+= Design
+
+TODO
+
+= Build
+
+To build, simply do:
+
+ mvn clean install
+
+= Deploy
+
+* you can drop the generated jar file (target/karaf-boot-sample-service-blueprint-annotation-1.0.jar) in the
+Karaf deploy folder
+* in the Karaf shell console, do:
+
+ bundle:install -s mvn:org.apache.karaf.boot/karaf-boot-sample-service-blueprint-annotation/1.0
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/18a2cfab/karaf-boot-samples/karaf-boot-sample-service-blueprint-annotation/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-service-blueprint-annotation/pom.xml b/karaf-boot-samples/karaf-boot-sample-service-blueprint-annotation/pom.xml
new file mode 100644
index 0000000..cc629dc
--- /dev/null
+++ b/karaf-boot-samples/karaf-boot-sample-service-blueprint-annotation/pom.xml
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+
+ <!--
+
+ 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.
+-->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-sample-service-blueprint-annotation</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-starter-blueprint</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-maven-plugin</artifactId>
+ <version>${project.version}</version>
+ <extensions>true</extensions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/18a2cfab/karaf-boot-samples/karaf-boot-sample-service-blueprint-annotation/src/main/java/sample/blueprint/service/provider/HelloService.java
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-service-blueprint-annotation/src/main/java/sample/blueprint/service/provider/HelloService.java b/karaf-boot-samples/karaf-boot-sample-service-blueprint-annotation/src/main/java/sample/blueprint/service/provider/HelloService.java
new file mode 100644
index 0000000..2555069
--- /dev/null
+++ b/karaf-boot-samples/karaf-boot-sample-service-blueprint-annotation/src/main/java/sample/blueprint/service/provider/HelloService.java
@@ -0,0 +1,25 @@
+/**
+ * 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 sample.blueprint.service.provider;
+
+public interface HelloService {
+
+ public String hello(String message);
+
+ public void startUp();
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/18a2cfab/karaf-boot-samples/karaf-boot-sample-service-blueprint-annotation/src/main/java/sample/blueprint/service/provider/HelloServiceImpl.java
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-service-blueprint-annotation/src/main/java/sample/blueprint/service/provider/HelloServiceImpl.java b/karaf-boot-samples/karaf-boot-sample-service-blueprint-annotation/src/main/java/sample/blueprint/service/provider/HelloServiceImpl.java
new file mode 100644
index 0000000..f46b5da
--- /dev/null
+++ b/karaf-boot-samples/karaf-boot-sample-service-blueprint-annotation/src/main/java/sample/blueprint/service/provider/HelloServiceImpl.java
@@ -0,0 +1,35 @@
+/**
+ * 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 sample.blueprint.service.provider;
+
+import org.apache.aries.blueprint.annotation.Bean;
+import org.apache.aries.blueprint.annotation.Service;
+
+@Bean(id = "HelloServiceImpl")
+@Service(autoExport = "interfaces")
+public class HelloServiceImpl implements HelloService{
+
+ public String hello(String message) {
+ return "Hello " + message + " !";
+ }
+
+ public void startUp() {
+ System.out.println("I'm starting up!");
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/18a2cfab/karaf-boot-starters/karaf-boot-starter-blueprint/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-starters/karaf-boot-starter-blueprint/pom.xml b/karaf-boot-starters/karaf-boot-starter-blueprint/pom.xml
new file mode 100644
index 0000000..9f48c60
--- /dev/null
+++ b/karaf-boot-starters/karaf-boot-starter-blueprint/pom.xml
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+
+ <!--
+
+ 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.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-starters</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>karaf-boot-starter-blueprint</artifactId>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.aries.blueprint</groupId>
+ <artifactId>org.apache.aries.blueprint.api</artifactId>
+ <version>1.0.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.aries.blueprint</groupId>
+ <artifactId>org.apache.aries.blueprint.annotation.api</artifactId>
+ <version>1.0.0</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <compilerArgument>-proc:none</compilerArgument>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/18a2cfab/karaf-boot-starters/karaf-boot-starter-blueprint/src/main/java/org/apache/karaf/boot/blueprint/impl/BlueprintProcessor.java
----------------------------------------------------------------------
diff --git a/karaf-boot-starters/karaf-boot-starter-blueprint/src/main/java/org/apache/karaf/boot/blueprint/impl/BlueprintProcessor.java b/karaf-boot-starters/karaf-boot-starter-blueprint/src/main/java/org/apache/karaf/boot/blueprint/impl/BlueprintProcessor.java
new file mode 100644
index 0000000..896a161
--- /dev/null
+++ b/karaf-boot-starters/karaf-boot-starter-blueprint/src/main/java/org/apache/karaf/boot/blueprint/impl/BlueprintProcessor.java
@@ -0,0 +1,76 @@
+package org.apache.karaf.boot.blueprint.impl;
+
+import javax.annotation.processing.AbstractProcessor;
+import javax.annotation.processing.RoundEnvironment;
+import javax.lang.model.element.TypeElement;
+import javax.tools.Diagnostic.Kind;
+import javax.tools.FileObject;
+import javax.tools.StandardLocation;
+import java.io.ByteArrayOutputStream;
+import java.io.CharArrayWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PrintWriter;
+import java.io.Reader;
+import java.io.Writer;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.aries.blueprint.annotation.Bean;
+
+public class BlueprintProcessor extends AbstractProcessor {
+
+ boolean hasRun;
+
+ public BlueprintProcessor() {
+ }
+
+ @Override
+ public Set<String> getSupportedAnnotationTypes() {
+ Set<String> set = new HashSet<String>();
+ set.add(Bean.class.getName());
+ return set;
+ }
+
+ @Override
+ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+ if (!hasRun) {
+ hasRun = true;
+ // Add the blueprint requirement
+ try (PrintWriter w = appendResource("META-INF/org.apache.karaf.boot.bnd")) {
+ w.println("Bundle-Blueprint-Annotation: true");
+ } catch (Exception e) {
+ processingEnv.getMessager().printMessage(Kind.ERROR, "Error: " + e.getMessage());
+ }
+ }
+ return true;
+ }
+
+ private PrintWriter appendResource(String resource) throws IOException {
+ try {
+ FileObject o = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", resource);
+ return new PrintWriter(o.openWriter());
+ } catch (Exception e) {
+ try {
+ FileObject o = processingEnv.getFiler().getResource(StandardLocation.CLASS_OUTPUT, "", resource);
+ CharArrayWriter baos = new CharArrayWriter();
+ try (Reader r = o.openReader(true)) {
+ char[] buf = new char[4096];
+ int l;
+ while ((l = r.read(buf)) > 0) {
+ baos.write(buf, 0, l);
+ }
+ }
+ o.delete();
+ o = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", resource);
+ Writer w = o.openWriter();
+ w.write(baos.toCharArray());
+ return new PrintWriter(w);
+ } catch (Exception e2) {
+ e2.addSuppressed(e);
+ e2.printStackTrace();
+ throw e2;
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/18a2cfab/karaf-boot-starters/karaf-boot-starter-blueprint/src/main/resources/META-INF/services/javax.annotation.processing.Processor
----------------------------------------------------------------------
diff --git a/karaf-boot-starters/karaf-boot-starter-blueprint/src/main/resources/META-INF/services/javax.annotation.processing.Processor b/karaf-boot-starters/karaf-boot-starter-blueprint/src/main/resources/META-INF/services/javax.annotation.processing.Processor
new file mode 100644
index 0000000..fab44d1
--- /dev/null
+++ b/karaf-boot-starters/karaf-boot-starter-blueprint/src/main/resources/META-INF/services/javax.annotation.processing.Processor
@@ -0,0 +1 @@
+org.apache.karaf.boot.blueprint.impl.BlueprintProcessor
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/18a2cfab/karaf-boot-starters/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-starters/pom.xml b/karaf-boot-starters/pom.xml
index 127874e..57dbd39 100644
--- a/karaf-boot-starters/pom.xml
+++ b/karaf-boot-starters/pom.xml
@@ -39,6 +39,7 @@
<module>karaf-boot-starter-web</module>
<module>karaf-boot-starter-jpa</module>
<module>karaf-boot-starter-cdi</module>
+ <module>karaf-boot-starter-blueprint</module>
</modules>
</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/18a2cfab/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index ca1f26e..eea3146 100644
--- a/pom.xml
+++ b/pom.xml
@@ -74,6 +74,8 @@
<!-- blueprint -->
<module>karaf-boot-samples/karaf-boot-sample-service-provider-blueprint</module>
<module>karaf-boot-samples/karaf-boot-sample-service-consumer-blueprint</module>
+ <!-- blueprint annotations -->
+ <module>karaf-boot-samples/karaf-boot-sample-service-blueprint-annotation</module>
<!-- cdi -->
<module>karaf-boot-samples/karaf-boot-sample-cdi</module>
<!-- shell -->
[32/35] karaf-boot git commit: Add META-INF to Private-Packages to
add the persistence.xml
Posted by cs...@apache.org.
Add META-INF to Private-Packages to add the persistence.xml
Project: http://git-wip-us.apache.org/repos/asf/karaf-boot/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-boot/commit/4860b601
Tree: http://git-wip-us.apache.org/repos/asf/karaf-boot/tree/4860b601
Diff: http://git-wip-us.apache.org/repos/asf/karaf-boot/diff/4860b601
Branch: refs/heads/master
Commit: 4860b601478eed6a0dac8d4058ce37d329f7e1c4
Parents: a55895f
Author: Christian Schneider <ch...@die-schneider.net>
Authored: Tue Apr 26 14:14:07 2016 +0200
Committer: Christian Schneider <ch...@die-schneider.net>
Committed: Tue Apr 26 14:14:07 2016 +0200
----------------------------------------------------------------------
samples/jpa/pom.xml | 2 +-
.../karaf/boot/jpa/impl/JpaProcessor.java | 39 +++++++++++++++++++-
2 files changed, 39 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/4860b601/samples/jpa/pom.xml
----------------------------------------------------------------------
diff --git a/samples/jpa/pom.xml b/samples/jpa/pom.xml
index 1c51404..f745ab2 100644
--- a/samples/jpa/pom.xml
+++ b/samples/jpa/pom.xml
@@ -26,7 +26,7 @@
<version>${project.version}</version>
</dependency>
</dependencies>
-
+
<build>
<plugins>
<plugin>
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/4860b601/starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/impl/JpaProcessor.java
----------------------------------------------------------------------
diff --git a/starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/impl/JpaProcessor.java b/starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/impl/JpaProcessor.java
index f257238..f160fec 100644
--- a/starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/impl/JpaProcessor.java
+++ b/starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/impl/JpaProcessor.java
@@ -1,6 +1,9 @@
package org.apache.karaf.boot.jpa.impl;
+import java.io.CharArrayWriter;
import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.Reader;
import java.io.Writer;
import java.util.Arrays;
import java.util.HashMap;
@@ -48,13 +51,18 @@ public class JpaProcessor extends AbstractProcessor {
}
if (!units.isEmpty()) {
try {
- FileObject o = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT,
+ FileObject o = processingEnv.getFiler().createResource(StandardLocation.SOURCE_OUTPUT,
"", "META-INF/persistence.xml");
process(o.openWriter(), units);
processingEnv.getMessager().printMessage(Kind.NOTE, "Generated META-INF/persistence.xml");
} catch (Exception e) {
processingEnv.getMessager().printMessage(Kind.ERROR, "Error: " + e.getMessage());
}
+ try (PrintWriter w = appendResource("META-INF/org.apache.karaf.boot.bnd")) {
+ w.println("Private-Package: META-INF");
+ } catch (Exception e) {
+ processingEnv.getMessager().printMessage(Kind.ERROR, "Error writing to META-INF/org.apache.karaf.boot.bnd: " + e.getMessage());
+ }
}
return true;
}
@@ -168,4 +176,33 @@ public class JpaProcessor extends AbstractProcessor {
}
}
+ private PrintWriter appendResource(String resource) throws IOException {
+ try {
+ FileObject o = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "",
+ resource);
+ return new PrintWriter(o.openWriter());
+ } catch (Exception e) {
+ try {
+ FileObject o = processingEnv.getFiler().getResource(StandardLocation.CLASS_OUTPUT, "",
+ resource);
+ CharArrayWriter baos = new CharArrayWriter();
+ try (Reader r = o.openReader(true)) {
+ char[] buf = new char[4096];
+ int l;
+ while ((l = r.read(buf)) > 0) {
+ baos.write(buf, 0, l);
+ }
+ }
+ o.delete();
+ o = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", resource);
+ Writer w = o.openWriter();
+ w.write(baos.toCharArray());
+ return new PrintWriter(w);
+ } catch (Exception e2) {
+ e2.addSuppressed(e);
+ e2.printStackTrace();
+ throw e2;
+ }
+ }
+ }
}
[18/35] karaf-boot git commit: [plugin] provide a simple way for
starters to contribute BND instructions
Posted by cs...@apache.org.
[plugin] provide a simple way for starters to contribute BND instructions
Project: http://git-wip-us.apache.org/repos/asf/karaf-boot/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-boot/commit/93af001d
Tree: http://git-wip-us.apache.org/repos/asf/karaf-boot/tree/93af001d
Diff: http://git-wip-us.apache.org/repos/asf/karaf-boot/diff/93af001d
Branch: refs/heads/master
Commit: 93af001ded3573c0eed9def320ba75427d5fe28a
Parents: 7f6469e
Author: Guillaume Nodet <gn...@apache.org>
Authored: Fri Apr 15 16:39:05 2016 +0200
Committer: Guillaume Nodet <gn...@apache.org>
Committed: Fri Apr 15 16:39:05 2016 +0200
----------------------------------------------------------------------
.../apache/karaf/boot/maven/GenerateMojo.java | 76 +++++++++++++++++---
1 file changed, 68 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/93af001d/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/maven/GenerateMojo.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/maven/GenerateMojo.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/maven/GenerateMojo.java
index f15dad3..d7fcdcb 100644
--- a/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/maven/GenerateMojo.java
+++ b/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/maven/GenerateMojo.java
@@ -14,6 +14,12 @@ import org.codehaus.plexus.util.xml.Xpp3Dom;
import org.codehaus.plexus.util.xml.Xpp3DomBuilder;
import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.StringReader;
+import java.nio.file.Files;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
@Mojo(name = "generate", threadSafe = true, defaultPhase = LifecyclePhase.PROCESS_CLASSES, requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME, inheritByDefault = false)
public class GenerateMojo extends AbstractMojo {
@@ -58,9 +64,59 @@ public class GenerateMojo extends AbstractMojo {
felixBundlePlugin.setVersion("3.0.0");
felixBundlePlugin.setInherited(true);
felixBundlePlugin.setExtensions(true);
- // TODO check if a osgi.bnd file is present in the project base directory
- // TODO if jpa-start is provided as persistence.xml location
- configuration = Xpp3DomBuilder.build(new ByteArrayInputStream(("<configuration>" +
+
+
+ //
+ // Bundle plugin
+ //
+
+ Map<String, String> instructions = new LinkedHashMap<>();
+ instructions.put("Private-Package", "org.apache.karaf.util.tracker");
+ instructions.put("_dsannotations", "*");
+
+ //
+ // Starters supplied instructions
+ //
+ File bndInst = new File(mavenProject.getBasedir(), "target/classes/META-INF/org.apache.karaf.boot.bnd");
+ if (bndInst.isFile()) {
+ List<String> lines = Files.readAllLines(bndInst.toPath());
+ for (String line : lines) {
+ if (!line.contains(":")) {
+ continue;
+ }
+ String name = line.substring(0, line.indexOf(':')).trim();
+ String value = line.substring(line.indexOf(':') + 1).trim();
+ if (instructions.containsKey(name)) {
+ instructions.put(name, instructions.get(name) + "," + value);
+ } else {
+ instructions.put(name, value);
+ }
+ }
+ bndInst.delete();
+ }
+
+ //
+ // User supplied instructions
+ //
+ bndInst = new File(mavenProject.getBasedir(), "osgi.bnd");
+ if (bndInst.isFile()) {
+ List<String> lines = Files.readAllLines(bndInst.toPath());
+ for (String line : lines) {
+ if (!line.contains(":")) {
+ continue;
+ }
+ String name = line.substring(0, line.indexOf(':')).trim();
+ String value = line.substring(line.indexOf(':') + 1).trim();
+ if (instructions.containsKey(name)) {
+ instructions.put(name, instructions.get(name) + "," + value);
+ } else {
+ instructions.put(name, value);
+ }
+ }
+ }
+
+ StringBuilder config = new StringBuilder();
+ config.append("<configuration>" +
"<finalName>${project.build.finalName}</finalName>" +
"<outputDirectory>${project.build.outputDirectory}</outputDirectory>" +
"<m_mavenSession>${session}</m_mavenSession>" +
@@ -71,11 +127,15 @@ public class GenerateMojo extends AbstractMojo {
"<supportedProjectType>bundle</supportedProjectType>" +
"<supportedProjectType>war</supportedProjectType>" +
"</supportedProjectTypes>" +
- "<instructions>" +
- "<Private-Package>org.apache.karaf.util.tracker</Private-Package>" +
- "<_dsannotations>*</_dsannotations>" +
- "</instructions>" +
- "</configuration>").getBytes()), "UTF-8");
+ "<instructions>");
+ for (Map.Entry<String, String> entry : instructions.entrySet()) {
+ config.append("<").append(entry.getKey()).append(">")
+ .append(entry.getValue())
+ .append("</").append(entry.getKey()).append(">");
+ }
+ config.append("</instructions>" +
+ "</configuration>");
+ configuration = Xpp3DomBuilder.build(new StringReader(config.toString()));
PluginDescriptor felixBundlePluginDescriptor = pluginManager.loadPlugin(felixBundlePlugin, mavenProject.getRemotePluginRepositories(), mavenSession.getRepositorySession());
MojoDescriptor felixBundleMojoDescriptor = felixBundlePluginDescriptor.getMojo("bundle");
execution = new MojoExecution(felixBundleMojoDescriptor, configuration);
[29/35] karaf-boot git commit: Add bnd.bnd by default if present
Posted by cs...@apache.org.
Add bnd.bnd by default if present
Project: http://git-wip-us.apache.org/repos/asf/karaf-boot/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-boot/commit/5e0846ff
Tree: http://git-wip-us.apache.org/repos/asf/karaf-boot/tree/5e0846ff
Diff: http://git-wip-us.apache.org/repos/asf/karaf-boot/diff/5e0846ff
Branch: refs/heads/master
Commit: 5e0846ffced2d78a73f2c5339799a682fac368b6
Parents: c615578
Author: Christian Schneider <ch...@die-schneider.net>
Authored: Mon Apr 25 14:27:02 2016 +0200
Committer: Christian Schneider <ch...@die-schneider.net>
Committed: Mon Apr 25 14:27:02 2016 +0200
----------------------------------------------------------------------
.../main/java/org/apache/karaf/boot/maven/GenerateMojo.java | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/5e0846ff/tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/maven/GenerateMojo.java
----------------------------------------------------------------------
diff --git a/tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/maven/GenerateMojo.java b/tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/maven/GenerateMojo.java
index dd88688..ee97d14 100644
--- a/tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/maven/GenerateMojo.java
+++ b/tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/maven/GenerateMojo.java
@@ -13,7 +13,6 @@ import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.util.xml.Xpp3Dom;
import org.codehaus.plexus.util.xml.Xpp3DomBuilder;
-import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.io.StringReader;
@@ -47,11 +46,6 @@ public class GenerateMojo extends AbstractMojo {
complete(instructions, bndInst);
bndInst.delete();
}
- // User supplied instructions
- bndInst = new File(mavenProject.getBasedir(), "osgi.bnd");
- if (bndInst.isFile()) {
- complete(instructions, bndInst);
- }
// Verify and use defaults
if (instructions.containsKey("Import-Package")) {
instructions.put("Import-Package", instructions.get("Import-Package") + ",*");
@@ -69,7 +63,8 @@ public class GenerateMojo extends AbstractMojo {
"<supportedProjectType>bundle</supportedProjectType>" +
"<supportedProjectType>war</supportedProjectType>" +
"</supportedProjectTypes>" +
- "<instructions>");
+ "<instructions>" +
+ "<_include>-bnd.bnd</_include>"); // include user bnd file if present
for (Map.Entry<String, String> entry : instructions.entrySet()) {
config.append("<").append(entry.getKey()).append(">")
.append(entry.getValue())
[26/35] karaf-boot git commit: Renaming dirs,
use blueprint-maven-plugin
Posted by cs...@apache.org.
Renaming dirs, use blueprint-maven-plugin
Project: http://git-wip-us.apache.org/repos/asf/karaf-boot/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-boot/commit/137222a0
Tree: http://git-wip-us.apache.org/repos/asf/karaf-boot/tree/137222a0
Diff: http://git-wip-us.apache.org/repos/asf/karaf-boot/diff/137222a0
Branch: refs/heads/master
Commit: 137222a0705d9aeaaffd87773039ba757aadd87d
Parents: 18a2cfa
Author: Christian Schneider <ch...@die-schneider.net>
Authored: Mon Apr 25 12:00:23 2016 +0200
Committer: Christian Schneider <ch...@die-schneider.net>
Committed: Mon Apr 25 12:00:23 2016 +0200
----------------------------------------------------------------------
karaf-boot-samples/README.md | 27 ----
.../karaf-boot-sample-cdi/README.md | 23 ---
.../karaf-boot-sample-cdi/pom.xml | 47 ------
.../main/java/sample/cdi/IceCreamService.java | 6 -
.../java/sample/cdi/impl/VanillaService.java | 45 ------
.../karaf-boot-sample-config/README.md | 31 ----
.../karaf-boot-sample-config/pom.xml | 47 ------
.../java/sample/config/ConfigComponent.java | 43 ------
.../karaf-boot-sample-jpa/README.md | 23 ---
.../karaf-boot-sample-jpa/pom.xml | 47 ------
.../src/main/java/sample/jpa/Task.java | 66 --------
.../README.md | 21 ---
.../pom.xml | 49 ------
.../service/provider/HelloService.java | 25 ---
.../service/provider/HelloServiceImpl.java | 35 -----
.../pom.xml | 51 ------
.../blueprint/service/consumer/HelloClient.java | 38 -----
.../resources/OSGI-INF/blueprint/config.xml | 26 ----
.../README.md | 36 -----
.../pom.xml | 52 -------
.../ds/service/consumer/HelloServiceClient.java | 59 -------
.../README.md | 30 ----
.../pom.xml | 52 -------
.../sample/osgi/service/consumer/Activator.java | 48 ------
.../README.md | 26 ----
.../pom.xml | 49 ------
.../service/provider/HelloService.java | 25 ---
.../service/provider/HelloServiceImpl.java | 30 ----
.../resources/OSGI-INF/blueprint/config.xml | 26 ----
.../README.md | 35 -----
.../pom.xml | 47 ------
.../ds/service/provider/HelloService.java | 26 ----
.../ds/service/provider/HelloServiceImpl.java | 31 ----
.../README.md | 33 ----
.../pom.xml | 47 ------
.../sample/osgi/service/provider/Activator.java | 41 -----
.../osgi/service/provider/HelloService.java | 26 ----
.../osgi/service/provider/HelloServiceImpl.java | 28 ----
.../karaf-boot-sample-servlet/README.md | 30 ----
.../karaf-boot-sample-servlet/pom.xml | 47 ------
.../main/java/sample/servlet/SampleServlet.java | 44 ------
.../karaf-boot-sample-shell/README.md | 38 -----
.../karaf-boot-sample-shell/pom.xml | 53 -------
.../main/java/sample/shell/HelloCommand.java | 47 ------
.../karaf-boot-starter-blueprint/pom.xml | 57 -------
.../boot/blueprint/impl/BlueprintProcessor.java | 76 ---------
.../javax.annotation.processing.Processor | 1 -
.../karaf-boot-starter-cdi/pom.xml | 67 --------
.../karaf/boot/cdi/impl/CdiProcessor.java | 82 ----------
.../javax.annotation.processing.Processor | 1 -
.../karaf-boot-starter-ds/pom.xml | 52 -------
.../apache/karaf/boot/ds/impl/DsProcessor.java | 72 ---------
.../javax.annotation.processing.Processor | 1 -
.../karaf-boot-starter-jpa/pom.xml | 57 -------
.../org/apache/karaf/boot/jpa/EclipseLink.java | 4 -
.../org/apache/karaf/boot/jpa/Hibernate.java | 91 -----------
.../java/org/apache/karaf/boot/jpa/OpenJpa.java | 38 -----
.../apache/karaf/boot/jpa/PersistentUnit.java | 36 -----
.../org/apache/karaf/boot/jpa/Property.java | 13 --
.../org/apache/karaf/boot/jpa/Provider.java | 10 --
.../apache/karaf/boot/jpa/TransactionType.java | 6 -
.../karaf/boot/jpa/impl/JpaProcessor.java | 140 -----------------
.../javax.annotation.processing.Processor | 1 -
.../karaf-boot-starter-karaf/pom.xml | 57 -------
.../karaf/boot/karaf/impl/KarafProcessor.java | 154 -------------------
.../javax.annotation.processing.Processor | 1 -
.../karaf-boot-starter-shell/pom.xml | 52 -------
.../karaf/boot/shell/impl/ShellProcessor.java | 84 ----------
.../javax.annotation.processing.Processor | 1 -
.../karaf-boot-starter-web/pom.xml | 41 -----
karaf-boot-starters/karaf-boot-starter/pom.xml | 41 -----
karaf-boot-starters/pom.xml | 45 ------
.../karaf-boot-maven-plugin/pom.xml | 85 ----------
.../apache/karaf/boot/maven/GenerateMojo.java | 124 ---------------
.../resources/META-INF/plexus/components.xml | 61 --------
karaf-boot-tools/pom.xml | 38 -----
pom.xml | 39 +----
samples/README.md | 27 ++++
samples/blueprint/pom.xml | 34 ++++
samples/blueprint/service-consumer/pom.xml | 90 +++++++++++
.../blueprint/service/consumer/HelloClient.java | 38 +++++
samples/blueprint/service-provider/README.md | 26 ++++
samples/blueprint/service-provider/pom.xml | 80 ++++++++++
.../service/provider/HelloService.java | 25 +++
.../service/provider/HelloServiceImpl.java | 38 +++++
samples/cdi/README.md | 23 +++
samples/cdi/pom.xml | 50 ++++++
.../main/java/sample/cdi/IceCreamService.java | 6 +
.../java/sample/cdi/impl/VanillaService.java | 45 ++++++
samples/ds/config/README.md | 31 ++++
samples/ds/config/pom.xml | 47 ++++++
.../java/sample/config/ConfigComponent.java | 43 ++++++
samples/ds/pom.xml | 36 +++++
samples/ds/service-consumer/README.md | 36 +++++
samples/ds/service-consumer/pom.xml | 52 +++++++
.../ds/service/consumer/HelloServiceClient.java | 59 +++++++
samples/ds/service-provider/README.md | 35 +++++
samples/ds/service-provider/pom.xml | 47 ++++++
.../ds/service/provider/HelloService.java | 26 ++++
.../ds/service/provider/HelloServiceImpl.java | 31 ++++
samples/ds/shell/README.md | 38 +++++
samples/ds/shell/pom.xml | 53 +++++++
.../main/java/sample/shell/HelloCommand.java | 47 ++++++
samples/jpa/README.md | 23 +++
samples/jpa/pom.xml | 47 ++++++
samples/jpa/src/main/java/sample/jpa/Task.java | 66 ++++++++
samples/pom.xml | 37 +++++
samples/servlet/README.md | 30 ++++
samples/servlet/pom.xml | 47 ++++++
.../main/java/sample/servlet/SampleServlet.java | 44 ++++++
starters/karaf-boot-starter-blueprint/pom.xml | 57 +++++++
.../boot/blueprint/impl/BlueprintProcessor.java | 76 +++++++++
.../javax.annotation.processing.Processor | 1 +
starters/karaf-boot-starter-cdi/pom.xml | 67 ++++++++
.../karaf/boot/cdi/impl/CdiProcessor.java | 82 ++++++++++
.../javax.annotation.processing.Processor | 1 +
starters/karaf-boot-starter-ds/pom.xml | 52 +++++++
.../apache/karaf/boot/ds/impl/DsProcessor.java | 72 +++++++++
.../javax.annotation.processing.Processor | 1 +
starters/karaf-boot-starter-jpa/pom.xml | 57 +++++++
.../org/apache/karaf/boot/jpa/EclipseLink.java | 4 +
.../org/apache/karaf/boot/jpa/Hibernate.java | 91 +++++++++++
.../java/org/apache/karaf/boot/jpa/OpenJpa.java | 38 +++++
.../apache/karaf/boot/jpa/PersistentUnit.java | 36 +++++
.../org/apache/karaf/boot/jpa/Property.java | 13 ++
.../org/apache/karaf/boot/jpa/Provider.java | 10 ++
.../apache/karaf/boot/jpa/TransactionType.java | 6 +
.../karaf/boot/jpa/impl/JpaProcessor.java | 140 +++++++++++++++++
.../javax.annotation.processing.Processor | 1 +
starters/karaf-boot-starter-karaf/pom.xml | 57 +++++++
.../karaf/boot/karaf/impl/KarafProcessor.java | 154 +++++++++++++++++++
.../javax.annotation.processing.Processor | 1 +
starters/karaf-boot-starter-shell/pom.xml | 52 +++++++
.../karaf/boot/shell/impl/ShellProcessor.java | 84 ++++++++++
.../javax.annotation.processing.Processor | 1 +
starters/karaf-boot-starter-web/pom.xml | 41 +++++
starters/karaf-boot-starter/pom.xml | 41 +++++
starters/pom.xml | 45 ++++++
tools/karaf-boot-maven-plugin/pom.xml | 85 ++++++++++
.../apache/karaf/boot/maven/GenerateMojo.java | 124 +++++++++++++++
.../resources/META-INF/plexus/components.xml | 61 ++++++++
tools/pom.xml | 38 +++++
142 files changed, 2950 insertions(+), 3280 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-samples/README.md
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/README.md b/karaf-boot-samples/README.md
deleted file mode 100644
index d65c349..0000000
--- a/karaf-boot-samples/README.md
+++ /dev/null
@@ -1,27 +0,0 @@
-* karaf-boot-sample-service-provider-osgi
- Expose a service using the "native" Karaf OSGi layer (low level)
-* karaf-boot-sample-service-consumer-osgi
- Use a service using the "native" Karaf OSGi layer (low level)
-
-* karaf-boot-services-osgi
- Simple services using OSGi
-* karaf-boot-services-blueprint
- Simple services using blueprint
-* karaf-boot-services-ds
- Simple services using DS/SCR
-* karaf-boot-services-cdi
- Simple services using CDI
-* karaf-boot-config-managed
- Managed by configuration (reload)
-* karaf-boot-servlet
- Servlet provider
-* karaf-boot-rest
- REST service provider
-* karaf-boot-soap
- SOAP service provider
-* karaf-boot-jpa
- JPA implementation
-* karaf-boot-profile
- Build a profile based on karaf-boot definition
-* karaf-boot-starter
- Package and configure Karaf as a ready to run artifact
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-samples/karaf-boot-sample-cdi/README.md
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-cdi/README.md b/karaf-boot-samples/karaf-boot-sample-cdi/README.md
deleted file mode 100644
index 1f98cac..0000000
--- a/karaf-boot-samples/karaf-boot-sample-cdi/README.md
+++ /dev/null
@@ -1,23 +0,0 @@
-== karaf-boot-sample-cdi ==
-
-This sample shows how to define a CDI bundle.
-
-= Design
-
-TODO.
-
-= Build
-
-To build, simply do:
-
- mvn clean install
-
-= Deploy
-
-To deploy i:
-
-* you can drop the generated jar file (target/karaf-boot-sample-cdi-1.0.jar) in the
-Karaf deploy folder
-* in the Karaf shell console, do:
-
- bundle:install -s mvn:org.apache.karaf.boot/karaf-boot-sample-cdi/1.0
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-samples/karaf-boot-sample-cdi/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-cdi/pom.xml b/karaf-boot-samples/karaf-boot-sample-cdi/pom.xml
deleted file mode 100644
index d627b6e..0000000
--- a/karaf-boot-samples/karaf-boot-sample-cdi/pom.xml
+++ /dev/null
@@ -1,47 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<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">
-
- <!--
-
- 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.
- -->
-
- <modelVersion>4.0.0</modelVersion>
-
- <groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-sample-cdi</artifactId>
- <version>1.0.0-SNAPSHOT</version>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-starter-cdi</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-maven-plugin</artifactId>
- <version>${project.version}</version>
- <extensions>true</extensions>
- </plugin>
- </plugins>
- </build>
-
-</project>
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-samples/karaf-boot-sample-cdi/src/main/java/sample/cdi/IceCreamService.java
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-cdi/src/main/java/sample/cdi/IceCreamService.java b/karaf-boot-samples/karaf-boot-sample-cdi/src/main/java/sample/cdi/IceCreamService.java
deleted file mode 100644
index 5f9cfac..0000000
--- a/karaf-boot-samples/karaf-boot-sample-cdi/src/main/java/sample/cdi/IceCreamService.java
+++ /dev/null
@@ -1,6 +0,0 @@
-package sample.cdi;
-
-public interface IceCreamService {
-
- String getFlavour();
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-samples/karaf-boot-sample-cdi/src/main/java/sample/cdi/impl/VanillaService.java
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-cdi/src/main/java/sample/cdi/impl/VanillaService.java b/karaf-boot-samples/karaf-boot-sample-cdi/src/main/java/sample/cdi/impl/VanillaService.java
deleted file mode 100644
index 3007035..0000000
--- a/karaf-boot-samples/karaf-boot-sample-cdi/src/main/java/sample/cdi/impl/VanillaService.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * 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 sample.cdi.impl;
-
-import javax.annotation.PostConstruct;
-import javax.enterprise.context.ApplicationScoped;
-
-import org.ops4j.pax.cdi.api.OsgiServiceProvider;
-import org.ops4j.pax.cdi.api.Properties;
-import org.ops4j.pax.cdi.api.Property;
-import sample.cdi.IceCreamService;
-
-@OsgiServiceProvider(classes = { VanillaService.class, IceCreamService.class })
-@Properties(@Property(name = "flavour", value = "vanilla"))
-@ApplicationScoped
-class VanillaService implements IceCreamService {
-
- private boolean initialized;
-
- @PostConstruct
- public void init() {
- initialized = true;
- }
-
- public String getFlavour() {
- if (!initialized) {
- throw new AssertionError("VanillaService is not initialized");
- }
- return "Vanilla";
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-samples/karaf-boot-sample-config/README.md
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-config/README.md b/karaf-boot-samples/karaf-boot-sample-config/README.md
deleted file mode 100644
index 1c8dbc5..0000000
--- a/karaf-boot-samples/karaf-boot-sample-config/README.md
+++ /dev/null
@@ -1,31 +0,0 @@
-== karaf-boot-sample-config ==
-
-This sample shows how to use a configuration provided in the etc folder of Karaf, and directly use the
-properties values in your code.
-
-= Design
-
-The ConfigComponent use a SampleConfig configuration. The SampleConfig configuration is "injected" at activation
-time of the component.
-
-The component just displays the values of the properties.
-
-= Build
-
-To build, simply do:
-
- mvn clean install
-
-= Deploy
-
-To deploy in Karaf, you have to enable the DS support first. For that, you have to install the scr feature:
-
- feature:install scr
-
-Once scr feature installed:
-
-* you can drop the generated jar file (target/karaf-boot-sample-config-1.0.jar) in the
-Karaf deploy folder
-* in the Karaf shell console, do:
-
- bundle:install -s mvn:org.apache.karaf.boot/karaf-boot-sample-config/1.0
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-samples/karaf-boot-sample-config/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-config/pom.xml b/karaf-boot-samples/karaf-boot-sample-config/pom.xml
deleted file mode 100644
index 688150b..0000000
--- a/karaf-boot-samples/karaf-boot-sample-config/pom.xml
+++ /dev/null
@@ -1,47 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<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">
-
- <!--
-
- 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.
- -->
-
- <modelVersion>4.0.0</modelVersion>
-
- <groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-sample-config</artifactId>
- <version>1.0.0-SNAPSHOT</version>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-starter-ds</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-maven-plugin</artifactId>
- <version>${project.version}</version>
- <extensions>true</extensions>
- </plugin>
- </plugins>
- </build>
-
-</project>
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-samples/karaf-boot-sample-config/src/main/java/sample/config/ConfigComponent.java
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-config/src/main/java/sample/config/ConfigComponent.java b/karaf-boot-samples/karaf-boot-sample-config/src/main/java/sample/config/ConfigComponent.java
deleted file mode 100644
index 52cf369..0000000
--- a/karaf-boot-samples/karaf-boot-sample-config/src/main/java/sample/config/ConfigComponent.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * 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 sample.config;
-
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.metatype.annotations.Designate;
-import org.osgi.service.metatype.annotations.ObjectClassDefinition;
-
-@ObjectClassDefinition(name = "Sample Configuration", pid = "org.apache.karaf.boot.sample.config")
-@interface SampleConfig {
- String stringProperty() default "default";
- int intProperty() default 0;
- boolean booleanProperty() default false;
-}
-
-@Component
-@Designate(ocd = SampleConfig.class)
-public class ConfigComponent {
-
- @Activate
- public void activate(SampleConfig sampleConfig) {
- System.out.println("We use the property there");
- System.out.println("stringProperty:" + sampleConfig.stringProperty());
- System.out.println("intProperty: " + sampleConfig.intProperty());
- System.out.println("booleanProperty: " + sampleConfig.booleanProperty());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-samples/karaf-boot-sample-jpa/README.md
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-jpa/README.md b/karaf-boot-samples/karaf-boot-sample-jpa/README.md
deleted file mode 100644
index 3a3f6a3..0000000
--- a/karaf-boot-samples/karaf-boot-sample-jpa/README.md
+++ /dev/null
@@ -1,23 +0,0 @@
-== karaf-boot-sample-jpa ==
-
-This sample shows how to define a JPA bundle and generate the persistent unit.
-
-= Design
-
-A Task entity is defined and annotated with the persistent unit annotations.
-
-= Build
-
-To build, simply do:
-
- mvn clean install
-
-= Deploy
-
-To deploy i:
-
-* you can drop the generated jar file (target/karaf-boot-sample-jpa-1.0.jar) in the
-Karaf deploy folder
-* in the Karaf shell console, do:
-
- bundle:install -s mvn:org.apache.karaf.boot/karaf-boot-sample-jpa/1.0
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-samples/karaf-boot-sample-jpa/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-jpa/pom.xml b/karaf-boot-samples/karaf-boot-sample-jpa/pom.xml
deleted file mode 100644
index 032396f..0000000
--- a/karaf-boot-samples/karaf-boot-sample-jpa/pom.xml
+++ /dev/null
@@ -1,47 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<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">
-
- <!--
-
- 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.
- -->
-
- <modelVersion>4.0.0</modelVersion>
-
- <groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-sample-jpa</artifactId>
- <version>1.0.0-SNAPSHOT</version>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-starter-jpa</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-maven-plugin</artifactId>
- <version>${project.version}</version>
- <extensions>true</extensions>
- </plugin>
- </plugins>
- </build>
-
-</project>
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-samples/karaf-boot-sample-jpa/src/main/java/sample/jpa/Task.java
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-jpa/src/main/java/sample/jpa/Task.java b/karaf-boot-samples/karaf-boot-sample-jpa/src/main/java/sample/jpa/Task.java
deleted file mode 100644
index cd431a7..0000000
--- a/karaf-boot-samples/karaf-boot-sample-jpa/src/main/java/sample/jpa/Task.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/**
- * 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 sample.jpa;
-
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.xml.bind.annotation.XmlRootElement;
-
-import org.apache.karaf.boot.jpa.Hibernate;
-import org.apache.karaf.boot.jpa.PersistentUnit;
-import org.apache.karaf.boot.jpa.Property;
-import org.apache.karaf.boot.jpa.Provider;
-
-@PersistentUnit(name = "tasklist", provider = Provider.Hibernate, properties = {
- @Property(name = "hibernate.hbm2ddl.auto", value = "create-drop")
-})
-@Hibernate.Dialect(Hibernate.Dialect.Value.HSQL)
-@Hibernate.Hbm2DdlAuto(Hibernate.Hbm2DdlAuto.Value.CreateDrop)
-@Entity
-@XmlRootElement
-public class Task {
- @Id
- Integer id;
- String title;
-
- public Task() {
- }
-
-
- public Task(Integer id, String title) {
- super();
- this.id = id;
- this.title = title;
- }
-
- public Integer getId() {
- return id;
- }
-
- public void setId(Integer id) {
- this.id = new Integer(id);
- }
-
- public String getTitle() {
- return title;
- }
-
- public void setTitle(String title) {
- this.title = title;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-samples/karaf-boot-sample-service-blueprint-annotation/README.md
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-service-blueprint-annotation/README.md b/karaf-boot-samples/karaf-boot-sample-service-blueprint-annotation/README.md
deleted file mode 100644
index 02f255e..0000000
--- a/karaf-boot-samples/karaf-boot-sample-service-blueprint-annotation/README.md
+++ /dev/null
@@ -1,21 +0,0 @@
-== karaf-boot-sample-service-blueprint-annotation ==
-
-This sample exposes an OSGi service using blueprint annotations.
-
-= Design
-
-TODO
-
-= Build
-
-To build, simply do:
-
- mvn clean install
-
-= Deploy
-
-* you can drop the generated jar file (target/karaf-boot-sample-service-blueprint-annotation-1.0.jar) in the
-Karaf deploy folder
-* in the Karaf shell console, do:
-
- bundle:install -s mvn:org.apache.karaf.boot/karaf-boot-sample-service-blueprint-annotation/1.0
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-samples/karaf-boot-sample-service-blueprint-annotation/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-service-blueprint-annotation/pom.xml b/karaf-boot-samples/karaf-boot-sample-service-blueprint-annotation/pom.xml
deleted file mode 100644
index cc629dc..0000000
--- a/karaf-boot-samples/karaf-boot-sample-service-blueprint-annotation/pom.xml
+++ /dev/null
@@ -1,49 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<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">
-
- <!--
-
- 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.
--->
-
- <modelVersion>4.0.0</modelVersion>
-
- <groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-sample-service-blueprint-annotation</artifactId>
- <version>1.0.0-SNAPSHOT</version>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-starter-blueprint</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-maven-plugin</artifactId>
- <version>${project.version}</version>
- <extensions>true</extensions>
- </plugin>
- </plugins>
- </build>
-
-</project>
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-samples/karaf-boot-sample-service-blueprint-annotation/src/main/java/sample/blueprint/service/provider/HelloService.java
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-service-blueprint-annotation/src/main/java/sample/blueprint/service/provider/HelloService.java b/karaf-boot-samples/karaf-boot-sample-service-blueprint-annotation/src/main/java/sample/blueprint/service/provider/HelloService.java
deleted file mode 100644
index 2555069..0000000
--- a/karaf-boot-samples/karaf-boot-sample-service-blueprint-annotation/src/main/java/sample/blueprint/service/provider/HelloService.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/**
- * 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 sample.blueprint.service.provider;
-
-public interface HelloService {
-
- public String hello(String message);
-
- public void startUp();
-
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-samples/karaf-boot-sample-service-blueprint-annotation/src/main/java/sample/blueprint/service/provider/HelloServiceImpl.java
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-service-blueprint-annotation/src/main/java/sample/blueprint/service/provider/HelloServiceImpl.java b/karaf-boot-samples/karaf-boot-sample-service-blueprint-annotation/src/main/java/sample/blueprint/service/provider/HelloServiceImpl.java
deleted file mode 100644
index f46b5da..0000000
--- a/karaf-boot-samples/karaf-boot-sample-service-blueprint-annotation/src/main/java/sample/blueprint/service/provider/HelloServiceImpl.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
- * 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 sample.blueprint.service.provider;
-
-import org.apache.aries.blueprint.annotation.Bean;
-import org.apache.aries.blueprint.annotation.Service;
-
-@Bean(id = "HelloServiceImpl")
-@Service(autoExport = "interfaces")
-public class HelloServiceImpl implements HelloService{
-
- public String hello(String message) {
- return "Hello " + message + " !";
- }
-
- public void startUp() {
- System.out.println("I'm starting up!");
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-samples/karaf-boot-sample-service-consumer-blueprint/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-service-consumer-blueprint/pom.xml b/karaf-boot-samples/karaf-boot-sample-service-consumer-blueprint/pom.xml
deleted file mode 100644
index eee6bb9..0000000
--- a/karaf-boot-samples/karaf-boot-sample-service-consumer-blueprint/pom.xml
+++ /dev/null
@@ -1,51 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<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">
-
- <!--
- 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.
--->
-
- <modelVersion>4.0.0</modelVersion>
-
- <groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-sample-service-consumer-blueprint</artifactId>
- <version>1.0.0-SNAPSHOT</version>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-starter</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-sample-service-provider-blueprint</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-maven-plugin</artifactId>
- <version>${project.version}</version>
- <extensions>true</extensions>
- </plugin>
- </plugins>
- </build>
-
-</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-samples/karaf-boot-sample-service-consumer-blueprint/src/main/java/sample/blueprint/service/consumer/HelloClient.java
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-service-consumer-blueprint/src/main/java/sample/blueprint/service/consumer/HelloClient.java b/karaf-boot-samples/karaf-boot-sample-service-consumer-blueprint/src/main/java/sample/blueprint/service/consumer/HelloClient.java
deleted file mode 100644
index 0459ab9..0000000
--- a/karaf-boot-samples/karaf-boot-sample-service-consumer-blueprint/src/main/java/sample/blueprint/service/consumer/HelloClient.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * 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 sample.blueprint.service.consumer;
-
-import sample.blueprint.service.provider.HelloService;
-
-public class HelloClient {
-
- HelloService helloService = null;
-
- public void startUp() {
- System.out.println(helloService.hello("World"));
- }
-
- public HelloService getHelloWorldService() {
- return helloService;
- }
-
- public void setHelloWorldService(HelloService helloWorldService) {
- this.helloService = helloWorldService;
-
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-samples/karaf-boot-sample-service-consumer-blueprint/src/main/resources/OSGI-INF/blueprint/config.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-service-consumer-blueprint/src/main/resources/OSGI-INF/blueprint/config.xml b/karaf-boot-samples/karaf-boot-sample-service-consumer-blueprint/src/main/resources/OSGI-INF/blueprint/config.xml
deleted file mode 100644
index ccd26d8..0000000
--- a/karaf-boot-samples/karaf-boot-sample-service-consumer-blueprint/src/main/resources/OSGI-INF/blueprint/config.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!--
- 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.
--->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
-
- <reference id="helloservice"
- interface="sample.blueprint.service.provider.HelloService" />
-
-
- <bean id="helloclient" class="sample.blueprint.service.consumer.HelloClient"
- init-method="startUp">
- <property name="helloWorldService" ref="helloservice" />
- </bean>
-</blueprint>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-samples/karaf-boot-sample-service-consumer-ds/README.md
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-service-consumer-ds/README.md b/karaf-boot-samples/karaf-boot-sample-service-consumer-ds/README.md
deleted file mode 100644
index ae04875..0000000
--- a/karaf-boot-samples/karaf-boot-sample-service-consumer-ds/README.md
+++ /dev/null
@@ -1,36 +0,0 @@
-== karaf-boot-sample-service-provider-osgi ==
-
-This sample exposes an OSGi service using the Karaf util classe and annotation.
-
-= Design
-
-This artifact uses the hello service provided by another artifact (karaf-boot-sample-service-provider-ds for instance).
-
-It uses the DS annotations to create a bean with a reference (@Reference) to the hello service.
-In the HelloServiceClient bean, we use the @Activate annotation to execute a specific method.
-
-You don't think anything else: karaf-boot will generate all the plumbing for you, and you will directly have a ready
-to use artifact.
-
-= Build
-
-To build, simply do:
-
- mvn clean install
-
-= Deploy
-
-To deploy in Karaf, you have to enable the DS support first. For that, you have to install the scr feature:
-
- feature:install scr
-
-Once scr feature installed, you have to install a hello service provider. Please use any of karaf-boot-sample-service-provider-*
-deployment first.
-
-Once the service provider is installed:
-
-* you can drop the generated jar file (target/karaf-boot-sample-service-consumer-ds-1.0.jar) in the
-Karaf deploy folder
-* in the Karaf shell console, do:
-
- bundle:install -s mvn:org.apache.karaf.boot/karaf-boot-sample-service-consumer-ds/1.0
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-samples/karaf-boot-sample-service-consumer-ds/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-service-consumer-ds/pom.xml b/karaf-boot-samples/karaf-boot-sample-service-consumer-ds/pom.xml
deleted file mode 100644
index c6b85c0..0000000
--- a/karaf-boot-samples/karaf-boot-sample-service-consumer-ds/pom.xml
+++ /dev/null
@@ -1,52 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<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">
-
- <!--
-
- 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.
- -->
-
- <modelVersion>4.0.0</modelVersion>
-
- <groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-sample-service-consumer-ds</artifactId>
- <version>1.0.0-SNAPSHOT</version>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-starter-ds</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-sample-service-provider-ds</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-maven-plugin</artifactId>
- <version>${project.version}</version>
- <extensions>true</extensions>
- </plugin>
- </plugins>
- </build>
-
-</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-samples/karaf-boot-sample-service-consumer-ds/src/main/java/sample/ds/service/consumer/HelloServiceClient.java
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-service-consumer-ds/src/main/java/sample/ds/service/consumer/HelloServiceClient.java b/karaf-boot-samples/karaf-boot-sample-service-consumer-ds/src/main/java/sample/ds/service/consumer/HelloServiceClient.java
deleted file mode 100644
index f70ebf7..0000000
--- a/karaf-boot-samples/karaf-boot-sample-service-consumer-ds/src/main/java/sample/ds/service/consumer/HelloServiceClient.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- * 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 sample.ds.service.consumer;
-
-import org.osgi.service.component.annotations.Activate;
-import org.osgi.service.component.annotations.Component;
-import org.osgi.service.component.annotations.Deactivate;
-import org.osgi.service.component.annotations.Reference;
-import sample.ds.service.provider.HelloService;
-
-@Component
-public class HelloServiceClient implements Runnable {
-
- private HelloService helloService;
-
- private Thread thread;
-
- @Activate
- public void start() {
- thread = new Thread(this);
- thread.start();
- }
-
- @Deactivate
- public void stop() {
- thread.interrupt();
- }
-
- public void run() {
- while (true) {
- System.out.println(helloService.hello("World"));
- try {
- Thread.sleep(5000);
- } catch (Exception e) {
- // nothing to do
- }
- }
- }
-
- @Reference
- public void setHelloService(HelloService helloService) {
- this.helloService = helloService;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-samples/karaf-boot-sample-service-consumer-osgi/README.md
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-service-consumer-osgi/README.md b/karaf-boot-samples/karaf-boot-sample-service-consumer-osgi/README.md
deleted file mode 100644
index 062348f..0000000
--- a/karaf-boot-samples/karaf-boot-sample-service-consumer-osgi/README.md
+++ /dev/null
@@ -1,30 +0,0 @@
-== karaf-boot-sample-service-consumer-osgi ==
-
-This sample uses an OSGi service using the Karaf util classe and annotation.
-
-= Design
-
-The service "contract" is exposed by another artifact (the karaf-boot-sample-service-provider-osgi module).
-
-The hello service is retrieved in the Activator of this artifact, and uses it directly.
-
-This Activator overrides the doStart() method, where we retrieve the HelloService using the getTrackedService() method. Karaf
-deals with all service lookup and tracking.
-
-= Build
-
-To build, simply do:
-
- mvn clean install
-
-= Deploy
-
-You have to install a hello service provider first. Please deploy the karaf-boot-sample-service-provider-osgi first.
-
-To deploy in Karaf:
-
-* you can drop the generated jar file (target/karaf-boot-sample-service-provider-osgi-1.0.jar) in the
-Karaf deploy folder
-* in the Karaf shell console, do:
-
- bundle:install -s mvn:org.apache.karaf.boot/karaf-boot-sample-service-consumer-osgi/1.0
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-samples/karaf-boot-sample-service-consumer-osgi/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-service-consumer-osgi/pom.xml b/karaf-boot-samples/karaf-boot-sample-service-consumer-osgi/pom.xml
deleted file mode 100644
index 2a18273..0000000
--- a/karaf-boot-samples/karaf-boot-sample-service-consumer-osgi/pom.xml
+++ /dev/null
@@ -1,52 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<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">
-
- <!--
-
- 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.
- -->
-
- <modelVersion>4.0.0</modelVersion>
-
- <groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-sample-service-consumer-osgi</artifactId>
- <version>1.0.0-SNAPSHOT</version>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-starter-karaf</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-sample-service-provider-osgi</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-maven-plugin</artifactId>
- <version>${project.version}</version>
- <extensions>true</extensions>
- </plugin>
- </plugins>
- </build>
-
-</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-samples/karaf-boot-sample-service-consumer-osgi/src/main/java/sample/osgi/service/consumer/Activator.java
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-service-consumer-osgi/src/main/java/sample/osgi/service/consumer/Activator.java b/karaf-boot-samples/karaf-boot-sample-service-consumer-osgi/src/main/java/sample/osgi/service/consumer/Activator.java
deleted file mode 100644
index fffd850..0000000
--- a/karaf-boot-samples/karaf-boot-sample-service-consumer-osgi/src/main/java/sample/osgi/service/consumer/Activator.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- * 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 sample.osgi.service.consumer;
-
-import org.apache.karaf.util.tracker.BaseActivator;
-import org.apache.karaf.util.tracker.annotation.RequireService;
-import org.apache.karaf.util.tracker.annotation.Services;
-import sample.osgi.service.provider.HelloService;
-
-/**
- * Simple activator that retrieve the hello service and use it.
- */
-@Services(
- requires = {
- @RequireService(HelloService.class)
- }
-)
-public class Activator extends BaseActivator {
-
- @Override
- public void doStart() throws Exception {
- HelloService helloService = getTrackedService(HelloService.class);
-
- // basic usage, in real life, it could be injected and used in a bean or whatever
- System.out.println("Hello " + helloService.hello("World"));
- }
-
- @Override
- public void doStop() {
- super.doStop();
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-samples/karaf-boot-sample-service-provider-blueprint/README.md
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-service-provider-blueprint/README.md b/karaf-boot-samples/karaf-boot-sample-service-provider-blueprint/README.md
deleted file mode 100644
index 07194df..0000000
--- a/karaf-boot-samples/karaf-boot-sample-service-provider-blueprint/README.md
+++ /dev/null
@@ -1,26 +0,0 @@
-== karaf-boot-sample-service-provider-blueprint ==
-
-This sample exposes an OSGi service using blueprint.
-
-= Design
-
-The service "contract" is describe by the Hello interface. It's a very simple service that expose one operation (hello).
-The service client send a message (String) to the hello service and he gets a response.
-
-The HelloServiceImpl is very simple: it prefixes the message with "Hello".
-
-We use a blueprint XML descriptor (for blueprint annotations, see the corresponding sample) in order to expose the service.
-
-= Build
-
-To build, simply do:
-
- mvn clean install
-
-= Deploy
-
-* you can drop the generated jar file (target/karaf-boot-sample-service-provider-blueprint-1.0.jar) in the
-Karaf deploy folder
-* in the Karaf shell console, do:
-
- bundle:install -s mvn:org.apache.karaf.boot/karaf-boot-sample-service-provider-blueprint/1.0
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-samples/karaf-boot-sample-service-provider-blueprint/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-service-provider-blueprint/pom.xml b/karaf-boot-samples/karaf-boot-sample-service-provider-blueprint/pom.xml
deleted file mode 100644
index a9bfaac..0000000
--- a/karaf-boot-samples/karaf-boot-sample-service-provider-blueprint/pom.xml
+++ /dev/null
@@ -1,49 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<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">
-
- <!--
-
- 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.
--->
-
- <modelVersion>4.0.0</modelVersion>
-
- <groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-sample-service-provider-blueprint</artifactId>
- <version>1.0.0-SNAPSHOT</version>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-starter</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-maven-plugin</artifactId>
- <version>${project.version}</version>
- <extensions>true</extensions>
- </plugin>
- </plugins>
- </build>
-
-</project>
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-samples/karaf-boot-sample-service-provider-blueprint/src/main/java/sample/blueprint/service/provider/HelloService.java
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-service-provider-blueprint/src/main/java/sample/blueprint/service/provider/HelloService.java b/karaf-boot-samples/karaf-boot-sample-service-provider-blueprint/src/main/java/sample/blueprint/service/provider/HelloService.java
deleted file mode 100644
index 2555069..0000000
--- a/karaf-boot-samples/karaf-boot-sample-service-provider-blueprint/src/main/java/sample/blueprint/service/provider/HelloService.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/**
- * 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 sample.blueprint.service.provider;
-
-public interface HelloService {
-
- public String hello(String message);
-
- public void startUp();
-
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-samples/karaf-boot-sample-service-provider-blueprint/src/main/java/sample/blueprint/service/provider/HelloServiceImpl.java
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-service-provider-blueprint/src/main/java/sample/blueprint/service/provider/HelloServiceImpl.java b/karaf-boot-samples/karaf-boot-sample-service-provider-blueprint/src/main/java/sample/blueprint/service/provider/HelloServiceImpl.java
deleted file mode 100644
index 4f97468..0000000
--- a/karaf-boot-samples/karaf-boot-sample-service-provider-blueprint/src/main/java/sample/blueprint/service/provider/HelloServiceImpl.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * 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 sample.blueprint.service.provider;
-
-public class HelloServiceImpl implements HelloService{
-
- public String hello(String message) {
- return "Hello " + message + " !";
- }
-
- public void startUp() {
- System.out.println("I'm starting up!");
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-samples/karaf-boot-sample-service-provider-blueprint/src/main/resources/OSGI-INF/blueprint/config.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-service-provider-blueprint/src/main/resources/OSGI-INF/blueprint/config.xml b/karaf-boot-samples/karaf-boot-sample-service-provider-blueprint/src/main/resources/OSGI-INF/blueprint/config.xml
deleted file mode 100644
index f85ae0a..0000000
--- a/karaf-boot-samples/karaf-boot-sample-service-provider-blueprint/src/main/resources/OSGI-INF/blueprint/config.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!--
- 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.
--->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
-
- <bean id="helloservice"
- class="sample.blueprint.service.provider.HelloServiceImpl"
- init-method="startUp" >
- </bean>
-
- <service ref="helloservice"
- interface="sample.blueprint.service.provider.HelloService" />
-
-</blueprint>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-samples/karaf-boot-sample-service-provider-ds/README.md
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-service-provider-ds/README.md b/karaf-boot-samples/karaf-boot-sample-service-provider-ds/README.md
deleted file mode 100644
index 94066f1..0000000
--- a/karaf-boot-samples/karaf-boot-sample-service-provider-ds/README.md
+++ /dev/null
@@ -1,35 +0,0 @@
-== karaf-boot-sample-service-provider-ds ==
-
-This sample exposes an OSGi service using the Karaf util classe and annotation.
-
-= Design
-
-The service "contract" is describe by the Hello interface. It's a very simple service that expose one operation (hello).
-The service client send a message (String) to the hello service and he gets a response.
-
-The HelloServiceImpl is very simple: it prefixes the message with "Hello".
-
-We use the @Component DS annotation on HelloServiceImpl implementation in order to expose the service.
-
-You don't think anything else: karaf-boot will generate all the plumbing for you, and you will directly have a ready
-to use artifact.
-
-= Build
-
-To build, simply do:
-
- mvn clean install
-
-= Deploy
-
-To deploy in Karaf, you have to enable the DS support first. For that, you have to install the scr feature:
-
- feature:install scr
-
-Once scr feature installed:
-
-* you can drop the generated jar file (target/karaf-boot-sample-service-provider-ds-1.0.jar) in the
-Karaf deploy folder
-* in the Karaf shell console, do:
-
- bundle:install -s mvn:org.apache.karaf.boot/karaf-boot-sample-service-provider-ds/1.0
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-samples/karaf-boot-sample-service-provider-ds/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-service-provider-ds/pom.xml b/karaf-boot-samples/karaf-boot-sample-service-provider-ds/pom.xml
deleted file mode 100644
index 854a780..0000000
--- a/karaf-boot-samples/karaf-boot-sample-service-provider-ds/pom.xml
+++ /dev/null
@@ -1,47 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<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">
-
- <!--
-
- 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.
- -->
-
- <modelVersion>4.0.0</modelVersion>
-
- <groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-sample-service-provider-ds</artifactId>
- <version>1.0.0-SNAPSHOT</version>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-starter-ds</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-maven-plugin</artifactId>
- <version>${project.version}</version>
- <extensions>true</extensions>
- </plugin>
- </plugins>
- </build>
-
-</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-samples/karaf-boot-sample-service-provider-ds/src/main/java/sample/ds/service/provider/HelloService.java
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-service-provider-ds/src/main/java/sample/ds/service/provider/HelloService.java b/karaf-boot-samples/karaf-boot-sample-service-provider-ds/src/main/java/sample/ds/service/provider/HelloService.java
deleted file mode 100644
index 50c2d30..0000000
--- a/karaf-boot-samples/karaf-boot-sample-service-provider-ds/src/main/java/sample/ds/service/provider/HelloService.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/**
- * 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 sample.ds.service.provider;
-
-/**
- * Simple hello service contract.
- */
-public interface HelloService {
-
- public String hello(String message);
-
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-samples/karaf-boot-sample-service-provider-ds/src/main/java/sample/ds/service/provider/HelloServiceImpl.java
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-service-provider-ds/src/main/java/sample/ds/service/provider/HelloServiceImpl.java b/karaf-boot-samples/karaf-boot-sample-service-provider-ds/src/main/java/sample/ds/service/provider/HelloServiceImpl.java
deleted file mode 100644
index 5319a47..0000000
--- a/karaf-boot-samples/karaf-boot-sample-service-provider-ds/src/main/java/sample/ds/service/provider/HelloServiceImpl.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * 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 sample.ds.service.provider;
-
-import org.osgi.service.component.annotations.Component;
-
-/**
- * Simple implementation of the hello service..
- */
-@Component
-public class HelloServiceImpl implements HelloService {
-
- public String hello(String message) {
- return "Hello " + message + " !";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-samples/karaf-boot-sample-service-provider-osgi/README.md
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-service-provider-osgi/README.md b/karaf-boot-samples/karaf-boot-sample-service-provider-osgi/README.md
deleted file mode 100644
index 092d350..0000000
--- a/karaf-boot-samples/karaf-boot-sample-service-provider-osgi/README.md
+++ /dev/null
@@ -1,33 +0,0 @@
-== karaf-boot-sample-service-provider-osgi ==
-
-This sample exposes an OSGi service using the Karaf util classe and annotation.
-
-= Design
-
-The service "contract" is describe by the Hello interface. It's a very simple service that expose one operation (hello).
-The service client send a message (String) to the hello service and he gets a response.
-
-The HelloServiceImpl is very simple: it prefixes the message with "Hello".
-
-In order to expose this service, we create an Activator, extending Karaf util BaseActivator.
-Our activator contains the @Services annotation describing the provided services (@ProvideService annotation).
-
-In this activator, we override the doStart() method, where we instantiate the HelloServiceImpl bean and register the
-HelloService service using the register() method (provided by Karaf). The Karaf BaseActivator manages the service
-registration, so you don't have to take care about the unregistration of the service, etc.
-
-= Build
-
-To build, simply do:
-
- mvn clean install
-
-= Deploy
-
-To deploy in Karaf:
-
-* you can drop the generated jar file (target/karaf-boot-sample-service-provider-osgi-1.0.jar) in the
-Karaf deploy folder
-* in the Karaf shell console, do:
-
- bundle:install -s mvn:org.apache.karaf.boot/karaf-boot-sample-service-provider-osgi/1.0
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-samples/karaf-boot-sample-service-provider-osgi/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-service-provider-osgi/pom.xml b/karaf-boot-samples/karaf-boot-sample-service-provider-osgi/pom.xml
deleted file mode 100644
index 507828a..0000000
--- a/karaf-boot-samples/karaf-boot-sample-service-provider-osgi/pom.xml
+++ /dev/null
@@ -1,47 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<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">
-
- <!--
-
- 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.
- -->
-
- <modelVersion>4.0.0</modelVersion>
-
- <groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-sample-service-provider-osgi</artifactId>
- <version>1.0.0-SNAPSHOT</version>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-starter-karaf</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-maven-plugin</artifactId>
- <version>${project.version}</version>
- <extensions>true</extensions>
- </plugin>
- </plugins>
- </build>
-
-</project>
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-samples/karaf-boot-sample-service-provider-osgi/src/main/java/sample/osgi/service/provider/Activator.java
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-service-provider-osgi/src/main/java/sample/osgi/service/provider/Activator.java b/karaf-boot-samples/karaf-boot-sample-service-provider-osgi/src/main/java/sample/osgi/service/provider/Activator.java
deleted file mode 100644
index 9bc9b20..0000000
--- a/karaf-boot-samples/karaf-boot-sample-service-provider-osgi/src/main/java/sample/osgi/service/provider/Activator.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/**
- * 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 sample.osgi.service.provider;
-
-import org.apache.karaf.util.tracker.BaseActivator;
-import org.apache.karaf.util.tracker.annotation.ProvideService;
-import org.apache.karaf.util.tracker.annotation.Services;
-
-/**
- * Simple activator registering the hello service.
- */
-@Services(
- provides = {
- @ProvideService(HelloService.class)
- }
-)
-public class Activator extends BaseActivator {
-
- @Override
- public void doStart() throws Exception {
- // create hello service bean
- HelloServiceImpl bean = new HelloServiceImpl();
- // register the hello service
- register(HelloService.class, bean);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-samples/karaf-boot-sample-service-provider-osgi/src/main/java/sample/osgi/service/provider/HelloService.java
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-service-provider-osgi/src/main/java/sample/osgi/service/provider/HelloService.java b/karaf-boot-samples/karaf-boot-sample-service-provider-osgi/src/main/java/sample/osgi/service/provider/HelloService.java
deleted file mode 100644
index fc0a357..0000000
--- a/karaf-boot-samples/karaf-boot-sample-service-provider-osgi/src/main/java/sample/osgi/service/provider/HelloService.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/**
- * 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 sample.osgi.service.provider;
-
-/**
- * Simple hello service contract.
- */
-public interface HelloService {
-
- public String hello(String message);
-
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-samples/karaf-boot-sample-service-provider-osgi/src/main/java/sample/osgi/service/provider/HelloServiceImpl.java
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-service-provider-osgi/src/main/java/sample/osgi/service/provider/HelloServiceImpl.java b/karaf-boot-samples/karaf-boot-sample-service-provider-osgi/src/main/java/sample/osgi/service/provider/HelloServiceImpl.java
deleted file mode 100644
index c212205..0000000
--- a/karaf-boot-samples/karaf-boot-sample-service-provider-osgi/src/main/java/sample/osgi/service/provider/HelloServiceImpl.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/**
- * 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 sample.osgi.service.provider;
-
-/**
- * Simple implementation of the hello service..
- */
-public class HelloServiceImpl implements HelloService {
-
- public String hello(String message) {
- return "Hello " + message + " !";
- }
-
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-samples/karaf-boot-sample-servlet/README.md
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-servlet/README.md b/karaf-boot-samples/karaf-boot-sample-servlet/README.md
deleted file mode 100644
index 75f940f..0000000
--- a/karaf-boot-samples/karaf-boot-sample-servlet/README.md
+++ /dev/null
@@ -1,30 +0,0 @@
-== karaf-boot-sample-servlet ==
-
-This sample shows how to easily create a servlet, ready to be deployed in Karaf.
-
-= Design
-
-The SampleServlet is servlet containing the @WebServlet annotation.
-
-This servlet is directly deployed by Karaf as soon as it's deployed.
-
-= Build
-
-To build, simply do:
-
- mvn clean install
-
-= Deploy
-
-To deploy in Karaf, you have to enable the web support by installing the http and http-whiteboard features:
-
- feature:install http
- feature:install http-whiteboard
-
-Once http features installed:
-
-* you can drop the generated jar file (target/karaf-boot-sample-servlet-1.0.jar) in the
-Karaf deploy folder
-* in the Karaf shell console, do:
-
- bundle:install -s mvn:org.apache.karaf.boot/karaf-boot-sample-servlet/1.0
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-samples/karaf-boot-sample-servlet/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-servlet/pom.xml b/karaf-boot-samples/karaf-boot-sample-servlet/pom.xml
deleted file mode 100644
index 773b00a..0000000
--- a/karaf-boot-samples/karaf-boot-sample-servlet/pom.xml
+++ /dev/null
@@ -1,47 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<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">
-
- <!--
-
- 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.
- -->
-
- <modelVersion>4.0.0</modelVersion>
-
- <groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-sample-servlet</artifactId>
- <version>1.0.0-SNAPSHOT</version>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-starter-web</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-maven-plugin</artifactId>
- <version>${project.version}</version>
- <extensions>true</extensions>
- </plugin>
- </plugins>
- </build>
-
-</project>
\ No newline at end of file
[24/35] karaf-boot git commit: Renaming dirs,
use blueprint-maven-plugin
Posted by cs...@apache.org.
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-tools/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/pom.xml b/karaf-boot-tools/pom.xml
deleted file mode 100644
index ccb9c88..0000000
--- a/karaf-boot-tools/pom.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<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">
-
- <!--
-
- 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.
- -->
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-build</artifactId>
- <version>1.0.0-SNAPSHOT</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
-
- <artifactId>karaf-boot-tools</artifactId>
- <packaging>pom</packaging>
-
- <modules>
- <module>karaf-boot-maven-plugin</module>
- </modules>
-
-</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index eea3146..9127ab0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -37,14 +37,15 @@
<modules>
<!-- Core karaf-boot -->
- <module>karaf-boot-starters</module>
- <module>karaf-boot-tools</module>
+ <module>starters</module>
+ <module>tools</module>
<!-- embedded mode -->
<!-- Archetypes -->
<!-- TODO archetypes -->
<!-- Demos -->
+ <module>samples</module>
<!-- TODO complete library demos -->
</modules>
@@ -61,37 +62,5 @@
</plugins>
</build>
- <profiles>
- <profile>
- <id>samples</id>
- <modules>
- <!-- Samples -->
- <!-- services -->
- <module>karaf-boot-samples/karaf-boot-sample-service-provider-osgi</module>
- <module>karaf-boot-samples/karaf-boot-sample-service-consumer-osgi</module>
- <module>karaf-boot-samples/karaf-boot-sample-service-provider-ds</module>
- <module>karaf-boot-samples/karaf-boot-sample-service-consumer-ds</module>
- <!-- blueprint -->
- <module>karaf-boot-samples/karaf-boot-sample-service-provider-blueprint</module>
- <module>karaf-boot-samples/karaf-boot-sample-service-consumer-blueprint</module>
- <!-- blueprint annotations -->
- <module>karaf-boot-samples/karaf-boot-sample-service-blueprint-annotation</module>
- <!-- cdi -->
- <module>karaf-boot-samples/karaf-boot-sample-cdi</module>
- <!-- shell -->
- <module>karaf-boot-samples/karaf-boot-sample-shell</module>
- <!-- config -->
- <module>karaf-boot-samples/karaf-boot-sample-config</module>
- <!-- jpa -->
- <module>karaf-boot-samples/karaf-boot-sample-jpa</module>
- <!-- servlet -->
- <module>karaf-boot-samples/karaf-boot-sample-servlet</module>
- <!-- webui / angular -->
- <!-- test -->
- <!-- rest & soap -->
- <!-- camel -->
- </modules>
- </profile>
- </profiles>
-
</project>
+
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/samples/README.md
----------------------------------------------------------------------
diff --git a/samples/README.md b/samples/README.md
new file mode 100644
index 0000000..d65c349
--- /dev/null
+++ b/samples/README.md
@@ -0,0 +1,27 @@
+* karaf-boot-sample-service-provider-osgi
+ Expose a service using the "native" Karaf OSGi layer (low level)
+* karaf-boot-sample-service-consumer-osgi
+ Use a service using the "native" Karaf OSGi layer (low level)
+
+* karaf-boot-services-osgi
+ Simple services using OSGi
+* karaf-boot-services-blueprint
+ Simple services using blueprint
+* karaf-boot-services-ds
+ Simple services using DS/SCR
+* karaf-boot-services-cdi
+ Simple services using CDI
+* karaf-boot-config-managed
+ Managed by configuration (reload)
+* karaf-boot-servlet
+ Servlet provider
+* karaf-boot-rest
+ REST service provider
+* karaf-boot-soap
+ SOAP service provider
+* karaf-boot-jpa
+ JPA implementation
+* karaf-boot-profile
+ Build a profile based on karaf-boot definition
+* karaf-boot-starter
+ Package and configure Karaf as a ready to run artifact
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/samples/blueprint/pom.xml
----------------------------------------------------------------------
diff --git a/samples/blueprint/pom.xml b/samples/blueprint/pom.xml
new file mode 100644
index 0000000..680358a
--- /dev/null
+++ b/samples/blueprint/pom.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+
+ <!--
+
+ 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.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-samples-blueprint</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>service-consumer</module>
+ <module>service-provider</module>
+ </modules>
+
+</project>
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/samples/blueprint/service-consumer/pom.xml
----------------------------------------------------------------------
diff --git a/samples/blueprint/service-consumer/pom.xml b/samples/blueprint/service-consumer/pom.xml
new file mode 100644
index 0000000..d482686
--- /dev/null
+++ b/samples/blueprint/service-consumer/pom.xml
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+
+ <!--
+ 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.
+-->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-sample-service-consumer-blueprint</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-starter</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.cdi</groupId>
+ <artifactId>pax-cdi-api</artifactId>
+ <version>0.5.0</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>javax.inject</groupId>
+ <artifactId>javax.inject</artifactId>
+ <version>1</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-sample-service-provider-blueprint</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-maven-plugin</artifactId>
+ <version>${project.version}</version>
+ <extensions>true</extensions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.aries.blueprint</groupId>
+ <artifactId>blueprint-maven-plugin</artifactId>
+ <version>1.3.0</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>blueprint-generate</goal>
+ </goals>
+ <phase>process-classes</phase>
+ </execution>
+ </executions>
+ <configuration>
+ <scanPaths>
+ <scanPath>sample</scanPath>
+ </scanPaths>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.3</version>
+ <configuration>
+ <source>1.8</source>
+ <target>1.8</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/samples/blueprint/service-consumer/src/main/java/sample/blueprint/service/consumer/HelloClient.java
----------------------------------------------------------------------
diff --git a/samples/blueprint/service-consumer/src/main/java/sample/blueprint/service/consumer/HelloClient.java b/samples/blueprint/service-consumer/src/main/java/sample/blueprint/service/consumer/HelloClient.java
new file mode 100644
index 0000000..ff568f8
--- /dev/null
+++ b/samples/blueprint/service-consumer/src/main/java/sample/blueprint/service/consumer/HelloClient.java
@@ -0,0 +1,38 @@
+/**
+ * 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 sample.blueprint.service.consumer;
+
+import javax.annotation.PostConstruct;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.ops4j.pax.cdi.api.OsgiService;
+
+import sample.blueprint.service.provider.HelloService;
+
+@Singleton
+public class HelloClient {
+
+ @Inject @OsgiService
+ HelloService helloService;
+
+ @PostConstruct
+ public void startUp() {
+ System.out.println(helloService.hello("World"));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/samples/blueprint/service-provider/README.md
----------------------------------------------------------------------
diff --git a/samples/blueprint/service-provider/README.md b/samples/blueprint/service-provider/README.md
new file mode 100644
index 0000000..07194df
--- /dev/null
+++ b/samples/blueprint/service-provider/README.md
@@ -0,0 +1,26 @@
+== karaf-boot-sample-service-provider-blueprint ==
+
+This sample exposes an OSGi service using blueprint.
+
+= Design
+
+The service "contract" is describe by the Hello interface. It's a very simple service that expose one operation (hello).
+The service client send a message (String) to the hello service and he gets a response.
+
+The HelloServiceImpl is very simple: it prefixes the message with "Hello".
+
+We use a blueprint XML descriptor (for blueprint annotations, see the corresponding sample) in order to expose the service.
+
+= Build
+
+To build, simply do:
+
+ mvn clean install
+
+= Deploy
+
+* you can drop the generated jar file (target/karaf-boot-sample-service-provider-blueprint-1.0.jar) in the
+Karaf deploy folder
+* in the Karaf shell console, do:
+
+ bundle:install -s mvn:org.apache.karaf.boot/karaf-boot-sample-service-provider-blueprint/1.0
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/samples/blueprint/service-provider/pom.xml
----------------------------------------------------------------------
diff --git a/samples/blueprint/service-provider/pom.xml b/samples/blueprint/service-provider/pom.xml
new file mode 100644
index 0000000..de9ab62
--- /dev/null
+++ b/samples/blueprint/service-provider/pom.xml
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+
+ <!-- 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. -->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-sample-service-provider-blueprint</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-starter</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.cdi</groupId>
+ <artifactId>pax-cdi-api</artifactId>
+ <version>0.5.0</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>javax.inject</groupId>
+ <artifactId>javax.inject</artifactId>
+ <version>1</version>
+ <optional>true</optional>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-maven-plugin</artifactId>
+ <version>${project.version}</version>
+ <extensions>true</extensions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.aries.blueprint</groupId>
+ <artifactId>blueprint-maven-plugin</artifactId>
+ <version>1.3.0</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>blueprint-generate</goal>
+ </goals>
+ <phase>process-classes</phase>
+ </execution>
+ </executions>
+ <configuration>
+ <scanPaths>
+ <scanPath>sample</scanPath>
+ </scanPaths>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.3</version>
+ <configuration>
+ <source>1.8</source>
+ <target>1.8</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/samples/blueprint/service-provider/src/main/java/sample/blueprint/service/provider/HelloService.java
----------------------------------------------------------------------
diff --git a/samples/blueprint/service-provider/src/main/java/sample/blueprint/service/provider/HelloService.java b/samples/blueprint/service-provider/src/main/java/sample/blueprint/service/provider/HelloService.java
new file mode 100644
index 0000000..2555069
--- /dev/null
+++ b/samples/blueprint/service-provider/src/main/java/sample/blueprint/service/provider/HelloService.java
@@ -0,0 +1,25 @@
+/**
+ * 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 sample.blueprint.service.provider;
+
+public interface HelloService {
+
+ public String hello(String message);
+
+ public void startUp();
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/samples/blueprint/service-provider/src/main/java/sample/blueprint/service/provider/HelloServiceImpl.java
----------------------------------------------------------------------
diff --git a/samples/blueprint/service-provider/src/main/java/sample/blueprint/service/provider/HelloServiceImpl.java b/samples/blueprint/service-provider/src/main/java/sample/blueprint/service/provider/HelloServiceImpl.java
new file mode 100644
index 0000000..8287891
--- /dev/null
+++ b/samples/blueprint/service-provider/src/main/java/sample/blueprint/service/provider/HelloServiceImpl.java
@@ -0,0 +1,38 @@
+/**
+ * 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 sample.blueprint.service.provider;
+
+import javax.annotation.PostConstruct;
+import javax.inject.Singleton;
+
+import org.ops4j.pax.cdi.api.OsgiServiceProvider;
+
+@OsgiServiceProvider(classes = HelloService.class)
+@Singleton
+public class HelloServiceImpl implements HelloService{
+
+ public String hello(String message) {
+ return "Hello " + message + " !";
+ }
+
+ @PostConstruct
+ public void startUp() {
+ System.out.println("I'm starting up!");
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/samples/cdi/README.md
----------------------------------------------------------------------
diff --git a/samples/cdi/README.md b/samples/cdi/README.md
new file mode 100644
index 0000000..1f98cac
--- /dev/null
+++ b/samples/cdi/README.md
@@ -0,0 +1,23 @@
+== karaf-boot-sample-cdi ==
+
+This sample shows how to define a CDI bundle.
+
+= Design
+
+TODO.
+
+= Build
+
+To build, simply do:
+
+ mvn clean install
+
+= Deploy
+
+To deploy i:
+
+* you can drop the generated jar file (target/karaf-boot-sample-cdi-1.0.jar) in the
+Karaf deploy folder
+* in the Karaf shell console, do:
+
+ bundle:install -s mvn:org.apache.karaf.boot/karaf-boot-sample-cdi/1.0
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/samples/cdi/pom.xml
----------------------------------------------------------------------
diff --git a/samples/cdi/pom.xml b/samples/cdi/pom.xml
new file mode 100644
index 0000000..1c4fac4
--- /dev/null
+++ b/samples/cdi/pom.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+
+ <!-- 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. -->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-sample-cdi</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-starter-cdi</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-maven-plugin</artifactId>
+ <version>${project.version}</version>
+ <extensions>true</extensions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.3</version>
+ <configuration>
+ <source>1.8</source>
+ <target>1.8</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/samples/cdi/src/main/java/sample/cdi/IceCreamService.java
----------------------------------------------------------------------
diff --git a/samples/cdi/src/main/java/sample/cdi/IceCreamService.java b/samples/cdi/src/main/java/sample/cdi/IceCreamService.java
new file mode 100644
index 0000000..5f9cfac
--- /dev/null
+++ b/samples/cdi/src/main/java/sample/cdi/IceCreamService.java
@@ -0,0 +1,6 @@
+package sample.cdi;
+
+public interface IceCreamService {
+
+ String getFlavour();
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/samples/cdi/src/main/java/sample/cdi/impl/VanillaService.java
----------------------------------------------------------------------
diff --git a/samples/cdi/src/main/java/sample/cdi/impl/VanillaService.java b/samples/cdi/src/main/java/sample/cdi/impl/VanillaService.java
new file mode 100644
index 0000000..3007035
--- /dev/null
+++ b/samples/cdi/src/main/java/sample/cdi/impl/VanillaService.java
@@ -0,0 +1,45 @@
+/**
+ * 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 sample.cdi.impl;
+
+import javax.annotation.PostConstruct;
+import javax.enterprise.context.ApplicationScoped;
+
+import org.ops4j.pax.cdi.api.OsgiServiceProvider;
+import org.ops4j.pax.cdi.api.Properties;
+import org.ops4j.pax.cdi.api.Property;
+import sample.cdi.IceCreamService;
+
+@OsgiServiceProvider(classes = { VanillaService.class, IceCreamService.class })
+@Properties(@Property(name = "flavour", value = "vanilla"))
+@ApplicationScoped
+class VanillaService implements IceCreamService {
+
+ private boolean initialized;
+
+ @PostConstruct
+ public void init() {
+ initialized = true;
+ }
+
+ public String getFlavour() {
+ if (!initialized) {
+ throw new AssertionError("VanillaService is not initialized");
+ }
+ return "Vanilla";
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/samples/ds/config/README.md
----------------------------------------------------------------------
diff --git a/samples/ds/config/README.md b/samples/ds/config/README.md
new file mode 100644
index 0000000..1c8dbc5
--- /dev/null
+++ b/samples/ds/config/README.md
@@ -0,0 +1,31 @@
+== karaf-boot-sample-config ==
+
+This sample shows how to use a configuration provided in the etc folder of Karaf, and directly use the
+properties values in your code.
+
+= Design
+
+The ConfigComponent use a SampleConfig configuration. The SampleConfig configuration is "injected" at activation
+time of the component.
+
+The component just displays the values of the properties.
+
+= Build
+
+To build, simply do:
+
+ mvn clean install
+
+= Deploy
+
+To deploy in Karaf, you have to enable the DS support first. For that, you have to install the scr feature:
+
+ feature:install scr
+
+Once scr feature installed:
+
+* you can drop the generated jar file (target/karaf-boot-sample-config-1.0.jar) in the
+Karaf deploy folder
+* in the Karaf shell console, do:
+
+ bundle:install -s mvn:org.apache.karaf.boot/karaf-boot-sample-config/1.0
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/samples/ds/config/pom.xml
----------------------------------------------------------------------
diff --git a/samples/ds/config/pom.xml b/samples/ds/config/pom.xml
new file mode 100644
index 0000000..688150b
--- /dev/null
+++ b/samples/ds/config/pom.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+
+ <!--
+
+ 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.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-sample-config</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-starter-ds</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-maven-plugin</artifactId>
+ <version>${project.version}</version>
+ <extensions>true</extensions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/samples/ds/config/src/main/java/sample/config/ConfigComponent.java
----------------------------------------------------------------------
diff --git a/samples/ds/config/src/main/java/sample/config/ConfigComponent.java b/samples/ds/config/src/main/java/sample/config/ConfigComponent.java
new file mode 100644
index 0000000..52cf369
--- /dev/null
+++ b/samples/ds/config/src/main/java/sample/config/ConfigComponent.java
@@ -0,0 +1,43 @@
+/**
+ * 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 sample.config;
+
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.metatype.annotations.Designate;
+import org.osgi.service.metatype.annotations.ObjectClassDefinition;
+
+@ObjectClassDefinition(name = "Sample Configuration", pid = "org.apache.karaf.boot.sample.config")
+@interface SampleConfig {
+ String stringProperty() default "default";
+ int intProperty() default 0;
+ boolean booleanProperty() default false;
+}
+
+@Component
+@Designate(ocd = SampleConfig.class)
+public class ConfigComponent {
+
+ @Activate
+ public void activate(SampleConfig sampleConfig) {
+ System.out.println("We use the property there");
+ System.out.println("stringProperty:" + sampleConfig.stringProperty());
+ System.out.println("intProperty: " + sampleConfig.intProperty());
+ System.out.println("booleanProperty: " + sampleConfig.booleanProperty());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/samples/ds/pom.xml
----------------------------------------------------------------------
diff --git a/samples/ds/pom.xml b/samples/ds/pom.xml
new file mode 100644
index 0000000..f031e88
--- /dev/null
+++ b/samples/ds/pom.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+
+ <!--
+
+ 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.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-samples-ds</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>config</module>
+ <module>service-consumer</module>
+ <module>service-provider</module>
+ <module>shell</module>
+ </modules>
+
+</project>
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/samples/ds/service-consumer/README.md
----------------------------------------------------------------------
diff --git a/samples/ds/service-consumer/README.md b/samples/ds/service-consumer/README.md
new file mode 100644
index 0000000..ae04875
--- /dev/null
+++ b/samples/ds/service-consumer/README.md
@@ -0,0 +1,36 @@
+== karaf-boot-sample-service-provider-osgi ==
+
+This sample exposes an OSGi service using the Karaf util classe and annotation.
+
+= Design
+
+This artifact uses the hello service provided by another artifact (karaf-boot-sample-service-provider-ds for instance).
+
+It uses the DS annotations to create a bean with a reference (@Reference) to the hello service.
+In the HelloServiceClient bean, we use the @Activate annotation to execute a specific method.
+
+You don't think anything else: karaf-boot will generate all the plumbing for you, and you will directly have a ready
+to use artifact.
+
+= Build
+
+To build, simply do:
+
+ mvn clean install
+
+= Deploy
+
+To deploy in Karaf, you have to enable the DS support first. For that, you have to install the scr feature:
+
+ feature:install scr
+
+Once scr feature installed, you have to install a hello service provider. Please use any of karaf-boot-sample-service-provider-*
+deployment first.
+
+Once the service provider is installed:
+
+* you can drop the generated jar file (target/karaf-boot-sample-service-consumer-ds-1.0.jar) in the
+Karaf deploy folder
+* in the Karaf shell console, do:
+
+ bundle:install -s mvn:org.apache.karaf.boot/karaf-boot-sample-service-consumer-ds/1.0
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/samples/ds/service-consumer/pom.xml
----------------------------------------------------------------------
diff --git a/samples/ds/service-consumer/pom.xml b/samples/ds/service-consumer/pom.xml
new file mode 100644
index 0000000..c6b85c0
--- /dev/null
+++ b/samples/ds/service-consumer/pom.xml
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+
+ <!--
+
+ 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.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-sample-service-consumer-ds</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-starter-ds</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-sample-service-provider-ds</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-maven-plugin</artifactId>
+ <version>${project.version}</version>
+ <extensions>true</extensions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/samples/ds/service-consumer/src/main/java/sample/ds/service/consumer/HelloServiceClient.java
----------------------------------------------------------------------
diff --git a/samples/ds/service-consumer/src/main/java/sample/ds/service/consumer/HelloServiceClient.java b/samples/ds/service-consumer/src/main/java/sample/ds/service/consumer/HelloServiceClient.java
new file mode 100644
index 0000000..f70ebf7
--- /dev/null
+++ b/samples/ds/service-consumer/src/main/java/sample/ds/service/consumer/HelloServiceClient.java
@@ -0,0 +1,59 @@
+/**
+ * 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 sample.ds.service.consumer;
+
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Deactivate;
+import org.osgi.service.component.annotations.Reference;
+import sample.ds.service.provider.HelloService;
+
+@Component
+public class HelloServiceClient implements Runnable {
+
+ private HelloService helloService;
+
+ private Thread thread;
+
+ @Activate
+ public void start() {
+ thread = new Thread(this);
+ thread.start();
+ }
+
+ @Deactivate
+ public void stop() {
+ thread.interrupt();
+ }
+
+ public void run() {
+ while (true) {
+ System.out.println(helloService.hello("World"));
+ try {
+ Thread.sleep(5000);
+ } catch (Exception e) {
+ // nothing to do
+ }
+ }
+ }
+
+ @Reference
+ public void setHelloService(HelloService helloService) {
+ this.helloService = helloService;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/samples/ds/service-provider/README.md
----------------------------------------------------------------------
diff --git a/samples/ds/service-provider/README.md b/samples/ds/service-provider/README.md
new file mode 100644
index 0000000..94066f1
--- /dev/null
+++ b/samples/ds/service-provider/README.md
@@ -0,0 +1,35 @@
+== karaf-boot-sample-service-provider-ds ==
+
+This sample exposes an OSGi service using the Karaf util classe and annotation.
+
+= Design
+
+The service "contract" is describe by the Hello interface. It's a very simple service that expose one operation (hello).
+The service client send a message (String) to the hello service and he gets a response.
+
+The HelloServiceImpl is very simple: it prefixes the message with "Hello".
+
+We use the @Component DS annotation on HelloServiceImpl implementation in order to expose the service.
+
+You don't think anything else: karaf-boot will generate all the plumbing for you, and you will directly have a ready
+to use artifact.
+
+= Build
+
+To build, simply do:
+
+ mvn clean install
+
+= Deploy
+
+To deploy in Karaf, you have to enable the DS support first. For that, you have to install the scr feature:
+
+ feature:install scr
+
+Once scr feature installed:
+
+* you can drop the generated jar file (target/karaf-boot-sample-service-provider-ds-1.0.jar) in the
+Karaf deploy folder
+* in the Karaf shell console, do:
+
+ bundle:install -s mvn:org.apache.karaf.boot/karaf-boot-sample-service-provider-ds/1.0
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/samples/ds/service-provider/pom.xml
----------------------------------------------------------------------
diff --git a/samples/ds/service-provider/pom.xml b/samples/ds/service-provider/pom.xml
new file mode 100644
index 0000000..854a780
--- /dev/null
+++ b/samples/ds/service-provider/pom.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+
+ <!--
+
+ 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.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-sample-service-provider-ds</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-starter-ds</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-maven-plugin</artifactId>
+ <version>${project.version}</version>
+ <extensions>true</extensions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/samples/ds/service-provider/src/main/java/sample/ds/service/provider/HelloService.java
----------------------------------------------------------------------
diff --git a/samples/ds/service-provider/src/main/java/sample/ds/service/provider/HelloService.java b/samples/ds/service-provider/src/main/java/sample/ds/service/provider/HelloService.java
new file mode 100644
index 0000000..50c2d30
--- /dev/null
+++ b/samples/ds/service-provider/src/main/java/sample/ds/service/provider/HelloService.java
@@ -0,0 +1,26 @@
+/**
+ * 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 sample.ds.service.provider;
+
+/**
+ * Simple hello service contract.
+ */
+public interface HelloService {
+
+ public String hello(String message);
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/samples/ds/service-provider/src/main/java/sample/ds/service/provider/HelloServiceImpl.java
----------------------------------------------------------------------
diff --git a/samples/ds/service-provider/src/main/java/sample/ds/service/provider/HelloServiceImpl.java b/samples/ds/service-provider/src/main/java/sample/ds/service/provider/HelloServiceImpl.java
new file mode 100644
index 0000000..5319a47
--- /dev/null
+++ b/samples/ds/service-provider/src/main/java/sample/ds/service/provider/HelloServiceImpl.java
@@ -0,0 +1,31 @@
+/**
+ * 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 sample.ds.service.provider;
+
+import org.osgi.service.component.annotations.Component;
+
+/**
+ * Simple implementation of the hello service..
+ */
+@Component
+public class HelloServiceImpl implements HelloService {
+
+ public String hello(String message) {
+ return "Hello " + message + " !";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/samples/ds/shell/README.md
----------------------------------------------------------------------
diff --git a/samples/ds/shell/README.md b/samples/ds/shell/README.md
new file mode 100644
index 0000000..dc6b380
--- /dev/null
+++ b/samples/ds/shell/README.md
@@ -0,0 +1,38 @@
+== karaf-boot-sample-shell ==
+
+This sample provides new shell command in the Karaf shell console, that uses the hello service, provided by another
+artifact (as karaf-boot-sample-service-provider-ds for instance).
+
+= Design
+
+The shell commands are exposed using the Karaf shell annotations.
+
+A command is basically a class implementing Action interface, and we use @Service, @Command, @Argument, @Option Karaf
+shell annotations.
+
+The @Reference annotation uses the hello service.
+
+= Build
+
+To build, simply do:
+
+ mvn clean install
+
+= Deploy
+
+You have to install a hello service provider first. Please deploy karaf-boot-sample-service-provider-ds first.
+
+To deploy in Karaf:
+
+* you can drop the generated jar file (target/karaf-boot-sample-shell-1.0.jar) in the
+Karaf deploy folder
+* in the Karaf shell console, do:
+
+ bundle:install -s mvn:org.apache.karaf.boot/karaf-boot-sample-shell/1.0
+
+= Usage
+
+Once deployed, you can use the sample:hello command like:
+
+karaf@root()> sample:hello world
+Hello world !
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/samples/ds/shell/pom.xml
----------------------------------------------------------------------
diff --git a/samples/ds/shell/pom.xml b/samples/ds/shell/pom.xml
new file mode 100644
index 0000000..1df8632
--- /dev/null
+++ b/samples/ds/shell/pom.xml
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+
+ <!--
+
+ 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.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-sample-shell</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-starter-shell</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-sample-service-provider-ds</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-maven-plugin</artifactId>
+ <version>${project.version}</version>
+ <inherited>true</inherited>
+ <extensions>true</extensions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/samples/ds/shell/src/main/java/sample/shell/HelloCommand.java
----------------------------------------------------------------------
diff --git a/samples/ds/shell/src/main/java/sample/shell/HelloCommand.java b/samples/ds/shell/src/main/java/sample/shell/HelloCommand.java
new file mode 100644
index 0000000..eb4a730
--- /dev/null
+++ b/samples/ds/shell/src/main/java/sample/shell/HelloCommand.java
@@ -0,0 +1,47 @@
+/**
+ * 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 sample.shell;
+
+import org.apache.karaf.shell.api.action.Action;
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.Option;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import sample.ds.service.provider.HelloService;
+
+@Service
+@Command(scope = "sample", name = "hello", description = "The hello command")
+public class HelloCommand implements Action {
+
+ @Reference
+ public HelloService helloService;
+
+ @Argument(index = 0, name = "arg", description = "This is the message argument", required = true, multiValued = false)
+ public String arg;
+
+ @Option(name = "opt", description = "This is an option", required = false, multiValued = false)
+ public String opt;
+
+ public Object execute() throws Exception {
+ if (opt != null)
+ System.out.println("Opt is " + opt);
+ System.out.println(helloService.hello(arg));
+ return null;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/samples/jpa/README.md
----------------------------------------------------------------------
diff --git a/samples/jpa/README.md b/samples/jpa/README.md
new file mode 100644
index 0000000..3a3f6a3
--- /dev/null
+++ b/samples/jpa/README.md
@@ -0,0 +1,23 @@
+== karaf-boot-sample-jpa ==
+
+This sample shows how to define a JPA bundle and generate the persistent unit.
+
+= Design
+
+A Task entity is defined and annotated with the persistent unit annotations.
+
+= Build
+
+To build, simply do:
+
+ mvn clean install
+
+= Deploy
+
+To deploy i:
+
+* you can drop the generated jar file (target/karaf-boot-sample-jpa-1.0.jar) in the
+Karaf deploy folder
+* in the Karaf shell console, do:
+
+ bundle:install -s mvn:org.apache.karaf.boot/karaf-boot-sample-jpa/1.0
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/samples/jpa/pom.xml
----------------------------------------------------------------------
diff --git a/samples/jpa/pom.xml b/samples/jpa/pom.xml
new file mode 100644
index 0000000..032396f
--- /dev/null
+++ b/samples/jpa/pom.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+
+ <!--
+
+ 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.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-sample-jpa</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-starter-jpa</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-maven-plugin</artifactId>
+ <version>${project.version}</version>
+ <extensions>true</extensions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/samples/jpa/src/main/java/sample/jpa/Task.java
----------------------------------------------------------------------
diff --git a/samples/jpa/src/main/java/sample/jpa/Task.java b/samples/jpa/src/main/java/sample/jpa/Task.java
new file mode 100644
index 0000000..cd431a7
--- /dev/null
+++ b/samples/jpa/src/main/java/sample/jpa/Task.java
@@ -0,0 +1,66 @@
+/**
+ * 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 sample.jpa;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.karaf.boot.jpa.Hibernate;
+import org.apache.karaf.boot.jpa.PersistentUnit;
+import org.apache.karaf.boot.jpa.Property;
+import org.apache.karaf.boot.jpa.Provider;
+
+@PersistentUnit(name = "tasklist", provider = Provider.Hibernate, properties = {
+ @Property(name = "hibernate.hbm2ddl.auto", value = "create-drop")
+})
+@Hibernate.Dialect(Hibernate.Dialect.Value.HSQL)
+@Hibernate.Hbm2DdlAuto(Hibernate.Hbm2DdlAuto.Value.CreateDrop)
+@Entity
+@XmlRootElement
+public class Task {
+ @Id
+ Integer id;
+ String title;
+
+ public Task() {
+ }
+
+
+ public Task(Integer id, String title) {
+ super();
+ this.id = id;
+ this.title = title;
+ }
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = new Integer(id);
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/samples/pom.xml
----------------------------------------------------------------------
diff --git a/samples/pom.xml b/samples/pom.xml
new file mode 100644
index 0000000..bdb5fee
--- /dev/null
+++ b/samples/pom.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+
+ <!--
+
+ 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.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-samples</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>blueprint</module>
+ <module>cdi</module>
+ <module>ds</module>
+ <module>jpa</module>
+ <module>servlet</module>
+ </modules>
+
+</project>
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/samples/servlet/README.md
----------------------------------------------------------------------
diff --git a/samples/servlet/README.md b/samples/servlet/README.md
new file mode 100644
index 0000000..75f940f
--- /dev/null
+++ b/samples/servlet/README.md
@@ -0,0 +1,30 @@
+== karaf-boot-sample-servlet ==
+
+This sample shows how to easily create a servlet, ready to be deployed in Karaf.
+
+= Design
+
+The SampleServlet is servlet containing the @WebServlet annotation.
+
+This servlet is directly deployed by Karaf as soon as it's deployed.
+
+= Build
+
+To build, simply do:
+
+ mvn clean install
+
+= Deploy
+
+To deploy in Karaf, you have to enable the web support by installing the http and http-whiteboard features:
+
+ feature:install http
+ feature:install http-whiteboard
+
+Once http features installed:
+
+* you can drop the generated jar file (target/karaf-boot-sample-servlet-1.0.jar) in the
+Karaf deploy folder
+* in the Karaf shell console, do:
+
+ bundle:install -s mvn:org.apache.karaf.boot/karaf-boot-sample-servlet/1.0
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/samples/servlet/pom.xml
----------------------------------------------------------------------
diff --git a/samples/servlet/pom.xml b/samples/servlet/pom.xml
new file mode 100644
index 0000000..773b00a
--- /dev/null
+++ b/samples/servlet/pom.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+
+ <!--
+
+ 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.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-sample-servlet</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-starter-web</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-maven-plugin</artifactId>
+ <version>${project.version}</version>
+ <extensions>true</extensions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/samples/servlet/src/main/java/sample/servlet/SampleServlet.java
----------------------------------------------------------------------
diff --git a/samples/servlet/src/main/java/sample/servlet/SampleServlet.java b/samples/servlet/src/main/java/sample/servlet/SampleServlet.java
new file mode 100644
index 0000000..d0069af
--- /dev/null
+++ b/samples/servlet/src/main/java/sample/servlet/SampleServlet.java
@@ -0,0 +1,44 @@
+/*
+ * 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 sample.servlet;
+
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+@WebServlet(name = "SampleServlet", urlPatterns = {"/sample"})
+public class SampleServlet extends HttpServlet {
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ final PrintWriter writer = response.getWriter();
+ writer.println("<html>");
+ writer.println("<head>");
+ writer.println("<title>Sample</title>");
+ writer.println("</head>");
+ writer.println("<body align='center'>");
+ writer.println("<h1>Sample karaf-boot</h1>");
+ writer.println("</body>");
+ writer.println("</html>");
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/starters/karaf-boot-starter-blueprint/pom.xml
----------------------------------------------------------------------
diff --git a/starters/karaf-boot-starter-blueprint/pom.xml b/starters/karaf-boot-starter-blueprint/pom.xml
new file mode 100644
index 0000000..9f48c60
--- /dev/null
+++ b/starters/karaf-boot-starter-blueprint/pom.xml
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+
+ <!--
+
+ 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.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-starters</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>karaf-boot-starter-blueprint</artifactId>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.aries.blueprint</groupId>
+ <artifactId>org.apache.aries.blueprint.api</artifactId>
+ <version>1.0.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.aries.blueprint</groupId>
+ <artifactId>org.apache.aries.blueprint.annotation.api</artifactId>
+ <version>1.0.0</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <compilerArgument>-proc:none</compilerArgument>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/starters/karaf-boot-starter-blueprint/src/main/java/org/apache/karaf/boot/blueprint/impl/BlueprintProcessor.java
----------------------------------------------------------------------
diff --git a/starters/karaf-boot-starter-blueprint/src/main/java/org/apache/karaf/boot/blueprint/impl/BlueprintProcessor.java b/starters/karaf-boot-starter-blueprint/src/main/java/org/apache/karaf/boot/blueprint/impl/BlueprintProcessor.java
new file mode 100644
index 0000000..896a161
--- /dev/null
+++ b/starters/karaf-boot-starter-blueprint/src/main/java/org/apache/karaf/boot/blueprint/impl/BlueprintProcessor.java
@@ -0,0 +1,76 @@
+package org.apache.karaf.boot.blueprint.impl;
+
+import javax.annotation.processing.AbstractProcessor;
+import javax.annotation.processing.RoundEnvironment;
+import javax.lang.model.element.TypeElement;
+import javax.tools.Diagnostic.Kind;
+import javax.tools.FileObject;
+import javax.tools.StandardLocation;
+import java.io.ByteArrayOutputStream;
+import java.io.CharArrayWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PrintWriter;
+import java.io.Reader;
+import java.io.Writer;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.aries.blueprint.annotation.Bean;
+
+public class BlueprintProcessor extends AbstractProcessor {
+
+ boolean hasRun;
+
+ public BlueprintProcessor() {
+ }
+
+ @Override
+ public Set<String> getSupportedAnnotationTypes() {
+ Set<String> set = new HashSet<String>();
+ set.add(Bean.class.getName());
+ return set;
+ }
+
+ @Override
+ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+ if (!hasRun) {
+ hasRun = true;
+ // Add the blueprint requirement
+ try (PrintWriter w = appendResource("META-INF/org.apache.karaf.boot.bnd")) {
+ w.println("Bundle-Blueprint-Annotation: true");
+ } catch (Exception e) {
+ processingEnv.getMessager().printMessage(Kind.ERROR, "Error: " + e.getMessage());
+ }
+ }
+ return true;
+ }
+
+ private PrintWriter appendResource(String resource) throws IOException {
+ try {
+ FileObject o = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", resource);
+ return new PrintWriter(o.openWriter());
+ } catch (Exception e) {
+ try {
+ FileObject o = processingEnv.getFiler().getResource(StandardLocation.CLASS_OUTPUT, "", resource);
+ CharArrayWriter baos = new CharArrayWriter();
+ try (Reader r = o.openReader(true)) {
+ char[] buf = new char[4096];
+ int l;
+ while ((l = r.read(buf)) > 0) {
+ baos.write(buf, 0, l);
+ }
+ }
+ o.delete();
+ o = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", resource);
+ Writer w = o.openWriter();
+ w.write(baos.toCharArray());
+ return new PrintWriter(w);
+ } catch (Exception e2) {
+ e2.addSuppressed(e);
+ e2.printStackTrace();
+ throw e2;
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/starters/karaf-boot-starter-blueprint/src/main/resources/META-INF/services/javax.annotation.processing.Processor
----------------------------------------------------------------------
diff --git a/starters/karaf-boot-starter-blueprint/src/main/resources/META-INF/services/javax.annotation.processing.Processor b/starters/karaf-boot-starter-blueprint/src/main/resources/META-INF/services/javax.annotation.processing.Processor
new file mode 100644
index 0000000..fab44d1
--- /dev/null
+++ b/starters/karaf-boot-starter-blueprint/src/main/resources/META-INF/services/javax.annotation.processing.Processor
@@ -0,0 +1 @@
+org.apache.karaf.boot.blueprint.impl.BlueprintProcessor
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/starters/karaf-boot-starter-cdi/pom.xml
----------------------------------------------------------------------
diff --git a/starters/karaf-boot-starter-cdi/pom.xml b/starters/karaf-boot-starter-cdi/pom.xml
new file mode 100644
index 0000000..3f33d28
--- /dev/null
+++ b/starters/karaf-boot-starter-cdi/pom.xml
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+
+ <!--
+
+ 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.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-starters</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>karaf-boot-starter-cdi</artifactId>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>osgi.cmpn</artifactId>
+ <version>${osgi.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.cdi</groupId>
+ <artifactId>pax-cdi-api</artifactId>
+ <version>${pax.cdi.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.enterprise</groupId>
+ <artifactId>cdi-api</artifactId>
+ <version>1.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-atinject_1.0_spec</artifactId>
+ <version>1.0</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <compilerArgument>-proc:none</compilerArgument>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/starters/karaf-boot-starter-cdi/src/main/java/org/apache/karaf/boot/cdi/impl/CdiProcessor.java
----------------------------------------------------------------------
diff --git a/starters/karaf-boot-starter-cdi/src/main/java/org/apache/karaf/boot/cdi/impl/CdiProcessor.java b/starters/karaf-boot-starter-cdi/src/main/java/org/apache/karaf/boot/cdi/impl/CdiProcessor.java
new file mode 100644
index 0000000..44cc571
--- /dev/null
+++ b/starters/karaf-boot-starter-cdi/src/main/java/org/apache/karaf/boot/cdi/impl/CdiProcessor.java
@@ -0,0 +1,82 @@
+package org.apache.karaf.boot.cdi.impl;
+
+import javax.annotation.processing.AbstractProcessor;
+import javax.annotation.processing.RoundEnvironment;
+import javax.lang.model.element.TypeElement;
+import javax.tools.Diagnostic.Kind;
+import javax.tools.FileObject;
+import javax.tools.StandardLocation;
+import java.io.ByteArrayOutputStream;
+import java.io.CharArrayWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PrintWriter;
+import java.io.Reader;
+import java.io.Writer;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.ops4j.pax.cdi.api.OsgiServiceProvider;
+
+public class CdiProcessor extends AbstractProcessor {
+
+ boolean hasRun;
+
+ public CdiProcessor() {
+ }
+
+ @Override
+ public Set<String> getSupportedAnnotationTypes() {
+ Set<String> set = new HashSet<String>();
+ set.add(OsgiServiceProvider.class.getName());
+ return set;
+ }
+
+ @Override
+ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+ if (!hasRun) {
+ hasRun = true;
+ // Make sure we have a META-INF/beans.xml file present
+ try (PrintWriter w = appendResource("META-INF/beans.xml")) {
+ processingEnv.getMessager().printMessage(Kind.NOTE, "Generated META-INF/beans.xml");
+ } catch (Exception e) {
+ processingEnv.getMessager().printMessage(Kind.ERROR, "Error: " + e.getMessage());
+ }
+ // Add the CDI requirement
+ try (PrintWriter w = appendResource("META-INF/org.apache.karaf.boot.bnd")) {
+ w.println("Require-Capability: osgi.extender; filter:=\"(osgi.extender=pax.cdi)\"");
+ } catch (Exception e) {
+ processingEnv.getMessager().printMessage(Kind.ERROR, "Error: " + e.getMessage());
+ }
+ }
+ return true;
+ }
+
+ private PrintWriter appendResource(String resource) throws IOException {
+ try {
+ FileObject o = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", resource);
+ return new PrintWriter(o.openWriter());
+ } catch (Exception e) {
+ try {
+ FileObject o = processingEnv.getFiler().getResource(StandardLocation.CLASS_OUTPUT, "", resource);
+ CharArrayWriter baos = new CharArrayWriter();
+ try (Reader r = o.openReader(true)) {
+ char[] buf = new char[4096];
+ int l;
+ while ((l = r.read(buf)) > 0) {
+ baos.write(buf, 0, l);
+ }
+ }
+ o.delete();
+ o = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", resource);
+ Writer w = o.openWriter();
+ w.write(baos.toCharArray());
+ return new PrintWriter(w);
+ } catch (Exception e2) {
+ e2.addSuppressed(e);
+ e2.printStackTrace();
+ throw e2;
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/starters/karaf-boot-starter-cdi/src/main/resources/META-INF/services/javax.annotation.processing.Processor
----------------------------------------------------------------------
diff --git a/starters/karaf-boot-starter-cdi/src/main/resources/META-INF/services/javax.annotation.processing.Processor b/starters/karaf-boot-starter-cdi/src/main/resources/META-INF/services/javax.annotation.processing.Processor
new file mode 100644
index 0000000..a6cd494
--- /dev/null
+++ b/starters/karaf-boot-starter-cdi/src/main/resources/META-INF/services/javax.annotation.processing.Processor
@@ -0,0 +1 @@
+org.apache.karaf.boot.cdi.impl.CdiProcessor
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/starters/karaf-boot-starter-ds/pom.xml
----------------------------------------------------------------------
diff --git a/starters/karaf-boot-starter-ds/pom.xml b/starters/karaf-boot-starter-ds/pom.xml
new file mode 100644
index 0000000..331c8e2
--- /dev/null
+++ b/starters/karaf-boot-starter-ds/pom.xml
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+
+ <!--
+
+ 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.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-starters</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>karaf-boot-starter-ds</artifactId>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>osgi.cmpn</artifactId>
+ <version>${osgi.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <compilerArgument>-proc:none</compilerArgument>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/starters/karaf-boot-starter-ds/src/main/java/org/apache/karaf/boot/ds/impl/DsProcessor.java
----------------------------------------------------------------------
diff --git a/starters/karaf-boot-starter-ds/src/main/java/org/apache/karaf/boot/ds/impl/DsProcessor.java b/starters/karaf-boot-starter-ds/src/main/java/org/apache/karaf/boot/ds/impl/DsProcessor.java
new file mode 100644
index 0000000..49baa70
--- /dev/null
+++ b/starters/karaf-boot-starter-ds/src/main/java/org/apache/karaf/boot/ds/impl/DsProcessor.java
@@ -0,0 +1,72 @@
+package org.apache.karaf.boot.ds.impl;
+
+import javax.annotation.processing.AbstractProcessor;
+import javax.annotation.processing.RoundEnvironment;
+import javax.lang.model.element.TypeElement;
+import javax.tools.Diagnostic.Kind;
+import javax.tools.FileObject;
+import javax.tools.StandardLocation;
+import java.io.CharArrayWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.Reader;
+import java.io.Writer;
+import java.util.HashSet;
+import java.util.Set;
+
+public class DsProcessor extends AbstractProcessor {
+
+ boolean hasRun;
+
+ public DsProcessor() {
+ }
+
+ @Override
+ public Set<String> getSupportedAnnotationTypes() {
+ Set<String> set = new HashSet<String>();
+ set.add(org.osgi.service.component.annotations.Component.class.getName());
+ return set;
+ }
+
+ @Override
+ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+ if (!hasRun) {
+ hasRun = true;
+ // Add the Karaf embedded package
+ try (PrintWriter w = appendResource("META-INF/org.apache.karaf.boot.bnd")) {
+ w.println("_dsannotations: *");
+ } catch (Exception e) {
+ processingEnv.getMessager().printMessage(Kind.ERROR, "Error: " + e.getMessage());
+ }
+ }
+ return true;
+ }
+
+ private PrintWriter appendResource(String resource) throws IOException {
+ try {
+ FileObject o = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", resource);
+ return new PrintWriter(o.openWriter());
+ } catch (Exception e) {
+ try {
+ FileObject o = processingEnv.getFiler().getResource(StandardLocation.CLASS_OUTPUT, "", resource);
+ CharArrayWriter baos = new CharArrayWriter();
+ try (Reader r = o.openReader(true)) {
+ char[] buf = new char[4096];
+ int l;
+ while ((l = r.read(buf)) > 0) {
+ baos.write(buf, 0, l);
+ }
+ }
+ o.delete();
+ o = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", resource);
+ Writer w = o.openWriter();
+ w.write(baos.toCharArray());
+ return new PrintWriter(w);
+ } catch (Exception e2) {
+ e2.addSuppressed(e);
+ e2.printStackTrace();
+ throw e2;
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/starters/karaf-boot-starter-ds/src/main/resources/META-INF/services/javax.annotation.processing.Processor
----------------------------------------------------------------------
diff --git a/starters/karaf-boot-starter-ds/src/main/resources/META-INF/services/javax.annotation.processing.Processor b/starters/karaf-boot-starter-ds/src/main/resources/META-INF/services/javax.annotation.processing.Processor
new file mode 100644
index 0000000..11ef8af
--- /dev/null
+++ b/starters/karaf-boot-starter-ds/src/main/resources/META-INF/services/javax.annotation.processing.Processor
@@ -0,0 +1 @@
+org.apache.karaf.boot.ds.impl.DsProcessor
[35/35] karaf-boot git commit: Fix initial build issue
Posted by cs...@apache.org.
Fix initial build issue
Project: http://git-wip-us.apache.org/repos/asf/karaf-boot/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-boot/commit/d941e864
Tree: http://git-wip-us.apache.org/repos/asf/karaf-boot/tree/d941e864
Diff: http://git-wip-us.apache.org/repos/asf/karaf-boot/diff/d941e864
Branch: refs/heads/master
Commit: d941e8643c1f30413d0060c8150e23364fa9a8a9
Parents: 6e4e7ed
Author: Jean-Baptiste Onofr� <jb...@apache.org>
Authored: Fri May 6 09:56:42 2016 +0200
Committer: Jean-Baptiste Onofr� <jb...@apache.org>
Committed: Fri May 6 09:56:42 2016 +0200
----------------------------------------------------------------------
pom.xml | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/d941e864/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 9127ab0..c1eb706 100644
--- a/pom.xml
+++ b/pom.xml
@@ -44,8 +44,9 @@
<!-- Archetypes -->
<!-- TODO archetypes -->
- <!-- Demos -->
- <module>samples</module>
+ <!-- Samples -->
+ <!-- As samples don't use karaf-boot parent pom, they should not be part of the reactor -->
+ <!-- <module>samples</module> -->
<!-- TODO complete library demos -->
</modules>
[12/35] karaf-boot git commit: Use correct started in blueprint
sample. Add README
Posted by cs...@apache.org.
Use correct started in blueprint sample. Add README
Project: http://git-wip-us.apache.org/repos/asf/karaf-boot/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-boot/commit/d68761ca
Tree: http://git-wip-us.apache.org/repos/asf/karaf-boot/tree/d68761ca
Diff: http://git-wip-us.apache.org/repos/asf/karaf-boot/diff/d68761ca
Branch: refs/heads/master
Commit: d68761cadd818e095794c1aa2c5507492c1d8ff8
Parents: dcdd4b4
Author: Jean-Baptiste Onofr� <jb...@apache.org>
Authored: Mon Nov 2 08:06:52 2015 +0100
Committer: Jean-Baptiste Onofr� <jb...@apache.org>
Committed: Mon Nov 2 08:06:52 2015 +0100
----------------------------------------------------------------------
.../README.md | 26 ++++++++++++++++++++
.../pom.xml | 5 ++--
2 files changed, 28 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/d68761ca/karaf-boot-samples/karaf-boot-sample-service-provider-blueprint/README.md
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-service-provider-blueprint/README.md b/karaf-boot-samples/karaf-boot-sample-service-provider-blueprint/README.md
new file mode 100644
index 0000000..07194df
--- /dev/null
+++ b/karaf-boot-samples/karaf-boot-sample-service-provider-blueprint/README.md
@@ -0,0 +1,26 @@
+== karaf-boot-sample-service-provider-blueprint ==
+
+This sample exposes an OSGi service using blueprint.
+
+= Design
+
+The service "contract" is describe by the Hello interface. It's a very simple service that expose one operation (hello).
+The service client send a message (String) to the hello service and he gets a response.
+
+The HelloServiceImpl is very simple: it prefixes the message with "Hello".
+
+We use a blueprint XML descriptor (for blueprint annotations, see the corresponding sample) in order to expose the service.
+
+= Build
+
+To build, simply do:
+
+ mvn clean install
+
+= Deploy
+
+* you can drop the generated jar file (target/karaf-boot-sample-service-provider-blueprint-1.0.jar) in the
+Karaf deploy folder
+* in the Karaf shell console, do:
+
+ bundle:install -s mvn:org.apache.karaf.boot/karaf-boot-sample-service-provider-blueprint/1.0
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/d68761ca/karaf-boot-samples/karaf-boot-sample-service-provider-blueprint/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-service-provider-blueprint/pom.xml b/karaf-boot-samples/karaf-boot-sample-service-provider-blueprint/pom.xml
index 4f0d59b..a9bfaac 100644
--- a/karaf-boot-samples/karaf-boot-sample-service-provider-blueprint/pom.xml
+++ b/karaf-boot-samples/karaf-boot-sample-service-provider-blueprint/pom.xml
@@ -27,11 +27,10 @@
<artifactId>karaf-boot-sample-service-provider-blueprint</artifactId>
<version>1.0.0-SNAPSHOT</version>
- <!-- TODO Change DS to blueprint-->
<dependencies>
<dependency>
<groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-starter-ds</artifactId>
+ <artifactId>karaf-boot-starter</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
@@ -47,4 +46,4 @@
</plugins>
</build>
-</project>
\ No newline at end of file
+</project>
[10/35] karaf-boot git commit: Fix build and introduce the samples
profile
Posted by cs...@apache.org.
Fix build and introduce the samples profile
Project: http://git-wip-us.apache.org/repos/asf/karaf-boot/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-boot/commit/c06650ca
Tree: http://git-wip-us.apache.org/repos/asf/karaf-boot/tree/c06650ca
Diff: http://git-wip-us.apache.org/repos/asf/karaf-boot/diff/c06650ca
Branch: refs/heads/master
Commit: c06650ca82ecbe3cc47a41b010f978fd9cd04fe9
Parents: eb034f8
Author: Jean-Baptiste Onofr� <jb...@apache.org>
Authored: Tue Oct 20 15:22:49 2015 +0200
Committer: Jean-Baptiste Onofr� <jb...@apache.org>
Committed: Tue Oct 20 15:22:49 2015 +0200
----------------------------------------------------------------------
.../sample.osgi.service.provider.Activator | 1 -
README.md | 13 +++++-
pom.xml | 47 +++++++++++---------
3 files changed, 39 insertions(+), 22 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/c06650ca/OSGI-INF/karaf-tracker/sample.osgi.service.provider.Activator
----------------------------------------------------------------------
diff --git a/OSGI-INF/karaf-tracker/sample.osgi.service.provider.Activator b/OSGI-INF/karaf-tracker/sample.osgi.service.provider.Activator
deleted file mode 100644
index 12b26d7..0000000
--- a/OSGI-INF/karaf-tracker/sample.osgi.service.provider.Activator
+++ /dev/null
@@ -1 +0,0 @@
-#Thu Sep 24 22:02:56 CEST 2015
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/c06650ca/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index 40eb582..8bbafbb 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,5 @@
Apache Karaf Boot
------------------
+=================
Karaf Boot provides an easy way to create artifacts ready to be deployed in Karaf, and also possibility to embed, configure, and bootstrap Karaf in a ready to run artifact.
@@ -10,3 +10,14 @@ Karaf Boot provides:
* set of dependencies providing annotations that you can use directly in your code: you focus on your business code, Karaf Boot does the rest
* a Maven plugin processing the annotations to create key turn artifacts
* an utility start to easily embed, configure, and bootstrap Karaf
+
+Building
+--------
+
+To build Karaf Boot, just do:
+
+ mvn clean install
+
+Once done, you can build the samples using:
+
+ mvn clean install -Psamples
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/c06650ca/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 8a42a00..922cc9a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -42,29 +42,36 @@
<!-- Archetypes -->
<!-- TODO archetypes -->
-
- <!-- Samples -->
- <!-- services -->
- <module>karaf-boot-samples/karaf-boot-sample-service-provider-osgi</module>
- <module>karaf-boot-samples/karaf-boot-sample-service-consumer-osgi</module>
- <module>karaf-boot-samples/karaf-boot-sample-service-provider-ds</module>
- <module>karaf-boot-samples/karaf-boot-sample-service-consumer-ds</module>
- <!-- blueprint -->
- <!-- cdi -->
- <!-- shell -->
- <module>karaf-boot-samples/karaf-boot-sample-shell</module>
- <!-- config -->
- <module>karaf-boot-samples/karaf-boot-sample-config</module>
- <!-- jpa -->
- <!-- servlet -->
- <module>karaf-boot-samples/karaf-boot-sample-servlet</module>
- <!-- webui / angular -->
- <!-- test -->
- <!-- rest & soap -->
- <!-- camel -->
<!-- Demos -->
<!-- TODO complete library demos -->
</modules>
+ <profiles>
+ <profile>
+ <id>samples</id>
+ <modules>
+ <!-- Samples -->
+ <!-- services -->
+ <module>karaf-boot-samples/karaf-boot-sample-service-provider-osgi</module>
+ <module>karaf-boot-samples/karaf-boot-sample-service-consumer-osgi</module>
+ <module>karaf-boot-samples/karaf-boot-sample-service-provider-ds</module>
+ <module>karaf-boot-samples/karaf-boot-sample-service-consumer-ds</module>
+ <!-- blueprint -->
+ <!-- cdi -->
+ <!-- shell -->
+ <module>karaf-boot-samples/karaf-boot-sample-shell</module>
+ <!-- config -->
+ <module>karaf-boot-samples/karaf-boot-sample-config</module>
+ <!-- jpa -->
+ <!-- servlet -->
+ <module>karaf-boot-samples/karaf-boot-sample-servlet</module>
+ <!-- webui / angular -->
+ <!-- test -->
+ <!-- rest & soap -->
+ <!-- camel -->
+ </modules>
+ </profile>
+ </profiles>
+
</project>
[08/35] karaf-boot git commit: Add karaf-boot-sample-config sample
Posted by cs...@apache.org.
Add karaf-boot-sample-config sample
Project: http://git-wip-us.apache.org/repos/asf/karaf-boot/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-boot/commit/1ea096cd
Tree: http://git-wip-us.apache.org/repos/asf/karaf-boot/tree/1ea096cd
Diff: http://git-wip-us.apache.org/repos/asf/karaf-boot/diff/1ea096cd
Branch: refs/heads/master
Commit: 1ea096cd69df985efc1c5b596ea4a0846c78cdd3
Parents: 1683f3c
Author: Jean-Baptiste Onofr� <jb...@apache.org>
Authored: Wed Oct 14 16:07:22 2015 +0200
Committer: Jean-Baptiste Onofr� <jb...@apache.org>
Committed: Wed Oct 14 16:07:22 2015 +0200
----------------------------------------------------------------------
.../karaf-boot-sample-config/README.md | 31 +++++++++++++
.../karaf-boot-sample-config/pom.xml | 47 ++++++++++++++++++++
.../java/sample/config/ConfigComponent.java | 43 ++++++++++++++++++
.../karaf-boot-starter-ds/pom.xml | 4 +-
.../apache/karaf/boot/maven/GenerateMojo.java | 1 +
pom.xml | 10 ++++-
6 files changed, 133 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/1ea096cd/karaf-boot-samples/karaf-boot-sample-config/README.md
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-config/README.md b/karaf-boot-samples/karaf-boot-sample-config/README.md
new file mode 100644
index 0000000..6f571d5
--- /dev/null
+++ b/karaf-boot-samples/karaf-boot-sample-config/README.md
@@ -0,0 +1,31 @@
+== karaf-boot-sample-config ==
+
+This sample shows how to use a configuration provided in the etc folder of Karaf, and directly use the
+properties values in your code.
+
+= Design
+
+The ConfigComponent use a SampleConfig configuration. The SampleConfig configuration is "injected" at activation
+time of the component.
+
+The component just displays the values of the properties.
+
+= Build
+
+To build, simply do:
+
+ mvn clean install
+
+= Deploy
+
+To deploy in Karaf, you have to enable the DS support first. For that, you have to install the scr feature:
+
+ feature:install scr
+
+Once scr feature installed:
+
+* you can drop the generated jar file (target/karaf-boot-sample-config-1.0.jar) in the
+Karaf deploy folder
+* in the Karaf shell console, do:
+
+ bundle:install -s mvn:karaf-boot-samples/karaf-boot-sample-config/1.0
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/1ea096cd/karaf-boot-samples/karaf-boot-sample-config/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-config/pom.xml b/karaf-boot-samples/karaf-boot-sample-config/pom.xml
new file mode 100644
index 0000000..688150b
--- /dev/null
+++ b/karaf-boot-samples/karaf-boot-sample-config/pom.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+
+ <!--
+
+ 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.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-sample-config</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-starter-ds</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-maven-plugin</artifactId>
+ <version>${project.version}</version>
+ <extensions>true</extensions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/1ea096cd/karaf-boot-samples/karaf-boot-sample-config/src/main/java/sample/config/ConfigComponent.java
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-config/src/main/java/sample/config/ConfigComponent.java b/karaf-boot-samples/karaf-boot-sample-config/src/main/java/sample/config/ConfigComponent.java
new file mode 100644
index 0000000..52cf369
--- /dev/null
+++ b/karaf-boot-samples/karaf-boot-sample-config/src/main/java/sample/config/ConfigComponent.java
@@ -0,0 +1,43 @@
+/**
+ * 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 sample.config;
+
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.metatype.annotations.Designate;
+import org.osgi.service.metatype.annotations.ObjectClassDefinition;
+
+@ObjectClassDefinition(name = "Sample Configuration", pid = "org.apache.karaf.boot.sample.config")
+@interface SampleConfig {
+ String stringProperty() default "default";
+ int intProperty() default 0;
+ boolean booleanProperty() default false;
+}
+
+@Component
+@Designate(ocd = SampleConfig.class)
+public class ConfigComponent {
+
+ @Activate
+ public void activate(SampleConfig sampleConfig) {
+ System.out.println("We use the property there");
+ System.out.println("stringProperty:" + sampleConfig.stringProperty());
+ System.out.println("intProperty: " + sampleConfig.intProperty());
+ System.out.println("booleanProperty: " + sampleConfig.booleanProperty());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/1ea096cd/karaf-boot-starters/karaf-boot-starter-ds/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-starters/karaf-boot-starter-ds/pom.xml b/karaf-boot-starters/karaf-boot-starter-ds/pom.xml
index 9add66a..09eb983 100644
--- a/karaf-boot-starters/karaf-boot-starter-ds/pom.xml
+++ b/karaf-boot-starters/karaf-boot-starter-ds/pom.xml
@@ -33,8 +33,8 @@
<dependencies>
<dependency>
<groupId>org.osgi</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- <version>5.0.0</version>
+ <artifactId>osgi.cmpn</artifactId>
+ <version>${osgi.version}</version>
</dependency>
</dependencies>
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/1ea096cd/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/maven/GenerateMojo.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/maven/GenerateMojo.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/maven/GenerateMojo.java
index da9414d..f15dad3 100644
--- a/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/maven/GenerateMojo.java
+++ b/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/maven/GenerateMojo.java
@@ -58,6 +58,7 @@ public class GenerateMojo extends AbstractMojo {
felixBundlePlugin.setVersion("3.0.0");
felixBundlePlugin.setInherited(true);
felixBundlePlugin.setExtensions(true);
+ // TODO check if a osgi.bnd file is present in the project base directory
// TODO if jpa-start is provided as persistence.xml location
configuration = Xpp3DomBuilder.build(new ByteArrayInputStream(("<configuration>" +
"<finalName>${project.build.finalName}</finalName>" +
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/1ea096cd/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index cb5e826..b1bab33 100644
--- a/pom.xml
+++ b/pom.xml
@@ -30,7 +30,7 @@
</description>
<properties>
- <karaf.version>4.0.1</karaf.version>
+ <karaf.version>4.0.2</karaf.version>
<osgi.version>6.0.0</osgi.version>
</properties>
@@ -40,7 +40,10 @@
<!-- TODO reuse @Services & @Reference shell annotations for generic use cases -->
+ <!-- Archetypes -->
+
<!-- Samples -->
+ <!-- services -->
<module>karaf-boot-samples/karaf-boot-sample-service-provider-osgi</module>
<module>karaf-boot-samples/karaf-boot-sample-service-consumer-osgi</module>
<module>karaf-boot-samples/karaf-boot-sample-service-provider-ds</module>
@@ -50,11 +53,16 @@
<!-- shell -->
<module>karaf-boot-samples/karaf-boot-sample-shell</module>
<!-- config -->
+ <module>karaf-boot-samples/karaf-boot-sample-config</module>
<!-- jpa -->
<!-- servlet -->
+ <!-- webui / angular -->
<!-- test -->
<!-- rest & soap -->
<!-- camel -->
+
+ <!-- Demos -->
+ <!-- complete library demos -->
</modules>
</project>
[19/35] karaf-boot git commit: [cdi] Provides a CDI starter and
example
Posted by cs...@apache.org.
[cdi] Provides a CDI starter and example
Project: http://git-wip-us.apache.org/repos/asf/karaf-boot/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-boot/commit/1d2b7741
Tree: http://git-wip-us.apache.org/repos/asf/karaf-boot/tree/1d2b7741
Diff: http://git-wip-us.apache.org/repos/asf/karaf-boot/diff/1d2b7741
Branch: refs/heads/master
Commit: 1d2b774123ed025d52bf08c1ec6462b637400506
Parents: 93af001
Author: Guillaume Nodet <gn...@apache.org>
Authored: Fri Apr 15 16:39:32 2016 +0200
Committer: Guillaume Nodet <gn...@apache.org>
Committed: Fri Apr 15 16:39:32 2016 +0200
----------------------------------------------------------------------
.../karaf-boot-sample-cdi/README.md | 23 ++++++
.../karaf-boot-sample-cdi/pom.xml | 47 +++++++++++
.../main/java/sample/cdi/IceCreamService.java | 6 ++
.../java/sample/cdi/impl/VanillaService.java | 45 +++++++++++
.../karaf-boot-starter-cdi/pom.xml | 67 ++++++++++++++++
.../karaf/boot/cdi/impl/CdiProcessor.java | 82 ++++++++++++++++++++
.../javax.annotation.processing.Processor | 1 +
karaf-boot-starters/pom.xml | 1 +
pom.xml | 1 +
9 files changed, 273 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/1d2b7741/karaf-boot-samples/karaf-boot-sample-cdi/README.md
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-cdi/README.md b/karaf-boot-samples/karaf-boot-sample-cdi/README.md
new file mode 100644
index 0000000..1f98cac
--- /dev/null
+++ b/karaf-boot-samples/karaf-boot-sample-cdi/README.md
@@ -0,0 +1,23 @@
+== karaf-boot-sample-cdi ==
+
+This sample shows how to define a CDI bundle.
+
+= Design
+
+TODO.
+
+= Build
+
+To build, simply do:
+
+ mvn clean install
+
+= Deploy
+
+To deploy i:
+
+* you can drop the generated jar file (target/karaf-boot-sample-cdi-1.0.jar) in the
+Karaf deploy folder
+* in the Karaf shell console, do:
+
+ bundle:install -s mvn:org.apache.karaf.boot/karaf-boot-sample-cdi/1.0
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/1d2b7741/karaf-boot-samples/karaf-boot-sample-cdi/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-cdi/pom.xml b/karaf-boot-samples/karaf-boot-sample-cdi/pom.xml
new file mode 100644
index 0000000..d627b6e
--- /dev/null
+++ b/karaf-boot-samples/karaf-boot-sample-cdi/pom.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+
+ <!--
+
+ 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.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-sample-cdi</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-starter-cdi</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-maven-plugin</artifactId>
+ <version>${project.version}</version>
+ <extensions>true</extensions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/1d2b7741/karaf-boot-samples/karaf-boot-sample-cdi/src/main/java/sample/cdi/IceCreamService.java
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-cdi/src/main/java/sample/cdi/IceCreamService.java b/karaf-boot-samples/karaf-boot-sample-cdi/src/main/java/sample/cdi/IceCreamService.java
new file mode 100644
index 0000000..5f9cfac
--- /dev/null
+++ b/karaf-boot-samples/karaf-boot-sample-cdi/src/main/java/sample/cdi/IceCreamService.java
@@ -0,0 +1,6 @@
+package sample.cdi;
+
+public interface IceCreamService {
+
+ String getFlavour();
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/1d2b7741/karaf-boot-samples/karaf-boot-sample-cdi/src/main/java/sample/cdi/impl/VanillaService.java
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-cdi/src/main/java/sample/cdi/impl/VanillaService.java b/karaf-boot-samples/karaf-boot-sample-cdi/src/main/java/sample/cdi/impl/VanillaService.java
new file mode 100644
index 0000000..3007035
--- /dev/null
+++ b/karaf-boot-samples/karaf-boot-sample-cdi/src/main/java/sample/cdi/impl/VanillaService.java
@@ -0,0 +1,45 @@
+/**
+ * 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 sample.cdi.impl;
+
+import javax.annotation.PostConstruct;
+import javax.enterprise.context.ApplicationScoped;
+
+import org.ops4j.pax.cdi.api.OsgiServiceProvider;
+import org.ops4j.pax.cdi.api.Properties;
+import org.ops4j.pax.cdi.api.Property;
+import sample.cdi.IceCreamService;
+
+@OsgiServiceProvider(classes = { VanillaService.class, IceCreamService.class })
+@Properties(@Property(name = "flavour", value = "vanilla"))
+@ApplicationScoped
+class VanillaService implements IceCreamService {
+
+ private boolean initialized;
+
+ @PostConstruct
+ public void init() {
+ initialized = true;
+ }
+
+ public String getFlavour() {
+ if (!initialized) {
+ throw new AssertionError("VanillaService is not initialized");
+ }
+ return "Vanilla";
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/1d2b7741/karaf-boot-starters/karaf-boot-starter-cdi/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-starters/karaf-boot-starter-cdi/pom.xml b/karaf-boot-starters/karaf-boot-starter-cdi/pom.xml
new file mode 100644
index 0000000..3f33d28
--- /dev/null
+++ b/karaf-boot-starters/karaf-boot-starter-cdi/pom.xml
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+
+ <!--
+
+ 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.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-starters</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>karaf-boot-starter-cdi</artifactId>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>osgi.cmpn</artifactId>
+ <version>${osgi.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.cdi</groupId>
+ <artifactId>pax-cdi-api</artifactId>
+ <version>${pax.cdi.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.enterprise</groupId>
+ <artifactId>cdi-api</artifactId>
+ <version>1.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-atinject_1.0_spec</artifactId>
+ <version>1.0</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <compilerArgument>-proc:none</compilerArgument>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/1d2b7741/karaf-boot-starters/karaf-boot-starter-cdi/src/main/java/org/apache/karaf/boot/cdi/impl/CdiProcessor.java
----------------------------------------------------------------------
diff --git a/karaf-boot-starters/karaf-boot-starter-cdi/src/main/java/org/apache/karaf/boot/cdi/impl/CdiProcessor.java b/karaf-boot-starters/karaf-boot-starter-cdi/src/main/java/org/apache/karaf/boot/cdi/impl/CdiProcessor.java
new file mode 100644
index 0000000..44cc571
--- /dev/null
+++ b/karaf-boot-starters/karaf-boot-starter-cdi/src/main/java/org/apache/karaf/boot/cdi/impl/CdiProcessor.java
@@ -0,0 +1,82 @@
+package org.apache.karaf.boot.cdi.impl;
+
+import javax.annotation.processing.AbstractProcessor;
+import javax.annotation.processing.RoundEnvironment;
+import javax.lang.model.element.TypeElement;
+import javax.tools.Diagnostic.Kind;
+import javax.tools.FileObject;
+import javax.tools.StandardLocation;
+import java.io.ByteArrayOutputStream;
+import java.io.CharArrayWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PrintWriter;
+import java.io.Reader;
+import java.io.Writer;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.ops4j.pax.cdi.api.OsgiServiceProvider;
+
+public class CdiProcessor extends AbstractProcessor {
+
+ boolean hasRun;
+
+ public CdiProcessor() {
+ }
+
+ @Override
+ public Set<String> getSupportedAnnotationTypes() {
+ Set<String> set = new HashSet<String>();
+ set.add(OsgiServiceProvider.class.getName());
+ return set;
+ }
+
+ @Override
+ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+ if (!hasRun) {
+ hasRun = true;
+ // Make sure we have a META-INF/beans.xml file present
+ try (PrintWriter w = appendResource("META-INF/beans.xml")) {
+ processingEnv.getMessager().printMessage(Kind.NOTE, "Generated META-INF/beans.xml");
+ } catch (Exception e) {
+ processingEnv.getMessager().printMessage(Kind.ERROR, "Error: " + e.getMessage());
+ }
+ // Add the CDI requirement
+ try (PrintWriter w = appendResource("META-INF/org.apache.karaf.boot.bnd")) {
+ w.println("Require-Capability: osgi.extender; filter:=\"(osgi.extender=pax.cdi)\"");
+ } catch (Exception e) {
+ processingEnv.getMessager().printMessage(Kind.ERROR, "Error: " + e.getMessage());
+ }
+ }
+ return true;
+ }
+
+ private PrintWriter appendResource(String resource) throws IOException {
+ try {
+ FileObject o = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", resource);
+ return new PrintWriter(o.openWriter());
+ } catch (Exception e) {
+ try {
+ FileObject o = processingEnv.getFiler().getResource(StandardLocation.CLASS_OUTPUT, "", resource);
+ CharArrayWriter baos = new CharArrayWriter();
+ try (Reader r = o.openReader(true)) {
+ char[] buf = new char[4096];
+ int l;
+ while ((l = r.read(buf)) > 0) {
+ baos.write(buf, 0, l);
+ }
+ }
+ o.delete();
+ o = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", resource);
+ Writer w = o.openWriter();
+ w.write(baos.toCharArray());
+ return new PrintWriter(w);
+ } catch (Exception e2) {
+ e2.addSuppressed(e);
+ e2.printStackTrace();
+ throw e2;
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/1d2b7741/karaf-boot-starters/karaf-boot-starter-cdi/src/main/resources/META-INF/services/javax.annotation.processing.Processor
----------------------------------------------------------------------
diff --git a/karaf-boot-starters/karaf-boot-starter-cdi/src/main/resources/META-INF/services/javax.annotation.processing.Processor b/karaf-boot-starters/karaf-boot-starter-cdi/src/main/resources/META-INF/services/javax.annotation.processing.Processor
new file mode 100644
index 0000000..a6cd494
--- /dev/null
+++ b/karaf-boot-starters/karaf-boot-starter-cdi/src/main/resources/META-INF/services/javax.annotation.processing.Processor
@@ -0,0 +1 @@
+org.apache.karaf.boot.cdi.impl.CdiProcessor
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/1d2b7741/karaf-boot-starters/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-starters/pom.xml b/karaf-boot-starters/pom.xml
index 8a22ae1..e50f6c2 100644
--- a/karaf-boot-starters/pom.xml
+++ b/karaf-boot-starters/pom.xml
@@ -37,6 +37,7 @@
<module>karaf-boot-starter-shell</module>
<module>karaf-boot-starter-web</module>
<module>karaf-boot-starter-jpa</module>
+ <module>karaf-boot-starter-cdi</module>
</modules>
</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/1d2b7741/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 5e1e5c8..ca1f26e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -32,6 +32,7 @@
<properties>
<karaf.version>4.0.2</karaf.version>
<osgi.version>6.0.0</osgi.version>
+ <pax.cdi.version>1.0.0.RC1</pax.cdi.version>
</properties>
<modules>
[16/35] karaf-boot git commit: [jpa] Add example to the build
Posted by cs...@apache.org.
[jpa] Add example to the build
Project: http://git-wip-us.apache.org/repos/asf/karaf-boot/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-boot/commit/222b024a
Tree: http://git-wip-us.apache.org/repos/asf/karaf-boot/tree/222b024a
Diff: http://git-wip-us.apache.org/repos/asf/karaf-boot/diff/222b024a
Branch: refs/heads/master
Commit: 222b024ae73e343bb7e167b93aa0593f62a87f13
Parents: dceec8d
Author: Guillaume Nodet <gn...@apache.org>
Authored: Fri Apr 15 15:20:59 2016 +0200
Committer: Guillaume Nodet <gn...@apache.org>
Committed: Fri Apr 15 15:20:59 2016 +0200
----------------------------------------------------------------------
pom.xml | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/222b024a/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 1161390..afd1bd6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -66,6 +66,7 @@
<!-- config -->
<module>karaf-boot-samples/karaf-boot-sample-config</module>
<!-- jpa -->
+ <module>karaf-boot-samples/karaf-boot-sample-jpa</module>
<!-- servlet -->
<module>karaf-boot-samples/karaf-boot-sample-servlet</module>
<!-- webui / angular -->
[11/35] karaf-boot git commit: Added a blueprint service sample
Posted by cs...@apache.org.
Added a blueprint service sample
Project: http://git-wip-us.apache.org/repos/asf/karaf-boot/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-boot/commit/dcdd4b4c
Tree: http://git-wip-us.apache.org/repos/asf/karaf-boot/tree/dcdd4b4c
Diff: http://git-wip-us.apache.org/repos/asf/karaf-boot/diff/dcdd4b4c
Branch: refs/heads/master
Commit: dcdd4b4cdbb58a69118f60bd6eafaab8abd42f1a
Parents: c06650c
Author: Morgan Hautman <mo...@gmail.com>
Authored: Wed Oct 28 16:37:30 2015 +0100
Committer: Morgan Hautman <mo...@gmail.com>
Committed: Wed Oct 28 16:37:30 2015 +0100
----------------------------------------------------------------------
.../pom.xml | 51 ++++++++++++++++++++
.../blueprint/service/consumer/HelloClient.java | 38 +++++++++++++++
.../resources/OSGI-INF/blueprint/config.xml | 26 ++++++++++
.../pom.xml | 50 +++++++++++++++++++
.../service/provider/HelloService.java | 25 ++++++++++
.../service/provider/HelloServiceImpl.java | 30 ++++++++++++
.../resources/OSGI-INF/blueprint/config.xml | 26 ++++++++++
pom.xml | 2 +
8 files changed, 248 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/dcdd4b4c/karaf-boot-samples/karaf-boot-sample-service-consumer-blueprint/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-service-consumer-blueprint/pom.xml b/karaf-boot-samples/karaf-boot-sample-service-consumer-blueprint/pom.xml
new file mode 100644
index 0000000..eee6bb9
--- /dev/null
+++ b/karaf-boot-samples/karaf-boot-sample-service-consumer-blueprint/pom.xml
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+
+ <!--
+ 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.
+-->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-sample-service-consumer-blueprint</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-starter</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-sample-service-provider-blueprint</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-maven-plugin</artifactId>
+ <version>${project.version}</version>
+ <extensions>true</extensions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/dcdd4b4c/karaf-boot-samples/karaf-boot-sample-service-consumer-blueprint/src/main/java/sample/blueprint/service/consumer/HelloClient.java
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-service-consumer-blueprint/src/main/java/sample/blueprint/service/consumer/HelloClient.java b/karaf-boot-samples/karaf-boot-sample-service-consumer-blueprint/src/main/java/sample/blueprint/service/consumer/HelloClient.java
new file mode 100644
index 0000000..0459ab9
--- /dev/null
+++ b/karaf-boot-samples/karaf-boot-sample-service-consumer-blueprint/src/main/java/sample/blueprint/service/consumer/HelloClient.java
@@ -0,0 +1,38 @@
+/**
+ * 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 sample.blueprint.service.consumer;
+
+import sample.blueprint.service.provider.HelloService;
+
+public class HelloClient {
+
+ HelloService helloService = null;
+
+ public void startUp() {
+ System.out.println(helloService.hello("World"));
+ }
+
+ public HelloService getHelloWorldService() {
+ return helloService;
+ }
+
+ public void setHelloWorldService(HelloService helloWorldService) {
+ this.helloService = helloWorldService;
+
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/dcdd4b4c/karaf-boot-samples/karaf-boot-sample-service-consumer-blueprint/src/main/resources/OSGI-INF/blueprint/config.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-service-consumer-blueprint/src/main/resources/OSGI-INF/blueprint/config.xml b/karaf-boot-samples/karaf-boot-sample-service-consumer-blueprint/src/main/resources/OSGI-INF/blueprint/config.xml
new file mode 100644
index 0000000..ccd26d8
--- /dev/null
+++ b/karaf-boot-samples/karaf-boot-sample-service-consumer-blueprint/src/main/resources/OSGI-INF/blueprint/config.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ 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.
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+
+ <reference id="helloservice"
+ interface="sample.blueprint.service.provider.HelloService" />
+
+
+ <bean id="helloclient" class="sample.blueprint.service.consumer.HelloClient"
+ init-method="startUp">
+ <property name="helloWorldService" ref="helloservice" />
+ </bean>
+</blueprint>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/dcdd4b4c/karaf-boot-samples/karaf-boot-sample-service-provider-blueprint/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-service-provider-blueprint/pom.xml b/karaf-boot-samples/karaf-boot-sample-service-provider-blueprint/pom.xml
new file mode 100644
index 0000000..4f0d59b
--- /dev/null
+++ b/karaf-boot-samples/karaf-boot-sample-service-provider-blueprint/pom.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+
+ <!--
+
+ 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.
+-->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-sample-service-provider-blueprint</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+
+ <!-- TODO Change DS to blueprint-->
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-starter-ds</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-maven-plugin</artifactId>
+ <version>${project.version}</version>
+ <extensions>true</extensions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/dcdd4b4c/karaf-boot-samples/karaf-boot-sample-service-provider-blueprint/src/main/java/sample/blueprint/service/provider/HelloService.java
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-service-provider-blueprint/src/main/java/sample/blueprint/service/provider/HelloService.java b/karaf-boot-samples/karaf-boot-sample-service-provider-blueprint/src/main/java/sample/blueprint/service/provider/HelloService.java
new file mode 100644
index 0000000..2555069
--- /dev/null
+++ b/karaf-boot-samples/karaf-boot-sample-service-provider-blueprint/src/main/java/sample/blueprint/service/provider/HelloService.java
@@ -0,0 +1,25 @@
+/**
+ * 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 sample.blueprint.service.provider;
+
+public interface HelloService {
+
+ public String hello(String message);
+
+ public void startUp();
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/dcdd4b4c/karaf-boot-samples/karaf-boot-sample-service-provider-blueprint/src/main/java/sample/blueprint/service/provider/HelloServiceImpl.java
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-service-provider-blueprint/src/main/java/sample/blueprint/service/provider/HelloServiceImpl.java b/karaf-boot-samples/karaf-boot-sample-service-provider-blueprint/src/main/java/sample/blueprint/service/provider/HelloServiceImpl.java
new file mode 100644
index 0000000..4f97468
--- /dev/null
+++ b/karaf-boot-samples/karaf-boot-sample-service-provider-blueprint/src/main/java/sample/blueprint/service/provider/HelloServiceImpl.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 sample.blueprint.service.provider;
+
+public class HelloServiceImpl implements HelloService{
+
+ public String hello(String message) {
+ return "Hello " + message + " !";
+ }
+
+ public void startUp() {
+ System.out.println("I'm starting up!");
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/dcdd4b4c/karaf-boot-samples/karaf-boot-sample-service-provider-blueprint/src/main/resources/OSGI-INF/blueprint/config.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-service-provider-blueprint/src/main/resources/OSGI-INF/blueprint/config.xml b/karaf-boot-samples/karaf-boot-sample-service-provider-blueprint/src/main/resources/OSGI-INF/blueprint/config.xml
new file mode 100644
index 0000000..f85ae0a
--- /dev/null
+++ b/karaf-boot-samples/karaf-boot-sample-service-provider-blueprint/src/main/resources/OSGI-INF/blueprint/config.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ 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.
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+
+ <bean id="helloservice"
+ class="sample.blueprint.service.provider.HelloServiceImpl"
+ init-method="startUp" >
+ </bean>
+
+ <service ref="helloservice"
+ interface="sample.blueprint.service.provider.HelloService" />
+
+</blueprint>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/dcdd4b4c/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 922cc9a..1161390 100644
--- a/pom.xml
+++ b/pom.xml
@@ -58,6 +58,8 @@
<module>karaf-boot-samples/karaf-boot-sample-service-provider-ds</module>
<module>karaf-boot-samples/karaf-boot-sample-service-consumer-ds</module>
<!-- blueprint -->
+ <module>karaf-boot-samples/karaf-boot-sample-service-provider-blueprint</module>
+ <module>karaf-boot-samples/karaf-boot-sample-service-consumer-blueprint</module>
<!-- cdi -->
<!-- shell -->
<module>karaf-boot-samples/karaf-boot-sample-shell</module>
[13/35] karaf-boot git commit: JPA persistence.xml generation
Posted by cs...@apache.org.
JPA persistence.xml generation
Project: http://git-wip-us.apache.org/repos/asf/karaf-boot/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-boot/commit/dd56eb85
Tree: http://git-wip-us.apache.org/repos/asf/karaf-boot/tree/dd56eb85
Diff: http://git-wip-us.apache.org/repos/asf/karaf-boot/diff/dd56eb85
Branch: refs/heads/master
Commit: dd56eb8539118c462e55564becf8f1a647cf53d6
Parents: d68761c
Author: Guillaume Nodet <gn...@apache.org>
Authored: Thu Apr 14 20:35:17 2016 +0200
Committer: Guillaume Nodet <gn...@apache.org>
Committed: Thu Apr 14 20:37:55 2016 +0200
----------------------------------------------------------------------
.../karaf-boot-starter-jpa/pom.xml | 57 ++++++++
.../org/apache/karaf/boot/jpa/EclipseLink.java | 4 +
.../org/apache/karaf/boot/jpa/Hibernate.java | 93 ++++++++++++
.../java/org/apache/karaf/boot/jpa/OpenJpa.java | 38 +++++
.../apache/karaf/boot/jpa/PersistentUnit.java | 36 +++++
.../org/apache/karaf/boot/jpa/Property.java | 13 ++
.../org/apache/karaf/boot/jpa/Provider.java | 10 ++
.../apache/karaf/boot/jpa/TransactionType.java | 6 +
.../karaf/boot/jpa/impl/JpaProcessor.java | 140 +++++++++++++++++++
.../javax.annotation.processing.Processor | 1 +
karaf-boot-starters/pom.xml | 1 +
11 files changed, 399 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/dd56eb85/karaf-boot-starters/karaf-boot-starter-jpa/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-starters/karaf-boot-starter-jpa/pom.xml b/karaf-boot-starters/karaf-boot-starter-jpa/pom.xml
new file mode 100644
index 0000000..c0ce5b8
--- /dev/null
+++ b/karaf-boot-starters/karaf-boot-starter-jpa/pom.xml
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+
+ <!--
+
+ 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.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-starters</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>karaf-boot-starter-jpa</artifactId>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>osgi.cmpn</artifactId>
+ <version>${osgi.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jpa_2.0_spec</artifactId>
+ <version>1.1</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <compilerArgument>-proc:none</compilerArgument>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/dd56eb85/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/EclipseLink.java
----------------------------------------------------------------------
diff --git a/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/EclipseLink.java b/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/EclipseLink.java
new file mode 100644
index 0000000..f1cba0d
--- /dev/null
+++ b/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/EclipseLink.java
@@ -0,0 +1,4 @@
+package org.apache.karaf.boot.jpa;
+
+public interface EclipseLink {
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/dd56eb85/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/Hibernate.java
----------------------------------------------------------------------
diff --git a/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/Hibernate.java b/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/Hibernate.java
new file mode 100644
index 0000000..06361d4
--- /dev/null
+++ b/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/Hibernate.java
@@ -0,0 +1,93 @@
+package org.apache.karaf.boot.jpa;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import org.apache.karaf.boot.jpa.PersistentUnit.ProviderProperty;
+
+public interface Hibernate {
+
+ @ProviderProperty("hibernate.query.substitutions")
+ @Target(ElementType.TYPE)
+ @Retention(RetentionPolicy.SOURCE)
+ @interface QuerySubstitutions {
+ String value();
+ }
+
+ @ProviderProperty("hibernate.hbm2ddl.auto")
+ @Target(ElementType.TYPE)
+ @Retention(RetentionPolicy.SOURCE)
+ @interface Hbm2DdlAuto {
+ Hbm2DdlAutoType value();
+ }
+
+ @ProviderProperty("hibernate.dialect")
+ @Target(ElementType.TYPE)
+ @Retention(RetentionPolicy.SOURCE)
+ @interface Dialect {
+ DialectType value();
+ }
+
+ enum DialectType {
+ Cache71,
+ DataDirectOracle9,
+ DB2390,
+ DB2400,
+ DB2,
+ Derby,
+ Firebird,
+ FrontBase,
+ H2,
+ HSQL,
+ Informix,
+ Ingres10,
+ Ingres9,
+ Ingres,
+ Interbase,
+ JDataStore,
+ Mckoi,
+ MimerSQL,
+ MySQL5,
+ MySQL5InnoDB,
+ MySQL,
+ MySQLInnoDB,
+ MySQLMyISAM,
+ Oracle10g,
+ Oracle8i,
+ Oracle9,
+ Oracle9i,
+ Oracle,
+ Pointbase,
+ PostgresPlus,
+ PostgreSQL,
+ Progress,
+ RDMSOS2200,
+ SAPDB,
+ SQLServer2008,
+ SQLServer,
+ Sybase11,
+ SybaseAnywhere,
+ SybaseASE15,
+ Sybase,
+ Teradata,
+ TimesTen;
+
+ public String toString() {
+ return "org.hibernate.dialect." + super.toString() + "Dialect";
+ }
+ }
+
+ enum Hbm2DdlAutoType {
+ Validate,
+ Update,
+ Create,
+ CreateDrop;
+
+ public String toString() {
+ return super.toString().toLowerCase();
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/dd56eb85/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/OpenJpa.java
----------------------------------------------------------------------
diff --git a/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/OpenJpa.java b/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/OpenJpa.java
new file mode 100644
index 0000000..01186fc
--- /dev/null
+++ b/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/OpenJpa.java
@@ -0,0 +1,38 @@
+package org.apache.karaf.boot.jpa;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import org.apache.karaf.boot.jpa.PersistentUnit.ProviderProperty;
+
+public interface OpenJpa {
+
+ @ProviderProperty("openjpa.AutoClear")
+ @Target(ElementType.TYPE)
+ @Retention(RetentionPolicy.SOURCE)
+ @interface AutoClear {
+ Value value();
+ enum Value {
+ Datastore, All;
+ public String toString() {
+ return super.toString().toLowerCase();
+ }
+ }
+ }
+
+ @ProviderProperty("openjpa.AutoDetach")
+ @Target(ElementType.TYPE)
+ @Retention(RetentionPolicy.SOURCE)
+ @interface AutoDetach {
+ Value value();
+ enum Value {
+ Close, Commit, Nontx_Read;
+ public String toString() {
+ return super.toString().toLowerCase().replace('_', '-');
+ }
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/dd56eb85/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/PersistentUnit.java
----------------------------------------------------------------------
diff --git a/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/PersistentUnit.java b/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/PersistentUnit.java
new file mode 100644
index 0000000..ada2ef3
--- /dev/null
+++ b/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/PersistentUnit.java
@@ -0,0 +1,36 @@
+package org.apache.karaf.boot.jpa;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.SOURCE)
+public @interface PersistentUnit {
+
+ String name();
+
+ String description() default "";
+
+ TransactionType transactionType() default TransactionType.RESOURCE_LOCAL;
+
+ Provider provider() default Provider.Default;
+
+ String providerName() default "";
+
+ String jtaDataSource() default "";
+
+ String nonJtaDataSource() default "";
+
+ // TODO: mapping-file, jar-file, class, exclude-unlisted-classes, shared-cache-mode, validation-mode
+
+ Property[] properties() default {};
+
+
+ @Target(ElementType.ANNOTATION_TYPE)
+ @interface ProviderProperty {
+ String value();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/dd56eb85/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/Property.java
----------------------------------------------------------------------
diff --git a/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/Property.java b/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/Property.java
new file mode 100644
index 0000000..5cce58c
--- /dev/null
+++ b/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/Property.java
@@ -0,0 +1,13 @@
+package org.apache.karaf.boot.jpa;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+@Retention(RetentionPolicy.SOURCE)
+public @interface Property {
+
+ String name();
+
+ String value();
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/dd56eb85/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/Provider.java
----------------------------------------------------------------------
diff --git a/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/Provider.java b/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/Provider.java
new file mode 100644
index 0000000..13a62d4
--- /dev/null
+++ b/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/Provider.java
@@ -0,0 +1,10 @@
+package org.apache.karaf.boot.jpa;
+
+public enum Provider {
+
+ Default,
+ Hibernate,
+ OpenJpa,
+ EclipseLink;
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/dd56eb85/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/TransactionType.java
----------------------------------------------------------------------
diff --git a/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/TransactionType.java b/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/TransactionType.java
new file mode 100644
index 0000000..53e76d2
--- /dev/null
+++ b/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/TransactionType.java
@@ -0,0 +1,6 @@
+package org.apache.karaf.boot.jpa;
+
+public enum TransactionType {
+ RESOURCE_LOCAL,
+ JTA
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/dd56eb85/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/impl/JpaProcessor.java
----------------------------------------------------------------------
diff --git a/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/impl/JpaProcessor.java b/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/impl/JpaProcessor.java
new file mode 100644
index 0000000..4becbc2
--- /dev/null
+++ b/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/impl/JpaProcessor.java
@@ -0,0 +1,140 @@
+package org.apache.karaf.boot.jpa.impl;
+
+import javax.annotation.processing.AbstractProcessor;
+import javax.annotation.processing.Messager;
+import javax.annotation.processing.RoundEnvironment;
+import javax.lang.model.element.AnnotationMirror;
+import javax.lang.model.element.AnnotationValue;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.TypeElement;
+import javax.tools.Diagnostic.Kind;
+import javax.tools.FileObject;
+import javax.tools.StandardLocation;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.karaf.boot.jpa.PersistentUnit;
+import org.apache.karaf.boot.jpa.Property;
+import org.apache.karaf.boot.jpa.Provider;
+
+public class JpaProcessor extends AbstractProcessor {
+
+ public JpaProcessor() {
+ }
+
+ @Override
+ public Set<String> getSupportedAnnotationTypes() {
+ return new HashSet<String>(Arrays.asList(
+ PersistentUnit.class.getName()
+ ));
+ }
+
+ @Override
+ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+ Map<PersistentUnit, List<? extends AnnotationMirror>> units = new HashMap<PersistentUnit, List<? extends AnnotationMirror>>();
+
+
+ for (Element elem : roundEnv.getElementsAnnotatedWith(PersistentUnit.class)) {
+ PersistentUnit pu = elem.getAnnotation(PersistentUnit.class);
+ units.put(pu, elem.getAnnotationMirrors());
+ }
+ if (!units.isEmpty()) {
+ try {
+ Set<String> puNames = new HashSet<String>();
+ FileObject o = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT,
+ "", "META-INF/persistence.xml");
+ PrintWriter w = new PrintWriter(o.openWriter());
+ w.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
+ w.println("<persistence version=\"2.0\" xmlns=\"http://java.sun.com/xml/ns/persistence\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd\">");
+ for (PersistentUnit pu : units.keySet()) {
+ if (pu.name() == null || pu.name().isEmpty()) {
+ throw new IOException("Missing persistent unit name");
+ }
+ if (!puNames.add(pu.name())) {
+ throw new IOException("Duplicate persistent unit name: " + pu.name());
+ }
+ w.println(" <persistence-unit name=\"" + pu.name() + "\" transaction-type=\"" + pu.transactionType().toString() + "\">");
+ if (!pu.description().isEmpty()) {
+ w.println(" <description>" + pu.description() + "</description>");
+ }
+ if (pu.provider() != Provider.Default || !pu.providerName().isEmpty()) {
+ if (pu.provider() != Provider.Default && !pu.providerName().isEmpty()) {
+ throw new IOException("At most one of provider and providerName can be used");
+ }
+ String name;
+ if (!pu.providerName().isEmpty()) {
+ name = pu.providerName();
+ } else {
+ switch (pu.provider()) {
+ case Hibernate:
+ name = "org.hibernate.jpa.HibernatePersistenceProvider";
+ break;
+ default:
+ // TODO
+ throw new IOException("Unsupported provider: " + pu.provider());
+ }
+ }
+ w.println(" <provider>" + name + "</provider>");
+ }
+ if (!pu.jtaDataSource().isEmpty()) {
+ w.println(" <jta-data-source>" + pu.jtaDataSource() + "</jta-data-source>");
+ }
+ if (!pu.nonJtaDataSource().isEmpty()) {
+ w.println(" <non-jta-data-source>" + pu.nonJtaDataSource() + "</non-jta-data-source>");
+ }
+ if (pu.properties().length > 0) {
+ w.println(" <properties>");
+ for (Property property : pu.properties()) {
+ w.println(" <property name=\"" + property.name() + "\" value=\"" + property.value() + "\"/>");
+ }
+
+
+ for (AnnotationMirror annMirror : units.get(pu)) {
+
+ String name = null;
+ for (AnnotationMirror a : processingEnv.getElementUtils().getAllAnnotationMirrors(annMirror.getAnnotationType().asElement())) {
+ if (a.toString().startsWith("@org.apache.karaf.boot.jpa.PersistentUnit.ProviderProperty")) {
+ name = a.getElementValues().values().iterator().next().getValue().toString();
+ break;
+ }
+ }
+ if (name != null) {
+ String value = annMirror.getElementValues().values().iterator().next().getValue().toString();
+ w.println(" <property name=\"" + name + "\" value=\"" + value + "\"/>");
+ }
+// processingEnv.getMessager().printMessage(Kind.MANDATORY_WARNING, "Annotation: " + annMirror);
+// processingEnv.getMessager().printMessage(Kind.MANDATORY_WARNING, "Annotation type: " + annMirror.getAnnotationType());
+// processingEnv.getMessager().printMessage(Kind.MANDATORY_WARNING, "Annotation annot: " + annMirror.getAnnotationType().getAnnotationMirrors());
+// processingEnv.getMessager().printMessage(Kind.MANDATORY_WARNING, "Annotation annot: " + processingEnv.getElementUtils().getAllAnnotationMirrors(annMirror.getAnnotationType().asElement()));
+// processingEnv.getMessager().printMessage(Kind.MANDATORY_WARNING, "Annotation values: " + annMirror.getElementValues());
+// if (annMirror.getAnnotationType().getAnnotation(PersistentUnit.ProviderProperty.class) != null) {
+// processingEnv.getMessager().printMessage(Kind.MANDATORY_WARNING, "Annotation ok");
+// } else {
+// processingEnv.getMessager().printMessage(Kind.MANDATORY_WARNING, "Annotation nok");
+// }
+ }
+
+ w.println(" </properties>");
+ }
+ w.println(" </persistence-unit>");
+ }
+ w.println("</persistence>");
+ w.close();
+ processingEnv.getMessager().printMessage(Kind.NOTE, "Generated META-INF/persistence.xml");
+ } catch (IOException e) {
+ processingEnv.getMessager().printMessage(Kind.ERROR, "Error: " + e.getMessage());
+ }
+ }
+ return true;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/dd56eb85/karaf-boot-starters/karaf-boot-starter-jpa/src/main/resources/META-INF/services/javax.annotation.processing.Processor
----------------------------------------------------------------------
diff --git a/karaf-boot-starters/karaf-boot-starter-jpa/src/main/resources/META-INF/services/javax.annotation.processing.Processor b/karaf-boot-starters/karaf-boot-starter-jpa/src/main/resources/META-INF/services/javax.annotation.processing.Processor
new file mode 100644
index 0000000..eb83448
--- /dev/null
+++ b/karaf-boot-starters/karaf-boot-starter-jpa/src/main/resources/META-INF/services/javax.annotation.processing.Processor
@@ -0,0 +1 @@
+org.apache.karaf.boot.jpa.impl.JpaProcessor
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/dd56eb85/karaf-boot-starters/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-starters/pom.xml b/karaf-boot-starters/pom.xml
index caa5d44..8a22ae1 100644
--- a/karaf-boot-starters/pom.xml
+++ b/karaf-boot-starters/pom.xml
@@ -36,6 +36,7 @@
<module>karaf-boot-starter-ds</module>
<module>karaf-boot-starter-shell</module>
<module>karaf-boot-starter-web</module>
+ <module>karaf-boot-starter-jpa</module>
</modules>
</project>
\ No newline at end of file
[23/35] karaf-boot git commit: Renaming dirs,
use blueprint-maven-plugin
Posted by cs...@apache.org.
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/starters/karaf-boot-starter-jpa/pom.xml
----------------------------------------------------------------------
diff --git a/starters/karaf-boot-starter-jpa/pom.xml b/starters/karaf-boot-starter-jpa/pom.xml
new file mode 100644
index 0000000..c0ce5b8
--- /dev/null
+++ b/starters/karaf-boot-starter-jpa/pom.xml
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+
+ <!--
+
+ 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.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-starters</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>karaf-boot-starter-jpa</artifactId>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>osgi.cmpn</artifactId>
+ <version>${osgi.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jpa_2.0_spec</artifactId>
+ <version>1.1</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <compilerArgument>-proc:none</compilerArgument>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/EclipseLink.java
----------------------------------------------------------------------
diff --git a/starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/EclipseLink.java b/starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/EclipseLink.java
new file mode 100644
index 0000000..f1cba0d
--- /dev/null
+++ b/starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/EclipseLink.java
@@ -0,0 +1,4 @@
+package org.apache.karaf.boot.jpa;
+
+public interface EclipseLink {
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/Hibernate.java
----------------------------------------------------------------------
diff --git a/starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/Hibernate.java b/starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/Hibernate.java
new file mode 100644
index 0000000..ae4dab3
--- /dev/null
+++ b/starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/Hibernate.java
@@ -0,0 +1,91 @@
+package org.apache.karaf.boot.jpa;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import org.apache.karaf.boot.jpa.PersistentUnit.ProviderProperty;
+
+public interface Hibernate {
+
+ @ProviderProperty("hibernate.query.substitutions")
+ @Target(ElementType.TYPE)
+ @Retention(RetentionPolicy.SOURCE)
+ @interface QuerySubstitutions {
+ String value();
+ }
+
+ @ProviderProperty("hibernate.hbm2ddl.auto")
+ @Target(ElementType.TYPE)
+ @Retention(RetentionPolicy.SOURCE)
+ @interface Hbm2DdlAuto {
+ Value value();
+ enum Value {
+ Validate,
+ Update,
+ Create,
+ CreateDrop;
+
+ public String toString() {
+ return super.toString().toLowerCase();
+ }
+ }
+ }
+
+ @ProviderProperty("hibernate.dialect")
+ @Target(ElementType.TYPE)
+ @Retention(RetentionPolicy.SOURCE)
+ @interface Dialect {
+ Value value();
+ enum Value {
+ Cache71,
+ DataDirectOracle9,
+ DB2390,
+ DB2400,
+ DB2,
+ Derby,
+ Firebird,
+ FrontBase,
+ H2,
+ HSQL,
+ Informix,
+ Ingres10,
+ Ingres9,
+ Ingres,
+ Interbase,
+ JDataStore,
+ Mckoi,
+ MimerSQL,
+ MySQL5,
+ MySQL5InnoDB,
+ MySQL,
+ MySQLInnoDB,
+ MySQLMyISAM,
+ Oracle10g,
+ Oracle8i,
+ Oracle9,
+ Oracle9i,
+ Oracle,
+ Pointbase,
+ PostgresPlus,
+ PostgreSQL,
+ Progress,
+ RDMSOS2200,
+ SAPDB,
+ SQLServer2008,
+ SQLServer,
+ Sybase11,
+ SybaseAnywhere,
+ SybaseASE15,
+ Sybase,
+ Teradata,
+ TimesTen;
+
+ public String toString() {
+ return "org.hibernate.dialect." + super.toString() + "Dialect";
+ }
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/OpenJpa.java
----------------------------------------------------------------------
diff --git a/starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/OpenJpa.java b/starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/OpenJpa.java
new file mode 100644
index 0000000..01186fc
--- /dev/null
+++ b/starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/OpenJpa.java
@@ -0,0 +1,38 @@
+package org.apache.karaf.boot.jpa;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import org.apache.karaf.boot.jpa.PersistentUnit.ProviderProperty;
+
+public interface OpenJpa {
+
+ @ProviderProperty("openjpa.AutoClear")
+ @Target(ElementType.TYPE)
+ @Retention(RetentionPolicy.SOURCE)
+ @interface AutoClear {
+ Value value();
+ enum Value {
+ Datastore, All;
+ public String toString() {
+ return super.toString().toLowerCase();
+ }
+ }
+ }
+
+ @ProviderProperty("openjpa.AutoDetach")
+ @Target(ElementType.TYPE)
+ @Retention(RetentionPolicy.SOURCE)
+ @interface AutoDetach {
+ Value value();
+ enum Value {
+ Close, Commit, Nontx_Read;
+ public String toString() {
+ return super.toString().toLowerCase().replace('_', '-');
+ }
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/PersistentUnit.java
----------------------------------------------------------------------
diff --git a/starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/PersistentUnit.java b/starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/PersistentUnit.java
new file mode 100644
index 0000000..ada2ef3
--- /dev/null
+++ b/starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/PersistentUnit.java
@@ -0,0 +1,36 @@
+package org.apache.karaf.boot.jpa;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.SOURCE)
+public @interface PersistentUnit {
+
+ String name();
+
+ String description() default "";
+
+ TransactionType transactionType() default TransactionType.RESOURCE_LOCAL;
+
+ Provider provider() default Provider.Default;
+
+ String providerName() default "";
+
+ String jtaDataSource() default "";
+
+ String nonJtaDataSource() default "";
+
+ // TODO: mapping-file, jar-file, class, exclude-unlisted-classes, shared-cache-mode, validation-mode
+
+ Property[] properties() default {};
+
+
+ @Target(ElementType.ANNOTATION_TYPE)
+ @interface ProviderProperty {
+ String value();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/Property.java
----------------------------------------------------------------------
diff --git a/starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/Property.java b/starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/Property.java
new file mode 100644
index 0000000..5cce58c
--- /dev/null
+++ b/starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/Property.java
@@ -0,0 +1,13 @@
+package org.apache.karaf.boot.jpa;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+@Retention(RetentionPolicy.SOURCE)
+public @interface Property {
+
+ String name();
+
+ String value();
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/Provider.java
----------------------------------------------------------------------
diff --git a/starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/Provider.java b/starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/Provider.java
new file mode 100644
index 0000000..13a62d4
--- /dev/null
+++ b/starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/Provider.java
@@ -0,0 +1,10 @@
+package org.apache.karaf.boot.jpa;
+
+public enum Provider {
+
+ Default,
+ Hibernate,
+ OpenJpa,
+ EclipseLink;
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/TransactionType.java
----------------------------------------------------------------------
diff --git a/starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/TransactionType.java b/starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/TransactionType.java
new file mode 100644
index 0000000..53e76d2
--- /dev/null
+++ b/starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/TransactionType.java
@@ -0,0 +1,6 @@
+package org.apache.karaf.boot.jpa;
+
+public enum TransactionType {
+ RESOURCE_LOCAL,
+ JTA
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/impl/JpaProcessor.java
----------------------------------------------------------------------
diff --git a/starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/impl/JpaProcessor.java b/starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/impl/JpaProcessor.java
new file mode 100644
index 0000000..4becbc2
--- /dev/null
+++ b/starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/impl/JpaProcessor.java
@@ -0,0 +1,140 @@
+package org.apache.karaf.boot.jpa.impl;
+
+import javax.annotation.processing.AbstractProcessor;
+import javax.annotation.processing.Messager;
+import javax.annotation.processing.RoundEnvironment;
+import javax.lang.model.element.AnnotationMirror;
+import javax.lang.model.element.AnnotationValue;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.TypeElement;
+import javax.tools.Diagnostic.Kind;
+import javax.tools.FileObject;
+import javax.tools.StandardLocation;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.karaf.boot.jpa.PersistentUnit;
+import org.apache.karaf.boot.jpa.Property;
+import org.apache.karaf.boot.jpa.Provider;
+
+public class JpaProcessor extends AbstractProcessor {
+
+ public JpaProcessor() {
+ }
+
+ @Override
+ public Set<String> getSupportedAnnotationTypes() {
+ return new HashSet<String>(Arrays.asList(
+ PersistentUnit.class.getName()
+ ));
+ }
+
+ @Override
+ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+ Map<PersistentUnit, List<? extends AnnotationMirror>> units = new HashMap<PersistentUnit, List<? extends AnnotationMirror>>();
+
+
+ for (Element elem : roundEnv.getElementsAnnotatedWith(PersistentUnit.class)) {
+ PersistentUnit pu = elem.getAnnotation(PersistentUnit.class);
+ units.put(pu, elem.getAnnotationMirrors());
+ }
+ if (!units.isEmpty()) {
+ try {
+ Set<String> puNames = new HashSet<String>();
+ FileObject o = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT,
+ "", "META-INF/persistence.xml");
+ PrintWriter w = new PrintWriter(o.openWriter());
+ w.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
+ w.println("<persistence version=\"2.0\" xmlns=\"http://java.sun.com/xml/ns/persistence\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd\">");
+ for (PersistentUnit pu : units.keySet()) {
+ if (pu.name() == null || pu.name().isEmpty()) {
+ throw new IOException("Missing persistent unit name");
+ }
+ if (!puNames.add(pu.name())) {
+ throw new IOException("Duplicate persistent unit name: " + pu.name());
+ }
+ w.println(" <persistence-unit name=\"" + pu.name() + "\" transaction-type=\"" + pu.transactionType().toString() + "\">");
+ if (!pu.description().isEmpty()) {
+ w.println(" <description>" + pu.description() + "</description>");
+ }
+ if (pu.provider() != Provider.Default || !pu.providerName().isEmpty()) {
+ if (pu.provider() != Provider.Default && !pu.providerName().isEmpty()) {
+ throw new IOException("At most one of provider and providerName can be used");
+ }
+ String name;
+ if (!pu.providerName().isEmpty()) {
+ name = pu.providerName();
+ } else {
+ switch (pu.provider()) {
+ case Hibernate:
+ name = "org.hibernate.jpa.HibernatePersistenceProvider";
+ break;
+ default:
+ // TODO
+ throw new IOException("Unsupported provider: " + pu.provider());
+ }
+ }
+ w.println(" <provider>" + name + "</provider>");
+ }
+ if (!pu.jtaDataSource().isEmpty()) {
+ w.println(" <jta-data-source>" + pu.jtaDataSource() + "</jta-data-source>");
+ }
+ if (!pu.nonJtaDataSource().isEmpty()) {
+ w.println(" <non-jta-data-source>" + pu.nonJtaDataSource() + "</non-jta-data-source>");
+ }
+ if (pu.properties().length > 0) {
+ w.println(" <properties>");
+ for (Property property : pu.properties()) {
+ w.println(" <property name=\"" + property.name() + "\" value=\"" + property.value() + "\"/>");
+ }
+
+
+ for (AnnotationMirror annMirror : units.get(pu)) {
+
+ String name = null;
+ for (AnnotationMirror a : processingEnv.getElementUtils().getAllAnnotationMirrors(annMirror.getAnnotationType().asElement())) {
+ if (a.toString().startsWith("@org.apache.karaf.boot.jpa.PersistentUnit.ProviderProperty")) {
+ name = a.getElementValues().values().iterator().next().getValue().toString();
+ break;
+ }
+ }
+ if (name != null) {
+ String value = annMirror.getElementValues().values().iterator().next().getValue().toString();
+ w.println(" <property name=\"" + name + "\" value=\"" + value + "\"/>");
+ }
+// processingEnv.getMessager().printMessage(Kind.MANDATORY_WARNING, "Annotation: " + annMirror);
+// processingEnv.getMessager().printMessage(Kind.MANDATORY_WARNING, "Annotation type: " + annMirror.getAnnotationType());
+// processingEnv.getMessager().printMessage(Kind.MANDATORY_WARNING, "Annotation annot: " + annMirror.getAnnotationType().getAnnotationMirrors());
+// processingEnv.getMessager().printMessage(Kind.MANDATORY_WARNING, "Annotation annot: " + processingEnv.getElementUtils().getAllAnnotationMirrors(annMirror.getAnnotationType().asElement()));
+// processingEnv.getMessager().printMessage(Kind.MANDATORY_WARNING, "Annotation values: " + annMirror.getElementValues());
+// if (annMirror.getAnnotationType().getAnnotation(PersistentUnit.ProviderProperty.class) != null) {
+// processingEnv.getMessager().printMessage(Kind.MANDATORY_WARNING, "Annotation ok");
+// } else {
+// processingEnv.getMessager().printMessage(Kind.MANDATORY_WARNING, "Annotation nok");
+// }
+ }
+
+ w.println(" </properties>");
+ }
+ w.println(" </persistence-unit>");
+ }
+ w.println("</persistence>");
+ w.close();
+ processingEnv.getMessager().printMessage(Kind.NOTE, "Generated META-INF/persistence.xml");
+ } catch (IOException e) {
+ processingEnv.getMessager().printMessage(Kind.ERROR, "Error: " + e.getMessage());
+ }
+ }
+ return true;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/starters/karaf-boot-starter-jpa/src/main/resources/META-INF/services/javax.annotation.processing.Processor
----------------------------------------------------------------------
diff --git a/starters/karaf-boot-starter-jpa/src/main/resources/META-INF/services/javax.annotation.processing.Processor b/starters/karaf-boot-starter-jpa/src/main/resources/META-INF/services/javax.annotation.processing.Processor
new file mode 100644
index 0000000..eb83448
--- /dev/null
+++ b/starters/karaf-boot-starter-jpa/src/main/resources/META-INF/services/javax.annotation.processing.Processor
@@ -0,0 +1 @@
+org.apache.karaf.boot.jpa.impl.JpaProcessor
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/starters/karaf-boot-starter-karaf/pom.xml
----------------------------------------------------------------------
diff --git a/starters/karaf-boot-starter-karaf/pom.xml b/starters/karaf-boot-starter-karaf/pom.xml
new file mode 100644
index 0000000..32bec48
--- /dev/null
+++ b/starters/karaf-boot-starter-karaf/pom.xml
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+
+ <!--
+
+ 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.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-starters</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>karaf-boot-starter-karaf</artifactId>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <version>${osgi.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.karaf</groupId>
+ <artifactId>org.apache.karaf.util</artifactId>
+ <version>${karaf.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <compilerArgument>-proc:none</compilerArgument>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/starters/karaf-boot-starter-karaf/src/main/java/org/apache/karaf/boot/karaf/impl/KarafProcessor.java
----------------------------------------------------------------------
diff --git a/starters/karaf-boot-starter-karaf/src/main/java/org/apache/karaf/boot/karaf/impl/KarafProcessor.java b/starters/karaf-boot-starter-karaf/src/main/java/org/apache/karaf/boot/karaf/impl/KarafProcessor.java
new file mode 100644
index 0000000..e51380e
--- /dev/null
+++ b/starters/karaf-boot-starter-karaf/src/main/java/org/apache/karaf/boot/karaf/impl/KarafProcessor.java
@@ -0,0 +1,154 @@
+package org.apache.karaf.boot.karaf.impl;
+
+import javax.annotation.processing.AbstractProcessor;
+import javax.annotation.processing.RoundEnvironment;
+import javax.lang.model.element.AnnotationMirror;
+import javax.lang.model.element.AnnotationValue;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.ExecutableElement;
+import javax.lang.model.element.TypeElement;
+import javax.tools.Diagnostic.Kind;
+import javax.tools.FileObject;
+import javax.tools.StandardLocation;
+import java.io.CharArrayWriter;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+import java.io.Reader;
+import java.io.Writer;
+import java.lang.annotation.Annotation;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import org.apache.karaf.util.tracker.annotation.Managed;
+import org.apache.karaf.util.tracker.annotation.ProvideService;
+import org.apache.karaf.util.tracker.annotation.RequireService;
+import org.apache.karaf.util.tracker.annotation.Services;
+
+public class KarafProcessor extends AbstractProcessor {
+
+ boolean hasRun;
+
+ public KarafProcessor() {
+ }
+
+ @Override
+ public Set<String> getSupportedAnnotationTypes() {
+ Set<String> set = new HashSet<String>();
+ set.add(Services.class.getName());
+ set.add(Managed.class.getName());
+ return set;
+ }
+
+ @Override
+ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+ List<String> instructions = new ArrayList<>();
+ Properties props = new Properties();
+
+ for (Element elem : roundEnv.getElementsAnnotatedWith(Services.class)) {
+ for (AnnotationMirror mirror : elem.getAnnotationMirrors()) {
+ if (Services.class.getName().equals(((TypeElement) mirror.getAnnotationType().asElement()).getQualifiedName().toString())) {
+ Map<String, Object> values = getAnnotationValues(mirror);
+ if (values.containsKey("provides")) {
+ for (AnnotationMirror p : (List<AnnotationMirror>) values.get("provides")) {
+ Map<String, Object> pv = getAnnotationValues(p);
+ String n = pv.get("value").toString();
+ instructions.add("Provide-Capability: osgi.service;effective:=active;objectClass=" + n);
+ }
+ }
+ if (values.containsKey("requires")) {
+ for (AnnotationMirror r : (List<AnnotationMirror>) values.get("requires")) {
+ Map<String, Object> rv = getAnnotationValues(r);
+ String value = rv.get("value").toString();
+ String filter = (String) rv.getOrDefault("filter", "");
+ boolean opt = ((Boolean) rv.getOrDefault("optional", false));
+
+ String fltWithClass = combine(filter, "(objectClass=" + value + ")");
+ instructions.add("Require-Capability: osgi.service;effective:=active;filter:=\"" + fltWithClass + "\"");
+ props.setProperty(value, filter);
+ }
+ }
+ }
+ }
+ instructions.add("Bundle-Activator: " + ((TypeElement) elem).getQualifiedName().toString());
+
+ Managed managed = elem.getAnnotation(Managed.class);
+ if (managed != null) {
+ props.setProperty("pid", managed.value());
+ }
+
+ String name = "OSGI-INF/karaf-tracker/" + ((TypeElement) elem).getQualifiedName().toString();
+ try (OutputStream os = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", name).openOutputStream()) {
+ props.store(os, null);
+ } catch (IOException e) {
+ processingEnv.getMessager().printMessage(Kind.ERROR, "Error writing to " + name + ": " + e.getMessage());
+ }
+ }
+
+ instructions.add("Private-Package: org.apache.karaf.util.tracker");
+ instructions.add("PREPEND-Import-Package: !org.apache.karaf.util.tracker.annotation");
+
+ if (!hasRun) {
+ hasRun = true;
+ // Add the Karaf embedded package
+ try (PrintWriter w = appendResource("META-INF/org.apache.karaf.boot.bnd")) {
+ for (String instr : instructions) {
+ w.println(instr);
+ }
+ } catch (Exception e) {
+ processingEnv.getMessager().printMessage(Kind.ERROR, "Error writing to META-INF/org.apache.karaf.boot.bnd: " + e.getMessage());
+ }
+ }
+
+ return true;
+ }
+
+ private Map<String, Object> getAnnotationValues(AnnotationMirror mirror) {
+ Map<String, Object> map = new HashMap<>();
+ for (Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> entry : mirror.getElementValues().entrySet()) {
+ map.put(entry.getKey().getSimpleName().toString(), entry.getValue().getValue());
+ }
+ return map;
+ }
+
+ private String combine(String filter1, String filter2) {
+ if (filter1!=null && !filter1.isEmpty()) {
+ return "(&" + filter2 + filter1 + ")";
+ } else {
+ return filter2;
+ }
+ }
+
+ private PrintWriter appendResource(String resource) throws IOException {
+ try {
+ FileObject o = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", resource);
+ return new PrintWriter(o.openWriter());
+ } catch (Exception e) {
+ try {
+ FileObject o = processingEnv.getFiler().getResource(StandardLocation.CLASS_OUTPUT, "", resource);
+ CharArrayWriter baos = new CharArrayWriter();
+ try (Reader r = o.openReader(true)) {
+ char[] buf = new char[4096];
+ int l;
+ while ((l = r.read(buf)) > 0) {
+ baos.write(buf, 0, l);
+ }
+ }
+ o.delete();
+ o = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", resource);
+ Writer w = o.openWriter();
+ w.write(baos.toCharArray());
+ return new PrintWriter(w);
+ } catch (Exception e2) {
+ e2.addSuppressed(e);
+ e2.printStackTrace();
+ throw e2;
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/starters/karaf-boot-starter-karaf/src/main/resources/META-INF/services/javax.annotation.processing.Processor
----------------------------------------------------------------------
diff --git a/starters/karaf-boot-starter-karaf/src/main/resources/META-INF/services/javax.annotation.processing.Processor b/starters/karaf-boot-starter-karaf/src/main/resources/META-INF/services/javax.annotation.processing.Processor
new file mode 100644
index 0000000..c45090b
--- /dev/null
+++ b/starters/karaf-boot-starter-karaf/src/main/resources/META-INF/services/javax.annotation.processing.Processor
@@ -0,0 +1 @@
+org.apache.karaf.boot.karaf.impl.KarafProcessor
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/starters/karaf-boot-starter-shell/pom.xml
----------------------------------------------------------------------
diff --git a/starters/karaf-boot-starter-shell/pom.xml b/starters/karaf-boot-starter-shell/pom.xml
new file mode 100644
index 0000000..28523c7
--- /dev/null
+++ b/starters/karaf-boot-starter-shell/pom.xml
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+
+ <!--
+
+ 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.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-starters</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>karaf-boot-starter-shell</artifactId>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.karaf.shell</groupId>
+ <artifactId>org.apache.karaf.shell.core</artifactId>
+ <version>${karaf.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <compilerArgument>-proc:none</compilerArgument>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/starters/karaf-boot-starter-shell/src/main/java/org/apache/karaf/boot/shell/impl/ShellProcessor.java
----------------------------------------------------------------------
diff --git a/starters/karaf-boot-starter-shell/src/main/java/org/apache/karaf/boot/shell/impl/ShellProcessor.java b/starters/karaf-boot-starter-shell/src/main/java/org/apache/karaf/boot/shell/impl/ShellProcessor.java
new file mode 100644
index 0000000..3de3bfb
--- /dev/null
+++ b/starters/karaf-boot-starter-shell/src/main/java/org/apache/karaf/boot/shell/impl/ShellProcessor.java
@@ -0,0 +1,84 @@
+package org.apache.karaf.boot.shell.impl;
+
+import javax.annotation.processing.AbstractProcessor;
+import javax.annotation.processing.RoundEnvironment;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.TypeElement;
+import javax.tools.Diagnostic.Kind;
+import javax.tools.FileObject;
+import javax.tools.StandardLocation;
+import java.io.CharArrayWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.Reader;
+import java.io.Writer;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.TreeSet;
+
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+
+public class ShellProcessor extends AbstractProcessor {
+
+ boolean hasRun;
+
+ public ShellProcessor() {
+ }
+
+ @Override
+ public Set<String> getSupportedAnnotationTypes() {
+ Set<String> set = new HashSet<String>();
+ set.add(Service.class.getName());
+ return set;
+ }
+
+ @Override
+ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+ Set<String> packages = new TreeSet<>();
+ for (Element elem : roundEnv.getElementsAnnotatedWith(Service.class)) {
+ packages.add(elem.getEnclosingElement().toString());
+ }
+
+ if (!packages.isEmpty()) {
+ if (!hasRun) {
+ hasRun = true;
+ // Add the Karaf embedded package
+ try (PrintWriter w = appendResource("META-INF/org.apache.karaf.boot.bnd")) {
+ w.println("Karaf-Commands: " + String.join(",", packages));
+ } catch (Exception e) {
+ processingEnv.getMessager().printMessage(Kind.ERROR, "Error writing to META-INF/org.apache.karaf.boot.bnd: " + e.getMessage());
+ }
+ }
+ }
+
+ return true;
+ }
+
+ private PrintWriter appendResource(String resource) throws IOException {
+ try {
+ FileObject o = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", resource);
+ return new PrintWriter(o.openWriter());
+ } catch (Exception e) {
+ try {
+ FileObject o = processingEnv.getFiler().getResource(StandardLocation.CLASS_OUTPUT, "", resource);
+ CharArrayWriter baos = new CharArrayWriter();
+ try (Reader r = o.openReader(true)) {
+ char[] buf = new char[4096];
+ int l;
+ while ((l = r.read(buf)) > 0) {
+ baos.write(buf, 0, l);
+ }
+ }
+ o.delete();
+ o = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", resource);
+ Writer w = o.openWriter();
+ w.write(baos.toCharArray());
+ return new PrintWriter(w);
+ } catch (Exception e2) {
+ e2.addSuppressed(e);
+ e2.printStackTrace();
+ throw e2;
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/starters/karaf-boot-starter-shell/src/main/resources/META-INF/services/javax.annotation.processing.Processor
----------------------------------------------------------------------
diff --git a/starters/karaf-boot-starter-shell/src/main/resources/META-INF/services/javax.annotation.processing.Processor b/starters/karaf-boot-starter-shell/src/main/resources/META-INF/services/javax.annotation.processing.Processor
new file mode 100644
index 0000000..3ebe726
--- /dev/null
+++ b/starters/karaf-boot-starter-shell/src/main/resources/META-INF/services/javax.annotation.processing.Processor
@@ -0,0 +1 @@
+org.apache.karaf.boot.shell.impl.ShellProcessor
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/starters/karaf-boot-starter-web/pom.xml
----------------------------------------------------------------------
diff --git a/starters/karaf-boot-starter-web/pom.xml b/starters/karaf-boot-starter-web/pom.xml
new file mode 100644
index 0000000..54bc3c5
--- /dev/null
+++ b/starters/karaf-boot-starter-web/pom.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+
+ <!--
+
+ 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.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-starters</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>karaf-boot-starter-web</artifactId>
+
+ <dependencies>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>javax.servlet-api</artifactId>
+ <version>3.1.0</version>
+ </dependency>
+ </dependencies>
+
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/starters/karaf-boot-starter/pom.xml
----------------------------------------------------------------------
diff --git a/starters/karaf-boot-starter/pom.xml b/starters/karaf-boot-starter/pom.xml
new file mode 100644
index 0000000..e5b2742
--- /dev/null
+++ b/starters/karaf-boot-starter/pom.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+
+ <!--
+
+ 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.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-starters</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>karaf-boot-starter</artifactId>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <version>${osgi.version}</version>
+ </dependency>
+ </dependencies>
+
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/starters/pom.xml
----------------------------------------------------------------------
diff --git a/starters/pom.xml b/starters/pom.xml
new file mode 100644
index 0000000..57dbd39
--- /dev/null
+++ b/starters/pom.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+
+ <!--
+
+ 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.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-build</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>karaf-boot-starters</artifactId>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>karaf-boot-starter</module>
+ <module>karaf-boot-starter-karaf</module>
+ <module>karaf-boot-starter-ds</module>
+ <module>karaf-boot-starter-shell</module>
+ <module>karaf-boot-starter-web</module>
+ <module>karaf-boot-starter-jpa</module>
+ <module>karaf-boot-starter-cdi</module>
+ <module>karaf-boot-starter-blueprint</module>
+ </modules>
+
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/tools/karaf-boot-maven-plugin/pom.xml
----------------------------------------------------------------------
diff --git a/tools/karaf-boot-maven-plugin/pom.xml b/tools/karaf-boot-maven-plugin/pom.xml
new file mode 100644
index 0000000..8897be1
--- /dev/null
+++ b/tools/karaf-boot-maven-plugin/pom.xml
@@ -0,0 +1,85 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+
+ <!--
+
+ 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.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-tools</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>karaf-boot-maven-plugin</artifactId>
+ <packaging>maven-plugin</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-api</artifactId>
+ <version>3.1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-annotations</artifactId>
+ <version>3.3</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-core</artifactId>
+ <version>3.1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-model</artifactId>
+ <version>3.2.1</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-plugin-plugin</artifactId>
+ <version>3.3</version>
+ <configuration>
+ <goalPrefix>karaf-boot</goalPrefix>
+ <skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
+ </configuration>
+ <executions>
+ <execution>
+ <id>generate-descriptor</id>
+ <goals>
+ <goal>descriptor</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>generate-helpmojo</id>
+ <goals>
+ <goal>helpmojo</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/maven/GenerateMojo.java
----------------------------------------------------------------------
diff --git a/tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/maven/GenerateMojo.java b/tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/maven/GenerateMojo.java
new file mode 100644
index 0000000..dd88688
--- /dev/null
+++ b/tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/maven/GenerateMojo.java
@@ -0,0 +1,124 @@
+package org.apache.karaf.boot.maven;
+
+import org.apache.maven.execution.MavenSession;
+import org.apache.maven.model.Plugin;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.BuildPluginManager;
+import org.apache.maven.plugin.MojoExecution;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.descriptor.*;
+import org.apache.maven.plugins.annotations.*;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.project.MavenProject;
+import org.codehaus.plexus.util.xml.Xpp3Dom;
+import org.codehaus.plexus.util.xml.Xpp3DomBuilder;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.StringReader;
+import java.nio.file.Files;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+@Mojo(name = "generate", threadSafe = true, defaultPhase = LifecyclePhase.PROCESS_CLASSES, requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME, inheritByDefault = false)
+public class GenerateMojo extends AbstractMojo {
+
+ @Parameter(defaultValue = "${project}", required = true, readonly = true)
+ private MavenProject mavenProject;
+
+ @Parameter(defaultValue = "${session}", required = true, readonly = true)
+ private MavenSession mavenSession;
+
+ @Component
+ private BuildPluginManager pluginManager;
+
+ public void execute() throws MojoExecutionException {
+ try {
+ //
+ // Felix Bundle plugin
+ //
+
+ Map<String, String> instructions = new LinkedHashMap<>();
+ // Starters supplied instructions
+ File bndInst = new File(mavenProject.getBasedir(), "target/classes/META-INF/org.apache.karaf.boot.bnd");
+ if (bndInst.isFile()) {
+ complete(instructions, bndInst);
+ bndInst.delete();
+ }
+ // User supplied instructions
+ bndInst = new File(mavenProject.getBasedir(), "osgi.bnd");
+ if (bndInst.isFile()) {
+ complete(instructions, bndInst);
+ }
+ // Verify and use defaults
+ if (instructions.containsKey("Import-Package")) {
+ instructions.put("Import-Package", instructions.get("Import-Package") + ",*");
+ }
+ // Build config
+ StringBuilder config = new StringBuilder();
+ config.append("<configuration>" +
+ "<finalName>${project.build.finalName}</finalName>" +
+ "<outputDirectory>${project.build.outputDirectory}</outputDirectory>" +
+ "<m_mavenSession>${session}</m_mavenSession>" +
+ "<project>${project}</project>" +
+ "<buildDirectory>${project.build.directory}</buildDirectory>" +
+ "<supportedProjectTypes>" +
+ "<supportedProjectType>jar</supportedProjectType>" +
+ "<supportedProjectType>bundle</supportedProjectType>" +
+ "<supportedProjectType>war</supportedProjectType>" +
+ "</supportedProjectTypes>" +
+ "<instructions>");
+ for (Map.Entry<String, String> entry : instructions.entrySet()) {
+ config.append("<").append(entry.getKey()).append(">")
+ .append(entry.getValue())
+ .append("</").append(entry.getKey()).append(">");
+ }
+ config.append("</instructions>" +
+ "</configuration>");
+ Xpp3Dom configuration = Xpp3DomBuilder.build(new StringReader(config.toString()));
+ // Invoke plugin
+ getLog().info("Invoking maven-bundle-plugin");
+ Plugin felixBundlePlugin = new Plugin();
+ felixBundlePlugin.setGroupId("org.apache.felix");
+ felixBundlePlugin.setArtifactId("maven-bundle-plugin");
+ felixBundlePlugin.setVersion("3.0.0");
+ felixBundlePlugin.setInherited(true);
+ felixBundlePlugin.setExtensions(true);
+ PluginDescriptor felixBundlePluginDescriptor = pluginManager.loadPlugin(felixBundlePlugin, mavenProject.getRemotePluginRepositories(), mavenSession.getRepositorySession());
+ MojoDescriptor felixBundleMojoDescriptor = felixBundlePluginDescriptor.getMojo("bundle");
+ MojoExecution execution = new MojoExecution(felixBundleMojoDescriptor, configuration);
+ pluginManager.executeMojo(mavenSession, execution);
+
+ } catch (Exception e) {
+ throw new MojoExecutionException("karaf-boot-maven-plugin failed", e);
+ }
+ }
+
+ private void complete(Map<String, String> instructions, File bndInst) throws IOException {
+ List<String> lines = Files.readAllLines(bndInst.toPath());
+ for (String line : lines) {
+ if (!line.contains(":")) {
+ continue;
+ }
+ String name = line.substring(0, line.indexOf(':')).trim();
+ String value = line.substring(line.indexOf(':') + 1).trim();
+ boolean prepend = false;
+ if (name.startsWith("PREPEND-")) {
+ prepend = true;
+ name = name.substring("PREPEND-".length());
+ }
+ if (instructions.containsKey(name)) {
+ if (prepend) {
+ instructions.put(name, value + "," + instructions.get(name));
+ } else {
+ instructions.put(name, instructions.get(name) + "," + value);
+ }
+ } else {
+ instructions.put(name, value);
+ }
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/tools/karaf-boot-maven-plugin/src/main/resources/META-INF/plexus/components.xml
----------------------------------------------------------------------
diff --git a/tools/karaf-boot-maven-plugin/src/main/resources/META-INF/plexus/components.xml b/tools/karaf-boot-maven-plugin/src/main/resources/META-INF/plexus/components.xml
new file mode 100644
index 0000000..6fa2eeb
--- /dev/null
+++ b/tools/karaf-boot-maven-plugin/src/main/resources/META-INF/plexus/components.xml
@@ -0,0 +1,61 @@
+<!--
+ 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.
+-->
+<component-set>
+ <components>
+ <component>
+ <role>org.apache.maven.lifecycle.mapping.LifecycleMapping</role>
+ <role-hint>jar</role-hint>
+ <implementation>org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping</implementation>
+ <configuration>
+ <lifecycles>
+ <lifecycle>
+ <id>default</id>
+ <phases>
+ <process-resources>org.apache.maven.plugins:maven-resources-plugin:resources</process-resources>
+ <compile>org.apache.maven.plugins:maven-compiler-plugin:compile</compile>
+ <process-classes>org.apache.karaf.boot:karaf-boot-maven-plugin:generate</process-classes>
+ <process-test-resources>org.apache.maven.plugins:maven-resources-plugin:testResources</process-test-resources>
+ <test-compile>org.apache.maven.plugins:maven-compiler-plugin:testCompile</test-compile>
+ <test>org.apache.maven.plugins:maven-surefire-plugin:test</test>
+ <install>
+ org.apache.maven.plugins:maven-install-plugin:install
+ </install>
+ <deploy>
+ org.apache.maven.plugins:maven-deploy-plugin:deploy
+ </deploy>
+ </phases>
+ </lifecycle>
+ </lifecycles>
+ </configuration>
+ </component>
+ <component>
+ <role>org.apache.maven.artifact.handler.ArtifactHandler</role>
+ <role-hint>bundle</role-hint>
+ <implementation>org.apache.maven.artifact.handler.DefaultArtifactHandler</implementation>
+ <configuration>
+ <type>jar</type>
+ <includesDependencies>false</includesDependencies>
+ <language>java</language>
+ <extension>jar</extension>
+ <addedToClasspath>true</addedToClasspath>
+ <packaging>jar</packaging>
+ </configuration>
+ </component>
+ </components>
+</component-set>
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/tools/pom.xml
----------------------------------------------------------------------
diff --git a/tools/pom.xml b/tools/pom.xml
new file mode 100644
index 0000000..ccb9c88
--- /dev/null
+++ b/tools/pom.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+
+ <!--
+
+ 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.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-build</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>karaf-boot-tools</artifactId>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>karaf-boot-maven-plugin</module>
+ </modules>
+
+</project>
\ No newline at end of file
[25/35] karaf-boot git commit: Renaming dirs,
use blueprint-maven-plugin
Posted by cs...@apache.org.
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-samples/karaf-boot-sample-servlet/src/main/java/sample/servlet/SampleServlet.java
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-servlet/src/main/java/sample/servlet/SampleServlet.java b/karaf-boot-samples/karaf-boot-sample-servlet/src/main/java/sample/servlet/SampleServlet.java
deleted file mode 100644
index d0069af..0000000
--- a/karaf-boot-samples/karaf-boot-sample-servlet/src/main/java/sample/servlet/SampleServlet.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * 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 sample.servlet;
-
-import javax.servlet.ServletException;
-import javax.servlet.annotation.WebServlet;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.io.PrintWriter;
-
-@WebServlet(name = "SampleServlet", urlPatterns = {"/sample"})
-public class SampleServlet extends HttpServlet {
-
- @Override
- public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
- final PrintWriter writer = response.getWriter();
- writer.println("<html>");
- writer.println("<head>");
- writer.println("<title>Sample</title>");
- writer.println("</head>");
- writer.println("<body align='center'>");
- writer.println("<h1>Sample karaf-boot</h1>");
- writer.println("</body>");
- writer.println("</html>");
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-samples/karaf-boot-sample-shell/README.md
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-shell/README.md b/karaf-boot-samples/karaf-boot-sample-shell/README.md
deleted file mode 100644
index dc6b380..0000000
--- a/karaf-boot-samples/karaf-boot-sample-shell/README.md
+++ /dev/null
@@ -1,38 +0,0 @@
-== karaf-boot-sample-shell ==
-
-This sample provides new shell command in the Karaf shell console, that uses the hello service, provided by another
-artifact (as karaf-boot-sample-service-provider-ds for instance).
-
-= Design
-
-The shell commands are exposed using the Karaf shell annotations.
-
-A command is basically a class implementing Action interface, and we use @Service, @Command, @Argument, @Option Karaf
-shell annotations.
-
-The @Reference annotation uses the hello service.
-
-= Build
-
-To build, simply do:
-
- mvn clean install
-
-= Deploy
-
-You have to install a hello service provider first. Please deploy karaf-boot-sample-service-provider-ds first.
-
-To deploy in Karaf:
-
-* you can drop the generated jar file (target/karaf-boot-sample-shell-1.0.jar) in the
-Karaf deploy folder
-* in the Karaf shell console, do:
-
- bundle:install -s mvn:org.apache.karaf.boot/karaf-boot-sample-shell/1.0
-
-= Usage
-
-Once deployed, you can use the sample:hello command like:
-
-karaf@root()> sample:hello world
-Hello world !
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-samples/karaf-boot-sample-shell/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-shell/pom.xml b/karaf-boot-samples/karaf-boot-sample-shell/pom.xml
deleted file mode 100644
index 1df8632..0000000
--- a/karaf-boot-samples/karaf-boot-sample-shell/pom.xml
+++ /dev/null
@@ -1,53 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<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">
-
- <!--
-
- 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.
- -->
-
- <modelVersion>4.0.0</modelVersion>
-
- <groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-sample-shell</artifactId>
- <version>1.0.0-SNAPSHOT</version>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-starter-shell</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-sample-service-provider-ds</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-maven-plugin</artifactId>
- <version>${project.version}</version>
- <inherited>true</inherited>
- <extensions>true</extensions>
- </plugin>
- </plugins>
- </build>
-
-</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-samples/karaf-boot-sample-shell/src/main/java/sample/shell/HelloCommand.java
----------------------------------------------------------------------
diff --git a/karaf-boot-samples/karaf-boot-sample-shell/src/main/java/sample/shell/HelloCommand.java b/karaf-boot-samples/karaf-boot-sample-shell/src/main/java/sample/shell/HelloCommand.java
deleted file mode 100644
index eb4a730..0000000
--- a/karaf-boot-samples/karaf-boot-sample-shell/src/main/java/sample/shell/HelloCommand.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- * 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 sample.shell;
-
-import org.apache.karaf.shell.api.action.Action;
-import org.apache.karaf.shell.api.action.Argument;
-import org.apache.karaf.shell.api.action.Command;
-import org.apache.karaf.shell.api.action.Option;
-import org.apache.karaf.shell.api.action.lifecycle.Reference;
-import org.apache.karaf.shell.api.action.lifecycle.Service;
-import sample.ds.service.provider.HelloService;
-
-@Service
-@Command(scope = "sample", name = "hello", description = "The hello command")
-public class HelloCommand implements Action {
-
- @Reference
- public HelloService helloService;
-
- @Argument(index = 0, name = "arg", description = "This is the message argument", required = true, multiValued = false)
- public String arg;
-
- @Option(name = "opt", description = "This is an option", required = false, multiValued = false)
- public String opt;
-
- public Object execute() throws Exception {
- if (opt != null)
- System.out.println("Opt is " + opt);
- System.out.println(helloService.hello(arg));
- return null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-starters/karaf-boot-starter-blueprint/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-starters/karaf-boot-starter-blueprint/pom.xml b/karaf-boot-starters/karaf-boot-starter-blueprint/pom.xml
deleted file mode 100644
index 9f48c60..0000000
--- a/karaf-boot-starters/karaf-boot-starter-blueprint/pom.xml
+++ /dev/null
@@ -1,57 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<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">
-
- <!--
-
- 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.
- -->
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-starters</artifactId>
- <version>1.0.0-SNAPSHOT</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
-
- <artifactId>karaf-boot-starter-blueprint</artifactId>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.aries.blueprint</groupId>
- <artifactId>org.apache.aries.blueprint.api</artifactId>
- <version>1.0.0</version>
- </dependency>
- <dependency>
- <groupId>org.apache.aries.blueprint</groupId>
- <artifactId>org.apache.aries.blueprint.annotation.api</artifactId>
- <version>1.0.0</version>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <compilerArgument>-proc:none</compilerArgument>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-starters/karaf-boot-starter-blueprint/src/main/java/org/apache/karaf/boot/blueprint/impl/BlueprintProcessor.java
----------------------------------------------------------------------
diff --git a/karaf-boot-starters/karaf-boot-starter-blueprint/src/main/java/org/apache/karaf/boot/blueprint/impl/BlueprintProcessor.java b/karaf-boot-starters/karaf-boot-starter-blueprint/src/main/java/org/apache/karaf/boot/blueprint/impl/BlueprintProcessor.java
deleted file mode 100644
index 896a161..0000000
--- a/karaf-boot-starters/karaf-boot-starter-blueprint/src/main/java/org/apache/karaf/boot/blueprint/impl/BlueprintProcessor.java
+++ /dev/null
@@ -1,76 +0,0 @@
-package org.apache.karaf.boot.blueprint.impl;
-
-import javax.annotation.processing.AbstractProcessor;
-import javax.annotation.processing.RoundEnvironment;
-import javax.lang.model.element.TypeElement;
-import javax.tools.Diagnostic.Kind;
-import javax.tools.FileObject;
-import javax.tools.StandardLocation;
-import java.io.ByteArrayOutputStream;
-import java.io.CharArrayWriter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.PrintWriter;
-import java.io.Reader;
-import java.io.Writer;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.apache.aries.blueprint.annotation.Bean;
-
-public class BlueprintProcessor extends AbstractProcessor {
-
- boolean hasRun;
-
- public BlueprintProcessor() {
- }
-
- @Override
- public Set<String> getSupportedAnnotationTypes() {
- Set<String> set = new HashSet<String>();
- set.add(Bean.class.getName());
- return set;
- }
-
- @Override
- public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
- if (!hasRun) {
- hasRun = true;
- // Add the blueprint requirement
- try (PrintWriter w = appendResource("META-INF/org.apache.karaf.boot.bnd")) {
- w.println("Bundle-Blueprint-Annotation: true");
- } catch (Exception e) {
- processingEnv.getMessager().printMessage(Kind.ERROR, "Error: " + e.getMessage());
- }
- }
- return true;
- }
-
- private PrintWriter appendResource(String resource) throws IOException {
- try {
- FileObject o = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", resource);
- return new PrintWriter(o.openWriter());
- } catch (Exception e) {
- try {
- FileObject o = processingEnv.getFiler().getResource(StandardLocation.CLASS_OUTPUT, "", resource);
- CharArrayWriter baos = new CharArrayWriter();
- try (Reader r = o.openReader(true)) {
- char[] buf = new char[4096];
- int l;
- while ((l = r.read(buf)) > 0) {
- baos.write(buf, 0, l);
- }
- }
- o.delete();
- o = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", resource);
- Writer w = o.openWriter();
- w.write(baos.toCharArray());
- return new PrintWriter(w);
- } catch (Exception e2) {
- e2.addSuppressed(e);
- e2.printStackTrace();
- throw e2;
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-starters/karaf-boot-starter-blueprint/src/main/resources/META-INF/services/javax.annotation.processing.Processor
----------------------------------------------------------------------
diff --git a/karaf-boot-starters/karaf-boot-starter-blueprint/src/main/resources/META-INF/services/javax.annotation.processing.Processor b/karaf-boot-starters/karaf-boot-starter-blueprint/src/main/resources/META-INF/services/javax.annotation.processing.Processor
deleted file mode 100644
index fab44d1..0000000
--- a/karaf-boot-starters/karaf-boot-starter-blueprint/src/main/resources/META-INF/services/javax.annotation.processing.Processor
+++ /dev/null
@@ -1 +0,0 @@
-org.apache.karaf.boot.blueprint.impl.BlueprintProcessor
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-starters/karaf-boot-starter-cdi/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-starters/karaf-boot-starter-cdi/pom.xml b/karaf-boot-starters/karaf-boot-starter-cdi/pom.xml
deleted file mode 100644
index 3f33d28..0000000
--- a/karaf-boot-starters/karaf-boot-starter-cdi/pom.xml
+++ /dev/null
@@ -1,67 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<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">
-
- <!--
-
- 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.
- -->
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-starters</artifactId>
- <version>1.0.0-SNAPSHOT</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
-
- <artifactId>karaf-boot-starter-cdi</artifactId>
-
- <dependencies>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>osgi.cmpn</artifactId>
- <version>${osgi.version}</version>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.cdi</groupId>
- <artifactId>pax-cdi-api</artifactId>
- <version>${pax.cdi.version}</version>
- </dependency>
- <dependency>
- <groupId>javax.enterprise</groupId>
- <artifactId>cdi-api</artifactId>
- <version>1.2</version>
- </dependency>
- <dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-atinject_1.0_spec</artifactId>
- <version>1.0</version>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <compilerArgument>-proc:none</compilerArgument>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-starters/karaf-boot-starter-cdi/src/main/java/org/apache/karaf/boot/cdi/impl/CdiProcessor.java
----------------------------------------------------------------------
diff --git a/karaf-boot-starters/karaf-boot-starter-cdi/src/main/java/org/apache/karaf/boot/cdi/impl/CdiProcessor.java b/karaf-boot-starters/karaf-boot-starter-cdi/src/main/java/org/apache/karaf/boot/cdi/impl/CdiProcessor.java
deleted file mode 100644
index 44cc571..0000000
--- a/karaf-boot-starters/karaf-boot-starter-cdi/src/main/java/org/apache/karaf/boot/cdi/impl/CdiProcessor.java
+++ /dev/null
@@ -1,82 +0,0 @@
-package org.apache.karaf.boot.cdi.impl;
-
-import javax.annotation.processing.AbstractProcessor;
-import javax.annotation.processing.RoundEnvironment;
-import javax.lang.model.element.TypeElement;
-import javax.tools.Diagnostic.Kind;
-import javax.tools.FileObject;
-import javax.tools.StandardLocation;
-import java.io.ByteArrayOutputStream;
-import java.io.CharArrayWriter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.PrintWriter;
-import java.io.Reader;
-import java.io.Writer;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.ops4j.pax.cdi.api.OsgiServiceProvider;
-
-public class CdiProcessor extends AbstractProcessor {
-
- boolean hasRun;
-
- public CdiProcessor() {
- }
-
- @Override
- public Set<String> getSupportedAnnotationTypes() {
- Set<String> set = new HashSet<String>();
- set.add(OsgiServiceProvider.class.getName());
- return set;
- }
-
- @Override
- public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
- if (!hasRun) {
- hasRun = true;
- // Make sure we have a META-INF/beans.xml file present
- try (PrintWriter w = appendResource("META-INF/beans.xml")) {
- processingEnv.getMessager().printMessage(Kind.NOTE, "Generated META-INF/beans.xml");
- } catch (Exception e) {
- processingEnv.getMessager().printMessage(Kind.ERROR, "Error: " + e.getMessage());
- }
- // Add the CDI requirement
- try (PrintWriter w = appendResource("META-INF/org.apache.karaf.boot.bnd")) {
- w.println("Require-Capability: osgi.extender; filter:=\"(osgi.extender=pax.cdi)\"");
- } catch (Exception e) {
- processingEnv.getMessager().printMessage(Kind.ERROR, "Error: " + e.getMessage());
- }
- }
- return true;
- }
-
- private PrintWriter appendResource(String resource) throws IOException {
- try {
- FileObject o = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", resource);
- return new PrintWriter(o.openWriter());
- } catch (Exception e) {
- try {
- FileObject o = processingEnv.getFiler().getResource(StandardLocation.CLASS_OUTPUT, "", resource);
- CharArrayWriter baos = new CharArrayWriter();
- try (Reader r = o.openReader(true)) {
- char[] buf = new char[4096];
- int l;
- while ((l = r.read(buf)) > 0) {
- baos.write(buf, 0, l);
- }
- }
- o.delete();
- o = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", resource);
- Writer w = o.openWriter();
- w.write(baos.toCharArray());
- return new PrintWriter(w);
- } catch (Exception e2) {
- e2.addSuppressed(e);
- e2.printStackTrace();
- throw e2;
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-starters/karaf-boot-starter-cdi/src/main/resources/META-INF/services/javax.annotation.processing.Processor
----------------------------------------------------------------------
diff --git a/karaf-boot-starters/karaf-boot-starter-cdi/src/main/resources/META-INF/services/javax.annotation.processing.Processor b/karaf-boot-starters/karaf-boot-starter-cdi/src/main/resources/META-INF/services/javax.annotation.processing.Processor
deleted file mode 100644
index a6cd494..0000000
--- a/karaf-boot-starters/karaf-boot-starter-cdi/src/main/resources/META-INF/services/javax.annotation.processing.Processor
+++ /dev/null
@@ -1 +0,0 @@
-org.apache.karaf.boot.cdi.impl.CdiProcessor
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-starters/karaf-boot-starter-ds/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-starters/karaf-boot-starter-ds/pom.xml b/karaf-boot-starters/karaf-boot-starter-ds/pom.xml
deleted file mode 100644
index 331c8e2..0000000
--- a/karaf-boot-starters/karaf-boot-starter-ds/pom.xml
+++ /dev/null
@@ -1,52 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<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">
-
- <!--
-
- 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.
- -->
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-starters</artifactId>
- <version>1.0.0-SNAPSHOT</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
-
- <artifactId>karaf-boot-starter-ds</artifactId>
-
- <dependencies>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>osgi.cmpn</artifactId>
- <version>${osgi.version}</version>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <compilerArgument>-proc:none</compilerArgument>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-starters/karaf-boot-starter-ds/src/main/java/org/apache/karaf/boot/ds/impl/DsProcessor.java
----------------------------------------------------------------------
diff --git a/karaf-boot-starters/karaf-boot-starter-ds/src/main/java/org/apache/karaf/boot/ds/impl/DsProcessor.java b/karaf-boot-starters/karaf-boot-starter-ds/src/main/java/org/apache/karaf/boot/ds/impl/DsProcessor.java
deleted file mode 100644
index 49baa70..0000000
--- a/karaf-boot-starters/karaf-boot-starter-ds/src/main/java/org/apache/karaf/boot/ds/impl/DsProcessor.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package org.apache.karaf.boot.ds.impl;
-
-import javax.annotation.processing.AbstractProcessor;
-import javax.annotation.processing.RoundEnvironment;
-import javax.lang.model.element.TypeElement;
-import javax.tools.Diagnostic.Kind;
-import javax.tools.FileObject;
-import javax.tools.StandardLocation;
-import java.io.CharArrayWriter;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.Reader;
-import java.io.Writer;
-import java.util.HashSet;
-import java.util.Set;
-
-public class DsProcessor extends AbstractProcessor {
-
- boolean hasRun;
-
- public DsProcessor() {
- }
-
- @Override
- public Set<String> getSupportedAnnotationTypes() {
- Set<String> set = new HashSet<String>();
- set.add(org.osgi.service.component.annotations.Component.class.getName());
- return set;
- }
-
- @Override
- public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
- if (!hasRun) {
- hasRun = true;
- // Add the Karaf embedded package
- try (PrintWriter w = appendResource("META-INF/org.apache.karaf.boot.bnd")) {
- w.println("_dsannotations: *");
- } catch (Exception e) {
- processingEnv.getMessager().printMessage(Kind.ERROR, "Error: " + e.getMessage());
- }
- }
- return true;
- }
-
- private PrintWriter appendResource(String resource) throws IOException {
- try {
- FileObject o = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", resource);
- return new PrintWriter(o.openWriter());
- } catch (Exception e) {
- try {
- FileObject o = processingEnv.getFiler().getResource(StandardLocation.CLASS_OUTPUT, "", resource);
- CharArrayWriter baos = new CharArrayWriter();
- try (Reader r = o.openReader(true)) {
- char[] buf = new char[4096];
- int l;
- while ((l = r.read(buf)) > 0) {
- baos.write(buf, 0, l);
- }
- }
- o.delete();
- o = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", resource);
- Writer w = o.openWriter();
- w.write(baos.toCharArray());
- return new PrintWriter(w);
- } catch (Exception e2) {
- e2.addSuppressed(e);
- e2.printStackTrace();
- throw e2;
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-starters/karaf-boot-starter-ds/src/main/resources/META-INF/services/javax.annotation.processing.Processor
----------------------------------------------------------------------
diff --git a/karaf-boot-starters/karaf-boot-starter-ds/src/main/resources/META-INF/services/javax.annotation.processing.Processor b/karaf-boot-starters/karaf-boot-starter-ds/src/main/resources/META-INF/services/javax.annotation.processing.Processor
deleted file mode 100644
index 11ef8af..0000000
--- a/karaf-boot-starters/karaf-boot-starter-ds/src/main/resources/META-INF/services/javax.annotation.processing.Processor
+++ /dev/null
@@ -1 +0,0 @@
-org.apache.karaf.boot.ds.impl.DsProcessor
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-starters/karaf-boot-starter-jpa/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-starters/karaf-boot-starter-jpa/pom.xml b/karaf-boot-starters/karaf-boot-starter-jpa/pom.xml
deleted file mode 100644
index c0ce5b8..0000000
--- a/karaf-boot-starters/karaf-boot-starter-jpa/pom.xml
+++ /dev/null
@@ -1,57 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<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">
-
- <!--
-
- 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.
- -->
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-starters</artifactId>
- <version>1.0.0-SNAPSHOT</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
-
- <artifactId>karaf-boot-starter-jpa</artifactId>
-
- <dependencies>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>osgi.cmpn</artifactId>
- <version>${osgi.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-jpa_2.0_spec</artifactId>
- <version>1.1</version>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <compilerArgument>-proc:none</compilerArgument>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/EclipseLink.java
----------------------------------------------------------------------
diff --git a/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/EclipseLink.java b/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/EclipseLink.java
deleted file mode 100644
index f1cba0d..0000000
--- a/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/EclipseLink.java
+++ /dev/null
@@ -1,4 +0,0 @@
-package org.apache.karaf.boot.jpa;
-
-public interface EclipseLink {
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/Hibernate.java
----------------------------------------------------------------------
diff --git a/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/Hibernate.java b/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/Hibernate.java
deleted file mode 100644
index ae4dab3..0000000
--- a/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/Hibernate.java
+++ /dev/null
@@ -1,91 +0,0 @@
-package org.apache.karaf.boot.jpa;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-import org.apache.karaf.boot.jpa.PersistentUnit.ProviderProperty;
-
-public interface Hibernate {
-
- @ProviderProperty("hibernate.query.substitutions")
- @Target(ElementType.TYPE)
- @Retention(RetentionPolicy.SOURCE)
- @interface QuerySubstitutions {
- String value();
- }
-
- @ProviderProperty("hibernate.hbm2ddl.auto")
- @Target(ElementType.TYPE)
- @Retention(RetentionPolicy.SOURCE)
- @interface Hbm2DdlAuto {
- Value value();
- enum Value {
- Validate,
- Update,
- Create,
- CreateDrop;
-
- public String toString() {
- return super.toString().toLowerCase();
- }
- }
- }
-
- @ProviderProperty("hibernate.dialect")
- @Target(ElementType.TYPE)
- @Retention(RetentionPolicy.SOURCE)
- @interface Dialect {
- Value value();
- enum Value {
- Cache71,
- DataDirectOracle9,
- DB2390,
- DB2400,
- DB2,
- Derby,
- Firebird,
- FrontBase,
- H2,
- HSQL,
- Informix,
- Ingres10,
- Ingres9,
- Ingres,
- Interbase,
- JDataStore,
- Mckoi,
- MimerSQL,
- MySQL5,
- MySQL5InnoDB,
- MySQL,
- MySQLInnoDB,
- MySQLMyISAM,
- Oracle10g,
- Oracle8i,
- Oracle9,
- Oracle9i,
- Oracle,
- Pointbase,
- PostgresPlus,
- PostgreSQL,
- Progress,
- RDMSOS2200,
- SAPDB,
- SQLServer2008,
- SQLServer,
- Sybase11,
- SybaseAnywhere,
- SybaseASE15,
- Sybase,
- Teradata,
- TimesTen;
-
- public String toString() {
- return "org.hibernate.dialect." + super.toString() + "Dialect";
- }
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/OpenJpa.java
----------------------------------------------------------------------
diff --git a/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/OpenJpa.java b/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/OpenJpa.java
deleted file mode 100644
index 01186fc..0000000
--- a/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/OpenJpa.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package org.apache.karaf.boot.jpa;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-import org.apache.karaf.boot.jpa.PersistentUnit.ProviderProperty;
-
-public interface OpenJpa {
-
- @ProviderProperty("openjpa.AutoClear")
- @Target(ElementType.TYPE)
- @Retention(RetentionPolicy.SOURCE)
- @interface AutoClear {
- Value value();
- enum Value {
- Datastore, All;
- public String toString() {
- return super.toString().toLowerCase();
- }
- }
- }
-
- @ProviderProperty("openjpa.AutoDetach")
- @Target(ElementType.TYPE)
- @Retention(RetentionPolicy.SOURCE)
- @interface AutoDetach {
- Value value();
- enum Value {
- Close, Commit, Nontx_Read;
- public String toString() {
- return super.toString().toLowerCase().replace('_', '-');
- }
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/PersistentUnit.java
----------------------------------------------------------------------
diff --git a/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/PersistentUnit.java b/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/PersistentUnit.java
deleted file mode 100644
index ada2ef3..0000000
--- a/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/PersistentUnit.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package org.apache.karaf.boot.jpa;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Target(ElementType.TYPE)
-@Retention(RetentionPolicy.SOURCE)
-public @interface PersistentUnit {
-
- String name();
-
- String description() default "";
-
- TransactionType transactionType() default TransactionType.RESOURCE_LOCAL;
-
- Provider provider() default Provider.Default;
-
- String providerName() default "";
-
- String jtaDataSource() default "";
-
- String nonJtaDataSource() default "";
-
- // TODO: mapping-file, jar-file, class, exclude-unlisted-classes, shared-cache-mode, validation-mode
-
- Property[] properties() default {};
-
-
- @Target(ElementType.ANNOTATION_TYPE)
- @interface ProviderProperty {
- String value();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/Property.java
----------------------------------------------------------------------
diff --git a/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/Property.java b/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/Property.java
deleted file mode 100644
index 5cce58c..0000000
--- a/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/Property.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package org.apache.karaf.boot.jpa;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
-@Retention(RetentionPolicy.SOURCE)
-public @interface Property {
-
- String name();
-
- String value();
-
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/Provider.java
----------------------------------------------------------------------
diff --git a/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/Provider.java b/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/Provider.java
deleted file mode 100644
index 13a62d4..0000000
--- a/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/Provider.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package org.apache.karaf.boot.jpa;
-
-public enum Provider {
-
- Default,
- Hibernate,
- OpenJpa,
- EclipseLink;
-
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/TransactionType.java
----------------------------------------------------------------------
diff --git a/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/TransactionType.java b/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/TransactionType.java
deleted file mode 100644
index 53e76d2..0000000
--- a/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/TransactionType.java
+++ /dev/null
@@ -1,6 +0,0 @@
-package org.apache.karaf.boot.jpa;
-
-public enum TransactionType {
- RESOURCE_LOCAL,
- JTA
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/impl/JpaProcessor.java
----------------------------------------------------------------------
diff --git a/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/impl/JpaProcessor.java b/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/impl/JpaProcessor.java
deleted file mode 100644
index 4becbc2..0000000
--- a/karaf-boot-starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/impl/JpaProcessor.java
+++ /dev/null
@@ -1,140 +0,0 @@
-package org.apache.karaf.boot.jpa.impl;
-
-import javax.annotation.processing.AbstractProcessor;
-import javax.annotation.processing.Messager;
-import javax.annotation.processing.RoundEnvironment;
-import javax.lang.model.element.AnnotationMirror;
-import javax.lang.model.element.AnnotationValue;
-import javax.lang.model.element.Element;
-import javax.lang.model.element.TypeElement;
-import javax.tools.Diagnostic.Kind;
-import javax.tools.FileObject;
-import javax.tools.StandardLocation;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.Writer;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.karaf.boot.jpa.PersistentUnit;
-import org.apache.karaf.boot.jpa.Property;
-import org.apache.karaf.boot.jpa.Provider;
-
-public class JpaProcessor extends AbstractProcessor {
-
- public JpaProcessor() {
- }
-
- @Override
- public Set<String> getSupportedAnnotationTypes() {
- return new HashSet<String>(Arrays.asList(
- PersistentUnit.class.getName()
- ));
- }
-
- @Override
- public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
- Map<PersistentUnit, List<? extends AnnotationMirror>> units = new HashMap<PersistentUnit, List<? extends AnnotationMirror>>();
-
-
- for (Element elem : roundEnv.getElementsAnnotatedWith(PersistentUnit.class)) {
- PersistentUnit pu = elem.getAnnotation(PersistentUnit.class);
- units.put(pu, elem.getAnnotationMirrors());
- }
- if (!units.isEmpty()) {
- try {
- Set<String> puNames = new HashSet<String>();
- FileObject o = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT,
- "", "META-INF/persistence.xml");
- PrintWriter w = new PrintWriter(o.openWriter());
- w.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
- w.println("<persistence version=\"2.0\" xmlns=\"http://java.sun.com/xml/ns/persistence\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd\">");
- for (PersistentUnit pu : units.keySet()) {
- if (pu.name() == null || pu.name().isEmpty()) {
- throw new IOException("Missing persistent unit name");
- }
- if (!puNames.add(pu.name())) {
- throw new IOException("Duplicate persistent unit name: " + pu.name());
- }
- w.println(" <persistence-unit name=\"" + pu.name() + "\" transaction-type=\"" + pu.transactionType().toString() + "\">");
- if (!pu.description().isEmpty()) {
- w.println(" <description>" + pu.description() + "</description>");
- }
- if (pu.provider() != Provider.Default || !pu.providerName().isEmpty()) {
- if (pu.provider() != Provider.Default && !pu.providerName().isEmpty()) {
- throw new IOException("At most one of provider and providerName can be used");
- }
- String name;
- if (!pu.providerName().isEmpty()) {
- name = pu.providerName();
- } else {
- switch (pu.provider()) {
- case Hibernate:
- name = "org.hibernate.jpa.HibernatePersistenceProvider";
- break;
- default:
- // TODO
- throw new IOException("Unsupported provider: " + pu.provider());
- }
- }
- w.println(" <provider>" + name + "</provider>");
- }
- if (!pu.jtaDataSource().isEmpty()) {
- w.println(" <jta-data-source>" + pu.jtaDataSource() + "</jta-data-source>");
- }
- if (!pu.nonJtaDataSource().isEmpty()) {
- w.println(" <non-jta-data-source>" + pu.nonJtaDataSource() + "</non-jta-data-source>");
- }
- if (pu.properties().length > 0) {
- w.println(" <properties>");
- for (Property property : pu.properties()) {
- w.println(" <property name=\"" + property.name() + "\" value=\"" + property.value() + "\"/>");
- }
-
-
- for (AnnotationMirror annMirror : units.get(pu)) {
-
- String name = null;
- for (AnnotationMirror a : processingEnv.getElementUtils().getAllAnnotationMirrors(annMirror.getAnnotationType().asElement())) {
- if (a.toString().startsWith("@org.apache.karaf.boot.jpa.PersistentUnit.ProviderProperty")) {
- name = a.getElementValues().values().iterator().next().getValue().toString();
- break;
- }
- }
- if (name != null) {
- String value = annMirror.getElementValues().values().iterator().next().getValue().toString();
- w.println(" <property name=\"" + name + "\" value=\"" + value + "\"/>");
- }
-// processingEnv.getMessager().printMessage(Kind.MANDATORY_WARNING, "Annotation: " + annMirror);
-// processingEnv.getMessager().printMessage(Kind.MANDATORY_WARNING, "Annotation type: " + annMirror.getAnnotationType());
-// processingEnv.getMessager().printMessage(Kind.MANDATORY_WARNING, "Annotation annot: " + annMirror.getAnnotationType().getAnnotationMirrors());
-// processingEnv.getMessager().printMessage(Kind.MANDATORY_WARNING, "Annotation annot: " + processingEnv.getElementUtils().getAllAnnotationMirrors(annMirror.getAnnotationType().asElement()));
-// processingEnv.getMessager().printMessage(Kind.MANDATORY_WARNING, "Annotation values: " + annMirror.getElementValues());
-// if (annMirror.getAnnotationType().getAnnotation(PersistentUnit.ProviderProperty.class) != null) {
-// processingEnv.getMessager().printMessage(Kind.MANDATORY_WARNING, "Annotation ok");
-// } else {
-// processingEnv.getMessager().printMessage(Kind.MANDATORY_WARNING, "Annotation nok");
-// }
- }
-
- w.println(" </properties>");
- }
- w.println(" </persistence-unit>");
- }
- w.println("</persistence>");
- w.close();
- processingEnv.getMessager().printMessage(Kind.NOTE, "Generated META-INF/persistence.xml");
- } catch (IOException e) {
- processingEnv.getMessager().printMessage(Kind.ERROR, "Error: " + e.getMessage());
- }
- }
- return true;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-starters/karaf-boot-starter-jpa/src/main/resources/META-INF/services/javax.annotation.processing.Processor
----------------------------------------------------------------------
diff --git a/karaf-boot-starters/karaf-boot-starter-jpa/src/main/resources/META-INF/services/javax.annotation.processing.Processor b/karaf-boot-starters/karaf-boot-starter-jpa/src/main/resources/META-INF/services/javax.annotation.processing.Processor
deleted file mode 100644
index eb83448..0000000
--- a/karaf-boot-starters/karaf-boot-starter-jpa/src/main/resources/META-INF/services/javax.annotation.processing.Processor
+++ /dev/null
@@ -1 +0,0 @@
-org.apache.karaf.boot.jpa.impl.JpaProcessor
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-starters/karaf-boot-starter-karaf/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-starters/karaf-boot-starter-karaf/pom.xml b/karaf-boot-starters/karaf-boot-starter-karaf/pom.xml
deleted file mode 100644
index 32bec48..0000000
--- a/karaf-boot-starters/karaf-boot-starter-karaf/pom.xml
+++ /dev/null
@@ -1,57 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<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">
-
- <!--
-
- 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.
- -->
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-starters</artifactId>
- <version>1.0.0-SNAPSHOT</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
-
- <artifactId>karaf-boot-starter-karaf</artifactId>
-
- <dependencies>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- <version>${osgi.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.karaf</groupId>
- <artifactId>org.apache.karaf.util</artifactId>
- <version>${karaf.version}</version>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <compilerArgument>-proc:none</compilerArgument>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-starters/karaf-boot-starter-karaf/src/main/java/org/apache/karaf/boot/karaf/impl/KarafProcessor.java
----------------------------------------------------------------------
diff --git a/karaf-boot-starters/karaf-boot-starter-karaf/src/main/java/org/apache/karaf/boot/karaf/impl/KarafProcessor.java b/karaf-boot-starters/karaf-boot-starter-karaf/src/main/java/org/apache/karaf/boot/karaf/impl/KarafProcessor.java
deleted file mode 100644
index e51380e..0000000
--- a/karaf-boot-starters/karaf-boot-starter-karaf/src/main/java/org/apache/karaf/boot/karaf/impl/KarafProcessor.java
+++ /dev/null
@@ -1,154 +0,0 @@
-package org.apache.karaf.boot.karaf.impl;
-
-import javax.annotation.processing.AbstractProcessor;
-import javax.annotation.processing.RoundEnvironment;
-import javax.lang.model.element.AnnotationMirror;
-import javax.lang.model.element.AnnotationValue;
-import javax.lang.model.element.Element;
-import javax.lang.model.element.ExecutableElement;
-import javax.lang.model.element.TypeElement;
-import javax.tools.Diagnostic.Kind;
-import javax.tools.FileObject;
-import javax.tools.StandardLocation;
-import java.io.CharArrayWriter;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.PrintWriter;
-import java.io.Reader;
-import java.io.Writer;
-import java.lang.annotation.Annotation;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-
-import org.apache.karaf.util.tracker.annotation.Managed;
-import org.apache.karaf.util.tracker.annotation.ProvideService;
-import org.apache.karaf.util.tracker.annotation.RequireService;
-import org.apache.karaf.util.tracker.annotation.Services;
-
-public class KarafProcessor extends AbstractProcessor {
-
- boolean hasRun;
-
- public KarafProcessor() {
- }
-
- @Override
- public Set<String> getSupportedAnnotationTypes() {
- Set<String> set = new HashSet<String>();
- set.add(Services.class.getName());
- set.add(Managed.class.getName());
- return set;
- }
-
- @Override
- public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
- List<String> instructions = new ArrayList<>();
- Properties props = new Properties();
-
- for (Element elem : roundEnv.getElementsAnnotatedWith(Services.class)) {
- for (AnnotationMirror mirror : elem.getAnnotationMirrors()) {
- if (Services.class.getName().equals(((TypeElement) mirror.getAnnotationType().asElement()).getQualifiedName().toString())) {
- Map<String, Object> values = getAnnotationValues(mirror);
- if (values.containsKey("provides")) {
- for (AnnotationMirror p : (List<AnnotationMirror>) values.get("provides")) {
- Map<String, Object> pv = getAnnotationValues(p);
- String n = pv.get("value").toString();
- instructions.add("Provide-Capability: osgi.service;effective:=active;objectClass=" + n);
- }
- }
- if (values.containsKey("requires")) {
- for (AnnotationMirror r : (List<AnnotationMirror>) values.get("requires")) {
- Map<String, Object> rv = getAnnotationValues(r);
- String value = rv.get("value").toString();
- String filter = (String) rv.getOrDefault("filter", "");
- boolean opt = ((Boolean) rv.getOrDefault("optional", false));
-
- String fltWithClass = combine(filter, "(objectClass=" + value + ")");
- instructions.add("Require-Capability: osgi.service;effective:=active;filter:=\"" + fltWithClass + "\"");
- props.setProperty(value, filter);
- }
- }
- }
- }
- instructions.add("Bundle-Activator: " + ((TypeElement) elem).getQualifiedName().toString());
-
- Managed managed = elem.getAnnotation(Managed.class);
- if (managed != null) {
- props.setProperty("pid", managed.value());
- }
-
- String name = "OSGI-INF/karaf-tracker/" + ((TypeElement) elem).getQualifiedName().toString();
- try (OutputStream os = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", name).openOutputStream()) {
- props.store(os, null);
- } catch (IOException e) {
- processingEnv.getMessager().printMessage(Kind.ERROR, "Error writing to " + name + ": " + e.getMessage());
- }
- }
-
- instructions.add("Private-Package: org.apache.karaf.util.tracker");
- instructions.add("PREPEND-Import-Package: !org.apache.karaf.util.tracker.annotation");
-
- if (!hasRun) {
- hasRun = true;
- // Add the Karaf embedded package
- try (PrintWriter w = appendResource("META-INF/org.apache.karaf.boot.bnd")) {
- for (String instr : instructions) {
- w.println(instr);
- }
- } catch (Exception e) {
- processingEnv.getMessager().printMessage(Kind.ERROR, "Error writing to META-INF/org.apache.karaf.boot.bnd: " + e.getMessage());
- }
- }
-
- return true;
- }
-
- private Map<String, Object> getAnnotationValues(AnnotationMirror mirror) {
- Map<String, Object> map = new HashMap<>();
- for (Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> entry : mirror.getElementValues().entrySet()) {
- map.put(entry.getKey().getSimpleName().toString(), entry.getValue().getValue());
- }
- return map;
- }
-
- private String combine(String filter1, String filter2) {
- if (filter1!=null && !filter1.isEmpty()) {
- return "(&" + filter2 + filter1 + ")";
- } else {
- return filter2;
- }
- }
-
- private PrintWriter appendResource(String resource) throws IOException {
- try {
- FileObject o = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", resource);
- return new PrintWriter(o.openWriter());
- } catch (Exception e) {
- try {
- FileObject o = processingEnv.getFiler().getResource(StandardLocation.CLASS_OUTPUT, "", resource);
- CharArrayWriter baos = new CharArrayWriter();
- try (Reader r = o.openReader(true)) {
- char[] buf = new char[4096];
- int l;
- while ((l = r.read(buf)) > 0) {
- baos.write(buf, 0, l);
- }
- }
- o.delete();
- o = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", resource);
- Writer w = o.openWriter();
- w.write(baos.toCharArray());
- return new PrintWriter(w);
- } catch (Exception e2) {
- e2.addSuppressed(e);
- e2.printStackTrace();
- throw e2;
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-starters/karaf-boot-starter-karaf/src/main/resources/META-INF/services/javax.annotation.processing.Processor
----------------------------------------------------------------------
diff --git a/karaf-boot-starters/karaf-boot-starter-karaf/src/main/resources/META-INF/services/javax.annotation.processing.Processor b/karaf-boot-starters/karaf-boot-starter-karaf/src/main/resources/META-INF/services/javax.annotation.processing.Processor
deleted file mode 100644
index c45090b..0000000
--- a/karaf-boot-starters/karaf-boot-starter-karaf/src/main/resources/META-INF/services/javax.annotation.processing.Processor
+++ /dev/null
@@ -1 +0,0 @@
-org.apache.karaf.boot.karaf.impl.KarafProcessor
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-starters/karaf-boot-starter-shell/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-starters/karaf-boot-starter-shell/pom.xml b/karaf-boot-starters/karaf-boot-starter-shell/pom.xml
deleted file mode 100644
index 28523c7..0000000
--- a/karaf-boot-starters/karaf-boot-starter-shell/pom.xml
+++ /dev/null
@@ -1,52 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<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">
-
- <!--
-
- 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.
- -->
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-starters</artifactId>
- <version>1.0.0-SNAPSHOT</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
-
- <artifactId>karaf-boot-starter-shell</artifactId>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.karaf.shell</groupId>
- <artifactId>org.apache.karaf.shell.core</artifactId>
- <version>${karaf.version}</version>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <compilerArgument>-proc:none</compilerArgument>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
-</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-starters/karaf-boot-starter-shell/src/main/java/org/apache/karaf/boot/shell/impl/ShellProcessor.java
----------------------------------------------------------------------
diff --git a/karaf-boot-starters/karaf-boot-starter-shell/src/main/java/org/apache/karaf/boot/shell/impl/ShellProcessor.java b/karaf-boot-starters/karaf-boot-starter-shell/src/main/java/org/apache/karaf/boot/shell/impl/ShellProcessor.java
deleted file mode 100644
index 3de3bfb..0000000
--- a/karaf-boot-starters/karaf-boot-starter-shell/src/main/java/org/apache/karaf/boot/shell/impl/ShellProcessor.java
+++ /dev/null
@@ -1,84 +0,0 @@
-package org.apache.karaf.boot.shell.impl;
-
-import javax.annotation.processing.AbstractProcessor;
-import javax.annotation.processing.RoundEnvironment;
-import javax.lang.model.element.Element;
-import javax.lang.model.element.TypeElement;
-import javax.tools.Diagnostic.Kind;
-import javax.tools.FileObject;
-import javax.tools.StandardLocation;
-import java.io.CharArrayWriter;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.Reader;
-import java.io.Writer;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.TreeSet;
-
-import org.apache.karaf.shell.api.action.lifecycle.Service;
-
-public class ShellProcessor extends AbstractProcessor {
-
- boolean hasRun;
-
- public ShellProcessor() {
- }
-
- @Override
- public Set<String> getSupportedAnnotationTypes() {
- Set<String> set = new HashSet<String>();
- set.add(Service.class.getName());
- return set;
- }
-
- @Override
- public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
- Set<String> packages = new TreeSet<>();
- for (Element elem : roundEnv.getElementsAnnotatedWith(Service.class)) {
- packages.add(elem.getEnclosingElement().toString());
- }
-
- if (!packages.isEmpty()) {
- if (!hasRun) {
- hasRun = true;
- // Add the Karaf embedded package
- try (PrintWriter w = appendResource("META-INF/org.apache.karaf.boot.bnd")) {
- w.println("Karaf-Commands: " + String.join(",", packages));
- } catch (Exception e) {
- processingEnv.getMessager().printMessage(Kind.ERROR, "Error writing to META-INF/org.apache.karaf.boot.bnd: " + e.getMessage());
- }
- }
- }
-
- return true;
- }
-
- private PrintWriter appendResource(String resource) throws IOException {
- try {
- FileObject o = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", resource);
- return new PrintWriter(o.openWriter());
- } catch (Exception e) {
- try {
- FileObject o = processingEnv.getFiler().getResource(StandardLocation.CLASS_OUTPUT, "", resource);
- CharArrayWriter baos = new CharArrayWriter();
- try (Reader r = o.openReader(true)) {
- char[] buf = new char[4096];
- int l;
- while ((l = r.read(buf)) > 0) {
- baos.write(buf, 0, l);
- }
- }
- o.delete();
- o = processingEnv.getFiler().createResource(StandardLocation.CLASS_OUTPUT, "", resource);
- Writer w = o.openWriter();
- w.write(baos.toCharArray());
- return new PrintWriter(w);
- } catch (Exception e2) {
- e2.addSuppressed(e);
- e2.printStackTrace();
- throw e2;
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-starters/karaf-boot-starter-shell/src/main/resources/META-INF/services/javax.annotation.processing.Processor
----------------------------------------------------------------------
diff --git a/karaf-boot-starters/karaf-boot-starter-shell/src/main/resources/META-INF/services/javax.annotation.processing.Processor b/karaf-boot-starters/karaf-boot-starter-shell/src/main/resources/META-INF/services/javax.annotation.processing.Processor
deleted file mode 100644
index 3ebe726..0000000
--- a/karaf-boot-starters/karaf-boot-starter-shell/src/main/resources/META-INF/services/javax.annotation.processing.Processor
+++ /dev/null
@@ -1 +0,0 @@
-org.apache.karaf.boot.shell.impl.ShellProcessor
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-starters/karaf-boot-starter-web/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-starters/karaf-boot-starter-web/pom.xml b/karaf-boot-starters/karaf-boot-starter-web/pom.xml
deleted file mode 100644
index 54bc3c5..0000000
--- a/karaf-boot-starters/karaf-boot-starter-web/pom.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<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">
-
- <!--
-
- 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.
- -->
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-starters</artifactId>
- <version>1.0.0-SNAPSHOT</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
-
- <artifactId>karaf-boot-starter-web</artifactId>
-
- <dependencies>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>javax.servlet-api</artifactId>
- <version>3.1.0</version>
- </dependency>
- </dependencies>
-
-</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-starters/karaf-boot-starter/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-starters/karaf-boot-starter/pom.xml b/karaf-boot-starters/karaf-boot-starter/pom.xml
deleted file mode 100644
index e5b2742..0000000
--- a/karaf-boot-starters/karaf-boot-starter/pom.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<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">
-
- <!--
-
- 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.
- -->
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-starters</artifactId>
- <version>1.0.0-SNAPSHOT</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
-
- <artifactId>karaf-boot-starter</artifactId>
-
- <dependencies>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- <version>${osgi.version}</version>
- </dependency>
- </dependencies>
-
-</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-starters/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-starters/pom.xml b/karaf-boot-starters/pom.xml
deleted file mode 100644
index 57dbd39..0000000
--- a/karaf-boot-starters/pom.xml
+++ /dev/null
@@ -1,45 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<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">
-
- <!--
-
- 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.
- -->
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-build</artifactId>
- <version>1.0.0-SNAPSHOT</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
-
- <artifactId>karaf-boot-starters</artifactId>
- <packaging>pom</packaging>
-
- <modules>
- <module>karaf-boot-starter</module>
- <module>karaf-boot-starter-karaf</module>
- <module>karaf-boot-starter-ds</module>
- <module>karaf-boot-starter-shell</module>
- <module>karaf-boot-starter-web</module>
- <module>karaf-boot-starter-jpa</module>
- <module>karaf-boot-starter-cdi</module>
- <module>karaf-boot-starter-blueprint</module>
- </modules>
-
-</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-tools/karaf-boot-maven-plugin/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/pom.xml b/karaf-boot-tools/karaf-boot-maven-plugin/pom.xml
deleted file mode 100644
index 8897be1..0000000
--- a/karaf-boot-tools/karaf-boot-maven-plugin/pom.xml
+++ /dev/null
@@ -1,85 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<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">
-
- <!--
-
- 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.
- -->
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.karaf.boot</groupId>
- <artifactId>karaf-boot-tools</artifactId>
- <version>1.0.0-SNAPSHOT</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
-
- <artifactId>karaf-boot-maven-plugin</artifactId>
- <packaging>maven-plugin</packaging>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-plugin-api</artifactId>
- <version>3.1.1</version>
- </dependency>
- <dependency>
- <groupId>org.apache.maven.plugin-tools</groupId>
- <artifactId>maven-plugin-annotations</artifactId>
- <version>3.3</version>
- </dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-core</artifactId>
- <version>3.1.1</version>
- </dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-model</artifactId>
- <version>3.2.1</version>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-plugin-plugin</artifactId>
- <version>3.3</version>
- <configuration>
- <goalPrefix>karaf-boot</goalPrefix>
- <skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
- </configuration>
- <executions>
- <execution>
- <id>generate-descriptor</id>
- <goals>
- <goal>descriptor</goal>
- </goals>
- </execution>
- <execution>
- <id>generate-helpmojo</id>
- <goals>
- <goal>helpmojo</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
-</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/maven/GenerateMojo.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/maven/GenerateMojo.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/maven/GenerateMojo.java
deleted file mode 100644
index dd88688..0000000
--- a/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/maven/GenerateMojo.java
+++ /dev/null
@@ -1,124 +0,0 @@
-package org.apache.karaf.boot.maven;
-
-import org.apache.maven.execution.MavenSession;
-import org.apache.maven.model.Plugin;
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.BuildPluginManager;
-import org.apache.maven.plugin.MojoExecution;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.descriptor.*;
-import org.apache.maven.plugins.annotations.*;
-import org.apache.maven.plugins.annotations.Parameter;
-import org.apache.maven.project.MavenProject;
-import org.codehaus.plexus.util.xml.Xpp3Dom;
-import org.codehaus.plexus.util.xml.Xpp3DomBuilder;
-
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.StringReader;
-import java.nio.file.Files;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-@Mojo(name = "generate", threadSafe = true, defaultPhase = LifecyclePhase.PROCESS_CLASSES, requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME, inheritByDefault = false)
-public class GenerateMojo extends AbstractMojo {
-
- @Parameter(defaultValue = "${project}", required = true, readonly = true)
- private MavenProject mavenProject;
-
- @Parameter(defaultValue = "${session}", required = true, readonly = true)
- private MavenSession mavenSession;
-
- @Component
- private BuildPluginManager pluginManager;
-
- public void execute() throws MojoExecutionException {
- try {
- //
- // Felix Bundle plugin
- //
-
- Map<String, String> instructions = new LinkedHashMap<>();
- // Starters supplied instructions
- File bndInst = new File(mavenProject.getBasedir(), "target/classes/META-INF/org.apache.karaf.boot.bnd");
- if (bndInst.isFile()) {
- complete(instructions, bndInst);
- bndInst.delete();
- }
- // User supplied instructions
- bndInst = new File(mavenProject.getBasedir(), "osgi.bnd");
- if (bndInst.isFile()) {
- complete(instructions, bndInst);
- }
- // Verify and use defaults
- if (instructions.containsKey("Import-Package")) {
- instructions.put("Import-Package", instructions.get("Import-Package") + ",*");
- }
- // Build config
- StringBuilder config = new StringBuilder();
- config.append("<configuration>" +
- "<finalName>${project.build.finalName}</finalName>" +
- "<outputDirectory>${project.build.outputDirectory}</outputDirectory>" +
- "<m_mavenSession>${session}</m_mavenSession>" +
- "<project>${project}</project>" +
- "<buildDirectory>${project.build.directory}</buildDirectory>" +
- "<supportedProjectTypes>" +
- "<supportedProjectType>jar</supportedProjectType>" +
- "<supportedProjectType>bundle</supportedProjectType>" +
- "<supportedProjectType>war</supportedProjectType>" +
- "</supportedProjectTypes>" +
- "<instructions>");
- for (Map.Entry<String, String> entry : instructions.entrySet()) {
- config.append("<").append(entry.getKey()).append(">")
- .append(entry.getValue())
- .append("</").append(entry.getKey()).append(">");
- }
- config.append("</instructions>" +
- "</configuration>");
- Xpp3Dom configuration = Xpp3DomBuilder.build(new StringReader(config.toString()));
- // Invoke plugin
- getLog().info("Invoking maven-bundle-plugin");
- Plugin felixBundlePlugin = new Plugin();
- felixBundlePlugin.setGroupId("org.apache.felix");
- felixBundlePlugin.setArtifactId("maven-bundle-plugin");
- felixBundlePlugin.setVersion("3.0.0");
- felixBundlePlugin.setInherited(true);
- felixBundlePlugin.setExtensions(true);
- PluginDescriptor felixBundlePluginDescriptor = pluginManager.loadPlugin(felixBundlePlugin, mavenProject.getRemotePluginRepositories(), mavenSession.getRepositorySession());
- MojoDescriptor felixBundleMojoDescriptor = felixBundlePluginDescriptor.getMojo("bundle");
- MojoExecution execution = new MojoExecution(felixBundleMojoDescriptor, configuration);
- pluginManager.executeMojo(mavenSession, execution);
-
- } catch (Exception e) {
- throw new MojoExecutionException("karaf-boot-maven-plugin failed", e);
- }
- }
-
- private void complete(Map<String, String> instructions, File bndInst) throws IOException {
- List<String> lines = Files.readAllLines(bndInst.toPath());
- for (String line : lines) {
- if (!line.contains(":")) {
- continue;
- }
- String name = line.substring(0, line.indexOf(':')).trim();
- String value = line.substring(line.indexOf(':') + 1).trim();
- boolean prepend = false;
- if (name.startsWith("PREPEND-")) {
- prepend = true;
- name = name.substring("PREPEND-".length());
- }
- if (instructions.containsKey(name)) {
- if (prepend) {
- instructions.put(name, value + "," + instructions.get(name));
- } else {
- instructions.put(name, instructions.get(name) + "," + value);
- }
- } else {
- instructions.put(name, value);
- }
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/137222a0/karaf-boot-tools/karaf-boot-maven-plugin/src/main/resources/META-INF/plexus/components.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/main/resources/META-INF/plexus/components.xml b/karaf-boot-tools/karaf-boot-maven-plugin/src/main/resources/META-INF/plexus/components.xml
deleted file mode 100644
index 6fa2eeb..0000000
--- a/karaf-boot-tools/karaf-boot-maven-plugin/src/main/resources/META-INF/plexus/components.xml
+++ /dev/null
@@ -1,61 +0,0 @@
-<!--
- 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.
--->
-<component-set>
- <components>
- <component>
- <role>org.apache.maven.lifecycle.mapping.LifecycleMapping</role>
- <role-hint>jar</role-hint>
- <implementation>org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping</implementation>
- <configuration>
- <lifecycles>
- <lifecycle>
- <id>default</id>
- <phases>
- <process-resources>org.apache.maven.plugins:maven-resources-plugin:resources</process-resources>
- <compile>org.apache.maven.plugins:maven-compiler-plugin:compile</compile>
- <process-classes>org.apache.karaf.boot:karaf-boot-maven-plugin:generate</process-classes>
- <process-test-resources>org.apache.maven.plugins:maven-resources-plugin:testResources</process-test-resources>
- <test-compile>org.apache.maven.plugins:maven-compiler-plugin:testCompile</test-compile>
- <test>org.apache.maven.plugins:maven-surefire-plugin:test</test>
- <install>
- org.apache.maven.plugins:maven-install-plugin:install
- </install>
- <deploy>
- org.apache.maven.plugins:maven-deploy-plugin:deploy
- </deploy>
- </phases>
- </lifecycle>
- </lifecycles>
- </configuration>
- </component>
- <component>
- <role>org.apache.maven.artifact.handler.ArtifactHandler</role>
- <role-hint>bundle</role-hint>
- <implementation>org.apache.maven.artifact.handler.DefaultArtifactHandler</implementation>
- <configuration>
- <type>jar</type>
- <includesDependencies>false</includesDependencies>
- <language>java</language>
- <extension>jar</extension>
- <addedToClasspath>true</addedToClasspath>
- <packaging>jar</packaging>
- </configuration>
- </component>
- </components>
-</component-set>
[02/35] karaf-boot git commit: Initial proposal
Posted by cs...@apache.org.
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/a0248b78/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/ProducedBean.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/ProducedBean.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/ProducedBean.java
new file mode 100644
index 0000000..b5e8b11
--- /dev/null
+++ b/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/ProducedBean.java
@@ -0,0 +1,13 @@
+package org.apache.karaf.boot.tools.maven.plugin.model;
+
+public class ProducedBean extends Bean {
+ public String factoryMethod;
+ public String factoryBeanId;
+
+ public ProducedBean(Class<?> clazz, String factoryBeanId, String factoryMethod) {
+ super(clazz);
+ this.factoryBeanId = factoryBeanId;
+ this.factoryMethod = factoryMethod;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/a0248b78/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/Property.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/Property.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/Property.java
new file mode 100644
index 0000000..4ec7e5a
--- /dev/null
+++ b/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/Property.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 org.apache.karaf.boot.tools.maven.plugin.model;
+
+import java.lang.reflect.Field;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.beans.factory.annotation.Value;
+
+public class Property implements Comparable<Property> {
+ public String name;
+ public String ref;
+ public String value;
+
+ public Property(String name, String ref, String value) {
+ this.name = name;
+ this.ref = ref;
+ this.value = value;
+ }
+
+ public static Property create(Matcher matcher, Field field) {
+ Value value = field.getAnnotation(Value.class);
+ if (needsInject(field)) {
+ BeanRef matching = matcher.getMatching(new BeanRef(field));
+ String ref = (matching == null) ? getRefName(field) : matching.id;
+ return new Property(field.getName(), ref, null);
+ } else if (value != null){
+ return new Property(field.getName(), null, cleanValue(value.value()));
+ } else {
+ // Field is not a property
+ return null;
+ }
+ }
+
+ /**
+ * Assume it is defined in another manually created blueprint context with default name
+ * @param field
+ * @return
+ */
+ private static String getRefName(Field field) {
+ Named named = field.getAnnotation(Named.class);
+ if (named != null) {
+ return named.value();
+ }
+ Qualifier qualifier = field.getAnnotation(Qualifier.class);
+ if (qualifier != null) {
+ return qualifier.value();
+ }
+ return Bean.getBeanName(field.getType());
+ }
+
+ private static boolean needsInject(Field field) {
+ return field.getAnnotation(Autowired.class) != null || field.getAnnotation(Inject.class) != null;
+ }
+
+ /**
+ * Remove default value definition
+ *
+ * @param value
+ * @return
+ */
+ private static String cleanValue(String value) {
+ return value.replaceAll("\\:.*\\}", "}");
+ }
+
+ public int compareTo(Property other) {
+ return name.compareTo(other.name);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/a0248b78/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/PropertyWriter.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/PropertyWriter.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/PropertyWriter.java
new file mode 100644
index 0000000..e8e6bda
--- /dev/null
+++ b/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/PropertyWriter.java
@@ -0,0 +1,23 @@
+/**
+ * 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.karaf.boot.tools.maven.plugin.model;
+
+public interface PropertyWriter {
+ void writeProperty(Property property);
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/a0248b78/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/SpringTransactionFactory.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/SpringTransactionFactory.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/SpringTransactionFactory.java
new file mode 100644
index 0000000..4d65261
--- /dev/null
+++ b/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/SpringTransactionFactory.java
@@ -0,0 +1,40 @@
+/**
+ * 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.karaf.boot.tools.maven.plugin.model;
+
+import java.util.HashMap;
+
+import org.springframework.transaction.annotation.Propagation;
+import org.springframework.transaction.annotation.Transactional;
+
+public class SpringTransactionFactory {
+ private static HashMap<Propagation, String> txTypeNames;
+
+ static {
+ txTypeNames = new HashMap<Propagation, String>();
+ txTypeNames.put(Propagation.REQUIRED, TransactionalDef.TYPE_REQUIRED);
+ txTypeNames.put(Propagation.REQUIRES_NEW, TransactionalDef.TYPE_REQUIRES_NEW);
+ }
+
+ TransactionalDef create(Class<?> clazz) {
+ Transactional transactional = clazz.getAnnotation(Transactional.class);
+ return transactional != null ?
+ new TransactionalDef("*", txTypeNames.get(transactional.propagation())) : null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/a0248b78/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/TransactionalDef.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/TransactionalDef.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/TransactionalDef.java
new file mode 100644
index 0000000..7be6a67
--- /dev/null
+++ b/karaf-boot-tools/karaf-boot-maven-plugin/src/main/java/org/apache/karaf/boot/tools/maven/plugin/model/TransactionalDef.java
@@ -0,0 +1,39 @@
+/**
+ * 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.karaf.boot.tools.maven.plugin.model;
+
+public class TransactionalDef {
+ public static final String TYPE_REQUIRED = "Required";
+ public static final String TYPE_REQUIRES_NEW = "RequiresNew";
+ private String method;
+ private String type;
+
+ public TransactionalDef(String method, String type) {
+ this.method = method;
+ this.type = type;
+ }
+
+ public String getMethod() {
+ return method;
+ }
+
+ public String getType() {
+ return type;
+ }
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/a0248b78/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/GeneratorTest.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/GeneratorTest.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/GeneratorTest.java
new file mode 100644
index 0000000..ff009b3
--- /dev/null
+++ b/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/GeneratorTest.java
@@ -0,0 +1,99 @@
+/**
+ * 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.karaf.boot.tools.maven.plugin;
+
+import static java.util.Arrays.asList;
+import static org.apache.karaf.boot.tools.maven.plugin.FilteredClassFinder.findClasses;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Set;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathFactory;
+
+import org.apache.karaf.boot.tools.maven.plugin.model.Context;
+import org.apache.karaf.boot.tools.maven.plugin.test.MyBean1;
+import org.apache.commons.io.output.ByteArrayOutputStream;
+import org.apache.xbean.finder.ClassFinder;
+import org.junit.Assert;
+import org.junit.Test;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.xml.sax.SAXException;
+
+public class GeneratorTest {
+
+ private XPath xpath;
+ private Document document;
+
+ @Test
+ public void testGenerate() throws Exception {
+ ClassFinder classFinder = new ClassFinder(this.getClass().getClassLoader());
+ String packageName = MyBean1.class.getPackage().getName();
+ Set<Class<?>> beanClasses = findClasses(classFinder, asList(packageName));
+ Context context = new Context(beanClasses);
+ context.resolve();
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+ new Generator(context, os, false).generate();
+ System.out.println(os.toString("UTF-8"));
+
+ document = readToDocument(os);
+ xpath = XPathFactory.newInstance().newXPath();
+ //xpath.setNamespaceContext(new NameSpaces(document));
+ Node bean1 = (Node) xpath.evaluate("/blueprint/bean[@id='myBean1']", document, XPathConstants.NODE);
+
+ // Bean
+ Assert.assertEquals(MyBean1.class.getName(), xpath.evaluate("@class", bean1));
+ Assert.assertEquals("init", xpath.evaluate("@init-method", bean1));
+ Assert.assertEquals("destroy", xpath.evaluate("@destroy-method", bean1));
+ Assert.assertEquals("true", xpath.evaluate("@field-injection", bean1));
+
+ // @Transactional
+ Assert.assertEquals("*", xpath.evaluate("transaction/@method", bean1));
+ Assert.assertEquals("Required", xpath.evaluate("transaction/@value", bean1));
+
+ // @PersistenceContext
+ Assert.assertEquals("person", xpath.evaluate("context/@unitname", bean1));
+ Assert.assertEquals("em", xpath.evaluate("context/@property", bean1));
+
+ // @PersistenceUnit
+ Assert.assertEquals("person", xpath.evaluate("unit/@unitname", bean1));
+ Assert.assertEquals("emf", xpath.evaluate("unit/@property", bean1));
+
+ // @Autowired
+ Assert.assertEquals("my1", xpath.evaluate("property[@name='bean2']/@ref", bean1));
+
+
+ }
+
+ private Document readToDocument(ByteArrayOutputStream os) throws ParserConfigurationException,
+ SAXException, IOException {
+ InputStream is = new ByteArrayInputStream(os.toByteArray());
+ DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder builder = builderFactory.newDocumentBuilder();
+ return builder.parse(is);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/a0248b78/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/Namespaces.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/Namespaces.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/Namespaces.java
new file mode 100644
index 0000000..c4224ce
--- /dev/null
+++ b/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/Namespaces.java
@@ -0,0 +1,54 @@
+/**
+ * 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.karaf.boot.tools.maven.plugin;
+
+import java.util.Iterator;
+
+import javax.xml.XMLConstants;
+import javax.xml.namespace.NamespaceContext;
+
+import org.w3c.dom.Document;
+
+
+public class Namespaces implements NamespaceContext {
+ private Document doc;
+
+ public Namespaces(Document doc) {
+ this.doc = doc;
+ }
+
+ @Override
+ public String getNamespaceURI(String prefix) {
+ if (prefix.equals(XMLConstants.DEFAULT_NS_PREFIX)) {
+ return doc.lookupNamespaceURI(null);
+ } else {
+ return doc.lookupNamespaceURI(prefix);
+ }
+ }
+
+ @Override
+ public String getPrefix(String namespaceURI) {
+ return doc.lookupPrefix(namespaceURI);
+ }
+
+ @Override
+ public Iterator<String> getPrefixes(String namespaceURI) {
+ return null;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/a0248b78/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/model/BeanTest.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/model/BeanTest.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/model/BeanTest.java
new file mode 100644
index 0000000..9f6470f
--- /dev/null
+++ b/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/model/BeanTest.java
@@ -0,0 +1,92 @@
+/**
+ * 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.karaf.boot.tools.maven.plugin.model;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import javax.inject.Named;
+
+import org.apache.karaf.boot.tools.maven.plugin.test.MyBean1;
+import org.apache.karaf.boot.tools.maven.plugin.test.MyBean3;
+import org.apache.karaf.boot.tools.maven.plugin.test.MyBean4;
+import org.apache.karaf.boot.tools.maven.plugin.test.ServiceAImpl1;
+import org.junit.Assert;
+import org.junit.Test;
+
+
+public class BeanTest {
+
+ @Test
+ public void testParseMyBean1() {
+ Bean bean = new Bean(MyBean1.class);
+ bean.resolve(new Context());
+ assertEquals(MyBean1.class, bean.clazz);
+ assertEquals("myBean1", bean.id); // Name derived from class name
+ assertEquals("init", bean.initMethod);
+ assertEquals("destroy", bean.destroyMethod);
+ Assert.assertEquals(2, bean.persistenceFields.length);
+ assertEquals("em", bean.persistenceFields[0].getName());
+ assertEquals("emf", bean.persistenceFields[1].getName());
+ assertEquals("*", bean.transactionDef.getMethod());
+ assertEquals("Required", bean.transactionDef.getType());
+ assertEquals(1, bean.properties.size());
+ Property prop = bean.properties.iterator().next();
+ assertEquals("bean2", prop.name);
+ assertEquals("serviceA", prop.ref);
+ }
+
+ @Test
+ public void testParseMyBean3() {
+ Bean bean = new Bean(MyBean3.class);
+ bean.resolve(new Context());
+ assertEquals(MyBean3.class, bean.clazz);
+ assertEquals("myBean3", bean.id); // Name derived from class name
+ assertNull("There should be no initMethod", bean.initMethod);
+ assertNull("There should be no destroyMethod", bean.destroyMethod);
+ assertEquals("There should be no persistence fields", 0, bean.persistenceFields.length);
+ assertEquals("*", bean.transactionDef.getMethod());
+ assertEquals("RequiresNew", bean.transactionDef.getType());
+ assertEquals(5, bean.properties.size());
+ }
+
+ @Test
+ public void testParseNamedBean() {
+ Bean bean = new Bean(ServiceAImpl1.class);
+ bean.resolve(new Context());
+ String definedName = ServiceAImpl1.class.getAnnotation(Named.class).value();
+ assertEquals("my1", definedName);
+ assertEquals("Name should be defined using @Named", definedName, bean.id);
+ assertNull("There should be no initMethod", bean.initMethod);
+ assertNull("There should be no destroyMethod", bean.destroyMethod);
+ assertEquals("There should be no persistence fields", 0, bean.persistenceFields.length);
+ assertNull("There should be no transaction definition", bean.transactionDef);
+ assertEquals("There should be no properties", 0, bean.properties.size());
+ }
+
+ @Test
+ public void testBlueprintBundleContext() {
+ Bean bean = new Bean(MyBean4.class);
+ bean.resolve(new Context());
+ Property bcProp = bean.properties.iterator().next();
+ assertEquals("bundleContext", bcProp.name);
+ assertEquals("blueprintBundleContext", bcProp.ref);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/a0248b78/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/model/ContextTest.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/model/ContextTest.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/model/ContextTest.java
new file mode 100644
index 0000000..e9a1d12
--- /dev/null
+++ b/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/model/ContextTest.java
@@ -0,0 +1,84 @@
+/**
+ * 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.karaf.boot.tools.maven.plugin.model;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.karaf.boot.tools.maven.plugin.test.MyBean3;
+import org.apache.karaf.boot.tools.maven.plugin.test.MyFactoryBean;
+import org.apache.karaf.boot.tools.maven.plugin.test.MyProduced;
+import org.apache.karaf.boot.tools.maven.plugin.test.ServiceB;
+import org.apache.karaf.boot.tools.maven.plugin.test.ServiceReferences;
+import org.junit.Assert;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.blueprint.container.BlueprintContainer;
+import org.osgi.service.blueprint.container.Converter;
+
+public class ContextTest {
+
+ @Test
+ public void testLists() {
+ Context context = new Context(MyBean3.class);
+ Assert.assertEquals(1, context.getBeans().size());
+ Assert.assertEquals(0, context.getServiceRefs().size());
+ }
+
+ @Test
+ public void testLists2() {
+ Context context = new Context(ServiceReferences.class);
+ Assert.assertEquals(1, context.getBeans().size());
+ Assert.assertEquals(2, context.getServiceRefs().size());
+ }
+
+ @Test
+ public void testMatching() throws NoSuchFieldException, SecurityException {
+ Context context = new Context(ServiceReferences.class);
+ BeanRef matching = context.getMatching(new BeanRef(ServiceB.class));
+ Assert.assertEquals(OsgiServiceRef.class, matching.getClass());
+ Assert.assertEquals(ServiceB.class, matching.clazz);
+ Assert.assertEquals("serviceB", matching.id);
+ }
+
+ private void assertSpecialRef(String expectedId, Class<?> clazz) {
+ Context context = new Context();
+ BeanRef ref = context.getMatching(new BeanRef(clazz));
+ assertEquals(expectedId, ref.id);
+ }
+
+ @Test
+ public void testSpecialRefs() {
+ assertSpecialRef("blueprintBundleContext", BundleContext.class);
+ assertSpecialRef("blueprintBundle", Bundle.class);
+ assertSpecialRef("blueprintContainer", BlueprintContainer.class);
+ assertSpecialRef("blueprintConverter", Converter.class);
+ }
+
+ @Test
+ public void testProduced() throws NoSuchFieldException, SecurityException {
+ Context context = new Context(MyFactoryBean.class);
+
+ ProducedBean matching = (ProducedBean)context.getMatching(new BeanRef(MyProduced.class));
+ Assert.assertEquals(MyProduced.class, matching.clazz);
+ Assert.assertEquals("myFactoryBean", matching.factoryBeanId);
+ Assert.assertEquals("create", matching.factoryMethod);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/a0248b78/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/model/PropertyTest.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/model/PropertyTest.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/model/PropertyTest.java
new file mode 100644
index 0000000..772af11
--- /dev/null
+++ b/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/model/PropertyTest.java
@@ -0,0 +1,73 @@
+/**
+ * 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.karaf.boot.tools.maven.plugin.model;
+
+import java.lang.reflect.Field;
+
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.karaf.boot.tools.maven.plugin.test.ServiceAImpl1;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class PropertyTest {
+ @Test
+ public void testRefInject() throws XMLStreamException {
+ Field field = TestBeanForRef.class.getDeclaredFields()[0];
+ Matcher matcher = new Matcher() {
+ public Bean getMatching(BeanRef template) {
+ return new Bean(ServiceAImpl1.class);
+ }
+ };
+ Property property = Property.create(matcher, field);
+ Assert.assertEquals("serviceA", property.name);
+ Assert.assertNull("Value should be null", property.value);
+ Assert.assertEquals("my1", property.ref);
+ }
+
+ @Test
+ public void testRefAutowired() throws XMLStreamException {
+ Field field = TestBeanForRef.class.getDeclaredFields()[1];
+ Matcher matcher = new Matcher() {
+ public Bean getMatching(BeanRef template) {
+ return null;
+ }
+ };
+ Property property = Property.create(matcher, field);
+ Assert.assertEquals("serviceB", property.name);
+ Assert.assertNull("Value should be null", property.value);
+ Assert.assertEquals("Should be default name as no match is found", "serviceB", property.ref);
+ }
+
+ @Test
+ public void testValue() throws XMLStreamException {
+ Field field = TestBeanForRef.class.getDeclaredFields()[2];
+ Property property = Property.create(null, field);
+ Assert.assertEquals("name", property.name);
+ Assert.assertEquals("${name}", property.value);
+ Assert.assertNull("Ref should be null", property.ref);
+ }
+
+ @Test
+ public void testNoProperty() throws XMLStreamException {
+ Field field = TestBeanForRef.class.getDeclaredFields()[3];
+ Property property = Property.create(null, field);
+ Assert.assertNull("Should not be a property", property);
+ }
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/a0248b78/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/model/TestBeanForRef.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/model/TestBeanForRef.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/model/TestBeanForRef.java
new file mode 100644
index 0000000..2a96d05
--- /dev/null
+++ b/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/model/TestBeanForRef.java
@@ -0,0 +1,39 @@
+/**
+ * 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.karaf.boot.tools.maven.plugin.model;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceUnit;
+
+import org.apache.karaf.boot.tools.maven.plugin.test.ServiceA;
+import org.apache.karaf.boot.tools.maven.plugin.test.ServiceB;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+
+@Singleton
+public class TestBeanForRef {
+ @Inject
+ ServiceA serviceA;
+ @Autowired
+ ServiceB serviceB;
+ @Value("${name:default}") String name;
+ @PersistenceUnit(unitName="myunit") EntityManager em;
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/a0248b78/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/MyBean1.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/MyBean1.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/MyBean1.java
new file mode 100644
index 0000000..248578a
--- /dev/null
+++ b/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/MyBean1.java
@@ -0,0 +1,52 @@
+/**
+ * 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.karaf.boot.tools.maven.plugin.test;
+
+import javax.inject.Singleton;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceUnit;
+import javax.transaction.Transactional;
+import javax.transaction.Transactional.TxType;
+
+import org.springframework.beans.factory.annotation.Autowired;
+
+@Singleton
+@Transactional(value=TxType.REQUIRED)
+public class MyBean1 extends ParentBean {
+
+ @Autowired
+ ServiceA bean2;
+
+ @PersistenceContext(unitName="person")
+ EntityManager em;
+
+ @PersistenceUnit(unitName="person")
+ EntityManager emf;
+
+ public void init() {
+ }
+
+ public void destroy() {
+ }
+
+ public void saveData() {
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/a0248b78/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/MyBean3.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/MyBean3.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/MyBean3.java
new file mode 100644
index 0000000..d96f6c6
--- /dev/null
+++ b/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/MyBean3.java
@@ -0,0 +1,50 @@
+/**
+ * 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.karaf.boot.tools.maven.plugin.test;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.transaction.annotation.Propagation;
+import org.springframework.transaction.annotation.Transactional;
+
+@Singleton
+@Transactional(propagation=Propagation.REQUIRES_NEW)
+public class MyBean3 {
+
+ @Inject
+ @Named("my1")
+ ServiceA serviceA1;
+
+ @Inject
+ @Qualifier("my2")
+ ServiceA serviceA2;
+
+ @Inject
+ ServiceB serviceB;
+
+ @Inject
+ @Named("serviceB2Id")
+ ServiceB serviceB2;
+
+ @Inject
+ MyProduced myProduced;
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/a0248b78/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/MyBean4.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/MyBean4.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/MyBean4.java
new file mode 100644
index 0000000..83a2244
--- /dev/null
+++ b/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/MyBean4.java
@@ -0,0 +1,13 @@
+package org.apache.karaf.boot.tools.maven.plugin.test;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.osgi.framework.BundleContext;
+
+@Singleton
+public class MyBean4 {
+
+ @Inject
+ BundleContext bundleContext;
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/a0248b78/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/MyFactoryBean.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/MyFactoryBean.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/MyFactoryBean.java
new file mode 100644
index 0000000..6442100
--- /dev/null
+++ b/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/MyFactoryBean.java
@@ -0,0 +1,17 @@
+package org.apache.karaf.boot.tools.maven.plugin.test;
+
+import javax.enterprise.inject.Produces;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+@Singleton
+public class MyFactoryBean {
+
+ @Inject
+ ServiceB serviceB;
+
+ @Produces
+ public MyProduced create() {
+ return new MyProduced("My message");
+ }
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/a0248b78/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/MyProduced.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/MyProduced.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/MyProduced.java
new file mode 100644
index 0000000..9426aea
--- /dev/null
+++ b/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/MyProduced.java
@@ -0,0 +1,18 @@
+package org.apache.karaf.boot.tools.maven.plugin.test;
+
+import javax.inject.Inject;
+
+public class MyProduced {
+ private String message;
+
+ @Inject
+ ServiceA serviceA;
+
+ public MyProduced(String message) {
+ this.message = message;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/a0248b78/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/ParentBean.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/ParentBean.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/ParentBean.java
new file mode 100644
index 0000000..dc8f515
--- /dev/null
+++ b/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/ParentBean.java
@@ -0,0 +1,33 @@
+/**
+ * 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.karaf.boot.tools.maven.plugin.test;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+
+public class ParentBean {
+
+ @PostConstruct
+ public void init() {
+ }
+
+ @PreDestroy
+ public void destroy() {
+ }
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/a0248b78/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/ServiceA.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/ServiceA.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/ServiceA.java
new file mode 100644
index 0000000..1897163
--- /dev/null
+++ b/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/ServiceA.java
@@ -0,0 +1,23 @@
+/**
+ * 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.karaf.boot.tools.maven.plugin.test;
+
+public interface ServiceA {
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/a0248b78/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/ServiceAImpl1.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/ServiceAImpl1.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/ServiceAImpl1.java
new file mode 100644
index 0000000..7b6f405
--- /dev/null
+++ b/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/ServiceAImpl1.java
@@ -0,0 +1,28 @@
+/**
+ * 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.karaf.boot.tools.maven.plugin.test;
+
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+@Singleton
+@Named("my1")
+public class ServiceAImpl1 implements ServiceA {
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/a0248b78/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/ServiceAImpl2.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/ServiceAImpl2.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/ServiceAImpl2.java
new file mode 100644
index 0000000..5c17339
--- /dev/null
+++ b/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/ServiceAImpl2.java
@@ -0,0 +1,34 @@
+/**
+ * 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.karaf.boot.tools.maven.plugin.test;
+
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import org.ops4j.pax.cdi.api.OsgiServiceProvider;
+import org.springframework.beans.factory.annotation.Value;
+
+@Singleton
+@Named("my2")
+@OsgiServiceProvider(classes={ServiceA.class})
+public class ServiceAImpl2 implements ServiceA {
+ @Value("${url:http://default}")
+ String url;
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/a0248b78/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/ServiceB.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/ServiceB.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/ServiceB.java
new file mode 100644
index 0000000..e931307
--- /dev/null
+++ b/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/ServiceB.java
@@ -0,0 +1,23 @@
+/**
+ * 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.karaf.boot.tools.maven.plugin.test;
+
+public interface ServiceB {
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/a0248b78/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/ServiceReferences.java
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/ServiceReferences.java b/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/ServiceReferences.java
new file mode 100644
index 0000000..4824bcb
--- /dev/null
+++ b/karaf-boot-tools/karaf-boot-maven-plugin/src/test/java/org/apache/karaf/boot/tools/maven/plugin/test/ServiceReferences.java
@@ -0,0 +1,33 @@
+
+/**
+ * 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.karaf.boot.tools.maven.plugin.test;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+
+import org.ops4j.pax.cdi.api.OsgiService;
+import org.springframework.stereotype.Component;
+
+@Component
+public class ServiceReferences {
+ @Inject @OsgiService ServiceB serviceB;
+
+ @Named("serviceB2Id") @Inject @OsgiService ServiceB serviceB2;
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/a0248b78/karaf-boot-tools/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot-tools/pom.xml b/karaf-boot-tools/pom.xml
new file mode 100644
index 0000000..ccb9c88
--- /dev/null
+++ b/karaf-boot-tools/pom.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+
+ <!--
+
+ 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.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-build</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>karaf-boot-tools</artifactId>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>karaf-boot-maven-plugin</module>
+ </modules>
+
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/a0248b78/karaf-boot/README.md
----------------------------------------------------------------------
diff --git a/karaf-boot/README.md b/karaf-boot/README.md
new file mode 100644
index 0000000..d428147
--- /dev/null
+++ b/karaf-boot/README.md
@@ -0,0 +1,5 @@
+Karaf Boot Annotations
+-----------------------
+
+Karaf Boot provides annotations allowing you to focus on your business code, and let Karaf Boot deals with all the
+plumbing for you.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/a0248b78/karaf-boot/pom.xml
----------------------------------------------------------------------
diff --git a/karaf-boot/pom.xml b/karaf-boot/pom.xml
new file mode 100644
index 0000000..22421fa
--- /dev/null
+++ b/karaf-boot/pom.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+
+ <!--
+
+ 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.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.karaf.boot</groupId>
+ <artifactId>karaf-boot-build</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>karaf-boot</artifactId>
+
+</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/a0248b78/karaf-boot/src/main/java/org/apache/karaf/boot/Arg.java
----------------------------------------------------------------------
diff --git a/karaf-boot/src/main/java/org/apache/karaf/boot/Arg.java b/karaf-boot/src/main/java/org/apache/karaf/boot/Arg.java
new file mode 100644
index 0000000..89e7d0f
--- /dev/null
+++ b/karaf-boot/src/main/java/org/apache/karaf/boot/Arg.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 org.apache.karaf.boot;
+
+
+/**
+ * used to describe argument of the bean constructor
+ * or the argument of the factory method for the bean
+ *
+ * this is mapped to Targument for the Tbean
+ *
+ */
+public @interface Arg {
+
+ /**
+ * the value of the argument
+ */
+ String value() default "";
+
+ /**
+ * the value of the ref attribute of the argument
+ */
+ String ref() default "";
+
+ /**
+ * the description of the argument
+ */
+ String description() default "";
+
+ /**
+ * the zero-based index into the parameter list of the factory method
+ * or constructor to be invoked for this argument. This is determined by
+ * specifying the <code>index</code> attribute for the bean. If not
+ * explicitly set, this will return -1 and the initial ordering is defined
+ * by its position in the args[] list.
+ */
+ int index() default -1;
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/a0248b78/karaf-boot/src/main/java/org/apache/karaf/boot/Bean.java
----------------------------------------------------------------------
diff --git a/karaf-boot/src/main/java/org/apache/karaf/boot/Bean.java b/karaf-boot/src/main/java/org/apache/karaf/boot/Bean.java
new file mode 100644
index 0000000..0a6ebbf
--- /dev/null
+++ b/karaf-boot/src/main/java/org/apache/karaf/boot/Bean.java
@@ -0,0 +1,79 @@
+/**
+ * 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.karaf.boot;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/*
+ * To annotate a bean as a blueprint bean, use @Bean
+ */
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Bean {
+
+ /**
+ * id, activation, dependsOn comes from Tcomponent
+ * the id property for the bean
+ * should this be auto generated if none is specified?
+ */
+ String id();
+
+ /**
+ * the activation property for the bean
+ * This can either be "eager" or "lazy". If not specified, it
+ * defaults to default-activation attribute of the enclosing
+ * <blueprint> element.
+ */
+ String activation() default "";
+
+ /**
+ * the components that the bean depends on
+ */
+ String[] dependsOn() default "";
+
+ /**
+ * the description property for the bean
+ */
+ String description() default "";
+
+ /**
+ * the scope property for the bean. value can be prototype or singleton
+ */
+ String scope() default "";
+
+ /**
+ * the reference to the factory component on which to invoke the
+ * factory method for the bean.
+ */
+ String factoryRef() default "";
+
+ /**
+ * the factory method in the factoryRef referred factory component
+ * @return
+ */
+ String factoryMethod() default "";
+
+ /**
+ * arguments for the bean constructor or the factory method of the bean
+ * @return
+ */
+ Arg[] args() default {};
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/a0248b78/karaf-boot/src/main/java/org/apache/karaf/boot/Bind.java
----------------------------------------------------------------------
diff --git a/karaf-boot/src/main/java/org/apache/karaf/boot/Bind.java b/karaf-boot/src/main/java/org/apache/karaf/boot/Bind.java
new file mode 100644
index 0000000..f7a3938
--- /dev/null
+++ b/karaf-boot/src/main/java/org/apache/karaf/boot/Bind.java
@@ -0,0 +1,31 @@
+/**
+ * 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.karaf.boot;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * used to annotation bind-method in blueprint reference listeners
+ *
+ */
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Bind {
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/a0248b78/karaf-boot/src/main/java/org/apache/karaf/boot/Destroy.java
----------------------------------------------------------------------
diff --git a/karaf-boot/src/main/java/org/apache/karaf/boot/Destroy.java b/karaf-boot/src/main/java/org/apache/karaf/boot/Destroy.java
new file mode 100644
index 0000000..a8e1258
--- /dev/null
+++ b/karaf-boot/src/main/java/org/apache/karaf/boot/Destroy.java
@@ -0,0 +1,31 @@
+/**
+ * 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.karaf.boot;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * used to annotation destroy-method in blueprint beans
+ *
+ */
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Destroy {
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/a0248b78/karaf-boot/src/main/java/org/apache/karaf/boot/Element.java
----------------------------------------------------------------------
diff --git a/karaf-boot/src/main/java/org/apache/karaf/boot/Element.java b/karaf-boot/src/main/java/org/apache/karaf/boot/Element.java
new file mode 100644
index 0000000..3259c80
--- /dev/null
+++ b/karaf-boot/src/main/java/org/apache/karaf/boot/Element.java
@@ -0,0 +1,43 @@
+/**
+ * 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.karaf.boot;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * used to annotate the element of the list.
+ *
+ */
+@Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Element {
+ ElementType type() default ElementType.STRING;
+ String value() default "";
+
+ public enum ElementType {
+ STRING,
+ LONG,
+ BYTE,
+ BOOLEAN,
+ INT,
+ SHORT
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/a0248b78/karaf-boot/src/main/java/org/apache/karaf/boot/Init.java
----------------------------------------------------------------------
diff --git a/karaf-boot/src/main/java/org/apache/karaf/boot/Init.java b/karaf-boot/src/main/java/org/apache/karaf/boot/Init.java
new file mode 100644
index 0000000..437ca8c
--- /dev/null
+++ b/karaf-boot/src/main/java/org/apache/karaf/boot/Init.java
@@ -0,0 +1,31 @@
+/**
+ * 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.karaf.boot;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * used to annotation init-method in blueprint beans
+ *
+ */
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Init {
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/a0248b78/karaf-boot/src/main/java/org/apache/karaf/boot/Inject.java
----------------------------------------------------------------------
diff --git a/karaf-boot/src/main/java/org/apache/karaf/boot/Inject.java b/karaf-boot/src/main/java/org/apache/karaf/boot/Inject.java
new file mode 100644
index 0000000..e0a0bd7
--- /dev/null
+++ b/karaf-boot/src/main/java/org/apache/karaf/boot/Inject.java
@@ -0,0 +1,32 @@
+/**
+ * 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.karaf.boot;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Target({ElementType.FIELD, ElementType.METHOD, ElementType.CONSTRUCTOR})
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Inject {
+ String value() default "";
+ String name() default "";
+ String description() default "";
+ String ref() default "";
+ String[] values() default {};
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/a0248b78/karaf-boot/src/main/java/org/apache/karaf/boot/List.java
----------------------------------------------------------------------
diff --git a/karaf-boot/src/main/java/org/apache/karaf/boot/List.java b/karaf-boot/src/main/java/org/apache/karaf/boot/List.java
new file mode 100644
index 0000000..f171908
--- /dev/null
+++ b/karaf-boot/src/main/java/org/apache/karaf/boot/List.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 org.apache.karaf.boot;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * used to annotate list value in property
+ * I am not convinced that we want to support this via annotation
+ *
+ */
+@Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})
+@Retention(RetentionPolicy.RUNTIME)
+public @interface List {
+
+ // the element of the list
+ public Element[] value();
+
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/a0248b78/karaf-boot/src/main/java/org/apache/karaf/boot/Reference.java
----------------------------------------------------------------------
diff --git a/karaf-boot/src/main/java/org/apache/karaf/boot/Reference.java b/karaf-boot/src/main/java/org/apache/karaf/boot/Reference.java
new file mode 100644
index 0000000..ee8d474
--- /dev/null
+++ b/karaf-boot/src/main/java/org/apache/karaf/boot/Reference.java
@@ -0,0 +1,69 @@
+/**
+ * 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.karaf.boot;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Target(ElementType.FIELD)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Reference
+{
+ /**
+ * the description property of the service reference
+ */
+ String description() default "";
+
+ /**
+ * the interface type that a matching service must support.
+ */
+ Class<?> serviceInterface() default Object.class;
+
+ /**
+ * the filter expression that a matching service must match.
+ */
+ String filter() default "";
+
+ /**
+ * the <code>component-name</code> attribute of the service reference.
+ */
+ String componentName() default "";
+
+ /**
+ * whether or not a matching service is required at all times. either optional or mandatory.
+ */
+ String availability() default "";
+
+ /**
+ * the reference listeners for the service reference, to receive bind and unbind events.
+ */
+ ReferenceListener[] referenceListeners() default {};
+
+ /**
+ * the timeout property. If the timeout is not specified,
+ * the default-timeout value is inherited from the encapsulating
+ * <code><blueprint></code> definition.
+ */
+ int timeout() default 0;
+
+ /**
+ * the id for the reference
+ */
+ String id() default "";
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/a0248b78/karaf-boot/src/main/java/org/apache/karaf/boot/ReferenceList.java
----------------------------------------------------------------------
diff --git a/karaf-boot/src/main/java/org/apache/karaf/boot/ReferenceList.java b/karaf-boot/src/main/java/org/apache/karaf/boot/ReferenceList.java
new file mode 100644
index 0000000..9c1378a
--- /dev/null
+++ b/karaf-boot/src/main/java/org/apache/karaf/boot/ReferenceList.java
@@ -0,0 +1,67 @@
+/**
+ * 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.karaf.boot;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Target(ElementType.FIELD)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface ReferenceList
+{
+ /**
+ * the description property of the service reference
+ */
+ String description() default "";
+
+ /**
+ * the interface type that a matching service must support.
+ */
+ Class<?> serviceInterface() default Object.class;
+
+ /**
+ * the filter expression that a matching service must match.
+ */
+ String filter() default "";
+
+ /**
+ * the <code>component-name</code> attribute of the service reference.
+ */
+ String componentName() default "";
+
+ /**
+ * whether or not a matching service is required at all times. either optional or mandatory.
+ */
+ String availability() default "";
+
+ /**
+ * the reference listeners for the service reference, to receive bind and unbind events.
+ */
+ ReferenceListener[] referenceListeners() default {};
+
+ /**
+ * the value of the memberType property.
+ */
+ String memberType() default "service-object";
+
+ /**
+ * the id for the referencelist
+ */
+ String id() default "";
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/a0248b78/karaf-boot/src/main/java/org/apache/karaf/boot/ReferenceListener.java
----------------------------------------------------------------------
diff --git a/karaf-boot/src/main/java/org/apache/karaf/boot/ReferenceListener.java b/karaf-boot/src/main/java/org/apache/karaf/boot/ReferenceListener.java
new file mode 100644
index 0000000..725a220
--- /dev/null
+++ b/karaf-boot/src/main/java/org/apache/karaf/boot/ReferenceListener.java
@@ -0,0 +1,28 @@
+/**
+ * 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.karaf.boot;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface ReferenceListener {
+ String ref() default "";
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/a0248b78/karaf-boot/src/main/java/org/apache/karaf/boot/Register.java
----------------------------------------------------------------------
diff --git a/karaf-boot/src/main/java/org/apache/karaf/boot/Register.java b/karaf-boot/src/main/java/org/apache/karaf/boot/Register.java
new file mode 100644
index 0000000..41bb50d
--- /dev/null
+++ b/karaf-boot/src/main/java/org/apache/karaf/boot/Register.java
@@ -0,0 +1,31 @@
+/**
+ * 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.karaf.boot;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * used to annotation register-method in blueprint registration listeners
+ *
+ */
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Register {
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/a0248b78/karaf-boot/src/main/java/org/apache/karaf/boot/RegistrationListener.java
----------------------------------------------------------------------
diff --git a/karaf-boot/src/main/java/org/apache/karaf/boot/RegistrationListener.java b/karaf-boot/src/main/java/org/apache/karaf/boot/RegistrationListener.java
new file mode 100644
index 0000000..793e2dd
--- /dev/null
+++ b/karaf-boot/src/main/java/org/apache/karaf/boot/RegistrationListener.java
@@ -0,0 +1,29 @@
+/**
+ * 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.karaf.boot;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface RegistrationListener {
+
+ String ref() default "";
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/a0248b78/karaf-boot/src/main/java/org/apache/karaf/boot/Service.java
----------------------------------------------------------------------
diff --git a/karaf-boot/src/main/java/org/apache/karaf/boot/Service.java b/karaf-boot/src/main/java/org/apache/karaf/boot/Service.java
new file mode 100644
index 0000000..09b6293
--- /dev/null
+++ b/karaf-boot/src/main/java/org/apache/karaf/boot/Service.java
@@ -0,0 +1,56 @@
+/**
+ * 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.karaf.boot;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Service {
+
+ /**
+ * the registration listeners to be notified when the service is
+ * registered and unregistered with the framework.
+ */
+ RegistrationListener[] registerationListeners() default {};
+
+ /**
+ * the ranking value to use when advertising the service. If the
+ * ranking value is zero, the service must be registered without a
+ * <code>service.ranking</code> service property.
+ */
+ int ranking() default 0;
+
+ /**
+ * the auto-export mode for the service.
+ * possible values are disabled, interfaces, class_hierarchy, all_classes
+ */
+ String autoExport() default "";
+
+ /**
+ * the interfaces that the service should be advertised as supporting.
+ */
+ Class<?>[] interfaces() default {};
+
+ /**
+ * the user declared properties to be advertised with the service.
+ */
+ ServiceProperty[] serviceProperties() default {};
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/a0248b78/karaf-boot/src/main/java/org/apache/karaf/boot/ServiceProperty.java
----------------------------------------------------------------------
diff --git a/karaf-boot/src/main/java/org/apache/karaf/boot/ServiceProperty.java b/karaf-boot/src/main/java/org/apache/karaf/boot/ServiceProperty.java
new file mode 100644
index 0000000..a6ca33d
--- /dev/null
+++ b/karaf-boot/src/main/java/org/apache/karaf/boot/ServiceProperty.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 org.apache.karaf.boot;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Target(ElementType.TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface ServiceProperty {
+ /**
+ * the key of the property
+ */
+ String key() default "";
+
+ /**
+ * the value of the property
+ */
+ String value() default "";
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/a0248b78/karaf-boot/src/main/java/org/apache/karaf/boot/Unbind.java
----------------------------------------------------------------------
diff --git a/karaf-boot/src/main/java/org/apache/karaf/boot/Unbind.java b/karaf-boot/src/main/java/org/apache/karaf/boot/Unbind.java
new file mode 100644
index 0000000..dbe15d1
--- /dev/null
+++ b/karaf-boot/src/main/java/org/apache/karaf/boot/Unbind.java
@@ -0,0 +1,31 @@
+/**
+ * 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.karaf.boot;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * used to annotation unbind-method in blueprint reference listeners
+ *
+ */
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Unbind {
+}
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/a0248b78/karaf-boot/src/main/java/org/apache/karaf/boot/Unregister.java
----------------------------------------------------------------------
diff --git a/karaf-boot/src/main/java/org/apache/karaf/boot/Unregister.java b/karaf-boot/src/main/java/org/apache/karaf/boot/Unregister.java
new file mode 100644
index 0000000..04ea698
--- /dev/null
+++ b/karaf-boot/src/main/java/org/apache/karaf/boot/Unregister.java
@@ -0,0 +1,31 @@
+/**
+ * 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.karaf.boot;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * used to annotation unregister-method in blueprint registration listeners
+ *
+ */
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Unregister {
+}
[31/35] karaf-boot git commit: Use pretty printing
Posted by cs...@apache.org.
Use pretty printing
Project: http://git-wip-us.apache.org/repos/asf/karaf-boot/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf-boot/commit/a55895f5
Tree: http://git-wip-us.apache.org/repos/asf/karaf-boot/tree/a55895f5
Diff: http://git-wip-us.apache.org/repos/asf/karaf-boot/diff/a55895f5
Branch: refs/heads/master
Commit: a55895f532d5c3dcabb4b1d98b10449734c42ec0
Parents: af6327c
Author: Christian Schneider <ch...@die-schneider.net>
Authored: Tue Apr 26 09:05:03 2016 +0200
Committer: Christian Schneider <ch...@die-schneider.net>
Committed: Tue Apr 26 09:05:03 2016 +0200
----------------------------------------------------------------------
samples/jpa/.gitignore | 1 +
starters/karaf-boot-starter-jpa/pom.xml | 2 --
.../main/java/org/apache/karaf/boot/jpa/impl/JpaProcessor.java | 5 +++--
3 files changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/a55895f5/samples/jpa/.gitignore
----------------------------------------------------------------------
diff --git a/samples/jpa/.gitignore b/samples/jpa/.gitignore
new file mode 100644
index 0000000..c71ea97
--- /dev/null
+++ b/samples/jpa/.gitignore
@@ -0,0 +1 @@
+/.apt_generated/
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/a55895f5/starters/karaf-boot-starter-jpa/pom.xml
----------------------------------------------------------------------
diff --git a/starters/karaf-boot-starter-jpa/pom.xml b/starters/karaf-boot-starter-jpa/pom.xml
index 734714b..7a89d90 100644
--- a/starters/karaf-boot-starter-jpa/pom.xml
+++ b/starters/karaf-boot-starter-jpa/pom.xml
@@ -30,7 +30,6 @@
<artifactId>geronimo-jpa_2.0_spec</artifactId>
<version>1.1</version>
</dependency>
- <!--
<dependency>
<groupId>net.java.dev.stax-utils</groupId>
<artifactId>stax-utils</artifactId>
@@ -42,7 +41,6 @@
</exclusion>
</exclusions>
</dependency>
- -->
<dependency>
<groupId>junit</groupId>
http://git-wip-us.apache.org/repos/asf/karaf-boot/blob/a55895f5/starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/impl/JpaProcessor.java
----------------------------------------------------------------------
diff --git a/starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/impl/JpaProcessor.java b/starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/impl/JpaProcessor.java
index ed52850..f257238 100644
--- a/starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/impl/JpaProcessor.java
+++ b/starters/karaf-boot-starter-jpa/src/main/java/org/apache/karaf/boot/jpa/impl/JpaProcessor.java
@@ -25,6 +25,8 @@ import org.apache.karaf.boot.jpa.PersistentUnit;
import org.apache.karaf.boot.jpa.Property;
import org.apache.karaf.boot.jpa.Provider;
+import javanet.staxutils.IndentingXMLStreamWriter;
+
public class JpaProcessor extends AbstractProcessor {
public JpaProcessor() {
@@ -60,8 +62,7 @@ public class JpaProcessor extends AbstractProcessor {
public void process(Writer writer, Map<PersistentUnit, List<? extends AnnotationMirror>> units) throws Exception {
Set<String> puNames = new HashSet<String>();
XMLOutputFactory xof = XMLOutputFactory.newInstance();
- //XMLStreamWriter w = new IndentingXMLStreamWriter(xof.createXMLStreamWriter(writer));
- XMLStreamWriter w = xof.createXMLStreamWriter(writer);
+ XMLStreamWriter w = new IndentingXMLStreamWriter(xof.createXMLStreamWriter(writer));
w.setDefaultNamespace("http://java.sun.com/xml/ns/persistence");
w.writeStartDocument();
w.writeStartElement("persistence");