[jboss-dev-forums] [Design of POJO Server] - Re: JAXB Deployer

alesj do-not-reply at jboss.com
Wed Mar 18 17:17:29 EDT 2009


"anil.saldhana at jboss.com" wrote : Since you do unmarshalling in the parse method of
  | http://anonsvn.jboss.org/repos/jbossas/projects/jboss-deployers/tags/2.0.5.GA/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/deployer/JAXBDeployer.java
  | 
  | a schema validation may be added. 
  | 
Like this?

  |    protected T parse(VFSDeploymentUnit unit, VirtualFile file, T root) throws Exception
  |    {
  |       if (file == null)
  |          throw new IllegalArgumentException("Null file");
  | 
  |       log.debug("Parsing: " + file.getName());
  | 
  |       InputSource source = new VFSInputSource(file);
  |       Unmarshaller unmarshaller = context.createUnmarshaller();
  |       if (schemaLocation != null)
  |       {
  |          unmarshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");
  |          ClassLoader tcl = SecurityActions.getContextClassLoader();
  |          URL schemaURL = tcl.getResource(schemaLocation);
  |          if(schemaURL == null)
  |             throw new IllegalStateException("Schema URL is null:" + schemaLocation);
  |          
  |          SchemaFactory scFact = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
  |          Schema schema = scFact.newSchema(schemaURL);
  |          unmarshaller.setSchema(schema);          
  |       }
  |       Object result = unmarshaller.unmarshal(source);
  |       return getOutput().cast(result);
  |    }
  | 

"anil.saldhana at jboss.com" wrote : 
  | I do not understand the meaning of openStreamAndValidate call being made in the parse into
  | http://anonsvn.jboss.org/repos/jbossas/projects/jboss-deployers/tags/2.0.5.GA/deployers-vfs-spi/src/main/java/org/jboss/deployers/vfs/spi/deployer/AbstractVFSParsingDeployer.java
  | 
  | You are opening a stream. There is no validation. :)
This is now replaced with VFSInputSource.

Validation in this case was meant for "inputStream != null". ;-)

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

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



More information about the jboss-dev-forums mailing list