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

📄 activatable.java

📁 JAVA基本类源代码,大家可以学习学习!
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
     * associated with <code>id</code>. An object can no longer be     * activated via that <code>id</code>.     *     * @param id the object's activation identifier     * @exception UnknownObjectException if object (<code>id</code>) is unknown     * @exception ActivationException if activation system is not running     * @exception RemoteException if remote call to activation system fails     * @since 1.2     */    public static void unregister(ActivationID id)	throws UnknownObjectException, ActivationException, RemoteException    {	ActivationGroup.getSystem().unregisterObject(id);    }    /**     * This <code>exportObject</code> method may be invoked explicitly     * by an "activatable" object, that does not extend the     * <code>Activatable</code> class, in order to both a) register     * the object's activation descriptor, constructed from the supplied     * <code>location</code>, and <code>data</code>, with     * the activation system (so the object can be activated), and     * b) export the remote object, <code>obj</code>, on a specific     * port (if port=0, then an anonymous port is chosen). Once the     * object is exported, it can receive incoming RMI calls.<p>     *     * This method does not need to be called if <code>obj</code>     * extends <code>Activatable</code>, since the first constructor     * calls this method.     *     * @param obj the object being exported     * @param location the object's code location     * @param data the object's bootstrapping data     * @param restart if true, the object is restarted (reactivated) when     * either the activator is restarted or the object's activation group     * is restarted after an unexpected crash; if false, the object is only     * activated on demand.  Specifying <code>restart</code> to be     * <code>true</code> does not force an initial immediate activation of     * a newly registered object;  initial activation is lazy.     * @param port the port on which the object is exported (an anonymous     * port is used if port=0)     * @return the activation identifier obtained from registering the     * descriptor, <code>desc</code>, with the activation system     * the wrong group     * @exception ActivationException if activation group is not active     * @exception RemoteException if object registration or export fails     * @since 1.2     */    public static ActivationID exportObject(Remote obj,					    String location,					    MarshalledObject data,					    boolean restart,					    int port)	throws ActivationException, RemoteException    {	ActivationDesc desc = new ActivationDesc(obj.getClass().getName(),						 location, data, restart);	ActivationID id = ActivationGroup.getSystem().registerObject(desc);	Remote stub = exportObject(obj, id, port);	ActivationGroup.currentGroup().activeObject(id, obj); 	return id;    }    /**     * This <code>exportObject</code> method may be invoked explicitly     * by an "activatable" object, that does not extend the     * <code>Activatable</code> class, in order to both a) register     * the object's activation descriptor, constructed from the supplied     * <code>location</code>, and <code>data</code>, with     * the activation system (so the object can be activated), and     * b) export the remote object, <code>obj</code>, on a specific     * port (if port=0, then an anonymous port is chosen). Once the     * object is exported, it can receive incoming RMI calls.<p>     *     * This method does not need to be called if <code>obj</code>     * extends <code>Activatable</code>, since the first constructor     * calls this method.     *     * @param obj the object being exported     * @param location the object's code location     * @param data the object's bootstrapping data     * @param restart if true, the object is restarted (reactivated) when     * either the activator is restarted or the object's activation group     * is restarted after an unexpected crash; if false, the object is only     * activated on demand.  Specifying <code>restart</code> to be     * <code>true</code> does not force an initial immediate activation of     * a newly registered object;  initial activation is lazy.     * @param port the port on which the object is exported (an anonymous     * port is used if port=0)     * @param csf the client-side socket factory for making calls to the     * remote object     * @param ssf the server-side socket factory for receiving remote calls     * @return the activation identifier obtained from registering the     * descriptor, <code>desc</code>, with the activation system     * the wrong group     * @exception ActivationException if activation group is not active     * @exception RemoteException if object registration or export fails     * @since 1.2     */    public static ActivationID exportObject(Remote obj,					    String location,					    MarshalledObject data,					    boolean restart,					    int port,					    RMIClientSocketFactory csf,					    RMIServerSocketFactory ssf)	throws ActivationException, RemoteException    {	ActivationDesc desc = new ActivationDesc(obj.getClass().getName(),						 location, data, restart);	ActivationID id = ActivationGroup.getSystem().registerObject(desc);	Remote stub = exportObject(obj, id, port, csf, ssf);	ActivationGroup.currentGroup().activeObject(id, obj); 	return id;    }    /**      * Export the activatable remote object to the RMI runtime to make     * the object available to receive incoming calls. The object is     * exported on an anonymous port, if <code>port</code> is zero. <p>     *     * During activation, this <code>exportObject</code> method should     * be invoked explicitly by an "activatable" object, that does not     * extend the <code>Activatable</code> class. There is no need for objects     * that do extend the <code>Activatable</code> class to invoke this     * method directly; this method is called by the second constructor     * above (which a subclass should invoke from its special activation     * constructor).     *      * @return the stub for the activatable remote object     * @param obj the remote object implementation     * @param id the object's  activation identifier     * @param port the port on which the object is exported (an anonymous     * port is used if port=0)     * @exception RemoteException if object export fails     * @since 1.2     */    public static Remote exportObject(Remote obj,				      ActivationID id,				      int port)	throws RemoteException    {	Object[] args = new Object[] { id, new Integer(port) }; 	return exportObject(obj, "ActivatableServerRef",			    idPortParamTypes, args);    }    /**      * Export the activatable remote object to the RMI runtime to make     * the object available to receive incoming calls. The object is     * exported on an anonymous port, if <code>port</code> is zero. <p>     *     * During activation, this <code>exportObject</code> method should     * be invoked explicitly by an "activatable" object, that does not     * extend the <code>Activatable</code> class. There is no need for objects     * that do extend the <code>Activatable</code> class to invoke this     * method directly; this method is called by the second constructor     * above (which a subclass should invoke from its special activation     * constructor).     *      * @return the stub for the activatable remote object     * @param obj the remote object implementation     * @param id the object's  activation identifier     * @param port the port on which the object is exported (an anonymous     * port is used if port=0)     * @param csf the client-side socket factory for making calls to the     * remote object     * @param ssf the server-side socket factory for receiving remote calls     * @exception RemoteException if object export fails     * @since 1.2     */    public static Remote exportObject(Remote obj,				      ActivationID id,				      int port,				      RMIClientSocketFactory csf,				      RMIServerSocketFactory ssf)	throws RemoteException    {	Object[] args = new Object[] { id, new Integer(port), csf, ssf }; 	return exportObject(obj, "ActivatableServerRef",			    idPortFactoryParamTypes, args);    }        /**     * Remove the remote object, obj, from the RMI runtime. If     * successful, the object can no longer accept incoming RMI calls.     * If the force parameter is true, the object is forcibly unexported     * even if there are pending calls to the remote object or the     * remote object still has calls in progress.  If the force     * parameter is false, the object is only unexported if there are     * no pending or in progress calls to the object.     *     * @param obj the remote object to be unexported     * @param force if true, unexports the object even if there are     * pending or in-progress calls; if false, only unexports the object     * if there are no pending or in-progress calls     * @return true if operation is successful, false otherwise     * @exception NoSuchObjectException if the remote object is not     * currently exported     * @since 1.2     */    public static boolean unexportObject(Remote obj, boolean force)	throws NoSuchObjectException    {	return sun.rmi.transport.ObjectTable.unexportObject(obj, force);    }    /*     * Create an instance of given server ref type with constructor chosen     * by indicated paramters and supplied with given arguements, and     * export remote object with it.     *     * All this code needs to be duplicated from UnicastRemoteObject     * because java does not have "friends".     */    private static Remote exportObject(Remote obj, String refType,				       Class[] params, Object[] args)	throws RemoteException    {	// compose name of server ref class and find it	String refClassName = RemoteRef.packagePrefix + "." + refType;	Class refClass;	try {	    refClass = Class.forName(refClassName);	} catch (ClassNotFoundException e) {	    throw new ExportException(		"No class found for server ref type: " + refType);	}	if (!ServerRef.class.isAssignableFrom(refClass)) {	    throw new ExportException(		"Server ref class not instance of " +		ServerRef.class.getName() + ": " + refClass.getName());	}	// create server ref instance using given constructor and arguments	ServerRef serverRef;	try {	    java.lang.reflect.Constructor cons =		refClass.getConstructor(params);	    serverRef = (ServerRef) cons.newInstance(args);	    // if impl does extend Activatable, set its ref	    if (obj instanceof Activatable)		((Activatable)obj).ref = serverRef;	} catch (Exception e) {	    throw new ExportException(		"Exception creating instance of server ref class: " +		refClass.getName(), e);	}	return serverRef.exportObject(obj, null);    }}

⌨️ 快捷键说明

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