org.kasource.spring.jaxb
Class JaxbObjectFactory
java.lang.Object
org.kasource.spring.jaxb.JaxbObjectFactory
public class JaxbObjectFactory
- extends Object
Create object by unmarshalling a XML Resource using JAXB.
This class can be used directly in spring XML configuration like:
The factory can also be use directly in code like:
ApplicationContext ctx; // initialized elsewhere
JaxbObjectFactory factory = new JaxbObjectFactory();
org.my.app.conf.AppConfig config = (AppConfig) factory.unmarshalObject(ctx.getResource("file:/some/resource/path/myConfig.xml), org.my.app.conf.AppConfig.class.getPackage().getName());
- Author:
- rikardwi
|
Method Summary |
Object |
unmarshalObject(org.springframework.core.io.Resource resource,
String packageName)
Unmarshall the object using JAXB from input resource and return it as an Object. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
JaxbObjectFactory
public JaxbObjectFactory()
unmarshalObject
public Object unmarshalObject(org.springframework.core.io.Resource resource,
String packageName)
throws IOException,
JAXBException
- Unmarshall the object using JAXB from input resource and return it as an Object.
- Parameters:
resource - Resource of XML Content to unmarshall.packageName - Java Package name of JAXB classes representing the resource content.
- Returns:
- The Unmarshalled object.
- Throws:
IOException - If resource does not have a readable InputStream.
JAXBException - If the resources could not be unmarshalled using classes from packageName.
Copyright © 2011. All Rights Reserved.