/** * Creates a new Bundle Adapter Service implementation. */ public BundleAdapterImpl(DependencyManager dm) { super(dm.createComponent()); // This service will be filtered by our super class, allowing us to take control. }
/** * Creates a new component. * * @return the new component */ public Component createComponent() { return m_manager.createComponent(); }
/** * Creates a new Adapter Service implementation. */ public AdapterServiceImpl(DependencyManager dm) { super(dm.createComponent()); }
public ComponentBuilderImpl(DependencyManager dm) { m_component = dm.createComponent(); m_componentUpdated = false; }
public AspectServiceImpl(DependencyManager dm) { super(dm.createComponent()); }
public ResourceAdapterImpl(DependencyManager dm) { super(dm.createComponent()); // This service will be filtered by our super class, allowing us to take control. }
public ServiceImpl(DependencyManager dm) { org.apache.felix.dm.DependencyManager dmDelegate = (org.apache.felix.dm.DependencyManager) dm.getDelegate(); m_delegate = dmDelegate.createComponent(); }
public FactoryConfigurationAdapterImpl(DependencyManager dm) { super(dm.createComponent()); m_logger = dm.getLogger(); }
private void addListener(final Object implementation, final String... topics) { Properties props = new Properties(); props.put(EventConstants.EVENT_TOPIC, topics); props.put(EventConstants.EVENT_FILTER, "(" + SessionFactory.SERVICE_SID + "=" + m_sessionID + ")"); Component component = m_manager.createComponent() .setInterface(EventHandler.class.getName(), props) .setImplementation(implementation); synchronized (m_eventHandlers) { m_eventHandlers.add(component); } m_manager.add(component); }
@SuppressWarnings("unchecked") private <T extends RepositoryObject> Component[] registerRepository(Class<? extends ObjectRepository<T>> iface, ObjectRepositoryImpl<?, T> imp, String[] topics) { Component repositoryService = m_manager.createComponent() .setInterface(iface.getName(), m_sessionProps) .setImplementation(imp) .add(m_manager.createServiceDependency().setService(LogService.class).setRequired(false)); Dictionary topic = new Hashtable(); topic.put(EventConstants.EVENT_TOPIC, topics); topic.put(EventConstants.EVENT_FILTER, "(" + SessionFactory.SERVICE_SID + "=" + m_sessionID + ")"); Component handlerService = m_manager.createComponent() .setInterface(EventHandler.class.getName(), topic) .setImplementation(imp); m_manager.add(repositoryService); m_manager.add(handlerService); return new Component[] {repositoryService, handlerService}; }
private void addListener(final Object implementation, final String topic) { m_manager.add(m_manager.createComponent() .setInterface(EventHandler.class.getName(), new Properties() {{ put(EventConstants.EVENT_TOPIC, topic); put(EventConstants.EVENT_FILTER, "(" + SessionFactory.SERVICE_SID + "=" + m_sessionID + ")"); }}) .setImplementation(implementation) ); }
@Override public void init(BundleContext context, DependencyManager manager) throws Exception { // publish access manager accessManager = manager.createComponent(); accessManager.setInterface(AccessManager.class.getName(), null); accessManager.setImplementation(LocalAccessManager.class); accessManager.add(createServiceDependency().setService(ExecutorManager.class).setRequired(true)); manager.add(accessManager); // register OIDC application context.registerService(HubWebApplication.class.getName(), new HubWebApplication("", AuthApplication.class), null); }
/** * Called by Dependency Manager upon initialization of this component. */ public void init( final Component aComponent ) throws Exception { Dictionary<?, ?> bundleProps = this.bundle.getHeaders(); String entry = ( String )bundleProps.get( this.headerKey ); if ( ( entry == null ) || "".equals( entry ) ) { throw new IllegalArgumentException( "No such header given: " + this.headerKey ); } Class<?> implClass = this.bundle.loadClass( entry ); Properties serviceProps = copyOlsProperties( bundleProps ); this.serviceComponent = this.manager.createComponent() // .setInterface( this.serviceClass.getName(), serviceProps ) // .setImplementation( implClass ) // .add( this.manager.createServiceDependency() // .setService( LogService.class ) // .setRequired( false ) // ); this.manager.add( this.serviceComponent ); }
public void commit() { m_log.log(LogService.LOG_DEBUG, "commit"); Dictionary properties = new Properties(); properties.put(EventConstants.EVENT_TOPIC, EVENTTOPIC_COMPLETE); m_component = m_dm.createComponent() .setInterface(EventHandler.class.getName(), properties) .setImplementation(this) .setCallbacks(null, null, null, null) .setAutoConfig(Component.class, false) .add(m_dm.createServiceDependency() .setService(ConfigurationAdmin.class) .setCallbacks("addConfigurationAdmin", null) .setRequired(false) ); m_dm.add(m_component); m_log.log(LogService.LOG_DEBUG, "commit done"); }
@Test public void testASingleComponentShouldNotRegisterAsFailure() { OUT.println("testASingleComponentShouldNotRegisterAsFailure"); setupEmptyBundles(); dm.add(dm.createComponent() .setImplementation(Object.class) .setInterface(Object.class.getName(), null) ); dme.wtf(); assertEquals("No unregistered components found\n", outContent.toString()); }
@Test public void testComponentThatDependsOnAOtheComponentShouldRegisterAsFailure() { OUT.println("testComponentThatDependsOnAOtheComponentShouldRegisterAsFailure"); setupEmptyBundles(); DependencyManager dm = new DependencyManager(m_bundleContext); DependencyManager.getDependencyManagers().add(dm); Component component = dm.createComponent() .setImplementation(Object.class) .setInterface(Object.class.getName(), null) .add(dm.createServiceDependency().setService(Math.class).setRequired(true)); dm.add(component); dme.wtf(); String output = outContent.toString(); assertTrue(output.contains("1 unregistered")); assertTrue(output.contains("java.lang.Math")); // remove the mess dm.remove(component); }
@Test public void testComponentThatHaveCycliclyDependencyOnAOtheComponentShouldRegisterAsFailure() { OUT.println("testComponentThatHaveCycliclyDependencyOnAOtheComponentShouldRegisterAsFailure"); setupEmptyBundles(); DependencyManager dm = new DependencyManager(m_bundleContext); DependencyManager.getDependencyManagers().add(dm); Component component1 = dm.createComponent() .setImplementation(Cipher.class) .setInterface(Cipher.class.getName(), null) .add(dm.createServiceDependency().setService(Math.class).setRequired(true)); dm.add(component1); Component component2 = dm.createComponent() .setImplementation(Math.class) .setInterface(Math.class.getName(), null) .add(dm.createServiceDependency().setService(Cipher.class).setRequired(true)); dm.add(component2); dme.wtf(); String output = outContent.toString(); assertTrue(output.contains("-> java.lang.Math -> javax.crypto.Cipher -> java.lang.Math") || output.contains("-> javax.crypto.Cipher -> java.lang.Math -> javax.crypto.Cipher")); // remove the mess dm.remove(component1); dm.remove(component2); }
@Test public void testCanFindRootFailureWithTwoFailures() { OUT.println("testCanFindRootFailureWithTwoFailures"); setupEmptyBundles(); Component component1 = dm.createComponent() .setImplementation(Object.class) .setInterface(Object.class.getName(), null) .add(dm.createServiceDependency().setService(Math.class).setRequired(true)) .add(dm.createServiceDependency().setService(Long.class).setRequired(true)); dm.add(component1); dme.wtf(); String output = outContent.toString(); assertTrue(output.contains("1 unregistered")); assertTrue(output.contains("java.lang.Math")); assertTrue(output.contains("java.lang.Long")); // remove the mess dm.remove(component1); }
@Test public void testCanFindRootFailure() { OUT.println("testCanFindRootFailure"); setupEmptyBundles(); Component component1 = dm.createComponent() .setImplementation(Object.class) .setInterface(Object.class.getName(), null) .add(dm.createServiceDependency().setService(Math.class).setRequired(true)); dm.add(component1); Component component2 = dm.createComponent() .setImplementation(Math.class) .setInterface(Math.class.getName(), null) .add(dm.createServiceDependency().setService(String.class).setRequired(true)); dm.add(component2); dme.wtf(); String output = outContent.toString(); assertTrue(output.contains("2 unregistered")); assertTrue(output.contains("java.lang.String")); // remove the mess dm.remove(component1); dm.remove(component2); }
@Override protected Application getNewApplication(HttpServletRequest request) throws ServletException { Application application = new VaadinClient(m_aceHost, m_obrUrl); m_manager.add(m_manager.createComponent() .setImplementation(application) .setCallbacks("setupDependencies", "start", "stop", "destroyDependencies") .add(m_manager.createServiceDependency() .setService(SessionFactory.class) .setRequired(true) ) .add(m_manager.createServiceDependency() .setService(UserAdmin.class) .setRequired(true) ) .add(m_manager.createServiceDependency() .setService(LogService.class) .setRequired(false) ) ); return application; }