EJBCompilerpublic class EJBCompiler extends Object This class is responsible mainly for executing ejbc.
It also does the following:
- constructs the class loader for the deployed app
- loads the deployment descriptors
- calls ejbc
- sets the unique id
- writes the deployment descriptors
classpath: Ejbc reads the target instance's classpath-prefix and
classpath-suffix via config context. It creates a class loader
hierarchy based on these class paths, common class loader urls
($INSTANCE/lib/classes:$INSTANCE/lib/*.jar:$INSTANCE/lib/*.zip)
and the application's urls.
BootStrap<-System<-Common<-Share<-Ejb<-Servlet<-Jasper [Admin Server]
|
|<-(classpath-prefix+classpath-suffix)<-Common<-Shared<-Ejb [EJBC]
Note that System classpath is shared between the two hierarchy.
According to the architect, end users are not expected to replace the
Application Server's jar (for example, appserv-rt.jar, etc). So, it is
sufficient to include the classpath-prefix and classpath-suffix in the
ejbc class loader hierarchy. Any system level jar should be replaced
accross all server instances.
S1AS8 Change:
Deployment no longer needs to pick up class paths from target
server instance. Deployment class paths contains only the DAS's
class path plus the whole application paths.
rmic-options: Ejbc reads rmic options from server xml. If none found, it
gets the default from DTD.
javac-options: Ejbc reads javac options from server xml. It supports
the "-g" and "-O" options.
|
Fields Summary |
---|
private String | name | private com.sun.enterprise.instance.ModulesManager | moduleManager | private com.sun.enterprise.instance.AppsManager | appManager | private DeploymentRequest | request | private EjbcContextImpl | ejbcContext | private List | classpathForCompilationAdded to support fix for 4980750 so WebModuleDeployer can specify an altered classpath for use during compilation. | private static final Logger | _logger | private static com.sun.enterprise.util.i18n.StringManager | localStrings |
Constructors Summary |
---|
public EJBCompiler(String name, File srcDir, File stubsDir, com.sun.enterprise.instance.BaseManager manager, DeploymentRequest request, com.sun.ejb.codegen.IASEJBCTimes timing)Returns new instance of EJBCompiler, using the deployment request's classpath list as the classpath
to be used during compilation.
this(name, srcDir, stubsDir, manager, request, timing, request.getCompleteClasspath());
| public EJBCompiler(String name, File srcDir, File stubsDir, com.sun.enterprise.instance.BaseManager manager, DeploymentRequest request, com.sun.ejb.codegen.IASEJBCTimes timing, List classpathForCompilation)Returns new instance of EJBCompiler, accepting an alternate classpath List to be used during compilation.
This added constructor supports the fix for bug 4980750 so WebModuleDeployer can specify an adjusted
classpath for use during compilation.
assert StringUtils.ok(name);
assert FileUtils.safeIsDirectory(srcDir);
assert manager != null;
assert request != null;
assert timing != null;
try
{
this.name = name;
this.request = request;
this.classpathForCompilation = classpathForCompilation;
// context used during code gen
this.ejbcContext = new EjbcContextImpl();
ejbcContext.setSrcDir(srcDir);
ejbcContext.setStubsDir(stubsDir);
ejbcContext.setTiming(timing);
ejbcContext.setRmicOptions( manager.getRmicOptions() );
ejbcContext.setJavacOptions( manager.getJavacOptions() );
ejbcContext.setOptionalArguments(this.request.getOptionalArguments());
ejbcContext.setDeploymentRequest(request);
if(manager instanceof ModulesManager)
{
moduleManager = (ModulesManager)manager;
appManager = null;
}
else if(manager instanceof AppsManager)
{
appManager = (AppsManager)manager;
moduleManager = null;
}
else
assert (false);
}
catch(Throwable t)
{
throw wrapException(t);
}
|
Methods Summary |
---|
public com.sun.enterprise.util.zip.ZipItem[] | compile()
ZipItem[] clientStubs = null;
try
{
if(request.getNoEJBC())
{
_logger.info( "********** EJBC Skipped! ************" );
return new ZipItem[] {};
}
if(appManager != null)
{
clientStubs = preDeployApp();
}
else
{
clientStubs = preDeployModule();
}
Application app = ejbcContext.getDescriptor();
if (app != null)
{
for (Iterator iter = app.getEjbDescriptors().iterator();
iter.hasNext();)
{
//translate deployment descriptor to load PolicyConfiguration
EJBSecurityManager.loadPolicyConfiguration((EjbDescriptor)iter.next());
}
}
}
catch(Throwable t)
{
throw wrapException(t);
}
return clientStubs;
| private com.sun.enterprise.util.zip.ZipItem[] | preDeployApp()EJBC for an application. This is called from the deployment backend.
clientDstJar is the EAR that was deployed. It has been saved in
classLoadable format (i.e. all classes in all jars contained in the EAR
have been expanded out from the root of the EAR so that they can be
loaded by the JarClassLoader).
ZipItem[] clientStubs = null;
Application application = request.getDescriptor();
String appRoot = ejbcContext.getSrcDir().getCanonicalPath();
setEjbClasspath(request.getModuleClasspath());
ejbcContext.setDescriptor(application);
/*
*Bug 4980750 - See also the comments in WebModuleDeployer
*for a discussion of the root cause of this bug. Use the List of classpath entries set by the
*constructor (either by default to preserve the old behavior or via an explicit argument passed from
*the method that instantiated EJBCompiler to supply an alternate classpath List).
*/
// converts all the class paths to an array
String[] classPathUrls = new String[this.classpathForCompilation.size()];
classPathUrls = (String[]) this.classpathForCompilation.toArray(classPathUrls);
ejbcContext.setClasspathUrls(classPathUrls);
// verify ejbc context
verifyContext();
// calls ejbc
clientStubs = IASEJBC.ejbc(this.ejbcContext);
UniqueIdGenerator uidGenerator = UniqueIdGenerator.getInstance();
long uid = uidGenerator.getNextUniqueId();
application.setUniqueId(uid);
this.appManager.saveAppDescriptor(this.name, application,
request.getDeployedDirectory().getCanonicalPath(),
request.getGeneratedXMLDirectory().getCanonicalPath(), false);
return clientStubs;
| private com.sun.enterprise.util.zip.ZipItem[] | preDeployModule()EJBC for a stand alone ejb module.
ZipItem[] clientStubs = null;
Application application = request.getDescriptor();
ejbcContext.setDescriptor(application);
/*
*Bug 4980750 - See also the comments in WebModuleDeployer
*for a discussion of the root cause of this bug. Use the List of classpath entries set by the
*constructor (either by default to preserve the old behavior or via an explicit argument passed from
*the method that instantiated EJBCompiler to supply an alternate classpath List).
*/
// converts all the class paths to an array
String[] classPathUrls = new String[this.classpathForCompilation.size()];
classPathUrls = (String[]) this.classpathForCompilation.toArray(classPathUrls);
ejbcContext.setClasspathUrls(classPathUrls);
// verify ejbc context
verifyContext();
// calls ejbc
clientStubs = IASEJBC.ejbc(this.ejbcContext);
UniqueIdGenerator uidGenerator = UniqueIdGenerator.getInstance();
long uid = uidGenerator.getNextUniqueId();
for (Iterator itr = application.getEjbBundleDescriptors().iterator();
itr.hasNext();)
{
// for stand alone ejb module, there will be
// one EjbBundleDescriptor
EjbBundleDescriptor bundleDesc = (EjbBundleDescriptor) itr.next();
// sets the unique id of all the beans in this bundle
bundleDesc.setUniqueId(uid);
}
this.moduleManager.saveAppDescriptor(this.name, application,
request.getDeployedDirectory().getCanonicalPath(),
request.getGeneratedXMLDirectory().getCanonicalPath(), true);
return clientStubs;
| private void | setEjbClasspath(java.util.List ejbClassPath)Sets the ejb portion of the class path in the ejbc context.
String[] ejbClassPathUrls = new String[ejbClassPath.size()];
ejbClassPathUrls = (String[]) ejbClassPath.toArray(ejbClassPathUrls);
this.ejbcContext.setEjbClasspathUrls(ejbClassPathUrls);
| void | verifyContext()Throws an exception if required elements of the ejbc context is null.
if ( (this.ejbcContext.getSrcDir() == null)
|| (this.ejbcContext.getStubsDir() == null)
|| (this.ejbcContext.getDescriptor() == null)
|| (this.ejbcContext.getRmicOptions() == null)
|| (this.ejbcContext.getJavacOptions() == null)
|| (this.ejbcContext.getTiming() == null))
{
// error - required element is missing
String msg = localStrings.getString(
"enterprise.deployment.backend.bad_ejbc_ctx");
throw new IASDeploymentException(msg);
}
| IASDeploymentException | wrapException(java.lang.Throwable t)
String msg = localStrings.getString(
"enterprise.deployment.backend.fatal_ejbc_error" );
if(t instanceof java.rmi.RemoteException)
{
msg += localStrings.getString(
"enterprise.deployment.backend.ejbc_remoteexception", t );
}
return new IASDeploymentException(msg, t);
|
|