djencks     2004/02/20 00:11:39

  Modified:    modules/deployment/src/java/org/apache/geronimo/deployment/plugin
                        DConfigBeanSupport.java
               modules/deployment/src/java/org/apache/geronimo/deployment/tools
                        DDBeanRootImpl.java
               modules/deployment/src/test/org/apache/geronimo/deployment/tools
                        DDBeanRootTest.java
  Log:
  some support for explicit namespaces in j2ee dds
  
  Revision  Changes    Path
  1.9       +43 -1     
incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/plugin/DConfigBeanSupport.java
  
  Index: DConfigBeanSupport.java
  ===================================================================
  RCS file: 
/home/cvs/incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/plugin/DConfigBeanSupport.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- DConfigBeanSupport.java   18 Feb 2004 20:55:31 -0000      1.8
  +++ DConfigBeanSupport.java   20 Feb 2004 08:11:39 -0000      1.9
  @@ -57,6 +57,7 @@
   
   import javax.enterprise.deploy.model.DDBean;
   import javax.enterprise.deploy.model.XpathEvent;
  +import javax.enterprise.deploy.model.DDBeanRoot;
   import javax.enterprise.deploy.spi.DConfigBean;
   import javax.enterprise.deploy.spi.exceptions.BeanNotFoundException;
   import javax.enterprise.deploy.spi.exceptions.ConfigurationException;
  @@ -99,5 +100,46 @@
       }
   
       public void notifyDDChange(XpathEvent event) {
  +    }
  +
  +    protected String[] getXPathsWithPrefix(String prefix, String[][] 
xpathSegments) {
  +        String[] result = new String[xpathSegments.length];
  +        for (int i = 0; i < xpathSegments.length; i++) {
  +            String[] xpathSegmentArray = xpathSegments[i];
  +            StringBuffer xpath = new StringBuffer();
  +            for (int j = 0; j < xpathSegmentArray.length; j++) {
  +                String segment = xpathSegmentArray[j];
  +                if (prefix != null) {
  +                    xpath.append(prefix).append(":");
  +                }
  +                xpath.append(segment);
  +                if (j < xpathSegmentArray.length -1) {
  +                    xpath.append("/");
  +                }
  +            }
  +            result[i] = xpath.toString();
  +        }
  +        return result;
  +    }
  +
  +    protected String[] getXPathsFromNamespace(String uri, String[][] 
xpathSegments) {
  +        String[] attributeNames = ddBean.getRoot().getAttributeNames();
  +        for (int i = 0; i < attributeNames.length; i++) {
  +            String attributeName = attributeNames[i];
  +            if (attributeName.startsWith("xmlns")) {
  +                if 
(ddBean.getRoot().getAttributeValue(attributeName).equals(uri)) {
  +                    if (attributeName.equals("xmlns")) {
  +                        return getXPathsWithPrefix(null , xpathSegments);
  +                    }
  +                    return getXPathsWithPrefix(attributeName.substring(6), 
xpathSegments);
  +                }
  +            }
  +        }
  +        //??? malformed document, apparently
  +        throw new IllegalStateException("namespace " + uri + " not declared 
in source document");
  +    }
  +
  +    protected String[] getXPathsForJ2ee_1_4(String[][] xpathSegments) {
  +        return getXPathsFromNamespace("http://java.sun.com/xml/ns/j2ee";, 
xpathSegments);
       }
   }
  
  
  
  1.3       +3 -3      
incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/tools/DDBeanRootImpl.java
  
  Index: DDBeanRootImpl.java
  ===================================================================
  RCS file: 
/home/cvs/incubator-geronimo/modules/deployment/src/java/org/apache/geronimo/deployment/tools/DDBeanRootImpl.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DDBeanRootImpl.java       11 Feb 2004 08:02:21 -0000      1.2
  +++ DDBeanRootImpl.java       20 Feb 2004 08:11:39 -0000      1.3
  @@ -143,11 +143,11 @@
       }
   
       public String[] getAttributeNames() {
  -        return null;
  +        return docBean.getAttributeNames();
       }
   
       public String getAttributeValue(String attrName) {
  -        return null;
  +        return docBean.getAttributeValue(attrName);
       }
   
       public DDBean[] getChildBean(String xpath) {
  
  
  
  1.3       +1 -2      
incubator-geronimo/modules/deployment/src/test/org/apache/geronimo/deployment/tools/DDBeanRootTest.java
  
  Index: DDBeanRootTest.java
  ===================================================================
  RCS file: 
/home/cvs/incubator-geronimo/modules/deployment/src/test/org/apache/geronimo/deployment/tools/DDBeanRootTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DDBeanRootTest.java       11 Feb 2004 08:02:21 -0000      1.2
  +++ DDBeanRootTest.java       20 Feb 2004 08:11:39 -0000      1.3
  @@ -85,7 +85,6 @@
           assertEquals(deployable, root.getDeployableObject());
           assertEquals(ModuleType.CAR, root.getType());
           assertEquals("/", root.getXpath());
  -        assertNull(root.getAttributeNames());
           assertNull(root.getText("foo"));
           assertTrue(Arrays.equals(new String[] {"Test DD for app-client1"}, 
root.getText("application-client/description")));
           assertTrue(Arrays.equals(new String[] {"http://localhost"}, 
root.getText("application-client/env-entry/env-entry-value")));
  
  
  

Reply via email to