Package org.osgi.util.tracker

Examples of org.osgi.util.tracker.ServiceTracker.open()


            {
                flt = "(" + Constants.OBJECTCLASS + "=" + type.getName() + ")";
            }
            Filter osgiFilter = FrameworkUtil.createFilter( flt );
            tracker = new ServiceTracker( bundleContext, osgiFilter, null );
            tracker.open( true );

            Object svc = type.cast( tracker.waitForService( timeout ) );
            if ( svc == null )
            {
                Dictionary dic = bundleContext.getBundle().getHeaders();
View Full Code Here


    protected void waitForServices(Bundle b, String sclass) {
    try {
      BundleContext bc = b.getBundleContext();
        String bsn = b.getSymbolicName();
      ServiceTracker st = new ServiceTracker(bc, sclass, null);
        st.open();
        Object bac = st.waitForService(DEFAULT_TIMEOUT);
      /* Uncomment for debug */
      /*
      if(bac == null) {
        System.out.println("SERVICE NOTFOUND " + bsn);
View Full Code Here

        flt = "(" + Constants.OBJECTCLASS + "=" + type.getName() + ")";
      }
      Filter osgiFilter = FrameworkUtil.createFilter(flt);
      tracker = new ServiceTracker(bc == null ? bundleContext : bc, osgiFilter,
          null);
      tracker.open();
     
      // add tracker to the list of trackers we close at tear down
      srs.add(tracker);
      Object x = tracker.waitForService(timeout);
      Object svc = type.cast(x);
View Full Code Here

            } else {
                flt = "(" + Constants.OBJECTCLASS + "=" + type.getName() + ")";
            }
            Filter osgiFilter = FrameworkUtil.createFilter(flt);
            tracker = new ServiceTracker(bc == null ? bundleContext : bc, osgiFilter, null);
            tracker.open();
           
            // add tracker to the list of trackers we close at tear down
            srs.add(tracker);
            Object svc = type.cast(tracker.waitForService(timeout));
            if (svc == null) {
View Full Code Here

            } else {
                flt = "(" + Constants.OBJECTCLASS + "=" + type.getName() + ")";
            }
            Filter osgiFilter = FrameworkUtil.createFilter(flt);
            tracker = new ServiceTracker(bc == null ? bundleContext : bc, osgiFilter, null);
            tracker.open();
           
            // add tracker to the list of trackers we close at tear down
            srs.add(tracker);
            Object svc = type.cast(tracker.waitForService(timeout));
            if (svc == null) {
View Full Code Here

       
        Component component = m.createComponent().setInterface(MyService2.class.getName(), null).setImplementation(new MyComponent(e));
        ServiceDependency dependency = m.createServiceDependency().setService(MyService.class).setRequired(true);
        ServiceDependency dependency2 = m.createServiceDependency().setService(MyService.class).setRequired(true);
        ServiceTracker st = new ServiceTracker(context, MyService2.class.getName(), null);
        st.open();
        Component component2 = m.createComponent().setInterface(MyService.class.getName(), null).setImplementation(new MyImpl(e));
       
        // add the component: it has no dependencies so it should be activated immediately
        m.add(component);
        Assert.assertNotNull("service should be available", st.getService());
View Full Code Here

        }
    }

    public Main getMain() {
        ServiceTracker tracker = new ServiceTracker(getFramework().getBundleContext(), Main.class.getName(), null);
        tracker.open();       
        Main geronimoMain = null;
        try {
            return (Main) tracker.waitForService(1000 * 60);
        } catch (InterruptedException e) {           
            // ignore
View Full Code Here

        return waitForServiceReference(context, clazz, 10, TimeUnit.SECONDS);
    }

    public static ServiceReference waitForServiceReference(BundleContext context, Class<?> clazz, long timeout, TimeUnit unit) {
        ServiceTracker tracker = new ServiceTracker(context, clazz.getName(), null);
        tracker.open();

        ServiceReference sref = null;
        try {
            if (tracker.waitForService(unit.toMillis(timeout)) != null) {
                sref = context.getServiceReference(clazz.getName());
View Full Code Here

            optional = true;
        }
        // Else, find the resolver
        String filter = "(&(" + Constants.OBJECTCLASS + "=" + Resolver.class.getName() + ")(name=" + resolver + "))";
        ServiceTracker tracker = new ServiceTracker(bundleContext, FrameworkUtil.createFilter(filter), null);
        tracker.open();
        try {
            if (optional) {
                Resolver r = (Resolver) tracker.getService();
                if (r != null) {
                    return r.resolve(feature);
View Full Code Here

            optional = true;
        }
        // Else, find the resolver
        String filter = "(&(" + Constants.OBJECTCLASS + "=" + Resolver.class.getName() + ")(name=" + resolver + "))";
        ServiceTracker tracker = new ServiceTracker(bundleContext, FrameworkUtil.createFilter(filter), null);
        tracker.open();
        try {
            if (optional) {
                Resolver r = (Resolver) tracker.getService();
                if (r != null) {
                    return r.resolve(feature);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.