Return-Path: X-Original-To: apmail-felix-commits-archive@www.apache.org Delivered-To: apmail-felix-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 404E8E64A for ; Mon, 4 Feb 2013 02:16:39 +0000 (UTC) Received: (qmail 57947 invoked by uid 500); 4 Feb 2013 02:16:39 -0000 Delivered-To: apmail-felix-commits-archive@felix.apache.org Received: (qmail 57911 invoked by uid 500); 4 Feb 2013 02:16:39 -0000 Mailing-List: contact commits-help@felix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@felix.apache.org Delivered-To: mailing list commits@felix.apache.org Received: (qmail 57904 invoked by uid 99); 4 Feb 2013 02:16:39 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 04 Feb 2013 02:16:39 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 04 Feb 2013 02:16:33 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id A4D6A238896F; Mon, 4 Feb 2013 02:16:12 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1442007 - in /felix/trunk/scr: ./ src/main/java/org/apache/felix/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/impl/manager/ Date: Mon, 04 Feb 2013 02:16:12 -0000 To: commits@felix.apache.org From: djencks@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130204021612.A4D6A238896F@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: djencks Date: Mon Feb 4 02:16:11 2013 New Revision: 1442007 URL: http://svn.apache.org/viewvc?rev=1442007&view=rev Log: FELIX-3888 Expose the internals of ScrCommand as an (optional) service. Also some cleanup and add aries version-checker Added: felix/trunk/scr/src/main/java/org/apache/felix/scr/ScrInfo.java Modified: felix/trunk/scr/pom.xml felix/trunk/scr/src/main/java/org/apache/felix/scr/Reference.java felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/Activator.java felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ComponentRegistry.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 felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ScrManagedServiceMetaTypeProvider.java felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/DependencyManager.java Modified: felix/trunk/scr/pom.xml URL: http://svn.apache.org/viewvc/felix/trunk/scr/pom.xml?rev=1442007&r1=1442006&r2=1442007&view=diff ============================================================================== --- felix/trunk/scr/pom.xml (original) +++ felix/trunk/scr/pom.xml Mon Feb 4 02:16:11 2013 @@ -223,6 +223,7 @@ ${project.artifactId} The Apache Software Foundation + 1.7 http://felix.apache.org/site/apache-felix-service-component-runtime.html @@ -230,7 +231,7 @@ org.apache.felix.scr.impl.Activator - org.apache.felix.scr;version=1.7, + org.apache.felix.scr;version=1.8, org.apache.felix.scr.component;version=1.0; mandatory:="status"; status="provisional", org.osgi.service.component @@ -393,6 +394,23 @@ *.impl + + org.apache.aries.versioning + org.apache.aries.versioning.plugin + 0.1.0 + + + default-verify + verify + + version-check + + + org.apache.felix:org.apache.felix.scr:1.6.2 + + + + Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/Reference.java URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/Reference.java?rev=1442007&r1=1442006&r2=1442007&view=diff ============================================================================== --- felix/trunk/scr/src/main/java/org/apache/felix/scr/Reference.java (original) +++ felix/trunk/scr/src/main/java/org/apache/felix/scr/Reference.java Mon Feb 4 02:16:11 2013 @@ -50,7 +50,13 @@ public interface Reference */ ServiceReference[] getServiceReferences(); - + /** + * added by mistake. Use getServiceReferences(); + * @return + */ + @Deprecated + ServiceReference[] getBoundServiceReferences(); + /** * Returns whether this reference is satisified. A {@link #isOptional() optional} * component is always satsified. Otherwise true is only Added: felix/trunk/scr/src/main/java/org/apache/felix/scr/ScrInfo.java URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/ScrInfo.java?rev=1442007&view=auto ============================================================================== --- felix/trunk/scr/src/main/java/org/apache/felix/scr/ScrInfo.java (added) +++ felix/trunk/scr/src/main/java/org/apache/felix/scr/ScrInfo.java Mon Feb 4 02:16:11 2013 @@ -0,0 +1,54 @@ +/* + * 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; + +import java.io.PrintStream; + +/** + * Abstraction of command interface. + * + * @Since 1.6.4 + */ +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 + * @param err PrintStream for errors. + */ + void list(String bundleIdentifier, PrintStream out, PrintStream err); + + /** + * 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 + * @param err PrintStream for errors. + */ + void info(String componentId, PrintStream out, PrintStream err); + + /** + * List in text the current SCR configuration + * @param out PrintStream for output. + */ + void config(PrintStream out); + +} \ No newline at end of file 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=1442007&r1=1442006&r2=1442007&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 Mon Feb 4 02:16:11 2013 @@ -108,7 +108,8 @@ public class Activator implements Bundle loadAllComponents( context ); // register the Gogo and old Shell commands - ScrCommand.register(context, m_componentRegistry, m_configuration); + ScrCommand scrCommand = ScrCommand.register(context, m_componentRegistry, m_configuration); + m_configuration.setScrCommand( scrCommand ); } Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ComponentRegistry.java URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ComponentRegistry.java?rev=1442007&r1=1442006&r2=1442007&view=diff ============================================================================== --- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ComponentRegistry.java (original) +++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ComponentRegistry.java Mon Feb 4 02:16:11 2013 @@ -69,11 +69,11 @@ public class ComponentRegistry implement /** * The map of known components indexed by component name. The values are - * either the component names (for name reservations) or implementations + * either null (for name reservations) or implementations * of the {@link ComponentHolder} interface. *

