Package org.eclipse.equinox.internal.simpleconfigurator.manipulator

Examples of org.eclipse.equinox.internal.simpleconfigurator.manipulator.SimpleConfiguratorManipulatorImpl


     * @param becomeEnabled if true, then ensure that the bundle is set to autostarted
     * if false, the bundle should not be autostarted
     * @return {@link Status#OK_STATUS} if all goes well, otherwise returns the exception
     */
    private IStatus changeSimpleConfiguratorManipulator(boolean becomeEnabled) {
        SimpleConfiguratorManipulator manipulator = new SimpleConfiguratorManipulatorImpl();
        BundleContext bundleContext = null;
        try {
            bundleContext = Platform.getBundle(ScalaJDTWeavingPlugin.ID).getBundleContext();
        } catch (Exception e) {
            return new Status(IStatus.ERROR, ScalaJDTWeavingPlugin.ID, "Cannot get bundleContext", e);
        }
        if (bundleContext == null) {
            return new Status(IStatus.ERROR, ScalaJDTWeavingPlugin.ID, "Cannot get bundleContext", new Exception());
        }
       
        try {
            BundleInfo[] infos = manipulator.loadConfiguration(bundleContext, null);
            BundleInfo weavingInfo = null;
            for (BundleInfo info : infos) {
                if (info.getSymbolicName().equals("org.eclipse.equinox.weaving.aspectj")) {
                    weavingInfo = info;
                    break;
                }
            }
            if (weavingInfo == null) {
                return new Status(IStatus.ERROR, ScalaJDTWeavingPlugin.ID, "Could not find equinox aspects bundle", new Exception());
            }
           
            weavingInfo.setMarkedAsStarted(becomeEnabled);
           
            URL configURL = Platform.getConfigurationLocation().getURL();
            if (configURL == null || !"file".equals(configURL.getProtocol())) {
                throw new IOException("Platform configuration location is not found: " + configURL);
            }
           
            URL installURL = Platform.getInstallLocation().getURL();
            if (installURL == null || !"file".equals(installURL.getProtocol())) {
                throw new IOException("Platform install location is not found: " + installURL);
            }
            manipulator.saveConfiguration(infos, new File(configURL.getFile() + SimpleConfiguratorManipulator.BUNDLES_INFO_PATH), new File(installURL.getFile()).toURI());
           
            return Status.OK_STATUS;
        } catch (IOException e) {
            return new Status(IStatus.ERROR, ScalaJDTWeavingPlugin.ID, "Cannot load configuration", e);
        }
View Full Code Here

TOP

Related Classes of org.eclipse.equinox.internal.simpleconfigurator.manipulator.SimpleConfiguratorManipulatorImpl

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.