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

📄 orb.java

📁 gcc的组建
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
   *   * By default the built-in fully functional ORB is returned. The ORB class   * is found as described in the header of this class.   *   * @param applet the applet. The property org.omg.CORBA.ORBClass,   * if present, defines the used ORB implementation class. If this   * property is not present, the ORB class is found as described in the   * class header.   *   * @param props the properties, may be <code>null</code>.   *   * @return a newly created functional derivative of this abstract class.   */  public static ORB init(Applet applet, Properties props)  {    String ocn = applet.getParameter(FUNCTIONAL_ORB);    String lp = applet.getParameter(LISTENER_PORT);        if (ocn==null && lp!=null)      ocn = DEFAULT_FOCUSED_ORB;        ORB orb = createORB(props, ocn);    orb.set_parameters(applet, props);    return orb;  }  /**   * Creates the working instance of ORB for a standalone application.   *    * By default the built-in fully functional ORB is returned. The ORB class is   * found as described in the header of this class.   *    * @param args the parameters, passed to the applications   * <code>main(String[] args)</code> method, may be <code>null</code>. The   * parameter -org.omg.CORBA.ORBClass <class name> if present, defines the used   * ORB implementation class. If this property is not present, the ORB class is   * found as described in the class header.   *    * @param props application specific properties, may be <code>null</code>.   *    * @return a newly created functional derivative of this abstract class.   */  public static ORB init(String[] args, Properties props)  {    String ocn = null;    String lp = null;    String orbKey = "-" + FUNCTIONAL_ORB;    String lpKey = "-" + LISTENER_PORT;    if (args != null)      if (args.length >= 2)        {          for (int i = 0; i < args.length - 1; i++)            {              if (args[i].equals(orbKey))                ocn = args[i + 1];              if (args[i].equals(lpKey))                lp = args[i + 1];            }        }    if (lp != null && ocn == null)      ocn = DEFAULT_FOCUSED_ORB;    ORB orb = createORB(props, ocn);    orb.set_parameters(args, props);    return orb;  }  /**   * List the initially available CORBA objects (services).   *    * @return a list of services.   *    * @see #resolve_initial_references(String)   */  public abstract String[] list_initial_services();  /**   * Find and return the easily accessible CORBA object, addressed   * by name.  The returned object is typically casted to the more   * specific reference using the <code>narrow(Object)</code> method   * of its helper. The method resolves the following string values,   * returning the working objects:   * <table border="1"><tr><th>String</th><th>Object class</th>   * <th>Object use</th></tr>   *   * <tr><td>NameService</td><td>{@link org.omg.CosNaming.NamingContextExt}</td>   * <td>Finds (usually remote) object by its name.</td></tr>   *   * <tr><td>RootPOA</td><td>{@link org.omg.PortableServer.POA}</td>   * <td>Holds the POA tree for this ORB, where since 1.4 all servants   * should be connected.</td></tr>   *   * <tr><td>RootPOAManager</td><td>{@link org.omg.PortableServer.POAManager}   * </td><td>Regulates (suspends/resumes) the root POA   * activity</td></tr>   *   * <tr><td>POACurrent</td><td>{@link org.omg.PortableServer.Current}   * </td><td>Informs the current thread about the Id and POA of the   * object being currently served (the methods of   * <code>Current</code> return different values for   * different threads).   * </td></tr>   *   * <tr><td>CodecFactory</td><td>{@link org.omg.IOP.Codec}</td>   * <td>Encodes/decodes IDL data types into/from byte arrays.</td>   * </tr>   *   * <tr><td>DynAnyFactory</td><td>{@link org.omg.DynamicAny.DynAnyFactory}</td>   * <td>Creates DynAny's.</td>   * </tr>   *   * <tr><td>PICurrent</td><td>{@link org.omg.PortableInterceptor.Current}</td>   * <td>Contains multiple slots where an interceptor can rememeber the   * request - specific values between subsequent   * calls of the interceptor methods.</td>   * </tr>   *   * </table>   *   * @param name the object name.   * @return the object   * @throws org.omg.CORBA.ORBPackage.InvalidName if the given name   * is not associated with the known object.   */  public abstract Object resolve_initial_references(String name)    throws org.omg.CORBA.ORBPackage.InvalidName;  /**   * Get the IOR reference string for the given object.   * IOR can be compared with the Internet address for a web page,   * it provides means to locate the CORBA service on the web.   * IOR contains the host address, port number, the object identifier   * (key) inside the server, the communication protocol version,   * supported charsets and so on.   *   * @param forObject the CORBA object   * @return the object IOR representation.   * @see #string_to_object(String)   */  public abstract String object_to_string(Object forObject);  /**   * This should perform the implementation dependent unit of work in the   * main thread.   *   * This method is part of the support for the distribute use of the   * single execution thread.   *   * Same as in Suns releases at least till 1.4 inclusive,   * the distribute use of the single thread is not implemented.   * Use multiple threads, provided by jre.   *   * The method returns without action.   */  public void perform_work()  {  }  /**  * Checks if the ORB needs the main thread to perform some work.  * The method should return true if the ORB needs the main thread,  * and false if it does not.  *  * This method is part of the support for the distribute use of the  * single execution thread.  *  * Same as in Suns releases at least till 1.4 inclusive,  * the distributed use of the single thread is not implemented.  * Use multiple threads, provided by jre.  *  * @return false, always.  */  public boolean work_pending()  {    return false;  }  /**   * <p>Find and return the CORBA object, addressed by the given   * string representation. The object can be (an usually is)   * located on a remote computer, possibly running a different   * (not necessary java) CORBA implementation. The returned   * object is typically casted to the more specific reference   * using the <code>narrow(Object)</code> method of its helper.   * </p><p>   * This function supports the following input formats:<br>   * 1. IOR reference (<b>ior:</b>nnnnn ..), usually computer generated.<br>    * 2. <b>corbaloc:</b>[<b>iiop</b>][version.subversion<b>@</b>]<b>:</b>host[<b>:</b>port]<b>/</b><i>key</i>   * defines similar information as IOR reference, but is more human readable.   * This type of reference may also contain multiple addresses (see   * OMG documentation for complete format).<br>   * 3. <b>corbaloc:rir:/</b><i>name</i> defines internal reference on this   * ORB that is resolved using {@link #resolve_initial_references}, passing    * the given <i>name</i> as parameter.<br>   * 4. <b>corbaname:rir:#</b><i>name</i> states that the given <i>name</i>   * must be resolved using the naming service, default for this ORB.<br>   * 5. <b>corbaname:</b>[<b>iiop</b>][version.subversion<b>@</b>]<b>:</b>host[<b>:</b>port]<b>#</b><i>name</i>   * states that the <i>name</i> must be resolved using the naming service   * that runs on the given host at the given port. The ORB expects to find    * there the {@link org.omg.CosNaming.NamingContext} under the key    * "NameService.<br>   * 7. file://[file name] Read the object definition string from the    * file system<br>   * 8. http://[url] Read the object definition string from the provided   * url.<br>   * 9. ftp://[url] Read the object definition string from the provided   * url.<br>   *    * <p>The default port is always 2809. The default iiop version is 1.0   * that now may not always be supported, so we would recommend to specify   * the version explicitly.</p>   * <p>   * The examples of the corbaloc and corbaname addresses:<br>   * corbaname:rir:#xobj - ask local naming service for "xobj".<br>   * corbaname:rir:/NameService#xobj - same (long form).<br>   * corbaname:iiop:1.2@localhost:900#xobj - same, assuming that the naming    * service runs at port 900 on the local host and supports iiop 1.2.<br>   * corbaname:iiop:localhost#xobj - same, assuming that the naming    * service runs at port 2809 on the local host and supports iiop 1.0.<br>   * corbaloc::gnu.xxx.yy/Prod/TradingService - the object exists on the   * host gnu.xxx.yy, port 2809 having the key "Prod/TradingService". Its ORB    * supports iiop 1.0.<br>   * corbaloc::gnu.xxx.yy/Prod/TradingService:801 - the object exists on the   * host gnu.xxx.yy, port 801 having the key "Prod/TradingService". Its ORB    * supports iiop 1.0 (iiop keyword ommitted).<br>   * corbaloc:iiop:1.1@gnu.xxx.yy/Prod/TradingService - the object exists on the   * host gnu.xxx.yy, port 801 having the key "Prod/TradingService". Its ORB    * supports iiop 1.1.<br>   * corbaloc:rir:/NameService - the default naming service.   *   * @param IOR the object IOR representation string.   *   * @return the found CORBA object.   *    * @throws BAD_PARAM if the string being parsed is invalid.   * @throws DATA_CONVERSION if the string being parsed contains unsupported   * prefix or protocol.   *    * @see #object_to_string(org.omg.CORBA.Object)   */  public abstract Object string_to_object(String IOR);  /**   * Start listening on the input socket. This method   * blocks the current thread until {@link #shutdown(boolean)}   * is called and shutdown process is completed.   */  public void run()  {  }  /**   * Shutdown the ORB server.   *   * @param wait_for_completion if true, the current thread is   * suspended untile the shutdown process is complete.   */  public void shutdown(boolean wait_for_completion)  {  }  /**   * Destroy this server, releasing the occupied resources.   * The default method returns without action.   */  public void destroy()  {  }  /**   * Set the ORB parameters. This method is normally called from   * {@link #init(String[], Properties)}.   *   * @param para the parameters, that were passed as the parameters   * to the  <code>main(String[] args)</code> method of the current standalone   * application.   *   * @param props application specific properties that were passed   * as a second parameter in {@link #init(String[], Properties)}).   * Can be <code>null</code>.   */  protected abstract void set_parameters(String[] para, Properties props);  /**   * Set the ORB parameters. This method is normally called from   * {@link #init(Applet, Properties)}.   *   * @param app the current applet.   *   * @param props application specific properties, passed as the second   * parameter in {@link #init(Applet, Properties)}.   * Can be <code>null</code>.   */  protected abstract void set_parameters(Applet app, Properties props);  /**   * Get the property with the given name, searching in the standard   * places for the ORB properties.   */  private static String getCumulatedProperty(Properties props, String property)  {    String orb_cn = null;    if (props != null)      orb_cn = props.getProperty(property, null);    if (orb_cn == null)      orb_cn = System.getProperty(property, null);    if (orb_cn == null)      orb_cn = checkFile(property, "user.home", null);    if (orb_cn == null)      orb_cn = checkFile(property, "java.home", "lib");        return orb_cn;  }  /**   * Check if the property is defined in the existsting file orb.properties.   *   * @param property the property   * @param dir the system property, defining the folder where the   * file could be expected.   * @param subdir subfolder where to look for the file.   *   * @return the property value, null if not found or file does not exist.   */  private static String checkFile(String property, String dir, String subdir)  {    try      {        File f = new File(dir);        if (!f.exists())          return null;        if (subdir != null)          f = new File(f, subdir);        f = new File(f, "orb.properties");        if (!f.exists())          return null;        Properties p = new Properties();        p.load(new BufferedInputStream(new FileInputStream(f)));        return p.getProperty(property, null);      }    catch (IOException ex)      {        return null;      }  }  /**   * Create ORB when its name is possibly known.   *    * @param props properties, possibly containing the ORB name.   * @param orbClassName the direct ORB class name, overriding other possible   * locations, or null if not specified.   */  private static ORB createORB(Properties props, String orbClassName)  {    ORB orb = null;    if (orbClassName == null)      {        orbClassName = getCumulatedProperty(props, FUNCTIONAL_ORB);        if (orbClassName == null)          {            String lp = getCumulatedProperty(props, LISTENER_PORT);            if (lp != null)              orbClassName = DEFAULT_FOCUSED_ORB;            else              orbClassName = DEFAULT_FUNCTIONAL_ORB;          }      }    try      {        orb = (ORB) ObjectCreator.forName(orbClassName).newInstance();      }    catch (ClassNotFoundException ex)      {        noORB(orbClassName, ex);      }    catch (IllegalAccessException ex)      {        noORB(orbClassName, ex);      }    catch (InstantiationException ex)      {        noORB(orbClassName, ex);      }    return orb;  }  /**   * Throw the runtime exception.   *   * @param orb_c the ORB class name.   * @param why the explaining chained exception.   */  private static void noORB(String orb_c, Throwable why)  {    throw new RuntimeException("The ORB " + orb_c + " cannot be instantiated.",                               why                              );  }}

⌨️ 快捷键说明

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