public static <C> ClassTracker<C> build(Class<C> clazz, Properties props){ String filter = OSGiUtils.createServiceFilter(props); return build(clazz, filter); }
/** * Releases the service, stops listening to the Serivce Registry, and * removes all PropertyChangeListeners. */ public void dispose(){ stop(); clearAllListeners(); }
/** * Creates a new tracker for the given class, and begins tracking. * There is no need to call init() * @param className name of the class to track */ public ClassTracker(BundleContext context, String className, String filter, ServiceTrackerCustomizer customizer) throws IllegalArgumentException{ construct(context, className, filter, customizer); }
public static Boolean serviceExists( BundleContext context, String clazz, Properties props){ String filter = createServiceFilter(props); return serviceExists(context, clazz, filter); }
@Override public void actionPerformed(ActionEvent e) { File file = getFile(); if(file == null){ return; } BundleContext context = OSGiUtils.getBundleContext(JointGroup.class); if(context == null){ return; } launchService(context, file); }
public static <T> SingleServiceListener<T> createIdServiceListener( Class<T> clazz, BundleContext context, String idPropertyName, String idString, String filter){ if(context == null || idPropertyName == null || idString == null){ throw new NullPointerException(); } filter = createIdFilter(idPropertyName, idString, filter); return new SingleServiceListener<T>(clazz, context, filter); }
/** * Initializes the tracking to begin tracking FrameSources. * @param context BundleContext to use for tracking. * @param filter FrameSource service property filter string * @return true if successful */ public boolean init(BundleContext context, String filter){ myTracker.setContext(context); myTracker.setFilter(filter); return myTracker.init(); }
/** * Creates a new OSGiFrameSourceTracker which tracks services registered * under the given class name. * @param className fully qualified name of the FrameSource class to track */ public OSGiFrameSourceTracker(String className){ myTracker = new ClassTracker(className); }
public static Boolean serviceExists(BundleContext context, String clazz, String idPropertyName, String idString, Properties props){ if(props == null){ props = new Properties(); } props.put(idPropertyName, idString); return serviceExists(context, clazz, props); }
/** * Starts listening for the desired services. * @return true is successful, false if it failed */ public boolean start(){ if(myContext == null){ return false; }else if(myStartFlag){ return true; } myStartFlag = startListening() && collectServiceReferences(); return myStartFlag; }
/** * Returns the service being tracked, null if no service is found. * @return service being tracked, null if no service is found */ public T getService(){ if(!ensureTracking()){ return null; } return myTrackedClass; }
/** * Creates a new tracker for the given class. init() must be called before * the ClassTracker begins tracking. * @param className name of the class to track */ public ClassTracker(String className){ setTrackedClassName(className); }
public static ManagedService startComponent( BundleContext context, String className, String idPropertyName, String idString, Object service, Properties serviceProperties){ return startComponent(context, new String[]{className}, idPropertyName, idString, service, serviceProperties); } public static ManagedService startComponent(
@Override public List<FrameSource> getSources() { if(myTracker == null){ return null; } return myTracker.getServices(); }
public static ManagedService startUniqueComponent( BundleContext context, String className, String idPropertyName, String idString, Object service, Properties serviceProperties){ return startUniqueComponent(context, new String[]{className}, idPropertyName, idString, service, serviceProperties); } public static ManagedService startUniqueComponent(
/** * Releases the service, decrementing the usage count for the * ServiceReference being tracked. * Notifies listeners that the service is no longer available. */ public void releaseService(){ if(myReference != null){ untrackWithEvent(myReference); } }
@Override public void componentOpened() { if (jointTreePanel1.isInitialized()) { return; } BundleContext context = OSGiUtils.getBundleContext(JointGroup.class); if (context != null) { jointTreePanel1.initialize(context); } jointTreePanel1.startUpdates(100); }
/** * Creates a new OSGiFrameSourceTracker. */ public OSGiFrameSourceTracker(){ myTracker = new ClassTracker(FrameSource.class.getName()); }
/** * Creates a new tracker for the given class, and begins tracking. * There is no need to call init() * @param className name of the class to track */ public ClassTracker(BundleContext context, String className, String filter) throws IllegalArgumentException{ construct(context, className, filter, null); } /**
/** * Returns a reference to the service being tracked. Returns null if the * service is not available. * @return reference to the service being tracked, null if the * service is not available */ public ServiceReference getServiceReference(){ ensureTracking(); return myReference; }