directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: r165578 - in /directory/network/trunk/src: examples/org/apache/mina/examples/echoserver/ examples/org/apache/mina/examples/httpserver/ java/org/apache/mina/common/ java/org/apache/mina/registry/ test/org/apache/mina/examples/echoserver/
Date Mon, 02 May 2005 04:31:32 GMT
Author: trustin
Date: Sun May  1 21:31:30 2005
New Revision: 165578

URL: http://svn.apache.org/viewcvs?rev=165578&view=rev
Log:
* Fixed: SessionInitializers are not invoked in SimpleServiceRegistry
* Removed ServiceRegistry.getXxxFilterChain()
** Added ServiceRegistry.getXxxAcceprot() instead

Modified:
    directory/network/trunk/src/examples/org/apache/mina/examples/echoserver/Main.java
    directory/network/trunk/src/examples/org/apache/mina/examples/httpserver/Main.java
    directory/network/trunk/src/java/org/apache/mina/common/DefaultExceptionMonitor.java
    directory/network/trunk/src/java/org/apache/mina/registry/ServiceRegistry.java
    directory/network/trunk/src/java/org/apache/mina/registry/SimpleServiceRegistry.java
    directory/network/trunk/src/test/org/apache/mina/examples/echoserver/AcceptorTest.java
    directory/network/trunk/src/test/org/apache/mina/examples/echoserver/ConnectorTest.java

Modified: directory/network/trunk/src/examples/org/apache/mina/examples/echoserver/Main.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/examples/org/apache/mina/examples/echoserver/Main.java?rev=165578&r1=165577&r2=165578&view=diff
==============================================================================
--- directory/network/trunk/src/examples/org/apache/mina/examples/echoserver/Main.java (original)
+++ directory/network/trunk/src/examples/org/apache/mina/examples/echoserver/Main.java Sun
May  1 21:31:30 2005
@@ -20,7 +20,7 @@
 
 import org.apache.mina.common.TransportType;
 import org.apache.mina.examples.echoserver.ssl.BogusSSLContextFactory;
-import org.apache.mina.io.IoFilterChain;
+import org.apache.mina.io.IoAcceptor;
 import org.apache.mina.io.filter.SSLFilter;
 import org.apache.mina.registry.Service;
 import org.apache.mina.registry.ServiceRegistry;
@@ -63,7 +63,7 @@
         System.out.println( "SSL is enabled." );
         SSLFilter sslFilter =
             new SSLFilter( BogusSSLContextFactory.getInstance( true ) );
-        IoFilterChain filters = registry.getIoFilterChain( TransportType.SOCKET );
-        filters.addLast( "sslFilter", sslFilter );
+        IoAcceptor acceptor = registry.getIoAcceptor( TransportType.SOCKET );
+        acceptor.getFilterChain().addLast( "sslFilter", sslFilter );
     }
 }

Modified: directory/network/trunk/src/examples/org/apache/mina/examples/httpserver/Main.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/examples/org/apache/mina/examples/httpserver/Main.java?rev=165578&r1=165577&r2=165578&view=diff
==============================================================================
--- directory/network/trunk/src/examples/org/apache/mina/examples/httpserver/Main.java (original)
+++ directory/network/trunk/src/examples/org/apache/mina/examples/httpserver/Main.java Sun
May  1 21:31:30 2005
@@ -20,7 +20,7 @@
 
 import org.apache.mina.common.TransportType;
 import org.apache.mina.examples.echoserver.ssl.BogusSSLContextFactory;
-import org.apache.mina.io.IoFilterChain;
+import org.apache.mina.io.IoAcceptor;
 import org.apache.mina.io.filter.SSLFilter;
 import org.apache.mina.registry.Service;
 import org.apache.mina.registry.ServiceRegistry;
@@ -63,7 +63,7 @@
         System.out.println( "SSL is enabled." );
         SSLFilter sslFilter =
             new SSLFilter( BogusSSLContextFactory.getInstance( true ) );
-        IoFilterChain filters = registry.getIoFilterChain( TransportType.SOCKET );
-        filters.addLast( "sslFilter", sslFilter );
+        IoAcceptor acceptor = registry.getIoAcceptor( TransportType.SOCKET );
+        acceptor.getFilterChain().addLast( "sslFilter", sslFilter );
     }
 }

Modified: directory/network/trunk/src/java/org/apache/mina/common/DefaultExceptionMonitor.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/common/DefaultExceptionMonitor.java?rev=165578&r1=165577&r2=165578&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/common/DefaultExceptionMonitor.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/common/DefaultExceptionMonitor.java Sun
May  1 21:31:30 2005
@@ -18,15 +18,12 @@
  */
 package org.apache.mina.common;
 
