FELIX-284 Add Management API
   - moved implementation and parser down into an impl package
   - defined the API in the main scr package
   - added Felix Shell Command "scr"
   - fixed exports

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@597657 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/scr/pom.xml b/scr/pom.xml
index fa7a6ff..55bb5a8 100644
--- a/scr/pom.xml
+++ b/scr/pom.xml
@@ -25,6 +25,11 @@
             <version>0.9.0-SNAPSHOT</version>
         </dependency>
         <dependency>
+            <groupId>${pom.groupId}</groupId>
+            <artifactId>org.apache.felix.shell</artifactId>
+            <version>1.0.0</version>
+        </dependency>
+        <dependency>
             <groupId>net.sf.kxml</groupId>
             <artifactId>kxml2</artifactId>
             <version>2.2.2</version>
@@ -46,16 +51,20 @@
                             Apache Software Foundation
                         </Bundle-Vendor>
                         <Bundle-Activator>
-                            org.apache.felix.scr.Activator
+                            org.apache.felix.scr.impl.Activator
                         </Bundle-Activator>
                         <Export-Package>
+                            org.apache.felix.scr;version=${pom.version},
                             org.osgi.service.cm,
                             org.osgi.service.component
                         </Export-Package>
                         <Private-Package>
-                            org.apache.felix.scr.*, org.kxml2.io,
+                            org.apache.felix.scr.impl.*, org.kxml2.io,
                             org.osgi.util.tracker, org.xmlpull.v1
                         </Private-Package>
+                        <Import-Package>
+                            org.apache.felix.shell;resolution:=optional,*
+                        </Import-Package>
                         <DynamicImport-Package>
                             org.osgi.service.log
                         </DynamicImport-Package>
