public Object run() throws ConfigurationException { service.updated( pid, properties ); return null; } }, getAccessControlContext( reference.getBundle() ) );
public Object run() { service.deleted( pid ); return null; } }, getAccessControlContext( reference.getBundle() ) );
public Object run() throws ConfigurationException { service.updated( pid, properties ); return null; } }, getAccessControlContext( reference.getBundle() ) );
public Object run() { service.deleted( pid ); return null; } }, getAccessControlContext( reference.getBundle() ) );
public void updated(String pid, Dictionary<String, ?> properties) throws ConfigurationException { m_managedServiceFactoryDelegate.updated(pid, properties); } }
public void deleted(String pid) { m_managedServiceFactoryDelegate.deleted(pid); }
@Test public void testInvokeFancyUpdatedMethodOk() throws Exception { Ensure ensure = createEnsure(); FancyService service = new FancyService(ensure); FactoryConfigurationAdapterImpl cdi = createConfigurationDependency(service, MyConfiguration.class); ((ManagedServiceFactory) cdi.m_component.getInstance()).updated(CONF_PID, (Dictionary<String, ?>) createDictionary()); ensure.waitForStep(1, 1000); ((ManagedServiceFactory) cdi.m_component.getInstance()).deleted(CONF_PID); ensure.waitForStep(2, 1000); }
private void updated( final ServiceReference<ManagedServiceFactory> reference, final ManagedServiceFactory service, final String pid, final Dictionary properties ) throws ConfigurationException { if ( System.getSecurityManager() != null ) { try { AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws ConfigurationException { service.updated( pid, properties ); return null; } }, getAccessControlContext( reference.getBundle() ) ); } catch ( PrivilegedActionException e ) { throw ( ConfigurationException ) e.getException(); } } else { service.updated( pid, properties ); } }
private void deleted( final ServiceReference<ManagedServiceFactory> reference, final ManagedServiceFactory service, final String pid ) { if ( System.getSecurityManager() != null ) { AccessController.doPrivileged( new PrivilegedAction() { public Object run() { service.deleted( pid ); return null; } }, getAccessControlContext( reference.getBundle() ) ); } else { service.deleted( pid ); } } }
@Test public void testInvokeManagedServiceUpdatedMethodOk() throws Exception { Ensure ensure = createEnsure(); AManagedService service = new AManagedService(ensure); FactoryConfigurationAdapterImpl cdi = createConfigurationDependency(service); ((ManagedServiceFactory) cdi.m_component.getInstance()).updated(CONF_PID, (Dictionary<String, ?>) createDictionary()); ensure.waitForStep(1, 1000); ((ManagedServiceFactory) cdi.m_component.getInstance()).deleted(CONF_PID); ensure.waitForStep(2, 1000); }
private void updated( final ServiceReference<ManagedServiceFactory> reference, final ManagedServiceFactory service, final String pid, final Dictionary properties ) throws ConfigurationException { if ( System.getSecurityManager() != null ) { try { AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws ConfigurationException { service.updated( pid, properties ); return null; } }, getAccessControlContext( reference.getBundle() ) ); } catch ( PrivilegedActionException e ) { throw ( ConfigurationException ) e.getException(); } } else { service.updated( pid, properties ); } }
private void deleted( final ServiceReference<ManagedServiceFactory> reference, final ManagedServiceFactory service, final String pid ) { if ( System.getSecurityManager() != null ) { AccessController.doPrivileged( new PrivilegedAction() { public Object run() { service.deleted( pid ); return null; } }, getAccessControlContext( reference.getBundle() ) ); } else { service.deleted( pid ); } } }
@Test public void testInvokePlainUpdatedMethodOk() throws Exception { Ensure ensure = createEnsure(); PlainService service = new PlainService(ensure); FactoryConfigurationAdapterImpl cdi = createConfigurationDependency(service); ((ManagedServiceFactory) cdi.m_component.getInstance()).updated(CONF_PID, (Dictionary<String, ?>) createDictionary()); ensure.waitForStep(1, 1000); ((ManagedServiceFactory) cdi.m_component.getInstance()).deleted(CONF_PID); ensure.waitForStep(2, 1000); }
@Override public ServiceFactory addingService(ServiceReference<ServiceFactory> reference) { ServiceFactory factory = context.getService(reference); if(factory instanceof ManagedServiceFactory) { Object pidObj = reference.getProperty(Constants.SERVICE_PID); if (pidObj instanceof String) { String pid = (String) pidObj; try { Configuration config = getConfiguration(pid); if (config != null) { ((ManagedServiceFactory) factory).updated(config.getFactoryPid(), config.getProperties()); } } catch (Exception e) { LOG.log(Level.WARNING, "Error configuring ManagedServiceFactory: " + factory, e); } } else { LOG.log(Level.SEVERE, "Unsupported pid: " + pidObj); } } return factory; }
@Override public ManagedServiceFactory addingService(ServiceReference<ManagedServiceFactory> reference) { ManagedServiceFactory factory = context.getService(reference); Object pidObj = reference.getProperty(Constants.SERVICE_PID); if (pidObj instanceof String) { String pid = (String) pidObj; for (Configuration config : configurations) { if (config.getPid().equals(pid) && config.getFactoryPid() != null) { try { factory.updated(config.getFactoryPid(), config.getProperties()); } catch (ConfigurationException e) { e.printStackTrace(); } } } } else { System.err.println("Unsupported pid: " + pidObj); } return factory; }
@Override public ManagedServiceFactory addingService(ServiceReference<ManagedServiceFactory> reference) { ManagedServiceFactory factory = context.getService(reference); Object pidObj = reference.getProperty(Constants.SERVICE_PID); if (pidObj instanceof String) { String pid = (String) pidObj; for (Configuration config : configurations) { if (config.getPid().equals(pid) && config.getFactoryPid() != null) { try { factory.updated(config.getFactoryPid(), config.getProperties()); } catch (ConfigurationException e) { e.printStackTrace(); } } } } else { System.err.println("Unsupported pid: " + pidObj); } return factory; }
@Test public void testDoNotInvokeFancyUpdatedMethodWithWrongSignatureOk() throws Exception { Ensure ensure = createEnsure(); FancyService service = new FancyService(ensure); FactoryConfigurationAdapterImpl cdi = createConfigurationDependency(service, Map.class); ensure.step(1); ((ManagedServiceFactory) cdi.m_component.getInstance()).updated(CONF_PID, (Dictionary<String, ?>) createDictionary()); TimeUnit.SECONDS.sleep(1L); // Our step shouldn't be changed... ensure.waitForStep(1, 1000); }