public static <Conf,Param> SingleServiceListener<ConfigurationWriter<Conf,Param>> createWriterServiceListener(BundleContext context, Class<Conf> configClass, Class<Param> paramClass, VersionProperty configFormat, String serviceFilter){ Properties props = new Properties(); props.put(Constants.CONFIG_FORMAT_VERSION, configFormat.toString()); props.put(Constants.CONFIG_CLASS, configClass.getName()); props.put(Constants.CONFIG_PARAM_CLASS, paramClass.getName()); String writerFilter = OSGiUtils.createServiceFilter(props); if(serviceFilter != null && !serviceFilter.isEmpty()){ writerFilter = "(&"+writerFilter+"("+serviceFilter+"))"; } return new SingleServiceListener( ConfigurationWriter.class, context, serviceFilter); } }
private static OSGiComponent launchJointGroupConfig( BundleContext context, File file, String paramId){ Properties props = new Properties(); props.put(Constants.CONFIG_PARAM_ID, paramId); props.put(Constants.CONFIG_FORMAT_VERSION, RobotJointGroupConfigXMLReader.VERSION.toString()); ServiceLifecycleProvider lifecycle = new SimpleLifecycle(file, File.class, props); OSGiComponent paramComp = new OSGiComponent(context, lifecycle); paramComp.start(); return paramComp; }
public static ServiceRegistration registerAddOnDriver( BundleContext context, ServiceAddOnDriver driver, Properties props){ Dictionary<String, Object> propTable = new Hashtable<String, Object>(); if(context == null || driver == null){ throw new NullPointerException(); } if(props != null){ for(Object prop: props.keySet()) { propTable.put(prop.toString(), props.get(prop)); } } propTable.put(Constants.SERVICE_VERSION, driver.getServiceVersion().toString()); propTable.put(Constants.CONFIG_FORMAT_VERSION, driver.getConfigurationFormat().toString()); ServiceRegistration reg = context.registerService( ServiceAddOnDriver.class.getName(), driver, propTable); if(reg == null){ theLogger.log(Level.WARNING, "Unknown error occured while registering " + "ServiceConfigurationWriter."); }else{ theLogger.log(Level.INFO, "ServiceAddOnDriver registered successfully."); } return reg; }
private static OSGiComponent launchRobotConfig( BundleContext context, File file, String paramId){ Properties props = new Properties(); props.put(Constants.CONFIG_PARAM_ID, paramId); props.put(Constants.CONFIG_FORMAT_VERSION, RobotConfigXMLReader.VERSION.toString()); ServiceLifecycleProvider lifecycle = new SimpleLifecycle(file, File.class, props); OSGiComponent paramComp = new OSGiComponent(context, lifecycle); paramComp.start(); return paramComp; } }
+ "and class={1}", new Object[]{ serviceVersion.toString(), serviceClass.getName()}); return null;
+ "formatVersion={0}, configClass={1} " + "and paramClass={2}", new Object[]{configFormat.toString(), configClass.getName(), paramClass.getName()}); return null;
+ "formatVersion={0}, configClass={1} " + "and paramClass={2}", new Object[]{configFormat.toString(), configClass.getName(), paramClass.getName()}); return null;
private static <Param> OSGiComponent launchJointGroupConfig( BundleContext context, Param jointGroupConfigParam, Class<Param> paramClass, String configParamId, Configuration<String> jgSvcConf){ Properties props = new Properties(); props.put(Constants.CONFIG_PARAM_ID, configParamId); props.put(Constants.CONFIG_FORMAT_VERSION, get(VersionProperty.class, jgSvcConf, CONF_CONFIG_READER_VERSION).toString()); ServiceLifecycleProvider lifecycle = new SimpleLifecycle( jointGroupConfigParam, paramClass, props); OSGiComponent paramComp = new OSGiComponent(context, lifecycle); paramComp.start(); startedJointGroupConfigs.add(paramComp); return paramComp; }
public static ManagedService registerFactory( BundleContext context, ServiceFactory fact, Properties props){ if(context == null || fact == null){ throw new NullPointerException(); } if(props == null){ props = new Properties(); } props.put(Constants.SERVICE_VERSION, fact.getServiceVersion().toString()); props.put(Constants.SERVICE_CLASS, fact.getServiceClass().getName()); props.put(Constants.CONFIG_CLASS, fact.getConfigurationClass().getName()); ManagedService ms = new OSGiComponent(context, new SimpleLifecycle(fact, ServiceFactory.class), props); ms.start(); return ms; }
private DependencyDescriptor buildFactoryDescriptor(Class<T> serviceClass, Class<C> configClass, VersionProperty serviceVersion){ DescriptorBuilder descs = new DescriptorBuilder(theServiceFactory, ServiceFactory.class) .with(Constants.SERVICE_CLASS, serviceClass.getName()) .with(Constants.SERVICE_VERSION, serviceVersion.toString()); if(configClass != null){ descs.with(Constants.CONFIG_CLASS, configClass.getName()); } return descs.getDescriptor(); }
private DependencyDescriptor buildLoaderDescriptor(Class<C> configClass, Class<P> paramClass, VersionProperty configFormat){ DescriptorBuilder descs = new DescriptorBuilder( theConfigLoader, ConfigurationLoader.class) .with(Constants.CONFIG_FORMAT_VERSION, configFormat.toString()); if(configClass != null){ descs.with(Constants.CONFIG_CLASS, configClass.getName()); }if(paramClass != null){ descs.with(Constants.CONFIG_PARAM_CLASS, paramClass.getName()); } return descs.getDescriptor(); }
public static ManagedService registerConfigLoader( BundleContext context, ConfigurationLoader loader, Properties props){ if(context == null || loader == null){ throw new NullPointerException(); } if(props == null){ props = new Properties(); } props.put(Constants.CONFIG_FORMAT_VERSION, loader.getConfigurationFormat().toString()); props.put(Constants.CONFIG_CLASS, loader.getConfigurationClass().getName()); props.put(Constants.CONFIG_PARAM_CLASS, loader.getParameterClass().getName()); ManagedService ms = new OSGiComponent(context, new SimpleLifecycle(loader, ConfigurationLoader.class), props); ms.start(); return ms; }
public static ManagedService registerConfigWriter( BundleContext context, ConfigurationWriter writer, Properties props){ if(context == null || writer == null){ throw new NullPointerException(); } if(props == null){ props = new Properties(); } props.put(Constants.CONFIG_FORMAT_VERSION, writer.getConfigurationFormat().toString()); props.put(Constants.CONFIG_CLASS, writer.getConfigurationClass().getName()); props.put(Constants.CONFIG_PARAM_CLASS, writer.getParameterClass().getName()); ManagedService ms = new OSGiComponent(context, new SimpleLifecycle(writer, ConfigurationWriter.class), props); ms.start(); return ms; }
private DependencyDescriptor buildParamDescriptor( Class<P> paramClass, VersionProperty configFormat, String paramId){ DescriptorBuilder descs = new DescriptorBuilder(theLoaderParam, paramClass) .with(Constants.CONFIG_FORMAT_VERSION, configFormat.toString()); if(paramId != null){ descs.with(Constants.CONFIG_PARAM_ID, paramId); } return descs.getDescriptor(); }
params.getServiceVersion().toString()); if(props != null && !props.isEmpty()){ myRegistrationProperties.putAll(props);