public class JavaXMLBeansObjectResolver extends AbstractObjectResolver
XMLDecoder
.
Example: The following code should return a DataSource
Object:
Settings4j.getObject("com/myCompany/myApp/MyDatasource");
In normal Cases the DataSource comes from the JNDI-Context (available in most Servlet Containers).
But in some environments there are no JNDI-Context (Commandline-Clients, UnitTests).
With Settings4j (default configuration) you can also place two Files into your Classpath:
"com/myCompany/myApp/MyDatasource"
: The File which defines the DataSource
"com/myCompany/myApp/MyDatasource.properties"
: Some Properties,
like which ObjectResolver should be use.
The File Content whould be the following:
Classpath File "com/myCompany/myApp/MyDatasource.properties":objectResolverKey=org.settings4j.objectresolver.JavaXMLBeansObjectResolver cached=true
Classpath File "com/myCompany/myApp/MyDatasource":<?xml version="1.0" encoding="UTF-8"?> <java version="1.6.0_05" class="java.beans.XMLDecoder"> <object class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <void property="driverClassName"> <string>org.hsqldb.jdbcDriver</string> </void> <void property="password"> <string></string> </void> <void property="url"> <string>jdbc:hsqldb:mem:test</string> </void> <void property="username"> <string>sa</string> </void> </object> </java>
PROP_CACHED, PROP_OBJECT_RESOLVER_KEY
Constructor and Description |
---|
JavaXMLBeansObjectResolver() |
Modifier and Type | Method and Description |
---|---|
protected Object |
contentToObject(String key,
Properties properties,
byte[] content,
ContentResolver contentResolver)
Method to convert the given content-File to an Object must be implemented by SubClasses.
|
addObjectResolver, getObject, getObjectProperties, getObjectResolverKey, getPropertySuffix, isCached, setCached, setPropertySuffix
protected Object contentToObject(String key, Properties properties, byte[] content, ContentResolver contentResolver)
contentToObject
in class AbstractObjectResolver
key
- The Original Key of the Objectproperties
- The Property-File which where Found under key + ".properties"content
- The byte[] Content to convert.contentResolver
- the contentResolver to get possible additional content Files.Copyright © 2008–2014. All rights reserved.