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>
