[jboss-dev-forums] [Design of JBossXB] - Re: Marshalling Into java.util.properties

adrian@jboss.org do-not-reply at jboss.com
Fri Oct 13 08:36:20 EDT 2006


The code to do this is really trivial

org.jboss.system.metadata.ServiceJBXBValueMetaData


  |       // Get the attribute element content in a parsable form
  |       StringBuffer buffer = ServiceConfigurator.getElementContent(getElement());
  | 
  |       Thread current = Thread.currentThread();
  |       ClassLoader oldTcl = current.getContextClassLoader();
  |       ClassLoader cl = valueContext.getClassloader();
  |       if (cl != null)
  |          current.setContextClassLoader(cl);
  |       try
  |       {
  |          // Parse the attribute element content
  |          SchemaBindingResolver resolver = SingletonSchemaResolverFactory.getInstance().getSchemaBindingResolver();
  |          Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
  |          StringReader reader = new StringReader(buffer.toString());
  |          Object bean = unmarshaller.unmarshal(reader, resolver);
  |          return bean;
  |       }
  |       finally
  |       {
  |          if (cl != null)
  |             current.setContextClassLoader(oldTcl);
  |       }
  | 

In fact, it is really redundant since this code is executed automatically
if you have the namespace registered properly with the schema binding
resolver and you are using the schema unmarshaller
(which is not currently the case for the -service.xml)

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3978130#3978130

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3978130



More information about the jboss-dev-forums mailing list