/** * Catches our DependencyManager handle from our component init method. */ public void init(Component c) { m_manager = c.getDependencyManager(); m_decoratorComponent = (ComponentContext) c; }
/** * Our Service is starting. */ public void start(Component c) { m_active = true; m_dm = c.getDependencyManager(); }
/** * Our Service is starting. */ public void start(Component c) { m_active = true; m_dm = c.getDependencyManager(); }
/** * Invoke a callback on all Service compositions. */ private void callbackComposites(Component service, String callback) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException { Object[] composites = service.getInstances(); for (Object composite: composites) { invokeMethod(composite, callback, service.getDependencyManager(), service); } }
/** * Called by Felix DM when stopping this component. */ protected void stop( final Component component ) throws IOException { BundleContext context = component.getDependencyManager().getBundleContext(); File repositoryFile = getRepositoryFile( context ); // Store the earlier provisioned configurations (just to be sure)... this.repository.store( repositoryFile ); }
DependencyManager dm = service.getDependencyManager(); Map<String, String> extraProperties = new HashMap<String, String>(); Object[] composites = service.getInstances();
@Override public ConfigurationDependency build() { String pid = m_pid == null ? (m_configType != null ? m_configType.getName() : null) : m_pid; if (pid == null) { throw new IllegalStateException("Pid not specified"); } ConfigurationDependency dep = m_component.getDependencyManager().createConfigurationDependency(); Objects.nonNull(m_pid); dep.setPid(pid); dep.setPropagate(m_propagate); dep.setRequired(m_required); if (m_updateMethodName != null) { dep.setCallback(m_updateCallbackInstance, m_updateMethodName, m_configType); } else if (m_refs.size() > 0) { // setup an internal callback object. When config is updated, we have to call each registered // method references. // Notice that we need the component to be instantiated in case there is a mref on one of the component instances (unbound method ref), or is used // called "needsInstance(true)". dep.setCallback(new Object() { @SuppressWarnings("unused") void updated(Component comp, Dictionary<String, Object> props) { m_refs.forEach(mref -> mref.accept(null, comp, props)); } }, "updated", m_hasComponentCallbackRefs); } return dep; }
private boolean mayStartNow(Component c) { ComponentExecutorFactory execFactory = m_componentExecutorFactory; BundleContext ctx = c.getDependencyManager().getBundleContext(); String parallel = ctx.getProperty(PARALLEL); if (execFactory == null) { // No ComponentExecutorFactory available. If a "parallel" OSGi system property is specified, // we have to wait for a ComponentExecutorFactory servoce if the component class name is matching one of the // prefixes specified in the "parallel" system property. if (parallel != null && requiresThreadPool(c, parallel)) { return false; // wait for a threadpool } else { return true; // no threadpool required, start the component now, synchronously } } else { // A threadpool is there. If the "parallel" OSGi system property is not specified, we can start the component // now and we'll use the threadpool for it. // But if the "parallel" system property is specified, the component will use the threadpool only if it's // classname is starting with one of the prefixes specified in the property. if (parallel == null || requiresThreadPool(c, parallel)) { createComponentExecutor(execFactory, c); } return true; // start the component now, possibly using the threadpool (see above). } }
private void addDependency(Component component, Class<?> service, boolean isRequired) { component.add(component.getDependencyManager().createServiceDependency().setService(service) .setRequired(isRequired)); }
/** * Called when this class is registered as OSGi service. * * @param aComponent * the bundle context to use, cannot be <code>null</code>. */ protected void init( final Component aComponent ) { DependencyManager dependencyManager = aComponent.getDependencyManager(); aComponent // .add( dependencyManager.createServiceDependency() // .setService( LogService.class ) // .setRequired( false ) // ); }
/** * Called by Felix DM when initializing this component. */ protected void init(org.apache.felix.dm.Component component) { DependencyManager dm = component.getDependencyManager(); component.add(dm.createServiceDependency() .setService(UIExtensionFactory.class, "(" + UIExtensionFactory.EXTENSION_POINT_KEY + "=" + UIExtensionFactory.EXTENSION_POINT_VALUE_MENU + ")") .setCallbacks("add", "remove") .setRequired(false)); }
private void init(Component component) { populate(); DependencyManager dm = component.getDependencyManager(); component.add(dm.createServiceDependency() .setInstanceBound(true) .setService(UIExtensionFactory.class, "(" + UIExtensionFactory.EXTENSION_POINT_KEY + "=" + m_extensionPoint + ")") .setCallbacks("addExtension", "removeExtension") ); }
/** * Called by the dependency manager upon initialization of this component. * * @param component * the component representing this object. */ public void init(Component component) { populate(); DependencyManager dm = component.getDependencyManager(); component.add(dm .createServiceDependency() .setService(UIExtensionFactory.class, "(" + UIExtensionFactory.EXTENSION_POINT_KEY + "=" + m_extensionPoint + ")") .setCallbacks("addExtension", "removeExtension")); }
/** * Called by Felix DM when starting this component. */ protected void start( final Component component ) throws IOException { BundleContext context = component.getDependencyManager().getBundleContext(); File configDir = getConfigDirectory( context ); File repositoryFile = getRepositoryFile( context ); // Load the earlier provisioned configurations... this.repository.load( repositoryFile ); try { provisionAll( configDir ); } finally { // Store the earlier provisioned configurations... this.repository.store( repositoryFile ); } }
DependencyManager dm = c.getDependencyManager();
@Override public ServiceDependency build() { DependencyManager dm = m_component.getDependencyManager(); if (m_ref != null && m_filter != null) { throw new IllegalArgumentException("Can not set ref and filter at the same time");
@Override public BundleDependency build() { DependencyManager dm = m_component.getDependencyManager();
DependencyManager dm = c.getDependencyManager(); boolean autoConfigureComponents = "true".equals(dm.getBundleContext().getProperty( Activator.CONF_ENABLE_AUTOCONFIG));