Package org.osgi.framework

Examples of org.osgi.framework.Bundle


  }

  void stop() {
    synchronized(services) {
      for(Iterator it = services.keySet().iterator(); it.hasNext(); ) {
        Bundle b = (Bundle)it.next();
        ThreadIOImpl tio = (ThreadIOImpl)services.get(b);
        tio.stop();
      }
    }
  }
View Full Code Here


  void beforeRestart() {
    System.out.println("In beforeRestart!");
    ServiceTracker tracker = new ServiceTracker(bc, PackageAdmin.class.getName(), null);
    tracker.open();
    PackageAdmin pa = (PackageAdmin)tracker.getService();
    Bundle extensionBC = null;
    Bundle extensionFW = null;
   
    try {
      extensionBC = Util.installBundle(bc, "bundleExt1_test-1.0.0.jar");
      extensionFW = Util.installBundle(bc, "bundleExt2_test-1.0.0.jar");
    } catch (BundleException e1) {
View Full Code Here

  // This is more or less copied from BundleArchiveImpl
  // It should rather be moved to the Util class
  private Collection getNativeCode(String bnc)   {
    if (bnc != null) {
      Bundle b = bc.getBundle();
      Hashtable fwprops = new Hashtable();
      fwprops.put(Constants.FRAMEWORK_PROCESSOR,
                bc.getProperty(Constants.FRAMEWORK_PROCESSOR));
      fwprops.put(Constants.FRAMEWORK_OS_NAME,
                bc.getProperty(Constants.FRAMEWORK_OS_NAME));
View Full Code Here

  }

  public boolean runTest() {
    try {
      Bundle fragment = Util.installBundle(bc, "bundleEnd152_test-1.0.0.jar");
      Bundle bundle = Util.installBundle(bc, "bundleEnd151_test-1.0.0.jar");
      bundle.start();

      for (int i = 0; i < loops; i++) {  
        for (int o = 0; o < locales.length; o++) {
          bundle.getHeaders(locales[o]);
        }
      }
     
      bundle.uninstall();
      fragment.uninstall();
    } catch (BundleException e) {
      e.printStackTrace();
    }
    return true;
View Full Code Here

            Bundle[] bundles = bundleContext.getBundles();

            for (int i = 0; i < bundles.length; i++) {
                try {
                    Bundle bundle = bundles[i];
                    BundleInfo info = bundleService.getInfo(bundle);
                    String bundleStateString = info.getState().toString();
                    CompositeData data = new CompositeDataSupport(bundleType,
                            new String[]{"ID", "Name", "Version", "Start Level", "State"},
                            new Object[]{info.getBundleId(), info.getSymbolicName(), info.getVersion(), info.getStartLevel(), bundleStateString});
View Full Code Here

        return install(url, false);
    }

    public long install(String url, boolean start) throws MBeanException {
        try {
            Bundle bundle = bundleContext.installBundle(url, null);
            if (start) {
                bundle.start();
            }
            return bundle.getBundleId();
        } catch (Exception e) {
            throw new MBeanException(null, e.getMessage());
        }
    }
View Full Code Here

        this.bundleContext = bundleContext;
    }

    @Override
    public String getDiag(long bundleId) {
        Bundle bundle = bundleContext.getBundle(bundleId);
        if (bundle == null) {
            throw new RuntimeException("Bundle with id " + bundleId + " not found");
        }
        return bundleService.getDiag(bundle);
    }
View Full Code Here

    private void getFragments(BundleRevision revision) {
        List<BundleWire> wires = revision.getWiring().getProvidedWires(BundleRevision.HOST_NAMESPACE);
        if (wires != null) {
            for (BundleWire w : wires) {
                Bundle b = w.getRequirerWiring().getBundle();
                this.fragments.add(b);
            }
        }
    }
View Full Code Here

    private void getFragmentHosts(BundleRevision revision) {
        List<BundleWire> wires = revision.getWiring().getRequiredWires(BundleRevision.HOST_NAMESPACE);
        if (wires != null) {
            for (BundleWire w : wires) {
                Bundle b = w.getProviderWiring().getBundle();
                if (b != null) {
                    this.fragmentHosts.add(b);
                }
            }
        }
View Full Code Here

        // id is a number
        Pattern pattern = Pattern.compile("^\\d+$");
        Matcher matcher = pattern.matcher(id);
       
        if (matcher.find()) {
            Bundle bundle = this.getBundleById(id);
            addBundle(bundle, id, bundles);
            return;
        }

        // id as a number range
        pattern = Pattern.compile("^(\\d+)-(\\d+)$");
        matcher = pattern.matcher(id);
        if (matcher.find()) {
            int index = id.indexOf('-');
            long startId = Long.parseLong(id.substring(0, index));
            long endId = Long.parseLong(id.substring(index + 1));
            if (startId < endId) {
                for (long i = startId; i <= endId; i++) {
                    Bundle bundle = bundleContext.getBundle(i);
                    addBundle(bundle, String.valueOf(i), bundles);
                }
            }
            return;
        }
View Full Code Here

TOP

Related Classes of org.osgi.framework.Bundle

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.