1 22 package org.jboss.system.metadata; 23 24 import java.io.StringReader ; 25 26 import org.jboss.system.ServiceConfigurator; 27 import org.jboss.xb.binding.Unmarshaller; 28 import org.jboss.xb.binding.UnmarshallerFactory; 29 import org.jboss.xb.binding.sunday.unmarshalling.SchemaBindingResolver; 30 import org.jboss.xb.binding.sunday.unmarshalling.SingletonSchemaResolverFactory; 31 import org.w3c.dom.Element ; 32 33 46 public class ServiceJBXBValueMetaData extends ServiceElementValueMetaData 47 { 48 51 public ServiceJBXBValueMetaData() 52 { 53 super(); 54 } 55 56 61 public ServiceJBXBValueMetaData(Element element) 62 { 63 super(element); 64 } 65 66 public Object getValue(ServiceValueContext valueContext) throws Exception 67 { 68 StringBuffer buffer = ServiceConfigurator.getElementContent(getElement()); 70 71 Thread current = Thread.currentThread(); 72 ClassLoader oldTcl = current.getContextClassLoader(); 73 ClassLoader cl = valueContext.getClassloader(); 74 if (cl != null) 75 current.setContextClassLoader(cl); 76 try 77 { 78 SchemaBindingResolver resolver = SingletonSchemaResolverFactory.getInstance().getSchemaBindingResolver(); 80 Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller(); 81 StringReader reader = new StringReader (buffer.toString()); 82 Object bean = unmarshaller.unmarshal(reader, resolver); 83 return bean; 84 } 85 finally 86 { 87 if (cl != null) 88 current.setContextClassLoader(oldTcl); 89 } 90 } 91 } 92 | Popular Tags |