SourceScanpublic class SourceScan extends AVKTasks This is the implementation for running source scan through Ant task.
This task runs the following two classses -
Invokes IASMTMain by passing the appropriate arguments,
Invokes the org.apache.xalan.xslt.Process class for transformation.
The attributes of this task are:
srcDir ="REQUIRED"
srcServer ="REQUIRED" (Options are: sunone, weblogic5, weblogic6, websphere, jboss)
jvmArgs ="OPTIONAL" (default: "-hotspot -ms96m -mx512m")
failOnError="OPTIONAL" (default: true)
|
Fields Summary |
---|
private File | srcDir | private String | srcServer |
Methods Summary |
---|
private void | checkArgs()Parse the source server argument. Throw exception if invalid
option is found.
if(srcDir == null || !srcDir.exists())
throw new BuildException("Provide a valid fullly qualified " +
"path of the source directory to be scanned: srcDir = "+srcDir);
if(srcServer == null)
throw new BuildException("Must specify which app server was used to create the application");
else if(srcServer.equalsIgnoreCase("sunone"))
srcServer = "as70";
else if(srcServer.equalsIgnoreCase("weblogic5"))
srcServer = "wl51";
else if(srcServer.equalsIgnoreCase("weblogic6"))
srcServer = "wl60";
else if(srcServer.equalsIgnoreCase("weblogic8"))
srcServer = "wl81";
else if(srcServer.equalsIgnoreCase("websphere4"))
srcServer = "ws40";
else if(srcServer.equalsIgnoreCase("websphere50"))
srcServer = "ws50";
else if(srcServer.equalsIgnoreCase("tomcat"))
srcServer = "tc41";
else if(srcServer.equalsIgnoreCase("JBoss"))
srcServer = "jb30";
else
throw new BuildException("srcServer = "+srcServer+" is not one of " +
"(sunone, weblogic5, weblogic6, weblogic8, websphere4, websphere50 and jboss )");
| private org.apache.tools.ant.types.Path | constructPath()
String j2ee_lib=j2ee_home + File.separator+"lib";
StringBuffer classPathBuffer = new StringBuffer();
String[] CLASSPATH_ELEMENTS = {
"lib"+File.separator +"ant.jar",
"lib"+File.separator +"xalan.jar",
"lib"+File.separator +"jhall.jar",
"lib"+File.separator +"dom4j.jar",
"lib"+File.separator +"asmt.jar",
"lib"+File.separator +"jaxb-api.jar",
"lib"+File.separator +"jaxb-impl.jar",
"lib"+File.separator +"jaxb-libs.jar",
"lib"+File.separator +"namespace.jar",
"lib"+File.separator +"asmt_en.jar",
"lib"+File.separator +"jax-qname.jar",
"lib"+File.separator +"relaxngDatatype.jar"};
classPathBuffer.append(java_home+"lib"+File.separator +
"tools.jar"+File.pathSeparator);
for(int i=0;i<CLASSPATH_ELEMENTS.length;i++) {
classPathBuffer.append((new File(avk_home,CLASSPATH_ELEMENTS[i])).getPath());
classPathBuffer.append(File.pathSeparator);
}
classPathBuffer.append(j2ee_lib+File.separator+
"javaee.jar"+File.pathSeparator);
return new Path(getProject(),classPathBuffer.toString());
| public void | execute()This is called by the ant framework.
checkArgs();
getInstallHomes();
// temporary until migration code has CLIP interface as default
if(jvmArgs == null)
jvmArgs = "-hotspot -ms96m -mx512m -Dasmt.home="+avk_home+" -DPACKAGE_PROPERTY_FILE="+avk_home+"/config/package.properties -DENABLE_CLIP=true";
if(invokeIASMT() !=0 && failOnError)
throw new BuildException("Problem in scanning source code");
if(invokeGenReportTool() !=0 && failOnError)
throw new BuildException("Problem in generating reports");
echo.setMessage("See \""+resultDir+File.separator+"codeSummary.html\" for results.");
echo.execute();
| private int | invokeGenReportTool()Invokes the com.sun.enterprise.appverification.tools.GenReportTool
Java java = createJavaTask();
List<String> list = new ArrayList<String>();
list.add(resultDir + File.separator + "result.xml");
list.add(resultDir);
list.add("codeSummary");
String[] args = (String[])list.toArray(new String[1]);
java.setClassname("com.sun.enterprise.appverification.tools.GenReportTool");
setArgs(java, args);
return java.executeJava();
| private int | invokeIASMT()Invokes the sun.iasmt.user.IASMTMain
Java java = (Java)project.createTask("java");
java.setClassname("sun.iasmt.user.IASMTMain");
setCommonVMSettings(java);
java.setClasspath(constructPath());
Environment.Variable sysp = new Environment.Variable();
sysp.setKey("asmt.home");
sysp.setValue(avk_home);
createResultDir("scan");
java.addSysproperty(sysp);
java.createArg().setLine("-c -t "+resultDir+
" -S "+srcServer+
" -s "+srcDir+
" -T sjs80PE -n -q"+
" -x "+resultDir+File.separator+"result.xml");
return java.executeJava();
| public void | setSrcDir(java.io.File srcDir)
this.srcDir = srcDir;
| public void | setSrcServer(java.lang.String srcServer)
this.srcServer = srcServer;
|
|