-import java.lang.reflect.Method;
-import java.text.DateFormat;
-import java.util.Date;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 
 /**
  * A default {@link ExceptionMonitor} implementation that logs uncaught
- * exceptions using <a href="http://jakarta.apache.org/commons/logging/">Apache
- * Jakarta Commons Logging</a> if available.  If not available, it prints it
- * out to {@link System#err}.
+ * exceptions using {@link Logger}.
  * <p>
  * All {@link SessionManager}s have this implementation as a default exception
  * monitor.
@@ -36,83 +33,10 @@
  */
 public class DefaultExceptionMonitor implements ExceptionMonitor
 {
-    private static final Object log;
-
-    private static final Method errorMethod;
-
-    static
-    {
-        Object tempLog = null;
-        Method tempErrorMethod = null;
-
-        try
-        {
-            Class logCls = Class.forName( "org.apache.commons.logging.Log" );
-            Class logFactoryCls = Class
-                    .forName( "org.apache.commons.logging.LogFactory" );
-            Method getLogMethod = logFactoryCls
-                    .getMethod( "getLog", new Class[] { String.class } );
-            tempLog = getLogMethod
-                    .invoke( null,
-                             new Object[] { DefaultExceptionMonitor.class
-                                     .getPackage().getName() } );
-            tempErrorMethod = logCls
-                    .getMethod( "error", new Class[] { Object.class,
-                                                      Throwable.class } );
-        }
-        catch( Exception e )
-        {
-            tempLog = null;
-            tempErrorMethod = null;
-        }
-
-        log = tempLog;
-        errorMethod = tempErrorMethod;
-    }
-
-    private final DateFormat df = DateFormat
-            .getDateTimeInstance( DateFormat.MEDIUM, DateFormat.MEDIUM );
-
-    private final Date date = new Date();
+    private static final Logger log = Logger.getLogger( DefaultExceptionMonitor.class.getName()
);
 
     public void exceptionCaught( Object source, Throwable cause )
     {
-        if( log == null )
-        {
-            logToStdErr( cause );
-        }
-        else
-        {
-            logToCommonsLogging( cause );
-        }
+        log.log( Level.WARNING, "Unexpected exception.", cause );
     }
-
-    private void logToCommonsLogging( Throwable cause )
-    {
-        try
-        {
-            errorMethod.invoke( log, new Object[] { "Uncaught exception: ",
-                                                   cause } );
-        }
-        catch( Exception e )
-        {
-            logToStdErr( cause );
-        }
-    }
-
-    private void logToStdErr( Throwable cause )
-    {
-        synchronized( System.err )
-        {
-            date.setTime( System.currentTimeMillis() );
-
-            System.err.print( '[' );
-            System.err.print( df.format( date ) );
-            System.err.print( "] [" );
-            System.err.print( Thread.currentThread().getName() );
-            System.err.print( "] Uncaught exception: " );
-            cause.printStackTrace();
-        }
-    }
-
 }

Modified: directory/network/trunk/src/java/org/apache/mina/registry/ServiceRegistry.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/registry/ServiceRegistry.java?rev=165578&r1=165577&r2=165578&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/registry/ServiceRegistry.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/registry/ServiceRegistry.java Sun May
 1 21:31:30 2005
@@ -23,9 +23,9 @@
 
 import org.apache.mina.common.SessionInitializer;
 import org.apache.mina.common.TransportType;
-import org.apache.mina.io.IoFilterChain;
+import org.apache.mina.io.IoAcceptor;
 import org.apache.mina.io.IoHandler;
-import org.apache.mina.protocol.ProtocolFilterChain;
+import org.apache.mina.protocol.ProtocolAcceptor;
 import org.apache.mina.protocol.ProtocolProvider;
 
 /**
@@ -73,9 +73,9 @@
      */
     void unbindAll();
 
-    IoFilterChain getIoFilterChain( TransportType transportType );
+    IoAcceptor getIoAcceptor( TransportType transportType );
     
