geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ammul...@apache.org
Subject svn commit: r371461 - in /geronimo/trunk/modules: connector-builder/src/java/org/apache/geronimo/connector/deployment/jsr88/ connector-builder/src/test-resources/ connector-builder/src/test/org/apache/geronimo/connector/deployment/jsr88/ connector/src/...
Date Mon, 23 Jan 2006 04:53:47 GMT
Author: ammulder
Date: Sun Jan 22 20:53:26 2006
New Revision: 371461

URL: http://svn.apache.org/viewcvs?rev=371461&view=rev
Log:
Apply changes from branch (Fixes GERONIMO-1510, contributes to GERONIMO-1137,
  other minor fixes)

Added:
    geronimo/trunk/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/jsr88/AdminObjectDCB.java   (props changed)
      - copied unchanged from r370976, geronimo/branches/1.0/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/jsr88/AdminObjectDCB.java
    geronimo/trunk/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/jsr88/AdminObjectInstance.java   (props changed)
      - copied unchanged from r370976, geronimo/branches/1.0/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/jsr88/AdminObjectInstance.java
    geronimo/trunk/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/jsr88/ConfigHolder.java   (props changed)
      - copied unchanged from r370976, geronimo/branches/1.0/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/jsr88/ConfigHolder.java
    geronimo/trunk/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/jsr88/ResourceAdapterInstance.java   (props changed)
      - copied unchanged from r370976, geronimo/branches/1.0/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/jsr88/ResourceAdapterInstance.java
    geronimo/trunk/modules/connector-builder/src/test-resources/jms-plan.xml   (props changed)
      - copied unchanged from r370976, geronimo/branches/1.0/modules/connector-builder/src/test-resources/jms-plan.xml
    geronimo/trunk/modules/connector-builder/src/test-resources/jms.rar   (props changed)
      - copied unchanged from r370976, geronimo/branches/1.0/modules/connector-builder/src/test-resources/jms.rar
    geronimo/trunk/modules/management/src/java/org/apache/geronimo/management/geronimo/JCAAdminObject.java   (props changed)
      - copied unchanged from r371460, geronimo/branches/1.0/modules/management/src/java/org/apache/geronimo/management/geronimo/JCAAdminObject.java
    geronimo/trunk/modules/naming-builder/src/java/org/apache/geronimo/naming/deployment/jsr88/
      - copied from r370976, geronimo/branches/1.0/modules/naming-builder/src/java/org/apache/geronimo/naming/deployment/jsr88/
    geronimo/trunk/modules/naming-builder/src/java/org/apache/geronimo/naming/deployment/jsr88/GBeanLocator.java   (props changed)
      - copied unchanged from r370976, geronimo/branches/1.0/modules/naming-builder/src/java/org/apache/geronimo/naming/deployment/jsr88/GBeanLocator.java
    geronimo/trunk/modules/naming-builder/src/java/org/apache/geronimo/naming/deployment/jsr88/ObjectNameGroup.java   (props changed)
      - copied unchanged from r370976, geronimo/branches/1.0/modules/naming-builder/src/java/org/apache/geronimo/naming/deployment/jsr88/ObjectNameGroup.java
Modified:
    geronimo/trunk/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/jsr88/ConfigPropertySetting.java
    geronimo/trunk/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/jsr88/ConnectionDefinitionInstance.java
    geronimo/trunk/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/jsr88/ConnectionManager.java
    geronimo/trunk/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/jsr88/Connector15DCBRoot.java
    geronimo/trunk/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/jsr88/ConnectorDCB.java
    geronimo/trunk/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/jsr88/ResourceAdapter.java
    geronimo/trunk/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/jsr88/SinglePool.java
    geronimo/trunk/modules/connector-builder/src/test/org/apache/geronimo/connector/deployment/jsr88/Connector15DCBTest.java
    geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/AdminObjectWrapper.java
    geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/AdminObjectWrapperGBean.java
    geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/outbound/ManagedConnectionFactoryWrapper.java
    geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/Deployer.java
    geronimo/trunk/modules/management/src/java/org/apache/geronimo/management/geronimo/JCAManagedConnectionFactory.java
    geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/repository/FileSystemRepository.java
    geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/serverinfo/BasicServerInfo.java
    geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/serverinfo/ServerInfo.java

