From: Adrian B. <ej...@us...> - 2004-03-08 15:43:02
|
User: ejort Date: 04/03/08 07:18:41 Modified: src/main/org/jboss/system Tag: Branch_3_2 ServiceConfigurator.java Log: Add support for system properties in more locations inside -service.xml Revision Changes Path No revision No revision 1.16.2.11 +23 -19 jboss-system/src/main/org/jboss/system/ServiceConfigurator.java Index: ServiceConfigurator.java =================================================================== RCS file: /cvsroot/jboss/jboss-system/src/main/org/jboss/system/ServiceConfigurator.java,v retrieving revision 1.16.2.10 retrieving revision 1.16.2.11 diff -u -r1.16.2.10 -r1.16.2.11 --- ServiceConfigurator.java 3 Jan 2004 13:48:23 -0000 1.16.2.10 +++ ServiceConfigurator.java 8 Mar 2004 15:18:40 -0000 1.16.2.11 @@ -45,7 +45,7 @@ /** * Service configuration helper. * - * @version <tt>$Revision: 1.16.2.10 $</tt> + * @version <tt>$Revision: 1.16.2.11 $</tt> * @author <a href="mailto:ma...@jb...">Marc Fleury</a> * @author <a href="mailto:hi...@jb...">Hiram Chirino</a> * @author <a href="mailto:d_j...@us...">David Jencks</a> @@ -97,7 +97,7 @@ { if (config.getTagName().equals("mbean")) { - internalInstall(config, mbeans, loaderName); + internalInstall(config, mbeans, loaderName, true); } else { @@ -111,7 +111,7 @@ if (element.getTagName().equals("mbean")) { Element mbean = (Element)nl.item(i); - internalInstall(mbean, mbeans, loaderName); + internalInstall(mbean, mbeans, loaderName, true); } // end of if () } // end of if () }//end of for @@ -141,10 +141,10 @@ } private ObjectName internalInstall(Element mbeanElement, List mbeans, - ObjectName loaderName) throws Exception + ObjectName loaderName, boolean replace) throws Exception { ObjectInstance instance = null; - ObjectName mbeanName = parseObjectName(mbeanElement); + ObjectName mbeanName = parseObjectName(mbeanElement, replace); instance = serviceCreator.install(mbeanName, loaderName, mbeanElement); @@ -232,11 +232,12 @@ Element element = (Element)attrs.item(j); + boolean replace = true; + // Set attributes if (element.getTagName().equals("attribute")) { String attributeName = element.getAttribute("name"); - boolean replace = true; boolean trim = true; String replaceAttr = element.getAttribute("replace"); if( replaceAttr.length() > 0 ) @@ -250,7 +251,7 @@ if (element.hasChildNodes()) { // Get the attribute value - String attributeText = getElementContent(element, trim); + String attributeText = getElementContent(element, trim, replace); for (int k = 0; k < attributes.length; k++) { @@ -306,8 +307,6 @@ "; type=" + typeClass); } - if( replace == true ) - attributeText = Strings.replaceProperties(attributeText); editor.setAsText(attributeText); value = editor.getValue(); } @@ -332,16 +331,18 @@ String mbeanRefName = element.getAttribute("optional-attribute-name"); if ("".equals(mbeanRefName)) - { mbeanRefName = null; - } // end of if () + else if (replace) + mbeanRefName = Strings.replaceProperties(mbeanRefName); String proxyType = element.getAttribute("proxy-type"); if ("".equals(proxyType)) proxyType = null; + else if (replace) + proxyType = Strings.replaceProperties(proxyType); // Get the mbeanRef value - ObjectName dependsObjectName = processDependency(objectName, loaderName, element, mbeans); + ObjectName dependsObjectName = processDependency(objectName, loaderName, element, mbeans, replace); if (debug) log.debug("considering " + ((mbeanRefName == null)? "<anonymous>": mbeanRefName.toString()) + " with object name " + dependsObjectName); @@ -401,7 +402,7 @@ } // end of if () // Get the depends value - ObjectName dependsObjectName = processDependency(objectName, loaderName, dependsElement, mbeans); + ObjectName dependsObjectName = processDependency(objectName, loaderName, dependsElement, mbeans, replace); if (!dependsListNames.contains(dependsObjectName)) { dependsListNames.add(dependsObjectName); @@ -438,7 +439,7 @@ } private ObjectName processDependency(ObjectName container, ObjectName loaderName, - Element element, List mbeans) + Element element, List mbeans, boolean replace) throws Exception { ObjectName dependsObjectName = null; @@ -451,7 +452,7 @@ Element child = (Element)childNode; if (child.getTagName().equals("mbean")) { - dependsObjectName = internalInstall(child, mbeans, loaderName); + dependsObjectName = internalInstall(child, mbeans, loaderName, replace); break; } else @@ -463,7 +464,7 @@ if (dependsObjectName == null) { - String name = getElementContent(element, true); + String name = getElementContent(element, true, replace); dependsObjectName = ObjectNameFactory.create(name); } if (dependsObjectName == null) @@ -602,7 +603,7 @@ * (thrown if 'name' is null or ""). * @throws MalformedObjectNameException */ - private ObjectName parseObjectName(final Element element) + private ObjectName parseObjectName(final Element element, boolean replace) throws Exception { String name = element.getAttribute("name"); @@ -611,11 +612,12 @@ { throw new DeploymentException("MBean attribute 'name' must be given."); } - + if (replace) + name = Strings.replaceProperties(name); return new ObjectName(name); } - private String getElementContent(Element element, boolean trim) + private String getElementContent(Element element, boolean trim, boolean replace) throws Exception { NodeList nl = element.getChildNodes(); @@ -630,6 +632,8 @@ } // end of for () if( trim ) attributeText = attributeText.trim(); + if (replace) + attributeText = Strings.replaceProperties(attributeText); return attributeText; } |