geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r158862 [9/9] - in geronimo/trunk/modules/interop: ./ src/idl/ src/java/org/apache/geronimo/interop/ src/java/org/apache/geronimo/interop/CosNaming/iiop_stubs/ src/java/org/apache/geronimo/interop/adapter/ src/java/org/apache/geronimo/interop/client/ src/java/org/apache/geronimo/interop/generator/ src/java/org/apache/geronimo/interop/naming/ src/java/org/apache/geronimo/interop/properties/ src/java/org/apache/geronimo/interop/repository/ src/java/org/apache/geronimo/interop/rmi/iiop/ src/java/org/apache/geronimo/interop/rmi/iiop/client/ src/java/org/apache/geronimo/interop/rmi/iiop/compiler/ src/java/org/apache/geronimo/interop/rmi/iiop/server/ src/java/org/apache/geronimo/interop/server/ src/java/org/apache/geronimo/interop/util/
Date Thu, 24 Mar 2005 02:30:55 GMT
Modified: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/server/MessageHandler.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/server/MessageHandler.java?view=diff&r1=158861&r2=158862
==============================================================================
--- geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/server/MessageHandler.java
(original)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/server/MessageHandler.java
Wed Mar 23 18:30:30 2005
@@ -19,98 +19,116 @@
 
 import java.net.InetAddress;
 import java.net.Socket;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.InputStream;
 
 import org.apache.geronimo.interop.GIOP.*;
 import org.apache.geronimo.interop.IOP.*;
 import org.apache.geronimo.interop.SystemException;
-import org.apache.geronimo.interop.adapter.HomeAdapter;
-import org.apache.geronimo.interop.adapter.AdapterManager;
 import org.apache.geronimo.interop.adapter.Adapter;
+import org.apache.geronimo.interop.adapter.AdapterManager;
 import org.apache.geronimo.interop.naming.NameService;
-import org.apache.geronimo.interop.rmi.iiop.*;
+import org.apache.geronimo.interop.properties.BooleanProperty;
+import org.apache.geronimo.interop.properties.SystemProperties;
+import org.apache.geronimo.interop.rmi.iiop.BadMagicException;
+import org.apache.geronimo.interop.rmi.iiop.CdrInputStream;
+import org.apache.geronimo.interop.rmi.iiop.CdrOutputStream;
+import org.apache.geronimo.interop.rmi.iiop.GiopMessage;
+import org.apache.geronimo.interop.rmi.iiop.ListenerInfo;
+import org.apache.geronimo.interop.rmi.iiop.UnsupportedProtocolVersionException;
+import org.apache.geronimo.interop.util.ExceptionUtil;
+import org.apache.geronimo.interop.util.ThreadContext;
 import org.apache.geronimo.interop.util.UTF8;
-import org.openejb.server.ServiceException;
 
