You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by gn...@apache.org on 2014/03/06 01:40:07 UTC
[4/6] git commit: Revert [KARAF-2763] and update demo / manuel for
[KARAF-2805]
Revert [KARAF-2763] and update demo / manuel for [KARAF-2805]
Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/662c07a6
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/662c07a6
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/662c07a6
Branch: refs/heads/master
Commit: 662c07a68bf53c4a99a480f5ca69deb452413df4
Parents: 66c52d1
Author: Guillaume Nodet <gn...@gmail.com>
Authored: Thu Mar 6 01:27:40 2014 +0100
Committer: Guillaume Nodet <gn...@gmail.com>
Committed: Thu Mar 6 01:27:40 2014 +0100
----------------------------------------------------------------------
demos/command/pom.xml | 16 +-
.../apache/karaf/demos/command/MyCommand.java | 17 +-
.../apache/karaf/demos/command/MyCompleter.java | 19 +-
.../resources/OSGI-INF/blueprint/mycommand.xml | 43 ---
.../main/webapp/developers-guide/extending.conf | 190 +++-------
pom.xml | 15 -
.../console/commands/NamespaceHandler.java | 186 +--------
.../org/apache/karaf/shell/inject/Destroy.java | 30 --
.../org/apache/karaf/shell/inject/Init.java | 30 --
.../apache/karaf/shell/inject/Reference.java | 30 --
.../org/apache/karaf/shell/inject/Service.java | 30 --
.../blueprint/shell-namespacehandler.xml | 6 -
.../console/commands/karaf-shell-1.2.0.xsd | 225 -----------
tooling/karaf-scr-maven-plugin/NOTICE | 71 ----
tooling/karaf-scr-maven-plugin/pom.xml | 243 ------------
.../karaf/tooling/scr/ScrCommandMojo.java | 374 -------------------
.../karaf/tooling/scr/ScrCommandSupport.java | 112 ------
tooling/pom.xml | 1 -
18 files changed, 71 insertions(+), 1567 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf/blob/662c07a6/demos/command/pom.xml
----------------------------------------------------------------------
diff --git a/demos/command/pom.xml b/demos/command/pom.xml
index e066f7b..2042170 100644
--- a/demos/command/pom.xml
+++ b/demos/command/pom.xml
@@ -42,13 +42,7 @@
<dependency>
<groupId>org.apache.karaf.shell</groupId>
- <artifactId>org.apache.karaf.shell.console</artifactId>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.gogo.runtime</artifactId>
+ <artifactId>org.apache.karaf.shell.core</artifactId>
<scope>provided</scope>
</dependency>
@@ -67,13 +61,7 @@
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<instructions>
- <Import-Package>
- org.apache.felix.service.command,
- org.apache.karaf.shell.commands,
- org.apache.karaf.shell.console,
- org.apache.karaf.shell.inject,
- *
- </Import-Package>
+ <Karaf-Commands>*</Karaf-Commands>
</instructions>
</configuration>
</plugin>
http://git-wip-us.apache.org/repos/asf/karaf/blob/662c07a6/demos/command/src/main/java/org/apache/karaf/demos/command/MyCommand.java
----------------------------------------------------------------------
diff --git a/demos/command/src/main/java/org/apache/karaf/demos/command/MyCommand.java b/demos/command/src/main/java/org/apache/karaf/demos/command/MyCommand.java
index fb37705..6f5fc1d 100644
--- a/demos/command/src/main/java/org/apache/karaf/demos/command/MyCommand.java
+++ b/demos/command/src/main/java/org/apache/karaf/demos/command/MyCommand.java
@@ -19,22 +19,23 @@
package org.apache.karaf.demos.command;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Completer;
-import org.apache.karaf.shell.console.OsgiCommandSupport;
-import org.apache.karaf.shell.inject.Service;
+
+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.Completion;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
@Command(scope = "mycommand", name = "hello", description="Says hello")
@Service
-public class MyCommand extends OsgiCommandSupport {
+public class MyCommand implements Action {
@Argument(index = 0, name = "arg", description = "The command argument", required = false, multiValued = false)
- @Completer(MyCompleter.class)
+ @Completion(MyCompleter.class)
String arg = null;
@Override
- protected Object doExecute() throws Exception {
+ public Object execute() throws Exception {
System.out.println("Executing My Command Demo");
return null;
}
http://git-wip-us.apache.org/repos/asf/karaf/blob/662c07a6/demos/command/src/main/java/org/apache/karaf/demos/command/MyCompleter.java
----------------------------------------------------------------------
diff --git a/demos/command/src/main/java/org/apache/karaf/demos/command/MyCompleter.java b/demos/command/src/main/java/org/apache/karaf/demos/command/MyCompleter.java
index ba45232..bc9a5c9 100644
--- a/demos/command/src/main/java/org/apache/karaf/demos/command/MyCompleter.java
+++ b/demos/command/src/main/java/org/apache/karaf/demos/command/MyCompleter.java
@@ -19,12 +19,14 @@
package org.apache.karaf.demos.command;
-import org.apache.karaf.shell.console.completer.StringsCompleter;
-import org.apache.karaf.shell.console.Completer;
-import org.apache.karaf.shell.inject.Service;
-
import java.util.List;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.apache.karaf.shell.api.console.CommandLine;
+import org.apache.karaf.shell.api.console.Completer;
+import org.apache.karaf.shell.api.console.Session;
+import org.apache.karaf.shell.support.completers.StringsCompleter;
+
/**
* <p>
* My completer.
@@ -34,17 +36,12 @@ import java.util.List;
@Service
public class MyCompleter implements Completer {
- /**
- * @param buffer it's the beginning string typed by the user
- * @param cursor it's the position of the cursor
- * @param candidates the list of completions proposed to the user
- */
- public int complete(String buffer, int cursor, List candidates) {
+ public int complete(Session session, CommandLine commandLine, List<String> candidates) {
StringsCompleter delegate = new StringsCompleter();
delegate.getStrings().add("one");
delegate.getStrings().add("two");
delegate.getStrings().add("three");
- return delegate.complete(buffer, cursor, candidates);
+ return delegate.complete(session, commandLine, candidates);
}
}
http://git-wip-us.apache.org/repos/asf/karaf/blob/662c07a6/demos/command/src/main/resources/OSGI-INF/blueprint/mycommand.xml
----------------------------------------------------------------------
diff --git a/demos/command/src/main/resources/OSGI-INF/blueprint/mycommand.xml b/demos/command/src/main/resources/OSGI-INF/blueprint/mycommand.xml
deleted file mode 100644
index 66709b8..0000000
--- a/demos/command/src/main/resources/OSGI-INF/blueprint/mycommand.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
-
- <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.2.0"
- scan="org.apache.karaf.demos.command" />
-
- <!-- Old style way of declaring commands
- This may be needed for actions that need complicated injections
- based on blueprint.
-
- <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.1.0">
- <command>
- <action class="org.apache.karaf.demos.command.MyCommand"/>
- <completers>
- <ref component-id="myCompleter"/>
- <null/>
- </completers>
- </command>
- </command-bundle>
-
- <bean id="myCompleter" class="org.apache.karaf.demos.command.MyCompleter"/>
- -->
-
-</blueprint>
http://git-wip-us.apache.org/repos/asf/karaf/blob/662c07a6/manual/src/main/webapp/developers-guide/extending.conf
----------------------------------------------------------------------
diff --git a/manual/src/main/webapp/developers-guide/extending.conf b/manual/src/main/webapp/developers-guide/extending.conf
index 6a762a0..eb04003 100644
--- a/manual/src/main/webapp/developers-guide/extending.conf
+++ b/manual/src/main/webapp/developers-guide/extending.conf
@@ -140,63 +140,37 @@ We can now create the command class {{HelloShellCommand.java}}
{code:lang=java}
package org.apache.karaf.shell.samples;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.console.OsgiCommandSupport;
-import org.apache.karaf.shell.inject.Service;
+import org.apache.karaf.shell.api.action.Action;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
@Command(scope = "test", name = "hello", description="Says hello")
@Service
-public class HelloShellCommand extends OsgiCommandSupport {
+public class HelloShellCommand implements Action {
@Override
- protected Object doExecute() throws Exception {
+ public Object execute() throws Exception {
System.out.println("Executing Hello command");
return null;
}
}
{code}
-h3. Blueprint definition
+h3. Manifest
-Blueprint is an injection framework for OSGi. It allows you to declare beans in a XML file and contains specific statement for OSGi services.
-
-For the command, we use Blueprint to create the command bean and register as an OSGi service.
-
-The blueprint definition file is located in the {{OSGI-INF/blueprint}} folder of our bundle.
-
-If you don't have the {{src/main/resources}} directory yet, create it.
-
-{code}
-mkdir src/main/resources
-{code}
-
-Then, re-generate the IDE project files and reload it so that this folder is now recognized as a source folder.
-
-Inside this directory, create the {{OSGI-INF/blueprint/}} directory and put the following file inside (the name of this file has no impact at all):
-
-For simple cases as above, or even if you only need to inject an OSGi service, you can use the auto-detecting feature provided by the blueprint namespace handler:
-
-{code:lang=xml}
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
-
- <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.2.0"
- scan="org.apache.karaf.shell.samples" />
-
-</blueprint>
-{code}
-
-Alternatively, if you need more control over the wiring, you can declare the command explicitely:
+In order for Karaf to find your command, you need to add the {{Karaf-Commands=*}} manifest header.
+This is usually done by modifying the maven bundle plugin configuration
{code:lang=xml}
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
-
- <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.2.0">
- <command>
- <action class="org.apache.karaf.shell.samples.HelloShellCommand"/>
- </command>
- </command-bundle>
-
-</blueprint>
+<plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <configuration>
+ <instructions>
+ <Karaf-Commands>*</Karaf-Commands>
+ </instructions>
+ </configuration>
+</plugin>
{code}
h3. Compile
@@ -243,30 +217,28 @@ We add an argument to the HelloCommand:
{code:lang=java}
package org.apache.karaf.shell.samples;
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Completer;
-import org.apache.karaf.shell.console.OsgiCommandSupport;
-import org.apache.karaf.shell.inject.Service;
+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.Completion;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
@Command(scope = "test", name = "hello", description="Says hello")
@Service
-public class HelloShellCommand extends OsgiCommandSupport {
+public class HelloShellCommand implements Action {
@Argument(index = 0, name = "name", description = "The name that sends the greet.", required = true, multiValued = false)
- @Completer(SimpleNameCompleter.class)
+ @Completion(SimpleNameCompleter.class)
String name = null;
@Override
- protected Object doExecute() throws Exception {
+ public Object execute() throws Exception {
System.out.println("Hello " + name);
return null;
}
}
{code}
-The Blueprint configuration file is the same as previously.
-
h3. Completer bean
A completer is a bean which implements the Completer interface:
@@ -274,9 +246,11 @@ A completer is a bean which implements the Completer interface:
{code:lang=java}
package org.apache.karaf.shell.samples;
-import org.apache.karaf.shell.console.completer.StringsCompleter;
-import org.apache.karaf.shell.console.Completer;
-import org.apache.karaf.shell.inject.Service;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.apache.karaf.shell.api.console.CommandLine;
+import org.apache.karaf.shell.api.console.Completer;
+import org.apache.karaf.shell.api.console.Session;
+import org.apache.karaf.shell.support.completers.StringsCompleter;
/**
* <p>
@@ -286,47 +260,17 @@ import org.apache.karaf.shell.inject.Service;
@Service
public class SimpleNameCompleter implements Completer {
- /**
- * @param buffer the beginning string typed by the user
- * @param cursor the position of the cursor
- * @param candidates the list of completions proposed to the user
- */
- public int complete(String buffer, int cursor, List candidates) {
- StringsCompleter delegate = new StringsCompleter();
- delegate.getStrings().add("Mike");
- delegate.getStrings().add("Eric");
- delegate.getStrings().add("Jenny");
- return delegate.complete(buffer, cursor, candidates);
- }
+ public int complete(Session session, CommandLine commandLine, List<String> candidates) {
+ StringsCompleter delegate = new StringsCompleter();
+ delegate.getStrings().add("Mike");
+ delegate.getStrings().add("Eric");
+ delegate.getStrings().add("Jenny");
+ return delegate.complete(buffer, cursor, candidates);
+ }
}
{code}
-h3. Blueprint with completer
-
-If you're not using the scanning feature, you need to "inject" the completer linked to your command. The same completer could be used for several commands and a command can have several completers:
-
-{code:lang=xml}
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
-
- <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.2.0">
- <command>
- <action class="org.apache.karaf.shell.samples.HelloShellCommand"/>
- <completers>
- <ref component-id="simpleNameCompleter"/>
- <null/>
- </completers>
- </command>
- </command-bundle>
-
- <bean id="simpleNameCompleter" class="org.apache.karaf.shell.samples.SimpleNameCompleter"/>
-
-</blueprint>
-{code}
-
-You can have multiple completers for a single class, each matching a command argument.
-The order of the completers must match the order of the arguments, in order to have the desirable results.
-
h3. Completers for option values
Quite often your commands will not have just arguments, but also options. You can provide completers for option values.
@@ -335,56 +279,33 @@ The snippet below shows the HelloShellCommand with an option to specify what the
{code:lang=java}
package org.apache.karaf.shell.samples;
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.console.OsgiCommandSupport;
-import org.apache.karaf.shell.inject.Service;
+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.Completion;
+import org.apache.karaf.shell.api.action.Option;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
@Command(scope = "test", name = "hello", description="Says hello")
@Service
-public class HelloShellCommand extends OsgiCommandSupport {
+public class HelloShellCommand implements Action {
@Argument(index = 0, name = "name", description = "The name that sends the greet.", required = true, multiValued = false)
- @Completer(SimpleNameCompleter.class)
+ @Completion(SimpleNameCompleter.class)
String name = null;
@Option(name = "-g", aliases = "--greet", description = "The configuration pid", required = false, multiValued = false)
- @Completer(GreetCompleter.class)
+ @Completion(GreetCompleter.class)
String greet = "Hello;
@Override
- protected Object doExecute() throws Exception {
+ public Object execute() throws Exception {
System.out.println(greet + " " + name);
return null;
}
}
{code}
-If you're using explicit wiring for the command, you need to specify the completer for the greet option in the blueprint file.
-All that is required is to add an optional-completer element in the blueprint configuration that will associate a completer with the -g option or its --greet alias.
-
-{code:lang=xml}
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
-
- <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.2.0">
- <command>
- <action class="org.apache.karaf.shell.samples.HelloShellCommand"/>
- <completers>
- <ref component-id="simpleNameCompleter"/>
- <null/>
- </completers>
- <optional-completers>
- <entry key="-g" value-ref="greetCompleter"/>
- </optional-completers>
- </command>
- </command-bundle>
-
- <bean id="simpleNameCompleter" class="org.apache.karaf.shell.samples.SimpleNameCompleter"/>
- <bean id="greetCompleter" class="org.apache.karaf.shell.samples.GreetCompleter"/>
-
-</blueprint>
-{code}
-
h3. Completers with state
Some times we want to tune the behavior of the completer depending on the commands already executed, in the current shell
@@ -392,19 +313,10 @@ or even the rest of the arguments that have been already passed to the command.
command which will provide auto completion for only for the properties of the pid specified by a previously issued config:edit
command or by the option --pid.
-This is done by accessing the CommandSession object which holds the state of the console. To get access to the CommandSession:
-
-{code}
-CommandSession session = CommandSessionHolder.getSession();
-{code}
-
-CommandSession provides map like methods for storing key/value pairs and can be used to put/get the state.
-
-If you want to get access to the list of arguments that is already passed to the command, you can simply:
-
-{code}
-ArgumentCompleter.ArgumentList list = (ArgumentCompleter.ArgumentList) commandSession.get(ArgumentCompleter.ARGUMENTS_LIST);
-{code}
+The Session object provides map like methods for storing key/value pairs and can be used to put/get the state.
+The pre-parsed CommandLine objects allows you to check the previous arguments and options on the command line and to fine tune
+the behavior of the Completer.
+Those two objects are given to the Completer when calling the {{complete}} method.
h3. Test
http://git-wip-us.apache.org/repos/asf/karaf/blob/662c07a6/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 032442a..5a37852 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1935,21 +1935,6 @@
</configuration>
</plugin>
<plugin>
- <groupId>org.apache.karaf.tooling</groupId>
- <artifactId>karaf-scr-maven-plugin</artifactId>
- <version>${project.version}</version>
- <executions>
- <execution>
- <goals>
- <goal>scr</goal>
- </goals>
- <configuration>
- <ranking>${karaf.service.ranking}</ranking>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-idea-plugin</artifactId>
<version>2.2.1</version>
http://git-wip-us.apache.org/repos/asf/karaf/blob/662c07a6/shell/console/src/main/java/org/apache/karaf/shell/console/commands/NamespaceHandler.java
----------------------------------------------------------------------
diff --git a/shell/console/src/main/java/org/apache/karaf/shell/console/commands/NamespaceHandler.java b/shell/console/src/main/java/org/apache/karaf/shell/console/commands/NamespaceHandler.java
index 075b986..2dd6976 100644
--- a/shell/console/src/main/java/org/apache/karaf/shell/console/commands/NamespaceHandler.java
+++ b/shell/console/src/main/java/org/apache/karaf/shell/console/commands/NamespaceHandler.java
@@ -18,11 +18,8 @@
*/
package org.apache.karaf.shell.console.commands;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
import java.net.URL;
import java.util.Arrays;
-import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -34,20 +31,11 @@ import org.apache.aries.blueprint.mutable.MutableCollectionMetadata;
import org.apache.aries.blueprint.mutable.MutableIdRefMetadata;
import org.apache.aries.blueprint.mutable.MutablePassThroughMetadata;
import org.apache.aries.blueprint.mutable.MutableRefMetadata;
-import org.apache.aries.blueprint.mutable.MutableReferenceMetadata;
import org.apache.aries.blueprint.mutable.MutableServiceMetadata;
import org.apache.aries.blueprint.mutable.MutableValueMetadata;
-import org.apache.felix.gogo.commands.Action;
-import org.apache.karaf.shell.console.Completer;
import org.apache.karaf.shell.console.SubShellAction;
import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.inject.Destroy;
-import org.apache.karaf.shell.inject.Init;
-import org.apache.karaf.shell.inject.Reference;
-import org.apache.karaf.shell.inject.Service;
import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.wiring.BundleWiring;
import org.osgi.service.blueprint.container.ComponentDefinitionException;
import org.osgi.service.blueprint.reflect.BeanArgument;
import org.osgi.service.blueprint.reflect.BeanMetadata;
@@ -58,12 +46,9 @@ import org.osgi.service.blueprint.reflect.MapMetadata;
import org.osgi.service.blueprint.reflect.Metadata;
import org.osgi.service.blueprint.reflect.NullMetadata;
import org.osgi.service.blueprint.reflect.RefMetadata;
-import org.osgi.service.blueprint.reflect.ReferenceMetadata;
import org.osgi.service.blueprint.reflect.ServiceMetadata;
import org.osgi.service.blueprint.reflect.ValueMetadata;
-import org.w3c.dom.Attr;
import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@@ -90,7 +75,6 @@ public class NamespaceHandler implements org.apache.aries.blueprint.NamespaceHan
public static final String SHELL_NAMESPACE_1_0_0 = "http://karaf.apache.org/xmlns/shell/v1.0.0";
public static final String SHELL_NAMESPACE_1_1_0 = "http://karaf.apache.org/xmlns/shell/v1.1.0";
- public static final String SHELL_NAMESPACE_1_2_0 = "http://karaf.apache.org/xmlns/shell/v1.2.0";
private int nameCounter = 0;
@@ -99,10 +83,8 @@ public class NamespaceHandler implements org.apache.aries.blueprint.NamespaceHan
return getClass().getResource("karaf-shell-1.0.0.xsd");
} else if(SHELL_NAMESPACE_1_1_0.equals(namespace)) {
return getClass().getResource("karaf-shell-1.1.0.xsd");
- } else if(SHELL_NAMESPACE_1_2_0.equals(namespace)) {
- return getClass().getResource("karaf-shell-1.2.0.xsd");
}
- return getClass().getResource("karaf-shell-1.2.0.xsd");
+ return getClass().getResource("karaf-shell-1.1.0.xsd");
}
public Set<Class> getManagedClasses() {
@@ -117,14 +99,6 @@ public class NamespaceHandler implements org.apache.aries.blueprint.NamespaceHan
public Metadata parse(Element element, ParserContext context) {
if (nodeNameEquals(element, COMMAND_BUNDLE)) {
- NamedNodeMap attrs = element.getAttributes();
- for (int i = 0; i < attrs.getLength(); i++) {
- Node child = attrs.item(i);
- if (child instanceof Attr) {
- Attr childAttr = (Attr) child;
- parseChildAttr(childAttr, context);
- }
- }
NodeList children = element.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
Node child = children.item(i);
@@ -140,164 +114,6 @@ public class NamespaceHandler implements org.apache.aries.blueprint.NamespaceHan
}
}
- private void parseChildAttr(Attr attr, ParserContext context) {
- if (nodeNameEquals(attr, SCAN)) {
- scan(attr, context);
- }
- }
-
- private void scan(Attr attr, ParserContext context) {
- try {
- Bundle bundle = getBundle(context);
- BundleWiring wiring = bundle.adapt(BundleWiring.class);
- for (String pkg : attr.getValue().split(" ")) {
- String name = pkg;
- int options = BundleWiring.LISTRESOURCES_LOCAL;
- name = name.replace('.', '/');
- if (name.endsWith("*")) {
- options |= BundleWiring.LISTRESOURCES_RECURSE;
- name = name.substring(0, name.length() - 1);
- }
- if (!name.startsWith("/")) {
- name = "/" + name;
- }
- if (name.endsWith("/")) {
- name = name.substring(0, name.length() - 1);
- }
- Collection<String> classes = wiring.listResources(name, "*.class", options);
- for (String className : classes) {
- className = className.replace('/', '.').replace(".class", "");
- inspectClass(context, bundle.loadClass(className));
- }
- }
- } catch (ComponentDefinitionException e) {
- throw e;
- } catch (Exception e) {
- throw new ComponentDefinitionException("Unable to scan commands", e);
- }
- }
-
- private void inspectClass(ParserContext context, Class<?> clazz) throws Exception {
- Service reg = clazz.getAnnotation(Service.class);
- if (reg == null) {
- return;
- }
- if (Action.class.isAssignableFrom(clazz)) {
- final Command cmd = clazz.getAnnotation(Command.class);
- if (cmd == null) {
- throw new IllegalArgumentException("Command " + clazz.getName() + " is not annotated with @Command");
- }
- String scope = cmd.scope();
- String function = cmd.name();
- // Create action
- MutableBeanMetadata action = context.createMetadata(MutableBeanMetadata.class);
- action.setId(getName());
- action.setActivation(MutableBeanMetadata.ACTIVATION_LAZY);
- action.setScope(MutableBeanMetadata.SCOPE_PROTOTYPE);
- action.setRuntimeClass(clazz);
- for (Class<?> cl = clazz; cl != Object.class; cl = cl.getSuperclass()) {
- for (Field field : cl.getDeclaredFields()) {
- if (field.getAnnotation(Reference.class) != null) {
- if (field.getType() == BundleContext.class) {
- action.addProperty(field.getName(), createRef(context, "blueprintBundleContext"));
- } else {
- action.addProperty(field.getName(), createRef(context, createServiceRef(context, field.getType()).getId()));
- }
- }
- }
- for (Method method : cl.getDeclaredMethods()) {
- if (method.getAnnotation(Init.class) != null) {
- if (action.getInitMethod() == null) {
- action.setInitMethod(method.getName());
- }
- }
- if (method.getAnnotation(Destroy.class) != null) {
- if (action.getDestroyMethod() == null) {
- action.setDestroyMethod(method.getName());
- }
- }
- }
- }
- context.getComponentDefinitionRegistry().registerComponentDefinition(action);
- // Create command
- MutableBeanMetadata command = context.createMetadata(MutableBeanMetadata.class);
- command.setRuntimeClass(BlueprintCommand.class);
- command.addProperty(BLUEPRINT_CONTAINER, createRef(context, BLUEPRINT_CONTAINER));
- command.addProperty(BLUEPRINT_CONVERTER, createRef(context, BLUEPRINT_CONVERTER));
- command.addProperty(ACTION_ID, createIdRef(context, action.getId()));
- // Create command service
- MutableServiceMetadata commandService = context.createMetadata(MutableServiceMetadata.class);
- commandService.setActivation(MutableServiceMetadata.ACTIVATION_LAZY);
- commandService.setId(getName());
- commandService.setAutoExport(ServiceMetadata.AUTO_EXPORT_ALL_CLASSES);
- commandService.setServiceComponent(command);
- commandService.addServiceProperty(createStringValue(context, "osgi.command.scope"),
- createStringValue(context, scope));
- commandService.addServiceProperty(createStringValue(context, "osgi.command.function"),
- createStringValue(context, function));
- context.getComponentDefinitionRegistry().registerComponentDefinition(commandService);
-
- // create the sub-shell action
- createSubShell(context, scope);
- }
- if (Completer.class.isAssignableFrom(clazz)) {
- MutableBeanMetadata completer = context.createMetadata(MutableBeanMetadata.class);
- completer.setId(getName());
- completer.setActivation(MutableBeanMetadata.ACTIVATION_LAZY);
- completer.setScope(MutableBeanMetadata.SCOPE_SINGLETON);
- completer.setRuntimeClass(clazz);
- // Create completer
- for (Class<?> cl = clazz; cl != Object.class; cl = cl.getSuperclass()) {
- for (Field field : cl.getDeclaredFields()) {
- if (field.getAnnotation(Reference.class) != null) {
- if (field.getType() == BundleContext.class) {
- completer.addProperty(field.getName(), createRef(context, "blueprintBundleContext"));
- } else {
- completer.addProperty(field.getName(), createRef(context, createServiceRef(context, field.getType()).getId()));
- }
- }
- }
- for (Method method : cl.getDeclaredMethods()) {
- if (method.getAnnotation(Init.class) != null) {
- if (completer.getInitMethod() == null) {
- completer.setInitMethod(method.getName());
- }
- }
- if (method.getAnnotation(Destroy.class) != null) {
- if (completer.getDestroyMethod() == null) {
- completer.setDestroyMethod(method.getName());
- }
- }
- }
- }
- context.getComponentDefinitionRegistry().registerComponentDefinition(completer);
- // Create completer service
- MutableServiceMetadata completerService = context.createMetadata(MutableServiceMetadata.class);
- completerService.setActivation(MutableServiceMetadata.ACTIVATION_LAZY);
- completerService.setId(getName());
- completerService.setAutoExport(ServiceMetadata.AUTO_EXPORT_ALL_CLASSES);
- completerService.setServiceComponent(createRef(context, completer.getId()));
- context.getComponentDefinitionRegistry().registerComponentDefinition(completerService);
- }
- }
-
- private ComponentMetadata createServiceRef(ParserContext context, Class<?> cls) {
- String id = ".serviceref." + cls.getName();
- ComponentMetadata metadata = context.getComponentDefinitionRegistry().getComponentDefinition(id);
- if (metadata == null) {
- MutableReferenceMetadata m = context.createMetadata(MutableReferenceMetadata.class);
- m.setRuntimeInterface(cls);
- m.setInterface(cls.getName());
- m.setActivation(ReferenceMetadata.ACTIVATION_EAGER);
- m.setAvailability(ReferenceMetadata.AVAILABILITY_MANDATORY);
- m.setId(id);
- context.getComponentDefinitionRegistry().registerComponentDefinition(m);
- return m;
- } else {
- return metadata;
- }
- }
-
private Bundle getBundle(ParserContext context) {
PassThroughMetadata ptm = (PassThroughMetadata) context.getComponentDefinitionRegistry().getComponentDefinition("blueprintBundle");
return (Bundle) ptm.getObject();
http://git-wip-us.apache.org/repos/asf/karaf/blob/662c07a6/shell/console/src/main/java/org/apache/karaf/shell/inject/Destroy.java
----------------------------------------------------------------------
diff --git a/shell/console/src/main/java/org/apache/karaf/shell/inject/Destroy.java b/shell/console/src/main/java/org/apache/karaf/shell/inject/Destroy.java
deleted file mode 100644
index d985db3..0000000
--- a/shell/console/src/main/java/org/apache/karaf/shell/inject/Destroy.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 org.apache.karaf.shell.inject;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.METHOD})
-@Deprecated
-public @interface Destroy {
-}
http://git-wip-us.apache.org/repos/asf/karaf/blob/662c07a6/shell/console/src/main/java/org/apache/karaf/shell/inject/Init.java
----------------------------------------------------------------------
diff --git a/shell/console/src/main/java/org/apache/karaf/shell/inject/Init.java b/shell/console/src/main/java/org/apache/karaf/shell/inject/Init.java
deleted file mode 100644
index 99744e2..0000000
--- a/shell/console/src/main/java/org/apache/karaf/shell/inject/Init.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 org.apache.karaf.shell.inject;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.METHOD})
-@Deprecated
-public @interface Init {
-}
http://git-wip-us.apache.org/repos/asf/karaf/blob/662c07a6/shell/console/src/main/java/org/apache/karaf/shell/inject/Reference.java
----------------------------------------------------------------------
diff --git a/shell/console/src/main/java/org/apache/karaf/shell/inject/Reference.java b/shell/console/src/main/java/org/apache/karaf/shell/inject/Reference.java
deleted file mode 100644
index 61feabc..0000000
--- a/shell/console/src/main/java/org/apache/karaf/shell/inject/Reference.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 org.apache.karaf.shell.inject;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.FIELD})
-@Deprecated
-public @interface Reference {
-}
http://git-wip-us.apache.org/repos/asf/karaf/blob/662c07a6/shell/console/src/main/java/org/apache/karaf/shell/inject/Service.java
----------------------------------------------------------------------
diff --git a/shell/console/src/main/java/org/apache/karaf/shell/inject/Service.java b/shell/console/src/main/java/org/apache/karaf/shell/inject/Service.java
deleted file mode 100644
index ef0d813..0000000
--- a/shell/console/src/main/java/org/apache/karaf/shell/inject/Service.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 org.apache.karaf.shell.inject;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.TYPE})
-@Deprecated
-public @interface Service {
-}
http://git-wip-us.apache.org/repos/asf/karaf/blob/662c07a6/shell/console/src/main/resources/OSGI-INF/blueprint/shell-namespacehandler.xml
----------------------------------------------------------------------
diff --git a/shell/console/src/main/resources/OSGI-INF/blueprint/shell-namespacehandler.xml b/shell/console/src/main/resources/OSGI-INF/blueprint/shell-namespacehandler.xml
index b2b5566..be1dd92 100644
--- a/shell/console/src/main/resources/OSGI-INF/blueprint/shell-namespacehandler.xml
+++ b/shell/console/src/main/resources/OSGI-INF/blueprint/shell-namespacehandler.xml
@@ -33,10 +33,4 @@
</service-properties>
</service>
- <service ref="namespaceHandler" interface="org.apache.aries.blueprint.NamespaceHandler">
- <service-properties>
- <entry key="osgi.service.blueprint.namespace" value="http://karaf.apache.org/xmlns/shell/v1.2.0" />
- </service-properties>
- </service>
-
</blueprint>
http://git-wip-us.apache.org/repos/asf/karaf/blob/662c07a6/shell/console/src/main/resources/org/apache/karaf/shell/console/commands/karaf-shell-1.2.0.xsd
----------------------------------------------------------------------
diff --git a/shell/console/src/main/resources/org/apache/karaf/shell/console/commands/karaf-shell-1.2.0.xsd b/shell/console/src/main/resources/org/apache/karaf/shell/console/commands/karaf-shell-1.2.0.xsd
deleted file mode 100644
index afc00f4..0000000
--- a/shell/console/src/main/resources/org/apache/karaf/shell/console/commands/karaf-shell-1.2.0.xsd
+++ /dev/null
@@ -1,225 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-
-<!-- $Rev: 699828 $ $Date: 2008-09-28 16:35:27 +0200 (Sun, 28 Sep 2008) $ -->
-
-<xsd:schema xmlns="http://karaf.apache.org/xmlns/shell/v1.2.0"
- xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- xmlns:bp="http://www.osgi.org/xmlns/blueprint/v1.0.0"
- targetNamespace="http://karaf.apache.org/xmlns/shell/v1.2.0"
- elementFormDefault="qualified"
- attributeFormDefault="unqualified">
-
- <xsd:import namespace="http://www.osgi.org/xmlns/blueprint/v1.0.0"/>
-
- <xsd:annotation>
- <xsd:documentation>
- Defines the configuration elements for Apache Karaf commands support.
- </xsd:documentation>
- </xsd:annotation>
-
- <xsd:element name="command-bundle">
- <xsd:complexType>
- <xsd:annotation>
- <xsd:documentation>
- Defines a command bundle.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:element ref="command" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
- <xsd:attribute name="scan" type="Tscan"/>
- </xsd:complexType>
- </xsd:element>
-
- <xsd:simpleType name="Tscan">
- <xsd:restriction>
- <xsd:simpleType>
- <xsd:list itemType="Tpackage" />
- </xsd:simpleType>
- <xsd:minLength value="1" />
- </xsd:restriction>
- </xsd:simpleType>
-
- <xsd:simpleType name="Tpackage">
- <xsd:restriction base="xsd:string">
- <xsd:pattern value="\*|[a-z]+(\.[a-z]+)+(\.\*)?" />
- </xsd:restriction>
- </xsd:simpleType>
-
- <xsd:element name="command">
- <xsd:complexType>
- <xsd:annotation>
- <xsd:documentation>
- Defines a command.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <!--
- NOTE: Not using an xsd:choice here, as I can't seem to figure out how to get it to properly
- validate the min/max of the containted elements. W/o the xsd:choice the validation
- works, though have to define elements in order :-(
- -->
- <xsd:element ref="action" minOccurs="1" maxOccurs="1"/>
- <xsd:element ref="documenter" minOccurs="0" maxOccurs="1"/>
- <xsd:choice minOccurs="0" maxOccurs="1">
- <xsd:element ref="completer"/>
- <xsd:element ref="completers"/>
- </xsd:choice>
- <xsd:element ref="optional-completers" minOccurs="0" maxOccurs="1"/>
- <xsd:element ref="message-source" minOccurs="0" maxOccurs="1"/>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
-
- <xsd:group name="commandComponentElements">
- <xsd:annotation>
- <xsd:documentation>
- Defines the valid elements for command components. This is based on beans:beanElements,
- stripping off the bits which are not valid in the command component context.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:choice minOccurs="0" maxOccurs="unbounded">
- <xsd:element name="argument" type="bp:Targument"/>
- <xsd:element name="property" type="bp:Tproperty"/>
- <!--
- NOTE: This seems to cause schema validation problems... not really sure why
- <xsd:any namespace="##other" processContents="strict" minOccurs="0" maxOccurs="unbounded"/>
- -->
- </xsd:choice>
- </xsd:sequence>
- </xsd:group>
-
- <xsd:attributeGroup name="commandComponentAttributes">
- <xsd:annotation>
- <xsd:documentation>
- Defines the valid attributes for command components. This is based on beans:beanAttributes,
- stripping off the bits which are not valid in the command component context.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:attribute name="class" type="xsd:string"/>
- <xsd:attribute name="depends-on" type="xsd:string"/>
- <xsd:attribute name="init-method" type="xsd:string"/>
- <xsd:attribute name="factory-method" type="xsd:string"/>
- <xsd:attribute name="factory-bean" type="xsd:string"/>
- <xsd:anyAttribute namespace="##other" processContents="lax"/>
- </xsd:attributeGroup>
-
- <xsd:complexType name="commandComponent" abstract="true">
- <xsd:annotation>
- <xsd:documentation>
- Support for command component elements, which are all basically just beans.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:group ref="commandComponentElements"/>
- <xsd:attributeGroup ref="commandComponentAttributes"/>
- </xsd:complexType>
-
- <xsd:element name="action">
- <xsd:complexType>
- <xsd:annotation>
- <xsd:documentation>
- Defines a command action.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="commandComponent"/>
- </xsd:complexContent>
- </xsd:complexType>
- </xsd:element>
-
- <xsd:element name="documenter">
- <xsd:complexType>
- <xsd:annotation>
- <xsd:documentation>
- Defines a command documenter.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="commandComponent"/>
- </xsd:complexContent>
- </xsd:complexType>
- </xsd:element>
-
- <xsd:element name="completer">
- <xsd:complexType>
- <xsd:annotation>
- <xsd:documentation>
- Defines a command completer.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="commandComponent"/>
- </xsd:complexContent>
- </xsd:complexType>
- </xsd:element>
-
- <xsd:element name="completers">
- <xsd:complexType>
- <xsd:annotation>
- <xsd:documentation>
- Defines a configurable command completer with a set of completers.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:sequence>
- <xsd:choice minOccurs="1" maxOccurs="unbounded">
- <xsd:element name="bean" type="bp:Tbean"/>
- <xsd:element name="ref" type="bp:Tref"/>
- <xsd:element name="null" type="bp:Tnull"/>
- </xsd:choice>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
-
- <xsd:element name="optional-completers">
- <xsd:complexType>
- <xsd:annotation>
- <xsd:documentation>
- Defines a configurable command completer with a set of completers.
- These completers are used for option value completion.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="bp:TtypedCollection">
- <xsd:sequence>
- <xsd:element name="entry" type="bp:TmapEntry" minOccurs="0"
- maxOccurs="unbounded" />
- </xsd:sequence>
- <xsd:attribute name="key-type" type="bp:Ttype" />
- </xsd:extension>
- </xsd:complexContent>
- </xsd:complexType>
- </xsd:element>
-
- <xsd:element name="message-source">
- <xsd:complexType>
- <xsd:annotation>
- <xsd:documentation>
- Defines a command message source.
- </xsd:documentation>
- </xsd:annotation>
- <xsd:complexContent>
- <xsd:extension base="commandComponent"/>
- </xsd:complexContent>
- </xsd:complexType>
- </xsd:element>
-
-</xsd:schema>
http://git-wip-us.apache.org/repos/asf/karaf/blob/662c07a6/tooling/karaf-scr-maven-plugin/NOTICE
----------------------------------------------------------------------
diff --git a/tooling/karaf-scr-maven-plugin/NOTICE b/tooling/karaf-scr-maven-plugin/NOTICE
deleted file mode 100644
index 7ec727b..0000000
--- a/tooling/karaf-scr-maven-plugin/NOTICE
+++ /dev/null
@@ -1,71 +0,0 @@
-Apache Karaf
-Copyright 2010-2014 The Apache Software Foundation
-
-
-I. Included Software
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
-Licensed under the Apache License 2.0.
-
-This product uses software developed at
-The OSGi Alliance (http://www.osgi.org/).
-Copyright (c) OSGi Alliance (2000, 2010).
-Licensed under the Apache License 2.0.
-
-This product includes software developed at
-OW2 (http://www.ow2.org/).
-Licensed under the BSD License.
-
-This product includes software developed at
-OPS4J (http://www.ops4j.org/).
-Licensed under the Apache License 2.0.
-
-This product includes software developed at
-Eclipse Foundation (http://www.eclipse.org/).
-Licensed under the EPL.
-
-This product includes software written by
-Antony Lesuisse.
-Licensed under Public Domain.
-
-
-II. Used Software
-
-This product uses software developed at
-FUSE Source (http://www.fusesource.org/).
-Licensed under the Apache License 2.0.
-
-This product uses software developed at
-AOP Alliance (http://aopalliance.sourceforge.net/).
-Licensed under the Public Domain.
-
-This product uses software developed at
-Tanuki Software (http://www.tanukisoftware.com/).
-Licensed under the Apache License 2.0.
-
-This product uses software developed at
-Jasypt (http://jasypt.sourceforge.net/).
-Licensed under the Apache License 2.0.
-
-This product uses software developed at
-JLine (http://jline.sourceforge.net).
-Licensed under the BSD License.
-
-This product uses software developed at
-SLF4J (http://www.slf4j.org/).
-Licensed under the MIT License.
-
-This product uses software developed at
-SpringSource (http://www.springsource.org/).
-Licensed under the Apache License 2.0.
-
-This product includes software from http://www.json.org.
-Copyright (c) 2002 JSON.org
-
-
-III. License Summary
-- Apache License 2.0
-- BSD License
-- EPL License
-- MIT License
http://git-wip-us.apache.org/repos/asf/karaf/blob/662c07a6/tooling/karaf-scr-maven-plugin/pom.xml
----------------------------------------------------------------------
diff --git a/tooling/karaf-scr-maven-plugin/pom.xml b/tooling/karaf-scr-maven-plugin/pom.xml
deleted file mode 100644
index 6189e8f..0000000
--- a/tooling/karaf-scr-maven-plugin/pom.xml
+++ /dev/null
@@ -1,243 +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.tooling</groupId>
- <artifactId>tooling</artifactId>
- <version>3.1.0-SNAPSHOT</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
-
- <artifactId>karaf-scr-maven-plugin</artifactId>
- <packaging>maven-plugin</packaging>
- <name>Apache Karaf :: Tooling :: Maven Karaf SCR Plugin</name>
-
- <properties>
- <appendedResourcesDirectory>${basedir}/../../etc/appended-resources</appendedResourcesDirectory>
- </properties>
-
- <dependencies>
-
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-plugin-api</artifactId>
- <version>3.0.3</version>
- </dependency>
- <dependency>
- <groupId>org.sonatype.aether</groupId>
- <artifactId>aether-api</artifactId>
- <version>1.11</version>
- </dependency>
- <dependency>
- <groupId>org.sonatype.aether</groupId>
- <artifactId>aether-util</artifactId>
- <version>1.11</version>
- </dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-artifact</artifactId>
- <version>3.0.3</version>
- </dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-core</artifactId>
- <version>3.0.3</version>
- </dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-compat</artifactId>
- <version>3.0.3</version>
- </dependency>
-
-
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-jdk14</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.maven.shared</groupId>
- <artifactId>maven-filtering</artifactId>
- <version>1.0-beta-4</version>
- </dependency>
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-utils</artifactId>
- <version>3.0</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <exclusions>
- <exclusion>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.bundlerepository</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.fileinstall</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.karaf.features</groupId>
- <artifactId>org.apache.karaf.features.core</artifactId>
- <exclusions>
- <exclusion>
- <artifactId>org.apache.karaf.shell.console</artifactId>
- <groupId>org.apache.karaf.shell</groupId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.url</groupId>
- <artifactId>pax-url-wrap</artifactId>
- </dependency>
- <dependency>
- <groupId>org.ops4j.pax.url</groupId>
- <artifactId>pax-url-aether</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.karaf.deployer</groupId>
- <artifactId>org.apache.karaf.deployer.spring</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.karaf.deployer</groupId>
- <artifactId>org.apache.karaf.deployer.blueprint</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.karaf.deployer</groupId>
- <artifactId>org.apache.karaf.deployer.features</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.karaf.deployer</groupId>
- <artifactId>org.apache.karaf.deployer.kar</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.karaf.kar</groupId>
- <artifactId>org.apache.karaf.kar.core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.servicemix.bundles</groupId>
- <artifactId>org.apache.servicemix.bundles.ant</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.karaf.shell</groupId>
- <artifactId>org.apache.karaf.shell.console</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.scr</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.gogo.runtime</artifactId>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.xbean</groupId>
- <artifactId>xbean-finder-shaded</artifactId>
- </dependency>
- <dependency>
- <groupId>org.easymock</groupId>
- <artifactId>easymock</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.scr.generator</artifactId>
- <version>1.5.0</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.scr.ds-annotations</artifactId>
- <version>1.2.4</version>
- </dependency>
- <dependency>
- <groupId>org.sonatype.plexus</groupId>
- <artifactId>plexus-build-api</artifactId>
- <version>0.0.7</version>
- </dependency>
- </dependencies>
-
- <profiles>
- <profile>
- <id>ci-build-profile</id>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-invoker-plugin</artifactId>
- <version>1.6</version>
- <configuration>
- <debug>true</debug>
- <projectsDirectory>src/it</projectsDirectory>
- <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
- <pomIncludes>
- <pomInclude>*/pom.xml</pomInclude>
- </pomIncludes>
- <postBuildHookScript>verify</postBuildHookScript>
- <localRepositoryPath>${project.build.directory}/system</localRepositoryPath>
- <!--<settingsFile>src/it/settings.xml</settingsFile>-->
- <mavenOpts>-Djava.io.tmpdir=${project.build.directory}</mavenOpts>
- <goals>
- <goal>install</goal>
- </goals>
- </configuration>
- <executions>
- <execution>
- <id>integration-test</id>
- <goals>
- <goal>install</goal>
- <goal>run</goal>
- </goals>
- </execution>
- </executions>
- <dependencies>
- <dependency>
- <groupId>xmlunit</groupId>
- <artifactId>xmlunit</artifactId>
- <version>1.3</version>
- </dependency>
- </dependencies>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
- <reporting>
- <!--<outputDirectory>target/site</outputDirectory>-->
- <plugins>
- <plugin>
- <artifactId>maven-plugin-plugin</artifactId>
- <version>2.9</version>
- </plugin>
- </plugins>
- </reporting>
-
-</project>
http://git-wip-us.apache.org/repos/asf/karaf/blob/662c07a6/tooling/karaf-scr-maven-plugin/src/main/java/org/apache/karaf/tooling/scr/ScrCommandMojo.java
----------------------------------------------------------------------
diff --git a/tooling/karaf-scr-maven-plugin/src/main/java/org/apache/karaf/tooling/scr/ScrCommandMojo.java b/tooling/karaf-scr-maven-plugin/src/main/java/org/apache/karaf/tooling/scr/ScrCommandMojo.java
deleted file mode 100644
index 413bc6c..0000000
--- a/tooling/karaf-scr-maven-plugin/src/main/java/org/apache/karaf/tooling/scr/ScrCommandMojo.java
+++ /dev/null
@@ -1,374 +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.tooling.scr;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.Writer;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.StringTokenizer;
-
-import org.apache.felix.service.command.CommandProcessor;
-import org.apache.felix.service.command.Function;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.CommandWithAction;
-import org.apache.karaf.shell.console.CompletableFunction;
-import org.apache.karaf.shell.inject.Destroy;
-import org.apache.karaf.shell.inject.Init;
-import org.apache.karaf.shell.inject.Reference;
-import org.apache.karaf.shell.inject.Service;
-import org.apache.maven.artifact.DependencyResolutionRequiredException;
-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;
-
-/**
- * The <code>ScrCommandMojo</code> generates a service descriptor file based
- * on annotations found in the sources.
- *
- * @goal scr
- * @phase process-classes
- * @threadSafe
- * @description Build Service Descriptors from Java Source
- * @requiresDependencyResolution compile
- */
-public class ScrCommandMojo extends AbstractMojo {
-
- /**
- * The Maven project.
- *
- * @parameter expression="project"
- * @required
- * @readonly
- */
- private MavenProject project;
-
- /**
- * @parameter expression="${project.build.directory}/generated-scr-commands"
- */
- private File outputDirectory;
-
- /**
- * @parameter
- */
- private int ranking;
-
- @Override
- public void execute() throws MojoExecutionException, MojoFailureException {
- try {
- ClassFinder finder = new ClassFinder(getClassLoader());
- List<String> components = new ArrayList<String>();
- boolean hasCommand = false;
- for (Class<?> clazz : finder.findAnnotatedClasses(Service.class)) {
-
- Command cmd = clazz.getAnnotation(Command.class);
- if (cmd != null) {
-// System.out.println("\nFound command: " + clazz.getName() + "\n\t" + cmd.scope() + ":" + cmd.name() + "\n");
-
- StringBuilder sb = new StringBuilder();
- sb.append("<?xml version='1.1'?>\n");
- sb.append("<scr:component xmlns:scr=\"http://www.osgi.org/xmlns/scr/v1.1.0\" name=\"")
- .append(clazz.getName())
- .append("\" activate=\"activate\" deactivate=\"deactivate\">\n");
- sb.append(" <implementation class=\"").append(ScrCommandSupport.class.getName()).append("\"/>\n");
- sb.append(" <service>\n");
- sb.append(" <provide interface=\"").append(Function.class.getName()).append("\"/>\n");
- sb.append(" <provide interface=\"").append(CompletableFunction.class.getName()).append("\"/>\n");
- sb.append(" <provide interface=\"").append(CommandWithAction.class.getName()).append("\"/>\n");
- sb.append(" </service>\n");
- Map<String, Class> refs = getReferences(clazz);
- for (String key : refs.keySet()) {
- sb.append(" <reference name=\"").append(key).append("\" cardinality=\"1..1\" interface=\"")
- .append(refs.get(key).getName()).append("\"/>\n");
- }
- sb.append(" <property name=\"hidden.component\" value=\"true\"/>\n");
- if (ranking != 0) {
- sb.append(" <property name=\"service.ranking\" value=\"").append(ranking).append("\"/>\n");
- }
- sb.append(" <property name=\"").append(CommandProcessor.COMMAND_SCOPE).append("\" value=\"").append(cmd.scope()).append("\"/>\n");
- sb.append(" <property name=\"").append(CommandProcessor.COMMAND_FUNCTION).append("\" value=\"").append(cmd.name()).append("\"/>\n");
- sb.append("</scr:component>\n");
- String component = "OSGI-INF/" + clazz.getName() + ".xml";
- components.add(component);
- File file = new File(outputDirectory, component);
- file.getParentFile().mkdirs();
- Writer w = new FileWriter(file);
- w.write(sb.toString());
- w.close();
- hasCommand = true;
- } else {
-// System.out.println("\nFound service: " + clazz.getName() + "\n");
-
- StringBuilder sb = new StringBuilder();
- sb.append("<?xml version='1.1'?>\n");
-
- String[] lf = getLifecycleMethods(clazz);
- sb.append("<scr:component xmlns:scr=\"http://www.osgi.org/xmlns/scr/v1.1.0\" name=\"")
- .append(clazz.getName()).append("\"");
- if (lf[0] != null) {
- sb.append(" activate=\"activate\"");
- }
- if (lf[1] != null) {
- sb.append(" deactivate=\"deactivate\"");
- }
- sb.append(">\n");
- sb.append(" <implementation class=\"").append(clazz.getName()).append("\"/>\n");
- sb.append(" <service>\n");
- List<Class> allClasses = new ArrayList<Class>();
- addAllClasses(allClasses, clazz);
- for (Class cl : allClasses) {
- sb.append(" <provide interface=\"").append(cl.getName()).append("\"/>\n");
- }
- sb.append(" </service>\n");
- Map<String, Class> refs = getReferences(clazz);
- for (String key : refs.keySet()) {
- sb.append(" <reference name=\"").append(key).append("\" cardinality=\"1..1\" interface=\"")
- .append(refs.get(key).getName()).append("\"");
- String[] bind = getBindMethods(clazz, key, refs.get(key));
- if (bind[0] != null) {
- sb.append(" bind=\"").append(bind[0]).append("\"");
- }
- if (bind[1] != null) {
- sb.append(" unbind=\"").append(bind[1]).append("\"");
- }
- sb.append("/>\n");
- }
- sb.append(" <property name=\"hidden.component\" value=\"true\"/>\n");
- if (ranking != 0) {
- sb.append(" <property name=\"service.ranking\" value=\"").append(ranking).append("\"/>\n");
- }
- sb.append("</scr:component>\n");
- String component = "OSGI-INF/" + clazz.getName() + ".xml";
- components.add(component);
- File file = new File(outputDirectory, component);
- file.getParentFile().mkdirs();
- Writer w = new FileWriter(file);
- w.write(sb.toString());
- w.close();
- }
- }
- if (!components.isEmpty()) {
- if (hasCommand) {
- String name = ScrCommandSupport.class.getName().replace('.', '/') + ".class";
- File file = new File(outputDirectory, name);
- file.getParentFile().mkdirs();
- URL url = getClass().getClassLoader().getResource(name);
- InputStream is = url.openStream();
- FileOutputStream fos = new FileOutputStream(file);
- copy(is, fos);
- is.close();
- fos.close();
- name = ScrCommandSupport.class.getName();
- name = name.substring(0, name.lastIndexOf('.'));
- setPrivatePackageHeader(name);
- }
- setServiceComponentHeader(components);
- updateProjectResources();
- }
- } catch (Exception e) {
- throw new MojoExecutionException("Error executing SCR command scanner", e);
- }
- }
-
- private String[] getLifecycleMethods(Class<?> clazz) {
- Method activate = null;
- Method deactivate = null;
- for (Method method : clazz.getMethods()) {
- if (method.getAnnotation(Init.class) != null) {
- if (activate == null) {
- activate = method;
- } else {
- throw new IllegalArgumentException("Multiple methods annotated with @Init found");
- }
- }
- if (method.getAnnotation(Destroy.class) != null) {
- if (deactivate == null) {
- deactivate = method;
- } else {
- throw new IllegalArgumentException("Multiple methods annotated with @Destroy found");
- }
- }
- }
- return new String[]{
- activate != null ? activate.getName() : null,
- deactivate != null ? deactivate.getName() : null
- };
- }
-
- private String[] getBindMethods(Class<?> clazz, String key, Class type) {
- String cap = key.substring(0, 1).toUpperCase() + key.substring(1);
- Method bind = null;
- Method unbind = null;
- try {
- bind = clazz.getMethod("set" + cap, type);
- } catch (NoSuchMethodException e0) {
- try {
- bind = clazz.getMethod("bind" + cap, type);
- } catch (NoSuchMethodException e1) {
- }
- }
- if (bind != null) {
- try {
- unbind = clazz.getMethod("un" + bind.getName(), type);
- } catch (NoSuchMethodException e0) {
- }
- }
- return new String[]{
- bind != null ? bind.getName() : null,
- unbind != null ? unbind.getName() : null
- };
- }
-
- private void addAllClasses(List<Class> allClasses, Class<?> clazz) {
- if (clazz != null && clazz != Object.class) {
- if (allClasses.add(clazz)) {
- addAllClasses(allClasses, clazz.getSuperclass());
- for (Class cl : clazz.getInterfaces()) {
- addAllClasses(allClasses, cl);
- }
- }
- }
- }
-
- private Map<String, Class> getReferences(Class<?> clazz) {
- Map<String, Class> refs = new HashMap<String, Class>();
- while (clazz != null) {
- for (Field field : clazz.getDeclaredFields()) {
- if (field.getAnnotation(Reference.class) != null) {
- refs.put(field.getName(), field.getType());
- }
- }
- clazz = clazz.getSuperclass();
- }
- return refs;
- }
-
- private ClassLoader getClassLoader() throws MojoFailureException, DependencyResolutionRequiredException, MalformedURLException {
- List<String> roots = Arrays.asList(project.getBuild().getOutputDirectory());
- List<String> paths = project.getCompileClasspathElements();
- List<URL> parentUrls = new ArrayList<URL>();
- List<URL> childUrls = new ArrayList<URL>();
-
-// System.out.println("Roots: " + roots);
-// System.out.println("Paths: " + paths);
- for (String path : paths) {
- URL url = new File(path).toURL();
- if (roots.contains(path)) {
- childUrls.add(url);
- } else {
- parentUrls.add(url);
- }
- }
- ClassLoader classLoader = new URLClassLoader(childUrls.toArray(new URL[]{}),
- new URLClassLoader(parentUrls.toArray(new URL[]{}), getClass().getClassLoader()));
- return classLoader;
- }
-
- private void setPrivatePackageHeader(String pkg) {
- String header = project.getProperties().getProperty("Private-Package");
- if (header != null && header.length() > 0) {
- header += "," + pkg;
- } else {
- header = pkg;
- }
- project.getProperties().setProperty("Private-Package", header);
-// System.out.println("\nPrivate-Package: " + header + "\n");
- }
-
- /**
- * Set the service component header based on the scr files.
- */
- private void setServiceComponentHeader(final List<String> files) {
- if (files != null && files.size() > 0) {
- final String svcHeader = project.getProperties().getProperty("Service-Component");
- final Set<String> xmlFiles = new HashSet<String>();
- if (svcHeader != null) {
- final StringTokenizer st = new StringTokenizer(svcHeader, ",");
- while (st.hasMoreTokens()) {
- final String token = st.nextToken();
- xmlFiles.add(token.trim());
- }
- }
-
- for (final String path : files) {
- xmlFiles.add(path);
- }
- final StringBuilder sb = new StringBuilder();
- boolean first = true;
- for (final String entry : xmlFiles) {
- if (!first) {
- sb.append(", ");
- } else {
- first = false;
- }
- sb.append(entry);
- }
- project.getProperties().setProperty("Service-Component", sb.toString());
-// System.out.println("\nService-Component: " + sb.toString() + "\n");
- }
- }
-
- /**
- * Update the Maven project resources.
- */
- private void updateProjectResources() {
- // now add the descriptor directory to the maven resources
- final String ourRsrcPath = this.outputDirectory.getAbsolutePath();
- boolean found = false;
- @SuppressWarnings("unchecked")
- final Iterator<Resource> rsrcIterator = this.project.getResources().iterator();
- while (!found && rsrcIterator.hasNext()) {
- final Resource rsrc = rsrcIterator.next();
- found = rsrc.getDirectory().equals(ourRsrcPath);
- }
- if (!found) {
- final Resource resource = new Resource();
- resource.setDirectory(this.outputDirectory.getAbsolutePath());
- this.project.addResource(resource);
- }
- }
-
- static void copy(InputStream is, OutputStream os) throws IOException {
- byte[] buffer = new byte[8192];
- int l;
- while ((l = is.read(buffer)) > 0) {
- os.write(buffer, 0, l);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/karaf/blob/662c07a6/tooling/karaf-scr-maven-plugin/src/main/java/org/apache/karaf/tooling/scr/ScrCommandSupport.java
----------------------------------------------------------------------
diff --git a/tooling/karaf-scr-maven-plugin/src/main/java/org/apache/karaf/tooling/scr/ScrCommandSupport.java b/tooling/karaf-scr-maven-plugin/src/main/java/org/apache/karaf/tooling/scr/ScrCommandSupport.java
deleted file mode 100644
index 2a16ebb..0000000
--- a/tooling/karaf-scr-maven-plugin/src/main/java/org/apache/karaf/tooling/scr/ScrCommandSupport.java
+++ /dev/null
@@ -1,112 +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.tooling.scr;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.felix.gogo.commands.Action;
-import org.apache.karaf.shell.commands.basic.AbstractCommand;
-import org.apache.karaf.shell.console.BundleContextAware;
-import org.apache.karaf.shell.console.CompletableFunction;
-import org.apache.karaf.shell.console.Completer;
-import org.apache.karaf.shell.inject.Init;
-import org.apache.karaf.shell.inject.Reference;
-import org.osgi.framework.BundleContext;
-import org.osgi.service.component.ComponentContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class ScrCommandSupport extends AbstractCommand implements CompletableFunction {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(ScrCommandSupport.class);
-
- private ComponentContext componentContext;
-
- public ScrCommandSupport() {
- }
-
- public void activate(ComponentContext componentContext) {
- LOGGER.info("Activating SCR command for " + componentContext.getProperties().get("component.name"));
- this.componentContext = componentContext;
- }
-
- public void deactivate(ComponentContext componentContext) {
- }
-
- public Class<? extends Action> getActionClass() {
- try {
- String className = (String) componentContext.getProperties().get("component.name");
- return (Class<? extends Action>) componentContext.getBundleContext().getBundle().loadClass(className);
- } catch (ClassNotFoundException e) {
- throw new IllegalStateException(e);
- }
- }
-
- @Override
- public Action createNewAction() {
- Class actionClass = getActionClass();
- try {
- Action action = (Action) actionClass.newInstance();
- // Inject services
- for (Class<?> cl = actionClass; cl != Object.class; cl = cl.getSuperclass()) {
- for (Field field : cl.getDeclaredFields()) {
- if (field.getAnnotation(Reference.class) != null) {
- Object value;
- if (field.getType() == BundleContext.class) {
- value = componentContext.getBundleContext();
- } else {
- value = componentContext.locateService(field.getName());
- }
- if (value == null) {
- throw new RuntimeException("No OSGi service matching " + field.getType().getName());
- }
- field.setAccessible(true);
- field.set(action, value);
- }
- }
- }
- if (action instanceof BundleContextAware) {
- ((BundleContextAware) action).setBundleContext(componentContext.getBundleContext());
- }
- for (Method method : actionClass.getDeclaredMethods()) {
- Init ann = method.getAnnotation(Init.class);
- if (ann != null && method.getParameterTypes().length == 0 && method.getReturnType() == void.class) {
- method.setAccessible(true);
- method.invoke(action);
- }
- }
- return action;
- } catch (Exception e) {
- throw new RuntimeException("Unable to creation command action " + actionClass.getName(), e);
- }
- }
-
- @Override
- public List<Completer> getCompleters() {
- return null;
- }
-
- @Override
- public Map<String, Completer> getOptionalCompleters() {
- return null;
- }
-}
http://git-wip-us.apache.org/repos/asf/karaf/blob/662c07a6/tooling/pom.xml
----------------------------------------------------------------------
diff --git a/tooling/pom.xml b/tooling/pom.xml
index 619463e..8535a9e 100644
--- a/tooling/pom.xml
+++ b/tooling/pom.xml
@@ -34,7 +34,6 @@
<name>Apache Karaf :: Tooling</name>
<modules>
- <module>karaf-scr-maven-plugin</module>
<module>karaf-maven-plugin</module>
</modules>