diff --git a/scr/src/main/java/org/apache/felix/scr/Component.java b/scr/src/main/java/org/apache/felix/scr/Component.java
new file mode 100644
index 0000000..b32aec0
--- /dev/null
+++ b/scr/src/main/java/org/apache/felix/scr/Component.java
@@ -0,0 +1,214 @@
+/*
+ * 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.util.Dictionary;
+
+import org.osgi.framework.Bundle;
+
+
+/**
+ * The <code>Component</code> interface represents a single component managed
+ * by the Service Component Runtime. Management agents may access the Component
+ * instances through the {@link ScrService}.
+ */
+public interface Component
+{
+
+    /**
+     * The Component has just been created and is still disabled or it has
+     * been disabled by calling the {@link #disable()} method (value is 1).
+     */
+    static final int STATE_DISABLED = 1;
+
+    /**
+     * The Component has been enabled and is now going to be activated (value
+     * is 2).
+     */
+    static final int STATE_ENABLED = 2;
+
+    /**
+     * The Component activation failed because any dependency is not satisfied
+     * (value is 4).
+     */
+    static final int STATE_UNSATISFIED = 4;
+
+    /**
+     * The Component is currently being activated either because it has been
+     * enabled or because any dependency which was previously unsatisfied has
+     * become satisfied (value is 8).
+     */
+    static final int STATE_ACTIVATING = 8;
+
+    /**
+     * The Component has successfully been activated and is fully functional
+     * (value is 16). This is the state of immediate components after
+     * successfull activation. Delayed and Service Factory Components enter
+     * this state when the service instance has actually be instantiated because
+     * the service has been acquired.
+     */
+    static final int STATE_ACTIVE = 16;
+
+    /**
+     * The Component has successfully been activated but is a Delayed or Service
+     * Factory Component pending instantiation on first use (value is 32).
+     */
+    static final int STATE_REGISTERED = 32;
+
+    /**
+     * The Component is a Component Factory ready to manage Component instances
+     * from configuration data received from the Configuration Admin Service
+     * (value is 64).
+     */
+    static final int STATE_FACTORY = 64;
+
+    /**
+     * The Component is being deactivated either because it is being disabled
+     * or because a dependency is not satisfied any more (value is 128). After
+     * deactivation the Component enters the {@link #STATE_UNSATISFIED} state.
+     */
+    static final int STATE_DEACTIVATING = 128;
+
+    /**
+     * The Component has been destroyed and cannot be used any more (value is
+     * 256). This state is only used when the bundle declaring the component
+     * is being stopped and all components have to be removed.
+     */
+    static final int STATE_DESTROYED = 256;
+
+
+    /**
+     * Returns the component ID of this component. This ID is managed by the
+     * SCR.
+     */
+    long getId();
+
+
+    /**
+     * Returns the name of the component, which is also used as the service PID.
+     * This method provides access to the <code>name</code> attribute of the
+     * <code>component</code> element.
+     */
+    String getName();
+
+
+    /**
+     * Returns the current state of the Component, which is one of the
+     * <code>STATE_*</code> constants defined in this interface.
+     */
+    int getState();
+
+
+    /**
+     * Returns the <code>Bundle</code> declaring this component.
+     */
+    Bundle getBundle();
+
+
+    /**
+     * Returns the component factory name or <code>null</code> if this component
+     * is not defined as a component factory. This method provides access to
+     * the <code>factory</code> attribute of the <code>component</code>
+     * element.
+     */
+    String getFactory();
+
+
+    /**
+     * Returns <code>true</code> if this component is a service factory. This
+     * method returns the value of the <code>serviceFactory</code> attribute of
+     * the <code>service</code> element. If the component has no service
+     * element, this method returns <code>false</code>.
+     */
+    boolean isServiceFactory();
+
+
+    /**
+     * Returns the class name of the Component implementation. This method
+     * provides access to the <code>class</code> attribute of the
+     * <code>implementation</code> element.
+     */
+    String getClassName();
+
+
+    /**
+     * Returns whether the Component is declared to be enabled initially. This
+     * method provides access to the <code>enabled</code> attribute of the
+     * <code>component</code> element.
+     */
+    boolean isDefaultEnabled();
+
+
+    /**
+     * Returns whether the Component is an Immediate or a Delayed Component.
+     * This method provides access to the <code>immediate</code> attribute of
+     * the <code>component</code> element.
+     */
+    boolean isImmediate();
+
+
+    /**
+     * Returns an array of service names provided by this Component or
+     * <code>null</code> if the Component is not registered as a service. This
+     * method provides access to the <code>interface</code> attributes of the
+     * <code>provide</code> elements.
+     */
+    String[] getServices();
+
+
+    /**
+     * Returns the properties of the Component. The Dictionary returned is a
+     * private copy of the actual properties and contains the same entries as
+     * are used to register the Component as a service and are returned by
+     * the <code>ComponentContext.getProperties()</code> method.
+     */
+    Dictionary getProperties();
+
+
+    /**
+     * Returns an array of {@link Reference} instances representing the service
+     * references (or dependencies) of this Component. If the Component has no
+     * references, <code>null</code> is returned.
+     */
+    Reference[] getReferences();
+
+
+    /**
+     * Enables this Component if it is disabled. If the Component is not
+     * currently {@link #STATE_DISABLED disabled} this method has no effect. If
+     * the Component is {@link #STATE_DESTROYED destroyed}, this method throws
+     * an <code>IllegalStateException</code>.
+     *
+     * @throws IllegalStateException If the Component is destroyed.
+     */
+    void enable();
+
+
+    /**
+     * Disables this Component if it is enabled. If the Component is already
+     * {@link #STATE_DISABLED disabled} this method has no effect. If the
+     * Component is {@link #STATE_DESTROYED destroyed}, this method throws an
+     * <code>IllegalStateException</code>.
+     *
+     * @throws IllegalStateException If the Component is destroyed.
+     */
+    void disable();
+
+}
diff --git a/scr/src/main/java/org/apache/felix/scr/ComponentRegistry.java b/scr/src/main/java/org/apache/felix/scr/ComponentRegistry.java
deleted file mode 100644
index e016856..0000000
--- a/scr/src/main/java/org/apache/felix/scr/ComponentRegistry.java
+++ /dev/null
@@ -1,117 +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.felix.scr;
-
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
-import org.osgi.service.component.ComponentException;
-
-
-/**
- * The <code>ComponentRegistry</code> TODO
- *
- * @author fmeschbe
- */
-public class ComponentRegistry
-{
-
-    // Known and registered ComponentManager instances
-    private Map m_componentNames;
-
-    // component id counter
-    private long m_componentCounter;
-
-    // the service registration of the ConfigurationListener service
-    private ServiceRegistration registration;
-
-
-    ComponentRegistry( BundleContext context )
-    {
-        m_componentNames = new HashMap();
-        m_componentCounter = -1;
-    }
-
-
-    void dispose()
-    {
-        if ( registration != null )
-        {
-            registration.unregister();
-            registration = null;
-        }
-    }
-
-
-    //---------- ComponentManager registration support ------------------------
-
-    long createComponentId()
-    {
-        m_componentCounter++;
-        return m_componentCounter;
-    }
-
-
-    void checkComponentName( String name )
-    {
-        if ( m_componentNames.containsKey( name ) )
-        {
-            throw new ComponentException( "The component name '" + name + "' has already been registered." );
-        }
-
-        // reserve the name
-        m_componentNames.put( name, name );
-    }
-
-
-    void registerComponent( String name, ComponentManager component )
-    {
-        // only register the component if there is a registration for it !
-        if ( !name.equals( m_componentNames.get( name ) ) )
-        {
-            // this is not expected if all works ok
-            throw new ComponentException( "The component name '" + name + "' has already been registered." );
-        }
-
-        m_componentNames.put( name, component );
-    }
-
-
-    ComponentManager getComponent( String name )
-    {
-        Object entry = m_componentNames.get( name );
-
-        // only return the entry if non-null and not a reservation
-        if ( entry instanceof ComponentManager )
-        {
-            return ( ComponentManager ) entry;
-        }
-
-        return null;
-    }
-
-
-    void unregisterComponent( String name )
-    {
-        m_componentNames.remove( name );
-    }
-}
diff --git a/scr/src/main/java/org/apache/felix/scr/Reference.java b/scr/src/main/java/org/apache/felix/scr/Reference.java
new file mode 100644
index 0000000..599013f
--- /dev/null
+++ b/scr/src/main/java/org/apache/felix/scr/Reference.java
@@ -0,0 +1,118 @@
+/*
+ * 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 org.osgi.framework.ServiceReference;
+
+
+/**
+ * The <code>Reference</code> interface represents a single reference (or
+ * dependency) to a service used by a Component.
+ */
+public interface Reference
+{
+
+    /**
+     * Returns the name of this Reference. This method provides access to the
+     * <code>name</code> attribute of the <code>referenec</code> element.
+     */
+    String getName();
+
+
+    /**
+     * Returns the name of the service used by this Reference. This method
+     * provides access to the <code>interface</code> attribute of the
+     * <code>reference</code> element.
+     */
+    String getServiceName();
+
+
+    /**
+     * Returns an array of references to the services bound to this Reference
+     * or <code>null</code> if no services are currently bound.
+     */
+    ServiceReference[] getServiceReferences();
+
+
+    /**
+     * Returns whether this reference is satisified. A {@link #isOptional() optional}
+     * component is always satsified. Otherwise <code>true</code> is only
+     * returned if at least one service is bound.
+     */
+    boolean isSatisfied();
+
+
+    /**
+     * Returns whether this reference is optional. This method provides access
+     * to the lower bound of the <code>cardinality</code> attribute of the
+     * <code>reference</code> element. In other words, this method returns
+     * <code>true</code> if the cardinality is <em>0..1</em> or <em>0..n</em>.
+     */
+    boolean isOptional();
+
+
+    /**
+     * Returns whether this reference is multiple. This method provides access
+     * to the upper bound of the <code>cardinality</code> attribute of the
+     * <code>reference</code> element. In other words, this method returns
+     * <code>true</code> if the cardinality is <em>0..n</em> or <em>1..n</em>.
+     */
+    boolean isMultiple();
+
+
+    /**
+     * Returns <code>true</code> if the reference is defined with static policy.
+     * This method provides access to the <code>policy</code> element of the
+     * <code>reference</code> element. <code>true</code> is returned if the
+     * policy is defined as <em>static</em>.
+     */
+    boolean isStatic();
+
+
+    /**
+     * Returns the value of the target property of this reference. Initially
+     * (without overwriting configuration) this method provides access to the
+     * <code>target</code> attribute of the <code>reference</code> element. If
+     * configuration overwrites the target property, this method returns the
+     * value of the Component property whose name is derived from the
+     * {@link #getName() reference name} plus the suffix <em>.target</em>. If
+     * no target property exists this method returns <code>null</code>.
+     */
+    String getTarget();
+
+
+    /**
+     * Returns the name of the method called if a service is being bound to
+     * the Component or <code>null</code> if no such method is configued. This
+     * method provides access to the <code>bind</code> attribute of the
+     * <code>reference</code> element.
+     */
+    String getBindMethodName();
+
+
+    /**
+     * Returns the name of the method called if a service is being unbound from
+     * the Component or <code>null</code> if no such method is configued. This
+     * method provides access to the <code>unbind</code> attribute of the
+     * <code>reference</code> element.
+     */
+    String getUnbindMethodName();
+
+}
diff --git a/scr/src/main/java/org/apache/felix/scr/ScrService.java b/scr/src/main/java/org/apache/felix/scr/ScrService.java
new file mode 100644
index 0000000..1605e55
--- /dev/null
+++ b/scr/src/main/java/org/apache/felix/scr/ScrService.java
@@ -0,0 +1,71 @@
+/*
+ * 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 org.osgi.framework.Bundle;
+
+
+/**
+ * The <code>ScrService</code> represents the Declarative Services main
+ * controller also known as the Service Component Runtime or SCR for short.
+ * It provides access to the components managed the SCR.
+ */
+public interface ScrService
+{
+
+    /**
+     * Returns an array of all components managed by this SCR instance. The
+     * components are returned in ascending order of their component.id. If
+     * there are no components currently managed by the SCR, <code>null</code>
+     * is returned.
+     *
+     * @return The components or <code>null</code> if there are none.
+     */
+    Component[] getComponents();
+
+
+    /**
+     * Returns the component whose component.id matches the given
+     * <code>componentId</code> or <code>null</code> if no component with the
+     * given id is currently managed.
+     *
+     * @param componentId The ID of the component to return
+     *
+     * @return The indicated component or <code>null</code> if no such
+     *      component exists.
+     */
+    Component getComponent( long componentId );
+
+
+    /**
+     * Reuturns an array of all components managed by this SCR instance on
+     * behalf of the given bundle. The components are returned in ascending
+     * order of their component.id. If there are no components managed by the
+     * SCR for the given bundle, <code>null</code> is returned.
+     *
+     * @param bundle The <code>Bundle</code> whose components are to be
+     *      returned.
+     *
+     * @return The bundle's components or <code>null</code> if the bundle
+     *      has none.
+     */
+    Component[] getComponents( Bundle bundle );
+
+}
diff --git a/scr/src/main/java/org/apache/felix/scr/AbstractComponentManager.java b/scr/src/main/java/org/apache/felix/scr/impl/AbstractComponentManager.java
similarity index 92%
rename from scr/src/main/java/org/apache/felix/scr/AbstractComponentManager.java
rename to scr/src/main/java/org/apache/felix/scr/impl/AbstractComponentManager.java
index 2af4f95..7a35b35 100644
--- a/scr/src/main/java/org/apache/felix/scr/AbstractComponentManager.java
+++ b/scr/src/main/java/org/apache/felix/scr/impl/AbstractComponentManager.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.felix.scr;
+package org.apache.felix.scr.impl;
 
 
 import java.lang.reflect.InvocationTargetException;
