felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r687061 - in /felix/trunk/shell.remote/src/main/java/org/apache/felix/shell/remote: Activator.java Listener.java ServiceMediator.java Shell.java
Date Tue, 19 Aug 2008 14:10:49 GMT
Author: fmeschbe
Date: Tue Aug 19 07:10:48 2008
New Revision: 687061

URL: http://svn.apache.org/viewvc?rev=687061&view=rev
Log:
FELIX-615 Use framework properties instead of system properties for configuration
and some import list optimizations.

Modified:
    felix/trunk/shell.remote/src/main/java/org/apache/felix/shell/remote/Activator.java
    felix/trunk/shell.remote/src/main/java/org/apache/felix/shell/remote/Listener.java
    felix/trunk/shell.remote/src/main/java/org/apache/felix/shell/remote/ServiceMediator.java
    felix/trunk/shell.remote/src/main/java/org/apache/felix/shell/remote/Shell.java

Modified: felix/trunk/shell.remote/src/main/java/org/apache/felix/shell/remote/Activator.java
URL: http://svn.apache.org/viewvc/felix/trunk/shell.remote/src/main/java/org/apache/felix/shell/remote/Activator.java?rev=687061&r1=687060&r2=687061&view=diff
==============================================================================
--- felix/trunk/shell.remote/src/main/java/org/apache/felix/shell/remote/Activator.java (original)
+++ felix/trunk/shell.remote/src/main/java/org/apache/felix/shell/remote/Activator.java Tue
Aug 19 07:10:48 2008
@@ -41,7 +41,7 @@
 
         //2. Prepare the listener
         m_Listener = new Listener();
-        m_Listener.activate();
+        m_Listener.activate( bundleContext );
     }
 
 

Modified: felix/trunk/shell.remote/src/main/java/org/apache/felix/shell/remote/Listener.java
URL: http://svn.apache.org/viewvc/felix/trunk/shell.remote/src/main/java/org/apache/felix/shell/remote/Listener.java?rev=687061&r1=687060&r2=687061&view=diff
==============================================================================
--- felix/trunk/shell.remote/src/main/java/org/apache/felix/shell/remote/Listener.java (original)
+++ felix/trunk/shell.remote/src/main/java/org/apache/felix/shell/remote/Listener.java Tue
Aug 19 07:10:48 2008
@@ -23,6 +23,8 @@
 import java.net.Socket;
 import java.net.SocketException;
 
+import org.osgi.framework.BundleContext;
+
 
 /**
  * Implements a simple listener that will accept a single connection.
@@ -44,25 +46,11 @@
     /**
      * Activates this listener on a listener thread (telnetconsole.Listener).
      */
-    public void activate()
+    public void activate( BundleContext bundleContext )
     {
-        //configure from system property
-        try
-        {
-            m_Port = Integer.parseInt( System.getProperty( "osgi.shell.telnet.port", "6666"
) );
-        }
-        catch ( NumberFormatException ex )
-        {
-            Activator.getServices().error( "Listener::activate()", ex );
-        }
-        try
-        {
-            m_MaxConnections = Integer.parseInt( System.getProperty( "osgi.shell.telnet.maxconn",
"2" ) );
-        }
-        catch ( NumberFormatException ex )
-        {
-            Activator.getServices().error( "Listener::activate()", ex );
-        }
+        //configure from framework property
+        m_Port = getProperty( bundleContext, "osgi.shell.telnet.port", 6666 );
+        m_MaxConnections = getProperty( bundleContext, "osgi.shell.telnet.maxconn", 2 );
         m_UseCounter = new AtomicInteger( 0 );
         m_ListenerThread = new Thread( new Acceptor(), "telnetconsole.Listener" );
         m_ListenerThread.start();
@@ -158,4 +146,23 @@
     private static final String INUSE_MESSAGE = "Connection refused.\r\n"
         + "All possible connections are currently being used.\r\n";
 
+
+    private int getProperty( BundleContext bundleContext, String propName, int defaultValue
)
+    {
+        String propValue = bundleContext.getProperty( propName );
+        if ( propValue != null )
+        {
+            try
+            {
+                return Integer.parseInt( propValue );
+            }
+            catch ( NumberFormatException ex )
+            {
+                Activator.getServices().error( "Listener::activate()", ex );
+            }
+        }
+
+        return defaultValue;
+    }
+
 }//class Listener

Modified: felix/trunk/shell.remote/src/main/java/org/apache/felix/shell/remote/ServiceMediator.java
URL: http://svn.apache.org/viewvc/felix/trunk/shell.remote/src/main/java/org/apache/felix/shell/remote/ServiceMediator.java?rev=687061&r1=687060&r2=687061&view=diff
==============================================================================
--- felix/trunk/shell.remote/src/main/java/org/apache/felix/shell/remote/ServiceMediator.java
(original)
+++ felix/trunk/shell.remote/src/main/java/org/apache/felix/shell/remote/ServiceMediator.java
Tue Aug 19 07:10:48 2008
@@ -18,7 +18,13 @@
 
 
 import org.apache.felix.shell.ShellService;
-import org.osgi.framework.*;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceEvent;
+import org.osgi.framework.ServiceListener;
+import org.osgi.framework.ServiceReference;
 import org.osgi.service.log.LogService;
 
 

Modified: felix/trunk/shell.remote/src/main/java/org/apache/felix/shell/remote/Shell.java
URL: http://svn.apache.org/viewvc/felix/trunk/shell.remote/src/main/java/org/apache/felix/shell/remote/Shell.java?rev=687061&r1=687060&r2=687061&view=diff
==============================================================================
--- felix/trunk/shell.remote/src/main/java/org/apache/felix/shell/remote/Shell.java (original)
+++ felix/trunk/shell.remote/src/main/java/org/apache/felix/shell/remote/Shell.java Tue Aug
19 07:10:48 2008
@@ -17,13 +17,13 @@
 package org.apache.felix.shell.remote;
 
 
-import org.apache.felix.shell.ShellService;
-
 import java.io.BufferedReader;
 import java.io.IOException;
 import java.io.PrintStream;
 import java.net.Socket;
 
+import org.apache.felix.shell.ShellService;
+
 
 /**
  * Implements the shell.



Mime
View raw message