/** * Start tracking dependencies. */ public void start(){ myListeningFlag = true; myRequiredCount = 0; for(DependencyDescriptor desc : myDependencyDescMap.values()){ if(DependencyType.REQUIRED == desc.getDependencyType()){ myRequiredCount++; } } for(SingleServiceListener ssl : myDependencyTrackers.values()){ ssl.start(); } }
public DefaultAddOnDriver(BundleContext context, VersionProperty serviceVersion, VersionProperty configFormat, ConfigurationAdapter<AddOn, Config> configAdapter){ if(context == null || serviceVersion == null || configFormat == null || configAdapter == null){ throw new NullPointerException(); } myContext = context; myServiceVersion = serviceVersion; myConfigFormat = configFormat; myConfigAdapter = configAdapter; myAddOnClass = myConfigAdapter.getSerivceClass(); myWriterTracker = ServiceUtils.createWriterServiceListener(context, myConfigAdapter.getConfigurationClass(), File.class, configFormat, null); myWriterTracker.start(); }
/** * Returns a global RobotManager. The RobotManager is retrieved from the * OSGi Service Registry. * @param context BundleContext for OSGi * @return global RobotManager */ public static RobotManager getRobotManager(BundleContext context){ if(context == null){ throw new NullPointerException(); } if(theManagerTracker == null){ theManagerTracker = new SingleServiceListener( RobotManager.class, context, null); theManagerTracker.start(); } RobotManager manager = theManagerTracker.getService(); if(manager == null){ RobotManager tmp = new RobotManager(context); context.registerService(RobotManager.class.getName(), tmp, null); manager = theManagerTracker.getService(); } if(manager == null){ throw new NullPointerException( "Unknown error registering and tracking RobotManager."); } return manager; } }
dependencyName, clazz, filterString, type)); if(isRunning()){ return ssl.start();
public DynamixelTracker(final OpenServoControlLoop osLoop){ BundleContext context = OSGiUtils.getBundleContext(ServoController.class); myTracker = new SingleServiceListener<ServoController>( ServoController.class, context, OSGiUtils.createFilter(ServoController.PROP_VERSION, DynamixelController.VERSION.toString())); myTracker.addPropertyChangeListener(SingleServiceListener.PROP_SERVICE_TRACKED, new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { DynamixelController controller = (DynamixelController)evt.getNewValue(); if(controller == null){ throw new IllegalArgumentException(); } DynamixelControlLoop loop = controller.getControlLoop(); if(loop == null){ throw new IllegalArgumentException(); } loop.setOpenServoLoop(osLoop); } }); myTracker.start(); }