use of org.apache.felix.dm.context.ComponentContext in project felix by apache.
the class ConfigurationDependencyImplTest method createConfigurationDependency.
private ConfigurationDependencyImpl createConfigurationDependency(Object service) {
BundleContext bc = mock(BundleContext.class);
Logger mockLogger = mock(Logger.class);
ComponentContext component = mock(ComponentContext.class);
when(component.getExecutor()).thenReturn(Executors.newSingleThreadExecutor());
when(component.getLogger()).thenReturn(mockLogger);
ConfigurationDependencyImpl result = new ConfigurationDependencyImpl(bc, mockLogger);
result.setCallback(service, "updated").setPid("does.not.matter");
result.setComponentContext(component);
result.start();
return result;
}
use of org.apache.felix.dm.context.ComponentContext in project felix by apache.
the class ComponentBuilderImpl method invokeCallbacks.
private void invokeCallbacks(Component component, Object callbackInstance, String callback, String defaultCallback) {
boolean logIfNotFound = (callback != null);
callback = callback != null ? callback : defaultCallback;
ComponentContext ctx = (ComponentContext) component;
Object[] instances = callbackInstance != null ? new Object[] { callbackInstance } : ctx.getInstances();
ctx.invokeCallbackMethod(instances, callback, new Class[][] { { Component.class }, {} }, new Object[][] { { component }, {} }, logIfNotFound);
}
use of org.apache.felix.dm.context.ComponentContext in project felix by apache.
the class Helpers method isDependencyRequiredByDefault.
/**
* Is a dependency required by default ?
*
* @param c the component on which the dependency is added
* @param ctx the bundle context
* @return true if the dependency is required by default, false if not
*/
public static boolean isDependencyRequiredByDefault(Component c) {
BundleContext ctx = ((ComponentContext) c).getBundleContext();
String defaultRequiredDependency = ctx.getProperty(DEFAULT_REQUIRED_DEPENDENCY);
if (defaultRequiredDependency != null) {
defaultRequiredDependency = defaultRequiredDependency.trim();
String componentName = c.getComponentDeclaration().getClassName();
for (String pkg : defaultRequiredDependency.split(",")) {
if (componentName.startsWith(pkg)) {
return true;
}
}
}
return false;
}
Aggregations