📄 refcountpeergroupinterface.html
字号:
However we have to make an exception for groups: even the creator of a group does not have access to the real object. So the interface has to forward startApp to the group, which is responsible for ensuring that it is executedonly once (if needed).<P><DD><DL><DT><B>Specified by:</B><DD><CODE><A HREF="../../../../net/jxta/platform/Module.html#startApp(java.lang.String[])">startApp</A></CODE> in interface <CODE><A HREF="../../../../net/jxta/platform/Module.html" title="interface in net.jxta.platform">Module</A></CODE><DT><B>Overrides:</B><DD><CODE><A HREF="../../../../net/jxta/impl/peergroup/PeerGroupInterface.html#startApp(java.lang.String[])">startApp</A></CODE> in class <CODE><A HREF="../../../../net/jxta/impl/peergroup/PeerGroupInterface.html" title="class in net.jxta.impl.peergroup">PeerGroupInterface</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>arg</CODE> - A table of strings arguments.<DT><B>Returns:</B><DD>int status indication.</DL></DD></DL><HR><A NAME="stopApp()"><!-- --></A><H3>stopApp</H3><PRE>public void <B>stopApp</B>()</PRE><DL><DD>This is here for temporary class hierarchy reasons. it is normaly ignored. By definition, the interface object protects the real object's start/stop methods from being called In that case we have to make an exception. Most applications currently assume that they do not share the group object and that they do refer to the real object directly. They call stopApp to signify their intention of no-longer using the group. Now that groups are shared, we convert stopApp to unref for compatibility. We could also just do nothing and let the interface be GC'd but calling unref makes the group go away immediately if not shared, which is what applications that call stopApp expect.<P><DD><DL><DT><B>Specified by:</B><DD><CODE><A HREF="../../../../net/jxta/platform/Module.html#stopApp()">stopApp</A></CODE> in interface <CODE><A HREF="../../../../net/jxta/platform/Module.html" title="interface in net.jxta.platform">Module</A></CODE><DT><B>Overrides:</B><DD><CODE><A HREF="../../../../net/jxta/impl/peergroup/PeerGroupInterface.html#stopApp()">stopApp</A></CODE> in class <CODE><A HREF="../../../../net/jxta/impl/peergroup/PeerGroupInterface.html" title="class in net.jxta.impl.peergroup">PeerGroupInterface</A></CODE></DL></DD><DD><DL></DL></DD></DL><HR><A NAME="getInterface()"><!-- --></A><H3>getInterface</H3><PRE>public <A HREF="../../../../net/jxta/service/Service.html" title="interface in net.jxta.service">Service</A> <B>getInterface</B>()</PRE><DL><DD>Service objects are not manipulated directly to protect usage of the service. A Service interface is returned to access the service methods. <p/>Since THIS is already such an object, it could return itself. However, we want the group to know about the number of interfaces objects floating around, so, we'll have the group make a new one. That way, applications which want to use unref() on interfaces can avoid sharing interface objects by using getInterface() as a sort of clone with the additional ref-counting semantics.<P><DD><DL><DT><B>Specified by:</B><DD><CODE><A HREF="../../../../net/jxta/service/Service.html#getInterface()">getInterface</A></CODE> in interface <CODE><A HREF="../../../../net/jxta/service/Service.html" title="interface in net.jxta.service">Service</A></CODE><DT><B>Overrides:</B><DD><CODE><A HREF="../../../../net/jxta/impl/peergroup/PeerGroupInterface.html#getInterface()">getInterface</A></CODE> in class <CODE><A HREF="../../../../net/jxta/impl/peergroup/PeerGroupInterface.html" title="class in net.jxta.impl.peergroup">PeerGroupInterface</A></CODE></DL></DD><DD><DL><DT><B>Returns:</B><DD>Service An interface object that implements this service and nothing more.</DL></DD></DL><HR><A NAME="getWeakInterface()"><!-- --></A><H3>getWeakInterface</H3><PRE>public <A HREF="../../../../net/jxta/peergroup/PeerGroup.html" title="interface in net.jxta.peergroup">PeerGroup</A> <B>getWeakInterface</B>()</PRE><DL><DD>Returns a weak interface object that represents this group. <p> A weak interface object has no life-cycle privileges over the group that it represents and therefore its users have no accountability. A weak interface object is safe to give away but holds no promise of sustained validity. <p> Whatever code gave away a weak interface object retains the power of terminating the group object from which it was obtained, thereby making the weak interface object invalid. <p> A weak interface object is immutable; its unref and stopApp methods do nothing. Its validity is exactly that of the group or interface object from which it was obtained. <p> A weak interface object can be obtained from an interface object, or from a real group object, or from a weak interface object. In the later case, the object returned may be the original weak interface object since such objects are immutable. <p. Whatever code obtains a weak interface object from a group object or regular interface object, remains entirely liable for invoking unref on the initial object before discarding it. Giving away a weak interface object is not equivalent to transfering ownerhsip of the original. Returns a weak interface object that refers to this interface object rather than to the group directly. The reason for that is that we want the owner of this interface object to be able to invalidate all weak interface objects made out of this interface object, without them keeping a reference to the group object, and without necessarily having to terminate the group.<P><DD><DL><DT><B>Specified by:</B><DD><CODE><A HREF="../../../../net/jxta/peergroup/PeerGroup.html#getWeakInterface()">getWeakInterface</A></CODE> in interface <CODE><A HREF="../../../../net/jxta/peergroup/PeerGroup.html" title="interface in net.jxta.peergroup">PeerGroup</A></CODE><DT><B>Overrides:</B><DD><CODE><A HREF="../../../../net/jxta/impl/peergroup/PeerGroupInterface.html#getWeakInterface()">getWeakInterface</A></CODE> in class <CODE><A HREF="../../../../net/jxta/impl/peergroup/PeerGroupInterface.html" title="class in net.jxta.impl.peergroup">PeerGroupInterface</A></CODE></DL></DD><DD><DL><DT><B>Returns:</B><DD>PeerGroup A weak interface object that implements this group and nothing more.</DL></DD></DL><HR><A NAME="finalize()"><!-- --></A><H3>finalize</H3><PRE>public void <B>finalize</B>()</PRE><DL><DD>stopApp used to be the standard way of giving up on a group instance, but now that goup instance can be shared, the standard of letting go of a peer group is to stop referencing it. Since the peergroup has permanent referers: the threads of the services we need to use the interface object as a super-strong reference. When an interface is finalized, it calls the group's unref method. The unref method stopApps the group when the last reference is gone. To accelerate the un-referencing of groups, applications may call the interface's unref method, but that takes some dicipline since the interface object becomes unusable after that. So, aware applications that use it must also take care of always cloning the interface object instead of sharing it. For compatibility with current apps which call stopApp, we have the interface's stopApp() do nothing as with all other interface objects. An invoker that has a reference to the true group object can still call its stopApp method with the usual result.<P><DD><DL></DL></DD></DL><HR><A NAME="unref()"><!-- --></A><H3>unref</H3><PRE>public void <B>unref</B>()</PRE><DL><DD>Can only be called once. After that the reference is no-longer usuable.<P><DD><DL><DT><B>Specified by:</B><DD><CODE><A HREF="../../../../net/jxta/peergroup/PeerGroup.html#unref()">unref</A></CODE> in interface <CODE><A HREF="../../../../net/jxta/peergroup/PeerGroup.html" title="interface in net.jxta.peergroup">PeerGroup</A></CODE><DT><B>Overrides:</B><DD><CODE><A HREF="../../../../net/jxta/impl/peergroup/PeerGroupInterface.html#unref()">unref</A></CODE> in class <CODE><A HREF="../../../../net/jxta/impl/peergroup/PeerGroupInterface.html" title="class in net.jxta.impl.peergroup">PeerGroupInterface</A></CODE></DL></DD><DD><DL></DL></DD></DL><HR><A NAME="init(net.jxta.peergroup.PeerGroup, net.jxta.id.ID, net.jxta.document.Advertisement)"><!-- --></A><H3>init</H3><PRE>public void <B>init</B>(<A HREF="../../../../net/jxta/peergroup/PeerGroup.html" title="interface in net.jxta.peergroup">PeerGroup</A> pg, <A HREF="../../../../net/jxta/id/ID.html" title="class in net.jxta.id">ID</A> assignedID, <A HREF="../../../../net/jxta/document/Advertisement.html" title="class in net.jxta.document">Advertisement</A> impl)</PRE><DL><DD>This is here for class hierarchy reasons. it is normaly ignored. By definition, the interface object protects the real object's start/stop methods from being called<P><DD><DL><DT><B>Specified by:</B><DD><CODE><A HREF="../../../../net/jxta/platform/Module.html#init(net.jxta.peergroup.PeerGroup, net.jxta.id.ID, net.jxta.document.Advertisement)">init</A></CODE> in interface <CODE><A HREF="../../../../net/jxta/platform/Module.html" title="interface in net.jxta.platform">Module</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>pg</CODE> - The PeerGroup from which this Module can obtain services. If this module is a service, this is also the PeerGroup of which this module is a service.<DD><CODE>assignedID</CODE> - Identity of Module within group. modules can use it as a the root of their namespace to create names that are unique within the group but predictible by the same module on another peer. This is normaly the ModuleClassID which is also the name under which the module is known by other modules. For a group it is the PeerGroupID itself. The parameters of a service, in the Peer configuration, are indexed by the assignedID of that service, and a Service must publish its run-time parameters in the Peer Advertisement under its assigned ID.<DD><CODE>impl</CODE> - The implementation advertisement for this Module. It is permissible to pass null if no implementation advertisement is available. This may happen if the implementation was selected by explicit class name rather than by following an implementation advertisement. Modules are not required to support that style of loading, but if they do, then their documentation should mention it.</DL></DD></DL><HR><A NAME="getImplAdvertisement()"><!-- --></A><H3>getImplAdvertisement</H3><PRE>public <A HREF="../../../../net/jxta/document/Advertisement.html" title="class in net.jxta.document">Advertisement</A> <B>getImplAdvertisement</B>()</PRE><DL><DD>Returns the advertisment for this service.<P><DD><DL><DT><B>Specified by:</B><DD><CODE><A HREF="../../../../net/jxta/service/Service.html#getImplAdvertisement()">getImplAdvertisement</A></CODE> in interface <CODE><A HREF="../../../../net/jxta/service/Service.html" title="interface in net.jxta.service">Service</A></CODE></DL></DD><DD><DL><DT><B>Returns:</B><DD>Advertisement the advertisement.</DL></DD></DL><HR><A NAME="getHomeThreadGroup()"><!-- --></A><H3>getHomeThreadGroup</H3><PRE>public java.lang.ThreadGroup <B>getHomeThreadGroup</B>()</PRE><DL><DD>Returns the Thread Group in which threads for this peer group will live. This is currently used only for debugging purposes so that the source of a thread can be determined.<P><DD><DL><DT><B>Specified by:</B><DD><CODE><A HREF="../../../../net/jxta/peergroup/PeerGroup.html#getHomeThreadGroup()">getHomeThreadGroup</A></CODE> in interface <CODE><A HREF="../../../../net/jxta/peergroup/PeerGroup.html" title="interface in net.jxta.peergroup">PeerGroup</A></CODE></DL></DD><DD><DL><DT><B>Returns:</B><DD>ThreadGroup</DL></DD>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -