1 22 package org.jboss.system.metadata; 23 24 import java.beans.PropertyEditor ; 25 import java.beans.PropertyEditorManager ; 26 27 import org.jboss.logging.Logger; 28 import org.jboss.util.StringPropertyReplacer; 29 import org.w3c.dom.Element ; 30 31 44 public class ServiceElementValueMetaData extends AbstractMetaDataVisitorNode implements ServiceValueMetaData 45 { 46 47 private static final Logger log = Logger.getLogger(ServiceElementValueMetaData.class); 48 49 50 private Element element; 51 52 55 public ServiceElementValueMetaData() 56 { 57 } 58 59 64 public ServiceElementValueMetaData(Element element) 65 { 66 setElement(element); 67 } 68 69 74 public Element getElement() 75 { 76 return element; 77 } 78 79 84 public void setElement(Element element) 85 { 86 if (element == null) 87 throw new IllegalArgumentException ("Null element"); 88 this.element = element; 89 } 90 91 public Object getValue(ServiceValueContext valueContext) throws Exception 92 { 93 if (valueContext.isReplace()) 95 { 96 PropertyEditor editor = PropertyEditorManager.findEditor(Element .class); 97 if (editor == null) 98 log.warn("Cannot perform property replace on Element"); 99 else 100 { 101 editor.setValue(element); 102 String text = editor.getAsText(); 103 text = StringPropertyReplacer.replaceProperties(text); 104 editor.setAsText(text); 105 return editor.getValue(); 106 } 107 } 108 109 return element; 110 } 111 } 112 | Popular Tags |