directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r106784 - in incubator/directory/eve/trunk: jndi-provider/src/java/org/apache/eve/jndi protocol/src/java/org/apache/eve/protocol protocol/src/test/org/apache/eve/protocol
Date Sun, 28 Nov 2004 03:38:16 GMT
Author: akarasulu
Date: Sat Nov 27 19:38:15 2004
New Revision: 106784

URL: http://svn.apache.org/viewcvs?view=rev&rev=106784
Log:
Changes ...

 o changed signature of getSingleton on SessionRegistry
 o using constructor directly with singleton cleanup too
 o made changes to handler that called getSingleton
 o added EventRouter handle to constructors 
 o added method that publishes a Disconnect event for the client
 o finished Unbind handler to call this new terminateSession method


Modified:
   incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/jndi/EveContextFactory.java
   incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/AddHandler.java
   incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/BindHandler.java
   incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/CompareHandler.java
   incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/DeleteHandler.java
   incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/LdapProtocolProvider.java
   incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/ModifyDnHandler.java
   incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/ModifyHandler.java
   incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/SearchHandler.java
   incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/SessionRegistry.java
   incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/UnbindHandler.java
   incubator/directory/eve/trunk/protocol/src/test/org/apache/eve/protocol/LdapProtocolProviderTest.java

