⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.java

📁 OSGI这是一个中间件,与UPNP齐名,是用于移植到嵌入式平台之上
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
        } else if ("-startlevel".equals(args[i])) {          if (i+1 < args.length) {             int n = Integer.parseInt(args[i+1]);            if(framework.startLevelService != null) {              if(n == 1) {                if(Debug.startlevel) {                  Debug.println("Entering startlevel compatibility mode, all bundles will have startlevel == 1");                }                framework.startLevelService.bCompat = true;              }	                    framework.startLevelService.setStartLevel(n);            } else {              println("No start level service - ignoring start level " + n, 0);            }            i++;          } else {            error("No integer level for startlevel command");          }        } else {          error("Unknown option: " + args[i] +                 "\nUse option -help to see all options");        }      } catch (BundleException e) {        Throwable ne = e.getNestedException();        if (ne != null) {          e.getNestedException().printStackTrace(System.err);        } else {          e.printStackTrace(System.err);        }        error("Command \"" + args[i] +               ((i+1 < args.length && !args[i+1].startsWith("-")) ?               " " + args[i+1] :               "") +              "\" failed, " + e.getMessage());      } catch (Exception e) {        e.printStackTrace(System.err);        error("Command \"" + args[i] +               ((i+1 < args.length && !args[i+1].startsWith("-")) ?               " " + args[i+1] :               "") +              "\" failed, " + e.getMessage());      }    }    if (!framework.active) {      try {        framework.launch(0);        println("Framework launched", 0);      } catch (Throwable t) {        if (t instanceof BundleException) {          BundleException be = (BundleException) t;          Throwable ne = be.getNestedException();          if (ne != null) t = ne;        }        t.printStackTrace(System.err);        error("Framework launch failed, " + t.getMessage());      }    }  }  /**   * Returns a bundle id from a string. The string is either a number   * or the location used for the bundle in the   * "-install bundleLocation" or "-istart" command.   * @param base Base URL to complete locations with.   * @param idLocation bundle id or location of the bundle to lookup   */  static private long getBundleID(String[] base, String idLocation ) {    try {      return Long.parseLong(idLocation);    } catch (NumberFormatException nfe) {      long id = framework.getBundleId( completeLocation( base, idLocation ) );      if (id!=-1) {        return id;      }       throw new IllegalArgumentException        ("Invalid bundle id/location: " +idLocation);    }  }  /**   ** Complete location relative to the base Jars URL.   ** @param base Base URLs to complete with; first match is used.   ** @param location The location to be completed.   **/  static private String completeLocation( String[] base, String location )  {    // Handle file: case where topDir is not ""    if(bZeroArgs && location.startsWith("file:jars/") && !topDir.equals("")) {      location = ("file:" + topDir + location.substring(5)).replace('\\', '/');      println("mangled bundle location to " + location, 2);    }    int ic = location.indexOf(":");    if (ic<2 || ic>location.indexOf("/")) {      println("location=" + location, 2);      // URL without protocol complete it.      for (int i=0; i<base.length; i++) {        println("base[" + i + "]=" + base[i], 2);        try {          URL url = new URL( new URL(base[i]), location );          println("check " + url, 2);          if ("file".equals(url.getProtocol())) {            File f = new File(url.getFile());            if (!f.exists() || !f.canRead()) {              continue; // Noope; try next.            }                      } else if ("http".equals(url.getProtocol())) {            HttpURLConnection uc = (HttpURLConnection) url.openConnection();            uc.connect();            int rc = uc.getResponseCode();            uc.disconnect();            if (rc!=HttpURLConnection.HTTP_OK) {              println("Can't access HTTP bundle: " + url + ", response code=" + rc, 0);              continue; // Noope; try next.            }          } else {            // Generic case; Check if we can read data from this URL            InputStream is = null;            try {              is = url.openStream();            } finally {              if (is!=null) is.close();            }          }          location = url.toString();          println("found location=" + location, 5);          break; // Found.        } catch (Exception _e) {        }      }    }    return location;  }  public static void frameworkEvent(final FrameworkEvent evt) {    framework.checkAdminPermission();    final FrameworkEvent e2 = new FrameworkEvent(evt.getType(),                                                 evt.getBundle(),                                                 evt.getThrowable());    AccessController.doPrivileged(new PrivilegedAction() {        public Object run() {          framework.listeners.frameworkEvent(e2);          return null;        }      });  }    /**   * Shutdown framework.   *   * <p>   * This code is called in SystemBundle.stop(), which is the   * preferred way to shut down the framework.   * </p>   */  static public void shutdown(final int exitcode) {    framework.checkAdminPermission();    AccessController.doPrivileged(new PrivilegedAction() {        public Object run() {          Thread t = new Thread() {              public void run() {                if (bootMgr != 0) {                  try {                    framework.stopBundle(bootMgr);                  } catch (BundleException e) {                    System.err.println("Stop of BootManager failed, " +                                       e.getNestedException());                  }                }                framework.shutdown();                if("true".equals(System.getProperty(EXITONSHUTDOWN_PROP, "true"))) {                  System.exit(exitcode);                } else {                  println("Framework shutdown, skipped System.exit()", 0);                }              }            };          t.setDaemon(false);          t.start();          return null;        }      });  }  /**   * Restart framework.   * <p>   * This code is called in SystemBundle.update()   * </p>   */  static public void restart() {    framework.checkAdminPermission();    AccessController.doPrivileged(new PrivilegedAction() {        public Object run() {          Thread t = new Thread() {              public void run() {                if (bootMgr != 0) {                  try {                    framework.stopBundle(bootMgr);                  } catch (BundleException e) {                    System.err.println("Stop of BootManager failed, " +                                       e.getNestedException());                  }                }                framework.shutdown();                try {                  if (bootMgr != 0) {                    framework.launch(bootMgr);                  } else {                    framework.launch(0);                  }                } catch (Exception e) {                  println("Failed to restart framework", 0);                }              }            };          t.setDaemon(false);          t.start();          return null;        }      });  }  /**   * Expand all occurance of -xargs URL into a new   * array without any -xargs   */  static String[] expandArgs(String[] argv) {    Vector v = new Vector();    int i = 0;    while(i < argv.length) {      if ("-xargs".equals(argv[i])) {        if (i+1 < argv.length) {           String   xargsPath = argv[i+1];          String[] moreArgs = loadArgs(xargsPath, argv);          i++;          String[] r = expandArgs(moreArgs);          for(int j = 0; j < r.length; j++) {            v.addElement(r[j]);          }        } else {          throw new IllegalArgumentException("-xargs without argument");        }      } else {        v.addElement(argv[i]);      }      i++;    }    String[] r = new String[v.size()];        v.copyInto(r);    return r;  }  /**   * Print help for starting the platform.   */  static void printResource(String name) {    try {      System.out.println(new String(Util.readResource(name)));    } catch (Exception e) {      System.out.println("No resource '" + name + "' available");    }  }  public static final String[] FWPROPS = new String[] {    Constants.FRAMEWORK_VENDOR,    Constants.FRAMEWORK_VERSION,    Constants.FRAMEWORK_LANGUAGE,    Constants.FRAMEWORK_OS_NAME ,    Constants.FRAMEWORK_OS_VERSION,    Constants.FRAMEWORK_PROCESSOR,    Constants.FRAMEWORK_EXECUTIONENVIRONMENT,        };  /**   * Print help for starting the platform.   */  static void printJVMInfo() {        try {      Properties props = System.getProperties();      System.out.println("--- System properties ---");      for(Enumeration e = props.keys(); e.hasMoreElements(); ) {        String key = (String)e.nextElement();        System.out.println(key + ": " + props.get(key));      }      System.out.println("\n--- Framework properties ---");      for(int i = 0; i < FWPROPS.length; i++) {        System.out.println(FWPROPS[i] + ": " + framework.getProperty(FWPROPS[i]));      }    } catch (Exception e) {      e.printStackTrace();    }  }  // Read version info from manifest  static String readVersion() {    try {      return (new String(Util.readResource("/version"))).trim();    } catch (Exception e) {      return "<no version found>";    }  }  /**   * Helper method which tries to find default xargs files.   */  static String getDefaultXArgs(String[] oldArgs) {    boolean bInit = false;    // If the old args has an -init somewhere, make sure    // we don't use the restart default xargs    for(int i = 0; i < oldArgs.length; i++) {      if("-init".equals(oldArgs[i])) {        bInit = true;      }    }    String fwDirStr = System.getProperty(FWDIR_PROP, FWDIR_DEFAULT);    File fwDir      = new File(fwDirStr);    File xargsFile  = null;        // avoid getParentFile since some profiles don't have this    String defDirStr = (new File(fwDir.getAbsolutePath())).getParent();    File   defDir    = defDirStr != null ? new File(defDirStr) : null;        println("fwDir="+ fwDir, 2);    println("defDir="+ defDir, 2);    println("bInit=" + bInit, 2);    // ..and select appropiate xargs file    if(defDir != null) {      topDir = defDir + File.separator;      try {        String osName = Alias.unifyOsName(System.getProperty("os.name"));        File f = new File(defDir, "init_" + osName + ".xargs");        if(f.exists()) {          defaultXArgsInit = f.getName();          println("found OS specific xargs=" + defaultXArgsInit, 1);        }      } catch (Exception ignored) {        // No OS specific xargs found      }      if(!bInit && (fwDir.exists() && fwDir.isDirectory())) {        println("found fwdir at " + fwDir.getAbsolutePath(), 1);        xargsFile = new File(defDir, defaultXArgsStart);        if(xargsFile.exists()) {          println("\n" +                   "Default restart xargs file: " + xargsFile +                   "\n" +                   "To reinitialize, remove the " + fwDir.toString() +                   " directory\n",                   5);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -