felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1660307 - in /felix/trunk/scr: ./ src/main/java/org/apache/felix/scr/impl/ src/main/java/org/apache/felix/scr/impl/config/ src/main/java/org/apache/felix/scr/info/
Date Tue, 17 Feb 2015 07:11:05 GMT
Author: cziegeler
Date: Tue Feb 17 07:11:05 2015
New Revision: 1660307

URL: http://svn.apache.org/r1660307
Log:
FELIX-4785 : Incompatible SCR API

Added:
    felix/trunk/scr/src/main/java/org/apache/felix/scr/info/
    felix/trunk/scr/src/main/java/org/apache/felix/scr/info/ScrInfo.java   (with props)
Modified:
    felix/trunk/scr/bnd.bnd
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/Activator.java
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ScrCommand.java
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ScrConfiguration.java

Modified: felix/trunk/scr/bnd.bnd
URL: http://svn.apache.org/viewvc/felix/trunk/scr/bnd.bnd?rev=1660307&r1=1660306&r2=1660307&view=diff
==============================================================================
--- felix/trunk/scr/bnd.bnd (original)
+++ felix/trunk/scr/bnd.bnd Tue Feb 17 07:11:05 2015
@@ -9,6 +9,7 @@ Provide-Capability: osgi.extender;\
                    
 
 Export-Package: org.apache.felix.scr.component;version=1.1.0;provide:=true, \
+ org.apache.felix.scr.info;version=1.0.0;provide:=true, \
  org.osgi.service.component;version=1.3;-split-package:=first;provide:=true, \
  org.osgi.service.component.runtime;version=1.3;provide:=true, \
  org.osgi.service.component.runtime.dto;version=1.3;provide:=true, \

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/Activator.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/Activator.java?rev=1660307&r1=1660306&r2=1660307&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/Activator.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/Activator.java Tue Feb 17 07:11:05
2015
@@ -165,6 +165,7 @@ public class Activator extends AbstractE
         super.doStart();
 
         m_scrCommand = ScrCommand.register(m_context, runtime, m_configuration);
+        m_configuration.setScrCommand( m_scrCommand );
     }
 
     @Override

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ScrCommand.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ScrCommand.java?rev=1660307&r1=1660306&r2=1660307&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ScrCommand.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ScrCommand.java Tue Feb 17 07:11:05
2015
@@ -33,6 +33,7 @@ import java.util.Map.Entry;
 import java.util.TreeMap;
 import java.util.regex.Pattern;
 
+import org.apache.felix.scr.info.ScrInfo;
 import org.apache.felix.scr.impl.config.ScrConfiguration;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
