Create and return a new MemoryUserDatabase
instance
that has been configured according to the properties of the
specified Reference
. If you instance can be created,
return null
instead.
// We only know how to deal with <code>javax.naming.Reference</code>s
// that specify a class name of "org.apache.catalina.UserDatabase"
if ((obj == null) || !(obj instanceof Reference)) {
return (null);
}
Reference ref = (Reference) obj;
if (!"org.apache.catalina.UserDatabase".equals(ref.getClassName())) {
return (null);
}
// Create and configure a MemoryUserDatabase instance based on the
// RefAddr values associated with this Reference
MemoryUserDatabase database = new MemoryUserDatabase(name.toString());
RefAddr ra = null;
ra = ref.get("pathname");
if (ra != null) {
database.setPathname(ra.getContent().toString());
}
// Return the configured database instance
database.open();
database.save();
return (database);