Search in sources :

Example 56 with BundleException

use of org.osgi.framework.BundleException in project azure-tools-for-java by Microsoft.

the class HDInsightHelperImpl method openJobViewEditor.

public void openJobViewEditor(Object projectObject, String uuid) {
    try {
        loadHDInsightPlugin();
    } catch (BundleException bundleException) {
        Activator.getDefault().log("Error loading plugin " + HDINSIHGT_BUNDLE_ID, bundleException);
    }
    IClusterDetail clusterDetail = JobViewManager.getCluster(uuid);
    IWorkbench workbench = PlatformUI.getWorkbench();
    IEditorDescriptor editorDescriptor = workbench.getEditorRegistry().findEditor("com.microsoft.azure.hdinsight.jobview");
    try {
        IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
        IEditorPart newEditor = page.openEditor(new JobViewInput(clusterDetail, uuid), editorDescriptor.getId());
    } catch (PartInitException e2) {
        Activator.getDefault().log("Error opening " + clusterDetail.getName(), e2);
    }
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) IEditorDescriptor(org.eclipse.ui.IEditorDescriptor) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) BundleException(org.osgi.framework.BundleException) IEditorPart(org.eclipse.ui.IEditorPart) PartInitException(org.eclipse.ui.PartInitException) IClusterDetail(com.microsoft.azure.hdinsight.sdk.cluster.IClusterDetail) JobViewInput(com.microsoft.azuretools.azureexplorer.editors.JobViewInput)

Example 57 with BundleException

use of org.osgi.framework.BundleException in project aries by apache.

the class BundleFrameworkManagerImpl method isolatedInstall.

private BundleFramework isolatedInstall(Collection<BundleSuggestion> bundlesToBeInstalled, BundleContext parentCtx, AriesApplication app) throws BundleException {
    LOGGER.debug(LOG_ENTRY, "isolatedInstall", new Object[] { bundlesToBeInstalled, app });
    /**
     * Build the configuration information for this application framework
     */
    BundleFrameworkConfiguration config = _bundleFrameworkConfigurationFactory.createBundleFrameworkConfig(app.getApplicationMetadata().getApplicationScope(), parentCtx, app);
    /**
     * Install and start the new isolated bundle framework
     */
    BundleFramework bundleFramework = _bundleFrameworkFactory.createBundleFramework(parentCtx, config);
    // We should now have a bundleFramework
    if (bundleFramework != null) {
        try {
            bundleFramework.init();
            /**
         * Install the bundles into the new framework
         */
            BundleContext frameworkBundleContext = bundleFramework.getIsolatedBundleContext();
            if (frameworkBundleContext != null) {
                for (BundleSuggestion suggestion : bundlesToBeInstalled) bundleFramework.install(suggestion, app);
            }
        } catch (BundleException be) {
            bundleFramework.close();
            throw be;
        } catch (RuntimeException re) {
            bundleFramework.close();
            throw re;
        }
    }
    LOGGER.debug(LOG_EXIT, "isolatedInstall", bundleFramework);
    return bundleFramework;
}
Also used : BundleFramework(org.apache.aries.application.management.spi.framework.BundleFramework) BundleSuggestion(org.apache.aries.application.management.spi.repository.BundleRepository.BundleSuggestion) BundleException(org.osgi.framework.BundleException) BundleFrameworkConfiguration(org.apache.aries.application.management.spi.framework.BundleFrameworkConfiguration) BundleContext(org.osgi.framework.BundleContext)

Example 58 with BundleException

use of org.osgi.framework.BundleException in project aries by apache.

the class ApplicationContextImpl method installBundles.

/**
   * This method finds bundles matching the list of content passed in
   * @param bundlesToFind       bundles to find and start if the bundle is shared.  If isolated, install it.
   * @param shared                      whether the bundles will be shared or isolated
   * @return the result of execution
   */
