geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ammul...@apache.org
Subject svn commit: r371460 - in /geronimo/branches/1.0/modules: connector-builder/src/java/org/apache/geronimo/connector/deployment/jsr88/ connector/src/java/org/apache/geronimo/connector/ connector/src/java/org/apache/geronimo/connector/outbound/ deployment/...
Date Mon, 23 Jan 2006 04:48:49 GMT
Author: ammulder
Date: Sun Jan 22 20:48:37 2006
New Revision: 371460

URL: http://svn.apache.org/viewcvs?rev=371460&view=rev
Log:
Various minor fixes
Add an AdminObject management interface

Added:
    geronimo/branches/1.0/modules/management/src/java/org/apache/geronimo/management/geronimo/JCAAdminObject.java
  (with props)
Modified:
    geronimo/branches/1.0/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/jsr88/SinglePool.java
    geronimo/branches/1.0/modules/connector/src/java/org/apache/geronimo/connector/AdminObjectWrapper.java
    geronimo/branches/1.0/modules/connector/src/java/org/apache/geronimo/connector/AdminObjectWrapperGBean.java
    geronimo/branches/1.0/modules/connector/src/java/org/apache/geronimo/connector/outbound/ManagedConnectionFactoryWrapper.java
    geronimo/branches/1.0/modules/deployment/src/java/org/apache/geronimo/deployment/Deployer.java
    geronimo/branches/1.0/modules/management/src/java/org/apache/geronimo/management/geronimo/JCAManagedConnectionFactory.java
    geronimo/branches/1.0/modules/system/src/java/org/apache/geronimo/system/repository/FileSystemRepository.java
    geronimo/branches/1.0/modules/system/src/java/org/apache/geronimo/system/serverinfo/BasicServerInfo.java
    geronimo/branches/1.0/modules/system/src/java/org/apache/geronimo/system/serverinfo/ServerInfo.java