Modified: incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/jndi/EveContextFactory.java
Url: http://svn.apache.org/viewcvs/incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/jndi/EveContextFactory.java?view=diff&rev=106784&p1=incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/jndi/EveContextFactory.java&r1=106783&p2=incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/jndi/EveContextFactory.java&r2=106784
==============================================================================
--- incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/jndi/EveContextFactory.java
(original)
+++ incubator/directory/eve/trunk/jndi-provider/src/java/org/apache/eve/jndi/EveContextFactory.java
Sat Nov 27 19:38:15 2004
@@ -491,8 +491,6 @@
 
     private void startUpWireProtocol() throws NamingException
     {
-        proto = new LdapProtocolProvider( ( Hashtable) initialEnv.clone() );
-
         try
         {
             fe = ( DefaultFrontend ) new DefaultFrontendFactory().create();
@@ -505,6 +503,8 @@
             ne.setResolvedName( new LdapName( ( String ) initialEnv.get( Context.PROVIDER_URL
) ) );
             throw ne;
         }
+
+        proto = new LdapProtocolProvider( ( Hashtable) initialEnv.clone(), fe.getEventRouter()
);
 
         int port = PropertiesUtils.get( initialEnv, EVE_LDAP_PORT, LDAP_PORT );
         srvEntry = new InetServiceEntry( proto.getName(), port, proto, TransportTypeEnum.TCP
);

Modified: incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/AddHandler.java
Url: http://svn.apache.org/viewcvs/incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/AddHandler.java?view=diff&rev=106784&p1=incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/AddHandler.java&r1=106783&p2=incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/AddHandler.java&r2=106784
==============================================================================
--- incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/AddHandler.java
(original)
+++ incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/AddHandler.java
Sat Nov 27 19:38:15 2004
@@ -41,7 +41,7 @@
         AddRequest req = ( AddRequest ) request;
         AddResponse resp = new AddResponseImpl( req.getMessageId() );
         resp.setLdapResult( new LdapResultImpl( resp ) );
-        InitialContext ictx = SessionRegistry.getSingleton( null ).get( key );
+        InitialContext ictx = SessionRegistry.getSingleton().get( key );
 
         try
         {

Modified: incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/BindHandler.java
Url: http://svn.apache.org/viewcvs/incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/BindHandler.java?view=diff&rev=106784&p1=incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/BindHandler.java&r1=106783&p2=incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/BindHandler.java&r2=106784
==============================================================================
--- incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/BindHandler.java
(original)
+++ incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/BindHandler.java
Sat Nov 27 19:38:15 2004
@@ -55,7 +55,7 @@
 
         String dn = req.getName();
         byte[] creds = req.getCredentials();
-        Hashtable env = SessionRegistry.getSingleton( null ).getEnvironment();
+        Hashtable env = SessionRegistry.getSingleton().getEnvironment();
         InitialContext ictx;
 
         try
@@ -72,7 +72,7 @@
             return resp;
         }
 
-        SessionRegistry.getSingleton( null ).put( key, ictx );
+        SessionRegistry.getSingleton().put( key, ictx );
         resp.setLdapResult( new LdapResultImpl( resp ) );
         resp.getLdapResult().setResultCode( ResultCodeEnum.SUCCESS );
         resp.getLdapResult().setMatchedDn( req.getName() );

Modified: incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/CompareHandler.java
Url: http://svn.apache.org/viewcvs/incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/CompareHandler.java?view=diff&rev=106784&p1=incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/CompareHandler.java&r1=106783&p2=incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/CompareHandler.java&r2=106784
==============================================================================
--- incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/CompareHandler.java
(original)
+++ incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/CompareHandler.java
Sat Nov 27 19:38:15 2004
@@ -45,7 +45,7 @@
         CompareRequest req = ( CompareRequest ) request;
         CompareResponse resp = new CompareResponseImpl( req.getMessageId() );
         resp.setLdapResult( new LdapResultImpl( resp ) );
-        InitialContext ictx = SessionRegistry.getSingleton( null ).get( key );
+        InitialContext ictx = SessionRegistry.getSingleton().get( key );
 
         try
         {

Modified: incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/DeleteHandler.java
Url: http://svn.apache.org/viewcvs/incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/DeleteHandler.java?view=diff&rev=106784&p1=incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/DeleteHandler.java&r1=106783&p2=incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/DeleteHandler.java&r2=106784
==============================================================================
--- incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/DeleteHandler.java
(original)
+++ incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/DeleteHandler.java
Sat Nov 27 19:38:15 2004
@@ -45,7 +45,7 @@
         DeleteRequest req = ( DeleteRequest ) request;
         DeleteResponse resp = new DeleteResponseImpl( req.getMessageId() );
         resp.setLdapResult( new LdapResultImpl( resp ) );
-        InitialContext ictx = SessionRegistry.getSingleton( null ).get( key );
+        InitialContext ictx = SessionRegistry.getSingleton().get( key );
 
         try
         {

Modified: incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/LdapProtocolProvider.java
Url: http://svn.apache.org/viewcvs/incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/LdapProtocolProvider.java?view=diff&rev=106784&p1=incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/LdapProtocolProvider.java&r1=106783&p2=incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/LdapProtocolProvider.java&r2=106784
==============================================================================
--- incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/LdapProtocolProvider.java
(original)
+++ incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/LdapProtocolProvider.java
Sat Nov 27 19:38:15 2004
@@ -24,6 +24,7 @@
 import org.apache.seda.protocol.ProtocolProvider;
 import org.apache.seda.protocol.RequestHandler;
 import org.apache.seda.listener.ClientKey;
+import org.apache.seda.event.EventRouter;
 
 import org.apache.ldap.common.message.*;
 import org.apache.ldap.common.message.spi.Provider;
@@ -96,6 +97,8 @@
         DEFAULT_HANDLERS = Collections.unmodifiableMap( map );
     }
 
+    /** a handle on the SEDA event router */
+    public final EventRouter router;
     /** the underlying provider decoder factory */
     public final DecoderFactory decoderFactory;
     /** the underlying provider encoder factory */
@@ -115,13 +118,16 @@
      * @param env environment properties used to configure the provider and
      * underlying codec providers if any
      */
-    public LdapProtocolProvider( Hashtable env ) throws LdapNamingException
+    public LdapProtocolProvider( Hashtable env, EventRouter router )
+            throws LdapNamingException
     {
+        this.router = router;
         Hashtable copy = ( Hashtable ) env.clone();
         this.handlers = new HashMap();
 
         copy.put( Context.PROVIDER_URL, "" );
-        SessionRegistry.getSingleton( copy );
+        SessionRegistry.releaseSingleton();
+        new SessionRegistry( copy, router );
 
         Iterator requestTypes = DEFAULT_HANDLERS.keySet().iterator();
         while ( requestTypes.hasNext() )
@@ -176,10 +182,12 @@
     /**
      * Creates a SEDA LDAP protocol provider.
      */
-    public LdapProtocolProvider() throws LdapNamingException
+    public LdapProtocolProvider( EventRouter router ) throws LdapNamingException
     {
+        this.router = router;
         this.handlers = new HashMap();
-        SessionRegistry.getSingleton( null );
+        SessionRegistry.releaseSingleton();
+        new SessionRegistry( null, router );
 
         Iterator requestTypes = DEFAULT_HANDLERS.keySet().iterator();
         while ( requestTypes.hasNext() )

Modified: incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/ModifyDnHandler.java
Url: http://svn.apache.org/viewcvs/incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/ModifyDnHandler.java?view=diff&rev=106784&p1=incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/ModifyDnHandler.java&r1=106783&p2=incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/ModifyDnHandler.java&r2=106784
==============================================================================
--- incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/ModifyDnHandler.java
(original)
+++ incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/ModifyDnHandler.java
Sat Nov 27 19:38:15 2004
@@ -45,7 +45,7 @@
         ModifyDnRequest req = ( ModifyDnRequest ) request;
         ModifyDnResponse resp = new ModifyDnResponseImpl( req.getMessageId() );
         resp.setLdapResult( new LdapResultImpl( resp ) );
-        InitialContext ictx = SessionRegistry.getSingleton( null ).get( key );
+        InitialContext ictx = SessionRegistry.getSingleton().get( key );
 
         try
         {

Modified: incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/ModifyHandler.java
Url: http://svn.apache.org/viewcvs/incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/ModifyHandler.java?view=diff&rev=106784&p1=incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/ModifyHandler.java&r1=106783&p2=incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/ModifyHandler.java&r2=106784
==============================================================================
--- incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/ModifyHandler.java
(original)
+++ incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/ModifyHandler.java
Sat Nov 27 19:38:15 2004
@@ -47,7 +47,7 @@
         ModifyRequest req = ( ModifyRequest ) request;
         ModifyResponse resp = new ModifyResponseImpl( req.getMessageId() );
         resp.setLdapResult( new LdapResultImpl( resp ) );
-        InitialContext ictx = SessionRegistry.getSingleton( null ).get( key );
+        InitialContext ictx = SessionRegistry.getSingleton().get( key );
 
         try
         {

Modified: incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/SearchHandler.java
Url: http://svn.apache.org/viewcvs/incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/SearchHandler.java?view=diff&rev=106784&p1=incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/SearchHandler.java&r1=106783&p2=incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/SearchHandler.java&r2=106784
==============================================================================
--- incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/SearchHandler.java
(original)
+++ incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/SearchHandler.java
Sat Nov 27 19:38:15 2004
@@ -58,7 +58,7 @@
     {
         LdapContext ctx;
         SearchRequest req = ( SearchRequest ) request;
-        InitialContext ictx = SessionRegistry.getSingleton( null ).get( key );
+        InitialContext ictx = SessionRegistry.getSingleton().get( key );
         NamingEnumeration list = null;
 
         // check the attributes to see if a referral's ref attribute is included

Modified: incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/SessionRegistry.java
Url: http://svn.apache.org/viewcvs/incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/SessionRegistry.java?view=diff&rev=106784&p1=incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/SessionRegistry.java&r1=106783&p2=incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/SessionRegistry.java&r2=106784
==============================================================================
--- incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/SessionRegistry.java
(original)
+++ incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/SessionRegistry.java
Sat Nov 27 19:38:15 2004
@@ -22,6 +22,8 @@
 import javax.naming.Context;
 
 import org.apache.seda.listener.ClientKey;
+import org.apache.seda.event.EventRouter;
+import org.apache.seda.event.DisconnectEvent;
 
 
 /**
@@ -33,6 +35,8 @@
 public class SessionRegistry
 {
     private static SessionRegistry s_singleton;
+    /** a handle on the event router */
+    private final EventRouter router;
     /** the set of client contexts */
     private final Map contexts = new HashMap();
     /** the observer to listen for key expiration */
@@ -45,27 +49,39 @@
      * Gets the singleton instance for this SessionRegistry.  If the singleton
      * does not exist one is created.
      *
-     * @param env the properties associated with the SessionRegistry if created
      * @return the singleton SessionRegistry instance
      */
-    public static SessionRegistry getSingleton( Hashtable env )
+    public static SessionRegistry getSingleton()
     {
-        if ( s_singleton == null )
-        {
-            s_singleton = new SessionRegistry( env );
-        }
-
         return s_singleton;
     }
 
 
+    static void releaseSingleton()
+    {
+        s_singleton = null;
+    }
+
+
     /**
      * Creates a singleton session state object for the system.
      *
      * @param env the properties associated with this SessionRegistry
      */
-    private SessionRegistry( Hashtable env )
+    SessionRegistry( Hashtable env, EventRouter router )
     {
+        this.router = router;
+
+        if ( s_singleton == null )
+        {
+            s_singleton = this;
+        }
+        else
+        {
+            throw new IllegalStateException( "there can only be one singlton" );
+        }
+
+
         if ( env == null )
         {
             this.env = new Hashtable();
@@ -162,5 +178,17 @@
                 contexts.remove( key );
             }
         }
+    }
+
+
+    /**
+     * Terminates the session by publishing a disconnect event.
+     *
+     * @param key the client key of the client to disconnect
+     */
+    public void terminateSession( ClientKey key )
+    {
+        DisconnectEvent event = new DisconnectEvent( this, key );
+        router.publish( event );
     }
 }

Modified: incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/UnbindHandler.java
Url: http://svn.apache.org/viewcvs/incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/UnbindHandler.java?view=diff&rev=106784&p1=incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/UnbindHandler.java&r1=106783&p2=incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/UnbindHandler.java&r2=106784
==============================================================================
--- incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/UnbindHandler.java
(original)
+++ incubator/directory/eve/trunk/protocol/src/java/org/apache/eve/protocol/UnbindHandler.java
Sat Nov 27 19:38:15 2004
@@ -35,12 +35,14 @@
 {
     public void handle( ClientKey key, Object request )
     {
-        InitialContext ictx = SessionRegistry.getSingleton( null ).get( key );
-        SessionRegistry.getSingleton( null ).remove( key );
+        InitialContext ictx = SessionRegistry.getSingleton().get( key );
+        SessionRegistry registry = SessionRegistry.getSingleton();
 
         try
         {
             ictx.close();
+            registry.terminateSession( key );
+            registry.remove( key );
         }
         catch ( NamingException e )
         {

Modified: incubator/directory/eve/trunk/protocol/src/test/org/apache/eve/protocol/LdapProtocolProviderTest.java
Url: http://svn.apache.org/viewcvs/incubator/directory/eve/trunk/protocol/src/test/org/apache/eve/protocol/LdapProtocolProviderTest.java?view=diff&rev=106784&p1=incubator/directory/eve/trunk/protocol/src/test/org/apache/eve/protocol/LdapProtocolProviderTest.java&r1=106783&p2=incubator/directory/eve/trunk/protocol/src/test/org/apache/eve/protocol/LdapProtocolProviderTest.java&r2=106784
==============================================================================
--- incubator/directory/eve/trunk/protocol/src/test/org/apache/eve/protocol/LdapProtocolProviderTest.java
(original)
+++ incubator/directory/eve/trunk/protocol/src/test/org/apache/eve/protocol/LdapProtocolProviderTest.java
Sat Nov 27 19:38:15 2004
@@ -37,6 +37,8 @@
  */
 public class LdapProtocolProviderTest extends TestCase
 {
+
+
     /**
      * Tests to make sure all the default handlers are kicking in properly with
      * the right request type.
@@ -46,7 +48,7 @@
      */
     public void testDefaultOperation() throws LdapNamingException
     {
-        LdapProtocolProvider provider = new LdapProtocolProvider();
+        LdapProtocolProvider provider = new LdapProtocolProvider( null );
         assertNotNull( provider.getDecoderFactory() );
         assertNotNull( provider.getEncoderFactory() );
         assertTrue( provider.getName() == LdapProtocolProvider.SERVICE_NAME );
@@ -126,7 +128,7 @@
         props.setProperty( UnbindRequest.class.getName(), BogusUnbindHandler.class.getName()
);
         props.setProperty( UnbindRequestImpl.class.getName(), BogusUnbindHandler.class.getName()
);
 
-        LdapProtocolProvider provider = new LdapProtocolProvider( props );
+        LdapProtocolProvider provider = new LdapProtocolProvider( props, null );
         assertNotNull( provider.getDecoderFactory() );
         assertNotNull( provider.getEncoderFactory() );
         assertTrue( provider.getName() == LdapProtocolProvider.SERVICE_NAME );

Mime
View raw message