geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject cvs commit: incubator-geronimo/modules/network/src/java/org/apache/geronimo/network/protocol DatagramProtocol.java
Date Sun, 14 Mar 2004 00:11:01 GMT
adc         2004/03/13 16:11:01

  Modified:    modules/network/src/java/org/apache/geronimo/network/protocol
                        DatagramProtocol.java
  Log:
  Added connectURI
  
  Revision  Changes    Path
  1.3       +30 -5     incubator-geronimo/modules/network/src/java/org/apache/geronimo/network/protocol/DatagramProtocol.java
  
  Index: DatagramProtocol.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/network/src/java/org/apache/geronimo/network/protocol/DatagramProtocol.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DatagramProtocol.java	10 Mar 2004 09:59:13 -0000	1.2
  +++ DatagramProtocol.java	14 Mar 2004 00:11:01 -0000	1.3
  @@ -18,8 +18,11 @@
   package org.apache.geronimo.network.protocol;
   
   import java.io.IOException;
  +import java.net.InetSocketAddress;
   import java.net.SocketAddress;
   import java.net.SocketException;
  +import java.net.URI;
  +import java.net.URISyntaxException;
   import java.nio.ByteBuffer;
   import java.nio.channels.DatagramChannel;
   import java.nio.channels.SelectionKey;
  @@ -42,10 +45,11 @@
   
       private Protocol up;
   
  +    private URI connectURI;
       private DatagramChannel source;
       private DatagramChannel destination;
  -    private SocketAddress sourceAddress;
  -    private SocketAddress destinationInterface;
  +    private InetSocketAddress sourceAddress;
  +    private InetSocketAddress destinationInterface;
   
       private SelectorManager selectorManager;
       private SelectionKey selectionKey;
  @@ -71,11 +75,15 @@
           throw new UnsupportedOperationException("Datagram protocol is at the bottom");
       }
   
  +    public URI getConnectURI() {
  +        return connectURI;
  +    }
  +
       public SocketAddress getSourceAddress() {
           return sourceAddress;
       }
   
  -    public void setSourceAddress(SocketAddress sourceAddress) {
  +    public void setSourceAddress(InetSocketAddress sourceAddress) {
           if (state == STARTED) throw new IllegalStateException("Protocol already started");
           this.sourceAddress = sourceAddress;
       }
  @@ -84,7 +92,7 @@
           return destinationInterface;
       }
   
  -    public void setDestinationInterface(SocketAddress destinationInterface) {
  +    public void setDestinationInterface(InetSocketAddress destinationInterface) {
           if (state == STARTED) throw new IllegalStateException("Protocol already started");
           this.destinationInterface = destinationInterface;
       }
  @@ -115,6 +123,20 @@
                   source.socket().setReuseAddress(true);
                   source.configureBlocking(false);
                   selectionKey = selectorManager.register(source, SelectionKey.OP_READ, this);
  +
  +                connectURI = new URI("async",
  +                                     null,
  +                                     sourceAddress.getHostName(),
  +                                     source.socket().getLocalPort(),
  +                                     "",
  +                                     "",
  +                                     null);
  +
  +                log.info("Datagram protocol available at: "
  +                         + sourceAddress.getHostName()
  +                         + ":"
  +                         + source.socket().getLocalPort());
  +                log.info("Datagram protocol clients will send datagrams to: " + connectURI);
               }
               if (destinationInterface != null) {
                   destination = DatagramChannel.open();
  @@ -126,6 +148,9 @@
               state = STOPPED;
               throw new ProtocolException(e);
           } catch (IOException e) {
  +            state = STOPPED;
  +            throw new ProtocolException(e);
  +        } catch (URISyntaxException e) {
               state = STOPPED;
               throw new ProtocolException(e);
           }
  
  
  

Mime
View raw message