• Bundle
  •  package org.osgi.framework;
    public interface Bundle extends Comparable<Bundle> {
    int UNINSTALLED = 0x00000001;
    int INSTALLED = 0x00000002;
    int RESOLVED = 0x00000004;
    int STARTING = 0x00000008;
    int STOPPING = 0x00000010;
    int ACTIVE = 0x00000020;
    int START_TRANSIENT = 0x00000001;
    int START_ACTIVATION_POLICY = 0x00000002;
    int STOP_TRANSIENT = 0x00000001;
    int SIGNERS_ALL = ;
    int SIGNERS_TRUSTED = ;
    int getState();
    voidstart(int options) throws BundleException;
    void start() throws BundleException;
    voidstop(int options) throws BundleException;
    void stop() throws BundleException;
    void update(InputStream input) throws BundleException;
    void update() throws BundleException;
    void uninstall() throws BundleException;
    Dictionary<String, String> getHeaders();
    long getBundleId();
    String getLocation();
    ServiceReference<?>[] getRegisteredServices();
    ServiceReference<?>[] getServicesInUse();
    boolean hasPermission(Object permission);
    URL getResource(String name);
    Enumeration<String> getEntryPaths(String path);
    URL getEntry(String path);
    long getLastModified();
    Enumeration<URL> findEntries(String path, String filePattern, boolean recurse);
    BundleContext getBundleContext();
    Map<X509Certificate, List<X509Certificate>> getSignerCertificates(int signersType);
    Version getVersion();
    <A> A adapt(Class<A> type);
    File getDataFile(String filename);
    }
  • Framework: also known as Bundle
  •  package org.osgi.framework.launch;
    
     import java.io.InputStream;
    import java.net.URL;
    import java.util.Enumeration;
    import org.osgi.framework.Bundle;
    import org.osgi.framework.BundleException;
    import org.osgi.framework.Constants;
    import org.osgi.framework.FrameworkEvent;
    public interface Framework extends Bundle {
    void init() throws BundleException;
    FrameworkEvent waitForStop(long timeout) throws InterruptedException;
    void start() throws BundleException;
    void start(int options) throws BundleException;
    void stop() throws BundleException;
    void stop(int options) throws BundleException;
    void uninstall() throws BundleException;
    void update() throws BundleException;
    void update(InputStream in) throws BundleException;
    long getBundleId();
    String getLocation();
    String getSymbolicName();
    Enumeration<String> getEntryPaths(String path);
    URL getEntry(String path);
    Enumeration<URL> findEntries(String path, String filePattern, boolean recurse);
    <A> A adapt(Class<A> type);
    }
  • FrameworkFactory
  •  package org.osgi.framework.launch;
    import java.util.Map;
    import org.osgi.framework.Bundle;
    /**
    * A factory for creating {@link Framework} instances.
    * @ThreadSafe
    * @noimplement
    * @version $Id: 1684e14aa98a1f6e1ff3e0f3afa2c55982210f72 $
    */
    public interface FrameworkFactory {
    Framework newFramework(Map<String, String> configuration);
    }
  • EquinoxLauncher: implement the interface of Framework

Configuration

dev.properties

 #
#Wed Sep 11 08:37:19 CST 2013
com.dragon.osgi.hello=bin
@ignoredot@=true

config.ini

 #Configuration File
