FELIX-2625 Small improvements
- Remove Declarative Services dependency (use plain old Activator)
- Remove unneeded logging
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1238474 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/webconsole-plugins/gogo/pom.xml b/webconsole-plugins/gogo/pom.xml
index 30f9a5e..e155deb 100644
--- a/webconsole-plugins/gogo/pom.xml
+++ b/webconsole-plugins/gogo/pom.xml
@@ -58,38 +58,6 @@
</plugin>
<plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-scr-plugin</artifactId>
- <version>1.7.2</version>
- <!-- As QDox is trying to inspect/load the classes
- we have to add a slf4j implementation to the
- class path of the plugin - we usually use
- a static field for the logger and during class
- loading this field requires an slf4j implementation!
- -->
- <dependencies>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-simple</artifactId>
- <version>1.5.2</version>
- </dependency>
- </dependencies>
- <executions>
- <execution>
- <id>generate-scr-scrdescriptor</id>
- <goals>
- <goal>scr</goal>
- </goals>
- <configuration>
- <properties>
- <service.vendor>The Apache Software Foundation</service.vendor>
- </properties>
- </configuration>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
@@ -116,9 +84,11 @@
<Bundle-NativeCode>
META-INF/native/windows32/jansi.dll;osname=Win32;processor=x86,
META-INF/native/windows64/jansi.dll;osname=Win32;processor=x86-64,
+ <!--
META-INF/native/linux32/libjansi.so;osname=Linux;processor=x86,
META-INF/native/linux64/libjansi.so;osname=Linux;processor=x86-64,
META-INF/native/osx/libjansi.jnilib;osname=MacOSX,
+ -->
*
</Bundle-NativeCode>
</instructions>
@@ -147,12 +117,6 @@
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <version>1.5.0</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.webconsole</artifactId>
<version>3.0.0</version>
@@ -170,11 +134,5 @@
<version>2.5</version>
<scope>provided</scope>
</dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.scr.annotations</artifactId>
- <version>1.6.0</version>
- <scope>provided</scope>
- </dependency>
</dependencies>
</project>
diff --git a/webconsole-plugins/gogo/src/main/java/org/apache/felix/webconsole/plugins/gogo/impl/Activator.java b/webconsole-plugins/gogo/src/main/java/org/apache/felix/webconsole/plugins/gogo/impl/Activator.java
index b8de725..59703ee 100644
--- a/webconsole-plugins/gogo/src/main/java/org/apache/felix/webconsole/plugins/gogo/impl/Activator.java
+++ b/webconsole-plugins/gogo/src/main/java/org/apache/felix/webconsole/plugins/gogo/impl/Activator.java
@@ -24,11 +24,21 @@
public class Activator implements BundleActivator {
+ private GogoPlugin plugin;
+
public void start(BundleContext context) throws Exception {
AnsiConsole.systemInstall();
+
+ this.plugin = new GogoPlugin();
+ this.plugin.register(context);
}
public void stop(BundleContext context) throws Exception {
+ if (this.plugin != null) {
+ this.plugin.unregister();
+ this.plugin = null;
+ }
+
AnsiConsole.systemUninstall();
}
diff --git a/webconsole-plugins/gogo/src/main/java/org/apache/felix/webconsole/plugins/gogo/impl/Console.java b/webconsole-plugins/gogo/src/main/java/org/apache/felix/webconsole/plugins/gogo/impl/Console.java
index c9f37e2..42b3585 100644
--- a/webconsole-plugins/gogo/src/main/java/org/apache/felix/webconsole/plugins/gogo/impl/Console.java
+++ b/webconsole-plugins/gogo/src/main/java/org/apache/felix/webconsole/plugins/gogo/impl/Console.java
@@ -45,8 +45,6 @@
import org.apache.felix.service.command.CommandSession;
import org.apache.felix.service.command.Converter;
import org.fusesource.jansi.Ansi;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
public class Console implements Runnable {
@@ -62,8 +60,6 @@
public static final String IGNORE_INTERRUPTS = "karaf.ignoreInterrupts";
- private static final Logger LOGGER = LoggerFactory.getLogger(Console.class);
-
protected CommandSession session;
private ConsoleReader reader;
@@ -160,7 +156,6 @@
}
session.execute(new String(w.toCharArray()));
} catch (Exception e) {
- LOGGER.debug("Error in initialization script", e);
System.err.println("Error in initialization script: " + e.getMessage());
} finally {
if (r != null) {
@@ -216,7 +211,6 @@
break;
} catch (Exception t) {
try {
- LOGGER.info("Exception caught while executing command", t);
session.put(LAST_EXCEPTION, t);
session.getConsole().print(Ansi.ansi().fg(Ansi.Color.RED).toString());
session.getConsole().println(
diff --git a/webconsole-plugins/gogo/src/main/java/org/apache/felix/webconsole/plugins/gogo/impl/GogoPlugin.java b/webconsole-plugins/gogo/src/main/java/org/apache/felix/webconsole/plugins/gogo/impl/GogoPlugin.java
index 323bf49..70b57b2 100644
--- a/webconsole-plugins/gogo/src/main/java/org/apache/felix/webconsole/plugins/gogo/impl/GogoPlugin.java
+++ b/webconsole-plugins/gogo/src/main/java/org/apache/felix/webconsole/plugins/gogo/impl/GogoPlugin.java
@@ -24,6 +24,7 @@
import java.io.ByteArrayInputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.InterruptedIOException;
import java.io.PipedInputStream;
@@ -32,42 +33,29 @@
import java.io.PrintWriter;
import java.util.zip.GZIPOutputStream;
-import javax.servlet.Servlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.apache.felix.scr.annotations.Activate;
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Deactivate;
-import org.apache.felix.scr.annotations.Property;
-import org.apache.felix.scr.annotations.Reference;
-import org.apache.felix.scr.annotations.Service;
import org.apache.felix.service.command.CommandProcessor;
import org.apache.felix.service.command.CommandSession;
import org.apache.felix.webconsole.SimpleWebConsolePlugin;
-import org.apache.felix.webconsole.WebConsoleConstants;
import org.osgi.framework.BundleContext;
/**
* The <code>GogoPlugin</code>
*/
-@Component
-@Service(Servlet.class)
public class GogoPlugin extends SimpleWebConsolePlugin {
/** Pseudo class version ID to keep the IDE quite. */
private static final long serialVersionUID = 1L;
- @Property(name=WebConsoleConstants.PLUGIN_LABEL)
public static final String LABEL = "gogo";
- @Property(name=WebConsoleConstants.PLUGIN_TITLE)
public static final String TITLE = "Gogo";
public static final int TERM_WIDTH = 120;
public static final int TERM_HEIGHT = 39;
- @Reference
private CommandProcessor commandProcessor;
public GogoPlugin() {
@@ -75,14 +63,18 @@
}
@Override
- @Activate
public void activate(BundleContext bundleContext) {
super.activate(bundleContext);
+ this.commandProcessor = new CommandProcessor() {
+ public CommandSession createSession(InputStream in, PrintStream out, PrintStream err) {
+ return ((CommandProcessor) getService(CommandProcessor.class.getName())).createSession(in, out, err);
+ }
+ };
}
@Override
- @Deactivate
public void deactivate() {
+ this.commandProcessor = null;
super.deactivate();
}