Package org.osgi.framework

Examples of org.osgi.framework.BundleContext


       AutoProcessor.AUTO_DEPLOY_DIR_VALUE);
      otherProps.put(AutoProcessor.AUTO_DEPLOY_ACTION_PROPERY,
          AutoProcessor.AUTO_DEPLOY_START_VALUE + ","
              + AutoProcessor.AUTO_DEPLOY_INSTALL_VALUE);

      BundleContext felixBudleContext = felix.getBundleContext();

      AutoProcessor.process(otherProps, felixBudleContext);
      // listen to errors
      felixBudleContext.addFrameworkListener(frameworkErrorListener);
      felixBudleContext.addBundleListener(myBundleListener);
      // Now start Felix instance.
      felix.start();
      System.out.println("felix started");

    } catch (Exception ex) {
View Full Code Here


     * @param name
     */
    public TestFailSafeTransaction(String name)
    {
        super(name);
        BundleContext context = FileAccessServiceLick.bc;
        ServiceReference ref = context
                .getServiceReference(FileAccessService.class.getName());
        this.fileAccessService = (FileAccessService) context.getService(ref);
    }
View Full Code Here

        try {
          ServiceReference[] srs = bc.getServiceReferences(null, "(test.name=" + test.getClass().getName() + ")");
          if(srs == null || srs.length == 0) {
            return;
          }
          BundleContext targetContext = srs[0].getBundle().getBundleContext();
          java.lang.reflect.Method m = test.getClass().getMethod(
              "setBundleContext", new Class[] { BundleContext.class });
          m.invoke(test, new Object[] { targetContext });
        } catch (NoSuchMethodException e) {
          // Skip if no method is found
View Full Code Here

                                  JOptionPane.INFORMATION_MESSAGE,
                                  null);
  }

  public void showVersion() {
    BundleContext bc = Activator.getBC();
    String version = (String)bc.getBundle().getHeaders().get("Bundle-Version");
    String txt = Strings.fmt("str_abouttext",
                             version,
                             bc.getProperty(org.osgi.framework.Constants.FRAMEWORK_VENDOR),
                             bc.getBundle(0).getHeaders().get("Bundle-Version"));

    ImageIcon icon =
      new ImageIcon(getClass().getResource("/kf_300x170.png"));

    JOptionPane.showMessageDialog(frame,
View Full Code Here

  public static void setBundleFilter(BundleFilter bf) {
    bundleFilter = bf;
  }

  public static Bundle[] getBundles() {
    BundleContext bc = getTargetBC();
    if (null==bc) {
      // May happen during stop, when processing events that has been queued.
      return new Bundle[0];
    }
    Bundle[] bl = bc.getBundles();
    if(bundleFilter != null) {
      ArrayList al = new ArrayList();
      for(int i = 0; bl != null && i < bl.length; i++) {
        if(bundleFilter.accept(bl[i])) {
          al.add(bl[i]);
View Full Code Here

  /**
   * Get all service references from the target BC.
   */
  public static ServiceReference[] getTargetBC_getServiceReferences()
  {
    final BundleContext tbc = getTargetBC();
    if(null != tbc) {
      try {
        return tbc.getServiceReferences(null, null);
      } catch (InvalidSyntaxException ise) {
        // Will not happen in this case!
      }
    }
    return null;
View Full Code Here

   */
  public static ServiceReference[]
    getTargetBC_getServiceReferences(final String clazz, final String filter)
    throws InvalidSyntaxException
  {
    final BundleContext tbc = getTargetBC();
    if(null != tbc) {
      return tbc.getServiceReferences(clazz, filter);
    }
    return null;
  }
View Full Code Here

   * Get default service reference from the target BC.
   */
  public static ServiceReference
    getTargetBC_getServiceReference(final String clazz)
  {
    final BundleContext tbc = getTargetBC();
    if(null != tbc) {
      return tbc.getServiceReference(clazz);
    }
    return null;
  }
View Full Code Here

  /**
   * Get default service reference from the target BC.
   */
  public static Object getTargetBC_getService(final ServiceReference sr)
  {
    final BundleContext tbc = getTargetBC();
    if(null != tbc) {
      return tbc.getService(sr);
    }
    return null;
  }
View Full Code Here

  /**
   * Unget a service from the target BC.
   */
  public static boolean getTargetBC_ungetService(final ServiceReference sr)
  {
    final BundleContext tbc = getTargetBC();
    if(null != tbc) {
      return tbc.ungetService(sr);
    }
    return false;
  }
View Full Code Here

TOP

Related Classes of org.osgi.framework.BundleContext

Copyright © 2018 www.massapicom. 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.