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

📄 endpointserviceinterface.java

📁 JXTA&#8482 is a set of open, generalized peer-to-peer (P2P) protocols that allow any networked devi
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        Messenger found = theRealThing.getCanonicalMessenger(plainAddr, hint);        // Address must not be a supported one.        if (found == null) {            return null;        }        // Get a channel for that servicename and serviceparam. redirect to this group.        // NOTE: This assumes that theRealThing.getGroup() is really the group where the application that obtained        // this interface object lives. This is the case today because all groups have their own endpoint service.        // In the future, interface objects may refer to a group context that is not necessarily the group where        // "therealThing" lives. When that happens, this interface object will have to know which group it works        // for without asking "theRealThing".        ChannelMessenger res = (ChannelMessenger) found.getChannelMessenger(theRealThing.getGroup().getPeerGroupID(),                addr.getServiceName(), addr.getServiceParameter());        synchronized (channelCache) {            // We have to check again. May be we did all that in parallel with some other thread and it beat            // us to the finish line. In which case, substitute the existing one and throw ours away.            Reference<Messenger> existing = channelCache.get(addr);            if (existing != null) {                Messenger messenger = existing.get();                if ((messenger != null) && ((messenger.getState() & Messenger.USABLE) != 0)) {                    return messenger;                }            }            // The listenerAdaptor of this interface obj is used to support the sendMessage-with-listener API.            res.setMessageWatcher(listenerAdaptor);            channelCache.put(res.getDestinationAddress(), new WeakReference<Messenger>(res));        }        return res;    }    /**     * {@inheritDoc}     */    public Messenger getMessenger(EndpointAddress addr) {        return getMessenger(addr, null);    }    /**     * {@inheritDoc}     */    public Messenger getMessenger(EndpointAddress addr, Object hint) {        // Get an unresolved messenger (that's immediate).        Messenger messenger = getMessengerImmediate(addr, hint);        if (messenger == null) {            return null;        }        // Now ask the messenger to resolve: this legacy blocking API ensures         // that only successfully resolved messengers are ever returned.        messenger.resolve();        try {            messenger.waitState(Messenger.RESOLVED | Messenger.TERMINAL, TimeUtils.AMINUTE);        } catch (InterruptedException ie) {            Thread.interrupted();        }        // check the state        int state = messenger.getState();        if ((state & Messenger.TERMINAL) != 0) {            return null;        }        if ((state & Messenger.RESOLVED) == 0) {            // Not failed yet. But too late for us.            return null;        }        return messenger;    }    /**     * {@inheritDoc}     */    public void propagate(Message msg, String serviceName, String serviceParam) {        theRealThing.propagate(msg, serviceName, serviceParam, Integer.MAX_VALUE);    }    /**     * {@inheritDoc}     */    public void propagate(Message msg, String serviceName, String serviceParam, int initialTTL) {        theRealThing.propagate(msg, serviceName, serviceParam, initialTTL);    }    /**     * {@inheritDoc}     */    public void demux(Message msg) {        theRealThing.demux(msg);    }    /**     * {@inheritDoc}     */    public void processIncomingMessage(Message message, EndpointAddress source, EndpointAddress destination) {        theRealThing.processIncomingMessage(message, source, destination);    }    /**     * {@inheritDoc}     */    @Deprecated    public boolean ping(EndpointAddress addr) {        return null != getMessengerImmediate(addr, null);    }    /**     * {@inheritDoc}     */    public MessengerEventListener addMessageTransport(MessageTransport transpt) {        // FIXME TOO: We should probably make the interface refuse to do it.        // But that will have to wait until we have criteria to decide who        // gets an interface object and who gets the real thing. In the        // meantime just do it.        return theRealThing.addMessageTransport(transpt);    }    /**     * {@inheritDoc}     */    public boolean removeMessageTransport(MessageTransport transpt) {        // FIXME TOO: We should probably make the interface refuse to do it.        // But that will have to wait until we have criteria to decide who        // gets an interface object and who gets the real thing. In the        // meantime just do it.        return theRealThing.removeMessageTransport(transpt);    }    /**     * {@inheritDoc}     */    public Iterator<MessageTransport> getAllMessageTransports() {        return theRealThing.getAllMessageTransports();    }    /**     * {@inheritDoc}     */    public MessageTransport getMessageTransport(String name) {        return theRealThing.getMessageTransport(name);    }    /**     * {@inheritDoc}     */    public boolean addIncomingMessageListener(EndpointListener listener, String serviceName, String serviceParam) {        return theRealThing.addIncomingMessageListener(listener, serviceName, serviceParam);    }    /**     * {@inheritDoc}     */    public EndpointListener getIncomingMessageListener(String serviceName, String serviceParam) {        return theRealThing.getIncomingMessageListener(serviceName, serviceParam);    }    /**     * {@inheritDoc}     */    public void addIncomingMessageFilterListener(MessageFilterListener listener, String namespace, String name) {        theRealThing.addIncomingMessageFilterListener(listener, namespace, name);    }    /**     * {@inheritDoc}     */    public void addOutgoingMessageFilterListener(MessageFilterListener listener, String namespace, String name) {        theRealThing.addOutgoingMessageFilterListener(listener, namespace, name);    }    /**     * {@inheritDoc}     */    public MessageFilterListener removeIncomingMessageFilterListener(MessageFilterListener listener, String namespace, String name) {        return theRealThing.removeIncomingMessageFilterListener(listener, namespace, name);    }    /**     * {@inheritDoc}     */    public MessageFilterListener removeOutgoingMessageFilterListener(MessageFilterListener listener, String namespace, String name) {        return theRealThing.removeOutgoingMessageFilterListener(listener, namespace, name);    }    /**     * {@inheritDoc}     */    public EndpointListener removeIncomingMessageListener(String serviceName, String serviceParam) {        return theRealThing.removeIncomingMessageListener(serviceName, serviceParam);    }    /**     * {@inheritDoc}     */    public boolean addMessengerEventListener(MessengerEventListener listener, int prio) {        return theRealThing.addMessengerEventListener(listener, prio);    }    /**     * {@inheritDoc}     */    public boolean removeMessengerEventListener(MessengerEventListener listener, int prio) {        return theRealThing.removeMessengerEventListener(listener, prio);    }    /**     * {@inheritDoc}     *     * @deprecated legacy support     */    @Deprecated    public boolean getMessenger(MessengerEventListener listener, EndpointAddress addr, Object hint) {        Messenger messenger = getMessengerImmediate(addr, hint);        if (messenger == null) {            return false;        }        if (!listenerAdaptor.watchMessenger(listener, messenger)) {            return false;        }        // Make sure that resolution is being attempted if not already in progress.        messenger.resolve();        return true;    }    /**     * Returns a Direct Messenger that may be used to send messages via  this endpoint to the specified destination.     *     * @param addr the destination address.     * @param hint the messenger hint, if any, otherwise null.     * @param exclusive if true avoids caching the messenger     * @return The messenger or {@code null} is returned if the destination address is not reachable.     */    public Messenger getDirectMessenger(EndpointAddress addr, Object hint, boolean exclusive) {        return theRealThing.getDirectMessenger(addr, hint, exclusive);    }}

⌨️ 快捷键说明

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