You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cz...@apache.org on 2017/02/01 13:17:43 UTC

svn commit: r1781242 - in /felix/trunk/osgi-r7/scr/src: main/java/org/apache/felix/scr/impl/inject/methods/ main/java/org/apache/felix/scr/impl/manager/ main/java/org/apache/felix/scr/impl/runtime/ test/java/org/apache/felix/scr/integration/

Author: cziegeler
Date: Wed Feb  1 13:17:42 2017
New Revision: 1781242

URL: http://svn.apache.org/viewvc?rev=1781242&view=rev
Log:
FELIX-5460 : Update DTOs

Modified:
    felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/methods/BaseMethod.java
    felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/manager/AbstractComponentManager.java
    felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/manager/ComponentManager.java
    felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/manager/ServiceFactoryComponentManager.java
    felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/manager/SingleComponentManager.java
    felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/runtime/ServiceComponentRuntimeImpl.java
    felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/CircularReferenceTest.java
    felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ComponentActivationTest.java
    felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/Felix5248Test.java
    felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/PersistentComponentFactoryTest.java

Modified: felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/methods/BaseMethod.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/methods/BaseMethod.java?rev=1781242&r1=1781241&r2=1781242&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/methods/BaseMethod.java (original)
+++ felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/inject/methods/BaseMethod.java Wed Feb  1 13:17:42 2017
@@ -113,20 +113,20 @@ public abstract class BaseMethod<P>
         {
             m_state = Resolved.INSTANCE;
             logger.log( LogService.LOG_DEBUG, "Found {0} method: {1}", new Object[]
-                { getMethodNamePrefix(), method }, null );
+                    { getMethodNamePrefix(), method }, null );
         }
         else if ( m_methodRequired )
         {
             m_state = NotFound.INSTANCE;
             logger.log(LogService.LOG_ERROR, "{0} method [{1}] not found; Component will fail",
-                new Object[]
-                    { getMethodNamePrefix(), getMethodName() }, null);
+                    new Object[]
+                            { getMethodNamePrefix(), getMethodName() }, null);
         }
         else
         {
             // optional method not found, log as DEBUG and ignore
             logger.log( LogService.LOG_DEBUG, "{0} method [{1}] not found, ignoring", new Object[]
-                { getMethodNamePrefix(), getMethodName() }, null );
+                    { getMethodNamePrefix(), getMethodName() }, null );
             m_state = NotApplicable.INSTANCE;
         }
     }
@@ -166,7 +166,7 @@ public abstract class BaseMethod<P>
             if ( logger.isLogEnabled( LogService.LOG_DEBUG ) )
             {
                 logger.log( LogService.LOG_DEBUG,
-                    "Locating method " + getMethodName() + " in class " + theClass.getName(), null );
+                        "Locating method " + getMethodName() + " in class " + theClass.getName(), null );
             }
 
             try
@@ -181,8 +181,8 @@ public abstract class BaseMethod<P>
             {
                 // log and return null
                 logger.log( LogService.LOG_ERROR,
-                    "findMethod: Suitable but non-accessible method {0} found in class {1}, subclass of {2}", new Object[]
-                        { getMethodName(), theClass.getName(), targetClass.getName() }, null );
+                        "findMethod: Suitable but non-accessible method {0} found in class {1}, subclass of {2}", new Object[]
+                                { getMethodName(), theClass.getName(), targetClass.getName() }, null );
                 break;
             }
 
@@ -197,7 +197,7 @@ public abstract class BaseMethod<P>
             // package methods only if in the same package and package
             // methods are (still) allowed
             acceptPackage &= targetClasslLoader == theClass.getClassLoader()
-                && targetPackage.equals( getPackageName( theClass ) );
+                    && targetPackage.equals( getPackageName( theClass ) );
 
             // private methods will not be accepted any more in super classes
             acceptPrivate = false;
@@ -213,7 +213,7 @@ public abstract class BaseMethod<P>
 
 
     private MethodResult invokeMethod(final Object componentInstance, final P rawParameter, SimpleLogger logger )
-        throws InvocationTargetException
+            throws InvocationTargetException
     {
         try
         {
@@ -224,14 +224,14 @@ public abstract class BaseMethod<P>
                         { getMethodNamePrefix(), getMethodName(), Arrays.asList( params ) }, null );
                 Object result = m_method.invoke(componentInstance, params);
                 logger.log( LogService.LOG_DEBUG, "invoked {0}: {1}", new Object[]
-                    { getMethodNamePrefix(), getMethodName() }, null );
+                        { getMethodNamePrefix(), getMethodName() }, null );
                 return new MethodResult((m_method.getReturnType() != Void.TYPE), (Map<String, Object>) result);
             }
             else
             {
                 logger.log( LogService.LOG_WARNING, "Method {0}: {1} cannot be called on null object",
-                    new Object[]
-                        { getMethodNamePrefix(), getMethodName() }, null );
+                        new Object[]
+                                { getMethodNamePrefix(), getMethodName() }, null );
             }
         }
         catch ( IllegalStateException ise )
