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

📄 endpointservice.java

📁 jxme的一些相关程序,主要是手机上程序开发以及手机和计算机通信的一些程序资料,程序编译需要Ant支持
💻 JAVA
字号:
/*
 * Copyright (c) 2001 Sun Microsystems, Inc.  All rights
 * reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * 3. The end-user documentation included with the redistribution,
 *    if any, must include the following acknowledgment:
 *       "This product includes software developed by the
 *       Sun Microsystems, Inc. for Project JXTA."
 *    Alternately, this acknowledgment may appear in the software itself,
 *    if and wherever such third-party acknowledgments normally appear.
 *
 * 4. The names "Sun", "Sun Microsystems, Inc.", "JXTA" and "Project JXTA" must
 *    not be used to endorse or promote products derived from this
 *    software without prior written permission. For written
 *    permission, please contact Project JXTA at http://www.jxta.org.
 *
 * 5. Products derived from this software may not be called "JXTA",
 *    nor may "JXTA" appear in their name, without prior written
 *    permission of Sun.
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL SUN MICROSYSTEMS OR
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 * ====================================================================
 *
 * This software consists of voluntary contributions made by many
 * individuals on behalf of Project JXTA.  For more
 * information on Project JXTA, please see
 * <http://www.jxta.org/>.
 *
 * This license is based on the BSD license adopted by the Apache Foundation.
 *
 * $Id: EndpointService.java,v 1.2 2002/03/04 20:18:38 echtcherbina Exp $
 */

package net.jxta.endpoint;

import net.jxta.service.Service;
import net.jxta.document.Advertisement;
import net.jxta.peergroup.PeerGroup;
import net.jxta.exception.PeerGroupException;

import java.io.IOException;
import java.util.Enumeration;

/**
 * The EndpointService Service provides a frontend API and enviroment to all
 * endpoint protocols. Applications can use the Endpoint API directely if they
 * need to understand and control the topology of the JXTA network. In general,
 * application are not expected to use this API.
 * <p>
 * @since JXTA 1.0
 */

public interface EndpointService extends Service {

    /**
     * Returns the group to which this EndpointServiceImpl is attached.
     *
     * @return PeerGroup the group.
     */
    public PeerGroup getGroup ();

    /**
     * Returns an enumeration of the endpoint protocols available to this
     * endpoint service.
     *
     * @return Enumeration the enumeration.
     */
    public Enumeration getEndpointProtocols ();

    /**
     * Returns a new Message object suitable for use with this endpoint
     * service.
     *
     * @return Message the new message.
     */
    public Message newMessage ();

    /**
     * Builds an EndpointAddress out the the given URI string.
     * The resulting EndpointAddress uniquely identifies a message listener
     * at a given network address.
     *
     * @param Uri the uri. The structure of the Uri is as follows:
     * protocol://address/[serviceName][/serviceParam]
     * @return EndpointAddress the EndpointAddress object corresponding to the given URI.
     */
    public EndpointAddress newEndpointAddress (String Uri);

    /**
     * Builds and returns an EndpointMessager that may be used to send
     * messages via this endpoint to the given destination     *
     * @param addr the destination address. This address specifies an
     * endpoint protocol, the address of a peer by that endpoint protocol, and
     * a serviceName and serviceParam, the concatenation of which designates
     * uniquely the listener to which the messages must be delivered on arrival.
     * <p>
     * @param addr the Endpoint Address of the destination.
     * @return EndpointMessenger the messenger. null is returned if the destination
     * address is not reachable.
     * @throws IOException is thrown if a network problem happened.
     * @see net.jxta.endpoint.EndpointAddress
     */
    public EndpointMessenger getMessenger (EndpointAddress addr)
        throws IOException;

    /**
     * Propagates the given message through all the endpoint protocols that
     * are available to this endpoint. Some or all of these endpoint protocols
     * may silently drop the message. Each endpoint protocol may interpret the
     * resquest for propagation differenly. The endpointService does not
     * define which destinations the message will actually reach.
     *
     * The concatenation of the serviceName and serviceParam arguments
     * uniquely designates the listener to which the message must be delivered
     * on arrival.
     *
     * @param srcMsg the message to be propagated.
     * @param serviceName a destination service name
     * @param serviceParam a destination queue name within that service
     * @throws IOException if the message could not be propagated
     **/
    public void propagate (Message srcMsg,
			   String serviceName,
                           String serviceParam)
        throws IOException;

