geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: rev 46287 - geronimo/trunk/modules/client/src/java/org/apache/geronimo/client
Date Fri, 17 Sep 2004 23:32:18 GMT
Author: dain
Date: Fri Sep 17 16:32:17 2004
New Revision: 46287

Added:
   geronimo/trunk/modules/client/src/java/org/apache/geronimo/client/AppClientJNDIProvider.java
Modified:
   geronimo/trunk/modules/client/src/java/org/apache/geronimo/client/AppClientContainer.java
Log:
Stubbed out JNDI provider


Modified: geronimo/trunk/modules/client/src/java/org/apache/geronimo/client/AppClientContainer.java
==============================================================================
--- geronimo/trunk/modules/client/src/java/org/apache/geronimo/client/AppClientContainer.java
(original)
+++ geronimo/trunk/modules/client/src/java/org/apache/geronimo/client/AppClientContainer.java
Fri Sep 17 16:32:17 2004
@@ -19,8 +19,8 @@
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 
-import org.apache.geronimo.naming.java.ReadOnlyContext;
-import org.apache.geronimo.naming.java.RootContext;
+import javax.management.ObjectName;
+
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoFactory;
 
@@ -31,12 +31,14 @@
     private static final Class[] MAIN_ARGS = {String[].class};
 
     private final String mainClassName;
-    private final ReadOnlyContext compContext;
+    private final AppClientJNDIProvider jndiProvider;
+    private final ObjectName appClientModuleName;
     private final Method mainMethod;
 
-    public AppClientContainer(String mainClassName, ReadOnlyContext compContext, ClassLoader
classLoader) throws Exception {
+    public AppClientContainer(String mainClassName,  ObjectName appClientModuleName, AppClientJNDIProvider
jndiProvider,ClassLoader classLoader) throws Exception {
         this.mainClassName = mainClassName;
-        this.compContext = compContext;
+        this.jndiProvider = jndiProvider;
+        this.appClientModuleName = appClientModuleName;
 
         try {
             Class mainClass = classLoader.loadClass(mainClassName);
@@ -48,32 +50,37 @@
         }
     }
 
-    public String getMainClassName() {
-        return mainClassName;
+    public ObjectName getAppClientModuleName() {
+        return appClientModuleName;
     }
 
-    public ReadOnlyContext getComponentContext() {
-        return compContext;
+    public String getMainClassName() {
+        return mainClassName;
     }
 
     public void main(String[] args) throws Exception {
-        ReadOnlyContext oldContext = RootContext.getComponentContext();
+        Throwable throwable = null;
         try {
-            RootContext.setComponentContext(compContext);
+            jndiProvider.startClient(null);
+
+            mainMethod.invoke(null, args);
 
-            try {
-                mainMethod.invoke(null, args);
-            } catch (InvocationTargetException e) {
-                Throwable cause = e.getCause();
-                if (cause instanceof Exception) {
-                    throw (Exception) cause;
-                } else if (cause instanceof Error) {
-                    throw (Error) cause;
-                }
-                throw e;
+        } catch (InvocationTargetException e) {
+            Throwable cause = e.getCause();
+            if (cause instanceof Exception) {
+                throwable = cause;
+            } else if (cause instanceof Error) {
+                throwable =  cause;
             }
+            throwable = e;
         } finally {
-            RootContext.setComponentContext(oldContext);
+            jndiProvider.stopClient(null);
+
+            if (throwable instanceof Exception) {
+                throw (Exception) throwable;
+            } else {
+                throw (Error) throwable;
+            }
         }
     }
 
@@ -84,10 +91,11 @@
 
         infoFactory.addOperation("main", new Class[]{String[].class});
         infoFactory.addAttribute("mainClassName", String.class, true);
-        infoFactory.addAttribute("componentContext", ReadOnlyContext.class, true);
+        infoFactory.addAttribute("appClientModuleObjectName", ObjectName.class, true);
+        infoFactory.addReference("JNDIProvider", AppClientJNDIProvider.class);
         infoFactory.addAttribute("classLoader", ClassLoader.class, false);
 
-        infoFactory.setConstructor(new String[]{"mainClassname", "componentContext", "classLoader"});
+        infoFactory.setConstructor(new String[]{"mainClassName", "appClientModuleName", "JNDIProvider",
"classLoader"});
 
         GBEAN_INFO = infoFactory.getBeanInfo();
     }

Added: geronimo/trunk/modules/client/src/java/org/apache/geronimo/client/AppClientJNDIProvider.java
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/client/src/java/org/apache/geronimo/client/AppClientJNDIProvider.java
Fri Sep 17 16:32:17 2004
@@ -0,0 +1,63 @@
+/**
+ *
+ * Copyright 2004 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.client;
+
+import javax.management.ObjectName;
+
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoFactory;
+
+/**
+ * @version $Revision$ $Date$
+ */
+public class AppClientJNDIProvider {
+    private final String protocol;
+    private final String host;
+    private final int port;
+
+    public AppClientJNDIProvider(String protocol, String host, int port) {
+        this.protocol = protocol;
+        this.host = host;
+        this.port = port;
+    }
+
+    public void startClient(ObjectName appClientModuleName) throws Exception {
+    }
+    
+    public void stopClient(ObjectName appClientModuleName) throws Exception {
+    }
+
+    public static final GBeanInfo GBEAN_INFO;
+
+    static {
+        GBeanInfoFactory infoFactory = new GBeanInfoFactory(AppClientJNDIProvider.class);
+
+        infoFactory.addOperation("startClient", new Class[]{ObjectName.class});
+        infoFactory.addOperation("stopClient", new Class[]{ObjectName.class});
+        infoFactory.addAttribute("protocol", String.class, true);
+        infoFactory.addAttribute("host", String.class, true);
+        infoFactory.addAttribute("port", int.class, true);
+
+        infoFactory.setConstructor(new String[]{"protocol", "host", "port"});
+
+        GBEAN_INFO = infoFactory.getBeanInfo();
+    }
+
+    public static GBeanInfo getGBeanInfo() {
+        return GBEAN_INFO;
+    }
+}

Mime
View raw message