Skip to content

Commit

Permalink
FELIX-5775 : Service properties not updated for lazy service when con…
Browse files Browse the repository at this point in the history
…figuration changes

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1821754 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
cziegeler committed Jan 20, 2018
1 parent 4ca423d commit 432efad
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,7 @@ public final Promise<Void> enable(final boolean async)

long count = taskCounter.incrementAndGet();

@Override
public void run()
{
try
Expand Down Expand Up @@ -537,6 +538,7 @@ public final Promise<Void> disable(final boolean async)

long count = taskCounter.incrementAndGet();

@Override
public void run()
{
try
Expand Down Expand Up @@ -591,6 +593,7 @@ <T> void registerMissingDependency(DependencyManager<S, T> dm, ServiceReference<

//---------- Component interface ------------------------------------------

@Override
public long getId()
{
return m_componentId;
Expand Down Expand Up @@ -969,6 +972,11 @@ protected boolean unregisterService()
return true;
}

protected ServiceRegistration<S> getServiceRegistration()
{
return registrationManager.getServiceRegistration();
}

AtomicInteger getTrackingCount()
{
return m_trackingCount;
Expand Down Expand Up @@ -1085,6 +1093,7 @@ synchronized void clear()
/**
* Returns <code>true</code> if logging for the given level is enabled.
*/
@Override
public boolean isLogEnabled(int level)
{
ComponentActivator activator = getActivator();
Expand All @@ -1095,6 +1104,7 @@ public boolean isLogEnabled(int level)
return false;
}

@Override
public void log(int level, String message, Throwable ex)
{
ComponentActivator activator = getActivator();
Expand All @@ -1104,6 +1114,7 @@ public void log(int level, String message, Throwable ex)
}
}

@Override
public void log(int level, String message, Object[] arguments, Throwable ex)
{
ComponentActivator activator = getActivator();
Expand Down Expand Up @@ -1227,6 +1238,7 @@ else if (!dm.isSatisfied())
return m_dependencyManagers;
}

@Override
public List<? extends ReferenceManager<S, ?>> getReferenceManagers()
{
return m_dependencyManagers;
Expand Down Expand Up @@ -1279,6 +1291,7 @@ private void disableDependencyManagers()
/* (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);
Expand Down Expand Up @@ -1401,6 +1414,7 @@ public ComponentMetadata getComponentMetadata()
return m_container.getComponentMetadata();
}

@Override
public int getSpecState()
{
return getState().getSpecState();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.apache.felix.scr.impl.helper.ComponentMethod;
import org.apache.felix.scr.impl.helper.ComponentMethods;
import org.apache.felix.scr.impl.helper.MethodResult;
import org.apache.felix.scr.impl.metadata.DSVersion;
import org.apache.felix.scr.impl.metadata.TargetedPID;
import org.osgi.framework.Bundle;
import org.osgi.framework.Constants;
Expand Down Expand Up @@ -108,12 +109,14 @@ private boolean createComponent(ComponentContextImpl<S> componentContext)
{
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;
Expand Down Expand Up @@ -515,7 +518,7 @@ void preDeregister()
if (m_componentContext != null)
{
m_componentContext.unsetServiceRegistration();
}
}
}

@Override
Expand All @@ -528,9 +531,14 @@ public Dictionary<String, Object> getServiceProperties()
return super.getServiceProperties();
}

final ServiceRegistration<S> getServiceRegistration()
@Override
protected ServiceRegistration<S> getServiceRegistration()
{
return m_componentContext == null? null: m_componentContext.getServiceRegistration();
if ( getComponentMetadata().getDSVersion() == DSVersion.DS12Felix )
{
return m_componentContext != null ? m_componentContext.getServiceRegistration() : null;
}
return super.getServiceRegistration();
}


Expand Down Expand Up @@ -801,6 +809,7 @@ private boolean servicePropertiesMatches( ServiceRegistration<S> reg, Dictionary
return regProps.equals( props );
}

@Override
public S getService( Bundle bundle, ServiceRegistration<S> serviceRegistration )
{
if ( getActivator().enterCreate( serviceRegistration.getReference() ) )
Expand Down Expand Up @@ -838,7 +847,7 @@ public S getService( Bundle bundle, ServiceRegistration<S> serviceRegistration )
//This is backup. Normally done in createComponent.
getActivator().leaveCreate(serviceRegistration.getReference());
}

}
finally
{
Expand Down Expand Up @@ -930,6 +939,7 @@ private S getService(ComponentContextImpl<S> componentContext)

}

@Override
public void ungetService( Bundle bundle, ServiceRegistration<S> serviceRegistration, S o )
{
obtainStateLock( );
Expand Down

0 comments on commit 432efad

Please sign in to comment.