@@ -52,13 +53,14 @@ import org.osgi.service.component.runtim
  * {@link #register(BundleContext, ScrService, ScrConfiguration)} method
  * instantiates and registers the Gogo and Shell commands as possible.
  */
-public class ScrCommand
+public class ScrCommand implements ScrInfo
 {
 
     private final BundleContext bundleContext;
     private final ServiceComponentRuntime scrService;
     private final ScrConfiguration scrConfiguration;
-
+    
+    private ServiceRegistration<ScrInfo> reg;
     private ServiceRegistration<?> gogoReg;
     private ServiceRegistration<?> shellReg;
 
@@ -145,7 +147,29 @@ public class ScrCommand
 
     // ---------- Actual implementation
 
-
+    
+    public void update( boolean infoAsService )
+    {
+        if (infoAsService)
+        {
+            if ( reg == null )
+            {
+                final Hashtable<String, Object> props = new Hashtable<String, Object>();
+                props.put(Constants.SERVICE_DESCRIPTION, "SCR Info service");
+                props.put(Constants.SERVICE_VENDOR, "The Apache Software Foundation");
+                reg = bundleContext.registerService( ScrInfo.class, this, props );
+            }
+        }
+        else
+        {
+            if ( reg != null )
+            {
+                reg.unregister();
+                reg = null;
+            }
+        }
+    }
+    
     /* (non-Javadoc)
      * @see org.apache.felix.scr.impl.ScrInfo#list(java.lang.String, java.io.PrintStream,
java.io.PrintStream)
      */
@@ -505,6 +529,8 @@ public class ScrCommand
         out.println(scrConfiguration.stopTimeout());
         out.print("Global extender: ");
         out.println(scrConfiguration.globalExtender());
+        out.print("Info Service registered: ");
+        out.println(scrConfiguration.infoAsService() ? "Supported" : "Unsupported");
     }
 
     private String toStateString(int state)

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ScrConfiguration.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ScrConfiguration.java?rev=1660307&r1=1660306&r2=1660307&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ScrConfiguration.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ScrConfiguration.java Tue
Feb 17 07:11:05 2015
@@ -23,6 +23,7 @@ import java.util.Dictionary;
 import java.util.Hashtable;
 
 import org.apache.felix.scr.impl.Activator;
+import org.apache.felix.scr.impl.ScrCommand;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceRegistration;
@@ -63,6 +64,8 @@ public class ScrConfiguration
 
     public static final String PROP_DELAYED_KEEP_INSTANCES = "ds.delayed.keepInstances";
 
+    public static final String PROP_INFO_SERVICE = "ds.info.service";
+
     public static final String PROP_LOCK_TIMEOUT = "ds.lock.timeout.milliseconds";
 
     public static final String PROP_STOP_TIMEOUT = "ds.stop.timeout.milliseconds";
@@ -94,7 +97,9 @@ public class ScrConfiguration
     private boolean factoryEnabled;
 
     private boolean keepInstances;
-
+    
+    private boolean infoAsService;
+    
     private long lockTimeout = DEFAULT_LOCK_TIMEOUT_MILLISECONDS;
 
     private long stopTimeout = DEFAULT_STOP_TIMEOUT_MILLISECONDS;
@@ -104,6 +109,8 @@ public class ScrConfiguration
     private BundleContext bundleContext;
 
     private ServiceRegistration<ManagedService> managedService;
+    
+    private ScrCommand scrCommand;
 
     public ScrConfiguration( Activator activator )
     {
@@ -140,6 +147,12 @@ public class ScrConfiguration
 
         this.bundleContext = null;
     }
+    
+    public void setScrCommand(ScrCommand scrCommand)
+    {
+        this.scrCommand = scrCommand;
+        scrCommand.update(infoAsService());
+    }
 
     // Called from the ScrManagedService.updated method to reconfigure
     void configure( Dictionary<String, ?> config, boolean fromConfig )
@@ -157,6 +170,7 @@ public class ScrConfiguration
                         logLevel = LogService.LOG_ERROR;
                         factoryEnabled = false;
                         keepInstances = false;
+                        infoAsService = false;
                         lockTimeout = DEFAULT_LOCK_TIMEOUT_MILLISECONDS;
                         stopTimeout = DEFAULT_STOP_TIMEOUT_MILLISECONDS;
                         newGlobalExtender = false;
@@ -166,6 +180,7 @@ public class ScrConfiguration
                         logLevel = getDefaultLogLevel();
                         factoryEnabled = getDefaultFactoryEnabled();
                         keepInstances = getDefaultKeepInstances();
+                        infoAsService = getDefaultInfoAsService();
                         lockTimeout = getDefaultLockTimeout();
                         stopTimeout = getDefaultStopTimeout();
                         newGlobalExtender = getDefaultGlobalExtender();
@@ -181,12 +196,17 @@ public class ScrConfiguration
                 logLevel = getLogLevel( config.get( PROP_LOGLEVEL ) );
                 factoryEnabled = VALUE_TRUE.equalsIgnoreCase( String.valueOf( config.get(
PROP_FACTORY_ENABLED ) ) );
                 keepInstances = VALUE_TRUE.equalsIgnoreCase( String.valueOf( config.get(
PROP_DELAYED_KEEP_INSTANCES ) ) );
+                infoAsService = VALUE_TRUE.equalsIgnoreCase( String.valueOf( config.get(
PROP_INFO_SERVICE) ) );
                 Long timeout = ( Long ) config.get( PROP_LOCK_TIMEOUT );
                 lockTimeout = timeout == null? DEFAULT_LOCK_TIMEOUT_MILLISECONDS: timeout;
                 timeout = ( Long ) config.get( PROP_STOP_TIMEOUT );
                 stopTimeout = timeout == null? DEFAULT_STOP_TIMEOUT_MILLISECONDS: timeout;
                 newGlobalExtender = VALUE_TRUE.equalsIgnoreCase( String.valueOf( config.get(
PROP_GLOBAL_EXTENDER) ) );
             }
+            if ( scrCommand != null )
+            {
+                scrCommand.update( infoAsService() );
+            }
             oldGlobalExtender = this.globalExtender;
             this.globalExtender = newGlobalExtender;
         }
@@ -216,6 +236,11 @@ public class ScrConfiguration
     {
         return keepInstances;
     }
+    
+    public boolean infoAsService()
+    {
+        return infoAsService;
+    }
 
     public long lockTimeout()
     {
@@ -248,6 +273,11 @@ public class ScrConfiguration
     {
         return getLogLevel( bundleContext.getProperty( PROP_LOGLEVEL ) );
     }
+    
+    private boolean getDefaultInfoAsService()
+    {
+        return VALUE_TRUE.equalsIgnoreCase( bundleContext.getProperty( PROP_INFO_SERVICE)
);
+    }
 
     private long getDefaultLockTimeout()
     {

Added: felix/trunk/scr/src/main/java/org/apache/felix/scr/info/ScrInfo.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/info/ScrInfo.java?rev=1660307&view=auto
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/info/ScrInfo.java (added)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/info/ScrInfo.java Tue Feb 17 07:11:05
2015
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.scr.info;
+
+import java.io.PrintWriter;
+
+/**
+ * Abstraction of command interface.
+ *
+ */
+public interface ScrInfo
+{
+
+    /**
+     * List in text the components for the bundle specified, or all components if null, sorted
by component ID
+     * @param bundleIdentifier bundle the components are in or null for all components
+     * @param out PrintStream for normal output
+     * @throws IllegalArgumentException if nothing can be found
+     */
+    void list(String bundleIdentifier, PrintWriter out);
+
+    /**
+     * List in text detailed information about the specified components.  Components can
be specified by
+     * numeric componentId, component name, a regexp to match for component name, or null
for all components.
+     * @param componentId specifier for desired components
+     * @param out PrintStream for normal output
+     * @throws IllegalArgumentException if nothing can be found
+     */
+    void info(String componentId, PrintWriter out);
+
+    /**
+     * List in text the current SCR configuration
+     * @param out PrintStream for output.
+     */
+    void config(PrintWriter out);
+
+}
\ No newline at end of file

Propchange: felix/trunk/scr/src/main/java/org/apache/felix/scr/info/ScrInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: felix/trunk/scr/src/main/java/org/apache/felix/scr/info/ScrInfo.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision rev url

Propchange: felix/trunk/scr/src/main/java/org/apache/felix/scr/info/ScrInfo.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message