/*
* Copyright (c) 2001-2007 Sun Microsystems, Inc. All rights reserved.
*
* The Sun Project JXTA(TM) Software License
*
* 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 Sun Microsystems, Inc. for JXTA(TM) technology."
* 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.
*
* JXTA is a registered trademark of Sun Microsystems, Inc. in the United
* States and other countries.
*
* Please see the license information page at :
* <http://www.jxta.org/project/www/license.html> for instructions on use of
* the license in source files.
*
* ====================================================================
*
* 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.
*/
package net.jxta.impl.endpoint.router;
import net.jxta.document.Advertisement;
import net.jxta.document.AdvertisementFactory;
import net.jxta.document.XMLElement;
import net.jxta.endpoint.EndpointAddress;
import net.jxta.endpoint.EndpointListener;
import net.jxta.endpoint.EndpointService;
import net.jxta.endpoint.Message;
import net.jxta.endpoint.MessageReceiver;
import net.jxta.endpoint.MessageSender;
import net.jxta.endpoint.MessageTransport;
import net.jxta.endpoint.Messenger;
import net.jxta.endpoint.MessengerEvent;
import net.jxta.endpoint.MessengerEventListener;
import net.jxta.exception.PeerGroupException;
import net.jxta.id.ID;
import net.jxta.id.IDFactory;
import net.jxta.impl.endpoint.LoopbackMessenger;
import net.jxta.impl.util.TimeUtils;
import net.jxta.impl.util.TimerThreadNamer;
import net.jxta.logging.Logging;
import net.jxta.peer.PeerID;
import net.jxta.peergroup.PeerGroup;
import net.jxta.platform.Module;
import net.jxta.protocol.AccessPointAdvertisement;
import net.jxta.protocol.ModuleImplAdvertisement;
import net.jxta.protocol.PeerAdvertisement;
import net.jxta.protocol.RouteAdvertisement;
import net.jxta.service.Service;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Timer;
import java.util.TimerTask;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
public class EndpointRouter implements EndpointListener, MessageReceiver, MessageSender, MessengerEventListener, Module {
/**
* Logger
*/
private final static transient Logger LOG = Logger.getLogger(EndpointRouter.class.getName());
/**
* Until we decide otherwise, the router is *by definition* handling
* virtually addressed messages.
*/
private final static String ROUTER_PROTOCOL_NAME = "jxta";
/**
* Router Service Name
*/
private final static String ROUTER_SERVICE_NAME = "EndpointRouter";
/**
* how long we are willing to wait for a response from an async
* getMessenger. We do not wait long at all because it is non-critical
* that we get the answer synchronously. The goal is to avoid starting
* a route discovery if there's a chance to get a direct connection.
* However, we will still take advantage of the direct route if it is
* found while we wait for the route discovery result. If that happens,
* the only wrong is that we used some bandwidth doing a route discovery
* that wasn't needed after all.
*/
public final static long ASYNC_MESSENGER_WAIT = 3L * TimeUtils.ASECOND;
/**
* MessageTransport Control operation
*/
public final static Integer GET_ROUTE_CONTROL = 0; // Return RouteControl Object
public final static int RouteControlOp = 0; // Return RouteControl Object
/**
* MAX timeout (seconds) for route discovery after that timeout
* the peer will bail out from finding a route
*/
private final static long MAX_FINDROUTE_TIMEOUT = 60L * TimeUtils.ASECOND;
/**
* How long do we wait (seconds) before retrying to make a connection
* to an endpoint destination
*/
private final static long MAX_ASYNC_GETMESSENGER_RETRY = 30L * TimeUtils.ASECOND;
/**
* These are peers which we know multi-hop routes for.
*/
private final Map<ID, RouteAdvertisement> routedRoutes = new HashMap<ID, RouteAdvertisement>(16);
/**
* A record of failures.
* <p/>
* Values are the time of failure as {@link java.lang.Long}. If
* {@code Long.MAX_VALUE} then a connect attempt is current in progress.
*/
private final Map<PeerID, Long> triedAndFailed = new HashMap<PeerID, Long>();
/**
* local peer ID as an endpointAddress.
*/
private EndpointAddress localPeerAddr = null;
/**
* local Peer ID
*/
private PeerID localPeerId = null;
/**
* The Endpoint Service we are routing for.
*/
private EndpointService endpoint = null;
/**
* PeerGroup handle
*/
private PeerGroup group = null;
private ID assignedID = null;
/**
* If {@code true} this service has been closed.
*/
private boolean stopped = false;
/**
* Whenever we initiate connectivity to a peer (creating a direct route).
* we remember that we need to send our route adv to that peer. So that
* it has a chance to re-establish the connection from its side, if need
* be. The route adv is actually sent piggy-backed on the first message
* that goes there.
*/
private final Set<EndpointAddress> newDestinations = Collections.synchronizedSet(new HashSet<EndpointAddress>());
/**
* A pool of messengers categorized by logical address.
* This actually is the direct routes map.
*/
private Destinatio
没有合适的资源?快使用搜索试试~ 我知道了~
一些对JXTA 有帮助的资源
共712个文件
java:619个
html:54个
properties:10个
3星 · 超过75%的资源 需积分: 10 8 下载量 83 浏览量
2009-06-04
14:41:47
上传
评论
收藏 4.17MB ZIP 举报
温馨提示
jxta2.5-src,jxta的源码,相信对研究的人有很大帮助哦 !
资源推荐
资源详情
资源评论
收起资源包目录
一些对JXTA 有帮助的资源 (712个子文件)
net.jxta.document.Advertisement 780B
junit-LICENSE.html 15KB
jetty-LICENSE.html 7KB
package.html 4KB
package.html 3KB
package.html 2KB
package.html 2KB
package.html 1KB
package.html 1KB
overview.html 1KB
overview.html 1KB
package.html 994B
package.html 906B
package.html 847B
package.html 810B
package.html 724B
package.html 712B
package.html 707B
package.html 651B
package.html 626B
package.html 624B
package.html 609B
package.html 603B
package.html 588B
package.html 565B
package.html 552B
package.html 550B
package.html 539B
package.html 508B
package.html 506B
package.html 497B
package.html 481B
package.html 471B
package.html 467B
package.html 460B
package.html 457B
package.html 451B
package.html 449B
package.html 447B
package.html 426B
package.html 404B
package.html 400B
package.html 375B
package.html 359B
package.html 359B
package.html 357B
package.html 355B
package.html 342B
package.html 340B
package.html 313B
package.html 245B
package.html 236B
package.html 233B
package.html 222B
package.html 174B
net.jxta.id.ID 127B
bcprov-jdk14.jar 1.42MB
org.mortbay.jetty.jar 563KB
junit.jar 118KB
javax.servlet.jar 72KB
EndpointRouter.java 107KB
PeerView.java 73KB
EndpointServiceImpl.java 73KB
NetworkConfigurator.java 67KB
ConfigDialog.java 66KB
JxtaSocket.java 64KB
GenericPeerGroup.java 63KB
SwingUI.java 62KB
RelayServer.java 60KB
DiscoveryServiceImpl.java 58KB
LiteXMLElement.java 57KB
RouteResolver.java 55KB
RelayClient.java 55KB
Message.java 52KB
ResolverServiceImpl.java 52KB
IDFactory.java 50KB
TcpTransport.java 46KB
JxtaBiDiPipe.java 46KB
ReliableOutputStream.java 46KB
Paged.java 45KB
TcpMessenger.java 44KB
Cm.java 44KB
TransportBindingMetric.java 44KB
WireFormatMessageBinary.java 43KB
ProxyService.java 43KB
PipeResolver.java 43KB
BTree.java 41KB
StdPeerGroup.java 39KB
PeerGroup.java 39KB
HttpMessageServlet.java 38KB
HttpClientMessenger.java 38KB
ReliableTest.java 36KB
Messenger.java 36KB
JTlsOutputStream.java 35KB
BlockingMessenger.java 35KB
MonitorManager.java 34KB
SrdiIndex.java 34KB
RendezVousServiceProvider.java 33KB
EdgePeerRdvService.java 33KB
McastTransport.java 33KB
共 712 条
- 1
- 2
- 3
- 4
- 5
- 6
- 8
资源评论
- 期海独行客2012-12-30其实这个源代码可以到官方网站拿到。 http://download.java.net/jxta/
coralhus2
- 粉丝: 1
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功