    /**
     * Registers an incoming messages listener.
     * Each incoming message addressed to the queue specified by
     * the given address will be passed to the given listener.
     * The address is usually formed by concatenating the the name of the
     * invoking service and a parameter unique to that service accross all
     * groups (the group ID is normally included for that purpose).
     * <p>
     * For a message to match this address, it must have been sent through
     * an EndpointMessenger obtained by providing an EndpointAddress constructed
     * with matching serviceName and serviceParam (see newEndpointAddress and
     * getMessenger), or by invoking propagate with matching serviceName
     * and serviceParam.
     * <p>
     * If a listener is already registered with the given address, an
     * IllegalArgumentException is thrown.
     * <p>
     * @param address a queue name, unique accross all groups on this peer,
     * @param listener a listener for these messages.
     * @throws IllegalArgumentException is thrown if a parameter was illegal.
     */
    public void addListener(String address, EndpointListener listener)
        throws IllegalArgumentException;

    /**
     * Removes the given listener previously registered under the given
     * address.
     *
     * @param address Endpoint Address associated to the listener.
     * @param listener a listener to remove.
     * @return boolean true is there was such a registration, false otherwise.
     */
    public boolean removeListener(String address, EndpointListener listener);

    /**
     * Registers an incoming messages filter listener.
     * Each incoming message which contains an element with the specified name
     * will be passed to the given listener.
     *
     * If a listener is already registered with the given address, an
     * IllegalArgumentException is thrown.
     *
     * @param elementName a message element name
     * @param listener    a listener for these messages.
     * @param incoming    whether to run the filter on the incoming or
     *                    outgoing messages.
     * @throws IllegalArgumentException is thrown when one of the argument
     * is illegal.
     */
    public void addFilterListener(String                 elementName, 
				  EndpointFilterListener listener,
				  boolean                incoming)
        throws IllegalArgumentException;


    /**
     * Removes the given listener previously registered under the given
     * element name
     *
     * @param address  the address the listener was registered for
     * @param listener the listener that was registered
     * @param incoming whether it was registered for incoming or outgoing
     *                 messages.
     */

    public void removeFilterListener(String address, 
					EndpointFilterListener listener,
					boolean                incoming);

    /**
     * Handles the given incoming message by calling the listener specified
     * by its destination as returned by the getDestAddress() method of the
     * message.
     * <p>
     * If the message cannot be delivered an IOException is thrawn.
     *
     * @param msg The message to be delivered.
     * @throws IOException when demux was not able to process the incoming message.
     */
    public void demux (Message msg) throws IOException;

    /**
     * Returns the endpoint protocol registered under the given name.
     *
     * @param name Canonical name of the Transport Protocl (http, tcp, jxtatls...).
     * @return EndpointProtocol the protocol if found. null otherwise.
     */
    public EndpointProtocol getEndpointProtocolByName (String name);

    /**
     * Verifies that the given address can be reached.
     * The verification is performed by the endpoint protocol designated
     * by the given address, as returned by the getProtocolName() method
     * of this address.
     * <p>
     * The method, and accuracy of the verification depends upon each endpoint
     * protocol.
     * <p>
     * @param addr is the Endpoint Address to ping.
     * @return boolean true if the address can be reached. False otherwise.
     */
    public boolean ping (EndpointAddress addr);


    /**
     * Installs the given endpoint protocol in this endpoint.
     *
     * The endpoint protocol becomes usable by the endpoint service to send
     * unicast messages and optionaly propagation and ping messages. The
     * endpoint service becomes usable by this protocol to handle incoming
     * messages.
     * <p>
     * If an endpoint protocol by the same name exists in one of the parent
     * endpoint services, this protocol takes precedence and hides the other.
     * <p>
     * If an endpoint protocol by that name exists in this endpoint service,
     * addEndpointProtocol fails and throws IllegalArgumentException.
     * <p>
     * @param proto the endpoint protocol to be installed.
     * @throws PeerGroupException is thrown when the Endpoint Protocol could not be
     * installed.
     */
    public void addEndpointProtocol (EndpointProtocol proto)
        throws PeerGroupException;

    /**
     * Removes the given endpoint protocol from this endpoint service.
     * <p>
     * Protocols remove themselves from the list when stopped.
     * If someone wants to remove a protocol from the list, it has to call
     * stopApp explicitly if relevant. "If relevant" is not all that easy
     * to figure out, since the same protocol object may be present in
     * several groups. conclusion. Don't do it if you don't know what you're
     * doing.
     * <p>
     * @param proto the protocol to be removed.
     */
    public void removeEndpointProtocol(EndpointProtocol proto);
}

⌨️ 快捷键说明

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