Modified: geronimo/branches/1.0/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/jsr88/SinglePool.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.0/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/jsr88/SinglePool.java?rev=371460&r1=371459&r2=371460&view=diff
==============================================================================
--- geronimo/branches/1.0/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/jsr88/SinglePool.java
(original)
+++ geronimo/branches/1.0/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/jsr88/SinglePool.java
Sun Jan 22 20:48:37 2006
@@ -54,7 +54,9 @@
     public void setMinSize(Integer value) {
         Integer old = getMinSize();
         if(value == null) {
-            getSinglePool().unsetMinSize();
+            if(getSinglePool().isSetMinSize()) {
+                getSinglePool().unsetMinSize();
+            }
         } else {
             getSinglePool().setMinSize(value.intValue());
         }
@@ -68,7 +70,9 @@
     public void setMaxSize(Integer value) {
         Integer old = getMaxSize();
         if(value == null) {
-            getSinglePool().unsetMaxSize();
+            if(getSinglePool().isSetMaxSize()) {
+                getSinglePool().unsetMaxSize();
+            }
         } else {
             getSinglePool().setMaxSize(value.intValue());
         }
@@ -82,7 +86,9 @@
     public void setBlockingTimeoutMillis(Integer value) {
         Integer old = getBlockingTimeoutMillis();
         if(value == null) {
-            getSinglePool().unsetBlockingTimeoutMilliseconds();
+            if(getSinglePool().isSetBlockingTimeoutMilliseconds()) {
+                getSinglePool().unsetBlockingTimeoutMilliseconds();
+            }
         } else {
             getSinglePool().setBlockingTimeoutMilliseconds(value.intValue());
         }
@@ -96,7 +102,9 @@
     public void setIdleTimeoutMinutes(Integer value) {
         Integer old = getIdleTimeoutMinutes();
         if(value == null) {
-            getSinglePool().unsetIdleTimeoutMinutes();
+            if(getSinglePool().isSetIdleTimeoutMinutes()) {
+                getSinglePool().unsetIdleTimeoutMinutes();
+            }
         } else {
             getSinglePool().setIdleTimeoutMinutes(value.intValue());
         }

Modified: geronimo/branches/1.0/modules/connector/src/java/org/apache/geronimo/connector/AdminObjectWrapper.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.0/modules/connector/src/java/org/apache/geronimo/connector/AdminObjectWrapper.java?rev=371460&r1=371459&r2=371460&view=diff
==============================================================================
--- geronimo/branches/1.0/modules/connector/src/java/org/apache/geronimo/connector/AdminObjectWrapper.java
(original)
+++ geronimo/branches/1.0/modules/connector/src/java/org/apache/geronimo/connector/AdminObjectWrapper.java
Sun Jan 22 20:48:37 2006
@@ -19,6 +19,13 @@
 
 import org.apache.geronimo.gbean.DynamicGBean;
 import org.apache.geronimo.gbean.DynamicGBeanDelegate;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.management.geronimo.JCAAdminObject;
+
+import javax.management.ObjectName;
+import java.util.Map;
+import java.util.HashMap;
+import java.lang.reflect.Constructor;
 
 /**
  * Wrapper around AdminObject that exposes its config-properties as GBeanAttributes and
@@ -26,7 +33,7 @@
  *
  * @version $Rev$ $Date$
  */
-public class AdminObjectWrapper implements DynamicGBean {
+public class AdminObjectWrapper implements DynamicGBean, JCAAdminObject {
 
     private final String adminObjectInterface;
     private final String adminObjectClass;
@@ -34,6 +41,10 @@
     private final DynamicGBeanDelegate delegate;
     private final Object adminObject;
 
+
+    private final Kernel kernel;
+    private final String objectName;
+
     /**
      * Default constructor required when a class is used as a GBean Endpoint.
      */
@@ -42,6 +53,8 @@
         adminObjectClass = null;
         adminObject = null;
         delegate = null;
+        kernel = null;
+        objectName = null;
     }
 
     /**
@@ -54,9 +67,13 @@
      */
     public AdminObjectWrapper(final String adminObjectInterface,
                               final String adminObjectClass,
+                              final Kernel kernel,
+                              final String objectName,
                               final ClassLoader cl) throws IllegalAccessException, InstantiationException,
ClassNotFoundException {
         this.adminObjectInterface = adminObjectInterface;
         this.adminObjectClass = adminObjectClass;
+        this.kernel = kernel;
+        this.objectName = objectName;
         Class clazz = cl.loadClass(adminObjectClass);
         adminObject = clazz.newInstance();
         delegate = new DynamicGBeanDelegate();
@@ -119,5 +136,53 @@
         return null;
     }
 
+    /**
+     * Gets the config properties in the form of a map where the key is the
+     * property name and the value is property type (as a String not a Class).
+     */
+    public Map getConfigProperties() {
+        String[] props = delegate.getProperties();
+        Map map = new HashMap();
+        for (int i = 0; i < props.length; i++) {
+            String prop = props[i];
+            if(prop.equals("logWriter")) {
+                continue;
+            }
+            map.put(prop, delegate.getPropertyType(prop));
+        }
+        return map;
+    }
+
+    public void setConfigProperty(String property, Object value) throws Exception {
+        Class cls = delegate.getPropertyType(property);
+        if(value != null && value instanceof String && !cls.getName().equals("java.lang.String"))
{
+            if(cls.isPrimitive()) {
+                if(cls.equals(int.class)) {
+                    cls = Integer.class;
+                } else if(cls.equals(boolean.class)) {
+                    cls = Boolean.class;
+                } else if(cls.equals(float.class)) {
+                    cls = Float.class;
+                } else if(cls.equals(double.class)) {
+                    cls = Double.class;
+                } else if(cls.equals(long.class)) {
+                    cls = Long.class;
+                } else if(cls.equals(short.class)) {
+                    cls = Short.class;
+                } else if(cls.equals(byte.class)) {
+                    cls = Byte.class;
+                } else if(cls.equals(char.class)) {
+                    cls = Character.class;
+                }
+            }
+            Constructor con = cls.getConstructor(new Class[]{String.class});
+            value = con.newInstance(new Object[]{value});
+        }
+        kernel.setAttribute(ObjectName.getInstance(objectName), property, value);
+    }
+
+    public Object getConfigProperty(String property) throws Exception {
+        return delegate.getAttribute(property);
+    }
 
 }

Modified: geronimo/branches/1.0/modules/connector/src/java/org/apache/geronimo/connector/AdminObjectWrapperGBean.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.0/modules/connector/src/java/org/apache/geronimo/connector/AdminObjectWrapperGBean.java?rev=371460&r1=371459&r2=371460&view=diff
==============================================================================
--- geronimo/branches/1.0/modules/connector/src/java/org/apache/geronimo/connector/AdminObjectWrapperGBean.java
(original)
+++ geronimo/branches/1.0/modules/connector/src/java/org/apache/geronimo/connector/AdminObjectWrapperGBean.java
Sun Jan 22 20:48:37 2006
@@ -20,26 +20,33 @@
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.management.geronimo.JCAAdminObject;
 
 /**
  * 
  * @version $Revision$
  */
 public class AdminObjectWrapperGBean {
-    
+
     public static final GBeanInfo GBEAN_INFO;
 
     static {
         GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic(AdminObjectWrapperGBean.class,
AdminObjectWrapper.class, NameFactory.JCA_ADMIN_OBJECT);
         infoBuilder.addAttribute("adminObjectInterface", String.class, true);
         infoBuilder.addAttribute("adminObjectClass", String.class, true);
+        infoBuilder.addAttribute("kernel", Kernel.class, false);
+        infoBuilder.addAttribute("objectName", String.class, false);
         infoBuilder.addAttribute("classLoader", ClassLoader.class, false);
 
         infoBuilder.addOperation("$getResource");
+        infoBuilder.addInterface(JCAAdminObject.class);
 
         infoBuilder.setConstructor(new String[]{
             "adminObjectInterface",
             "adminObjectClass",
+            "kernel",
+            "objectName",
             "classLoader"
         });
 

Modified: geronimo/branches/1.0/modules/connector/src/java/org/apache/geronimo/connector/outbound/ManagedConnectionFactoryWrapper.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.0/modules/connector/src/java/org/apache/geronimo/connector/outbound/ManagedConnectionFactoryWrapper.java?rev=371460&r1=371459&r2=371460&view=diff
==============================================================================
--- geronimo/branches/1.0/modules/connector/src/java/org/apache/geronimo/connector/outbound/ManagedConnectionFactoryWrapper.java
(original)
+++ geronimo/branches/1.0/modules/connector/src/java/org/apache/geronimo/connector/outbound/ManagedConnectionFactoryWrapper.java
Sun Jan 22 20:48:37 2006
@@ -317,7 +317,6 @@
                     cls = Character.class;
                 }
             }
-            //todo: what about value is null but type is primitive?
             Constructor con = cls.getConstructor(new Class[]{String.class});
             value = con.newInstance(new Object[]{value});
         }

Modified: geronimo/branches/1.0/modules/deployment/src/java/org/apache/geronimo/deployment/Deployer.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.0/modules/deployment/src/java/org/apache/geronimo/deployment/Deployer.java?rev=371460&r1=371459&r2=371460&view=diff
==============================================================================
--- geronimo/branches/1.0/modules/deployment/src/java/org/apache/geronimo/deployment/Deployer.java
(original)
+++ geronimo/branches/1.0/modules/deployment/src/java/org/apache/geronimo/deployment/Deployer.java
Sun Jan 22 20:48:37 2006
@@ -123,17 +123,27 @@
      * @return The URL that clients should use for deployment file uploads.
      */
     public String getRemoteDeployUploadURL() {
+        // Get the token GBean from the remote deployment configuration
         Set set = kernel.listGBeans(new GBeanQuery(null, "org.apache.geronimo.deployment.remote.RemoteDeployToken"));
         if(set.size() == 0) {
             return null;
         }
         ObjectName token = (ObjectName) set.iterator().next();
+        // Identify the parent configuration for that GBean
         set = kernel.getDependencyManager().getParents(token);
-        if(set.size() == 0) {
-            log.error("Unable to find configuration for remote deployer GBean");
+        ObjectName config = null;
+        for (Iterator it = set.iterator(); it.hasNext();) {
+            ObjectName name = (ObjectName) it.next();
+            if(Configuration.isConfigurationObjectName(name)) {
+                config = name;
+                break;
+            }
+        }
+        if(config == null) {
+            log.warn("Unable to find remote deployment configuration; is the remote deploy
web application running?");
             return null;
         }
-        ObjectName config = (ObjectName) set.iterator().next();
+        // Generate the URL based on the remote deployment configuration
         Hashtable hash = new Hashtable();
         hash.put("J2EEApplication", token.getKeyProperty("J2EEApplication"));
         hash.put("J2EEServer", token.getKeyProperty("J2EEServer"));

Added: geronimo/branches/1.0/modules/management/src/java/org/apache/geronimo/management/geronimo/JCAAdminObject.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.0/modules/management/src/java/org/apache/geronimo/management/geronimo/JCAAdminObject.java?rev=371460&view=auto
==============================================================================
--- geronimo/branches/1.0/modules/management/src/java/org/apache/geronimo/management/geronimo/JCAAdminObject.java
(added)
+++ geronimo/branches/1.0/modules/management/src/java/org/apache/geronimo/management/geronimo/JCAAdminObject.java
Sun Jan 22 20:48:37 2006
@@ -0,0 +1,40 @@
+/**
+ *
+ * Copyright 2003-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.management.geronimo;
+
+import java.util.Map;
+
+/**
+ * Management interface for admin objects
+ * todo: make it implement J2EEManagedObject
+ *
+ * @version $Rev: 368994 $ $Date: 2006-01-14 02:07:18 -0500 (Sat, 14 Jan 2006) $
+ */
+public interface JCAAdminObject {
+    public String getAdminObjectClass();
+    public String getAdminObjectInterface();
+
+    /**
+     * Gets the config properties in the form of a map where the key is the
+     * property name and the value is property type (as a String not a Class).
+     */
+    public Map getConfigProperties();
+
+    public void setConfigProperty(String property, Object value) throws Exception;
+
+    public Object getConfigProperty(String property) throws Exception;
+}

Propchange: geronimo/branches/1.0/modules/management/src/java/org/apache/geronimo/management/geronimo/JCAAdminObject.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: geronimo/branches/1.0/modules/management/src/java/org/apache/geronimo/management/geronimo/JCAManagedConnectionFactory.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.0/modules/management/src/java/org/apache/geronimo/management/geronimo/JCAManagedConnectionFactory.java?rev=371460&r1=371459&r2=371460&view=diff
==============================================================================
--- geronimo/branches/1.0/modules/management/src/java/org/apache/geronimo/management/geronimo/JCAManagedConnectionFactory.java
(original)
+++ geronimo/branches/1.0/modules/management/src/java/org/apache/geronimo/management/geronimo/JCAManagedConnectionFactory.java
Sun Jan 22 20:48:37 2006
@@ -49,7 +49,6 @@
      * connection factory.  That object should implement
      * javax.resource.spi.ConnectionManager and
      * org.apache.geronimo.connector.outbound.PoolingAttributes
-     * @return
      */
     public String getConnectionManager();
     

Modified: geronimo/branches/1.0/modules/system/src/java/org/apache/geronimo/system/repository/FileSystemRepository.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.0/modules/system/src/java/org/apache/geronimo/system/repository/FileSystemRepository.java?rev=371460&r1=371459&r2=371460&view=diff
==============================================================================
--- geronimo/branches/1.0/modules/system/src/java/org/apache/geronimo/system/repository/FileSystemRepository.java
(original)
+++ geronimo/branches/1.0/modules/system/src/java/org/apache/geronimo/system/repository/FileSystemRepository.java
Sun Jan 22 20:48:37 2006
@@ -74,6 +74,9 @@
 
     public boolean hasURI(URI uri) {
         uri = resolve(uri);
+        if(uri == null) {
+            return false;
+        }
         if ("file".equals(uri.getScheme())) {
             File f = new File(uri);
             return f.exists() && f.canRead();
@@ -92,6 +95,10 @@
 
     private URI resolve(final URI uri) {
         String[] bits = uri.toString().split("/");
+        if(bits.length < 3) {
+            log.warn("Unable to resolve URI '"+uri+"' as a repository entry");
+            return null;
+        }
         StringBuffer buf = new StringBuffer(bits[0]).append('/');
         String type = bits.length >= 4 ? bits[3] : "jar";
         buf.append(type).append('s').append('/').append(bits[1]).append('-').append(bits[2]).append('.').append(type);

Modified: geronimo/branches/1.0/modules/system/src/java/org/apache/geronimo/system/serverinfo/BasicServerInfo.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.0/modules/system/src/java/org/apache/geronimo/system/serverinfo/BasicServerInfo.java?rev=371460&r1=371459&r2=371460&view=diff
==============================================================================
--- geronimo/branches/1.0/modules/system/src/java/org/apache/geronimo/system/serverinfo/BasicServerInfo.java
(original)
+++ geronimo/branches/1.0/modules/system/src/java/org/apache/geronimo/system/serverinfo/BasicServerInfo.java
Sun Jan 22 20:48:37 2006
@@ -108,6 +108,10 @@
         return baseDirectory;
     }
 
+    public String getCurrentBaseDirectory() {
+        return base.getAbsolutePath();
+    }
+
     public String getVersion() {
         return ServerConstants.getVersion();
     }

Modified: geronimo/branches/1.0/modules/system/src/java/org/apache/geronimo/system/serverinfo/ServerInfo.java
URL: http://svn.apache.org/viewcvs/geronimo/branches/1.0/modules/system/src/java/org/apache/geronimo/system/serverinfo/ServerInfo.java?rev=371460&r1=371459&r2=371460&view=diff
==============================================================================
--- geronimo/branches/1.0/modules/system/src/java/org/apache/geronimo/system/serverinfo/ServerInfo.java
(original)
+++ geronimo/branches/1.0/modules/system/src/java/org/apache/geronimo/system/serverinfo/ServerInfo.java
Sun Jan 22 20:48:37 2006
@@ -41,7 +41,17 @@
 
     public URI resolve(final URI uri);
 
+    /**
+     * A config.xml setting for the base directory.  This is normally
+     * left null, which means the ServerInfo will use the Geronimo
+     * install directory.
+     */
     public String getBaseDirectory();
+
+    /**
+     * The base directory that this ServerInfo is actually using.
+     */
+    public String getCurrentBaseDirectory();
 
     public String getVersion();
 



Mime
View raw message