@@ -245,7 +245,7 @@ public abstract class BaseMethod<P>
             // public, SCR must log an error message with the log service,
             // if present, and ignore the method
             logger.log( LogService.LOG_DEBUG, "Method {0} cannot be called", new Object[]
-                { getMethodName() }, ex );
+                    { getMethodName() }, ex );
         }
         catch ( InvocationTargetException ex )
         {
@@ -311,7 +311,7 @@ public abstract class BaseMethod<P>
      */
     public /* static */ Method getMethod( Class<?> clazz, String name, Class[] parameterTypes, boolean acceptPrivate,
             boolean acceptPackage, SimpleLogger logger ) throws SuitableMethodNotAccessibleException,
-        InvocationTargetException
+    InvocationTargetException
     {
         try
         {
@@ -335,7 +335,7 @@ public abstract class BaseMethod<P>
             {
                 String argList = ( parameterTypes != null ) ? Arrays.asList( parameterTypes ).toString() : "";
                 logger.log( LogService.LOG_DEBUG, "Declared Method {0}.{1}({2}) not found", new Object[]
-                    { clazz.getName(), name, argList }, null );
+                        { clazz.getName(), name, argList }, null );
             }
         }
         catch ( NoClassDefFoundError cdfe )
@@ -450,6 +450,7 @@ public abstract class BaseMethod<P>
     {
         AccessController.doPrivileged( new PrivilegedAction<Object>()
         {
+            @Override
             public Object run()
             {
                 method.setAccessible( true );
@@ -504,7 +505,11 @@ public abstract class BaseMethod<P>
         catch ( InvocationTargetException ite )
         {
             logger.log( LogService.LOG_ERROR, "The {0} method has thrown an exception", new Object[]
-                { getMethodName() }, ite.getCause() );
+                    { getMethodName() }, ite.getCause() );
+            if ( methodCallFailureResult != null && methodCallFailureResult.getResult() != null )
+            {
+                methodCallFailureResult.getResult().put("exception", ite.getCause());
+            }
         }
 
         return methodCallFailureResult;
@@ -520,7 +525,7 @@ public abstract class BaseMethod<P>
     {
 
         <P> MethodResult invoke( final BaseMethod<P> baseMethod, final Object componentInstance, final P rawParameter, SimpleLogger logger )
-            throws InvocationTargetException;
+                throws InvocationTargetException;
 
 
         <P> boolean methodExists( final BaseMethod<P> baseMethod, SimpleLogger logger );
@@ -532,12 +537,14 @@ public abstract class BaseMethod<P>
         private static final State INSTANCE = new NotApplicable();
 
 
+        @Override
         public <P> MethodResult invoke( final BaseMethod<P> baseMethod, final Object componentInstance, final P rawParameter, SimpleLogger logger )
         {
             return MethodResult.VOID;
         }
 
 
+        @Override
         public <P> boolean methodExists( final BaseMethod<P> baseMethod, SimpleLogger logger )
         {
             return true;
@@ -570,14 +577,16 @@ public abstract class BaseMethod<P>
         }
 
 
+        @Override
         public <P> MethodResult invoke( final BaseMethod<P> baseMethod, final Object componentInstance, final P rawParameter, SimpleLogger logger )
-            throws InvocationTargetException
+                throws InvocationTargetException
         {
             resolve( baseMethod, logger );
             return baseMethod.getState().invoke( baseMethod, componentInstance, rawParameter, logger );
         }
 
 
+        @Override
         public <P> boolean methodExists( final BaseMethod<P> baseMethod, SimpleLogger logger )
         {
             resolve( baseMethod, logger );
@@ -590,17 +599,19 @@ public abstract class BaseMethod<P>
         private static final State INSTANCE = new NotFound();
 
 
+        @Override
         public <P> MethodResult invoke( final BaseMethod<P> baseMethod, final Object componentInstance, final P rawParameter, SimpleLogger logger )
         {
             // 112.3.1 If the method is not found , SCR must log an error
             // message with the log service, if present, and ignore the
             // method
             logger.log( LogService.LOG_ERROR, "{0} method [{1}] not found", new Object[]
-                { baseMethod.getMethodNamePrefix(), baseMethod.getMethodName() }, null );
+                    { baseMethod.getMethodNamePrefix(), baseMethod.getMethodName() }, null );
             return null;
         }
 
 
+        @Override
         public <P> boolean methodExists( final BaseMethod<P> baseMethod, SimpleLogger logger )
         {
             return false;
@@ -612,13 +623,15 @@ public abstract class BaseMethod<P>
         private static final State INSTANCE = new Resolved();
 
 
+        @Override
         public <P> MethodResult invoke( final BaseMethod<P> baseMethod, final Object componentInstance, final P rawParameter, SimpleLogger logger )
-            throws InvocationTargetException
+                throws InvocationTargetException
         {
             return baseMethod.invokeMethod( componentInstance, rawParameter, logger );
         }
 
 
+        @Override
         public <P> boolean methodExists( final BaseMethod<P> baseMethod, SimpleLogger logger )
         {
             return true;

Modified: felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/manager/AbstractComponentManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/manager/AbstractComponentManager.java?rev=1781242&r1=1781241&r2=1781242&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/manager/AbstractComponentManager.java (original)
+++ felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/manager/AbstractComponentManager.java Wed Feb  1 13:17:42 2017
@@ -18,6 +18,8 @@
  */
 package org.apache.felix.scr.impl.manager;
 
+import java.io.PrintWriter;
+import java.io.StringWriter;
 import java.lang.reflect.InvocationTargetException;
 import java.security.Permission;
 import java.util.ArrayList;
@@ -76,9 +78,11 @@ public abstract class AbstractComponentM
         disposed(-1, false, false, false),
         //Since enable/disable on the component description are asynchronous, this tracks the component configuration state
         //which may differ while the enable/disable is occurring.
-        disabled(-1, false, false, false), unsatisfiedReference(ComponentConfigurationDTO.UNSATISFIED_REFERENCE, true,
-            false, false), satisfied(ComponentConfigurationDTO.SATISFIED, true, true,
-                false), active(ComponentConfigurationDTO.ACTIVE, true, true, true);
+        disabled(-1, false, false, false),
+        unsatisfiedReference(ComponentConfigurationDTO.UNSATISFIED_REFERENCE, true, false, false),
+        satisfied(ComponentConfigurationDTO.SATISFIED, true, true, false),
+        active(ComponentConfigurationDTO.ACTIVE, true, true, true),
+        failed(ComponentConfigurationDTO.FAILED_ACTIVATION, true, true, false);
 
         private final int specState;
 
@@ -143,7 +147,7 @@ public abstract class AbstractComponentM
      * two threads and the initiating thread does not wait for the operation to complete, we can't use a regular lock.
      */
     private final AtomicReference<Deferred<Void>> m_enabledLatchRef = new AtomicReference<Deferred<Void>>(
-        new Deferred<Void>());
+            new Deferred<Void>());
 
     private final AtomicReference<State> state = new AtomicReference<State>(State.disabled);
 
@@ -158,6 +162,8 @@ public abstract class AbstractComponentM
 
     protected final ReentrantReadWriteLock m_activationLock = new ReentrantReadWriteLock();
 
+    private volatile String failureReason;
+
     /**
      * The constructor receives both the activator and the metadata
      *
@@ -187,25 +193,25 @@ public abstract class AbstractComponentM
         if (isLogEnabled(LogService.LOG_DEBUG))
         {
             log(LogService.LOG_DEBUG,
-                "Component {0} created: DS={1}, implementation={2}, immediate={3}, default-enabled={4}, factory={5}, configuration-policy={6}, activate={7}, deactivate={8}, modified={9} configuration-pid={10}",
-                new Object[] { metadata.getName(), metadata.getDSVersion(), metadata.getImplementationClassName(),
-                        metadata.isImmediate(), metadata.isEnabled(), metadata.getFactoryIdentifier(),
-                        metadata.getConfigurationPolicy(), metadata.getActivate(), metadata.getDeactivate(),
-                        metadata.getModified(), metadata.getConfigurationPid() },
-                null);
+                    "Component {0} created: DS={1}, implementation={2}, immediate={3}, default-enabled={4}, factory={5}, configuration-policy={6}, activate={7}, deactivate={8}, modified={9} configuration-pid={10}",
+                    new Object[] { metadata.getName(), metadata.getDSVersion(), metadata.getImplementationClassName(),
+                            metadata.isImmediate(), metadata.isEnabled(), metadata.getFactoryIdentifier(),
+                            metadata.getConfigurationPolicy(), metadata.getActivate(), metadata.getDeactivate(),
+                            metadata.getModified(), metadata.getConfigurationPid() },
+                    null);
 
             if (metadata.getServiceMetadata() != null)
             {
                 log(LogService.LOG_DEBUG,
-                    "Component {0} Services: scope={1}, services={2}", new Object[] { metadata.getName(),
-                            metadata.getServiceScope(), Arrays.asList(metadata.getServiceMetadata().getProvides()) },
-                    null);
+                        "Component {0} Services: scope={1}, services={2}", new Object[] { metadata.getName(),
+                                metadata.getServiceScope(), Arrays.asList(metadata.getServiceMetadata().getProvides()) },
+                        null);
             }
 
             if (metadata.getProperties() != null)
             {
                 log(LogService.LOG_DEBUG, "Component {0} Properties: {1}",
-                    new Object[] { metadata.getName(), metadata.getProperties() }, null);
+                        new Object[] { metadata.getName(), metadata.getProperties() }, null);
             }
         }
     }
@@ -346,7 +352,7 @@ public abstract class AbstractComponentM
             while (m_ceiling < trackingCount || (!m_missing.isEmpty() && m_missing.iterator().next() < trackingCount))
             {
                 log(LogService.LOG_DEBUG, "waitForTracked trackingCount: {0} ceiling: {1} missing: {2}",
-                    new Object[] { trackingCount, m_ceiling, m_missing }, null);
+                        new Object[] { trackingCount, m_ceiling, m_missing }, null);
                 try
                 {
                     if (!doMissingWait())
@@ -366,8 +372,8 @@ public abstract class AbstractComponentM
                     catch (InterruptedException e1)
                     {
                         log(LogService.LOG_ERROR,
-                            "waitForTracked interrupted twice: {0} ceiling: {1} missing: {2},  Expect further errors",
-                            new Object[] { trackingCount, m_ceiling, m_missing }, e1);
+                                "waitForTracked interrupted twice: {0} ceiling: {1} missing: {2},  Expect further errors",
+                                new Object[] { trackingCount, m_ceiling, m_missing }, e1);
                     }
                     Thread.currentThread().interrupt();
                 }
@@ -384,7 +390,7 @@ public abstract class AbstractComponentM
         if (!m_missingCondition.await(getLockTimeout(), TimeUnit.MILLISECONDS))
         {
             log(LogService.LOG_ERROR, "waitForTracked timed out: {0} ceiling: {1} missing: {2},  Expect further errors",
-                new Object[] { m_trackingCount, m_ceiling, m_missing }, null);
+                    new Object[] { m_trackingCount, m_ceiling, m_missing }, null);
             dumpThreads();
             m_missing.clear();
             return false;
@@ -446,6 +452,7 @@ public abstract class AbstractComponentM
 
                 long count = taskCounter.incrementAndGet();
 
+                @Override
                 public void run()
                 {
                     try
@@ -537,6 +544,7 @@ public abstract class AbstractComponentM
 
                 long count = taskCounter.incrementAndGet();
 
+                @Override
                 public void run()
                 {
                     try
@@ -591,6 +599,7 @@ public abstract class AbstractComponentM
 
     //---------- Component interface ------------------------------------------
 
+    @Override
     public long getId()
     {
         return m_componentId;
@@ -662,7 +671,7 @@ public abstract class AbstractComponentM
         if (previousState.isEnabled())
         {
             log(LogService.LOG_WARNING, "enable  called but component is already in state {0}",
-                new Object[] { previousState }, null);
+                    new Object[] { previousState }, null);
             return;
         }
 
@@ -885,14 +894,14 @@ public abstract class AbstractComponentM
             try
             {
                 @SuppressWarnings("unchecked")
-				ServiceRegistration<S> serviceRegistration = (ServiceRegistration<S>) bundleContext.registerService(
-                    services, getService(), serviceProperties);
+                ServiceRegistration<S> serviceRegistration = (ServiceRegistration<S>) bundleContext.registerService(
+                        services, getService(), serviceProperties);
                 return serviceRegistration;
             }
             catch (ServiceException e)
             {
                 log(LogService.LOG_ERROR, "Unexpected error registering component service with properties {0}",
-                    new Object[] { serviceProperties }, e);
+                        new Object[] { serviceProperties }, e);
                 return null;
             }
         }
@@ -979,9 +988,9 @@ public abstract class AbstractComponentM
         catch (ClassNotFoundException e)
         {
             log(LogService.LOG_ERROR, "Could not load implementation object class {0}",
-                new Object[] { getComponentMetadata().getImplementationClassName() }, e);
+                    new Object[] { getComponentMetadata().getImplementationClassName() }, e);
             throw new IllegalStateException(
-                "Could not load implementation object class " + getComponentMetadata().getImplementationClassName());
+                    "Could not load implementation object class " + getComponentMetadata().getImplementationClassName());
         }
         m_componentMethods.initComponentMethods(getComponentMetadata(), implementationObjectClass);
 
@@ -1009,7 +1018,7 @@ public abstract class AbstractComponentM
                 //not actually satisfied any longer
                 deactivateDependencyManagers();
                 log(LogService.LOG_DEBUG, "Could not get required dependency for dependency manager: {0}",
-                    new Object[] { dependencyManager.getName() }, null);
+                        new Object[] { dependencyManager.getName() }, null);
                 return false;
             }
         }
@@ -1022,13 +1031,13 @@ public abstract class AbstractComponentM
      * @return {@code true} if the component needs reactivation, {@code false} otherwise.
      */
     abstract <T> boolean invokeUpdatedMethod(DependencyManager<S, T> dependencyManager, RefPair<S, T> refPair,
-        int trackingCount);
+            int trackingCount);
 
     abstract <T> void invokeBindMethod(DependencyManager<S, T> dependencyManager, RefPair<S, T> refPair,
-        int trackingCount);
+            int trackingCount);
 
     abstract <T> void invokeUnbindMethod(DependencyManager<S, T> dependencyManager, RefPair<S, T> oldRefPair,
-        int trackingCount);
+            int trackingCount);
 
     //**********************************************************************************************************
     public ComponentActivator getActivator()
@@ -1054,6 +1063,7 @@ public abstract class AbstractComponentM
     /**
      * Returns <code>true</code> if logging for the given level is enabled.
      */
+    @Override
     public boolean isLogEnabled(int level)
     {
         ComponentActivator activator = getActivator();
@@ -1064,6 +1074,7 @@ public abstract class AbstractComponentM
         return false;
     }
 
+    @Override
     public void log(int level, String message, Throwable ex)
     {
         ComponentActivator activator = getActivator();
@@ -1073,6 +1084,7 @@ public abstract class AbstractComponentM
         }
     }
 
+    @Override
     public void log(int level, String message, Object[] arguments, Throwable ex)
     {
         ComponentActivator activator = getActivator();
@@ -1106,7 +1118,7 @@ public abstract class AbstractComponentM
                         if (!bundle.hasPermission(perm))
                         {
                             log(LogService.LOG_DEBUG, "Permission to register service {0} is denied",
-                                new Object[] { service }, null);
+                                    new Object[] { service }, null);
                             allowed = false;
                         }
                     }
@@ -1121,7 +1133,7 @@ public abstract class AbstractComponentM
     private List<DependencyManager<S, ?>> loadDependencyManagers(ComponentMetadata metadata)
     {
         List<DependencyManager<S, ?>> depMgrList = new ArrayList<DependencyManager<S, ?>>(
-            metadata.getDependencies().size());
+                metadata.getDependencies().size());
 
         // If this component has got dependencies, create dependency managers for each one of them.
         if (metadata.getDependencies().size() != 0)
@@ -1130,7 +1142,7 @@ public abstract class AbstractComponentM
             for (ReferenceMetadata currentdependency : metadata.getDependencies())
             {
                 @SuppressWarnings({ "unchecked", "rawtypes" })
-				DependencyManager<S, ?> depmanager = new DependencyManager(this, currentdependency, index++);
+                DependencyManager<S, ?> depmanager = new DependencyManager(this, currentdependency, index++);
 
                 depMgrList.add(depmanager);
             }
@@ -1162,12 +1174,12 @@ public abstract class AbstractComponentM
                 if (dm.isOptional())
                 {
                     log(LogService.LOG_DEBUG, "No permission to get optional dependency: {0}; assuming satisfied",
-                        new Object[] { dm.getName() }, null);
+                            new Object[] { dm.getName() }, null);
                 }
                 else
                 {
                     log(LogService.LOG_DEBUG, "No permission to get mandatory dependency: {0}; assuming unsatisfied",
-                        new Object[] { dm.getName() }, null);
+                            new Object[] { dm.getName() }, null);
                     satisfied = false;
                 }
             }