private void installBundles(List<DeploymentContent> bundlesToFind, boolean shared) throws BundleException {
    LOGGER.debug(LOG_ENTRY, "install", new Object[] { bundlesToFind, Boolean.valueOf(shared) });
    if (!bundlesToFind.isEmpty() || !shared) {
        Iterator<DeploymentContent> it = bundlesToFind.iterator();
        /**
       * Dont install any bundles from the list which are already
       * installed
       */
        Bundle[] sharedBundles = _bundleFrameworkManager.getSharedBundleFramework().getIsolatedBundleContext().getBundles();
        if (shared) {
            if (sharedBundles.length > 0) {
                while (it.hasNext()) {
                    DeploymentContent bundleToFind = it.next();
                    for (Bundle b : sharedBundles) {
                        if (bundleToFind.getContentName().equals(b.getSymbolicName()) && bundleToFind.getExactVersion().equals(b.getVersion())) {
                            it.remove();
                            _bundles.add(b);
                            break;
                        }
                    }
                }
            }
        }
        /**
       * Ask the repository manager to find us a list of suggested bundles
       * to install based on our content list
       */
        Map<DeploymentContent, BundleSuggestion> bundlesToBeInstalled = findBundleSuggestions(bundlesToFind);
        /**
       * Perform the install of the bundles
       */
        try {
            if (shared)
                _bundles.addAll(_bundleFrameworkManager.installSharedBundles(new ArrayList<BundleSuggestion>(bundlesToBeInstalled.values()), makeAppProxy()));
            else
                _bundles.add(_bundleFrameworkManager.installIsolatedBundles(new ArrayList<BundleSuggestion>(bundlesToBeInstalled.values()), makeAppProxy()));
        } catch (BundleException e) {
            LOGGER.debug(LOG_EXCEPTION, e);
            throw e;
        }
    }
    LOGGER.debug(LOG_EXIT, "install");
}
Also used : Bundle(org.osgi.framework.Bundle) BundleSuggestion(org.apache.aries.application.management.spi.repository.BundleRepository.BundleSuggestion) BundleException(org.osgi.framework.BundleException) DeploymentContent(org.apache.aries.application.DeploymentContent)

Example 59 with BundleException

use of org.osgi.framework.BundleException in project aries by apache.

the class ApplicationContextImpl method uninstall.

/**
   * Called to remove the application, if called multiple times the subsequent
   * calls will be ignored.
   * @return whether the uninstallation is successful
   */
protected synchronized void uninstall() throws BundleException {
    LOGGER.debug(LOG_ENTRY, "uninstall");
    if (_state != ApplicationState.UNINSTALLED) {
        // and attempt to stop and uninstall each of them. 
        for (Iterator<Bundle> bundleIter = _bundles.iterator(); bundleIter.hasNext(); ) {
            Bundle bundleToRemove = bundleIter.next();
            if (bundleToRemove.getState() != Bundle.UNINSTALLED) {
                try {
                    // If Bundle is active, stop it first.
                    if (bundleToRemove.getState() == Bundle.ACTIVE) {
                        _bundleFrameworkManager.stopBundle(bundleToRemove);
                    }
                } catch (BundleException be) {
                    LOGGER.debug(LOG_EXCEPTION, be);
                }
                try {
                    // Delegate the uninstall to the bundleFrameworkManager
                    _bundleFrameworkManager.uninstallBundle(bundleToRemove);
                } catch (BundleException be) {
                    LOGGER.debug(LOG_EXCEPTION, be);
                }
            }
            bundleIter.remove();
        }
        _state = ApplicationState.UNINSTALLED;
    }
    LOGGER.debug(LOG_EXIT, "uninstall");
}
Also used : Bundle(org.osgi.framework.Bundle) BundleException(org.osgi.framework.BundleException)

Example 60 with BundleException

use of org.osgi.framework.BundleException in project aries by apache.

the class ApplicationContextManagerImpl method bindBundleFrameworkManager.

public void bindBundleFrameworkManager(BundleFrameworkManager bfm) {
    LOGGER.debug(LOG_ENTRY, "bindBundleFrameworkManager", bfm);
    List<AriesApplicationContext> contexts = new ArrayList<AriesApplicationContext>();
    synchronized (_appToContextMap) {
        contexts.addAll(_appToContextMap.values());
    }
    for (AriesApplicationContext ctx : contexts) {
        try {
            ((ApplicationContextImpl) ctx).open();
        } catch (BundleException e) {
            LOGGER.debug(LOG_EXCEPTION, e);
        }
    }
    LOGGER.debug(LOG_EXIT, "bindBundleFrameworkManager");
}
Also used : AriesApplicationContext(org.apache.aries.application.management.AriesApplicationContext) ArrayList(java.util.ArrayList) BundleException(org.osgi.framework.BundleException)

Aggregations

BundleException (org.osgi.framework.BundleException)99 Bundle (org.osgi.framework.Bundle)54 IOException (java.io.IOException)31 Test (org.junit.Test)19 File (java.io.File)15 ArrayList (java.util.ArrayList)13 InputStream (java.io.InputStream)10 FileInputStream (java.io.FileInputStream)9 BundleContext (org.osgi.framework.BundleContext)9 HashMap (java.util.HashMap)8 Map (java.util.Map)7 InvalidSyntaxException (org.osgi.framework.InvalidSyntaxException)7 Hashtable (java.util.Hashtable)5 Manifest (java.util.jar.Manifest)5 ServiceReference (org.osgi.framework.ServiceReference)5 Version (org.osgi.framework.Version)5 BundleStartLevel (org.osgi.framework.startlevel.BundleStartLevel)5 LowDiskException (android.taobao.atlas.runtime.LowDiskException)4 TimeoutException (java.util.concurrent.TimeoutException)4 AtomicReference (java.util.concurrent.atomic.AtomicReference)4