Propchange: geronimo/trunk/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/jsr88/AdminObjectDCB.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/trunk/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/jsr88/AdminObjectInstance.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/trunk/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/jsr88/ConfigHolder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: geronimo/trunk/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/jsr88/ConfigPropertySetting.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/jsr88/ConfigPropertySetting.java?rev=371461&r1=371460&r2=371461&view=diff
==============================================================================
--- geronimo/trunk/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/jsr88/ConfigPropertySetting.java (original)
+++ geronimo/trunk/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/jsr88/ConfigPropertySetting.java Sun Jan 22 20:53:26 2006
@@ -31,6 +31,7 @@
  */
 public class ConfigPropertySetting extends XmlBeanSupport {
     private DDBean configProperty;
+    private String defaultValue;
 
     public ConfigPropertySetting() {
         super(null);
@@ -54,14 +55,21 @@
         setXmlObject(property);
         final String name = configProperty.getText("config-property-name")[0];
         getPropertySetting().setName(name);
+        String[] test = configProperty.getText("config-property-value");
+        if(test != null && test.length == 1) {
+            defaultValue = test[0];
+        } else {
+            defaultValue = null;
+        }
         if(setDefault) {
-            String[] test = configProperty.getText("config-property-value");
-            if(test != null && test.length == 1) {
-                getPropertySetting().setStringValue(test[0]);
-            } else {
-                getPropertySetting().setStringValue(null);
-            }
+            getPropertySetting().setStringValue(defaultValue);
         }
+    }
+
+    boolean isSetToDefault() {
+        String value = getValue();
+        return (defaultValue == null && value == null) ||
+                (defaultValue != null && value != null && defaultValue.equals(value));
     }
 
     // ----------------------- JavaBean Properties for config-property-setting ----------------------

Modified: geronimo/trunk/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/jsr88/ConnectionDefinitionInstance.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/jsr88/ConnectionDefinitionInstance.java?rev=371461&r1=371460&r2=371461&view=diff
==============================================================================
--- geronimo/trunk/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/jsr88/ConnectionDefinitionInstance.java (original)
+++ geronimo/trunk/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/jsr88/ConnectionDefinitionInstance.java Sun Jan 22 20:53:26 2006
@@ -16,17 +16,10 @@
  */
 package org.apache.geronimo.connector.deployment.jsr88;
 
-import java.util.Iterator;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.HashMap;
 import javax.enterprise.deploy.model.DDBean;
-import javax.enterprise.deploy.model.XpathListener;
-import javax.enterprise.deploy.model.XpathEvent;
-import org.apache.geronimo.deployment.plugin.XmlBeanSupport;
 import org.apache.geronimo.xbeans.geronimo.GerConnectiondefinitionInstanceType;
 import org.apache.geronimo.xbeans.geronimo.GerConfigPropertySettingType;
+import org.apache.geronimo.naming.deployment.jsr88.GBeanLocator;
 import org.apache.xmlbeans.SchemaTypeLoader;
 
 /**
@@ -35,37 +28,14 @@
  *
  * @version $Rev$ $Date$
  */
-public class ConnectionDefinitionInstance extends XmlBeanSupport {
-    final XpathListener xpathListener = new XpathListener() {
-                    public void fireXpathEvent(XpathEvent event) {
-                        if(event.isAddEvent()) {
-                            //todo: add new config-property-setting, fire change event
-                        } else if(event.isRemoveEvent()) {
-                            //todo: remove config-property-setting, fire change event
-                        } else if(event.isChangeEvent()) {
-                            if(event.getChangeEvent().getPropertyName().equals("config-property-name")) {
-                                String old = (String) event.getChangeEvent().getOldValue();
-                                for (int i = 0; i < settings.length; i++) {
-                                    ConfigPropertySetting setting = settings[i];
-                                    if(setting.getName().equals(old)) {
-                                        setting.setName((String) event.getChangeEvent().getNewValue());
-                                        break;
-                                    }
-                                }
-                            }
-                        }
-                    }
-                };
+public class ConnectionDefinitionInstance extends ConfigHolder {
     private DDBean connectionDefinition;
-    private ConfigPropertySetting[] settings = new ConfigPropertySetting[0];
     private ConnectionManager manager;
 
     public ConnectionDefinitionInstance() {
-        super(null);
     }
 
     public ConnectionDefinitionInstance(DDBean connectionDefinition, GerConnectiondefinitionInstanceType instance) {
-        super(null);
         configure(connectionDefinition, instance);
     }
 
@@ -73,68 +43,13 @@
         return (GerConnectiondefinitionInstanceType) getXmlObject();
     }
 
-    void clearNullSettings() {
-        List list = new ArrayList();
-        for (int i = 0; i < settings.length; i++) {
-            ConfigPropertySetting setting = settings[i];
-            if(setting.getValue() != null) {
-                list.add(setting);
-            }
-        }
-        settings = (ConfigPropertySetting[]) list.toArray(new ConfigPropertySetting[list.size()]);
-        GerConnectiondefinitionInstanceType instance = getConnectionInstance();
-        for (int i = instance.getConfigPropertySettingArray().length-1; i>=0; --i) {
-            GerConfigPropertySettingType type = instance.getConfigPropertySettingArray(i);
-            if(type.isNil() || type.getStringValue() == null) {
-                instance.removeConfigPropertySetting(i);
-            }
-        }
-    }
-
-    void reconfigure() {
+    public void reconfigure() {
         configure(connectionDefinition, getConnectionInstance());
     }
 
     void configure(DDBean connectionDefinition, GerConnectiondefinitionInstanceType definition) {
-        ConfigPropertySetting[] old = null;
-        if(this.connectionDefinition != null) {
-            this.connectionDefinition.removeXpathListener("config-property", xpathListener);
-            old = settings;
-        }
         this.connectionDefinition = connectionDefinition;
-        setXmlObject(definition);
-
-        // Prepare the ConfigPropertySetting array
-        List list = new ArrayList();
-        DDBean[] all = connectionDefinition == null ? new DDBean[0] : connectionDefinition.getChildBean("config-property");
-        Map byName = new HashMap();
-        for (int i = 0; i < all.length; i++) {
-            DDBean ddBean = all[i];
-            byName.put(ddBean.getText("config-property-name")[0], ddBean);
-        }
-        GerConfigPropertySettingType[] previous = definition.getConfigPropertySettingArray();
-        for (int i = 0; i < previous.length; i++) {
-            GerConfigPropertySettingType setting = previous[i];
-            DDBean ddBean = (DDBean) byName.remove(setting.getName());
-            if(ddBean != null) {
-                list.add(new ConfigPropertySetting(ddBean, setting, false));
-            } else {
-                System.out.println("Ignoring connectiondefinition-instance/config-setting "+setting.getName()+" (no matching config-property in J2EE DD)");
-                //todo: delete it from the XMLBeans tree
-            }
-        }
-        for (Iterator it = byName.keySet().iterator(); it.hasNext();) {
-            String name = (String) it.next();
-            DDBean bean = (DDBean) byName.get(name);
-            list.add(new ConfigPropertySetting(bean, getConnectionInstance().addNewConfigPropertySetting(), true));
-        }
-        settings = (ConfigPropertySetting[]) list.toArray(new ConfigPropertySetting[list.size()]);
-        if(old != null) {
-            pcs.firePropertyChange("configPropertySetting", old, settings);
-        }
-        if(connectionDefinition != null) {
-            connectionDefinition.addXpathListener("config-property", xpathListener);
-        }
+        super.configure(connectionDefinition, definition);
         if(connectionDefinition != null) {
             DDBean parent = connectionDefinition.getChildBean("..")[0];
             ConnectionManager oldMgr = manager;
@@ -159,6 +74,18 @@
         return connectionDefinition;
     }
 
+    protected GerConfigPropertySettingType createConfigProperty() {
+        return getConnectionInstance().addNewConfigPropertySetting();
+    }
+
+    protected GerConfigPropertySettingType[] getConfigProperties() {
+        return getConnectionInstance().getConfigPropertySettingArray();
+    }
+
+    protected void removeConfigProperty(int index) {
+        getConnectionInstance().removeConfigPropertySetting(index);
+    }
+
     // ----------------------- JavaBean Properties for /connectiondefinition-instance ----------------------
 
     public String getName() {
@@ -191,18 +118,9 @@
         pcs.firePropertyChange("implementedInterface", old, getImplementedInterface());
     }
 
-    public ConfigPropertySetting[] getConfigPropertySetting() {
-        return settings;
-    }
-
-    public ConfigPropertySetting getConfigPropertySetting(int index) {
-        return settings[index];
-    }
-
     public ConnectionManager getConnectionManager() {
         return manager;
     }
-
 
     // ----------------------- End of JavaBean Properties ----------------------
 

Modified: geronimo/trunk/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/jsr88/ConnectionManager.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/jsr88/ConnectionManager.java?rev=371461&r1=371460&r2=371461&view=diff
==============================================================================
--- geronimo/trunk/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/jsr88/ConnectionManager.java (original)
+++ geronimo/trunk/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/jsr88/ConnectionManager.java Sun Jan 22 20:53:26 2006
@@ -53,8 +53,9 @@
                     manager.addNewNoTransaction();
                 } else if(tx.equalsIgnoreCase("LocalTransaction")) {
                     manager.addNewLocalTransaction();
-                } else if(tx.equalsIgnoreCase("XATranasaction")) {
+                } else if(tx.equalsIgnoreCase("XATransaction")) {
                     manager.addNewXaTransaction();
+                    manager.getXaTransaction().addNewTransactionCaching();
                 }
             }
         }
@@ -203,7 +204,7 @@
     }
 
     public boolean isTransactionXACachingThread() {
-        return isTransactionXA() && getManager().getXaTransaction().isSetTransactionCaching();
+        return isTransactionXA() && getManager().getXaTransaction().isSetThreadCaching();
     }
 
     public void setTransactionXACachingThread(boolean set) {

Modified: geronimo/trunk/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/jsr88/Connector15DCBRoot.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/jsr88/Connector15DCBRoot.java?rev=371461&r1=371460&r2=371461&view=diff
==============================================================================
--- geronimo/trunk/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/jsr88/Connector15DCBRoot.java (original)
+++ geronimo/trunk/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/jsr88/Connector15DCBRoot.java Sun Jan 22 20:53:26 2006
@@ -137,10 +137,8 @@
         } finally {
             for (int i = 0; i < parents.size(); i++) {
                 Object parent = parents.get(i);
-                if(parent instanceof ConnectionDefinitionInstance) {
-                    ConnectionDefinitionInstance instance = (ConnectionDefinitionInstance) parent;
-                    instance.reconfigure();
-                } //todo: else if instanceof ResourceAdapterInstance, else if instanceof AdminObjectInstance
+                ConfigHolder instance = (ConfigHolder) parent;
+                instance.reconfigure();
             }
         }
     }
