public ServoControllerContext(Class<Param> paramClass, Param param, VersionProperty controllerVersion, VersionProperty configFormat){ if(paramClass == null || param == null || controllerVersion == null || configFormat == null){ throw new NullPointerException(); } myServiceParams = new ConfiguredServiceParams( ServoController.class, null, paramClass, null, param, null, controllerVersion, configFormat); } }
private static ServiceLifecycleProvider getBindingManagerStreamLifecycle( Robot.Id robotId, String speechServiceId, String configFileId){ ConfiguredServiceParams< VisemeBindingManager, VisemeBindingManagerConfig, InputStream> params = new ConfiguredServiceParams( VisemeBindingManager.class, VisemeBindingManagerConfig.class, InputStream.class, null, null, configFileId, VisemeBindingManager.VERSION, VisemeBindingManagerConfigAvroStreamLoader.VERSION); Properties registrationProps = new Properties(); registrationProps.put(Robot.PROP_ID, robotId.getRobtIdString()); registrationProps.put(SpeechService.PROP_ID, speechServiceId); ConfiguredServiceLifecycle lifecycle = new ConfiguredServiceLifecycle(params, registrationProps); return lifecycle; } public static ManagedServiceGroup startVisemeFrameSourceStreamGroup(
@Override protected Robot create(Map dependencies){ Robot robot = super.create(dependencies); if(robot == null){ return null; } robot.connect(); return robot; } };
@Override protected void handleChange(String name, Object dependency, Map<String, Object> availableDependencies) { super.handleChange(name, dependency, availableDependencies); if(myService != null && theRobot.equals(name)){ setRobot(myService, (Robot)dependency); } }
@Override protected void cleanupService(Robot service) { try{ service.disconnect(); for(ManagedService s : myServoControllerServices){ try{ s.dispose(); }catch(Throwable t){ theLogger.log(Level.WARNING, "Error disposing controller service.", t); } } }catch(Exception ex){} super.cleanupService(service); }
public static <S,C,P> ConfiguredServiceParams<S,C,P> buildParams( Configuration<String> conf, C configInst, P paramInst){ return new ConfiguredServiceParams<S, C, P>( get(Class.class, conf, CONF_SERVICE_CLASS), get(Class.class, conf, CONF_CONFIG_CLASS), get(Class.class, conf, CONF_PARAM_CLASS), configInst, paramInst, get(String.class, conf, CONF_PARAM_ID), get(VersionProperty.class, conf, CONF_SERVICE_VERSION), get(VersionProperty.class, conf, CONF_CONFIG_READER_VERSION)); }
private static ServiceLifecycleProvider getBindingManagerLifecycle( Robot.Id robotId, String speechServiceId, String configFileId){ ConfiguredServiceParams< VisemeBindingManager, VisemeBindingManagerConfig, File> params = new ConfiguredServiceParams( VisemeBindingManager.class, VisemeBindingManagerConfig.class, File.class, null, null, configFileId, VisemeBindingManager.VERSION, VisemeBindingManagerAvroConfigLoader.VERSION); Properties registrationProps = new Properties(); registrationProps.put(Robot.PROP_ID, robotId.getRobtIdString()); registrationProps.put(SpeechService.PROP_ID, speechServiceId); ConfiguredServiceLifecycle lifecycle = new ConfiguredServiceLifecycle(params, registrationProps); return lifecycle; }
@Override protected synchronized JointGroup create(Map<String, Object> dependencies) { JointGroup group = super.create(dependencies); if(group == null){ return null; } Robot robot = (Robot)dependencies.get(theRobot); setRobot(group, robot); return group; }
public RobotJointGroupLifecycle(Robot.Id robotId, Class<P> paramClass, String paramId, VersionProperty configFormat){ super(new ConfiguredServiceParams( JointGroup.class, RobotJointGroupConfig.class, paramClass, null, null, paramId, RobotJointGroup.VERSION, configFormat)); getDependencyDescriptors().add( new DescriptorBuilder(theRobot, Robot.class) .with(Robot.PROP_ID, robotId.getRobtIdString()) .getDescriptor()); if(myRegistrationProperties == null){ myRegistrationProperties = new Properties(); } myRegistrationProperties.put(Robot.PROP_ID, robotId.getRobtIdString()); }
@Override protected Robot create(Map dependencies) { Robot r = super.create(dependencies); if(r == null){ return null;
private static void startRobot(BundleContext context, String path){ theLogger.info("Opening Robot Config File."); File file = ConfigUtils.getFileSystemAdapter().openFile(path); if(file == null){ return; } ConfiguredServiceParams<Robot,Object,File> robotParams = new ConfiguredServiceParams( Robot.class, null, File.class, null, file, null, ServoRobot.VERSION, RobotConfigXMLReader.VERSION); Properties props = new Properties(); props.put(Robot.PROP_ID, ROBOT_ID); ConfiguredServiceLifecycle<Robot,?,File> robotLifecycle = new ConfiguredServiceLifecycle<Robot,Object,File>(robotParams){ @Override protected Robot create(Map dependencies){ Robot robot = super.create(dependencies); if(robot == null){ return null; } robot.connect(); return robot; } }; OSGiComponent robotComp = new OSGiComponent( context, robotLifecycle, null, props, true); robotComp.start(); }