Package org.osgi.framework

Examples of org.osgi.framework.BundleContext.addServiceListener()


        EasyMock.expect(systemBundle.getHeaders()).andReturn(new Hashtable());
        EasyMock.expect(systemBundle.getRegisteredServices()).andReturn(null);
        EasyMock.expect(new Long(systemBundle.getBundleId())).andReturn(new Long(0)).anyTimes();
        EasyMock.expect(systemBundle.getBundleContext()).andReturn(bundleContext);
        bundleContext.addBundleListener((BundleListener) EasyMock.anyObject());
        bundleContext.addServiceListener((ServiceListener) EasyMock.anyObject());
        EasyMock.expect(bundleContext.getBundles()).andReturn(new Bundle[] { systemBundle });
        final Capture c = new Capture();
        EasyMock.expect(bundleContext.createFilter((String) capture(c))).andAnswer(new IAnswer() {
            public Object answer() throws Throwable {
                return FilterImpl.newInstance((String) c.getValue());
View Full Code Here


        EasyMock.expect(systemBundle.getHeaders()).andReturn(new Hashtable());
        EasyMock.expect(systemBundle.getRegisteredServices()).andReturn(null);
        EasyMock.expect(new Long(systemBundle.getBundleId())).andReturn(new Long(0)).anyTimes();
        EasyMock.expect(systemBundle.getBundleContext()).andReturn(bundleContext);
        bundleContext.addBundleListener((BundleListener) EasyMock.anyObject());
        bundleContext.addServiceListener((ServiceListener) EasyMock.anyObject());
        EasyMock.expect(bundleContext.getBundles()).andReturn(new Bundle[] { systemBundle });
        EasyMock.expect(bundleContext.createFilter(null)).andReturn(new Filter() {
            public boolean match(ServiceReference reference) {
                return true;
            }
View Full Code Here

          return ctx.getBundle(0).getBundleContext();
        }
      });
      if (systemBundle == null) systemBundle = ctx;
      systemBundle.addBundleListener(cacheClearoutListener);
      systemBundle.addServiceListener(cacheClearoutListener);
    }
  }

  private static final class ServiceKey
  {
View Full Code Here

            // Register the JNDI service listener
            jndiServiceListener = new JNDIServiceListener(syscontext);
            try {
                String filter = "(" + Constants.OBJECTCLASS + "=" + ObjectFactory.class.getName() + ")";
                syscontext.addServiceListener(jndiServiceListener, filter);
            } catch (InvalidSyntaxException e) {
                // ignore
            }

            // Register the socket-binding services
View Full Code Here

        Filter filter = EasyMock.createMock(Filter.class);
        EasyMock.replay(filter);
       
        BundleContext bc = EasyMock.createMock(BundleContext.class);
        EasyMock.expect(bc.createFilter("(objectClass=org.osgi.service.remoteserviceadmin.EndpointListener)")).andReturn(filter);
        bc.addServiceListener((ServiceListener) EasyMock.anyObject(),
            EasyMock.eq("(objectClass=org.osgi.service.remoteserviceadmin.EndpointListener)"));
        EasyMock.expectLastCall();
        EasyMock.expect(bc.getServiceReferences("org.osgi.service.remoteserviceadmin.EndpointListener", null)).andReturn(null);
        bc.addBundleListener((BundleListener) EasyMock.anyObject());
        EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() {           
View Full Code Here

        Filter filter = EasyMock.createMock(Filter.class);
        EasyMock.replay(filter);
       
        BundleContext bc = EasyMock.createMock(BundleContext.class);
        EasyMock.expect(bc.createFilter("(objectClass=org.osgi.service.remoteserviceadmin.EndpointListener)")).andReturn(filter);
        bc.addServiceListener((ServiceListener) EasyMock.anyObject(),
            EasyMock.eq("(objectClass=org.osgi.service.remoteserviceadmin.EndpointListener)"));
        EasyMock.expectLastCall();
        EasyMock.expect(bc.getServiceReferences("org.osgi.service.remoteserviceadmin.EndpointListener", null)).andReturn(null);
        bc.addBundleListener((BundleListener) EasyMock.anyObject());
        EasyMock.expectLastCall();
View Full Code Here

        EasyMock.expect(bc.createFilter((String) EasyMock.anyObject())).andAnswer(new IAnswer<Filter>() {
            public Filter answer() throws Throwable {
                return FrameworkUtil.createFilter((String) EasyMock.getCurrentArguments()[0]);
            }
        }).anyTimes();
        bc.addServiceListener((ServiceListener) EasyMock.anyObject(),
            EasyMock.eq("(objectClass=org.osgi.service.remoteserviceadmin.EndpointListener)"));
        EasyMock.expectLastCall();
        EasyMock.expect(bc.getServiceReferences("org.osgi.service.remoteserviceadmin.EndpointListener", null)).andReturn(null);
        bc.addBundleListener((BundleListener) EasyMock.anyObject());
        EasyMock.expectLastCall();
View Full Code Here

            // Register the JNDI service listener
            jndiServiceListener = new JNDIServiceListener(syscontext);
            try {
                String filter = "(" + Constants.OBJECTCLASS + "=" + ObjectFactory.class.getName() + ")";
                syscontext.addServiceListener(jndiServiceListener, filter);
            } catch (InvalidSyntaxException e) {
                // ignore
            }

            // Register the socket-binding services
View Full Code Here

            ServiceListener listener = new ServiceListener() {
                public void serviceChanged(ServiceEvent event) {
                    commands.clear();
                }
            };
            context.addServiceListener(listener,
                    String.format("(&(%s=*)(%s=*))",
                            CommandProcessor.COMMAND_SCOPE,
                            CommandProcessor.COMMAND_FUNCTION));
        }
    }
View Full Code Here

                    synchronized (CommandsCompleter.this) {
                        commands.clear();
                    }
                }
            };
            context.addServiceListener(listener,
                    String.format("(&(%s=*)(%s=*))",
                            CommandProcessor.COMMAND_SCOPE,
                            CommandProcessor.COMMAND_FUNCTION));
        }
    }
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.