@Override public DescriptorBuilder dependency(String name, Class clazz){ return finish().dependency(name, clazz); }
@Override public List<DependencyDescriptor> getDescriptors(){ return finish().getDescriptors(); }
public SimpleLifecycle( T service, String[] serviceClassNames, String idKey, String idStr, Properties props){ this(service, serviceClassNames, getProps(idKey, idStr, props)); }
/** * Creates a new lifecycle provider for a VisemeEventNotifier which uses * the given SpeechService. * @param speechServiceId SpeechService for the VisemeEventNotifier to use */ public VisemeBindingManagerLifecycle(Properties registrationProps){ super(new DescriptorListBuilder() .dependency(theVisemeConfig, VisemeBindingManagerConfig.class) .with(registrationProps) .getDescriptors()); myRegistrationProperties = new Properties(); myRegistrationProperties.putAll(registrationProps); }
@Override public void run() { Properties props = null; if(key != null){ props = new Properties(); props.put(key, val); } new OSGiComponent(context, new SimpleLifecycle(obj, clazz, props)).start(); } };
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(); }
/** * Begins building a DependencyDescriptor with the give name and class. * By default the DependencyType is REQUIRED. Call optional() * @param name * @param clazz */ public DescriptorBuilder(String name, Class clazz){ this(new DescriptorListBuilder(), name, clazz, DependencyType.REQUIRED); }
public static ManagedServiceGroup startVisemeFrameSourceGroup( ManagedServiceFactory fact, Robot.Id robotId, String speechServiceId, String visemeConfigPath){ String groupId = "viseme/" + robotId.getRobtIdString() + "/" + speechServiceId; ManagedServiceGroup group = new ManagedServiceGroup(fact, getLifecycles(groupId, robotId, speechServiceId, visemeConfigPath), groupId, null); group.start(); return group; }
private DescriptorListBuilder finish(){ myListBuilder.getDescriptors().add(getDescriptor()); return myListBuilder; } }
public static List<ManagedService> launchDefaultBlender( BundleContext context, Robot.Id robotId, long blenderIntervalMsec){ ManagedServiceGroup bsg = new DefaultBlenderServiceGroup( context, robotId, blenderIntervalMsec, null); bsg.start(); return bsg.getServices(); }
/** * Adds a new DependencyDescriptor with the given name and class * @param name dependency name used within the ManagedService * @param clazz dependency class * @return context for describing the dependency further or adding other * dependencies */ public DescriptorBuilder dependency(String name, Class clazz){ if(myDependencies == null){ myDependencies = new ArrayList<DependencyDescriptor>(); } return new DescriptorBuilder( this, name, clazz, DependencyType.REQUIRED); } /**
@Override public ManagedServiceGroup adapt(Configuration<String> a) { ManagedServiceGroup g = buildGroup(myFactory, a); if(myStartFlag){ g.start(); } return g; } }
public DependencyDescriptor getDescriptor(){ String filter = buildFilter(); return new DependencyDescriptor( myDependencyName, myDependencyClass, filter, myType); }
/** * Creates a new lifecycle provider for a VisemeEventNotifier which uses * the given SpeechService. * @param speechServiceId SpeechService for the VisemeEventNotifier to use */ public VisemeEventNotifierLifecycle(String speechServiceId){ super(new DescriptorListBuilder() .dependency(theSpeechService, SpeechService.class) .with(SpeechService.PROP_ID, speechServiceId) .getDescriptors()); myRegistrationProperties = new Properties(); myRegistrationProperties.put( SpeechService.PROP_ID, speechServiceId); }
public static ManagedService startComponent(BundleContext context, String[] classNames, Object service, Properties serviceProperties){ if(context == null || service == null){ throw new NullPointerException(); } SimpleLifecycle lifecycle = new SimpleLifecycle(service, classNames, null); OSGiComponent comp = new OSGiComponent(context, lifecycle, serviceProperties); comp.start(); return comp; }
public RobotChannelsLifecycle(Robot.Id robotId){ super(new DescriptorListBuilder() .dependency(theRobot, Robot.class) .with(Robot.PROP_ID, robotId.getRobtIdString()) .dependency(theJointGroup, JointGroup.class) .with(Robot.PROP_ID, robotId.getRobtIdString()) .optional() .getDescriptors()); if(myRegistrationProperties == null){ myRegistrationProperties = new Properties(); } myRegistrationProperties.put(Robot.PROP_ID, robotId.getRobtIdString()); }
public VisemeFrameSourceLifecycle( Robot.Id robotId, String speechServiceId){ super(new DescriptorListBuilder() .dependency(theVisemeNotifier, VisemeEventNotifier.class) .with(SpeechService.PROP_ID, speechServiceId) .dependency(theVisemeManager, VisemeBindingManager.class) .with(Robot.PROP_ID, robotId.getRobtIdString()) .getDescriptors()); if(robotId == null || speechServiceId == null){ throw new NullPointerException(); } myRobotId = robotId; myRegistrationProperties = new Properties(); myRegistrationProperties.put( Robot.PROP_ID, myRobotId); }
public RobotOutputLifecycle(Robot.Id robotId){ super(new DescriptorListBuilder() .dependency(theRobot, Robot.class) .with(Robot.PROP_ID, robotId.getRobtIdString()) .getDescriptors()); if(myRegistrationProperties == null){ myRegistrationProperties = new Properties(); } myRegistrationProperties.put(Robot.PROP_ID, robotId.getRobtIdString()); myRegistrationProperties.put(Blender.PROP_POSITION_MAP_TYPE, RobotPositionMap.class.getName()); }
private List<DependencyDescriptor> makeDepDescList(ChannelBindingConfig cbc) { /* was in lifecycleconstructor first line: * super(new DescriptorListBuilder() //The name "service" is used only within the lifecycle .dependency("service", conf.getChannelType().getServiceClass()).with(conf.getOSGiFilterString()) .getDescriptors()); */ DescriptorListBuilder firstListBuilder = new DescriptorListBuilder(); //The name "service" is used only within the lifecycle ChannelBindingConfig.ChannelType chanType = cbc.getChannelType(); Class depClazz = chanType.getServiceClass(); String osgiFilter = cbc.getOSGiFilterString(); // This serviceName is used only within the lifecycle String serviceName = ChannelBindingLifecycle.SERVICE_DEP_KEY; // "service"; DescriptorBuilder firstDBuilder = firstListBuilder.dependency(serviceName, depClazz); DescriptorBuilder secondDBuilder = firstDBuilder.with(osgiFilter); List<DependencyDescriptor> finishedList = secondDBuilder.getDescriptors(); return finishedList; }
private List<DependencyDescriptor> makeDepDescList(ChannelBindingConfig cbc) { /* was in lifecycleconstructor first line: * super(new DescriptorListBuilder() //The name "service" is used only within the lifecycle .dependency("service", conf.getChannelType().getServiceClass()).with(conf.getOSGiFilterString()) .getDescriptors()); */ DescriptorListBuilder firstListBuilder = new DescriptorListBuilder(); //The name "service" is used only within the lifecycle ChannelBindingConfig.ChannelType chanType = cbc.getChannelType(); Class depClazz = chanType.getServiceClass(); String osgiFilter = cbc.getOSGiFilterString(); // This serviceName is used only within the lifecycle String serviceName = ChannelBindingLifecycle.SERVICE_DEP_KEY; // "service"; DescriptorBuilder firstDBuilder = firstListBuilder.dependency(serviceName, depClazz); DescriptorBuilder secondDBuilder = firstDBuilder.with(osgiFilter); List<DependencyDescriptor> finishedList = secondDBuilder.getDescriptors(); return finishedList; }