*/
public synchronized PClassMapping getPClassMapping(String className,
ClassLoader classLoader)
throws PException {
boolean debug = logger.isLoggable(BasicLevel.DEBUG);
HomeItf pcm = (HomeItf) cn2pcm.get(className);
if (pcm != null) {
if (debug)
logger.log(BasicLevel.DEBUG, "PClassMapping for class " + className
+ " is being configured:" + pcm);
return pcm;
}
pcm = (HomeItf) mapper.lookup(className);
if (pcm != null) {
if (debug)
logger.log(BasicLevel.DEBUG, "PClassMapping for class " + className
+ " already exist:" + pcm);
return pcm;
}
// Creates the PClassMapping, its PBinder and the PNC
if (debug) {
logger.log(BasicLevel.DEBUG,
"Looking for the PClassMapping of the class " + className);
}
String pcmcn = NamingRules.fqMappingName(className);
try {
pcm = (HomeItf) classLoader.loadClass(pcmcn).newInstance();
} catch (Exception e) {
throw new PException(e,
"Impossible to instanciate the PClassMapping of the class "
+ className + ": " + pcmcn);
}
pcm.setTransactionalPersistenceManager(tpm);
pcm.setPOManagerFactory(pmf);
Properties classProperties = pcm.getClassProperties();
if (debug) {
logger.log(BasicLevel.DEBUG, "Jorm config:" + classProperties);
}
//Load the Jorm Meta information
loadJormSpeedoMI(className, classProperties, classLoader);
// Fetch the Binder
PBinder binder = findPBinder(className, classLoader,
classProperties.getProperty(JormPathHelper.getPath(className)));
pcm.setPBinder(binder);
binder.setPClassMapping(pcm);
// Fetch the PNC of the class
PNameCoder classPnc = findPNameManager(
className, classLoader, pcm, classProperties.getProperty(JormPathHelper.getPath(className))
);
((PClassMappingCtrl) pcm).setClassPNameCoder(classPnc);
//Configure references (PNameCoder and GenClassMappping)
RefConfig refConfig = new RefConfig(classProperties, classLoader);
cn2pcm.put(className, pcm);//register the pcm in order to avoid double configuration
pcm.configureRefFields(refConfig);
cn2pcm.remove(className);
if (debug) {
logger.log(BasicLevel.DEBUG, "PClassMapping/PBinder/PNC created for the class " + className);
logger.log(BasicLevel.DEBUG, "- pcm: " + pcm);
logger.log(BasicLevel.DEBUG, "- binder: " + binder);
logger.log(BasicLevel.DEBUG, "-pnc: " + classPnc);
}
// Maps the class
mapper.map(null, pcm);
pcm.configureRefFields(new GCMHomeConfig(pcm));
cpm.applyProperties(pcm);
logger.log(BasicLevel.DEBUG, "Class " + className + " mapped");
//Manage the cluster of classes
PMapCluster cluster = mapper.getPMappingStructuresManager().getPMapCluster(className);
if (cluster.isDefined()) { //cluster is full (all classes are mapped)