@@ -149,7 +147,10 @@
         ResourceAdapter[] adapters = connector.getResourceAdapter();
         for (int i = 0; i < adapters.length; i++) {
             ResourceAdapter adapter = adapters[i];
-            // todo: check resource adapter instances
+            if(adapter.getResourceAdapterInstance() != null) {
+                parents.add(adapter.getResourceAdapterInstance());
+                adapter.getResourceAdapterInstance().clearNullSettings();
+            }
             ConnectionDefinition defs[] = adapter.getConnectionDefinition();
             for (int j = 0; j < defs.length; j++) {
                 ConnectionDefinition def = defs[j];
@@ -161,6 +162,21 @@
                 }
             }
         }
-        //todo: check admin object instances
+        try {
+            DDBean[] adminDDBs = connector.getDDBean().getChildBean(connector.getXpaths()[0]);
+            if(adminDDBs == null) adminDDBs = new DDBean[0];
+            for (int i = 0; i < adminDDBs.length; i++) {
+                DDBean ddb = adminDDBs[i];
+                AdminObjectDCB dcb = (AdminObjectDCB) connector.getDConfigBean(ddb);
+                AdminObjectInstance[] instances = dcb.getAdminObjectInstance();
+                for (int j = 0; j < instances.length; j++) {
+                    AdminObjectInstance instance = instances[j];
+                    parents.add(instance);
+                    instance.clearNullSettings();
+                }
+            }
+        } catch (ConfigurationException e) {
+            e.printStackTrace();
+        }
     }
 }

Modified: geronimo/trunk/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/jsr88/ConnectorDCB.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/jsr88/ConnectorDCB.java?rev=371461&r1=371460&r2=371461&view=diff
==============================================================================
--- geronimo/trunk/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/jsr88/ConnectorDCB.java (original)
+++ geronimo/trunk/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/jsr88/ConnectorDCB.java Sun Jan 22 20:53:26 2006
@@ -19,14 +19,26 @@
 import java.util.Set;
 import java.util.HashSet;
 import java.util.Iterator;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.LinkedHashMap;
+import java.util.Arrays;
+import java.util.Collections;
 import javax.enterprise.deploy.model.DDBean;
 import javax.enterprise.deploy.model.XpathListener;
 import javax.enterprise.deploy.model.XpathEvent;
+import javax.enterprise.deploy.spi.DConfigBean;
+import javax.enterprise.deploy.spi.exceptions.ConfigurationException;
+
 import org.apache.geronimo.deployment.plugin.DConfigBeanSupport;
 import org.apache.geronimo.deployment.xbeans.DependencyType;
 import org.apache.geronimo.xbeans.geronimo.GerConnectorType;
 import org.apache.geronimo.xbeans.geronimo.GerResourceadapterType;
+import org.apache.geronimo.xbeans.geronimo.GerAdminobjectType;
+import org.apache.geronimo.xbeans.geronimo.GerAdminobjectInstanceType;
 import org.apache.xmlbeans.SchemaTypeLoader;
