当前位置: 首页>>代码示例>>Java>>正文


Java ManagedService类代码示例

本文整理汇总了Java中org.osgi.service.cm.ManagedService的典型用法代码示例。如果您正苦于以下问题:Java ManagedService类的具体用法?Java ManagedService怎么用?Java ManagedService使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ManagedService类属于org.osgi.service.cm包,在下文中一共展示了ManagedService类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testRegistersManagedEMF

import org.osgi.service.cm.ManagedService; //导入依赖的package包/类
@Test
public void testRegistersManagedEMF() throws InvalidSyntaxException, ConfigurationException {
	
	AriesEntityManagerFactoryBuilder emfb = new AriesEntityManagerFactoryBuilder(
			containerContext, provider, providerBundle, punit);
	
	verify(containerContext).registerService(eq(ManagedService.class),
			any(ManagedService.class), argThat(servicePropsMatcher(
					SERVICE_PID, "org.apache.aries.jpa.test-props")));
	
	// No EMF created as incomplete
	verifyZeroInteractions(msReg, provider);
	
	emfb.close();
	verify(msReg).unregister();
}
 
开发者ID:apache,项目名称:aries-jpa,代码行数:17,代码来源:PropsConfigurationTest.java

示例2: registerManagedService

import org.osgi.service.cm.ManagedService; //导入依赖的package包/类
public static ServiceRegistration registerManagedService(BundleContext bundleContext, ManagedService listener,
		String pid) {

       Dictionary<String, Object> props = new Hashtable<String, Object>();
	props.put(Constants.SERVICE_PID, pid);
	Bundle bundle = bundleContext.getBundle();
	props.put(Constants.BUNDLE_SYMBOLICNAME, OsgiStringUtils.nullSafeSymbolicName(bundle));
	props.put(Constants.BUNDLE_VERSION, OsgiBundleUtils.getBundleVersion(bundle));

	return bundleContext.registerService(ManagedService.class.getName(), listener, props);
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:12,代码来源:CMUtils.java

示例3: init

import org.osgi.service.cm.ManagedService; //导入依赖的package包/类
@Override
public void init(BundleContext bc, DependencyManager manager) throws Exception {
  Properties properties = new Properties();
  properties.setProperty(Constants.SERVICE_PID, PID);

  manager.add(createComponent()
      .setInterface(new String[]{
              DeviceDriverManager.class.getName(),
              ManagedService.class.getName()},
          properties)
      .setImplementation(DriverManagerImpl.class)
      .add(createServiceDependency()
          .setService(DirectoryService.class)
          .setRequired(true))
      .add(createConfigurationDependency().setPid(PID)));
}
 
开发者ID:semiotproject,项目名称:semiot-platform,代码行数:17,代码来源:Activator.java

示例4: start

import org.osgi.service.cm.ManagedService; //导入依赖的package包/类
/**
 * Called when this bundle is started by OSGi Framework.
 * Determines underlying platform and loads the relevant service
 * which implements <code>GPIO</code> interface.
 */
public void start(BundleContext context) throws Exception {

	/* Linux user space GPIO implementation, "sysfs" based */
	if (System.getProperty("os.name").toLowerCase().startsWith("linux")) {

		GPIOLinux gpioLinux = new GPIOLinux();

		Dictionary<String, String> properties = new Hashtable<String, String>();
		properties.put("service.pid", "org.openhab.gpio");

		context.registerService(GPIO.class, gpioLinux, null);
		context.registerService(ManagedService.class, gpioLinux, properties);
	} else {
		/* Throwing exception is not implemented because it's causing Equinox to constantly trying to start the bundle */
		logger.error("No supported operating system was found, GPIO service won't be available");
	}
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:23,代码来源:GPIOActivator.java

示例5: doActivate

import org.osgi.service.cm.ManagedService; //导入依赖的package包/类
@Activate
public void doActivate(ComponentContext ctx) {
	log.info("Start");
	context = ctx.getBundleContext();
	context.addBundleListener(this);
	context.addServiceListener(this);
	
	// configuration
	Hashtable<String, Object> properties = new Hashtable<String, Object>();
	properties.put(Constants.SERVICE_PID, CONFIG_PID);
	configUpdaterReg = context.registerService(ManagedService.class.getName(), new ConfigUpdater(this) , properties);
	
	if (enabled) refreshAll();
	
	
}
 
开发者ID:mhus,项目名称:mhus-osgi-tools,代码行数:17,代码来源:BundleWatchImpl.java

示例6: PiService

import org.osgi.service.cm.ManagedService; //导入依赖的package包/类
/**
 * PiService creator. Record itself as a managed service.
 * 
 */
public PiService() {
	
	gpioController = GpioFactory.getInstance();

	String[] clazzes = new String[] { ManagedService.class.getName() };
	// register the class as a managed service.
	Hashtable<String, Object> properties = new Hashtable<String,Object>();
	properties.put(Constants.SERVICE_PID, this.getClass().getName());

	Activator.bc.registerService(clazzes, this, properties);
	
	Activator.log(LogService.LOG_INFO, "Registered "
			+ this.getClass().getName() +  ", Pid = "
			+ (String) properties.get(Constants.SERVICE_PID));
}
 
开发者ID:lathil,项目名称:Ptoceti,代码行数:20,代码来源:PiService.java

示例7: start

import org.osgi.service.cm.ManagedService; //导入依赖的package包/类
/**
 * Called when this bundle is started by OSGi Framework.
 * Determines underlying platform and loads the relevant service
 * which implements <code>GPIO</code> interface.
 */
public void start(BundleContext context) throws Exception {

    /* Linux user space GPIO implementation, "sysfs" based */
    if (System.getProperty("os.name").toLowerCase().startsWith("linux")) {

        GPIOLinux gpioLinux = new GPIOLinux();

        Dictionary<String, String> properties = new Hashtable<String, String>();
        properties.put("service.pid", "org.openhab.gpio");

        context.registerService(GPIO.class, gpioLinux, null);
        context.registerService(ManagedService.class, gpioLinux, properties);
    } else {
        /*
         * Throwing exception is not implemented because it's causing Equinox to constantly trying to start the
         * bundle
         */
        logger.error("No supported operating system was found, GPIO service won't be available");
    }
}
 
开发者ID:openhab,项目名称:openhab1-addons,代码行数:26,代码来源:GPIOActivator.java

示例8: registerManagedService

import org.osgi.service.cm.ManagedService; //导入依赖的package包/类
private void registerManagedService(BundleContext containerContext, PersistenceUnitInfo persistenceUnit) {
	Dictionary<String, Object> configuration = new Hashtable<String, Object>(); // NOSONAR
	configuration.put(Constants.SERVICE_PID, JPA_CONFIGURATION_PREFIX + persistenceUnit.getPersistenceUnitName());
	configReg = containerContext.registerService(ManagedService.class, 
			new ManagedEMF(this, persistenceUnit.getPersistenceUnitName()), configuration);
}
 
开发者ID:apache,项目名称:aries-jpa,代码行数:7,代码来源:AriesEntityManagerFactoryBuilder.java

示例9: setup

import org.osgi.service.cm.ManagedService; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Before
public void setup() throws Exception {
	
	when(punit.getPersistenceUnitName()).thenReturn("test-props");
	when(punit.getPersistenceProviderClassName())
		.thenReturn(ECLIPSE_PERSISTENCE_PROVIDER);
	when(punit.getTransactionType()).thenReturn(PersistenceUnitTransactionType.JTA);
	when(punit.getBundle()).thenReturn(punitBundle);
	when(punit.getProperties()).thenReturn(punitProperties);
	
	when(punitBundle.getBundleContext()).thenReturn(punitContext);
	when(punitBundle.getVersion()).thenReturn(Version.parseVersion("1.2.3"));
	
	when(containerContext.registerService(eq(ManagedService.class), 
			any(ManagedService.class), any(Dictionary.class))).thenReturn(msReg);
	when(containerContext.getService(dsfRef)).thenReturn(dsf);
	when(containerContext.getService(dsRef)).thenReturn(ds);
	when(containerContext.createFilter(Mockito.anyString()))
		.thenAnswer(new Answer<Filter>() {
			@Override
			public Filter answer(InvocationOnMock i) throws Throwable {
				return FrameworkUtil.createFilter(i.getArguments()[0].toString());
			}
		});
	
	when(punitContext.registerService(eq(EntityManagerFactory.class), any(EntityManagerFactory.class), 
			any(Dictionary.class))).thenReturn(emfReg);
	
	when(emf.isOpen()).thenReturn(true);
	
	
	Properties jdbcProps = new Properties();
	jdbcProps.setProperty("url", JDBC_URL);
	jdbcProps.setProperty("user", JDBC_USER);
	jdbcProps.setProperty("password", JDBC_PASSWORD);
	
	when(dsf.createDataSource(jdbcProps)).thenReturn(ds);
	
}
 
开发者ID:apache,项目名称:aries-jpa,代码行数:41,代码来源:PropsConfigurationTest.java

示例10: start

import org.osgi.service.cm.ManagedService; //导入依赖的package包/类
@Override
public void start(BundleContext context) throws Exception {
    bundleContext = context;
    scheduled.set(true);
    Hashtable<String, Object> props = new Hashtable<>();
    props.put(Constants.SERVICE_PID, getPid());
    managedServiceRegistration = bundleContext.registerService(ManagedService.class, this::updated, props);
    scheduled.set(false);
    reconfigure();
}
 
开发者ID:ops4j,项目名称:org.ops4j.pax.transx,代码行数:11,代码来源:AbstractActivator.java

示例11: setUp

import org.osgi.service.cm.ManagedService; //导入依赖的package包/类
protected void setUp() throws Exception {
    adminControl = createControl();
    admin = adminControl.createMock(ConfigurationAdmin.class);
    cfg = createMock(Configuration.class);

    config = new Hashtable<String, Object>();

    expect(admin.getConfiguration(persistentId)).andReturn(cfg).atLeastOnce();
    expect(cfg.getProperties()).andReturn(config).atLeastOnce();

    adminControl.replay();
    replay(cfg);

    bundleContext = new MockBundleContext() {

        // add Configuration admin support
        @Override
        public Object getService(ServiceReference reference) {
            return admin;
        }

        // ManagedService registration
        @Override
        public ServiceRegistration registerService(String clazz, Object service, Dictionary properties) {
            // save the callback
            if (ManagedService.class.getName().equals(clazz)) {
                msCallback = (ManagedService) service;
            }
            return super.registerService(clazz, service, properties);
        }
    };

    appContext = new GenericApplicationContext();
    appContext.getBeanFactory().addBeanPostProcessor(new BundleContextAwareProcessor(bundleContext));

    XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(appContext);
    // reader.setEventListener(this.listener);
    reader.loadBeanDefinitions(new ClassPathResource("configProperties.xml", getClass()));
    appContext.refresh();
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:41,代码来源:ConfigPropertiesHandlerTest.java

示例12: registerManagedService

import org.osgi.service.cm.ManagedService; //导入依赖的package包/类
private void registerManagedService(final String persistentId) {
    // Register a ManagedService so we get updates from the ConfigAdmin when the cfg file corresponding
    // to the persistentId changes.
    final ManagedService managedService = new ManagedService() {
        private volatile boolean initialUpdate = true;

        @Override
        public void updated(final Dictionary<String, ?> properties) {
            LOG.debug("{}: ManagedService updated for persistentId {}, properties: {}, initialUpdate: {}",
                    logName(), persistentId, properties, initialUpdate);

            // The first update occurs when the service is registered so ignore it as we want subsequent
            // updates when it changes. The ConfigAdmin will send an update even if the cfg file doesn't
            // yet exist.
            if (initialUpdate) {
                initialUpdate = false;
            } else {
                blueprintContainerRestartService.restartContainerAndDependents(bundle);
            }
        }
    };

    Dictionary<String, Object> props = new Hashtable<>();
    props.put(Constants.SERVICE_PID, persistentId);
    props.put(Constants.BUNDLE_SYMBOLICNAME, bundle.getSymbolicName());
    props.put(Constants.BUNDLE_VERSION, bundle.getHeaders().get(Constants.BUNDLE_VERSION));
    managedServiceRegs.add(bundle.getBundleContext().registerService(ManagedService.class.getName(),
            managedService, props));
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:30,代码来源:ComponentProcessor.java

示例13: start

import org.osgi.service.cm.ManagedService; //导入依赖的package包/类
public synchronized void start(BundleContext bc) throws Exception {
    zkd = new ZooKeeperDiscovery(bc);
    bc.registerService(ManagedService.class, zkd, configProperties(PID_DISCOVERY_ZOOKEEPER));
    
    zkStarter = new ZookeeperStarter(bc);
    bc.registerService(ManagedService.class, zkStarter, configProperties(PID_ZOOKEEPER_SERVER));
}
 
开发者ID:apache,项目名称:aries-rsa,代码行数:8,代码来源:Activator.java

示例14: init

import org.osgi.service.cm.ManagedService; //导入依赖的package包/类
@Override
public void init(BundleContext bc, DependencyManager manager)
    throws Exception {
  Properties properties = new Properties();
  properties.setProperty(Constants.SERVICE_PID, PID);

  manager.add(createComponent()
      .setInterface(new String[]{
          DirectoryService.class.getName(),
          ManagedService.class.getName()
      }, properties)
      .setImplementation(DirectoryServiceImpl.class)
      .add(createConfigurationDependency().setPid(PID)));
}
 
开发者ID:semiotproject,项目名称:semiot-platform,代码行数:15,代码来源:Activator.java

示例15: start

import org.osgi.service.cm.ManagedService; //导入依赖的package包/类
@Override
public void start(BundleContext context) {
    handler = new GenericControllerHandler<ExperimentsController>(context, ExperimentsController.class.getName());

    String pid = "com.recalot.views.experiments";

    Dictionary config = new Hashtable();
    config.put(pid + ".path", new String("/experiments"));

    service = new WebService(pid, context, new Servlet(handler), config);
    context.registerService(ManagedService.class.getName(), service, config);
    service.initialize();
}
 
开发者ID:mys3lf,项目名称:recalot.com,代码行数:14,代码来源:Activator.java


注:本文中的org.osgi.service.cm.ManagedService类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。