/** * Stops tracking dependency changes. Does not modify the existing service * or its OSGi registration state. Call unregister() to unregister * the service being managed. */ @Override public void stop(){ if(myDependenciesTracker != null && myDependenciesTracker.isRunning()){ myDependenciesTracker.stop(); } stopLifecycle(); }
public void __start(){ if(myDependenciesTracker == null){ handleAllDependencies(Collections.EMPTY_MAP); return; } if(!myDependenciesTracker.isRunning()){ myDependenciesTracker.start(); } } /**
@Override public <T> ManagedService<T> createService( ServiceLifecycleProvider<T> lifecycle, Properties registrationPropeties, Properties uniqueRegistrationProperties) { return new OSGiComponent<T>(myContext, lifecycle, registrationPropeties, uniqueRegistrationProperties, true); }
private static ServiceRegistration registerChannelRobotParams( BundleContext context, Robot.Id robotId){ RobotChannelsLifecycle lifecycle = new RobotChannelsLifecycle(robotId); OSGiComponent comp = new OSGiComponent(context, lifecycle); comp.start(); return null; }
public ServiceChannelExtender(BundleContext context, String bindingConfigOSGiFilter, Properties bindingRegistrationProps){ super(ChannelBindingConfig.class, context, bindingConfigOSGiFilter); myManagerFactory = new OSGiComponentFactory(context); myManagerMap = new HashMap(); myBindingRegistrationProperties = bindingRegistrationProps; }
@Override public void run() { if(mySelfRegistrationEnabledFlag){ registerSelf(); } if(myLifecycleListener == null && myLifecycleProvider != null){ myLifecycleListener = new LifecycleDependencyListener(); myLifecycleProvider.addPropertyChangeListener(myLifecycleListener); } __start(); }}); }
public static void clearJointGroups() { for (OSGiComponent aJointGroupConfig : startedJointGroupConfigs) { aJointGroupConfig.dispose(); } startedJointGroupConfigs.clear(); for (OSGiComponent aJointGroupLifecycle : startedJointGroupLifecycles) { aJointGroupLifecycle.dispose(); } startedJointGroupLifecycles.clear(); } /*
@Override public void setRegistrationEnabled(boolean enabled){ myRegistrationEnabledFlag = enabled; if(myRegistrationEnabledFlag && myService != null && myServiceRegistration == null){ register(); }else if(!myRegistrationEnabledFlag && myServiceRegistration != null){ unregister(); } }
/** * If set true, this OSGiComponent will register itself when start() is * called, or immediately if start has already been called. If set false * and the component is already registered, it will be unregistered. * By default this is set to true. * @param enabled true to enable self-registration of the OSGiComponent */ public void setSelfRegistrationEnabled(boolean enabled){ mySelfRegistrationEnabledFlag = enabled; if(mySelfRegistrationEnabledFlag && mySelfRegistration == null){ registerSelf(); }else if(!mySelfRegistrationEnabledFlag && myServiceRegistration != null){ unregisterSelf(); } } /**
@Override public void unregister(){ spawnThread(new Runnable() { @Override public void run() { __unregister(); }}); }
@Override public void register(){ // spawnThread(3, new Runnable() { // @Override public void run() { __register(); // }}); }
@Override public boolean getDependencyStatus(String dependencyId) { if(myDependenciesTracker == null){ return false; } return myDependenciesTracker.getDependency(dependencyId) != null; }
@Override public boolean isRegistered() { return isAvailable() && myServiceRegistration != null; }
@Override public void run() { __unregister(); }}); }
@Override public int getAvailableDependencyCount() { if(myDependenciesTracker == null){ return 0; } Map map = myDependenciesTracker.getAvailableDependencies(); if(map == null){ return 0; } return map.size(); }
@Override public int getDependencyCount() { List deps = getDependencies(); if(deps == null){ return 0; } return deps.size(); }
private void launchRemoteSpeechClient(BundleContext context, String speechClientId, String speechHostId, String commandSenderId, String configSenderId, String errorReceiverId, String speechRequestSenderId, String speechEventsReceiverId){ RemoteSpeechServiceClientLifecycle lifecycle = new RemoteSpeechServiceClientLifecycle(speechClientId, speechHostId, commandSenderId, configSenderId, errorReceiverId, speechRequestSenderId, speechEventsReceiverId); OSGiComponent speechComp = new OSGiComponent(context, lifecycle); speechComp.start(); }
@Override public <T> ManagedService<T> createService( ServiceLifecycleProvider<T> lifecycle, Properties registrationPropeties) { return new OSGiComponent<T>(myContext, lifecycle, registrationPropeties); }
protected static OSGiComponent launchJointGroupLifecycle( BundleContext context, Robot.Id robotId, String paramId){ RobotJointGroupLifecycle<File> lifecycle = new RobotJointGroupLifecycle<File>(robotId, File.class, paramId, RobotJointGroupConfigXMLReader.VERSION); OSGiComponent jointGroupComp = new OSGiComponent(context, lifecycle); jointGroupComp.start(); return null; }
private static OSGiComponent startRobotClientLifecycle(BundleContext context, String sourceId, String destId, Robot.Id robotId, String reqSenderId, String respReceiverId, String frameSenderId){ RemoteRobotClientLifecycle lifecycle = new RemoteRobotClientLifecycle(sourceId, destId, robotId, reqSenderId, respReceiverId, frameSenderId); OSGiComponent comp = new OSGiComponent(context, lifecycle); comp.start(); return comp; }