avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-avalon-cornerstone/apps/demo/src/java/org/apache/avalon/cornerstone/demos/simpleserver SimpleServer.java SimpleServer.xinfo
Date Tue, 20 Nov 2001 12:23:51 GMT
donaldp     01/11/20 04:23:51

  Modified:    apps/demo/src/conf avalon-demo-assembly.xml
               apps/demo/src/java/org/apache/avalon/cornerstone/demos/simpleserver
                        SimpleServer.java SimpleServer.xinfo
  Log:
  Make SimpleServer depend on PacketManager so can be used to test that class.
  
  Revision  Changes    Path
  1.6       +3 -0      jakarta-avalon-cornerstone/apps/demo/src/conf/avalon-demo-assembly.xml
  
  Index: avalon-demo-assembly.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/demo/src/conf/avalon-demo-assembly.xml,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- avalon-demo-assembly.xml	2001/11/19 12:28:39	1.5
  +++ avalon-demo-assembly.xml	2001/11/20 12:23:51	1.6
  @@ -67,6 +67,9 @@
       <!-- The names here must match the names specified for a Block in some conf.xml
file.
       The role should be the interface mentioned in the BlockInfo (.xinfo) files  -->
   
  +
  +    <provide name="packet-manager" 
  +             role="org.apache.avalon.cornerstone.services.packet.PacketManager"/>
       <provide name="sockets" role="org.apache.avalon.cornerstone.services.sockets.SocketManager"/>
       <provide name="connections"
                role="org.apache.avalon.cornerstone.services.connection.ConnectionManager"
/>
  
  
  
  1.6       +42 -1     jakarta-avalon-cornerstone/apps/demo/src/java/org/apache/avalon/cornerstone/demos/simpleserver/SimpleServer.java
  
  Index: SimpleServer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/demo/src/java/org/apache/avalon/cornerstone/demos/simpleserver/SimpleServer.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- SimpleServer.java	2001/11/19 12:28:39	1.5
  +++ SimpleServer.java	2001/11/20 12:23:51	1.6
  @@ -10,6 +10,8 @@
   import java.io.*;
   import java.net.ProtocolException;
   import java.net.ServerSocket;
  +import java.net.DatagramSocket;
  +import java.net.DatagramPacket;
   import java.net.Socket;
   import java.net.SocketException;
   import java.util.Iterator;
  @@ -24,6 +26,9 @@
   import org.apache.avalon.cornerstone.services.scheduler.TimeTrigger;
   import org.apache.avalon.cornerstone.services.sockets.ServerSocketFactory;
   import org.apache.avalon.cornerstone.services.sockets.SocketManager;
  +import org.apache.avalon.cornerstone.services.packet.PacketManager;
  +import org.apache.avalon.cornerstone.services.packet.PacketHandler;
  +import org.apache.avalon.cornerstone.services.packet.PacketHandlerFactory;
   import org.apache.avalon.cornerstone.services.store.ObjectRepository;
   import org.apache.avalon.cornerstone.services.store.Store;
   import org.apache.avalon.framework.activity.Initializable;
  @@ -57,7 +62,7 @@
   public class SimpleServer
       extends AbstractLogEnabled
       implements Block, SimpleService, Contextualizable, Composable, Configurable, Initializable,
  -               ConnectionHandlerFactory, ConnectionHandler, Target
  +               ConnectionHandlerFactory, ConnectionHandler, Target, PacketHandler, PacketHandlerFactory
   {
       private TimeScheduler           m_timeScheduler;
       private Configuration           m_configuration;
  @@ -65,6 +70,7 @@
       private ConnectionManager       m_connectionManager;
       private Store                   m_testStore;
       private ObjectRepository        m_repository;
  +    private PacketManager           m_packetManager;
   
       private PrintWriter             m_out;
       private int                     m_count;
  @@ -87,6 +93,7 @@
           m_socketManager = (SocketManager)componentManager.lookup( SocketManager.ROLE );
           m_connectionManager = (ConnectionManager)componentManager.lookup( ConnectionManager.ROLE
);
           m_timeScheduler = (TimeScheduler)componentManager.lookup( TimeScheduler.ROLE );
  +        m_packetManager = (PacketManager)componentManager.lookup( PacketManager.ROLE );
       }
   
       public void configure( final Configuration configuration )
  @@ -136,7 +143,41 @@
           ExtensionTestClass2.doSomeThing();
           getLogger().info( "...successful test" );
   
  +        getLogger().info( "Creating datagram socket..." );
  +        final DatagramSocket datagramSocket = new DatagramSocket( 5053 );
  +        getLogger().info( "...successful" );
  +
  +        getLogger().info( "Connecting datagram socket..." );
  +        m_packetManager.connect( "udp/5053", datagramSocket, this );
  +        getLogger().info( "...successful" );
  +
           getLogger().info( "...Demo init" );
  +    }
  +
  +    /**
  +     * Construct an appropriate PacketHandler.
  +     *
  +     * @return the new PacketHandler
  +     * @exception Exception if an error occurs
  +     */
  +    public PacketHandler createPacketHandler()
  +        throws Exception
  +    {
  +        return this;
  +    }
  +
  +    /**
  +     * Handle a datgram packet.
  +     * This handler is responsible for processing packets as they occur.
  +     *
  +     * @param packet the packet
  +     * @exception IOException if an error reading from socket occurs
  +     * @exception ProtocolException if an error handling connection occurs
  +     */
  +    public void handlePacket( final DatagramPacket packet )
  +        throws IOException, ProtocolException
  +    {
  +        System.out.println( "Pickety pickety pop - got a packet!" );
       }
   
       /**
  
  
  
  1.4       +3 -0      jakarta-avalon-cornerstone/apps/demo/src/java/org/apache/avalon/cornerstone/demos/simpleserver/SimpleServer.xinfo
  
  Index: SimpleServer.xinfo
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-cornerstone/apps/demo/src/java/org/apache/avalon/cornerstone/demos/simpleserver/SimpleServer.xinfo,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SimpleServer.xinfo	2001/09/24 02:14:05	1.3
  +++ SimpleServer.xinfo	2001/11/20 12:23:51	1.4
  @@ -24,6 +24,9 @@
         <service name="org.apache.avalon.cornerstone.services.sockets.SocketManager" version="1.0"/>
       </dependency>
       <dependency>
  +      <service name="org.apache.avalon.cornerstone.services.packet.PacketManager" version="1.0"/>
  +    </dependency>
  +    <dependency>
         <service name="org.apache.avalon.cornerstone.services.scheduler.TimeScheduler"
version="1.0"/>
       </dependency>
     </dependencies>
  
  
  

--
To unsubscribe, e-mail:   <mailto:avalon-cvs-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-cvs-help@jakarta.apache.org>


Mime
View raw message