@@ -29,6 +29,8 @@
 import java.util.Iterator;
 import java.util.List;
 
+import org.apache.felix.scr.Reference;
+import org.osgi.framework.Bundle;
 import org.osgi.framework.ServiceReference;
 import org.osgi.framework.ServiceRegistration;
 import org.osgi.service.component.ComponentInstance;
@@ -42,32 +44,8 @@
  */
 abstract class AbstractComponentManager implements ComponentManager, ComponentInstance
 {
-    // manager has been newly created or disabled
-    static final int STATE_DISABLED = 1;
-
-    // manager has just been enabled and is going to be activated
-    static final int STATE_ENABLED = 2;
-
-    // manager has been enabled but not satisfied
-    static final int STATE_UNSATISFIED = 4;
-
-    // manager is currently activating
-    static final int STATE_ACTIVATING = 8;
-
-    // manager is now active
-    static final int STATE_ACTIVE = 16;
-
-    // manager for a delayed component has been registered (not active yet)
-    static final int STATE_REGISTERED = 32;
-
-    // manager for a component factory has been registered
-    static final int STATE_FACTORY = 64;
-
-    // manager is current deactivating
-    static final int STATE_DEACTIVATING = 128;
-
-    // manager has been destroyed and may not be used anymore
-    static final int STATE_DESTROYED = 256;
+    // the ID of this component
+    private long m_componentId;
 
     // The state of this instance manager
     private int m_state;
@@ -91,10 +69,11 @@
      * @param activator
      * @param metadata
      */
-    protected AbstractComponentManager( BundleComponentActivator activator, ComponentMetadata metadata )
+    protected AbstractComponentManager( BundleComponentActivator activator, ComponentMetadata metadata, long componentId )
     {
         m_activator = activator;
         m_componentMetadata = metadata;
+        m_componentId = componentId;
 
         m_state = STATE_DISABLED;
         m_dependencyManagers = new ArrayList();
@@ -228,6 +207,80 @@
     }
 
 
+    //---------- Component interface ------------------------------------------
+
+    public long getId()
+    {
+        return m_componentId;
+    }
+
+
+    public String getName()
+    {
+        return m_componentMetadata.getName();
+    }
+
+
+    public Bundle getBundle()
+    {
+        return getActivator().getBundleContext().getBundle();
+    }
+
+
+    public String getClassName()
+    {
+        return m_componentMetadata.getImplementationClassName();
+    }
+
+
+    public String getFactory()
+    {
+        return m_componentMetadata.getFactoryIdentifier();
+    }
+
+
+    public Reference[] getReferences()
+    {
+        if ( m_dependencyManagers != null && m_dependencyManagers.size() > 0 )
+        {
+            return (org.apache.felix.scr.Reference[] ) m_dependencyManagers.toArray( new Reference[m_dependencyManagers.size()] );
+        }
+
+        return null;
+    }
+
+
+    public boolean isImmediate()
+    {
+        return m_componentMetadata.isImmediate();
+
+    }
+
+
+    public boolean isDefaultEnabled()
+    {
+        return m_componentMetadata.isEnabled();
+    }
+
+
+    public boolean isServiceFactory()
+    {
+        return m_componentMetadata.getServiceMetadata() != null
+            && m_componentMetadata.getServiceMetadata().isServiceFactory();
+    }
+
+
+    public String[] getServices()
+    {
+        if ( m_componentMetadata.getServiceMetadata() != null )
+        {
+            return m_componentMetadata.getServiceMetadata().getProvides();
+        }
+
+        return null;
+    }
+
+
     //---------- internal immediate state change methods ----------------------
     // these methods must only be called from a separate thread by calling
     // the respective asynchronous (public) method
@@ -302,7 +355,8 @@
      */
     private void activateInternal()
     {
-        synchronized (this) {
+        synchronized ( this )
+        {
             // CONCURRENCY NOTE: This method is only called from within the
             //     ComponentActorThread to enable, activate or reactivate the
             //     component. Still we use the setStateConditional to not create
@@ -345,7 +399,7 @@
 
                 // if at least one dependency is missing, we cannot continue and
                 // have to return
-                if (getState() == STATE_UNSATISFIED)
+                if ( getState() == STATE_UNSATISFIED )
                 {
                     return;
                 }
@@ -624,7 +678,7 @@
     public abstract Object getInstance();
 
 
-    protected abstract Dictionary getProperties();
+    public abstract Dictionary getProperties();
 
 
     /**
@@ -676,7 +730,7 @@
     }
 
 
-    int getState()
+    public int getState()
     {
         return m_state;
     }
diff --git a/scr/src/main/java/org/apache/felix/scr/Activator.java b/scr/src/main/java/org/apache/felix/scr/impl/Activator.java
similarity index 95%
rename from scr/src/main/java/org/apache/felix/scr/Activator.java
rename to scr/src/main/java/org/apache/felix/scr/impl/Activator.java
index 22becf7..79e1f6c 100644
--- a/scr/src/main/java/org/apache/felix/scr/Activator.java
+++ b/scr/src/main/java/org/apache/felix/scr/impl/Activator.java
@@ -1,4 +1,4 @@
-/* 
+/*
  * 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
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.felix.scr;
+package org.apache.felix.scr.impl;
 
 
 import java.io.PrintStream;
@@ -39,7 +39,7 @@
 /**
  * This activator is used to cover requirement described in section 112.8.1 @@ -27,14
  * 37,202 @@ in active bundles.
- * 
+ *
  */
 public class Activator implements BundleActivator, SynchronousBundleListener
 {
@@ -69,7 +69,7 @@
     /**
      * Registers this instance as a (synchronous) bundle listener and loads the
      * components of already registered bundles.
-     * 
+     *
      * @param context The <code>BundleContext</code> of the SCR implementation
      *      bundle.
      */
@@ -91,7 +91,7 @@
                 + context.getBundle().getHeaders().get( Constants.BUNDLE_VERSION ), null );
         }
 
-        // create and start the component actor 
+        // create and start the component actor
         m_componentActor = new ComponentActorThread();
         m_componentActor.start();
 
@@ -100,6 +100,21 @@
 
         // 112.8.2 load all components of active bundles
         loadAllComponents( context );
+
+        // We dynamically import the impl service API, so it
+        // might not actually be available, so be ready to catch
+        // the exception when we try to register the command service.
+        try
+        {
+            // Register "scr" impl command service as a
+            // wrapper for the bundle repository service.
+            context.registerService( org.apache.felix.shell.Command.class.getName(), new ScrCommand( m_context,
+                m_componentRegistry ), null );
+        }
+        catch ( Throwable th )
+        {
+            // Ignore.
+        }
     }
 
 
@@ -107,7 +122,7 @@
      * Unregisters this instance as a bundle listener and unloads all components
      * which have been registered during the active life time of the SCR
      * implementation bundle.
-     * 
+     *
      * @param context The <code>BundleContext</code> of the SCR implementation
      *      bundle.
      */
@@ -147,7 +162,7 @@
      * Loads and unloads any components provided by the bundle whose state
      * changed. If the bundle has been started, the components are loaded. If
      * the bundle is about to stop, the components are unloaded.
-     * 
+     *
      * @param event The <code>BundleEvent</code> representing the bundle state
      *      change.
      */
@@ -270,9 +285,9 @@
      * This method assumes a <code>getContext</code> method returning a
      * <code>BundleContext</code> instance to be present in the class of the
      * bundle or any of its parent classes.
-     * 
+     *
      * @param bundle The <code>Bundle</code> whose context is to be returned.
-     * 
+     *
      * @return The <code>BundleContext</code> of the bundle or
      *         <code>null</code> if no <code>getContext</code> method
      *         returning a <code>BundleContext</code> can be found.
@@ -391,7 +406,7 @@
      * Method to actually emit the log message. If the LogService is available,
      * the message will be logged through the LogService. Otherwise the message
      * is logged to stdout (or stderr in case of LOG_ERROR level messages),
-     * 
+     *
      * @param level The log level to log the message at
      * @param message The message to log
      * @param ex An optional <code>Throwable</code> whose stack trace is written,
diff --git a/scr/src/main/java/org/apache/felix/scr/BundleComponentActivator.java b/scr/src/main/java/org/apache/felix/scr/impl/BundleComponentActivator.java
similarity index 98%
rename from scr/src/main/java/org/apache/felix/scr/BundleComponentActivator.java
rename to scr/src/main/java/org/apache/felix/scr/impl/BundleComponentActivator.java
index 4fb57c8..bc0fc6d 100644
--- a/scr/src/main/java/org/apache/felix/scr/BundleComponentActivator.java
+++ b/scr/src/main/java/org/apache/felix/scr/impl/BundleComponentActivator.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.felix.scr;
+package org.apache.felix.scr.impl;
 
 
 import java.io.BufferedReader;
@@ -29,7 +29,7 @@
 import java.util.List;
 import java.util.StringTokenizer;
 
-import org.apache.felix.scr.parser.KXml2SAXParser;
+import org.apache.felix.scr.impl.parser.KXml2SAXParser;
 import org.osgi.framework.BundleContext;
 import org.osgi.service.cm.ConfigurationAdmin;
 import org.osgi.service.component.ComponentException;
@@ -414,7 +414,7 @@
         // if all components are selected
         if ( name == null )
         {
-            return ( ComponentManager[] ) m_managers.toArray( new ComponentManager[m_managers.size()] );
+            return (org.apache.felix.scr.impl.ComponentManager[] ) m_managers.toArray( new ComponentManager[m_managers.size()] );
         }
 
         if ( m_componentRegistry.getComponent( name ) != null )
diff --git a/scr/src/main/java/org/apache/felix/scr/ComponentActorThread.java b/scr/src/main/java/org/apache/felix/scr/impl/ComponentActorThread.java
similarity index 98%
rename from scr/src/main/java/org/apache/felix/scr/ComponentActorThread.java
rename to scr/src/main/java/org/apache/felix/scr/impl/ComponentActorThread.java
index 5c7a4d9..8a075cd 100644
--- a/scr/src/main/java/org/apache/felix/scr/ComponentActorThread.java
+++ b/scr/src/main/java/org/apache/felix/scr/impl/ComponentActorThread.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.felix.scr;
+package org.apache.felix.scr.impl;
 
 
 import java.util.LinkedList;
diff --git a/scr/src/main/java/org/apache/felix/scr/ComponentContextImpl.java b/scr/src/main/java/org/apache/felix/scr/impl/ComponentContextImpl.java
similarity index 97%
rename from scr/src/main/java/org/apache/felix/scr/ComponentContextImpl.java
rename to scr/src/main/java/org/apache/felix/scr/impl/ComponentContextImpl.java
index e2a022c..4c11191 100644
--- a/scr/src/main/java/org/apache/felix/scr/ComponentContextImpl.java
+++ b/scr/src/main/java/org/apache/felix/scr/impl/ComponentContextImpl.java
@@ -1,4 +1,4 @@
-/* 
+/*
  * 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
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.felix.scr;
+package org.apache.felix.scr.impl;
 
 
 import java.util.Dictionary;
@@ -44,7 +44,7 @@
         m_componentManager = componentManager;
     }
 
-    
+
     protected AbstractComponentManager getComponentManager()
     {
         return m_componentManager;
@@ -73,12 +73,12 @@
         }
         else
         {
-            // is it correct to assume an ordered bound services set ? 
+            // is it correct to assume an ordered bound services set ?
             int maxRanking = Integer.MIN_VALUE;
             long minId = Long.MAX_VALUE;
             selectedRef = null;
 
-            ServiceReference[] refs = dm.getServiceReferences();
+            ServiceReference[] refs = dm.getFrameworkServiceReferences();
             for ( int i = 0; refs != null && i < refs.length; i++ )
             {
                 ServiceReference ref = refs[i];
diff --git a/scr/src/main/java/org/apache/felix/scr/ComponentFactoryImpl.java b/scr/src/main/java/org/apache/felix/scr/impl/ComponentFactoryImpl.java
similarity index 97%
rename from scr/src/main/java/org/apache/felix/scr/ComponentFactoryImpl.java
rename to scr/src/main/java/org/apache/felix/scr/impl/ComponentFactoryImpl.java
index 50dd172..803a245 100644
--- a/scr/src/main/java/org/apache/felix/scr/ComponentFactoryImpl.java
+++ b/scr/src/main/java/org/apache/felix/scr/impl/ComponentFactoryImpl.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.felix.scr;
+package org.apache.felix.scr.impl;
 
 
 import java.util.Dictionary;
@@ -25,6 +25,7 @@
 import java.util.IdentityHashMap;
 import java.util.Map;
 
+import org.apache.felix.scr.Reference;
 import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceRegistration;
 import org.osgi.service.cm.ManagedServiceFactory;
@@ -58,7 +59,7 @@
     ComponentFactoryImpl( BundleComponentActivator activator, ComponentMetadata metadata,
         ComponentRegistry componentRegistry )
     {
-        super( activator, metadata );
+        super( activator, metadata, componentRegistry.createComponentId() );
         m_componentRegistry = componentRegistry;
         m_createdComponents = new IdentityHashMap();
     }
@@ -104,7 +105,7 @@
     }
 
 
-    protected Dictionary getProperties()
+    public Dictionary getProperties()
     {
         Dictionary props = new Hashtable();
 
@@ -132,6 +133,7 @@
 
     //---------- ManagedServiceFactory interface ------------------------------
 
+
     public void updated( String pid, Dictionary configuration )
     {
         ComponentManager cm;
diff --git a/scr/src/main/java/org/apache/felix/scr/ComponentManager.java b/scr/src/main/java/org/apache/felix/scr/impl/ComponentManager.java
similarity index 92%
rename from scr/src/main/java/org/apache/felix/scr/ComponentManager.java
rename to scr/src/main/java/org/apache/felix/scr/impl/ComponentManager.java
index 3a7a23ad..a71b58e 100644
--- a/scr/src/main/java/org/apache/felix/scr/ComponentManager.java
+++ b/scr/src/main/java/org/apache/felix/scr/impl/ComponentManager.java
@@ -16,7 +16,9 @@
  * specific language governing permissions and limitations

  * under the License.

  */

-package org.apache.felix.scr;

+package org.apache.felix.scr.impl;

+

+import org.apache.felix.scr.Component;

 

 

 /**

@@ -24,7 +26,7 @@
  * managers that are responsible for managing component's lifecycle.

  *

  */

-public interface ComponentManager {

+public interface ComponentManager extends Component {

 

 	/**

 	 * Enable the component

diff --git a/scr/src/main/java/org/apache/felix/scr/ComponentMetadata.java b/scr/src/main/java/org/apache/felix/scr/impl/ComponentMetadata.java
similarity index 99%
rename from scr/src/main/java/org/apache/felix/scr/ComponentMetadata.java
rename to scr/src/main/java/org/apache/felix/scr/impl/ComponentMetadata.java
index 3fe3e4d..07613e7 100644
--- a/scr/src/main/java/org/apache/felix/scr/ComponentMetadata.java
+++ b/scr/src/main/java/org/apache/felix/scr/impl/ComponentMetadata.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.felix.scr;
+package org.apache.felix.scr.impl;
 
 import java.util.ArrayList;
 import java.util.Dictionary;
diff --git a/scr/src/main/java/org/apache/felix/scr/impl/ComponentRegistry.java b/scr/src/main/java/org/apache/felix/scr/impl/ComponentRegistry.java
new file mode 100644
index 0000000..130f348
--- /dev/null
+++ b/scr/src/main/java/org/apache/felix/scr/impl/ComponentRegistry.java
@@ -0,0 +1,186 @@
+/*
+ * 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.impl;
+
+
+import java.util.ArrayList;
+import java.util.Dictionary;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.felix.scr.Component;
+import org.apache.felix.scr.ScrService;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.component.ComponentException;
+
+
+/**
+ * The <code>ComponentRegistry</code> TODO
+ *
+ * @author fmeschbe
+ */
+public class ComponentRegistry implements ScrService
+{
+
+    // Known and registered ComponentManager instances
+    private Map m_componentsByName;
+
+    // components registered by their component ID
+    private Map m_componentsById;
+
+    // component id counter
+    private long m_componentCounter;
+
+    // the service m_registration of the ConfigurationListener service
+    private ServiceRegistration m_registration;
+
+
+    ComponentRegistry( BundleContext context )
+    {
+        m_componentsByName = new HashMap();
+        m_componentsById = new HashMap();
+        m_componentCounter = -1;
+
+        // register as ScrService
+        Dictionary props = new Hashtable();
+        props.put( Constants.SERVICE_DESCRIPTION, "Declarative Services Management Agent" );
+        props.put( Constants.SERVICE_VENDOR, "The Apache Software Foundation" );
+        m_registration = context.registerService( ScrService.class.getName(), this, props );
+    }
+
+
+    void dispose()
+    {
+        if ( m_registration != null )
+        {
+            m_registration.unregister();
+            m_registration = null;
+        }
+    }
+
+
+    //---------- ScrService interface -----------------------------------------
+
+
+    public Component[] getComponents()
+    {
+        if (m_componentsById.isEmpty()) {
+            return null;
+        }
+
+        return (org.apache.felix.scr.Component[] ) m_componentsById.values().toArray( new Component[m_componentsById.size()] );
+    }
+
+    public Component[] getComponents( Bundle bundle )
+    {
+        Component[] all = getComponents();
+        if (all == null || all.length == 0) {
+            return null;
+        }
+
+        // compare the bundle by its id
+        long bundleId = bundle.getBundleId();
+
+        // scan the components for the the desired components
+        List perBundle = new ArrayList();
+        for (int i=0; i < all.length; i++) {
+            if (all[i].getBundle().getBundleId() == bundleId) {
+                perBundle.add( all[i] );
+            }
+        }
+
+        // nothing to return
+        if (perBundle.isEmpty()) {
+            return null;
+        }
+
+        return (org.apache.felix.scr.Component[] ) perBundle.toArray( new Component[perBundle.size()] );
+    }
+
+
+    public Component getComponent( long componentId )
+    {
+        return (Component) m_componentsById.get(new Long(componentId));
+    }
+
+
+    //---------- ComponentManager m_registration support ------------------------
+
+    long createComponentId()
+    {
+        m_componentCounter++;
+        return m_componentCounter;
+    }
+
+
+    void checkComponentName( String name )
+    {
+        if ( m_componentsByName.containsKey( name ) )
+        {
+            throw new ComponentException( "The component name '" + name + "' has already been registered." );
+        }
+
+        // reserve the name
+        m_componentsByName.put( name, name );
+    }
+
+
+    void registerComponent( String name, ComponentManager component )
+    {
+        // only register the component if there is a m_registration for it !
+        if ( !name.equals( m_componentsByName.get( name ) ) )
+        {
+            // this is not expected if all works ok
+            throw new ComponentException( "The component name '" + name + "' has already been registered." );
+        }
+
+        m_componentsByName.put( name, component );
+        m_componentsById.put( new Long(component.getId()), component );
+    }
+
+
+    ComponentManager getComponent( String name )
+    {
+        Object entry = m_componentsByName.get( name );
+
+        // only return the entry if non-null and not a reservation
+        if ( entry instanceof ComponentManager )
+        {
+            return ( ComponentManager ) entry;
+        }
+
+        return null;
+    }
+
+
+    void unregisterComponent( String name )
+    {
+        Object entry = m_componentsByName.remove( name );
+        if ( entry instanceof ComponentManager )
+        {
+            Long id = new Long( ( ( ComponentManager ) entry ).getId() );
+            m_componentsById.remove( id );
+        }
+    }
+}
diff --git a/scr/src/main/java/org/apache/felix/scr/DelayedComponentManager.java b/scr/src/main/java/org/apache/felix/scr/impl/DelayedComponentManager.java
similarity index 98%
rename from scr/src/main/java/org/apache/felix/scr/DelayedComponentManager.java
rename to scr/src/main/java/org/apache/felix/scr/impl/DelayedComponentManager.java
index d239315..38c8477 100644
--- a/scr/src/main/java/org/apache/felix/scr/DelayedComponentManager.java
+++ b/scr/src/main/java/org/apache/felix/scr/impl/DelayedComponentManager.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.felix.scr;
+package org.apache.felix.scr.impl;
 
 
 import org.osgi.framework.Bundle;
diff --git a/scr/src/main/java/org/apache/felix/scr/DependencyManager.java b/scr/src/main/java/org/apache/felix/scr/impl/DependencyManager.java
similarity index 96%
rename from scr/src/main/java/org/apache/felix/scr/DependencyManager.java
rename to scr/src/main/java/org/apache/felix/scr/impl/DependencyManager.java
index 8cdc00d..dbd4d89 100644
--- a/scr/src/main/java/org/apache/felix/scr/DependencyManager.java
+++ b/scr/src/main/java/org/apache/felix/scr/impl/DependencyManager.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.felix.scr;
+package org.apache.felix.scr.impl;
 
 
 import java.lang.reflect.InvocationTargetException;
@@ -29,6 +29,7 @@
 import java.util.List;
 import java.util.Map;
 
+import org.apache.felix.scr.Reference;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
 import org.osgi.framework.Filter;
@@ -44,7 +45,7 @@
  * declared by a single <code>&lt;reference&gt;</code element in component
  * descriptor.
  */
-class DependencyManager implements ServiceListener
+class DependencyManager implements ServiceListener, Reference
 {
     // mask of states ok to send events
     private static final int STATE_MASK = AbstractComponentManager.STATE_UNSATISFIED
@@ -108,7 +109,7 @@
         componentManager.getActivator().getBundleContext().addServiceListener( this, filterString );
 
         // get the current number of registered services available
-        ServiceReference refs[] = getServiceReferences();
+        ServiceReference refs[] = getFrameworkServiceReferences();
         m_size = ( refs == null ) ? 0 : refs.length;
     }
 
@@ -309,6 +310,52 @@
     }
 
 
+    //---------- Reference interface ------------------------------------------
+
+
+    public String getServiceName()
+    {
+        return m_dependencyMetadata.getInterface();
+    }
+
+
+    public ServiceReference[] getServiceReferences()
+    {
+        return getBoundServiceReferences();
+    }
+
+
+    public boolean isOptional()
+    {
+        return m_dependencyMetadata.isOptional();
+    }
+
+
+    public boolean isMultiple()
+    {
+        return m_dependencyMetadata.isMultiple();
+    }
+
+
+    public boolean isStatic()
+    {
+        return m_dependencyMetadata.isStatic();
+    }
+
+
+    public String getBindMethodName()
+    {
+        return m_dependencyMetadata.getBind();
+    }
+
+
+    public String getUnbindMethodName()
+    {
+        return m_dependencyMetadata.getUnbind();
+    }
+
+
+
     //---------- Service tracking support -------------------------------------
 
     /**
@@ -358,12 +405,12 @@
 
     /**
      * Returns the first service reference returned by the
-     * {@link #getServiceReferences()} method or <code>null</code> if no
+     * {@link #getFrameworkServiceReferences()} method or <code>null</code> if no
      * matching service can be found.
      */
     ServiceReference getServiceReference()
     {
-        ServiceReference[] sr = getServiceReferences();
+        ServiceReference[] sr = getFrameworkServiceReferences();
         return ( sr != null && sr.length > 0 ) ? sr[0] : null;
     }
 
@@ -379,7 +426,7 @@
      * This method always directly accesses the framework's service registry
      * and ignores the services bound by this dependency manager.
      */
-    ServiceReference[] getServiceReferences()
+    ServiceReference[] getFrameworkServiceReferences()
     {
         try
         {
@@ -411,14 +458,14 @@
 
     /**
      * Returns an array of service instances for the service references returned
-     * by the {@link #getServiceReference()} method. If no services match the
+     * by the {@link #getFrameworkServiceReferences()} method. If no services match the
      * criteria configured for this dependency <code>null</code> is returned.
      * All services returned by this method will be considered bound after this
      * method returns.
      */
     Object[] getServices()
     {
-        ServiceReference[] sr = getServiceReferences();
+        ServiceReference[] sr = getFrameworkServiceReferences();
         if ( sr == null || sr.length == 0 )
         {
             return null;
@@ -548,7 +595,7 @@
     /**
      * Returns the name of the service reference.
      */
-    String getName()
+    public String getName()
     {
         return m_dependencyMetadata.getName();
     }
@@ -560,7 +607,7 @@
      * registered in the framework and available to this dependency manager is
      * not zero.
      */
-    boolean isSatisfied()
+    public boolean isSatisfied()
     {
         return size() > 0 || m_dependencyMetadata.isOptional();
     }
@@ -590,7 +637,7 @@
         }
 
         // Get service references
-        ServiceReference refs[] = getServiceReferences();
+        ServiceReference refs[] = getFrameworkServiceReferences();
 
         // refs can be null if the dependency is optional
         if ( refs == null )
@@ -1044,7 +1091,7 @@
         }
 
         // check for new services to be added
-        ServiceReference[] refs = getServiceReferences();
+        ServiceReference[] refs = getFrameworkServiceReferences();
         if ( refs != null )
         {
             for ( int i = 0; i < refs.length; i++ )
@@ -1066,7 +1113,7 @@
      * @return The target filter of this dependency or <code>null</code> if
      *      none is set.
      */
-    private String getTarget()
+    public String getTarget()
     {
         return m_target;
     }
diff --git a/scr/src/main/java/org/apache/felix/scr/ImmediateComponentManager.java b/scr/src/main/java/org/apache/felix/scr/impl/ImmediateComponentManager.java
similarity index 98%
rename from scr/src/main/java/org/apache/felix/scr/ImmediateComponentManager.java
rename to scr/src/main/java/org/apache/felix/scr/impl/ImmediateComponentManager.java
index 12b4935..ba9605b 100644
--- a/scr/src/main/java/org/apache/felix/scr/ImmediateComponentManager.java
+++ b/scr/src/main/java/org/apache/felix/scr/impl/ImmediateComponentManager.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.felix.scr;
+package org.apache.felix.scr.impl;
 
 
 import java.lang.reflect.InvocationTargetException;
@@ -41,9 +41,6 @@
  */
 class ImmediateComponentManager extends AbstractComponentManager
 {
-    // the component ID
-    private long m_componentId;
-
     // The object that implements the service and that is bound to other services
     private Object m_implementationObject;
 
@@ -74,9 +71,7 @@
      */
     ImmediateComponentManager( BundleComponentActivator activator, ComponentMetadata metadata, long componentId )
     {
-        super( activator, metadata );
-
-        m_componentId = componentId;
+        super( activator, metadata, componentId );
 
         // only register as ManagedService if not created by a Component Factory
         if ( !getComponentMetadata().isFactory() )
@@ -341,7 +336,7 @@
      *
      * @return a private Hashtable of component properties
      */
-    protected Dictionary getProperties()
+    public Dictionary getProperties()
     {
 
         // TODO: Currently on ManagedService style configuration is supported, ManagedServiceFactory style is missing
@@ -372,7 +367,7 @@
 
             // 5. set component.name and component.id
             props.put( ComponentConstants.COMPONENT_NAME, getComponentMetadata().getName() );
-            props.put( ComponentConstants.COMPONENT_ID, new Long( m_componentId ) );
+            props.put( ComponentConstants.COMPONENT_ID, new Long( getId() ) );
 
             m_properties = props;
         }
diff --git a/scr/src/main/java/org/apache/felix/scr/ManagerFactory.java b/scr/src/main/java/org/apache/felix/scr/impl/ManagerFactory.java
similarity index 97%
rename from scr/src/main/java/org/apache/felix/scr/ManagerFactory.java
rename to scr/src/main/java/org/apache/felix/scr/impl/ManagerFactory.java
index 21b204b..7f2a902 100644
--- a/scr/src/main/java/org/apache/felix/scr/ManagerFactory.java
+++ b/scr/src/main/java/org/apache/felix/scr/impl/ManagerFactory.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations

  * under the License.

  */

-package org.apache.felix.scr;

+package org.apache.felix.scr.impl;

 

 import org.osgi.service.log.LogService;

 

diff --git a/scr/src/main/java/org/apache/felix/scr/PropertyMetadata.java b/scr/src/main/java/org/apache/felix/scr/impl/PropertyMetadata.java
similarity index 99%
rename from scr/src/main/java/org/apache/felix/scr/PropertyMetadata.java
rename to scr/src/main/java/org/apache/felix/scr/impl/PropertyMetadata.java
index 66e4f44..ab8068e 100644
--- a/scr/src/main/java/org/apache/felix/scr/PropertyMetadata.java
+++ b/scr/src/main/java/org/apache/felix/scr/impl/PropertyMetadata.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.felix.scr;
+package org.apache.felix.scr.impl;
 
 import java.util.ArrayList;
 import java.util.List;
diff --git a/scr/src/main/java/org/apache/felix/scr/ReadOnlyDictionary.java b/scr/src/main/java/org/apache/felix/scr/impl/ReadOnlyDictionary.java
similarity index 98%
rename from scr/src/main/java/org/apache/felix/scr/ReadOnlyDictionary.java
rename to scr/src/main/java/org/apache/felix/scr/impl/ReadOnlyDictionary.java
index 6350535..260b76f 100644
--- a/scr/src/main/java/org/apache/felix/scr/ReadOnlyDictionary.java
+++ b/scr/src/main/java/org/apache/felix/scr/impl/ReadOnlyDictionary.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.felix.scr;
+package org.apache.felix.scr.impl;
 
 
 import java.util.Dictionary;
diff --git a/scr/src/main/java/org/apache/felix/scr/ReferenceMetadata.java b/scr/src/main/java/org/apache/felix/scr/impl/ReferenceMetadata.java
similarity index 99%
rename from scr/src/main/java/org/apache/felix/scr/ReferenceMetadata.java
rename to scr/src/main/java/org/apache/felix/scr/impl/ReferenceMetadata.java
index 66296c2..b55bb5a 100644
--- a/scr/src/main/java/org/apache/felix/scr/ReferenceMetadata.java
+++ b/scr/src/main/java/org/apache/felix/scr/impl/ReferenceMetadata.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.felix.scr;
+package org.apache.felix.scr.impl;
 
 
 import org.osgi.service.component.ComponentException;
diff --git a/scr/src/main/java/org/apache/felix/scr/ServiceFactoryComponentManager.java b/scr/src/main/java/org/apache/felix/scr/impl/ServiceFactoryComponentManager.java
similarity index 99%
rename from scr/src/main/java/org/apache/felix/scr/ServiceFactoryComponentManager.java
rename to scr/src/main/java/org/apache/felix/scr/impl/ServiceFactoryComponentManager.java
index 49921ee..4ca248c 100644
--- a/scr/src/main/java/org/apache/felix/scr/ServiceFactoryComponentManager.java
+++ b/scr/src/main/java/org/apache/felix/scr/impl/ServiceFactoryComponentManager.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.felix.scr;
+package org.apache.felix.scr.impl;
 
 
 import java.util.IdentityHashMap;
diff --git a/scr/src/main/java/org/apache/felix/scr/ServiceMetadata.java b/scr/src/main/java/org/apache/felix/scr/impl/ServiceMetadata.java
similarity index 98%
rename from scr/src/main/java/org/apache/felix/scr/ServiceMetadata.java
rename to scr/src/main/java/org/apache/felix/scr/impl/ServiceMetadata.java
index 4df31a0..665a400 100644
--- a/scr/src/main/java/org/apache/felix/scr/ServiceMetadata.java
+++ b/scr/src/main/java/org/apache/felix/scr/impl/ServiceMetadata.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations

  * under the License.

  */

-package org.apache.felix.scr;

+package org.apache.felix.scr.impl;

 

 import java.util.ArrayList;

 import java.util.Iterator;

diff --git a/scr/src/main/java/org/apache/felix/scr/XmlHandler.java b/scr/src/main/java/org/apache/felix/scr/impl/XmlHandler.java
similarity index 95%
rename from scr/src/main/java/org/apache/felix/scr/XmlHandler.java
rename to scr/src/main/java/org/apache/felix/scr/impl/XmlHandler.java
index 338e44d..221729b 100644
--- a/scr/src/main/java/org/apache/felix/scr/XmlHandler.java
+++ b/scr/src/main/java/org/apache/felix/scr/impl/XmlHandler.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.felix.scr;
+package org.apache.felix.scr.impl;
 
 
 import java.io.IOException;
@@ -28,8 +28,8 @@
 import java.util.Map;
 import java.util.Properties;
 
-import org.apache.felix.scr.parser.KXml2SAXHandler;
-import org.apache.felix.scr.parser.ParseException;
+import org.apache.felix.scr.impl.parser.KXml2SAXHandler;
+import org.apache.felix.scr.impl.parser.ParseException;
 import org.osgi.framework.Bundle;
 
 
@@ -271,7 +271,7 @@
 
 
     /**
-     * @see org.apache.felix.scr.parser.KXml2SAXHandler#characters(java.lang.String)
+     * @see org.apache.felix.scr.impl.parser.KXml2SAXHandler#characters(java.lang.String)
      */
     public void characters( String text )
     {
@@ -286,7 +286,7 @@
 
 
     /**
-     * @see org.apache.felix.scr.parser.KXml2SAXHandler#processingInstruction(java.lang.String, java.lang.String)
+     * @see org.apache.felix.scr.impl.parser.KXml2SAXHandler#processingInstruction(java.lang.String, java.lang.String)
      */
     public void processingInstruction( String target, String data )
     {
@@ -295,7 +295,7 @@
 
 
     /**
-     * @see org.apache.felix.scr.parser.KXml2SAXHandler#setLineNumber(int)
+     * @see org.apache.felix.scr.impl.parser.KXml2SAXHandler#setLineNumber(int)
      */
     public void setLineNumber( int lineNumber )
     {
@@ -304,7 +304,7 @@
 
 
     /**
-     * @see org.apache.felix.scr.parser.KXml2SAXHandler#setColumnNumber(int)
+     * @see org.apache.felix.scr.impl.parser.KXml2SAXHandler#setColumnNumber(int)
      */
     public void setColumnNumber( int columnNumber )
     {
diff --git a/scr/src/main/java/org/apache/felix/scr/parser/KXml2SAXHandler.java b/scr/src/main/java/org/apache/felix/scr/impl/parser/KXml2SAXHandler.java
similarity index 97%
rename from scr/src/main/java/org/apache/felix/scr/parser/KXml2SAXHandler.java
rename to scr/src/main/java/org/apache/felix/scr/impl/parser/KXml2SAXHandler.java
index 59b14aa..6b7857b 100644
--- a/scr/src/main/java/org/apache/felix/scr/parser/KXml2SAXHandler.java
+++ b/scr/src/main/java/org/apache/felix/scr/impl/parser/KXml2SAXHandler.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations

  * under the License.

  */

-package org.apache.felix.scr.parser;

+package org.apache.felix.scr.impl.parser;

 

 import java.util.Properties;

 

diff --git a/scr/src/main/java/org/apache/felix/scr/parser/KXml2SAXParser.java b/scr/src/main/java/org/apache/felix/scr/impl/parser/KXml2SAXParser.java
similarity index 98%
rename from scr/src/main/java/org/apache/felix/scr/parser/KXml2SAXParser.java
rename to scr/src/main/java/org/apache/felix/scr/impl/parser/KXml2SAXParser.java
index 4c3765f..165ddfe 100644
--- a/scr/src/main/java/org/apache/felix/scr/parser/KXml2SAXParser.java
+++ b/scr/src/main/java/org/apache/felix/scr/impl/parser/KXml2SAXParser.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations

  * under the License.

  */

-package org.apache.felix.scr.parser;

+package org.apache.felix.scr.impl.parser;

 

 

 import java.io.Reader;

diff --git a/scr/src/main/java/org/apache/felix/scr/parser/ParseException.java b/scr/src/main/java/org/apache/felix/scr/impl/parser/ParseException.java
similarity index 96%
rename from scr/src/main/java/org/apache/felix/scr/parser/ParseException.java
rename to scr/src/main/java/org/apache/felix/scr/impl/parser/ParseException.java
index e70a078..21eddaf 100644
--- a/scr/src/main/java/org/apache/felix/scr/parser/ParseException.java
+++ b/scr/src/main/java/org/apache/felix/scr/impl/parser/ParseException.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.felix.scr.parser;
+package org.apache.felix.scr.impl.parser;
 
 public class ParseException extends Exception
 {