-public class MessageHandler {
 
-    private AdapterManager      adapterManager;
-    private boolean             simpleIDL;
-    private boolean             writeSystemExceptionStackTrace;
-    private NameService         nameService = NameService.getInstance();
-
-    public MessageHandler( AdapterManager adapterManager, boolean simpleIDL,
-                           boolean writeSystemExceptionStackTrace )
-    {
-        this.adapterManager = adapterManager;
-        this.simpleIDL = simpleIDL;
-        this.writeSystemExceptionStackTrace = writeSystemExceptionStackTrace;
+public class MessageHandler extends Thread {
+    public static MessageHandler getInstance(ListenerInfo listenerInfo, Socket socket) {
+        MessageHandler object = new MessageHandler();
+        object.init(listenerInfo, socket);
+        return object;
     }
 
-    public void service(Socket socket) throws ServiceException, IOException {
-
-        InputStream in;
-        OutputStream out;
-
-        String clientHostName;
-        String clientHostAddress;
-        String clientInfo;
+    // -----------------------------------------------------------------------
+    // properties
+    // -----------------------------------------------------------------------
+
+
+    public static final BooleanProperty simpleIDLProperty =
+            new BooleanProperty(SystemProperties.class, "org.apache.geronimo.interop.simpleIDL");
+
+    public static BooleanProperty writeSystemExceptionStackTraceProperty =
+            new BooleanProperty(SystemProperties.class, "org.apache.geronimo.interop.rmi.iiop.writeSystemExceptionStackTrace")
+            .defaultValue(true);
+
+    // -----------------------------------------------------------------------
+    // private data
+    // -----------------------------------------------------------------------
+
+    private static final boolean SIMPLE_IDL = simpleIDLProperty.getBoolean();
+
+    private static boolean _writeSystemExceptionStackTrace = writeSystemExceptionStackTraceProperty.getBoolean();
+
+    private static RequestHandler[] _handlers = new RequestHandler[128];
+
+    private NameService _nameService;
+    private ListenerInfo _listenerInfo;
+    private java.net.Socket _socket;
+    private java.io.InputStream _socketIn;
+    private java.io.OutputStream _socketOut;
+    private String _clientHostName;
+    private String _clientHostAddress;
+    private String _clientInfo;
+    private org.apache.geronimo.interop.rmi.iiop.ObjectInputStream _objectInput;
+    private org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream _objectOutput;
+    private org.apache.geronimo.interop.rmi.iiop.ObjectInputStream _simpleInput;
+    private org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream _simpleOutput;
+
+    // -----------------------------------------------------------------------
+    // public methods
+    // -----------------------------------------------------------------------
 
-        in = socket.getInputStream();
-        out = socket.getOutputStream();
-
-        InetAddress addr = socket.getInetAddress();
-        clientHostName = addr.getHostName();
-        clientHostAddress = addr.getHostAddress();
-        clientInfo = clientHostName;
-
-        if (!clientHostAddress.equals(clientHostName)) {
-            clientInfo += " (" + clientHostAddress + ")";
-        }
+    public static void registerHandler(char keyType, RequestHandler handler) {
+        _handlers[keyType] = handler;
+    }
 
+    public void run() {
+        ThreadContext.setDefaultRmiHost(_listenerInfo.host);
+        ThreadContext.setDefaultRmiPort(_listenerInfo.port);
         boolean firstMessage = true;
         CdrInputStream input = CdrInputStream.getInstance();
         CdrOutputStream output = CdrOutputStream.getInstance();
         CdrOutputStream results = CdrOutputStream.getInstance();
-
         for (; ;) {
             boolean sendResponse = true;
             GiopMessage inputMessage;
-
             try {
-                inputMessage = input.receive_message( in, clientInfo );
+                inputMessage = input.receive_message(_socketIn, _clientInfo);
                 firstMessage = false;
             } catch (BadMagicException ex) {
                 if (firstMessage) {
-                    warnBadMagic(clientInfo, ex);
+                    warnBadMagic(_clientInfo, ex);
                 } else {
-                    warnBadMagicBadSize(clientInfo, ex);
+                    warnBadMagicBadSize(_clientInfo, ex);
                 }
-                closeStreams( in, out );
+                closeSocket();
                 return;
             } catch (UnsupportedProtocolVersionException ex) {
-                warnGiopVersion( clientInfo, ex);
-                closeStreams( in, out );
+                warnGiopVersion(_clientInfo, ex);
+                closeSocket();
                 return;
             } catch (Exception ex) {
                 if (input.getOffset() > 0) {
                     ex.printStackTrace();
-                    warnReceiveFailed( clientInfo, ex);
+                    warnReceiveFailed(_clientInfo, ex);
                 }
                 // Otherwise client shutdown was not in the middle of a
                 // request, i.e. probably 'normal' and unworthy of a
                 // log message.
-                closeStreams( in, out );
+                closeSocket();
                 return;
             }
-
             output.setGiopVersion(input.getGiopVersion());
-
             switch (inputMessage.type) {
                 case MsgType_1_1._Request:
-                    processRequest(input, output, results, inputMessage.request, clientInfo);
+                    processRequest(input, output, results, inputMessage.request);
                     if ((inputMessage.request.response_flags & 1) == 0) {
                         sendResponse = false; // oneway request
                     }
@@ -121,37 +139,63 @@
                 default:
                     throw new SystemException("TODO: message type = " + inputMessage.type);
             }
-
             if (sendResponse) {
                 try {
-                    output.send_message( out, clientInfo );
+                    output.send_message(_socketOut, _clientInfo);
                 } catch (Exception ex) {
-                    warnSendFailed(clientInfo, ex);
-                    closeStreams( in, out );
+                    warnSendFailed(_clientInfo, ex);
+                    closeSocket();
                     return;
                 }
             }
-
             input.reset();
             output.reset();
             results.reset();
         }
     }
 
-    protected void closeStreams( InputStream in, OutputStream out ) {
+    // -----------------------------------------------------------------------
+    // protected methods
+    // -----------------------------------------------------------------------
+
+    protected void init(ListenerInfo listenerInfo, Socket socket) {
+        setDaemon(true);
+        _nameService = NameService.getInstance();
+        _listenerInfo = listenerInfo;
+        _socket = socket;
         try {
-            if (in != null) {
-                in.close();
+            _socketIn = _socket.getInputStream();
+            _socketOut = _socket.getOutputStream();
+            InetAddress addr = _socket.getInetAddress();
+            _clientHostName = addr.getHostName();
+            _clientHostAddress = addr.getHostAddress();
+            _clientInfo = _clientHostName;
+            if (!_clientHostAddress.equals(_clientHostName)) {
+                _clientInfo += " (" + _clientHostAddress + ")";
+            }
+        } catch (Throwable ex) {
+            closeSocket();
+            throw ExceptionUtil.rethrow(ex);
+        }
+    }
+
+    protected void closeSocket() {
+        try {
+            if (_socketIn != null) {
+                _socketIn.close();
             }
         } catch (Exception ignore) {
         }
-
         try {
-            if (out != null) {
-                out.close();
+            if (_socketOut != null) {
+                _socketOut.close();
             }
         } catch (Exception ignore) {
         }
+        try {
+            _socket.close();
+        } catch (Exception ignore) {
+        }
     }
 
     protected byte[] getObjectKey(TargetAddress target) {
@@ -166,23 +210,25 @@
         }
     }
 
-    protected void processRequest(CdrInputStream parameters,
-                                  CdrOutputStream output,
-                                  CdrOutputStream results,
-                                  RequestHeader_1_2 request,
-                                  String clientInfo
-                                  ) {
+    protected void processRequest(CdrInputStream parameters, CdrOutputStream output, CdrOutputStream
results, RequestHeader_1_2 request) {
         byte[] objectKey = getObjectKey(request.target);
         int keyLength = objectKey.length;
         int keyType = keyLength == 0 ? 0 : objectKey[0];
+        if (keyType >= 'A' && keyType <= 'Z') {
+            RequestHandler handler = _handlers[keyType];
+            if (handler != null) {
+                handler.processRequest(objectKey, request.operation, parameters, output);
+                return;
+            }
+        }
 
         ReplyHeader_1_2 reply = new ReplyHeader_1_2();
         reply.request_id = request.request_id;
 
-        ObjectInputStream objectIn;
-        ObjectOutputStream objectOut;
+        org.apache.geronimo.interop.rmi.iiop.ObjectInputStream objectIn;
+        org.apache.geronimo.interop.rmi.iiop.ObjectOutputStream objectOut;
 
-        if (simpleIDL || keyType == 'N' || keyType == 'J') {
+        if (SIMPLE_IDL || keyType == 'N' || keyType == 'J') {
             // Name Service and JMS use simple IDL interoperability.
             objectIn = org.apache.geronimo.interop.rmi.iiop.SimpleObjectInputStream.getInstance(parameters);
             objectOut = org.apache.geronimo.interop.rmi.iiop.SimpleObjectOutputStream.getInstance(results);
@@ -209,38 +255,82 @@
                 objectName = UTF8.toString(objectKey);
             }
 
+            /*
+            if (objectName.startsWith("EJB~"))
+            {
+                // Compact encoding of component class names,
+                // saves 11 bytes per request.
+                objectName = "ejb.components." + objectName.substring(4);
+            }
+            */
+
             processServiceContext(request);
 
+            /*
             Object object;
             try
             {
-                object = nameService.lookup(objectName);
+                object = null; //_nameService.lookup(objectName);
             }
             catch (javax.naming.NameNotFoundException notFound)
             {
-                warnLookupFailed(clientInfo, notFound);
+                warnLookupFailed(_clientInfo, notFound);
                 throw new org.omg.CORBA.OBJECT_NOT_EXIST(objectName);
             }
 
-            Adapter adapter = (Adapter)object;
-            if (adapter != null)
+            if (object instanceof RemoteInterface)
             {
-                adapter.invoke(request.operation, objectKey, objectIn, objectOut);
+                RemoteInterface skeleton = ((RemoteInterface)object).$getSkeleton();
+                skeleton.$invoke(request.operation, objectKey, objectIn, objectOut);
+                if (objectOut.hasException())
+                {
+                    reply.reply_status = ReplyStatusType_1_2.USER_EXCEPTION;
+                }
+                else
+                {
+                    reply.reply_status = ReplyStatusType_1_2.NO_EXCEPTION;
+                }
+                output.write_reply(reply, results);
+            }
+            else
+            {
+                warnInvokeFailedNoRemoteInterface(_clientInfo, object, object.getClass());
+                throw new org.omg.CORBA.OBJECT_NOT_EXIST(objectName);
+            }
+            */
+
+            Object object;
+            try {
+                object = _nameService.lookup(objectName);
+            } catch (javax.naming.NameNotFoundException notFound) {
+                object = AdapterManager.getInstance().getAdapter(objectName);
+
+                if (object == null) {
+                    warnLookupFailed(_clientInfo, notFound);
+                    throw new org.omg.CORBA.OBJECT_NOT_EXIST(objectName);
+                }
+            }
+
+//            Adapter a = AdapterManager.getInstance().getAdapter(objectName);
+//            if (a != null)
+            if (object != null && object instanceof Adapter) {
+                Adapter a = (Adapter) object;
+                //RemoteInterface skeleton = a.getRemoteInterface();
+                a.invoke(request.operation, objectKey, objectIn, objectOut);
 
                 if (objectOut.hasException()) {
                     reply.reply_status = ReplyStatusType_1_2.USER_EXCEPTION;
                 } else {
                     reply.reply_status = ReplyStatusType_1_2.NO_EXCEPTION;
                 }
-
                 output.write_reply(reply, results);
             } else {
                 throw new org.omg.CORBA.OBJECT_NOT_EXIST(objectName);
             }
         } catch (Exception ex) {
-            warnSystemException(clientInfo, ex);
+            warnSystemException(_clientInfo, ex);
             results = CdrOutputStream.getInstance(); // in case we already wrote to it
-            results.write_SystemException(ex, writeSystemExceptionStackTrace);
+            results.write_SystemException(ex, _writeSystemExceptionStackTrace);
             reply.reply_status = ReplyStatusType_1_2.SYSTEM_EXCEPTION;
             output.write_reply(reply, results);
         }
@@ -275,9 +365,26 @@
                 password = SecurityInfo.decode(context.context_data);
             }
             */
+            // Otherwise OK to ignore unknown tags.
+        }
 
-            // TODO: Is the ServiceContext a CSIv2 Security Context?
+        // Default security info.
+        /*
+        if (username == null)
+        {
+            username = User.GUEST;
+        }
+        if (password == null)
+        {
+            password = "";
         }
+
+        // Check if the password is correct.
+        User user = User.getInstance(username);
+        user.login(password); // may throw SecurityException
+        User.setCurrent(user);
+        SimpleSubject.setCurrent(new SimpleSubject(username, password));
+        */
     }
 
     // log methods

Modified: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/server/ServerNamingContext.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/server/ServerNamingContext.java?view=diff&r1=158861&r2=158862
==============================================================================
--- geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/server/ServerNamingContext.java
(original)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/server/ServerNamingContext.java
Wed Mar 23 18:30:30 2005
@@ -20,7 +20,10 @@
 import javax.naming.NameNotFoundException;
 import javax.naming.NamingException;
 
-import org.apache.geronimo.interop.CosNaming.*;
+import org.apache.geronimo.interop.CosNaming.BindingIteratorHolder;
+import org.apache.geronimo.interop.CosNaming.BindingListHolder;
+import org.apache.geronimo.interop.CosNaming.NameComponent;
+import org.apache.geronimo.interop.CosNaming.NamingContext;
 import org.apache.geronimo.interop.CosNaming.NamingContextExtPackage.InvalidAddress;
 import org.apache.geronimo.interop.CosNaming.NamingContextPackage.AlreadyBound;
 import org.apache.geronimo.interop.CosNaming.NamingContextPackage.CannotProceed;
@@ -30,22 +33,41 @@
 import org.apache.geronimo.interop.adapter.Adapter;
 import org.apache.geronimo.interop.naming.NameService;
 import org.apache.geronimo.interop.naming.NameServiceLog;
-import org.apache.geronimo.interop.rmi.iiop.CorbaObject;
+import org.apache.geronimo.interop.rmi.iiop.RemoteInterface;
 
-public class ServerNamingContext extends CorbaObject implements NamingContextExt {
 
-    private NameService                     nameService;
-    protected static ServerNamingContext    snc = null;
+public class ServerNamingContext implements org.apache.geronimo.interop.rmi.iiop.NameServiceOperations
{
+    
+    protected static ServerNamingContext _snc = null;
 
-    public ServerNamingContext()
-    {
-        nameService = NameService.getInstance();
+    public static ServerNamingContext getInstance() {
+        if (_snc == null) {
+            synchronized (ServerNamingContext.class) {
+                _snc = new ServerNamingContext();
+                _snc.init();
+            }
+        }
+
+        return _snc;
     }
 
+    // -----------------------------------------------------------------------
+    // private data
+    // -----------------------------------------------------------------------
+
+    private NameService _nameService;
+
+    private volatile int _cycle;
+
+    // -----------------------------------------------------------------------
+    // public methods from interface NamingContextExtOperations
+    // -----------------------------------------------------------------------
+
     public org.omg.CORBA.Object resolve_str(String name) throws NotFound, CannotProceed,
InvalidName {
         return lookup(name, null);
     }
 
+
     public String to_string(NameComponent[] n) throws InvalidName {
         throw NoImplement();
     }
@@ -58,6 +80,10 @@
         throw NoImplement();
     }
 
+    // -----------------------------------------------------------------------
+    // public methods from interface NamingContextOperations
+    // -----------------------------------------------------------------------
+
     public org.omg.CORBA.Object resolve(NameComponent[] name) throws NotFound, CannotProceed,
InvalidName {
         return lookup(toString(name), name);
     }
@@ -98,15 +124,51 @@
         return new org.omg.CORBA.NO_IMPLEMENT();
     }
 
+    // -----------------------------------------------------------------------
+    // public methods from interface NameServiceOperations (Sybase proprietary)
+    // -----------------------------------------------------------------------
+
+    public String resolve_host(String host) {
+        System.out.println("ServerNamingContext.resolve_host(): TODO host = " + host);
+
+        //String resolvedHost = ClusterPartition.getInstance(host).resolveHost();
+        //return "cycle=" + Math.max(1, ++_cycle) + ";" + resolvedHost;
+        
+        // Cycle prefix for round-robin load balancing.
+        // Any weighted balancing is applied by client.
+
+        return host;
+    }
+
+    // -----------------------------------------------------------------------
+    // protected methods
+    // -----------------------------------------------------------------------
+
+    protected void init() {
+        _nameService = NameService.getInstance();
+    }
+
     protected org.omg.CORBA.Object lookup(String nameString, NameComponent[] name) throws
NotFound {
         try {
-            Object object = nameService.lookup(nameString);
+            Object object = _nameService.lookup(nameString);
+
+            /*
+            if (object instanceof RemoteInterface)
+            {
+                RemoteInterface remote = (RemoteInterface)object;
+                return remote.$getObjectRef();
+            }
+            else
+            {
+                NameServiceLog.getInstance().warnObjectHasNoRemoteInterface(nameString, object.getClass().getName());
+                throw new NotFound(NotFoundReason.not_object, name);
+            }
+            */
 
             if (object instanceof Adapter) {
                 Adapter a = (Adapter) object;
-                //RemoteInterface remote = a.getRemoteInterface();
-                //return remote.$getObjectRef();
-                return a.getObjectRef();
+                RemoteInterface remote = a.getRemoteInterface();
+                return remote.$getObjectRef();
             } else {
                 NameServiceLog.getInstance().warnObjectHasNoRemoteInterface(nameString, object.getClass().getName());
                 throw new NotFound(NotFoundReason.not_object, name);

Modified: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/server/SocketListener.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/server/SocketListener.java?view=diff&r1=158861&r2=158862
==============================================================================
--- geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/server/SocketListener.java
(original)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/rmi/iiop/server/SocketListener.java
Wed Mar 23 18:30:30 2005
@@ -0,0 +1,128 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.interop.rmi.iiop.server;
+
+import java.net.InetAddress;
+import java.net.Socket;
+
+import org.apache.geronimo.interop.SystemException;
+import org.apache.geronimo.interop.properties.SystemProperties;
+import org.apache.geronimo.interop.rmi.iiop.ListenerInfo;
+import org.apache.geronimo.interop.rmi.iiop.Protocol;
+
+
+public class SocketListener extends Thread {
+    public static SocketListener getInstance() {
+        return new SocketListener();
+    }
+
+    // private data
+
+    private String _name;
+
+    private String _host;
+
+    private int _port;
+
+    private int _listenBacklog;
+
+    private java.net.ServerSocket _listener;
+
+    // internal methods
+
+    protected void init() {
+        _host = "localhost";
+        _port = 2000;
+        _listenBacklog = 10;
+        setDaemon(true);
+    }
+
+    // public methods
+
+    public void setHost(String host) {
+        _host = host;
+    }
+
+    public void setPort(int port) {
+        _port = port;
+    }
+
+    public void setListenBacklog(int backlog) {
+        _listenBacklog = backlog;
+    }
+
+    public void run() {
+        String iiopURL = "iiop://" + _host + ":" + _port;
+        ListenerInfo listenerInfo = new ListenerInfo();
+        listenerInfo.protocol = Protocol.IIOP; // TODO: other protocols (IIOPS etc.)
+        listenerInfo.host = _host;
+        listenerInfo.port = _port;
+        try {
+            InetAddress addr = InetAddress.getByName(_host);
+            _listener = new java.net.ServerSocket(_port, _listenBacklog, addr);
+        } catch (Exception ex) {
+            System.out.println("SocketListener: Error creating server socket.");
+            ex.printStackTrace();
+            try {
+                Socket socket = new Socket(_host, _port);
+                socket.close();
+                System.out.println("SocketListener: Error server already running: " + iiopURL);
+                ex.printStackTrace();
+            } catch (Exception ignore) {
+            }
+            return;
+        }
+        new CheckConnect().start();
+        for (; ;) {
+            java.net.Socket socket;
+            try {
+                socket = _listener.accept();
+            } catch (Exception ex) {
+                throw new SystemException(ex); // TODO: log error message
+            }
+            MessageHandler.getInstance(listenerInfo, socket).start();
+        }
+    }
+
+    private class CheckConnect extends Thread {
+        public void run() {
+            try {
+                Socket socket = new Socket(_host, _port);
+                socket.close();
+                if (!SystemProperties.quiet()) {
+                    System.out.println(formatAcceptingIiopConnections());
+                }
+            } catch (Exception ex) {
+                warnConnectFailed(_host, _port);
+            }
+        }
+    }
+
+    // format methods
+
+    protected String formatAcceptingIiopConnections() {
+        String msg = "SocketListener.formatAcceptingIiopConnection(): ";
+        return msg;
+    }
+
+    // log methods
+
+    protected void warnConnectFailed(String host, int port) {
+        System.out.println("SocketListener.warnConnectFailed(): host = " + host + ", port
= " + port);
+    }
+}

Modified: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/server/IIOPDaemon.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/server/IIOPDaemon.java?view=diff&r1=158861&r2=158862
==============================================================================
--- geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/server/IIOPDaemon.java
(original)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/server/IIOPDaemon.java
Wed Mar 23 18:30:30 2005
@@ -0,0 +1,166 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.interop.server;
+
+import java.net.InetSocketAddress;
+import java.net.ServerSocket;
+import java.net.Socket;
+
+import org.apache.geronimo.interop.adapter.Adapter;
+import org.apache.geronimo.interop.adapter.AdapterManager;
+import org.apache.geronimo.interop.naming.NameService;
+import org.apache.geronimo.interop.rmi.iiop.ListenerInfo;
+import org.apache.geronimo.interop.rmi.iiop.server.MessageHandler;
+
+
+public class IIOPDaemon implements Runnable {
+    protected String _host = "localhost";
+    protected int _port = 9000;
+    protected String _name = "IIOP";
+    protected ServerSocket _ss = null;
+    protected boolean _ready = false;
+
+    public void setHost(String host) {
+        _host = host;
+    }
+
+    public String getHost() {
+        return _host;
+    }
+
+    public void setPort(int port) {
+        _port = port;
+    }
+
+    public int getPort() {
+        return _port;
+    }
+
+    public void setName(String name) {
+        _name = name;
+    }
+
+    public String getName() {
+        return _name;
+    }
+
+    public void setReady() {
+        _ready = true;
+    }
+
+    public boolean isReady() {
+        return _ready;
+    }
+
+    public ServerSocket getServerSocket() {
+        if (_ss == null) {
+            synchronized (this) {
+                try {
+                    InetSocketAddress isa = new InetSocketAddress(_host, _port);
+                    _ss = new ServerSocket();
+                    _ss.bind(isa);
+                    setReady();
+                } catch (Exception ex) {
+                    ex.printStackTrace();
+                }
+            }
+        }
+
+        return _ss;
+    }
+
+    public void run() {
+        ListenerInfo li = new ListenerInfo();
+        li.protocol = 1;
+        li.host = getHost();
+        li.port = getPort();
+
+        ServerSocket ss = getServerSocket();
+        Socket s = null;
+        System.out.println("[" + getName() + "-" + getHost() + ":" + getPort() + "] Accepting
Connections...");
+        while (isReady()) {
+            try {
+                s = ss.accept();
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+
+            MessageHandler mh;
+            mh = MessageHandler.getInstance(li, s);
+            mh.start();
+        }
+    }
+
+    public static void main(String args[]) {
+        IIOPDaemon id = new IIOPDaemon();
+        id.setHost("localhost");
+        id.setPort(9000);
+
+        Thread t = new Thread(id);
+        t.setName(id.getName() + " Daemon");
+        t.start();
+
+        NameService ns = NameService.getInstance();
+        AdapterManager am = AdapterManager.getInstance();
+
+        //
+        // NameService
+        //
+        Adapter a = new Adapter();
+        a.setBindName("NameService");
+        a.setRemoteClassName("org.apache.geronimo.interop.rmi.iiop.server.ServerNamingContext");
+        a.setRemoteInterfaceName("org.apache.geronimo.interop.rmi.iiop.NameServiceOperations");
+        a.setShared(true);
+        a.addId("IDL:org.apache.geronimo.interop/rmi/iiop/NameService:1.0");
+        a.addId("IDL:omg.org/CosNaming/NamingContext:1.0");
+        a.addId("IDL:omg.org/CosNaming/NamingContextExt:1.0");
+        a.addId("NameService"); // this gets passed in by the J2SE 1.4 ORB
+        a.setClassLoader(id.getClass().getClassLoader());
+        //a.generateSkels();
+        //a.compileSkels();
+
+        am.registerAdapter(a);
+        ns.bindAdapter(a);
+
+        //
+        // Component
+        //
+        a = new Adapter();
+        a.setBindName("mark.comps.Add");
+        a.setRemoteClassName("mark.comps.AddImpl");
+        a.setRemoteInterfaceName("mark.comps.Add");
+        a.addId("RMI:mark.comps.Add:0000000000000000");
+        a.setClassLoader(id.getClass().getClassLoader());
+
+        am.registerAdapter(a);
+        ns.bindAdapter(a);
+
+        //
+        // Component
+        //
+        a = new Adapter();
+        a.setBindName("mark.comps.Add2");
+        a.setRemoteClassName("mark.comps.Add2Impl");
+        a.setRemoteInterfaceName("mark.comps.Add2");
+        a.addId("RMI:mark.comps.Add2:0000000000000000");
+        a.setClassLoader(id.getClass().getClassLoader());
+
+        am.registerAdapter(a);
+        ns.bindAdapter(a);
+    }
+}

Modified: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/server/IIOPSDaemon.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/server/IIOPSDaemon.java?view=diff&r1=158861&r2=158862
==============================================================================
--- geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/server/IIOPSDaemon.java
(original)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/server/IIOPSDaemon.java
Wed Mar 23 18:30:30 2005
@@ -0,0 +1,33 @@
+/**
+ *
+ *  Copyright 2004-2005 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.interop.server;
+
+
+
+
+public class IIOPSDaemon extends IIOPDaemon {
+    public static void main(String args[]) {
+        IIOPSDaemon id = new IIOPSDaemon();
+        id.setName("IIOPS");
+        id.setHost("localhost");
+        id.setPort(9000);
+
+        Thread t = new Thread(id);
+        t.start();
+    }
+}

Modified: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/JavaClass.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/JavaClass.java?view=diff&r1=158861&r2=158862
==============================================================================
--- geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/JavaClass.java
(original)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/JavaClass.java
Wed Mar 23 18:30:30 2005
@@ -26,6 +26,9 @@
 
 
 public abstract class JavaClass {
+    // -----------------------------------------------------------------------
+    // properties
+    // -----------------------------------------------------------------------
 
     public static final StringProperty classDirProperty =
             new StringProperty(SystemProperties.class, "org.apache.geronimo.interop.classDir")
@@ -45,10 +48,21 @@
                           + File.pathSeparator
                           + FileUtil.pretty(SystemProperties.getHome() + "/genfiles/java/src"));
 
+    // -----------------------------------------------------------------------
+    // private data
+    // -----------------------------------------------------------------------
+
     private static String _classDir = classDirProperty.getString();
+
     private static List _classPath = ListUtil.getPathList(classPathProperty.getString());
+
     private static String _sourceDir = sourceDirProperty.getString();
+
     private static List _sourcePath = ListUtil.getPathList(sourcePathProperty.getString());
+
+    // -----------------------------------------------------------------------
+    // public methods
+    // -----------------------------------------------------------------------
 
     public static String addPackageSuffix(String className, String suffix) {
         String jp = getPackagePrefix(className);

Modified: geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/SystemUtil.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/SystemUtil.java?view=diff&r1=158861&r2=158862
==============================================================================
--- geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/SystemUtil.java
(original)
+++ geronimo/trunk/modules/interop/src/java/org/apache/geronimo/interop/util/SystemUtil.java
Wed Mar 23 18:30:30 2005
@@ -54,11 +54,6 @@
         return _isJDK14;
     }
 
-    public static String getVmVersion()
-    {
-        return _vmVersion;
-    }
-
     public static boolean isWindows() {
         return java.io.File.separatorChar == '\\';
     }



Mime
View raw message