Package org.osgi.framework

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


        } catch (InvalidSyntaxException e) {
            LOGGER.error("Syntax error looking up service {} using filter {}", EventHandler.class.getName(), EventHandler.MANAGED_FILTER);
        } finally {
            if (references != null) {
                for (ServiceReference ref : references) {
                    bundleContext.ungetService(ref);
                }
            }
        }
        return result;
    }
View Full Code Here


                Bundle bundle = ref.getBundle();
                if (bundle != null) {
                    BundleContext ctx = getBundleContextForServiceLookup();
                    if (ctx != null) {
                      try {
                          ctx.ungetService(ref);
                      } catch (IllegalStateException ise) {
                        // we don't care it doesn't exist so, shrug.
                      }
                    }
                }
View Full Code Here

            BundleContext context = framework.getBundleContext();
            ServiceReference[] references = context.getServiceReferences(ManagementAgentFactory.class.getName(), null);
            if (references != null) {
                ManagementAgentFactory service = (ManagementAgentFactory) context.getService(references[0]);
                service.updated(m_configuration);
                context.ungetService(references[0]);
            }
            else {
                System.err.println("Can not find Management Agent config service! Aborting..");
                System.exit(1);
            }
View Full Code Here

        Object service = ctx.getService(ref);
        if (service != null) {
          className = service.getClass().getName();
        }

        ctx.ungetService(ref);
       
        return new NameClassPair(serviceId, className, true);
      }

      public void release(BundleContext ctx, ServiceReference ref)
View Full Code Here

        return new Binding(serviceId, service, true);
      }

      public void release(BundleContext ctx, ServiceReference ref)
      {
        ctx.ungetService(ref);
      }
    });
  }

  public Object lookup(Name name) throws NamingException
View Full Code Here

                try {
                    if (target instanceof Function) {
                        function = (Function) target;
                    }
                } finally {
                    context.ungetService(reference);
                }
            }
        } catch (Throwable t) {
        }
        return function;
View Full Code Here

 
  private void ungetService(String serviceClassName, String filter) {
    BundleContext bundleContext = fTestBundle.getBundleContext();
    ServiceReference reference = getServiceReference(bundleContext, serviceClassName, filter);
    if (reference != null) {
      bundleContext.ungetService(reference);
    }
  }
 
  private ServiceReference getServiceReference(BundleContext bundleContext, String serviceClassName, String filter) {
    if (filter == null || filter.equals("")) {
View Full Code Here

                    if (target instanceof Function) {
                        return unProxy((Function) target);
                    }
                } finally {
                    if (context != null) {
                        context.ungetService(reference);
                    }
                }
            }
            Bundle bundle = FrameworkUtil.getBundle(CommandsCompleter.class);
            BundleContext bc = bundle.getBundleContext();
View Full Code Here

            if (pm != null) {
                Callable call = pm.unwrap(function);
                if (call != null) {
                    return unProxy((Function) call.call());
                }
                bc.ungetService(ref);
            }
        } catch (Throwable t) {
        }
        return function;
    }
View Full Code Here

        assertNotSame("The proxy should not be the same object as the original service", testService, proxyService);
        assertEquals("Doing it", proxyService.doit());

        EasyMock.reset(clientBC);
        EasyMock.expect(clientBC.ungetService(sr)).andReturn(true).once();
        EasyMock.replay(clientBC);

        proxyServiceSF.ungetService(clientBundle, null, proxyService);

        EasyMock.verify(clientBC);
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.