@@ -1197,6 +1209,7 @@ public abstract class AbstractComponentM
         return m_dependencyManagers;
     }
 
+    @Override
     public List<? extends ReferenceManager<S, ?>> getReferenceManagers()
     {
         return m_dependencyManagers;
@@ -1249,6 +1262,7 @@ public abstract class AbstractComponentM
     /* (non-Javadoc)
      * @see org.apache.felix.scr.impl.manager.ComponentManager#getProperties()
      */
+    @Override
     public abstract Map<String, Object> getProperties();
 
     public abstract void setServiceProperties(Dictionary<String, ?> serviceProperties);
@@ -1284,7 +1298,7 @@ public abstract class AbstractComponentM
      *         private and had not to be copied
      */
     protected static Dictionary<String, Object> copyTo(Dictionary<String, Object> target, final Map<String, ?> source,
-        final boolean allProps)
+            final boolean allProps)
     {
         if (target == null)
         {
@@ -1343,7 +1357,7 @@ public abstract class AbstractComponentM
     }
 
     protected static Dictionary<String, Object> copyToDictionary(final Dictionary<String, ?> source,
-        final boolean allProps)
+            final boolean allProps)
     {
         Hashtable<String, Object> target = new Hashtable<String, Object>();
 
@@ -1371,6 +1385,7 @@ public abstract class AbstractComponentM
         return m_container.getComponentMetadata();
     }
 
+    @Override
     public int getSpecState()
     {
         return getState().getSpecState();
@@ -1383,16 +1398,37 @@ public abstract class AbstractComponentM
         return s;
     }
 
+    @Override
+    public String getFailureReason() {
+        return this.failureReason;
+    }
+
+    public void setFailureReason(final Throwable e)
+    {
+        if ( e != null )
+        {
+            final StringWriter sw = new StringWriter();
+            final PrintWriter pw = new PrintWriter(sw);
+            e.printStackTrace(pw);
+            pw.flush();
+            this.failureReason = sw.toString();
+        }
+    }
+
     void setState(State previousState, State newState)
     {
         if (state.compareAndSet(previousState, newState))
         {
             log(LogService.LOG_DEBUG, "Changed state from {0} to {1}", new Object[] { previousState, newState }, null);
+            if ( newState != State.failed )
+            {
+                this.failureReason = null;
+            }
         }
         else
         {
             log(LogService.LOG_DEBUG, "Did not change state from {0} to {1}: current state {2}",
-                new Object[] { previousState, newState, state.get() }, null);
+                    new Object[] { previousState, newState, state.get() }, null);
         }
 
     }
@@ -1408,7 +1444,7 @@ public abstract class AbstractComponentM
                 tracked(trackingCount);
             }
             Dictionary<String, Object> serviceProps = (methodResult.getResult() == null) ? null
-                : new Hashtable<String, Object>(methodResult.getResult());
+                    : new Hashtable<String, Object>(methodResult.getResult());
             setServiceProperties(serviceProps);
         }
     }