+import org.apache.xmlbeans.XmlCursor;
 
 /**
  * Represents /connector in a Geronimo Connector deployment plan.
@@ -38,6 +50,7 @@
     private DDBean resourceAdapterDDBean;
     private ResourceAdapter[] resourceAdapter = new ResourceAdapter[0];
     private Dependency[] dependency = new Dependency[0];
+    private AdminObjectDCB[] adminobjects = new AdminObjectDCB[0];
 
     public ConnectorDCB(DDBean connectorDDBean, final GerConnectorType connector) {
         super(connectorDDBean, connector);
@@ -62,6 +75,33 @@
         });
     }
 
+    public String[] getXpaths() {
+        return getXPathsForJ2ee_1_4(new String[][]{{"resourceadapter","adminobject",},});
+    }
+
+    public DConfigBean getDConfigBean(DDBean bean) throws ConfigurationException {
+        if (getXpaths()[0].equals(bean.getXpath())) { // "adminobject"
+            String aoInterface = bean.getText("adminobject-interface")[0];
+            String aoClass = bean.getText("adminobject-class")[0];
+            // Check whether we've seen this one before
+            for(int i=0; i<adminobjects.length; i++) {
+                if(adminobjects[i].getAdminObjectClass().equals(aoClass) &&
+                   adminobjects[i].getAdminObjectInterface().equals(aoInterface)) {
+                    return adminobjects[i];
+                }
+            }
+            // Haven't seen it; create a new DConfigBean
+            GerAdminobjectType ao = getConnector().addNewAdminobject();
+            AdminObjectDCB dcb = new AdminObjectDCB(bean, ao);
+            AdminObjectDCB[] list = new AdminObjectDCB[adminobjects.length+1];
+            System.arraycopy(adminobjects, 0, list, 0, adminobjects.length);
+            list[adminobjects.length] = dcb;
+            return dcb;
+        } else {
+            throw new ConfigurationException("No DConfigBean matching DDBean "+bean.getXpath());
+        }
+    }
+
     private void loadExistingData(GerConnectorType connector) {
         //todo: Handle the import children
         //todo: Handle the hidden-classes children
@@ -89,7 +129,78 @@
                 resourceAdapter[i] = new ResourceAdapter(resourceAdapterDDBean, adapter);
             }
         }
-        //todo: Handle the AdminObject children
+        // Handle the AdminObject children
+        GerAdminobjectType[] admins = connector.getAdminobjectArray();
+        DDBean[] data = getDDBean().getChildBean(getXpaths()[0]);
+        List ddBeans = data == null ? Collections.EMPTY_LIST : new ArrayList(Arrays.asList(data)); // resourceadapter/adminobject
+
+        Map dcbs = new LinkedHashMap();
+        if(admins == null) {
+            adminobjects = new AdminObjectDCB[0];
+        } else {
+            // Match up each Geronimo adminobject with a ra.xml adminobject and create DConfigBeans accordingly
+            for (int i = 0; i < admins.length; i++) {
+                GerAdminobjectType admin = admins[i];
+                String aoClass = admin.getAdminobjectClass();
+                String aoIface = admin.getAdminobjectInterface();
+                AdminObjectDCB dcb = (AdminObjectDCB) dcbs.get("class "+aoClass+" iface "+aoIface);
+                if(dcb != null) {
+                    // this is a second Geronimo adminobject block of the same type; there will not be a matching DDBean any more
+                    // merge the adminobject-instance entries instead!!!
+                    if(admin.getAdminobjectInstanceArray().length > 0) {
+                        GerAdminobjectType old = dcb.getAdminObject();
+                        GerAdminobjectInstanceType[] array = admin.getAdminobjectInstanceArray();
+                        int oldCount = dcb.getAdminObjectInstance().length;
+                        for (int j = 0; j < array.length; j++) {
+                            GerAdminobjectInstanceType instance = array[j];
+                            XmlCursor source = instance.newCursor();
+                            XmlCursor dest = old.newCursor();
+                            dest.toEndToken();
+                            if(!source.moveXml(dest)) {
+                                throw new RuntimeException("Unable to move admin object instance");
+                            }
+                            source.dispose();
+                            dest.dispose();
+                            dcb.addAdminObjectInstance(old.getAdminobjectInstanceArray(oldCount+j));
+                        }
+                    }
+                    continue;
+                }
+                DDBean target = null;
+                for (int j = 0; j < ddBeans.size(); j++) {
+                    DDBean ddBean = (DDBean) ddBeans.get(j);
+                    String ddClass = ddBean.getText("adminobject-class")[0];
+                    String ddIface = ddBean.getText("adminobject-interface")[0];
+                    if(ddClass.equals(aoClass) && ddIface.equals(aoIface)) {
+                        target = ddBean;
+                        ddBeans.remove(j);
+                        break;
+                    }
+                }
+                if(target == null) {
+                    System.out.println("Geronimo connector deployment plan has admin object with interface '"+aoIface+"' and class '"+aoClass+"' but the ra.xml does not have a matching adminobject declared.  Deleting this adminobject from the Geronimo plan.");
+                    continue;
+                }
+                dcb = new AdminObjectDCB(target, admin);
+                dcbs.put("class "+aoClass+" iface "+aoIface, dcb);
+            }
+        }
+        // There are some admin object types in ra.xml with no matching instances; create DConfigBeans for those
+        for (int i = 0; i < ddBeans.size(); i++) {
+            DDBean ddBean = (DDBean) ddBeans.get(i);
+            String ddClass = ddBean.getText("adminobject-class")[0];
+            String ddIface = ddBean.getText("adminobject-interface")[0];
+            GerAdminobjectType admin = connector.addNewAdminobject();
+            dcbs.put("class "+ddClass+" iface "+ddIface, new AdminObjectDCB(ddBean, admin));
+        }
+        List adminResults = new ArrayList();
+        for (Iterator it = dcbs.keySet().iterator(); it.hasNext();) {
+            String key = (String) it.next();
+            DConfigBean value = (DConfigBean) dcbs.get(key);
+            adminResults.add(value);
+        }
+        adminobjects = (AdminObjectDCB[]) adminResults.toArray(new AdminObjectDCB[adminResults.size()]);
+
         //todo: Handle the GBean children
     }
 
@@ -104,7 +215,6 @@
     // import*
     // hidden-classes*
     // non-overridable-classes*
-    // adminobject*
     // gbean*
 
     public String getConfigID() {
@@ -256,7 +366,7 @@
 
     // ----------------------- End of JavaBean Properties ----------------------
 
-    
+
 
     protected SchemaTypeLoader getSchemaTypeLoader() {
         return Connector15DCBRoot.SCHEMA_TYPE_LOADER;

Modified: geronimo/trunk/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/jsr88/ResourceAdapter.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/jsr88/ResourceAdapter.java?rev=371461&r1=371460&r2=371461&view=diff
==============================================================================
--- geronimo/trunk/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/jsr88/ResourceAdapter.java (original)
+++ geronimo/trunk/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/jsr88/ResourceAdapter.java Sun Jan 22 20:53:26 2006
@@ -36,6 +36,7 @@
 public class ResourceAdapter extends XmlBeanSupport {
     private DDBean resourceAdapter;
     private ConnectionDefinition[] instances = new ConnectionDefinition[0];
+    private ResourceAdapterInstance resourceAdapterInstance;
 
     public ResourceAdapter() {
         super(null);
@@ -53,6 +54,11 @@
     void configure(DDBean resourceAdapter, GerResourceadapterType ra) {
         this.resourceAdapter = resourceAdapter;
         setXmlObject(ra);
+        if(ra.isSetResourceadapterInstance()) {
+            resourceAdapterInstance = new ResourceAdapterInstance(resourceAdapter, ra.getResourceadapterInstance());
+        } else {
+            resourceAdapterInstance = null;
+        }
         if(ra.isSetOutboundResourceadapter()) {
             DDBean[] test = resourceAdapter.getChildBean("outbound-resourceadapter");
             if(test != null && test.length > 0) {
@@ -72,8 +78,6 @@
     }
 
     // ----------------------- JavaBean Properties for /connector/resourceadapter ----------------------
-    //todo: handle the following properties
-    // resourceadapter-instance?
 
     public ConnectionDefinition[] getConnectionDefinition() {
         return instances;
@@ -129,7 +133,24 @@
         if(definition.getConnectionDefinition() == null) {
             definition.configure(resourceAdapter, getResourceAdapter().getOutboundResourceadapter().addNewConnectionDefinition());
         }
-        pcs.firePropertyChange("resourceAdapter", old, instances);
+        pcs.firePropertyChange("connectionDefinition", old, instances);
+    }
+
+    public ResourceAdapterInstance getResourceAdapterInstance() {
+        return resourceAdapterInstance;
+    }
+
+    public void setResourceAdapterInstance(ResourceAdapterInstance resourceAdapterInstance) {
+        ResourceAdapterInstance old = this.resourceAdapterInstance;
+        this.resourceAdapterInstance = resourceAdapterInstance;
+        if(resourceAdapterInstance.getResourceAdapterInstance() == null) {
+            if(getResourceAdapter().isSetResourceadapterInstance()) {
+                resourceAdapterInstance.configure(resourceAdapter, getResourceAdapter().getResourceadapterInstance());
+            } else {
+                resourceAdapterInstance.configure(resourceAdapter, getResourceAdapter().addNewResourceadapterInstance());
+            }
+        }
+        pcs.firePropertyChange("resourceAdapterInstance", old, instances);
     }
 
     // ----------------------- End of JavaBean Properties ----------------------

Propchange: geronimo/trunk/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/jsr88/ResourceAdapterInstance.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: geronimo/trunk/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/jsr88/SinglePool.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/jsr88/SinglePool.java?rev=371461&r1=371460&r2=371461&view=diff
==============================================================================
--- geronimo/trunk/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/jsr88/SinglePool.java (original)
+++ geronimo/trunk/modules/connector-builder/src/java/org/apache/geronimo/connector/deployment/jsr88/SinglePool.java Sun Jan 22 20:53:26 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());
         }

Propchange: geronimo/trunk/modules/connector-builder/src/test-resources/jms-plan.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/trunk/modules/connector-builder/src/test-resources/jms.rar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: geronimo/trunk/modules/connector-builder/src/test/org/apache/geronimo/connector/deployment/jsr88/Connector15DCBTest.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/connector-builder/src/test/org/apache/geronimo/connector/deployment/jsr88/Connector15DCBTest.java?rev=371461&r1=371460&r2=371461&view=diff
==============================================================================
--- geronimo/trunk/modules/connector-builder/src/test/org/apache/geronimo/connector/deployment/jsr88/Connector15DCBTest.java (original)
+++ geronimo/trunk/modules/connector-builder/src/test/org/apache/geronimo/connector/deployment/jsr88/Connector15DCBTest.java Sun Jan 22 20:53:26 2006
@@ -21,9 +21,12 @@
 import org.apache.geronimo.deployment.tools.loader.ConnectorDeployable;
 import org.apache.geronimo.xbeans.geronimo.GerConnectorDocument;
 import org.apache.geronimo.xbeans.geronimo.GerConfigPropertySettingType;
+import org.apache.geronimo.naming.deployment.jsr88.GBeanLocator;
 
 import javax.enterprise.deploy.model.DDBeanRoot;
+import javax.enterprise.deploy.model.DDBean;
 import javax.enterprise.deploy.shared.ModuleType;
+import javax.enterprise.deploy.spi.DConfigBean;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.InputStream;
@@ -69,14 +72,14 @@
         assertNull(connector.getParentID());
         assertNull(connector.getSuppressDefaultParentID());
         connector.setConfigID("MyDatabase");
-        connector.setParentID("org/apache/geronimo/Server");
-        // Try the dependency element
+        connector.setParentID("geronimo/j2ee-server/1.0/car");
+        // Try the /connector/dependency element
         assertNotNull(connector.getDependency());
         assertEquals(0, connector.getDependency().length);
         Dependency dep = new Dependency();
         connector.setDependency(new Dependency[]{dep});
         assertEquals(1, connector.getDependency().length);
-        dep.setURI("postgresql/jars/postgresql-8.0-313.jdbc3.jar");
+        dep.setURI("postgresql/postgresql-8.0/313.jdbc3/jar");
         assertNull(dep.getArtifactId());
         assertNull(dep.getGroupId());
         assertNull(dep.getType());
@@ -86,6 +89,9 @@
         dep.setVersion("313.jdbc3");
         assertNull(dep.getURI());
         assertNull(dep.getType());
+        // todo: Try the /connector/import element
+        // todo: Try the /connector/hidden-classes element
+        // todo: Try the /connector/non-overridable-classes element
         // Try the /connector/resourceadapter element
         assertNotNull(connector.getResourceAdapter());
         assertEquals(1, connector.getResourceAdapter().length);
@@ -215,15 +221,21 @@
         GerConfigPropertySettingType[] settings = doc.getConnector().getResourceadapterArray(0).
                 getOutboundResourceadapter().getConnectionDefinitionArray(0).
                 getConnectiondefinitionInstanceArray(0).getConfigPropertySettingArray();
-        assertEquals(4, settings.length);
+        assertEquals(2, settings.length);
+        Set seen = new HashSet();
         for (int i = 0; i < settings.length; i++) {
             GerConfigPropertySettingType setting = settings[i];
-            if(setting.getName().equals("CommitBeforeAutocommit")) {
-                assertEquals("false", setting.getStringValue());
-            } else if(setting.getName().equals("Driver")) {
+            if(seen.contains(setting.getName())) {
+                fail("Duplicate for config property setting '"+setting.getName()+"'");
+            }
+            seen.add(setting.getName());
+// These two are set to their defaults and now no longer appear
+//            if(setting.getName().equals("CommitBeforeAutocommit")) {
+//                assertEquals("false", setting.getStringValue());
+//            } else if(setting.getName().equals("ExceptionSorterClass")) {
+//                assertEquals("org.tranql.connector.AllExceptionsAreFatalSorter", setting.getStringValue());
+            if(setting.getName().equals("Driver")) {
                 assertEquals("org.apache.derby.jdbc.EmbeddedDriver", setting.getStringValue());
-            } else if(setting.getName().equals("ExceptionSorterClass")) {
-                assertEquals("org.tranql.connector.AllExceptionsAreFatalSorter", setting.getStringValue());
             } else if(setting.getName().equals("ConnectionURL")) {
                 assertEquals("jdbc:derby:TestDatabase;create=true", setting.getStringValue());
             } else fail("Unknown connection setting '"+setting.getName()+"'");
@@ -233,12 +245,12 @@
         // Now set them to blank
         nullCount = 0;
         for (int i = 0; i < 6; i++) {
-            if(instance.getConfigPropertySetting()[i].getValue() == null) {
+            if(instance.getConfigPropertySetting()[i].getValue() == null || instance.getConfigPropertySetting()[i].isSetToDefault()) {
                 instance.getConfigPropertySetting()[i].setValue("");
                 ++nullCount;
             }
         }
-        assertEquals(2, nullCount);
+        assertEquals(4, nullCount);
         // Now make sure we write out with 6
         pout = new ByteArrayOutputStream();
         dcbRoot.toXML(pout);
@@ -250,20 +262,282 @@
                 getOutboundResourceadapter().getConnectionDefinitionArray(0).
                 getConnectiondefinitionInstanceArray(0).getConfigPropertySettingArray();
         assertEquals(6, settings.length);
+        seen.clear();
         for (int i = 0; i < settings.length; i++) {
             GerConfigPropertySettingType setting = settings[i];
+            if(seen.contains(setting.getName())) {
+                fail("Duplicate for config property setting '"+setting.getName()+"'");
+            }
+            seen.add(setting.getName());
             if(setting.getName().equals("UserName")) {
                 assertEquals("", setting.getStringValue());
             } else if(setting.getName().equals("Password")) {
                 assertEquals("", setting.getStringValue());
             } else if(setting.getName().equals("CommitBeforeAutocommit")) {
-                assertEquals("false", setting.getStringValue());
+                assertEquals("", setting.getStringValue());
             } else if(setting.getName().equals("Driver")) {
                 assertEquals("org.apache.derby.jdbc.EmbeddedDriver", setting.getStringValue());
             } else if(setting.getName().equals("ExceptionSorterClass")) {
-                assertEquals("org.tranql.connector.AllExceptionsAreFatalSorter", setting.getStringValue());
+                assertEquals("", setting.getStringValue());
             } else if(setting.getName().equals("ConnectionURL")) {
                 assertEquals("jdbc:derby:TestDatabase;create=true", setting.getStringValue());
+            } else fail("Unknown connection setting '"+setting.getName()+"'");
+        }
+    }
+
+    public void testCreateJMSResource() throws Exception {
+        // Create and test the DDBeanRoot
+        URL resource = classLoader.getResource("jms.rar");
+        assertNotNull(resource);
+        ConnectorDeployable deployable = new ConnectorDeployable(resource);
+        assertEquals(ModuleType.RAR, deployable.getType());
+        Set entrySet = new HashSet(Collections.list(deployable.entries()));
+        assertTrue(entrySet.contains("META-INF/ra.xml"));
+        assertTrue(entrySet.contains("activemq-ra-3.2.1.jar"));
+        DDBeanRoot root = deployable.getDDBeanRoot();
+        assertNotNull(root);
+        assertEquals(ModuleType.RAR, root.getType());
+        assertEquals(deployable, root.getDeployableObject());
+        // Create the DConfigBeanRoot
+        Connector15DCBRoot dcbRoot = new Connector15DCBRoot(root);
+        assertNotNull(dcbRoot.getXpaths());
+        assertEquals(1, dcbRoot.getXpaths().length);
+        assertEquals("connector", dcbRoot.getXpaths()[0]);
+        // Try the /connector element
+        ConnectorDCB connector = (ConnectorDCB) dcbRoot.getDConfigBean(root.getChildBean(dcbRoot.getXpaths()[0])[0]);
+        assertNotNull(connector);
+        assertNull(connector.getConfigID());
+        assertNull(connector.getInverseClassLoading());
+        assertNull(connector.getParentID());
+        assertNull(connector.getSuppressDefaultParentID());
+        connector.setConfigID("MyJMS");
+        connector.setParentID("geronimo/activemq/1.0/car");
+        // Try the /connector/dependency element
+        assertNotNull(connector.getDependency());
+        assertEquals(0, connector.getDependency().length);
+        Dependency dep = new Dependency();
+        connector.setDependency(new Dependency[]{dep});
+        assertEquals(1, connector.getDependency().length);
+        dep.setURI("postgresql/postgresql-8.0/313.jdbc3/jar");
+        assertNull(dep.getArtifactId());
+        assertNull(dep.getGroupId());
+        assertNull(dep.getType());
+        assertNull(dep.getVersion());
+        dep.setGroupId("postgresql");
+        dep.setArtifactId("postgresql-8.0");
+        dep.setVersion("313.jdbc3");
+        assertNull(dep.getURI());
+        assertNull(dep.getType());
+        // todo: Try the /connector/import element
+        // todo: Try the /connector/hidden-classes element
+        // todo: Try the /connector/non-overridable-classes element
+        // Try the /connector/resourceadapter element
+        assertNotNull(connector.getResourceAdapter());
+        assertEquals(1, connector.getResourceAdapter().length);
+        ResourceAdapter adapter = connector.getResourceAdapter()[0];
+        assertNotNull(adapter);
+        // Try the /connector/resourceadapter/resourceadapter-instance element
+        assertNull(adapter.getResourceAdapterInstance());
+        adapter.setResourceAdapterInstance(new ResourceAdapterInstance());
+        ResourceAdapterInstance raInstance = adapter.getResourceAdapterInstance();
+        assertNull(raInstance.getResourceAdapterName());
+        assertNotNull(raInstance.getConfigProperties());
+        assertEquals(7, raInstance.getConfigPropertySetting().length);
+        for (int i = 0; i < raInstance.getConfigPropertySetting().length; i++) {
+            ConfigPropertySetting config = raInstance.getConfigPropertySetting()[i];
+            assertTrue(config.isSetToDefault());
+        }
+        int found = 0;
+        for (int i = 0; i < 7; i++) {
+            ConfigPropertySetting setting = raInstance.getConfigPropertySetting(i);
+            if(setting.getName().equals("ServerUrl")) {
+                setting.setValue("tcp://localhost:12345");
+                ++found;
+            } else if(setting.getName().equals("UserName")) {
+                setting.setValue("test-user");
+                ++found;
+            } else if(setting.getName().equals("Password")) {
+                setting.setValue("test-password");
+                ++found;
+            }
+        }
+        assertEquals(found, 3);
+        // Try the /connector/resourceadapter/resourceadapter-instance/workmanager
+        assertNull(raInstance.getWorkManager());
+        GBeanLocator workManager = new GBeanLocator();
+        raInstance.setWorkManager(workManager);
+        workManager.setGBeanLink("DefaultWorkManager");
+        // Try the /connector/resourceadapter/outbound-resourceadapter/connection-definition element
+        assertNotNull(adapter.getConnectionDefinition());
+        assertEquals(0, adapter.getConnectionDefinition().length);
+        ConnectionDefinition definition = new ConnectionDefinition();
+        adapter.setConnectionDefinition(new ConnectionDefinition[]{definition});
+        assertEquals(1, adapter.getConnectionDefinition().length);
+        definition.setConnectionFactoryInterface("javax.jms.ConnectionFactory");
+        // Try the .../connection-definition/connectiondefinition-instance elements
+        assertNotNull(definition.getConnectionInstances());
+        assertEquals(0, definition.getConnectionInstances().length);
+        ConnectionDefinitionInstance instance = new ConnectionDefinitionInstance();
+        definition.setConnectionInstance(new ConnectionDefinitionInstance[]{instance});
+        assertEquals(1, definition.getConnectionInstances().length);
+        assertNotNull(instance.getDDBean());
+        instance.setName("Test JMS Resource");
+        instance.setImplementedInterface(new String[]{"javax.jms.QueueConnectorFactory","javax.jms.TopicConnectionFactory"});
+        // Try the .../connection-definition/connectiondefinition-instance/config-property-setting elements
+        assertNotNull(instance.getConfigPropertySetting());
+        assertEquals(0, instance.getConfigPropertySetting().length);
+        // Try the .../connection-definition/connectionmanager elements
+        ConnectionManager manager = instance.getConnectionManager();
+        assertNotNull(manager);
+        assertFalse(manager.isContainerManagedSecurity());
+        assertFalse(manager.isPoolNone());
+        assertNotNull(manager.getPoolSingle());
+        assertNull(manager.getPoolPartitioned());
+        assertFalse(manager.isTransactionLog());
+        assertFalse(manager.isTransactionNone());
+        assertTrue(manager.isTransactionXA());
+        assertFalse(manager.isTransactionXACachingThread());
+        assertTrue(manager.isTransactionXACachingTransaction());
+        assertFalse(manager.isTransactionLocal());
+        SinglePool pool = manager.getPoolSingle();
+        assertNull(pool.getMinSize());
+        assertNull(pool.getMaxSize());
+        assertNull(pool.getIdleTimeoutMinutes());
+        assertNull(pool.getBlockingTimeoutMillis());
+        assertTrue(pool.isMatchOne());
+        assertFalse(pool.isMatchAll());
+        assertFalse(pool.isSelectOneAssumeMatch());
+        pool.setMinSize(new Integer(2));
+        pool.setMaxSize(new Integer(30));
+        pool.setBlockingTimeoutMillis(new Integer(5000));
+        DDBean[] ddBeans = connector.getDDBean().getChildBean(connector.getXpaths()[0]);
+        assertNotNull(ddBeans);
+        assertEquals(2, ddBeans.length);
+        DConfigBean[] adminDCBs = new DConfigBean[ddBeans.length];
+        for (int i = 0; i < adminDCBs.length; i++) {
+            adminDCBs[i] = connector.getDConfigBean(ddBeans[i]);
+            AdminObjectDCB dcb = (AdminObjectDCB) adminDCBs[i];
+            if(dcb.getAdminObjectClass().indexOf("Queue") > -1) {
+                assertEquals(0, dcb.getAdminObjectInstance().length);
+                AdminObjectInstance one = new AdminObjectInstance();
+                AdminObjectInstance two = new AdminObjectInstance();
+                dcb.setAdminObjectInstance(new AdminObjectInstance[]{one, two});
+                one.setMessageDestinationName("TestQueue1");
+                one.getConfigPropertySetting()[0].setValue("PhysicalName1");
+                two.setMessageDestinationName("TestQueue2");
+                two.getConfigPropertySetting()[0].setValue("PhysicalName2");
+            } else if(dcb.getAdminObjectClass().indexOf("Topic") > -1) {
+                assertEquals(0, dcb.getAdminObjectInstance().length);
+            } else fail("Unknown AdminobjectDCB admin object class '"+dcb.getAdminObjectClass()+"'");
+        }
+
+
+        //todo: Look at the XmlBeans tree and make sure the right stuff is in there
+        //dcbRoot.toXML(System.out);
+    }
+
+    public void testLoadJMSResources() throws Exception {
+        InputStream in = classLoader.getResource("jms-plan.xml").openStream();
+        // Create and test the DDBeanRoot
+        URL resource = classLoader.getResource("jms.rar");
+        assertNotNull(resource);
+        ConnectorDeployable deployable = new ConnectorDeployable(resource);
+        assertEquals(ModuleType.RAR, deployable.getType());
+        Set entrySet = new HashSet(Collections.list(deployable.entries()));
+        assertTrue(entrySet.contains("META-INF/ra.xml"));
+        assertTrue(entrySet.contains("activemq-ra-3.2.1.jar"));
+        DDBeanRoot root = deployable.getDDBeanRoot();
+        assertNotNull(root);
+        assertEquals(ModuleType.RAR, root.getType());
+        assertEquals(deployable, root.getDeployableObject());
+        // Create the DConfigBeanRoot
+        Connector15DCBRoot dcbRoot = new Connector15DCBRoot(root);
+        RARConfiguration configuration = new RARConfiguration(deployable, dcbRoot);
+        configuration.restore(in);
+        // Try the /connector element
+        ConnectorDCB connector = (ConnectorDCB) dcbRoot.getDConfigBean(root.getChildBean(dcbRoot.getXpaths()[0])[0]);
+        assertNotNull(connector);
+        // Try the /connector/resourceadapter element
+        assertNotNull(connector.getResourceAdapter());
+        assertEquals(1, connector.getResourceAdapter().length);
+        ResourceAdapter adapter = connector.getResourceAdapter()[0];
+        assertNotNull(adapter);
+        // Try the /connector/resourceadapter/resourceadapter-instance element
+        ResourceAdapterInstance raInstance = adapter.getResourceAdapterInstance();
+        assertNotNull(raInstance);
+        assertEquals("Test ActiveMQ RA", raInstance.getResourceAdapterName());
+        assertEquals(7, raInstance.getConfigPropertySetting().length);
+        int found = 0;
+        Set seen = new HashSet();
+        for (int i = 0; i < 7; i++) {
+            ConfigPropertySetting setting = raInstance.getConfigPropertySetting(i);
+            if(seen.contains(setting.getName())) {
+                fail("Duplicate for config property setting '"+setting.getName()+"'");
+            }
+            seen.add(setting.getName());
+            if(setting.getName().equals("ServerUrl")) {
+                assertEquals("tcp://localhost:61616", setting.getValue());
+                ++found;
+            } else if(setting.getName().equals("UserName")) {
+                assertEquals("geronimo-user", setting.getValue());
+                ++found;
+            } else if(setting.getName().equals("Password")) {
+                assertEquals("geronimo-pw", setting.getValue());
+                ++found;
+            }
+        }
+        assertEquals(3, found);
+        //todo: check the work manager
+        // Try the /connector/resourceadapter/outbound-resourceadapter/connection-definition element
+        assertNotNull(adapter.getConnectionDefinition());
+        assertEquals(1, adapter.getConnectionDefinition().length);
+        ConnectionDefinition definition = adapter.getConnectionDefinition(0);
+        // Try the .../connection-definition/connectiondefinition-instance elements
+        assertNotNull(definition.getConnectionInstances());
+        assertEquals(1, definition.getConnectionInstances().length);
+        ConnectionDefinitionInstance instance = definition.getConnectionInstances()[0];
+        // Try the .../connection-definition/connectiondefinition-instance/config-property-setting elements
+        assertNotNull(instance.getConfigPropertySetting());
+        assertEquals(0, instance.getConfigPropertySetting().length);
+        // Try the /connector/adminobject element
+        DDBean[] ddBeans = connector.getDDBean().getChildBean(connector.getXpaths()[0]);
+        assertNotNull(ddBeans);
+        assertEquals(2, ddBeans.length);
+        DConfigBean[] adminDCBs = new DConfigBean[ddBeans.length];
+        for (int i = 0; i < adminDCBs.length; i++) {
+            adminDCBs[i] = connector.getDConfigBean(ddBeans[i]);
+            AdminObjectDCB dcb = (AdminObjectDCB) adminDCBs[i];
+            if(dcb.getAdminObjectClass().indexOf("Queue") > -1) {
+                assertEquals(3, dcb.getAdminObjectInstance().length);
+                assertEquals("TestQueue1Name", dcb.getAdminObjectInstance()[0].getMessageDestinationName());
+                assertEquals("TestQueue2Name", dcb.getAdminObjectInstance()[1].getMessageDestinationName());
+                assertEquals("TestQueue3Name", dcb.getAdminObjectInstance()[2].getMessageDestinationName());
+            } else if(dcb.getAdminObjectClass().indexOf("Topic") > -1) {
+                assertEquals(1, dcb.getAdminObjectInstance().length);
+                assertEquals("TestTopic1Name", dcb.getAdminObjectInstance()[0].getMessageDestinationName());
+            } else fail("Unknown AdminobjectDCB admin object class '"+dcb.getAdminObjectClass()+"'");
+        }
+        // Make sure that saving clears out the null/default values
+        ByteArrayOutputStream pout = new ByteArrayOutputStream();
+        dcbRoot.toXML(pout);
+        pout.close();
+        ByteArrayInputStream pin = new ByteArrayInputStream(pout.toByteArray());
+        GerConnectorDocument doc = GerConnectorDocument.Factory.parse(pin);
+        pin.close();
+        GerConfigPropertySettingType[] settings = doc.getConnector().getResourceadapterArray(0).
+                getResourceadapterInstance().getConfigPropertySettingArray();
+        assertEquals(2, settings.length);
+        seen.clear();
+        for (int i = 0; i < settings.length; i++) {
+            GerConfigPropertySettingType setting = settings[i];
+            if(seen.contains(setting.getName())) {
+                fail("Duplicate for config property setting '"+setting.getName()+"'");
+            }
+            seen.add(setting.getName());
+            if(setting.getName().equals("UserName")) {
+                assertEquals("geronimo-user", setting.getStringValue());
+            } else if(setting.getName().equals("Password")) {
+                assertEquals("geronimo-pw", setting.getStringValue());
             } else fail("Unknown connection setting '"+setting.getName()+"'");
         }
     }

Modified: geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/AdminObjectWrapper.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/AdminObjectWrapper.java?rev=371461&r1=371460&r2=371461&view=diff
==============================================================================
--- geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/AdminObjectWrapper.java (original)
+++ geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/AdminObjectWrapper.java Sun Jan 22 20:53:26 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/trunk/modules/connector/src/java/org/apache/geronimo/connector/AdminObjectWrapperGBean.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/AdminObjectWrapperGBean.java?rev=371461&r1=371460&r2=371461&view=diff
==============================================================================
--- geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/AdminObjectWrapperGBean.java (original)
+++ geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/AdminObjectWrapperGBean.java Sun Jan 22 20:53:26 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/trunk/modules/connector/src/java/org/apache/geronimo/connector/outbound/ManagedConnectionFactoryWrapper.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/outbound/ManagedConnectionFactoryWrapper.java?rev=371461&r1=371460&r2=371461&view=diff
==============================================================================
--- geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/outbound/ManagedConnectionFactoryWrapper.java (original)
+++ geronimo/trunk/modules/connector/src/java/org/apache/geronimo/connector/outbound/ManagedConnectionFactoryWrapper.java Sun Jan 22 20:53:26 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/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/Deployer.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/Deployer.java?rev=371461&r1=371460&r2=371461&view=diff
==============================================================================
--- geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/Deployer.java (original)
+++ geronimo/trunk/modules/deployment/src/java/org/apache/geronimo/deployment/Deployer.java Sun Jan 22 20:53:26 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"));

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

Modified: geronimo/trunk/modules/management/src/java/org/apache/geronimo/management/geronimo/JCAManagedConnectionFactory.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/management/src/java/org/apache/geronimo/management/geronimo/JCAManagedConnectionFactory.java?rev=371461&r1=371460&r2=371461&view=diff
==============================================================================
--- geronimo/trunk/modules/management/src/java/org/apache/geronimo/management/geronimo/JCAManagedConnectionFactory.java (original)
+++ geronimo/trunk/modules/management/src/java/org/apache/geronimo/management/geronimo/JCAManagedConnectionFactory.java Sun Jan 22 20:53:26 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();
     

Propchange: geronimo/trunk/modules/naming-builder/src/java/org/apache/geronimo/naming/deployment/jsr88/GBeanLocator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/trunk/modules/naming-builder/src/java/org/apache/geronimo/naming/deployment/jsr88/ObjectNameGroup.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/repository/FileSystemRepository.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/repository/FileSystemRepository.java?rev=371461&r1=371460&r2=371461&view=diff
==============================================================================
--- geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/repository/FileSystemRepository.java (original)
+++ geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/repository/FileSystemRepository.java Sun Jan 22 20:53:26 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/trunk/modules/system/src/java/org/apache/geronimo/system/serverinfo/BasicServerInfo.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/serverinfo/BasicServerInfo.java?rev=371461&r1=371460&r2=371461&view=diff
==============================================================================
--- geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/serverinfo/BasicServerInfo.java (original)
+++ geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/serverinfo/BasicServerInfo.java Sun Jan 22 20:53:26 2006
@@ -108,6 +108,10 @@
         return baseDirectory;
     }
 
+    public String getCurrentBaseDirectory() {
+        return base.getAbsolutePath();
+    }
+
     public String getVersion() {
         return ServerConstants.getVersion();
     }

Modified: geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/serverinfo/ServerInfo.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/serverinfo/ServerInfo.java?rev=371461&r1=371460&r2=371461&view=diff
==============================================================================
--- geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/serverinfo/ServerInfo.java (original)
+++ geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/serverinfo/ServerInfo.java Sun Jan 22 20:53:26 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