*/
public Persistent create(String name) throws PersistenceException
{
if (! isConfigured())
{
throw new PersistenceException("Factory not configured!");
}
DefaultPersistent newPersistent = null;
if (name.indexOf(".") < 0)
{
throw new PersistenceException("Name of Persistent must be of the form 'schema.name'" + ":'" + name + "'");
}
try
{
PersistentMetaData pmd = getMetaData(name);
/**
* If this persistent is not instantiated using a custom class...
*/
if (pmd.getClassName() == null)
{
if (pmd.isRowSecurable())
{
newPersistent = new RowSecurablePersistent();
}
else
{
newPersistent = new DefaultPersistent();
}
/* We pass our persistent's the same log as the factory... */
newPersistent.setLogger(log);
/* And a reference back to their factory, so they can */
/* access getService, etc */
newPersistent.setFactory(this);
newPersistent.setMetaData(pmd);
newPersistent.setAuthorizationManager(pmd.getAuthManager());
/* If auth manager bypass is allowed at all for this persistent, */
/* hand it the default bypass manager */
if (pmd.isAuthManagerBypassAllowed())
{
newPersistent.setBypassAuthorizationManager(getByPassAuthManager());
}
return newPersistent;
}
else
{
Class c = Class.forName(pmd.getClassName());
Object o = c.newInstance();
/* If the class we instantiated extends Persistent... */
if (o instanceof Persistent)
{
Persistent p = (Persistent) c.newInstance();
p.setMetaData(pmd);
return p;
}
else
{
/* If it does not, then "wrap" it in a persistent */
DefaultPersistent np = null;
if (pmd.isRowSecurable())
{
np = new RowSecurablePersistent();
}
else
{
np = new DefaultPersistent();
}
/* We pass our persistent's the same log as the factory... */
np.setLogger(log);
/* And a reference back to their factory, so they can */
/* access getService, etc */
np.setFactory(this);
np.setMetaData(pmd);
np.setAuthorizationManager(pmd.getAuthManager());
/* If auth manager bypass is allowed at all for this persistent, */
/* hand it the default bypass manager */
if (pmd.isAuthManagerBypassAllowed())
{
np.setBypassAuthorizationManager(getByPassAuthManager());
}
np.setBean(o);
return np;
}
}
}
catch (Exception ce)
{
throw new PersistenceException(ce);
}
}