Package org.osgi.service.startlevel

Examples of org.osgi.service.startlevel.StartLevel


      * @param bundle the bundle to start.
      * @return whether the bundle was started.
      */
    private boolean startBundle(Bundle bundle)
    {
        StartLevel startLevelSvc = FileInstall.getStartLevel();
        // Fragments can never be started.
        // Bundles can only be started transient when the start level of the framework is high
        // enough. Persistent (i.e. non-transient) starts will simply make the framework start the
        // bundle when the start level is high enough.
        if (startBundles
                && bundle.getState() != Bundle.UNINSTALLED
                && !isFragment(bundle)
                && startLevelSvc.getStartLevel() >= startLevelSvc.getBundleStartLevel(bundle))
        {
            try
            {
                int options = useStartTransient ? Bundle.START_TRANSIENT : 0;
                options |= useStartActivationPolicy ? Bundle.START_ACTIVATION_POLICY : 0;
View Full Code Here


        // Check if we want to convert URLs to maven style
        boolean convertToMavenUrls = Boolean.parseBoolean(configProps.getProperty(PROPERTY_CONVERT_TO_MAVEN_URL, "true"));

        // Retrieve the Start Level service, since it will be needed
        // to set the start level of the installed bundles.
        StartLevel sl = (StartLevel) context.getService(
                context.getServiceReference(org.osgi.service.startlevel.StartLevel.class.getName()));

        // Set the default bundle start level
        int ibsl = 60;
        try {
            String str = configProps.getProperty("karaf.startlevel.bundle");
            if (str != null) {
                ibsl = Integer.parseInt(str);
            }
        } catch (Throwable t) {
        }
        sl.setInitialBundleStartLevel(ibsl);

        // The auto-install property specifies a space-delimited list of
        // bundle URLs to be automatically installed into each new profile;
        // the start level to which the bundles are assigned is specified by
        // appending a ".n" to the auto-install property name, where "n" is
View Full Code Here

    }

    protected void setStartLevel(int level) throws Exception {
        BundleContext ctx = framework.getBundleContext();
        ServiceReference[] refs = ctx.getServiceReferences(StartLevel.class.getName(), null);
        StartLevel sl = (StartLevel) ctx.getService(refs[0]);
        sl.setStartLevel(level);
    }
View Full Code Here

    }

    void startBundle(final ServiceContainer serviceContainer, ServiceName serviceName, OSGiCapability moduleMetaData) {
        ServiceController<Bundle> controller = (ServiceController<Bundle>) serviceContainer.getRequiredService(serviceName);
        Bundle bundle = controller.getValue();
        StartLevel startLevel = injectedStartLevel.getValue();
        startLevel.setBundleStartLevel(bundle, moduleMetaData.getStartLevel());
        try {
            bundle.start();
        } catch (BundleException ex) {
            ROOT_LOGGER.cannotStart(ex, bundle);
        }
View Full Code Here

        return startLevel.get();
    }

    private void initialize() {
        BundleContext syscontext = BundleContextProvider.getBundleContext();
        StartLevel service = getStartLevel(syscontext);
        if (service != null) {
            startLevelProducer.set(service);
        }
    }
View Full Code Here

            startLevelProducer.set(service);
        }
    }

    private StartLevel getStartLevel(BundleContext syscontext) {
        StartLevel result = null;
        if (syscontext != null) {
            ServiceReference sref = syscontext.getServiceReference(StartLevel.class.getName());
            result = (StartLevel) syscontext.getService(sref);
        }
        return result;
View Full Code Here

                    StartLevelAware startLevelAware = method.getAnnotation(StartLevelAware.class);
                    Bundle bundle = getBundle(testCase);
                    if (bundle != null) {
                        int bundleStartLevel = startLevelAware.startLevel();
                        log.fine("Setting bundle start level of " + bundle + " to: " + bundleStartLevel);
                        StartLevel startLevel = getStartLevel();
                        startLevel.setBundleStartLevel(bundle, bundleStartLevel);
                        if (startLevelAware.autostart()) {
                            try {
                                bundle.start();
                            } catch (BundleException ex) {
                                log.log(Level.SEVERE, ex.getMessage(), ex);
View Full Code Here

        }
    }

    private void injectStartLevel(Object testCase, Field field) {
        try {
            StartLevel startLevel = getStartLevel();
            log.warning("Deprecated @Inject StartLevel, use @ArquillianResource StartLevel");
            field.set(testCase, startLevel);
        } catch (IllegalAccessException ex) {
            throw new IllegalStateException("Cannot inject StartLevel", ex);
        }
View Full Code Here

    }

    private StartLevel getStartLevel() {
        BundleContext context = BundleContextProvider.getBundleContext();
        ServiceReference sref = context.getServiceReference(StartLevel.class.getName());
        StartLevel startLevel = (StartLevel) context.getService(sref);
        return startLevel;
    }
View Full Code Here

            Bundle[] bundles = visitor.getBundles();
            PackageAdmin packageAdmin = visitor.getPackageAdmin();
            if (packageAdmin == null) {
                throw new IOException("PackageAdmin is not available");
            }
            StartLevel startLevel = visitor.getStartLevel();
            if (startLevel == null) {
                throw new IOException("StartLevel is not available");
            }
            TabularDataSupport dataSupport = new TabularDataSupport(BUNDLES_TYPE);
            if (bundles != null) {
View Full Code Here

TOP

Related Classes of org.osgi.service.startlevel.StartLevel

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.