Modified: felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/manager/ComponentManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/manager/ComponentManager.java?rev=1781242&r1=1781241&r2=1781242&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/manager/ComponentManager.java (original)
+++ felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/manager/ComponentManager.java Wed Feb  1 13:17:42 2017
@@ -25,20 +25,22 @@ import org.osgi.service.component.runtim
 
 
 public interface ComponentManager<S> {
-	
+
     int STATE_UNSATISFIED_CONFIGURATION = ComponentConfigurationDTO.UNSATISFIED_CONFIGURATION;
     int STATE_UNSATISFIED_REFERENCE = ComponentConfigurationDTO.UNSATISFIED_REFERENCE;
     int STATE_SATISFIED = ComponentConfigurationDTO.SATISFIED;
-	int STATE_ACTIVE = ComponentConfigurationDTO.ACTIVE;
-	int STATE_DISPOSED = 32;
-	int STATE_DISABLED = 64; //TODO????
-
-	Map<String, Object> getProperties();
-
-	long getId();
-
-	int getSpecState();
-	
-	List<? extends ReferenceManager<S, ?>> getReferenceManagers();
-	
+    int STATE_ACTIVE = ComponentConfigurationDTO.ACTIVE;
+    int STATE_DISPOSED = 32;
+    int STATE_DISABLED = 64; //TODO????
+
+    Map<String, Object> getProperties();
+
+    long getId();
+
+    int getSpecState();
+
+    String getFailureReason();
+
+    List<? extends ReferenceManager<S, ?>> getReferenceManagers();
+
 }
\ No newline at end of file

Modified: felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/manager/ServiceFactoryComponentManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/manager/ServiceFactoryComponentManager.java?rev=1781242&r1=1781241&r2=1781242&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/manager/ServiceFactoryComponentManager.java (original)
+++ felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/manager/ServiceFactoryComponentManager.java Wed Feb  1 13:17:42 2017
@@ -24,8 +24,8 @@ import java.util.Collection;
 import java.util.Dictionary;
 import java.util.IdentityHashMap;
 
-import org.apache.felix.scr.impl.inject.LifecycleMethod;
 import org.apache.felix.scr.impl.inject.ComponentMethods;
+import org.apache.felix.scr.impl.inject.LifecycleMethod;
 import org.apache.felix.scr.impl.inject.MethodResult;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.ServiceRegistration;
@@ -71,6 +71,7 @@ public class ServiceFactoryComponentMana
     /* (non-Javadoc)
      * @see org.apache.felix.scr.AbstractComponentManager#deleteComponent()
      */
+    @Override
     protected void deleteComponent( int reason )
     {
         if ( !isStateLocked() )
@@ -90,6 +91,7 @@ public class ServiceFactoryComponentMana
     /* (non-Javadoc)
      * @see org.osgi.framework.ServiceFactory#getService(org.osgi.framework.Bundle, org.osgi.framework.ServiceRegistration)
      */
+    @Override
     public S getService( Bundle bundle, ServiceRegistration<S> serviceRegistration )
     {
         log( LogService.LOG_DEBUG, "ServiceFactory.getService()", null );
@@ -100,8 +102,8 @@ public class ServiceFactoryComponentMana
         if (collectDependencies(componentContext) )
         {
             log( LogService.LOG_DEBUG,
-                "getService (ServiceFactory) dependencies collected.",
-                null );
+                    "getService (ServiceFactory) dependencies collected.",
+                    null );
 
         }
         else
@@ -113,6 +115,7 @@ public class ServiceFactoryComponentMana
         // private ComponentContext and implementation instances
         S service = createImplementationObject( bundle, new SetImplementationObject<S>()
         {
+            @Override
             public void presetComponentContext( ComponentContextImpl<S> componentContext )
             {
                 synchronized ( serviceContexts )
@@ -121,6 +124,7 @@ public class ServiceFactoryComponentMana
                 }
             }
 
+            @Override
             public void resetImplementationObject( S implementationObject )
             {
                 synchronized ( serviceContexts )
@@ -137,10 +141,12 @@ public class ServiceFactoryComponentMana
             // log that the service factory component cannot be created (we don't
             // know why at this moment; this should already have been logged)
             log( LogService.LOG_DEBUG, "Failed creating the component instance; see log for reason", null );
-        } 
-        else 
+            setState(previousState, State.failed);
+
+        }
+        else
         {
-             setState(previousState, State.active);
+            setState(previousState, State.active);
         }
 
         return service;
@@ -150,6 +156,7 @@ public class ServiceFactoryComponentMana
     /* (non-Javadoc)
      * @see org.osgi.framework.ServiceFactory#ungetService(org.osgi.framework.Bundle, org.osgi.framework.ServiceRegistration, java.lang.Object)
      */
+    @Override
     public void ungetService( Bundle bundle, ServiceRegistration<S> registration, S service )
     {
         log( LogService.LOG_DEBUG, "ServiceFactory.ungetService()", null );
@@ -182,6 +189,7 @@ public class ServiceFactoryComponentMana
         }
     }
 
+    @Override
     <T> void invokeBindMethod( DependencyManager<S, T> dependencyManager, RefPair<S, T> refPair, int trackingCount )
     {
         for ( ComponentContextImpl<S> cc : getComponentContexts() )
@@ -190,21 +198,23 @@ public class ServiceFactoryComponentMana
         }
     }
 
+    @Override
     <T> boolean invokeUpdatedMethod( DependencyManager<S, T> dependencyManager, RefPair<S, T> refPair, int trackingCount )
     {
-    	// as all instances are treated the same == have the same updated signatures for methods/fields
-    	// we just need one result
-    	boolean reactivate = false;
+        // as all instances are treated the same == have the same updated signatures for methods/fields
+        // we just need one result
+        boolean reactivate = false;
         for ( ComponentContextImpl<S> cc : getComponentContexts() )
         {
-            if ( dependencyManager.invokeUpdatedMethod( cc, refPair, trackingCount, cc.getEdgeInfo( dependencyManager ) ) ) 
+            if ( dependencyManager.invokeUpdatedMethod( cc, refPair, trackingCount, cc.getEdgeInfo( dependencyManager ) ) )
             {
-            	reactivate = true;
+                reactivate = true;
             }
         }
         return reactivate;
     }
 
+    @Override
     <T> void invokeUnbindMethod( DependencyManager<S, T> dependencyManager, RefPair<S, T> oldRefPair, int trackingCount )
     {
         for ( ComponentContextImpl<S> cc : getComponentContexts() )
@@ -213,6 +223,7 @@ public class ServiceFactoryComponentMana
         }
     }
 
+    @Override
     protected MethodResult invokeModifiedMethod()
     {
         LifecycleMethod modifiedMethod = getComponentMethods().getModifiedMethod();
@@ -226,7 +237,7 @@ public class ServiceFactoryComponentMana
         }
         return result;
     }
