Author: rajdavies
Date: Wed Feb 8 03:02:36 2006
New Revision: 375922
URL: http://svn.apache.org/viewcvs?rev=375922&view=rev
Log:
support defining local address and port for a socket - e.g:
ssl://localhost:5666/localhost:60606
where the path (localhost:60606) - defines the local address and local port
For jira issue: AMQ-529
Modified:
incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/stream/sync/socket/SocketStreamChannelFactory.java
Modified:
incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/stream/sync/socket/SocketStreamChannelFactory.java
URL:
http://svn.apache.org/viewcvs/incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/stream/sync/socket/SocketStreamChannelFactory.java?rev=375922&r1=375921&r2=375922&view=diff
==============================================================================
---
incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/stream/sync/socket/SocketStreamChannelFactory.java
(original)
+++
incubator/activemq/trunk/activeio/activeio-core/src/main/java/org/apache/activeio/stream/sync/socket/SocketStreamChannelFactory.java
Wed Feb 8 03:02:36 2006
@@ -61,7 +61,26 @@
*/
public StreamChannel openStreamChannel(URI location) throws IOException {
Socket socket=null;
- socket = socketFactory.createSocket(location.getHost(),
location.getPort());
+ String path=location.getPath();
+ // see if the path is a local URI location
+ if(path!=null&&path.length()>0){
+ if (path.indexOf('/')==0){
+ //strip leading slash
+ path = path.substring(1,path.length());
+ }
+ int localPortIndex=path.indexOf(':');
+ try{
+ int localPort =
Integer.parseInt(path.substring((localPortIndex+1),path.length()));
+ InetAddress localAddress = InetAddress.getByName(path);
+ socket = socketFactory.createSocket(location.getHost(),
location.getPort(),localAddress,localPort);
+ }catch(Exception e){
+ System.err.println("Could not define local address and port
from path: " + path);
+ e.printStackTrace();
+ }
+ }
+ if (socket==null){
+ socket = socketFactory.createSocket(location.getHost(),
location.getPort());
+ }
return createStreamChannel(socket);
}