Castor JDO support.
| Method from org.jboss.jdo.castor.CastorJDOImpl Detail: |
public void creating(Class objClass,
Object identity) {
if (log.isDebugEnabled())
log.debug( "Creating " + objClass.getName() + " (" + identity + ")" );
}
|
public void creating(Object objClass,
Object identity) {
if (log.isDebugEnabled())
log.debug( "Creating " + objClass + " (" + identity + ")" );
}
|
public void exception(Exception except) {
log.error("Exception", except);
}
|
public URL findResourceInJar(String name) {
URL url = null;
try
{
url = getClass().getClassLoader().getResource( name );
}
catch ( Exception e )
{
log.error( "Could not find resource: " + name, e );
}
return url;
}
Copied from Jetty.java. Used to find resource within .sar. |
public boolean getCommonClassPath() {
return _commonClassPath;
}
|
public String getConfiguration() {
return _dbConf;
}
|
public String getConfigurationURL() {
return _dbUrl;
}
|
public Database getDatabase() throws DatabaseNotFoundException, PersistenceException {
Method m;
if (_commonClassPath) {
_jdo.setClassLoader(null);
} else {
_jdo.setClassLoader(Thread.currentThread().getContextClassLoader());
}
return _jdo.getDatabase();
}
|
public String getDescription() {
return _jdo.getDescription();
}
|
public String getJndiName() {
return _jndiName;
}
|
public int getLockTimeout() {
return _jdo.getLockTimeout();
}
|
public boolean getLoggingEnabled() {
return (_jdo.getLogInterceptor() != null);
}
|
public Object getObjectInstance(Object obj,
Name name,
Context nameCtx,
Hashtable environment) throws Exception {
return _instances.get(name.toString());
}
|
protected ObjectName getObjectName(MBeanServer server,
ObjectName name) throws MalformedObjectNameException {
if (name == null) {
return new ObjectName(OBJECT_NAME+",name="+_jndiName);
}
return name;
}
|
public PrintWriter getPrintWriter() {
if (writer == null)
{
writer = new LoggerPluginWriter(log.getLoggerPlugin ());
}
return writer;
}
|
public Reference getReference() {
return new Reference(getClass().getName(), getClass().getName(), null);
}
|
public boolean isAutoStore() {
return _autoStore;
}
|
public boolean isDatabasePooling() {
return _dbPooling;
}
Return true if the Database instance uses the application server pooling. |
public void loading(Class objClass,
Object identity) {
if (log.isDebugEnabled())
log.debug( "Loading " + objClass.getName() + " (" + identity + ")" );
}
|
public void loading(Object objClass,
Object identity) {
if (log.isDebugEnabled())
log.debug( "Loading " + objClass + " (" + identity + ")" );
}
|
public void message(String message) {
log.debug(message);
}
|
public void queryStatement(String statement) {
log.debug(statement);
}
|
public void removing(Class objClass,
Object identity) {
if (log.isDebugEnabled())
log.debug( "Removing " + objClass.getName() + " (" + identity + ")" );
}
|
public void removing(Object objClass,
Object identity) {
if (log.isDebugEnabled())
log.debug( "Removing " + objClass + " (" + identity + ")" );
}
|
public void setAutoStore(boolean autoStore) {
_autoStore = autoStore;
}
|
public void setCommonClassPath(boolean commonClassPath) {
_commonClassPath = commonClassPath;
}
|
public void setConfiguration(String dbConf) {
_dbConf = dbConf;
}
|
public void setDatabasePooling(boolean dbPooling) {
_dbPooling = dbPooling;
}
True if user prefers to use application server database pools.
False if user wants a new connection for each call to getDatabase(). |
public void setDescription(String description) {
_jdo.setDescription(description);
}
|
public void setJndiName(String jndiName) {
_jndiName = jndiName;
}
|
public void setLockTimeout(int lockTimeout) {
_jdo.setLockTimeout(lockTimeout);
}
|
public void setLoggingEnabled(boolean loggingEnabled) {
_jdo.setLogInterceptor(loggingEnabled ? this : null);
}
|
protected void startService() throws Exception {
org.exolab.castor.jdo.conf.Database database;
Unmarshaller unm;
int pos;
Method m;
boolean debug = log.isDebugEnabled();
// Bind in JNDI
bind(new InitialContext(), "java:/" + _jndiName, this);
// Determine complete URL to _dbConf file. It is likely a relative path.
URL confUrl = Thread.currentThread().getContextClassLoader().getResource( _dbConf );
if ( null == confUrl )
{
FileNotFoundException e = new FileNotFoundException(
"CastorJDOImpl.startService(): Unable to resolve Configuration attribute to URL = "
+ _dbConf );
log.error( "CastorJDOImpl.startService(): Unable to find " + _dbConf + " file.", e );
}
_dbUrl = confUrl.toString();
_jdo.setTransactionManager("java:/TransactionManager");
_jdo.setConfiguration( _dbUrl );
unm = new Unmarshaller(org.exolab.castor.jdo.conf.Database.class);
database = (org.exolab.castor.jdo.conf.Database) unm.unmarshal(new InputSource( _dbUrl ));
_jdo.setDatabaseName(database.getName());
if (database.getJndi() != null) {
_dataSourceName = database.getJndi().getName();
}
// Older Castor versions older don't have these methods,
// we'll use reflection for backward compatibility
//_jdo.setAutoStore(_autoStore);
//_jdo.setDatabasePooling(_dbpooling);
try {
// 0.9.4
m = _jdo.getClass().getMethod("setAutoStore",
new Class[] {boolean.class});
m.invoke(_jdo, new Object[] {new Boolean(_autoStore)});
} catch (Exception ex) {
if (debug)
log.debug("couldn't invoke setAutoStore()");
}
try {
// 0.9.3
m = _jdo.getClass().getMethod("setDatabasePooling",
new Class[] {boolean.class});
m.invoke(_jdo, new Object[] {new Boolean(_dbPooling)});
} catch (Exception ex) {
if (debug)
log.debug("couldn't invoke setDatabasePooling()");
}
_instances.put(_jndiName, this);
if (debug)
log.debug("DataObjects factory for " + _dataSourceName + " bound to " + _jndiName);
}
|
protected void stopService() throws Exception {
// Unbind from JNDI
InitialContext ctx = new InitialContext();
try {
ctx.unbind("java:/" + _jndiName);
}
finally {
ctx.close();
}
}
|
public void storeStatement(String statement) {
log.debug(statement);
}
|
public void storing(Class objClass,
Object identity) {
if (log.isDebugEnabled())
log.debug( "Storing " + objClass.getName() + " (" + identity + ")" );
}
|
public void storing(Object objClass,
Object identity) {
if (log.isDebugEnabled())
log.debug( "Storing " + objClass + " (" + identity + ")" );
}
|