-    
+
     @Override
     boolean hasInstance()
     {
@@ -235,6 +246,7 @@ public class ServiceFactoryComponentMana
 
     //---------- Component interface
 
+    @Override
     public ComponentInstance getComponentInstance()
     {
         // TODO: should return the component instance corresponding to the

Modified: felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/manager/SingleComponentManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/manager/SingleComponentManager.java?rev=1781242&r1=1781241&r2=1781242&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/manager/SingleComponentManager.java (original)
+++ felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/manager/SingleComponentManager.java Wed Feb  1 13:17:42 2017
@@ -28,9 +28,9 @@ import java.util.List;
 import java.util.Map;
 import java.util.concurrent.atomic.AtomicInteger;
 
-import org.apache.felix.scr.impl.inject.LifecycleMethod;
 import org.apache.felix.scr.impl.inject.ComponentMethods;
 import org.apache.felix.scr.impl.inject.ConstructorMethod;
+import org.apache.felix.scr.impl.inject.LifecycleMethod;
 import org.apache.felix.scr.impl.inject.MethodResult;
 import org.apache.felix.scr.impl.manager.DependencyManager.OpenStatus;
 import org.apache.felix.scr.impl.metadata.TargetedPID;
@@ -71,7 +71,7 @@ public class SingleComponentManager<S> e
     // null if properties are not to be overwritten
     private Dictionary<String, Object> m_serviceProperties;
 
-   /**
+    /**
      * The constructor receives both the activator and the metadata
      * @param componentMethods
      */
@@ -111,12 +111,14 @@ public class SingleComponentManager<S> e
         {
             S tmpComponent = createImplementationObject( null, new SetImplementationObject<S>()
             {
+                @Override
                 public void presetComponentContext( ComponentContextImpl<S> componentContext )
                 {
                     m_componentContext = componentContext;
                 }
 
 
+                @Override
                 public void resetImplementationObject( S implementationObject )
                 {
                     m_componentContext = null;
@@ -216,7 +218,7 @@ public class SingleComponentManager<S> e
 
 
     @SuppressWarnings("unchecked")
-	protected S createImplementationObject( Bundle usingBundle, SetImplementationObject<S> setter, ComponentContextImpl<S> componentContext )
+    protected S createImplementationObject( Bundle usingBundle, SetImplementationObject<S> setter, ComponentContextImpl<S> componentContext )
     {
         final Class<S> implementationObjectClass;
         S implementationObject = null;
@@ -230,14 +232,14 @@ public class SingleComponentManager<S> e
             log( LogService.LOG_WARNING, "Bundle shut down during instantiation of the implementation object", null);
             return null;
         }
-                
-        // bind target services 
+
+        // bind target services
         final List<DependencyManager.OpenStatus<S, ?>> openStatusList = new ArrayList<DependencyManager.OpenStatus<S,?>>();
-        
+
         final Map<Integer, ConstructorMethod.ReferencePair<S>> paramMap = ( getComponentMetadata().isActivateConstructor() ? new HashMap<Integer, ConstructorMethod.ReferencePair<S>>() : null);
         boolean failed = false;
-	    for ( DependencyManager<S, ?> dm : getDependencyManagers())
-	    {
+        for ( DependencyManager<S, ?> dm : getDependencyManagers())
+        {
             // if a dependency turned unresolved since the validation check,
             // creating the instance fails here, so we deactivate and return
             // null.
@@ -251,69 +253,70 @@ public class SingleComponentManager<S> e
                 break;
             }
             openStatusList.add(open);
-        	if ( dm.getReferenceMetadata().getParameterIndex() != null)
-        	{
-        		final ConstructorMethod.ReferencePair<S> pair = new ConstructorMethod.ReferencePair<S>();
-        		pair.dependencyManager = dm;
-        		pair.openStatus = open;
+            if ( dm.getReferenceMetadata().getParameterIndex() != null)
+            {
+                final ConstructorMethod.ReferencePair<S> pair = new ConstructorMethod.ReferencePair<S>();
+                pair.dependencyManager = dm;
+                pair.openStatus = open;
                 paramMap.put(dm.getReferenceMetadata().getParameterIndex(), pair);
-	        }
-	    }
+            }
+        }
+
+        if ( !failed )
+        {
+            try
+            {
+                // 112.4.4 The class is retrieved with the loadClass method of the component's bundle
+                implementationObjectClass = (Class<S>) bundle.loadClass(
+                        getComponentMetadata().getImplementationClassName() )  ;
+
+                implementationObject = getComponentMethods().getConstructor().newInstance(implementationObjectClass,
+                        componentContext,
+                        paramMap,
+                        this);
+
+            }
+            catch ( Throwable t )
+            {
+                // failed to instantiate, return null
+                log( LogService.LOG_ERROR, "Error during instantiation of the implementation object", t );
+                this.setFailureReason(t);
+                return null;
+            }
+
+            componentContext.setImplementationObject(implementationObject);
 
-	    if ( !failed )
-	    {
-	        try
-	        {
-	            // 112.4.4 The class is retrieved with the loadClass method of the component's bundle
-	            implementationObjectClass = (Class<S>) bundle.loadClass(
-	                    getComponentMetadata().getImplementationClassName() )  ;
-	
-	            implementationObject = getComponentMethods().getConstructor().newInstance(implementationObjectClass,
-	            		componentContext,
-	            		paramMap,
-	            		this);
-	            
-	        }
-	        catch ( Throwable t )
-	        {
-	            // failed to instantiate, return null
-	            log( LogService.LOG_ERROR, "Error during instantiation of the implementation object", t );
-	            return null;
-	        }
-	
-	        componentContext.setImplementationObject(implementationObject);
-	
-	        // 3. set the implementation object prematurely
-	        setter.presetComponentContext( componentContext );
+            // 3. set the implementation object prematurely
+            setter.presetComponentContext( componentContext );
 
-	        // 4. Bind the target services
+            // 4. Bind the target services
             final Iterator<DependencyManager.OpenStatus<S, ?>> iter = openStatusList.iterator();
-	        for ( DependencyManager<S, ?> dm: getDependencyManagers())
-	        {
-	        	final DependencyManager.OpenStatus<S, ?> open = iter.next();
-		        if ( !dm.bind(componentContext, (OpenStatus) open) )
-		        {
+            for ( DependencyManager<S, ?> dm: getDependencyManagers())
+            {
+                final DependencyManager.OpenStatus<S, ?> open = iter.next();
+                if ( !dm.bind(componentContext, (OpenStatus) open) )
+                {
                     log( LogService.LOG_DEBUG, "Cannot create component instance due to failure to bind reference {0}",
                             new Object[] { dm.getName() }, null );
                     failed = true;
                     break;
-		        }
-	        }
-	    }
+                }
+            }
+        }
         if (failed)
         {
             // make sure, we keep no bindings. Only close the dm's we opened.
             int skipCount = getReversedDependencyManagers().size() - openStatusList.size();
             for ( DependencyManager<S, ?> md: getReversedDependencyManagers() )
             {
-            	if ( skipCount > 0 )
-            	{
-            		skipCount--;
-            	} 
-            	else 
-            	{
-            		md.close( componentContext, componentContext.getEdgeInfo( md ) );
-            	}
+                if ( skipCount > 0 )
+                {
+                    skipCount--;
+                }
+                else
+                {
+                    md.close( componentContext, componentContext.getEdgeInfo( md ) );
+                }
                 md.deactivate();
             }
 
@@ -323,10 +326,12 @@ public class SingleComponentManager<S> e
         }
 
         // 5. Call the activate method, if present
+        final MethodResult failedResult = new MethodResult(true, new HashMap<String, Object>());
         final MethodResult result = getComponentMethods().getActivateMethod().invoke( implementationObject,
-                componentContext, 1, null, this );
-        if ( result == null )
+                componentContext, 1, failedResult, this );
+        if ( result == failedResult )
         {
+            this.setFailureReason((Throwable)failedResult.getResult().get("exception"));
             // 112.5.8 If the activate method throws an exception, SCR must log an error message
             // containing the exception with the Log Service and activation fails
             for ( DependencyManager<S, ?> md: getReversedDependencyManagers() )
@@ -336,8 +341,8 @@ public class SingleComponentManager<S> e
 
             if ( implementationObject != null )
             {
-            	// make sure the implementation object is not available
-            	setter.resetImplementationObject( implementationObject );
+                // make sure the implementation object is not available
+                setter.resetImplementationObject( implementationObject );
             }
 
             return null;
@@ -546,7 +551,7 @@ public class SingleComponentManager<S> e
         if (m_componentContext != null)
         {
             m_componentContext.unsetServiceRegistration();
-        }        
+        }
     }
 
     @Override
@@ -832,6 +837,7 @@ public class SingleComponentManager<S> e
         return regProps.equals( props );
     }
 
+    @Override
     public S getService( Bundle bundle, ServiceRegistration<S> serviceRegistration )
     {
         obtainStateLock(  );
@@ -868,7 +874,7 @@ public class SingleComponentManager<S> e
                 //This is backup.  Normally done in createComponent.
                 getActivator().leaveCreate(serviceRegistration.getReference());
             }
-            
+
         }
         finally
         {
@@ -890,14 +896,14 @@ public class SingleComponentManager<S> e
             if ( collectDependencies(componentContext))
             {
                 log( LogService.LOG_DEBUG,
-                    "getService (single component manager) dependencies collected.",
-                    null );
+                        "getService (single component manager) dependencies collected.",
+                        null );
             }
             else
             {
                 log( LogService.LOG_INFO,
-                    "Could not obtain all required dependencies, getService returning null",
-                    null );
+                        "Could not obtain all required dependencies, getService returning null",
+                        null );
                 success = false;
             }
             obtainStateLock(  );
@@ -910,7 +916,8 @@ public class SingleComponentManager<S> e
                     S result = getService(componentContext );
                     if ( result == null )
                     {
-                        success = false;;
+                        success = false;
+                        setState(previousState, State.failed);
                     }
                     else
                     {
@@ -960,6 +967,7 @@ public class SingleComponentManager<S> e
 
     }
 