#Wed Sep 11 08:37:19 CST 2013
osgi.bundles=reference\:file\:G\:/eclipse/eclipse/plugins/org.apache.felix.gogo.runtime_0.8.0.v201108120515.jar@start,reference\:file\:G\:/eclipse/eclipse/plugins/org.apache.felix.gogo.shell_0.8.0.v201110170705.jar@start,reference\:file\:G\:/eclipse/eclipse/plugins/org.apache.felix.gogo.command_0.8.0.v201108120515.jar@start,reference\:file\:G\:/eclipse/Workspace/com.dragon.osgi.hello@start,reference\:file\:G\:/eclipse/eclipse/plugins/org.eclipse.equinox.console_1.0.0.v20120522-1841.jar@start
osgi.bundles.defaultStartLevel=4
osgi.install.area=file\:G\:\\eclipse\\eclipse
osgi.framework=file\:G\:/eclipse/eclipse/plugins/org.eclipse.osgi_3.8.0.v20120529-1548.jar
osgi.configuration.cascaded=false
  •  /*******************************************************************************
    * Copyright (c) 2006, 2011 Cognos Incorporated, IBM Corporation and others.
    * All rights reserved. This program and the accompanying materials
    * are made available under the terms of the Eclipse Public License v1.0
    * which accompanies this distribution, and is available at
    * http://www.eclipse.org/legal/epl-v10.html
    *
    *******************************************************************************/
    package org.eclipse.osgi.framework.internal.core; import java.io.UnsupportedEncodingException;
    import java.lang.reflect.Method;
    import java.net.URL;
    import java.net.URLDecoder;
    import java.security.CodeSource;
    import java.util.*;
    import org.eclipse.core.runtime.internal.adaptor.EclipseAdaptorMsg;
    import org.eclipse.osgi.util.NLS; /*
    * This class should be used in ALL places in the framework implementation to get "system" properties.
    * The static methods on this class should be used instead of the System#getProperty, System#setProperty etc methods.
    */
    public class FrameworkProperties { /**@GuardedBy FrameworkProperties.class*/
    private static Properties properties; // A flag of some sort will have to be supported.
    // Many existing plugins get framework propeties directly from System instead of BundleContext.
    // Note that the OSGi TCK is one example where this property MUST be set to false because many TCK bundles set and read system properties.
    private static final String USING_SYSTEM_PROPERTIES_KEY = "osgi.framework.useSystemProperties"; //$NON-NLS-1$
    private static final String PROP_FRAMEWORK = "osgi.framework"; //$NON-NLS-1$
    private static final String PROP_INSTALL_AREA = "osgi.install.area"; //$NON-NLS-1$ public static Properties getProperties() {
    SecurityManager sm = System.getSecurityManager();
    if (sm != null)
    sm.checkPropertiesAccess();
    return internalGetProperties(null);
    } public static String getProperty(String key) {
    return getProperty(key, null);
    } public static String getProperty(String key, String defaultValue) {
    SecurityManager sm = System.getSecurityManager();
    if (sm != null)
    sm.checkPropertyAccess(key);
    return internalGetProperties(null).getProperty(key, defaultValue);
    } public static String setProperty(String key, String value) {
    SecurityManager sm = System.getSecurityManager();
    if (sm != null)
    sm.checkPermission(new PropertyPermission(key, "write")); //$NON-NLS-1$
    return (String) internalGetProperties(null).put(key, value);
    } public static String clearProperty(String key) {
    SecurityManager sm = System.getSecurityManager();
    if (sm != null)
    sm.checkPermission(new PropertyPermission(key, "write")); //$NON-NLS-1$
    return (String) internalGetProperties(null).remove(key);
    } private static synchronized Properties internalGetProperties(String usingSystemProperties) {
    if (properties == null) {
    Properties systemProperties = System.getProperties();
    if (usingSystemProperties == null)
    usingSystemProperties = systemProperties.getProperty(USING_SYSTEM_PROPERTIES_KEY);
    if (usingSystemProperties == null || usingSystemProperties.equalsIgnoreCase(Boolean.TRUE.toString())) {
    properties = systemProperties;
    } else {
    // use systemProperties for a snapshot
    // also see requirements in Bundlecontext.getProperty(...))
    properties = new Properties();
    // snapshot of System properties for uses of getProperties who expect to see framework properties set as System properties
    // we need to do this for all system properties because the properties object is used to back
    // BundleContext#getProperty method which expects all system properties to be available
    synchronized (systemProperties) {
    // bug 360198 - must synchronize on systemProperties to avoid concurrent modification exception
    properties.putAll(systemProperties);
    }
    }
    }
    return properties;
    } public static synchronized void setProperties(Map<String, String> input) {
    if (input == null) {
    // just use internal props; note that this will reuse a previous set of properties if they were set
    internalGetProperties("false"); //$NON-NLS-1$
    return;
    }
    properties = null;
    Properties toSet = internalGetProperties("false"); //$NON-NLS-1$
    for (Iterator<String> keys = input.keySet().iterator(); keys.hasNext();) {
    String key = keys.next();
    Object value = input.get(key);
    if (value instanceof String) {
    toSet.setProperty(key, (String) value);
    continue;
    }
    value = input.get(key);
    if (value != null)
    toSet.put(key, value);
    else
    toSet.remove(key);
    }
    } public static synchronized boolean inUse() {
    return properties != null;
    } public static void initializeProperties() {
    // initialize some framework properties that must always be set
    if (getProperty(PROP_FRAMEWORK) == null || getProperty(PROP_INSTALL_AREA) == null) {
    CodeSource cs = FrameworkProperties.class.getProtectionDomain().getCodeSource();
    if (cs == null)
    throw new IllegalArgumentException(NLS.bind(EclipseAdaptorMsg.ECLIPSE_STARTUP_PROPS_NOT_SET, PROP_FRAMEWORK + ", " + PROP_INSTALL_AREA)); //$NON-NLS-1$
    URL url = cs.getLocation();
    // allow props to be preset
    if (getProperty(PROP_FRAMEWORK) == null)
    setProperty(PROP_FRAMEWORK, url.toExternalForm());
    if (getProperty(PROP_INSTALL_AREA) == null) {
    String filePart = url.getFile();
    setProperty(PROP_INSTALL_AREA, filePart.substring(0, filePart.lastIndexOf('/')));
    }
    }
    // always decode these properties
    setProperty(PROP_FRAMEWORK, decode(getProperty(PROP_FRAMEWORK)));
    setProperty(PROP_INSTALL_AREA, decode(getProperty(PROP_INSTALL_AREA)));
    } public static String decode(String urlString) {
    //try to use Java 1.4 method if available
    try {
    Class<? extends URLDecoder> clazz = URLDecoder.class;
    Method method = clazz.getDeclaredMethod("decode", new Class[] {String.class, String.class}); //$NON-NLS-1$
    //first encode '+' characters, because URLDecoder incorrectly converts
    //them to spaces on certain class library implementations.
    if (urlString.indexOf('+') >= 0) {
    int len = urlString.length();
    StringBuffer buf = new StringBuffer(len);
    for (int i = 0; i < len; i++) {
    char c = urlString.charAt(i);
    if (c == '+')
    buf.append("%2B"); //$NON-NLS-1$
    else
    buf.append(c);
    }
    urlString = buf.toString();
    }
    Object result = method.invoke(null, new Object[] {urlString, "UTF-8"}); //$NON-NLS-1$
    if (result != null)
    return (String) result;
    } catch (Exception e) {
    //JDK 1.4 method not found -- fall through and decode by hand
    }
    //decode URL by hand
    boolean replaced = false;
    byte[] encodedBytes = urlString.getBytes();
    int encodedLength = encodedBytes.length;
    byte[] decodedBytes = new byte[encodedLength];
    int decodedLength = 0;
    for (int i = 0; i < encodedLength; i++) {
    byte b = encodedBytes[i];
    if (b == '%') {
    byte enc1 = encodedBytes[++i];
    byte enc2 = encodedBytes[++i];
    b = (byte) ((hexToByte(enc1) << 4) + hexToByte(enc2));
    replaced = true;
    }
    decodedBytes[decodedLength++] = b;
    }
    if (!replaced)
    return urlString;
    try {
    return new String(decodedBytes, 0, decodedLength, "UTF-8"); //$NON-NLS-1$
    } catch (UnsupportedEncodingException e) {
    //use default encoding
    return new String(decodedBytes, 0, decodedLength);
    }
    } private static int hexToByte(byte b) {
    switch (b) {
    case '0' :
    return 0;
    case '1' :
    return 1;
    case '2' :
    return 2;
    case '3' :
    return 3;
    case '4' :
    return 4;
    case '5' :
    return 5;
    case '6' :
    return 6;
    case '7' :
    return 7;
    case '8' :
    return 8;
    case '9' :
    return 9;
    case 'A' :
    case 'a' :
    return 10;
    case 'B' :
    case 'b' :
    return 11;
    case 'C' :
    case 'c' :
    return 12;
    case 'D' :
    case 'd' :
    return 13;
    case 'E' :
    case 'e' :
    return 14;
    case 'F' :
    case 'f' :
    return 15;
    default :
    throw new IllegalArgumentException("Switch error decoding URL"); //$NON-NLS-1$
    }
    }
    }

    FrameworkProperties

  •  package org.eclipse.osgi.framework.internal.core;
    
     import java.io.*;
    import java.net.URL;
    import java.security.*;
    import java.security.cert.X509Certificate;
    import java.util.*;
    import org.eclipse.core.runtime.adaptor.EclipseStarter;
    import org.eclipse.osgi.baseadaptor.BaseAdaptor;
    import org.eclipse.osgi.framework.adaptor.FrameworkAdaptor;
    import org.osgi.framework.*; public class EquinoxLauncher implements org.osgi.framework.launch.Framework { private volatile Framework framework;
    private volatile Bundle systemBundle;
    private final Map<String, String> configuration;
    private volatile ConsoleManager consoleMgr = null; public EquinoxLauncher(Map<String, String> configuration) {
    this.configuration = configuration;
    }
    public void init() {
    checkAdminPermission(AdminPermission.EXECUTE);
    if (System.getSecurityManager() == null)
    internalInit();
    else {
    AccessController.doPrivileged(new PrivilegedAction<Object>() {
    public Object run() {
    internalInit();
    return null;
    }
    });
    }
    }
    synchronized Framework internalInit() {
    if ((getState() & (Bundle.ACTIVE | Bundle.STARTING | Bundle.STOPPING)) != 0)
    return framework; // no op if (System.getSecurityManager() != null && configuration.get(Constants.FRAMEWORK_SECURITY) != null)
    throw new SecurityException("Cannot specify the \"" + Constants.FRAMEWORK_SECURITY + "\" configuration property when a security manager is already installed."); //$NON-NLS-1$ //$NON-NLS-2$ Framework current = framework;
    if (current != null) {
    current.close();
    framework = null;
    systemBundle = null;
    }
    ClassLoader tccl = Thread.currentThread().getContextClassLoader();
    try {
    FrameworkProperties.setProperties(configuration);
    FrameworkProperties.initializeProperties();
    // make sure the active framework thread is used
    setEquinoxProperties(configuration);
    current = new Framework(new BaseAdaptor(new String[0]));
    consoleMgr = ConsoleManager.startConsole(current);
    current.launch();
    framework = current;
    systemBundle = current.systemBundle;
    } finally {
    ClassLoader currentCCL = Thread.currentThread().getContextClassLoader();
    if (currentCCL != tccl)
    Thread.currentThread().setContextClassLoader(tccl);
    }
    return current;
    }
    private void setEquinoxProperties(Map<String, String> configuration) {
    Object threadBehavior = configuration == null ? null : configuration.get(Framework.PROP_FRAMEWORK_THREAD);
    if (threadBehavior == null) {
    if (FrameworkProperties.getProperty(Framework.PROP_FRAMEWORK_THREAD) == null)
    FrameworkProperties.setProperty(Framework.PROP_FRAMEWORK_THREAD, Framework.THREAD_NORMAL);
    } else {
    FrameworkProperties.setProperty(Framework.PROP_FRAMEWORK_THREAD, (String) threadBehavior);
    } // set the compatibility boot delegation flag to false to get "standard" OSGi behavior WRT boot delegation (bug 344850)
    if (FrameworkProperties.getProperty(Constants.OSGI_COMPATIBILITY_BOOTDELEGATION) == null)
    FrameworkProperties.setProperty(Constants.OSGI_COMPATIBILITY_BOOTDELEGATION, "false"); //$NON-NLS-1$
    // set the support for multiple host to true to get "standard" OSGi behavior (bug 344850)
    if (FrameworkProperties.getProperty("osgi.support.multipleHosts") == null) //$NON-NLS-1$
    FrameworkProperties.setProperty("osgi.support.multipleHosts", "true"); //$NON-NLS-1$ //$NON-NLS-2$
    // first check props we are required to provide reasonable defaults for
    Object windowSystem = configuration == null ? null : configuration.get(Constants.FRAMEWORK_WINDOWSYSTEM);
    if (windowSystem == null) {
    windowSystem = FrameworkProperties.getProperty(EclipseStarter.PROP_WS);
    if (windowSystem != null)
    FrameworkProperties.setProperty(Constants.FRAMEWORK_WINDOWSYSTEM, (String) windowSystem);
    }
    // rest of props can be ignored if the configuration is null
    if (configuration == null)
    return;
    // check each osgi clean property and set the appropriate equinox one
    Object clean = configuration.get(Constants.FRAMEWORK_STORAGE_CLEAN);
    if (Constants.FRAMEWORK_STORAGE_CLEAN_ONFIRSTINIT.equals(clean)) {
    // remove this so we only clean on first init
    configuration.remove(Constants.FRAMEWORK_STORAGE_CLEAN);
    FrameworkProperties.setProperty(EclipseStarter.PROP_CLEAN, Boolean.TRUE.toString());
    }
    }
    public FrameworkEvent waitForStop(long timeout) throws InterruptedException {
    Framework current = framework;
    if (current == null)
    return new FrameworkEvent(FrameworkEvent.STOPPED, this, null);
    return current.waitForStop(timeout);
    }
    public Enumeration<URL> findEntries(String path, String filePattern, boolean recurse) {
    Bundle current = systemBundle;
    if (current == null)
    return null;
    return current.findEntries(path, filePattern, recurse);
    }
    public BundleContext getBundleContext() {
    Bundle current = systemBundle;
    if (current == null)
    return null;
    return current.getBundleContext();
    }
    public long getBundleId() {
    return 0;
    }
    public URL getEntry(String path) {
    Bundle current = systemBundle;
    if (current == null)
    return null;
    return current.getEntry(path);
    }
    public Enumeration<String> getEntryPaths(String path) {
    Bundle current = systemBundle;
    if (current == null)
    return null;
    return current.getEntryPaths(path);
    }
    public Dictionary<String, String> getHeaders() {
    Bundle current = systemBundle;
    if (current == null)
    return null;
    return current.getHeaders();
    }
    public Dictionary<String, String> getHeaders(String locale) {
    Bundle current = systemBundle;
    if (current == null)
    return null;
    return current.getHeaders(locale);
    }
    public long getLastModified() {
    Bundle current = systemBundle;
    if (current == null)
    return System.currentTimeMillis();
    return current.getLastModified();
    }
    public String getLocation() {
    return Constants.SYSTEM_BUNDLE_LOCATION;
    }
    public ServiceReference<?>[] getRegisteredServices() {
    Bundle current = systemBundle;
    if (current == null)
    return null;
    return current.getRegisteredServices();
    }
    public URL getResource(String name) {
    Bundle current = systemBundle;
    if (current == null)
    return null;
    return current.getResource(name);
    }
    public Enumeration<URL> getResources(String name) throws IOException {
    Bundle current = systemBundle;
    if (current == null)
    return null;
    return current.getResources(name);
    }
    public ServiceReference<?>[] getServicesInUse() {
    Bundle current = systemBundle;
    if (current == null)
    return null;
    return current.getServicesInUse();
    }
    public int getState() {
    Bundle current = systemBundle;
    if (current == null)
    return Bundle.INSTALLED;
    return current.getState();
    }
    public String getSymbolicName() {
    return FrameworkAdaptor.FRAMEWORK_SYMBOLICNAME;
    }
    public boolean hasPermission(Object permission) {
    Bundle current = systemBundle;
    if (current == null)
    return false;
    return current.hasPermission(permission);
    }
    public Class<?> loadClass(String name) throws ClassNotFoundException {
    Bundle current = systemBundle;
    if (current == null)
    return null;
    return current.loadClass(name);
    }
    public void start(int options) throws BundleException {
    start();
    }
    public void start() throws BundleException {
    checkAdminPermission(AdminPermission.EXECUTE);
    if (System.getSecurityManager() == null)
    internalStart();
    else
    try {
    AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
    public Object run() {
    internalStart();
    return null;
    }
    });
    } catch (PrivilegedActionException e) {
    throw (BundleException) e.getException();
    }
    }
    private void checkAdminPermission(String actions) {
    SecurityManager sm = System.getSecurityManager();
    if (sm != null)
    sm.checkPermission(new AdminPermission(this, actions));
    }
    void internalStart() {
    if (getState() == Bundle.ACTIVE)
    return;
    Framework current = internalInit();
    int level = 1;
    try {
    level = Integer.parseInt(configuration.get(Constants.FRAMEWORK_BEGINNING_STARTLEVEL));
    } catch (Throwable t) {
    // do nothing
    }
    current.startLevelManager.doSetStartLevel(level);
    }
    public void stop(int options) throws BundleException {
    stop();
    }
    public void stop() throws BundleException {
    Bundle current = systemBundle;
    if (current == null)
    return;
    ConsoleManager currentConsole = consoleMgr;
    if (currentConsole != null) {
    currentConsole.stopConsole();
    consoleMgr = null;
    }
    current.stop();
    }
    public void uninstall() throws BundleException {
    throw new BundleException(Msg.BUNDLE_SYSTEMBUNDLE_UNINSTALL_EXCEPTION, BundleException.INVALID_OPERATION);
    }
    public void update() throws BundleException {
    Bundle current = systemBundle;
    if (current == null)
    return;
    current.update();
    }
    public void update(InputStream in) throws BundleException {
    try {
    in.close();
    } catch (IOException e) {
    // nothing; just being nice
    }
    update();
    }
    public Map<X509Certificate, List<X509Certificate>> getSignerCertificates(int signersType) {
    Bundle current = systemBundle;
    if (current != null)
    return current.getSignerCertificates(signersType);
    @SuppressWarnings("unchecked")
    final Map<X509Certificate, List<X509Certificate>> empty = Collections.EMPTY_MAP;
    return empty;
    }
    public Version getVersion() {
    Bundle current = systemBundle;
    if (current != null)
    return current.getVersion();
    return Version.emptyVersion;
    }
    public <A> A adapt(Class<A> adapterType) {
    Bundle current = systemBundle;
    if (current != null) {
    return current.adapt(adapterType);
    }
    return null;
    }
    public int compareTo(Bundle o) {
    Bundle current = systemBundle;
    if (current != null)
    return current.compareTo(o);
    throw new IllegalStateException();
    }
    public File getDataFile(String filename) {
    Bundle current = systemBundle;
    if (current != null)
    return current.getDataFile(filename);
    return null;
    }
    }

    EquinoxLauncher

    Methods in EquixonLauncher

  •  public EquinoxLauncher(Map<String, String> configuration) {
    this.configuration = configuration;
    }
     public void init() {
    checkAdminPermission(AdminPermission.EXECUTE);
    if (System.getSecurityManager() == null)
    internalInit();
    else {
    AccessController.doPrivileged(new PrivilegedAction<Object>() {
    public Object run() {
    internalInit();
    return null;
    }
    });
    }
    }
    synchronized Framework internalInit() {
    if ((getState() & (Bundle.ACTIVE | Bundle.STARTING | Bundle.STOPPING)) != 0)
    return framework; // no op if (System.getSecurityManager() != null && configuration.get(Constants.FRAMEWORK_SECURITY) != null)
    throw new SecurityException("Cannot specify the \"" + Constants.FRAMEWORK_SECURITY + "\" configuration property when a security manager is already installed."); //$NON-NLS-1$ //$NON-NLS-2$ Framework current = framework;
    if (current != null) {
    current.close();
    framework = null;
    systemBundle = null;
    }
    ClassLoader tccl = Thread.currentThread().getContextClassLoader();
    try {
    FrameworkProperties.setProperties(configuration);
    FrameworkProperties.initializeProperties();
    // make sure the active framework thread is used
    setEquinoxProperties(configuration);
    current = new Framework(new BaseAdaptor(new String[0]));
    consoleMgr = ConsoleManager.startConsole(current);
    current.launch();
    framework = current;
    systemBundle = current.systemBundle;
    } finally {
    ClassLoader currentCCL = Thread.currentThread().getContextClassLoader();
    if (currentCCL != tccl)
    Thread.currentThread().setContextClassLoader(tccl);
    }
    return current;
    }
     public static ConsoleManager startConsole(Framework framework) {
    ConsoleManager consoleManager = new ConsoleManager(framework, FrameworkProperties.getProperty(PROP_CONSOLE));
    consoleManager.startConsole();
    return consoleManager;
    }
     public synchronized void launch() {
    /* Return if framework already started */
    if (active) {
    return;
    }
    /* mark framework as started */
    active = true;
    shutdownEvent = new FrameworkEvent[1];
    if (THREAD_NORMAL.equals(FrameworkProperties.getProperty(PROP_FRAMEWORK_THREAD, THREAD_NORMAL))) {
    Thread fwkThread = new Thread(this, "Framework Active Thread"); //$NON-NLS-1$
    fwkThread.setDaemon(false);
    fwkThread.start();
    }
    /* Resume systembundle */
    if (Debug.DEBUG_GENERAL) {
    Debug.println("Trying to launch framework"); //$NON-NLS-1$
    }
    systemBundle.resume();
    signedContentFactory = new ServiceTracker<SignedContentFactory, SignedContentFactory>(systemBundle.getBundleContext(), SignedContentFactory.class.getName(), null);
    signedContentFactory.open();
     public void run() {
    synchronized (this) {
    while (active)
    try {
    this.wait(1000);
    } catch (InterruptedException e) {
    // do nothing
    }
    }
    }
     private void createSystemBundle() {
    try {
    systemBundle = new InternalSystemBundle(this);
    systemBundle.getBundleData().setBundle(systemBundle);
    } catch (BundleException e) { // fatal error
    e.printStackTrace();
    throw new RuntimeException(NLS.bind(Msg.OSGI_SYSTEMBUNDLE_CREATE_EXCEPTION, e.getMessage()), e);
    }
    }
     protected InternalSystemBundle(Framework framework) throws BundleException {
    super(framework.adaptor.createSystemBundleData(), framework); // startlevel=0 means framework stopped
    Constants.setInternalSymbolicName(bundledata.getSymbolicName());
    state = Bundle.RESOLVED;
    context = createContext();
    fsl = new EquinoxStartLevel();
  • org.eclipse.core.launcher
  •  package org.eclipse.core.launcher;
    public class Main {
    public static void main(String[] args) {
    org.eclipse.equinox.launcher.Main.main(args);
    }
    }
  • org.eclipse.equinox.launcher.Main.java
    • Methods in Main.java
    •  public static void main(String[] args) {
      int result = 0;
      try {
      result = new Main().run(args);
      } catch (Throwable t) {
      // This is *really* unlikely to happen - run() takes care of exceptional situations.
      // In case something weird happens, just dump stack - logging is not available at this point
      t.printStackTrace();
      } finally {
      if (!Boolean.getBoolean(PROP_NOSHUTDOWN))
      // make sure we always terminate the VM
      System.exit(result);
      }
      }
           public int run(String[] args) {
      int result = 0;
      try {
      basicRun(args);
      String exitCode = System.getProperty(PROP_EXITCODE);
      try {
      result = exitCode == null ? 0 : Integer.parseInt(exitCode);
      } catch (NumberFormatException e) {
      result = 17;
      }
      } catch (Throwable e) {
      // only log the exceptions if they have not been caught by the
      // EclipseStarter (i.e., if the exitCode is not 13)
      if (!"13".equals(System.getProperty(PROP_EXITCODE))) { //$NON-NLS-1$
      log("Exception launching the Eclipse Platform:"); //$NON-NLS-1$
      log(e);
      String message = "An error has occurred"; //$NON-NLS-1$
      if (logFile == null)
      message += " and could not be logged: \n" + e.getMessage(); //$NON-NLS-1$
      else
      message += ". See the log file\n" + logFile.getAbsolutePath(); //$NON-NLS-1$
      System.getProperties().put(PROP_EXITDATA, message);
      }
      // Return "unlucky" 13 as the exit code. The executable will recognize
      // this constant and display a message to the user telling them that
      // there is information in their log file.
      result = 13;
      } finally {
      // always try putting down the splash screen just in case the application failed to do so
      takeDownSplash();
      if (bridge != null)
      bridge.uninitialize();
      }
      // Return an int exit code and ensure the system property is set.
      System.getProperties().put(PROP_EXITCODE, Integer.toString(result));
      setExitData();
      return result;
      }
           protected void basicRun(String[] args) throws Exception {
      System.getProperties().put("eclipse.startTime", Long.toString(System.currentTimeMillis())); //$NON-NLS-1$
      commands = args;
      String[] passThruArgs = processCommandLine(args); if (!debug)
      // debug can be specified as system property as well
      debug = System.getProperty(PROP_DEBUG) != null;
      setupVMProperties();
      processConfiguration(); // need to ensure that getInstallLocation is called at least once to initialize the value.
      // Do this AFTER processing the configuration to allow the configuration to set
      // the install location.
      getInstallLocation(); // locate boot plugin (may return -dev mode variations)
      URL[] bootPath = getBootPath(bootLocation); //Set up the JNI bridge. We need to know the install location to find the shared library
      setupJNI(bootPath); //ensure minimum Java version, do this after JNI is set up so that we can write an error message
      //with exitdata if we fail.
      if (!checkVersion(System.getProperty("java.version"), System.getProperty(PROP_REQUIRED_JAVA_VERSION))) //$NON-NLS-1$
      return; // verify configuration location is writable
      if (!checkConfigurationLocation(configurationLocation))
      return; setSecurityPolicy(bootPath);
      // splash handling is done here, because the default case needs to know
      // the location of the boot plugin we are going to use
      handleSplash(bootPath); beforeFwkInvocation();
      invokeFramework(passThruArgs, bootPath);
      }

最新文章

  1. Android Studio同时打开多个项目
  2. 关于lambda表达式的一些学习——基于谓词筛选值序列
  3. HDU - Hotel
  4. 解决wamp mysql数据库出现乱码的问题。
  5. FbinstTool万能启动超级简单教程
  6. 虚拟机备份转移后,网络启动异常,提示“SIOCSIFADDR: No such device”的解决方案
  7. 利用navicat for oracle将数据库全部数据移动
  8. SpringMVC源码解析- HandlerAdapter - ModelFactory(转)
  9. 12本最优秀的Android开发电子书强力推荐
  10. Windows7系统的封装
  11. HADOOP源码分析之RPC(1)
  12. master_pos_wait函数与MySQL主从切换
  13. 利用mk-table-checksum监测Mysql主从数据一致性操作记录
  14. SharePoint JS感悟-js脚本
  15. document,element,node方法
  16. laravel框架详解
  17. 使用python调用淘宝的ip地址库查询接口结合zabbix判断dnspod域名解析是否正确
  18. spring-boot-2.0.3之redis缓存实现,不是你想的那样哦!
  19. OFIFG fault when using DCO in MSP430
  20. .Net连接字符串设置连接池大小显著提高数据库速度

热门文章

  1. LightOJ - 1032 数位DP
  2. Jquery 循环内间隔执行 异步执行
  3. PIE SDK打开GDB、Dwg数据
  4. PIE SDK Pansharp融合
  5. 1.rabbitmq 集群版安装及使用nginx进行四层负载均衡设置
  6. jsoup: Java HTML Parser
  7. python 爬虫系列09-selenium+拉钩
  8. 每日一问:Python生成器和迭代器,with上下文管理工具
  9. this,super,和继承
  10. matlab矩阵中如何去掉重复的行;如何找到相同的行,并找到其位置