* The {@link #checkComponentName(String)} will first add an entry to this - * map being the name of the component to reserve the name. After setting up + * map with null value to reserve the name. After setting up * the component, the {@link #registerComponentHolder(String, ComponentHolder)} * method replaces the value of the named entry with the actual * {@link ComponentHolder}. @@ -111,7 +111,7 @@ public class ComponentRegistry implement * @see #registerComponentId(AbstractComponentManager) * @see #unregisterComponentId(long) */ - private final Map m_componentsById; + private final Map> m_componentsById; /** * Counter to setup the component IDs as issued by the @@ -135,9 +135,9 @@ public class ComponentRegistry implement protected ComponentRegistry( BundleContext context ) { m_bundleContext = context; - m_componentHoldersByName = new HashMap /* */ (); - m_componentHoldersByPid = new HashMap(); - m_componentsById = new HashMap(); + m_componentHoldersByName = new HashMap(); + m_componentHoldersByPid = new HashMap>(); + m_componentsById = new HashMap>(); m_componentCounter = -1; // keep me informed on ConfigurationAdmin state changes @@ -188,16 +188,16 @@ public class ComponentRegistry implement public Component[] getComponents() { - Object[] holders = getComponentHolders(); - ArrayList list = new ArrayList(); - for ( int i = 0; i < holders.length; i++ ) + ComponentHolder[] holders = getComponentHolders(); + ArrayList list = new ArrayList(); + for ( ComponentHolder holder: holders ) { - if ( holders[i] instanceof ComponentHolder ) + if ( holders != null ) { - Component[] components = ( ( ComponentHolder ) holders[i] ).getComponents(); - for ( int j = 0; j < components.length; j++ ) + Component[] components = holder.getComponents(); + for ( Component component: components ) { - list.add( components[j] ); + list.add( component ); } } } @@ -214,20 +214,19 @@ public class ComponentRegistry implement public Component[] getComponents( Bundle bundle ) { - Object[] holders = getComponentHolders(); - ArrayList list = new ArrayList(); - for ( int i = 0; i < holders.length; i++ ) + ComponentHolder[] holders = getComponentHolders(); + ArrayList list = new ArrayList(); + for ( ComponentHolder holder: holders ) { - if ( holders[i] instanceof ComponentHolder ) + if ( holder != null ) { - ComponentHolder holder = ( ComponentHolder ) holders[i]; BundleComponentActivator activator = holder.getActivator(); if ( activator != null && activator.getBundleContext().getBundle() == bundle ) { Component[] components = holder.getComponents(); - for ( int j = 0; j < components.length; j++ ) + for ( Component component: components ) { - list.add( components[j] ); + list.add( component ); } } } @@ -239,7 +238,7 @@ public class ComponentRegistry implement return null; } - return ( Component[] ) list.toArray( new Component[list.size()] ); + return list.toArray( new Component[list.size()] ); } @@ -247,27 +246,26 @@ public class ComponentRegistry implement { synchronized ( m_componentsById ) { - return ( Component ) m_componentsById.get( new Long( componentId ) ); + return m_componentsById.get( new Long( componentId ) ); } } public Component[] getComponents( String componentName ) { - List /* */(); + List list = new ArrayList(); synchronized ( m_componentHoldersByName ) { - for ( Iterator ci = m_componentHoldersByName.values().iterator(); ci.hasNext(); ) + for ( ComponentHolder c: m_componentHoldersByName.values() ) { - ComponentHolder c = ( ComponentHolder ) ci.next(); - if ( componentName.equals( c.getComponentMetadata().getName() ) ) + if ( c.getComponentMetadata().getName().equals( componentName ) ) { - list.addAll( Arrays.asList( c.getComponents() ) ); + list.addAll( Arrays.asList( c.getComponents() ) ); } } } - return ( list.isEmpty() ) ? null : ( Component[] ) list.toArray( new Component[list.size()] ); + return ( list.isEmpty() ) ? null : list.toArray( new Component[list.size()] ); } @@ -282,7 +280,7 @@ public class ComponentRegistry implement * * @return the assigned component ID */ - final long registerComponentId( final AbstractComponentManager componentManager ) + final long registerComponentId( final AbstractComponentManager componentManager ) { long componentId; synchronized ( m_componentsById ) @@ -309,7 +307,7 @@ public class ComponentRegistry implement { synchronized ( m_componentsById ) { - m_componentsById.remove( new Long( componentId ) ); + m_componentsById.remove( componentId ); } } @@ -534,7 +532,7 @@ public class ComponentRegistry implement if (metadata.isFactory()) { // 112.2.4 SCR must register a Component Factory - // service on behalf ot the component + // service on behalf of the component // as soon as the component factory is satisfied if ( !activator.getConfiguration().isFactoryEnabled() ) { @@ -683,7 +681,7 @@ public class ComponentRegistry implement } } - public synchronized void registerMissingDependency( DependencyManager dependencyManager, ServiceReference serviceReference, int trackingCount ) + public synchronized void registerMissingDependency( DependencyManager dependencyManager, ServiceReference serviceReference, int trackingCount ) { //check that the service reference is from scr if ( serviceReference.getProperty( ComponentConstants.COMPONENT_NAME ) == null || serviceReference.getProperty( ComponentConstants.COMPONENT_ID ) == null ) @@ -701,16 +699,16 @@ public class ComponentRegistry implement private static class Entry { - private final DependencyManager dm; + private final DependencyManager dm; private final int trackingCount; - private Entry( DependencyManager dm, int trackingCount ) + private Entry( DependencyManager dm, int trackingCount ) { this.dm = dm; this.trackingCount = trackingCount; } - public DependencyManager getDm() + public DependencyManager getDm() { return dm; } 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=1442007&r1=1442006&r2=1442007&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 Mon Feb 4 02:16:11 2013 @@ -20,21 +20,26 @@ package org.apache.felix.scr.impl; import java.io.PrintStream; import java.lang.reflect.Constructor; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; +import java.util.Comparator; import java.util.Dictionary; import java.util.Hashtable; import java.util.Iterator; import java.util.TreeSet; +import java.util.regex.Pattern; import org.apache.felix.scr.Component; import org.apache.felix.scr.Reference; +import org.apache.felix.scr.ScrInfo; import org.apache.felix.scr.ScrService; import org.apache.felix.scr.impl.config.ScrConfiguration; import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; import org.osgi.framework.Constants; import org.osgi.framework.ServiceReference; +import org.osgi.framework.ServiceRegistration; /** * The ScrCommand class provides the implementations for the @@ -42,14 +47,16 @@ import org.osgi.framework.ServiceReferen * {@link #register(BundleContext, ScrService, ScrConfiguration)} method * instantiates and registers the Gogo and Shell commands as possible. */ -class ScrCommand +public class ScrCommand implements ScrInfo { private final BundleContext bundleContext; private final ScrService scrService; private final ScrConfiguration scrConfiguration; + + private ServiceRegistration reg; - static void register(BundleContext bundleContext, ScrService scrService, ScrConfiguration scrConfiguration) + static ScrCommand register(BundleContext bundleContext, ScrService scrService, ScrConfiguration scrConfiguration) { final ScrCommand cmd = new ScrCommand(bundleContext, scrService, scrConfiguration); @@ -99,6 +106,7 @@ class ScrCommand { // Ignore. } + return cmd; } private ScrCommand(BundleContext bundleContext, ScrService scrService, ScrConfiguration scrConfiguration) @@ -110,7 +118,33 @@ class ScrCommand // ---------- Actual implementation - void list(final String bundleIdentifier, final PrintStream out, final PrintStream err) + + public void update( boolean infoAsService ) + { + if (infoAsService) + { + if ( reg == null ) + { + final Hashtable props = new Hashtable(); + 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) + */ + public void list(final String bundleIdentifier, final PrintStream out, final PrintStream err) { Component[] components; @@ -166,20 +200,27 @@ class ScrCommand } } - out.println(" Id State Name"); + Arrays.sort( components, new Comparator() + { + + public int compare(Component c1, Component c2) + { + return Long.signum(c1.getId() - c2.getId()); + } + + }); + + out.println(" Id State BundleId Name"); for ( Component component : components ) { - out.print( '[' ); - out.print( pad( String.valueOf( component.getId() ), -4 ) ); - out.print( "] [" ); - out.print( pad( toStateString( component.getState() ), 13 ) ); - out.print( "] " ); - out.print( component.getName() ); - out.println(); + out.println( String.format( "[%1$4d] [%2$s] [%3$4d] %4$s", component.getId(), toStateString( component.getState() ), component.getBundle().getBundleId(), component.getName() ) ); } } - void info(final String componentId, PrintStream out, PrintStream err) + /* (non-Javadoc) + * @see org.apache.felix.scr.impl.ScrInfo#info(java.lang.String, java.io.PrintStream, java.io.PrintStream) + */ + public void info(final String componentId, PrintStream out, PrintStream err) { Component[] components = getComponentFromArg(componentId, err); if (components == null) @@ -187,8 +228,40 @@ class ScrCommand return; } + Arrays.sort( components, new Comparator() + { + + public int compare(Component c1, Component c2) + { + long bundleId1 = c1.getBundle().getBundleId(); + long bundleId2 = c2.getBundle().getBundleId(); + int result = Long.signum(bundleId1 - bundleId2); + if (result == 0) { + result = Long.signum(c1.getId() - c2.getId()); + } + return result; + } + + }); + + long bundleId = -1; + for ( Component component : components ) { + if (components.length > 1) + { + if ( component.getBundle().getBundleId() != bundleId ) + { + if ( bundleId != -1 ) + { + out.println(); + out.println(); + } + bundleId = component.getBundle().getBundleId(); + out.println(String.format("*** Bundle: %1$s (%2$d)", component.getBundle().getSymbolicName(), bundleId)); + } + out.println(); + } out.print( "ID: " ); out.println( component.getId() ); out.print( "Name: " ); @@ -292,6 +365,10 @@ class ScrCommand out.println( serviceRefs[k] ); } } + else + { + out.println( " (unbound)" ); + } } } @@ -360,7 +437,10 @@ class ScrCommand } } - void config(PrintStream out) + /* (non-Javadoc) + * @see org.apache.felix.scr.impl.ScrInfo#config(java.io.PrintStream) + */ + public void config(PrintStream out) { out.print("Log Level: "); out.println(scrConfiguration.getLogLevel()); @@ -368,58 +448,36 @@ class ScrCommand out.println(scrConfiguration.isFactoryEnabled() ? "Supported" : "Unsupported"); } - private String pad(String value, int size) - { - boolean right = size < 0; - size = right ? -size : size; - - if (value.length() >= size) - { - return value; - } - - char[] buf = new char[size]; - int padLen = size - value.length(); - int valOff = right ? padLen : 0; - int padOff = right ? 0 : value.length(); - - value.getChars(0, value.length(), buf, valOff); - Arrays.fill(buf, padOff, padOff + padLen, ' '); - - return new String(buf); - } - private String toStateString(int state) { - switch (state) - { - case Component.STATE_DISABLED: - return "disabled"; - case Component.STATE_UNSATISFIED: - return "unsatisfied"; - case Component.STATE_ACTIVE: - return "active"; - case Component.STATE_REGISTERED: - return "registered"; - case Component.STATE_FACTORY: - return "factory"; - case Component.STATE_DISPOSED: - return "disposed"; - - case Component.STATE_ENABLING: - return "enabling"; - case Component.STATE_ENABLED: - return "enabled"; - case Component.STATE_ACTIVATING: - return "activating"; - case Component.STATE_DEACTIVATING: - return "deactivating"; - case Component.STATE_DISABLING: - return "disabling"; - case Component.STATE_DISPOSING: - return "disposing"; - default: - return String.valueOf(state); + switch (state) { + + case (Component.STATE_DISABLED): + return "disabled "; + case (Component.STATE_ENABLING): + return "enabling "; + case (Component.STATE_ENABLED): + return "enabled "; + case (Component.STATE_UNSATISFIED): + return "unsatisfied "; + case (Component.STATE_ACTIVATING): + return "activating "; + case (Component.STATE_ACTIVE): + return "active "; + case (Component.STATE_REGISTERED): + return "registered "; + case (Component.STATE_FACTORY): + return "factory "; + case (Component.STATE_DEACTIVATING): + return "deactivating"; + case (Component.STATE_DISABLING): + return "disabling "; + case (Component.STATE_DISPOSING): + return "disposing "; + case (Component.STATE_DISPOSED): + return "disposed "; + default: + return "unkown: " + state; } } @@ -438,12 +496,13 @@ class ScrCommand } else { - components = new Component[] + return new Component[] { component }; } } catch (NumberFormatException nfe) { + // check whether it is a component name components = scrService.getComponents(componentIdentifier); if (components == null) @@ -452,10 +511,22 @@ class ScrCommand } } } - else + if ( components == null) { - - err.println("Component ID required"); + components = scrService.getComponents(); + if (componentIdentifier != null) + { + ArrayList cs = new ArrayList(components.length); + Pattern p = Pattern.compile(componentIdentifier); + for (Component component: components) + { + if ( p.matcher( component.getName()).matches() ) + { + cs.add( component ); + } + } + components = cs.toArray( new Component[cs.size()] ); + } } return components; 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=1442007&r1=1442006&r2=1442007&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 Mon Feb 4 02:16:11 2013 @@ -22,6 +22,7 @@ package org.apache.felix.scr.impl.config import java.util.Dictionary; import java.util.Hashtable; +import org.apache.felix.scr.impl.ScrCommand; import org.osgi.framework.BundleContext; import org.osgi.framework.Constants; import org.osgi.framework.ServiceRegistration; @@ -61,6 +62,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_LOGLEVEL = "ds.loglevel"; private static final String LOG_LEVEL_DEBUG = "debug"; @@ -80,10 +83,14 @@ public class ScrConfiguration private boolean factoryEnabled; private boolean keepInstances; + + private boolean infoAsService; private BundleContext bundleContext; private ServiceRegistration managedService; + + private ScrCommand scrCommand; public ScrConfiguration( ) { @@ -114,6 +121,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 config ) @@ -125,12 +138,14 @@ public class ScrConfiguration logLevel = LogService.LOG_ERROR; factoryEnabled = false; keepInstances = false; + infoAsService = false; } else { logLevel = getDefaultLogLevel(); factoryEnabled = getDefaultFactoryEnabled(); keepInstances = getDefaultKeepInstances(); + infoAsService = getDefaultInfoAsService(); } } else @@ -138,6 +153,11 @@ 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) ) ); + } + if ( scrCommand != null ) + { + scrCommand.update( infoAsService() ); } } @@ -161,6 +181,11 @@ public class ScrConfiguration { return keepInstances; } + + public boolean infoAsService() + { + return infoAsService; + } private boolean getDefaultFactoryEnabled() @@ -179,6 +204,11 @@ public class ScrConfiguration { return getLogLevel( bundleContext.getProperty( PROP_LOGLEVEL ) ); } + + private boolean getDefaultInfoAsService() + { + return VALUE_TRUE.equalsIgnoreCase( bundleContext.getProperty( PROP_INFO_SERVICE) ); + } private int getLogLevel( final Object levelObject ) Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ScrManagedServiceMetaTypeProvider.java URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ScrManagedServiceMetaTypeProvider.java?rev=1442007&r1=1442006&r2=1442007&view=diff ============================================================================== --- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ScrManagedServiceMetaTypeProvider.java (original) +++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ScrManagedServiceMetaTypeProvider.java Mon Feb 4 02:16:11 2013 @@ -72,7 +72,7 @@ class ScrManagedServiceMetaTypeProvider return null; } - final ArrayList adList = new ArrayList(); + final ArrayList adList = new ArrayList(); adList.add(new AttributeDefinitionImpl(ScrConfiguration.PROP_LOGLEVEL, "SCR Log Level", "Allows limiting the amount of logging information sent to the OSGi LogService." @@ -93,19 +93,25 @@ class ScrManagedServiceMetaTypeProvider .getScrConfiguration().isFactoryEnabled())); adList.add( new AttributeDefinitionImpl( - ScrConfiguration.PROP_DELAYED_KEEP_INSTANCES, - "Keep Component Instances", - "Whether or not to keep instances of delayed components once they are not referred to any more. The " - + "Declarative Services specifications suggests that instances of delayed components are disposed off " - + "if there is not used any longer. Setting this flag causes the components to not be disposed off " - + "and thus prevent them from being constantly recreated if often used. Examples of such components " - + "may be EventHandler services. The default is to dispose off unused components.", this - .getScrConfiguration().keepInstances() ) ); + ScrConfiguration.PROP_DELAYED_KEEP_INSTANCES, + "Keep Component Instances", + "Whether or not to keep instances of delayed components once they are not referred to any more. The " + + "Declarative Services specifications suggests that instances of delayed components are disposed off " + + "if there is not used any longer. Setting this flag causes the components to not be disposed off " + + "and thus prevent them from being constantly recreated if often used. Examples of such components " + + "may be EventHandler services. The default is to dispose off unused components.", this + .getScrConfiguration().keepInstances() ) ); + + adList.add( new AttributeDefinitionImpl( + ScrConfiguration.PROP_INFO_SERVICE, + "Bind Info Service", + "Whether to bind a service backing the console commands providing info on components ", + this.getScrConfiguration().infoAsService() ) ); return new ObjectClassDefinition() { - private final AttributeDefinition[] attrs = (AttributeDefinition[]) adList + private final AttributeDefinition[] attrs = adList .toArray(new AttributeDefinition[adList.size()]); public String getName() Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/DependencyManager.java URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/DependencyManager.java?rev=1442007&r1=1442006&r2=1442007&view=diff ============================================================================== --- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/DependencyManager.java (original) +++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/DependencyManager.java Mon Feb 4 02:16:11 2013 @@ -1133,7 +1133,15 @@ public class DependencyManager imp return result; } - + /** + * a mistake, use getServiceReferences instead + */ + @Deprecated + public ServiceReference[] getBoundServiceReferences() + { + return getServiceReferences(); + } + /** * Returns the RefPair containing the given service reference and the bound service * or null if this is instance is not currently bound to that