* @throws CmpCompilerException if any other error occurs while generating concrete impls
*/
void compile() throws CmpCompilerException, GeneratorException {
// deployment descriptor object representation for the archive
Application application = null;
// deployment descriptor object representation for each module
EjbBundleDescriptor bundle = null;
// ejb name
String beanName = null;
// GeneratorException message if any
StringBuffer generatorExceptionMsg = null;
try {
// scratchpad variable
long time;
// stubs dir for the current deployment
File stubsDir = this._ejbcCtx.getStubsDir();
application = this._ejbcCtx.getDescriptor();
_logger.log(Level.FINE, "ejbc.processing_cmp",
application.getRegistrationName());
Vector cmpFiles = new Vector();
final ClassLoader jcl = application.getClassLoader();
// For each Bundle descriptor generate concrete class.
Iterator bundleItr =
application.getEjbBundleDescriptors().iterator();
while ( bundleItr.hasNext() ) {
bundle = (EjbBundleDescriptor)bundleItr.next();
if (!bundle.containsCMPEntity()) {
continue;
}
// If it is a stand alone module then the srcDir is
// the ModuleDirectory
String archiveUri = (!application.isVirtual()) ?
DeploymentUtils.getEmbeddedModulePath(
this._ejbcCtx.getSrcDir().getCanonicalPath(),
bundle.getModuleDescriptor().getArchiveUri()):
this._ejbcCtx.getSrcDir().getCanonicalPath();
if (com.sun.enterprise.util.logging.Debug.enabled) {
_logger.log(Level.FINE,"[CMPC] Module Dir name is "
+ archiveUri);
}
String generatedXmlsPath = (!application.isVirtual()) ?
DeploymentUtils.getEmbeddedModulePath(
this._ejbcCtx.getDeploymentRequest().
getGeneratedXMLDirectory().getCanonicalPath(),
bundle.getModuleDescriptor().getArchiveUri()):
this._ejbcCtx.getDeploymentRequest().
getGeneratedXMLDirectory().getCanonicalPath();
if (com.sun.enterprise.util.logging.Debug.enabled) {
_logger.log(Level.FINE,"[CMPC] Generated XML Dir name is "
+ generatedXmlsPath);
}
IASPersistenceManagerDescriptor pmDesc =
bundle.getPreferredPersistenceManager();
String generatorName = null;
if (null == pmDesc) {
generatorName = IASPersistenceManagerDescriptor.PM_CLASS_GENERATOR_DEFAULT;
} else {
generatorName = pmDesc.getPersistenceManagerClassGenerator();
// Backward compatability:
// Support existing settings that have the old name.
if (generatorName.equals(
IASPersistenceManagerDescriptor.PM_CLASS_GENERATOR_DEFAULT_OLD)) {
generatorName = IASPersistenceManagerDescriptor.PM_CLASS_GENERATOR_DEFAULT;
}
}
CMPGenerator gen = null;
try {
Class generator = getClass().getClassLoader().loadClass(generatorName);
gen = (CMPGenerator)generator.newInstance();
} catch (Throwable e) {
String msg = localStrings.getString("cmpc.cmp_generator_class_error",
application.getRegistrationName(),
bundle.getModuleDescriptor().getArchiveUri());
_logger.log(Level.SEVERE, msg, e);
generatorExceptionMsg = addGeneratorExceptionMessage(msg,
generatorExceptionMsg);
continue;
}
try {
time = now();
gen.init(bundle, _ejbcCtx, archiveUri, generatedXmlsPath);
this._ejbcCtx.getTiming().cmpGeneratorTime += (now() - time);
Iterator ejbs=bundle.getEjbs().iterator();
while ( ejbs.hasNext() ) {
EjbDescriptor desc = (EjbDescriptor) ejbs.next();
beanName = desc.getName();
if (com.sun.enterprise.util.logging.Debug.enabled) {
_logger.log(Level.FINE,"[CMPC] Ejb Class Name: "
+ desc.getEjbClassName());
}
if ( desc instanceof IASEjbCMPEntityDescriptor ) {
// generate concrete CMP class implementation
IASEjbCMPEntityDescriptor entd =
(IASEjbCMPEntityDescriptor)desc;
if (com.sun.enterprise.util.logging.Debug.enabled) {
_logger.log(Level.FINE,
"[CMPC] Home Object Impl name is "
+ entd.getLocalHomeImplClassName());
}
// generate persistent class
entd.setClassLoader(jcl);
try {
time = now();
gen.generate(entd, stubsDir, stubsDir);
this._ejbcCtx.getTiming().cmpGeneratorTime +=
(now() - time);
} catch (GeneratorException e) {
String msg = e.getMessage();
_logger.log(Level.WARNING, msg);
generatorExceptionMsg = addGeneratorExceptionMessage(
msg, generatorExceptionMsg);
}
/* WARNING: IASRI 4683195
* JDO Code failed when there was a relationship involved
* because it depends upon the orginal ejbclasname and hence
* this code is shifted to just before the Remote Impl is
* generated.Remote/Home Impl generation depends upon this
* value
*/
} else if (desc instanceof EjbCMPEntityDescriptor ) {
//RI code here
}
} // end while ejbs.hasNext()
beanName = null;
time = now();
Collection col = gen.cleanup();
this._ejbcCtx.getTiming().cmpGeneratorTime += (now() - time);
for (Iterator fileIter=col.iterator();fileIter.hasNext();) {
File file=(File)fileIter.next();
String fileName=file.getPath();
_logger.log(Level.FINE,"[CMPC] File name is "+fileName);
cmpFiles.addElement(fileName);
}
} catch (GeneratorException e) {
String msg = e.getMessage();
_logger.log(Level.WARNING, msg);
generatorExceptionMsg = addGeneratorExceptionMessage(msg,
generatorExceptionMsg);
}
} // end of bundle
bundle = null;
if (generatorExceptionMsg == null) {
// class path for javac
String classPath =
getClassPath(this._ejbcCtx.getClasspathUrls(), stubsDir);
time = now();
IASEJBC.compileClasses(classPath, cmpFiles, stubsDir,
stubsDir.getCanonicalPath(),
this._ejbcCtx.getJavacOptions());
this._ejbcCtx.getTiming().javaCompileTime += (now() - time);
_logger.log(Level.FINE, "ejbc.done_processing_cmp",
application.getRegistrationName());
}
} catch (GeneratorException e) {
_logger.log(Level.WARNING, e.getMessage());
throw e;
} catch (Throwable e) {
String eType = e.getClass().getName();
String appName = application.getRegistrationName();
String exMsg = e.getMessage();
String msg = null;
if (bundle == null) {
// Application or compilation error