KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > core > internal > plugins > InternalPlatform


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.core.internal.plugins;
12
13 import java.net.URL JavaDoc;
14 import org.eclipse.core.internal.model.RegistryLoader;
15 import org.eclipse.core.runtime.*;
16 import org.eclipse.core.runtime.model.Factory;
17 import org.eclipse.core.runtime.model.PluginRegistryModel;
18 import org.osgi.framework.BundleContext;
19 import org.osgi.framework.BundleException;
20
21
22 /**
23  * @deprecated Marking as deprecated to remove the warnings
24  */

25 public class InternalPlatform {
26     private static IPluginRegistry registry = null;
27
28     public static IPluginRegistry getPluginRegistry() {
29         if (registry == null) {
30             registry = new PluginRegistry();
31         }
32         return registry;
33     }
34
35     public static IPluginDescriptor getPluginDescriptor(String JavaDoc pluginId) {
36         return getPluginRegistry().getPluginDescriptor(pluginId);
37     }
38
39     public static void installPlugins(URL JavaDoc[] installURLs) throws CoreException {
40         String JavaDoc message = Policy.bind("platform.errorInstalling"); //$NON-NLS-1$
41
MultiStatus result = new MultiStatus(Platform.PI_RUNTIME, 0, message, null);
42         BundleContext context = org.eclipse.core.internal.runtime.InternalPlatform.getDefault().getBundleContext();
43         for (int i = 0; i < installURLs.length; i++) {
44             try {
45                 context.installBundle(installURLs[i].toExternalForm());
46             } catch (BundleException e) {
47                 IStatus status = new Status(IStatus.ERROR, Platform.PI_RUNTIME, 0, org.eclipse.core.internal.plugins.Policy.bind("platform.cannotInstallPlugin", installURLs[i].toExternalForm()), e); //$NON-NLS-1$
48
result.merge(status);
49             }
50         }
51         if (!result.isOK())
52             throw new CoreException(result);
53     }
54
55
56     /**
57      * Convenience method equivalent to parsePlugins(URL[], Factory, boolean) where debug is set to false.
58      * @see #parsePlugins(URL[], Factory, boolean)
59      */

60     public static PluginRegistryModel parsePlugins(URL JavaDoc[] pluginPath, Factory factory) {
61         return parsePlugins(pluginPath, factory, false);
62     }
63
64     /**
65      * Returns a plug-in registry containing all of the plug-ins discovered
66      * on the given plug-in path. Any problems encountered are added to
67      * the status managed by the supplied factory.
68      * <p>
69      * The given plug-in path is the list of locations in which to look for plug-ins.
70      * If an entry identifies a directory (i.e., ends in a '/'), this method
71      * attempts to scan all sub-directories for plug-ins. Alternatively, an
72      * entry may identify a particular plug-in manifest (<code>plugin.xml</code>) file.
73      * </p>
74      * <p>
75      * <b>Note:</b> this method does not affect the running platform. It is intended
76      * for introspecting installed plug-ins on this and other platforms. The returned
77      * registry is <b>not</b> the same as the platform's registry.
78      * </p>
79      *
80      * @param pluginPath the list of locations in which to look for plug-ins
81      * @param factory the factory to use to create runtime model objects
82      * @param debug turn the debug information on or off
83      * @return the registry of parsed plug-ins
84      */

85     public synchronized static PluginRegistryModel parsePlugins(URL JavaDoc[] pluginPath, Factory factory, boolean debug) {
86         return RegistryLoader.parseRegistry(pluginPath, factory, debug);
87     }
88
89 }
90
Popular Tags