-    ProtocolFilterChain getProtocolFilterChain( TransportType transportType );
+    ProtocolAcceptor getProtocolAcceptor( TransportType transportType );
 
     /**
      * Returns {@link Set} of all services bound in this registry.

Modified: directory/network/trunk/src/java/org/apache/mina/registry/SimpleServiceRegistry.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/java/org/apache/mina/registry/SimpleServiceRegistry.java?rev=165578&r1=165577&r2=165578&view=diff
==============================================================================
--- directory/network/trunk/src/java/org/apache/mina/registry/SimpleServiceRegistry.java (original)
+++ directory/network/trunk/src/java/org/apache/mina/registry/SimpleServiceRegistry.java Sun
May  1 21:31:30 2005
@@ -14,12 +14,10 @@
 import org.apache.mina.common.TransportType;
 import org.apache.mina.io.IoAcceptor;
 import org.apache.mina.io.IoHandler;
-import org.apache.mina.io.IoFilterChain;
 import org.apache.mina.io.datagram.DatagramAcceptor;
 import org.apache.mina.io.filter.IoThreadPoolFilter;
 import org.apache.mina.io.socket.SocketAcceptor;
 import org.apache.mina.protocol.ProtocolAcceptor;
-import org.apache.mina.protocol.ProtocolFilterChain;
 import org.apache.mina.protocol.ProtocolProvider;
 import org.apache.mina.protocol.filter.ProtocolThreadPoolFilter;
 import org.apache.mina.protocol.io.IoProtocolAcceptor;
@@ -131,12 +129,14 @@
         }
     }
 
-    public IoFilterChain getIoFilterChain(TransportType transportType) {
-        return findIoAcceptor( transportType ).getFilterChain();
+    public IoAcceptor getIoAcceptor( TransportType transportType )
+    {
+        return findIoAcceptor( transportType );
     }
 
-    public ProtocolFilterChain getProtocolFilterChain(TransportType transportType) {
-        return findProtocolAcceptor( transportType ).getFilterChain();
+    public ProtocolAcceptor getProtocolAcceptor( TransportType transportType )
+    {
+        return findProtocolAcceptor( transportType );
     }
 
     public synchronized Set getAllServices()

Modified: directory/network/trunk/src/test/org/apache/mina/examples/echoserver/AcceptorTest.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/test/org/apache/mina/examples/echoserver/AcceptorTest.java?rev=165578&r1=165577&r2=165578&view=diff
==============================================================================
--- directory/network/trunk/src/test/org/apache/mina/examples/echoserver/AcceptorTest.java
(original)
+++ directory/network/trunk/src/test/org/apache/mina/examples/echoserver/AcceptorTest.java
Sun May  1 21:31:30 2005
@@ -34,6 +34,7 @@
 import org.apache.mina.examples.echoserver.ssl.BogusSSLContextFactory;
 import org.apache.mina.examples.echoserver.ssl.SSLServerSocketFactory;
 import org.apache.mina.examples.echoserver.ssl.SSLSocketFactory;
+import org.apache.mina.io.IoAcceptor;
 import org.apache.mina.io.filter.SSLFilter;
 
 /**
@@ -61,7 +62,8 @@
         SSLFilter sslFilter =
             new SSLFilter( BogusSSLContextFactory.getInstance( true ) );
         //sslFilter.setDebug( SSLFilter.Debug.ON );
-        registry.getIoFilterChain( TransportType.SOCKET ).addLast( "SSL", sslFilter );
+        IoAcceptor acceptor = registry.getIoAcceptor( TransportType.SOCKET );
+        acceptor.getFilterChain().addLast( "SSL", sslFilter );
         
         // Create a commons-net socket factory
         SSLSocketFactory.setSslEnabled(true);

Modified: directory/network/trunk/src/test/org/apache/mina/examples/echoserver/ConnectorTest.java
URL: http://svn.apache.org/viewcvs/directory/network/trunk/src/test/org/apache/mina/examples/echoserver/ConnectorTest.java?rev=165578&r1=165577&r2=165578&view=diff
==============================================================================
--- directory/network/trunk/src/test/org/apache/mina/examples/echoserver/ConnectorTest.java
(original)
+++ directory/network/trunk/src/test/org/apache/mina/examples/echoserver/ConnectorTest.java
Sun May  1 21:31:30 2005
@@ -30,6 +30,7 @@
 import org.apache.mina.common.SessionInitializer;
 import org.apache.mina.common.TransportType;
 import org.apache.mina.examples.echoserver.ssl.BogusSSLContextFactory;
+import org.apache.mina.io.IoAcceptor;
 import org.apache.mina.io.IoConnector;
 import org.apache.mina.io.IoHandlerAdapter;
 import org.apache.mina.io.IoSession;
@@ -76,7 +77,8 @@
         SSLFilter acceptorSSLFilter =
             new SSLFilter( BogusSSLContextFactory.getInstance( true ) );
         //acceptorSSLFilter.setDebug( SSLFilter.Debug.ON );
-        registry.getIoFilterChain( TransportType.SOCKET ).addLast( "SSL", acceptorSSLFilter
);
+        IoAcceptor acceptor = registry.getIoAcceptor( TransportType.SOCKET );
+        acceptor.getFilterChain().addLast( "SSL", acceptorSSLFilter );
 
         // Create a connector
         IoConnector connector = new SocketConnector();



Mime
View raw message