+    @Override
     public void ungetService( Bundle bundle, ServiceRegistration<S> serviceRegistration, S o )
     {
         obtainStateLock( );

Modified: felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/runtime/ServiceComponentRuntimeImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/runtime/ServiceComponentRuntimeImpl.java?rev=1781242&r1=1781241&r2=1781242&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/runtime/ServiceComponentRuntimeImpl.java (original)
+++ felix/trunk/osgi-r7/scr/src/main/java/org/apache/felix/scr/impl/runtime/ServiceComponentRuntimeImpl.java Wed Feb  1 13:17:42 2017
@@ -50,114 +50,119 @@ import org.osgi.util.promise.Promises;
 public class ServiceComponentRuntimeImpl implements ServiceComponentRuntime
 {
 
-	private static final String[] EMPTY = {};
+    private static final String[] EMPTY = {};
 
-	private final BundleContext context;
-	private final ComponentRegistry componentRegistry;
+    private final BundleContext context;
+    private final ComponentRegistry componentRegistry;
 
 
-	public ServiceComponentRuntimeImpl(BundleContext context,ComponentRegistry componentRegistry)
-	{
-		this.context = context;
-		this.componentRegistry = componentRegistry;
-	}
-
-	/**
-	 * @see org.osgi.service.component.runtime.ServiceComponentRuntime#getComponentDescriptionDTOs(org.osgi.framework.Bundle[])
-	 */
-	public Collection<ComponentDescriptionDTO> getComponentDescriptionDTOs(Bundle... bundles)
-	{
-		List<ComponentHolder<?>> holders;
-		if (bundles == null || bundles.length == 0)
-		{
-			holders = componentRegistry.getComponentHolders();
-		}
-		else
-		{
-			holders = componentRegistry.getComponentHolders(bundles);
-		}
-
-		List<ComponentDescriptionDTO> result = new ArrayList<ComponentDescriptionDTO>(holders.size());
-		for (ComponentHolder<?> holder: holders)
-		{
-		    ComponentDescriptionDTO dto = holderToDescription(holder);
-		    if ( dto != null )
-		    {
-		        result.add(dto);
-		    }
-		}
-		return result;
-	}
-
-	/**
-	 * @see org.osgi.service.component.runtime.ServiceComponentRuntime#getComponentDescriptionDTO(org.osgi.framework.Bundle, java.lang.String)
-	 */
-	public ComponentDescriptionDTO getComponentDescriptionDTO(Bundle bundle, String name)
-	{
-	    ComponentHolder<?> holder = componentRegistry.getComponentHolder(bundle, name);
-		if ( holder != null )
-		{
-			return holderToDescription(holder);
-		}
-		else
-		{
-			return null;
-		}
-	}
-
-	/**
-	 * @see org.osgi.service.component.runtime.ServiceComponentRuntime#getComponentConfigurationDTOs(org.osgi.service.component.runtime.dto.ComponentDescriptionDTO)
-	 */
-	public Collection<ComponentConfigurationDTO> getComponentConfigurationDTOs(ComponentDescriptionDTO description)
-	{
-		if ( description == null)
-		{
-			return Collections.emptyList();
-		}
-		try
-		{
-    		ComponentHolder<?> holder = getHolderFromDescription( description);
-    		// Get a fully filled out valid description DTO
-    		description = holderToDescription(holder);
+    public ServiceComponentRuntimeImpl(BundleContext context,ComponentRegistry componentRegistry)
+    {
+        this.context = context;
+        this.componentRegistry = componentRegistry;
+    }
+
+    /**
+     * @see org.osgi.service.component.runtime.ServiceComponentRuntime#getComponentDescriptionDTOs(org.osgi.framework.Bundle[])
+     */
+    @Override
+    public Collection<ComponentDescriptionDTO> getComponentDescriptionDTOs(Bundle... bundles)
+    {
+        List<ComponentHolder<?>> holders;
+        if (bundles == null || bundles.length == 0)
+        {
+            holders = componentRegistry.getComponentHolders();
+        }
+        else
+        {
+            holders = componentRegistry.getComponentHolders(bundles);
+        }
+
+        List<ComponentDescriptionDTO> result = new ArrayList<ComponentDescriptionDTO>(holders.size());
+        for (ComponentHolder<?> holder: holders)
+        {
+            ComponentDescriptionDTO dto = holderToDescription(holder);
+            if ( dto != null )
+            {
+                result.add(dto);
+            }
+        }
+        return result;
+    }
+
+    /**
+     * @see org.osgi.service.component.runtime.ServiceComponentRuntime#getComponentDescriptionDTO(org.osgi.framework.Bundle, java.lang.String)
+     */
+    @Override
+    public ComponentDescriptionDTO getComponentDescriptionDTO(Bundle bundle, String name)
+    {
+        ComponentHolder<?> holder = componentRegistry.getComponentHolder(bundle, name);
+        if ( holder != null )
+        {
+            return holderToDescription(holder);
+        }
+        else
+        {
+            return null;
+        }
+    }
+
+    /**
+     * @see org.osgi.service.component.runtime.ServiceComponentRuntime#getComponentConfigurationDTOs(org.osgi.service.component.runtime.dto.ComponentDescriptionDTO)
+     */
+    @Override
+    public Collection<ComponentConfigurationDTO> getComponentConfigurationDTOs(ComponentDescriptionDTO description)
+    {
+        if ( description == null)
+        {
+            return Collections.emptyList();
+        }
+        try
+        {
+            ComponentHolder<?> holder = getHolderFromDescription( description);
+            // Get a fully filled out valid description DTO
+            description = holderToDescription(holder);
             if ( description == null)
             {
                 return Collections.emptyList();
             }
-    		List<? extends ComponentManager<?>> managers = holder.getComponents();
-    		List<ComponentConfigurationDTO> result = new ArrayList<ComponentConfigurationDTO>(managers.size());
-    		for (ComponentManager<?> manager: managers)
-    		{
-    			result.add(managerToConfiguration(manager, description));
-    		}
-    		return result;
-		}
-		catch ( IllegalStateException ise)
-		{
-		    return Collections.emptyList();
-		}
-	}
-
-	/**
-	 * @see org.osgi.service.component.runtime.ServiceComponentRuntime#isComponentEnabled(org.osgi.service.component.runtime.dto.ComponentDescriptionDTO)
-	 */
-	public boolean isComponentEnabled(ComponentDescriptionDTO description)
-	{
+            List<? extends ComponentManager<?>> managers = holder.getComponents();
+            List<ComponentConfigurationDTO> result = new ArrayList<ComponentConfigurationDTO>(managers.size());
+            for (ComponentManager<?> manager: managers)
+            {
+                result.add(managerToConfiguration(manager, description));
+            }
+            return result;
+        }
+        catch ( IllegalStateException ise)
+        {
+            return Collections.emptyList();
+        }
+    }
+
+    /**
+     * @see org.osgi.service.component.runtime.ServiceComponentRuntime#isComponentEnabled(org.osgi.service.component.runtime.dto.ComponentDescriptionDTO)
+     */
+    @Override
+    public boolean isComponentEnabled(ComponentDescriptionDTO description)
+    {
         try
         {
-    		ComponentHolder<?> holder = getHolderFromDescription( description);
-	    	return holder.isEnabled();
+            ComponentHolder<?> holder = getHolderFromDescription( description);
+            return holder.isEnabled();
         }
         catch ( IllegalStateException ise)
         {
             return false;
         }
-	}
+    }
 
-	/**
-	 * @see org.osgi.service.component.runtime.ServiceComponentRuntime#enableComponent(org.osgi.service.component.runtime.dto.ComponentDescriptionDTO)
-	 */
-	public Promise<Void> enableComponent(ComponentDescriptionDTO description)
-	{
+    /**
+     * @see org.osgi.service.component.runtime.ServiceComponentRuntime#enableComponent(org.osgi.service.component.runtime.dto.ComponentDescriptionDTO)
+     */
+    @Override
+    public Promise<Void> enableComponent(ComponentDescriptionDTO description)
+    {
         try
         {
             ComponentHolder<?> holder = getHolderFromDescription( description);
@@ -167,13 +172,14 @@ public class ServiceComponentRuntimeImpl
         {
             return Promises.failed(ise);
         }
-	}
+    }
 
-	/**
-	 * @see org.osgi.service.component.runtime.ServiceComponentRuntime#disableComponent(org.osgi.service.component.runtime.dto.ComponentDescriptionDTO)
-	 */
-	public Promise<Void> disableComponent(ComponentDescriptionDTO description)
-	{
+    /**
+     * @see org.osgi.service.component.runtime.ServiceComponentRuntime#disableComponent(org.osgi.service.component.runtime.dto.ComponentDescriptionDTO)
+     */
+    @Override
+    public Promise<Void> disableComponent(ComponentDescriptionDTO description)
+    {
         try
         {
             ComponentHolder<?> holder = getHolderFromDescription( description);
@@ -183,19 +189,23 @@ public class ServiceComponentRuntimeImpl
         {
             return Promises.failed(ise);
         }
-	}
+    }
 
-	private ComponentConfigurationDTO managerToConfiguration(ComponentManager<?> manager, ComponentDescriptionDTO description)
-	{
-		ComponentConfigurationDTO dto = new ComponentConfigurationDTO();
+    private ComponentConfigurationDTO managerToConfiguration(ComponentManager<?> manager, ComponentDescriptionDTO description)
+    {
+        ComponentConfigurationDTO dto = new ComponentConfigurationDTO();
         dto.satisfiedReferences = satisfiedRefManagersToDTO(manager.getReferenceManagers());
         dto.unsatisfiedReferences = unsatisfiedRefManagersToDTO(manager.getReferenceManagers());
-		dto.description = description;
-		dto.id = manager.getId();
-		dto.properties = new HashMap<String, Object>(manager.getProperties());//TODO deep copy?
-		dto.state = manager.getSpecState();
-		return dto;
-	}
+        dto.description = description;
+        dto.id = manager.getId();
+        dto.properties = new HashMap<String, Object>(manager.getProperties());//TODO deep copy?
+        dto.state = manager.getSpecState();
+        if ( dto.state == ComponentConfigurationDTO.FAILED_ACTIVATION )
+        {
+            dto.failure = manager.getFailureReason();
+        }
+        return dto;
+    }
 
     private SatisfiedReferenceDTO[] satisfiedRefManagersToDTO(List<? extends ReferenceManager<?, ?>> referenceManagers)
     {
@@ -249,22 +259,22 @@ public class ServiceComponentRuntimeImpl
         return dtos.toArray( new UnsatisfiedReferenceDTO[dtos.size()] );
     }
 
-	private ServiceReferenceDTO serviceReferenceToDTO( ServiceReference<?> serviceRef)
-	{
-	    if (serviceRef == null)
-	        return null;
-
-		ServiceReferenceDTO dto = new ServiceReferenceDTO();
-		Bundle bundle = serviceRef.getBundle();
-		if (bundle != null)
-		    dto.bundle = bundle.getBundleId();
-		else
-		    dto.bundle = -1; // No bundle ever has -1 as ID, so this indicates no bundle.
-
-		dto.id = (Long) serviceRef.getProperty(Constants.SERVICE_ID);
-		dto.properties = deepCopy( serviceRef );
-		Bundle[] usingBundles = serviceRef.getUsingBundles();
-		if (usingBundles != null)
+    private ServiceReferenceDTO serviceReferenceToDTO( ServiceReference<?> serviceRef)
+    {
+        if (serviceRef == null)
+            return null;
+
+        ServiceReferenceDTO dto = new ServiceReferenceDTO();
+        Bundle bundle = serviceRef.getBundle();
+        if (bundle != null)
+            dto.bundle = bundle.getBundleId();
+        else
+            dto.bundle = -1; // No bundle ever has -1 as ID, so this indicates no bundle.
+
+        dto.id = (Long) serviceRef.getProperty(Constants.SERVICE_ID);
+        dto.properties = deepCopy( serviceRef );
+        Bundle[] usingBundles = serviceRef.getUsingBundles();
+        if (usingBundles != null)
         {
             long[] usingBundleIds = new long[usingBundles.length];
             for (int i = 0; i < usingBundles.length; i++)
@@ -274,55 +284,55 @@ public class ServiceComponentRuntimeImpl
             dto.usingBundles = usingBundleIds;
         }
         return dto;
-	}
+    }
 
-	/**
-	 * Return the component holder
-	 * @param description Component description DTO
-	 * @return The component holder
-	 * @throws IllegalStateException If the bundle is not active anymore
-	 */
-	private ComponentHolder<?> getHolderFromDescription(ComponentDescriptionDTO description)
-	{
-		if (description.bundle == null)
-		{
-			throw new IllegalArgumentException("No bundle supplied in ComponentDescriptionDTO named " + description.name);
-		}
-		long bundleId = description.bundle.id;
-		Bundle b = context.getBundle(bundleId);
-		String name = description.name;
-		return componentRegistry.getComponentHolder(b, name);
-	}
-
-	private ComponentDescriptionDTO holderToDescription( ComponentHolder<?> holder )
-	{
-		ComponentDescriptionDTO dto = new ComponentDescriptionDTO();
-		ComponentMetadata m = holder.getComponentMetadata();
-		dto.activate = m.getActivate();
-		dto.bundle = bundleToDTO(holder.getActivator().getBundleContext());
-		// immediately return if bundle is not active anymore
-		if ( dto.bundle == null )
-		{
-		    return null;
-		}
-		dto.configurationPid = m.getConfigurationPid().toArray(new String[m.getConfigurationPid().size()]);
-		dto.configurationPolicy = m.getConfigurationPolicy();
-		dto.deactivate = m.getDeactivate();
-		dto.defaultEnabled = m.isEnabled();
-		dto.factory = m.getFactoryIdentifier();
-		dto.immediate = m.isImmediate();
-		dto.implementationClass = m.getImplementationClassName();
-		dto.modified = m.getModified();
-		dto.name = m.getName();
-		dto.properties = deepCopy(m.getProperties());
-		dto.references = refsToDTO(m.getDependencies());
-		dto.scope = m.getServiceMetadata() == null? null: m.getServiceMetadata().getScope().name();
-		dto.serviceInterfaces = m.getServiceMetadata() == null? EMPTY: m.getServiceMetadata().getProvides();
-		// DS 1.4
-		dto.factoryProperties = m.isFactory() ? m.getFactoryProperties() : null;
-		dto.activationFields = (m.getActivationFields() == null ? EMPTY : m.getActivationFields().toArray(new String[m.getActivationFields().size()]));
-		return dto;
-	}
+    /**
+     * Return the component holder
+     * @param description Component description DTO
+     * @return The component holder
+     * @throws IllegalStateException If the bundle is not active anymore
+     */
+    private ComponentHolder<?> getHolderFromDescription(ComponentDescriptionDTO description)
+    {
+        if (description.bundle == null)
+        {
+            throw new IllegalArgumentException("No bundle supplied in ComponentDescriptionDTO named " + description.name);
+        }
+        long bundleId = description.bundle.id;
+        Bundle b = context.getBundle(bundleId);
+        String name = description.name;
+        return componentRegistry.getComponentHolder(b, name);
+    }
+
+    private ComponentDescriptionDTO holderToDescription( ComponentHolder<?> holder )
+    {
+        ComponentDescriptionDTO dto = new ComponentDescriptionDTO();
+        ComponentMetadata m = holder.getComponentMetadata();
+        dto.activate = m.getActivate();
+        dto.bundle = bundleToDTO(holder.getActivator().getBundleContext());
+        // immediately return if bundle is not active anymore
+        if ( dto.bundle == null )
+        {
+            return null;
+        }
+        dto.configurationPid = m.getConfigurationPid().toArray(new String[m.getConfigurationPid().size()]);
+        dto.configurationPolicy = m.getConfigurationPolicy();
+        dto.deactivate = m.getDeactivate();
+        dto.defaultEnabled = m.isEnabled();
+        dto.factory = m.getFactoryIdentifier();
+        dto.immediate = m.isImmediate();
+        dto.implementationClass = m.getImplementationClassName();
+        dto.modified = m.getModified();
+        dto.name = m.getName();
+        dto.properties = deepCopy(m.getProperties());
+        dto.references = refsToDTO(m.getDependencies());
+        dto.scope = m.getServiceMetadata() == null? null: m.getServiceMetadata().getScope().name();
+        dto.serviceInterfaces = m.getServiceMetadata() == null? EMPTY: m.getServiceMetadata().getProvides();
+        // DS 1.4
+        dto.factoryProperties = m.isFactory() ? m.getFactoryProperties() : null;
+        dto.activationFields = (m.getActivationFields() == null ? EMPTY : m.getActivationFields().toArray(new String[m.getActivationFields().size()]));
+        return dto;
+    }
 
     private Map<String, Object> deepCopy(Map<String, Object> source)
     {
@@ -346,16 +356,16 @@ public class ServiceComponentRuntimeImpl
     }
 
     Object convert(Object source)
-	{
-	    if (source.getClass().isArray())
-	    {
-	        Class<?> type = source.getClass().getComponentType();
-	        if (checkType(type))
-	        {
-	            return source;
-	        }
-	        return String.valueOf(source);
-	        /* array copy code in case it turns out to be needed
+    {
+        if (source.getClass().isArray())
+        {
+            Class<?> type = source.getClass().getComponentType();
+            if (checkType(type))
+            {
+                return source;
+            }
+            return String.valueOf(source);
+            /* array copy code in case it turns out to be needed
 	        int length = Array.getLength(source);
             Object copy = Array.newInstance(type, length);
 	        for (int i = 0; i<length; i++)
@@ -363,14 +373,14 @@ public class ServiceComponentRuntimeImpl
 	            Array.set(copy, i, Array.get(source, i));
 	        }
 	        return copy;
-	        */
-	    }
-	    if (checkType(source.getClass()))
-	    {
-	        return source;
-	    }
-	    return String.valueOf(source);
-	}
+             */
+        }
+        if (checkType(source.getClass()))
+        {
+            return source;
+        }
+        return String.valueOf(source);
+    }
 
     boolean checkType(Class<?> type)
     {
@@ -381,40 +391,40 @@ public class ServiceComponentRuntimeImpl
         return false;
     }
 
-	private ReferenceDTO[] refsToDTO(List<ReferenceMetadata> dependencies)
-	{
-		ReferenceDTO[] dtos = new ReferenceDTO[dependencies.size()];
-		int i = 0;
-		for (ReferenceMetadata r: dependencies)
-		{
-			ReferenceDTO dto = new ReferenceDTO();
-			dto.bind = r.getBind();
-			dto.cardinality = r.getCardinality();
-			dto.field = r.getField();
-			dto.fieldOption = r.getFieldOption();
-			dto.interfaceName = r.getInterface();
-			dto.name = r.getName();
-			dto.policy = r.getPolicy();
-			dto.policyOption = r.getPolicyOption();
-			dto.scope = r.getScope().name();
-			dto.target = r.getTarget();
-			dto.unbind = r.getUnbind();
-			dto.updated = r.getUpdated();
-			// DS 1.4
-			dto.parameter = r.getParameterIndex();
-			dto.collectionType = r.getFieldCollectionType();
-			dtos[i++] = dto;
-		}
-		return dtos;
-	}
-
-	private BundleDTO bundleToDTO(BundleContext bundleContext)
-	{
-		if (bundleContext == null)
-		{
-			return null;
-		}
-		try
+    private ReferenceDTO[] refsToDTO(List<ReferenceMetadata> dependencies)
+    {
+        ReferenceDTO[] dtos = new ReferenceDTO[dependencies.size()];
+        int i = 0;
+        for (ReferenceMetadata r: dependencies)
+        {
+            ReferenceDTO dto = new ReferenceDTO();
+            dto.bind = r.getBind();
+            dto.cardinality = r.getCardinality();
+            dto.field = r.getField();
+            dto.fieldOption = r.getFieldOption();
+            dto.interfaceName = r.getInterface();
+            dto.name = r.getName();
+            dto.policy = r.getPolicy();
+            dto.policyOption = r.getPolicyOption();
+            dto.scope = r.getScope().name();
+            dto.target = r.getTarget();
+            dto.unbind = r.getUnbind();
+            dto.updated = r.getUpdated();
+            // DS 1.4
+            dto.parameter = r.getParameterIndex();
+            dto.collectionType = r.getFieldCollectionType();
+            dtos[i++] = dto;
+        }
+        return dtos;
+    }
+
+    private BundleDTO bundleToDTO(BundleContext bundleContext)
+    {
+        if (bundleContext == null)
+        {
+            return null;
+        }
+        try
         {
             Bundle bundle = bundleContext.getBundle();
             if (bundle == null)
@@ -433,5 +443,5 @@ public class ServiceComponentRuntimeImpl
         {
             return null;
         }
-	}
+    }
 }

Modified: felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/CircularReferenceTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/CircularReferenceTest.java?rev=1781242&r1=1781241&r2=1781242&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/CircularReferenceTest.java (original)
+++ felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/CircularReferenceTest.java Wed Feb  1 13:17:42 2017
@@ -74,7 +74,7 @@ public class CircularReferenceTest exten
     public void test_A11_B0n_immediate_A_first() throws InvalidSyntaxException
     {
         String componentNameA = "2.A.1.1.dynamic";
-        final ComponentConfigurationDTO componentA = findComponentConfigurationByName( componentNameA, ComponentConfigurationDTO.SATISFIED | ComponentConfigurationDTO.ACTIVE );
+        final ComponentConfigurationDTO componentA = findComponentConfigurationByName( componentNameA, ComponentConfigurationDTO.FAILED_ACTIVATION | ComponentConfigurationDTO.ACTIVE );
         A a = getServiceFromConfiguration(componentA, A.class);
         assertEquals( 1, a.getBs().size());
 
@@ -176,7 +176,7 @@ public class CircularReferenceTest exten
     public void test_A11_B01_immediate_A_first() throws InvalidSyntaxException
     {
         String componentNameA = "5.A.1.1.dynamic";
-        final ComponentConfigurationDTO componentA = findComponentConfigurationByName( componentNameA, ComponentConfigurationDTO.SATISFIED | ComponentConfigurationDTO.ACTIVE );
+        final ComponentConfigurationDTO componentA = findComponentConfigurationByName( componentNameA, ComponentConfigurationDTO.FAILED_ACTIVATION | ComponentConfigurationDTO.ACTIVE );
         A a = getServiceFromConfiguration(componentA, A.class);
         assertEquals( 1, a.getBs().size());
 

Modified: felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ComponentActivationTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ComponentActivationTest.java?rev=1781242&r1=1781241&r2=1781242&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ComponentActivationTest.java (original)
+++ felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/ComponentActivationTest.java Wed Feb  1 13:17:42 2017
@@ -95,7 +95,7 @@ public class ComponentActivationTest ext
         final String componentname = "ActivatorComponent.activate.fail";
 
         // activate must fail, so state remains SATISFIED
-        ComponentConfigurationDTO cc = getDisabledConfigurationAndEnable(componentname, ComponentConfigurationDTO.SATISFIED);
+        ComponentConfigurationDTO cc = getDisabledConfigurationAndEnable(componentname, ComponentConfigurationDTO.FAILED_ACTIVATION);
 
         disableAndCheck( cc );
     }

Modified: felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/Felix5248Test.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/Felix5248Test.java?rev=1781242&r1=1781241&r2=1781242&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/Felix5248Test.java (original)
+++ felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/Felix5248Test.java Wed Feb  1 13:17:42 2017
@@ -48,7 +48,7 @@ public class Felix5248Test extends Compo
 
         String componentName = "Component";
         ComponentConfigurationDTO component = findComponentConfigurationByName( componentName,
-                ComponentConfigurationDTO.SATISFIED );
+                ComponentConfigurationDTO.FAILED_ACTIVATION );
         log.log( LogService.LOG_INFO, "A checked satisfied (not active)" );
 
         props.clear();

Modified: felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/PersistentComponentFactoryTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/PersistentComponentFactoryTest.java?rev=1781242&r1=1781241&r2=1781242&view=diff
==============================================================================
--- felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/PersistentComponentFactoryTest.java (original)
+++ felix/trunk/osgi-r7/scr/src/test/java/org/apache/felix/scr/integration/PersistentComponentFactoryTest.java Wed Feb  1 13:17:42 2017
@@ -117,7 +117,7 @@ public class PersistentComponentFactoryT
         final ComponentInstance instance = factory.newInstance( props );
         TestCase.assertNotNull( instance );
 
-        checkConfigurationCount( componentname, 1, ComponentConfigurationDTO.SATISFIED );
+        checkConfigurationCount( componentname, 1, ComponentConfigurationDTO.FAILED_ACTIVATION );
     }
 
     @Test