clean up and refactor some APIs surrounding file I/O and exclusions files. Needed in order to allow clients to use some APIs with application-specific exclusions.
git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@2250 f5eafffb-2e1d-0410-98e4-8ec43c5233c4
This commit is contained in:
parent
29f015f282
commit
afd0014e74
Binary file not shown.
|
@ -10,6 +10,8 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package com.ibm.wala.j2ee;
|
package com.ibm.wala.j2ee;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.jar.JarFile;
|
import java.util.jar.JarFile;
|
||||||
|
@ -24,6 +26,7 @@ import com.ibm.wala.ipa.callgraph.AnalysisScope;
|
||||||
import com.ibm.wala.types.ClassLoaderReference;
|
import com.ibm.wala.types.ClassLoaderReference;
|
||||||
import com.ibm.wala.util.config.AnalysisScopeReader;
|
import com.ibm.wala.util.config.AnalysisScopeReader;
|
||||||
import com.ibm.wala.util.config.FileOfClasses;
|
import com.ibm.wala.util.config.FileOfClasses;
|
||||||
|
import com.ibm.wala.util.config.FileProvider;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description of analysis for EJBs
|
* Description of analysis for EJBs
|
||||||
|
@ -49,17 +52,19 @@ public class J2EEAnalysisScope extends AnalysisScope {
|
||||||
* @param lifecycleEntrypoints
|
* @param lifecycleEntrypoints
|
||||||
* Should EJB lifecycle entrypoints be considered as call graph
|
* Should EJB lifecycle entrypoints be considered as call graph
|
||||||
* entrypoints?
|
* entrypoints?
|
||||||
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public J2EEAnalysisScope(String baseScope, ClassLoader loader, boolean lifecycleEntrypoints) {
|
public J2EEAnalysisScope(String baseScope, ClassLoader loader, boolean lifecycleEntrypoints) throws IOException {
|
||||||
this(baseScope, loader, EXCLUSIONS_FILE, lifecycleEntrypoints);
|
this(baseScope, loader, FileProvider.getFile(EXCLUSIONS_FILE), lifecycleEntrypoints);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param lifecycleEntrypoints
|
* @param lifecycleEntrypoints
|
||||||
* Should EJB lifecycle entrypoints be considered as call graph
|
* Should EJB lifecycle entrypoints be considered as call graph
|
||||||
* entrypoints?
|
* entrypoints?
|
||||||
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public J2EEAnalysisScope(String baseScope, ClassLoader loader, String exclusionsFile, boolean lifecycleEntrypoints) {
|
public J2EEAnalysisScope(String baseScope, ClassLoader loader, File exclusionsFile, boolean lifecycleEntrypoints) throws IOException {
|
||||||
super(Collections.singleton(Language.JAVA));
|
super(Collections.singleton(Language.JAVA));
|
||||||
AnalysisScope base = AnalysisScopeReader.read(baseScope, exclusionsFile, loader);
|
AnalysisScope base = AnalysisScopeReader.read(baseScope, exclusionsFile, loader);
|
||||||
|
|
||||||
|
@ -69,7 +74,7 @@ public class J2EEAnalysisScope extends AnalysisScope {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (exclusionsFile != null) {
|
if (exclusionsFile != null) {
|
||||||
FileOfClasses file = new FileOfClasses(exclusionsFile, loader);
|
FileOfClasses file = new FileOfClasses(exclusionsFile);
|
||||||
setExclusions(file);
|
setExclusions(file);
|
||||||
}
|
}
|
||||||
this.lifecycleEntrypoints = lifecycleEntrypoints;
|
this.lifecycleEntrypoints = lifecycleEntrypoints;
|
||||||
|
@ -80,12 +85,13 @@ public class J2EEAnalysisScope extends AnalysisScope {
|
||||||
* @param lifecycleEntrypoints
|
* @param lifecycleEntrypoints
|
||||||
* Should EJB lifecycle entrypoints be considered as call graph
|
* Should EJB lifecycle entrypoints be considered as call graph
|
||||||
* entrypoints?
|
* entrypoints?
|
||||||
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public static J2EEAnalysisScope makeDefault(ClassLoader loader, boolean lifecycleEntrypoints) {
|
public static J2EEAnalysisScope makeDefault(ClassLoader loader, boolean lifecycleEntrypoints) throws IOException {
|
||||||
return new J2EEAnalysisScope(DEFAULT_FILE, loader, lifecycleEntrypoints);
|
return new J2EEAnalysisScope(DEFAULT_FILE, loader, lifecycleEntrypoints);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static J2EEAnalysisScope make(JarFile[] J2SELibs, JarFile[] J2EELibs, ClassLoader loader, boolean lifecycleEntrypoints) {
|
public static J2EEAnalysisScope make(JarFile[] J2SELibs, JarFile[] J2EELibs, ClassLoader loader, boolean lifecycleEntrypoints) throws IOException {
|
||||||
return make(J2SELibs, J2EELibs, EXCLUSIONS_FILE, loader, lifecycleEntrypoints);
|
return make(J2SELibs, J2EELibs, EXCLUSIONS_FILE, loader, lifecycleEntrypoints);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,11 +101,12 @@ public class J2EEAnalysisScope extends AnalysisScope {
|
||||||
* @param lifecycleEntrypoints
|
* @param lifecycleEntrypoints
|
||||||
* Should EJB lifecycle entrypoints be considered as call graph
|
* Should EJB lifecycle entrypoints be considered as call graph
|
||||||
* entrypoints?
|
* entrypoints?
|
||||||
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public static J2EEAnalysisScope make(JarFile[] J2SELibs, JarFile[] J2EELibs, String exclusionsFile, ClassLoader loader,
|
public static J2EEAnalysisScope make(JarFile[] J2SELibs, JarFile[] J2EELibs, String exclusionsFile, ClassLoader loader,
|
||||||
boolean lifecycleEntrypoints) {
|
boolean lifecycleEntrypoints) throws IOException {
|
||||||
J2EEAnalysisScope scope;
|
J2EEAnalysisScope scope;
|
||||||
scope = new J2EEAnalysisScope(BASIC_FILE, loader, exclusionsFile, lifecycleEntrypoints);
|
scope = new J2EEAnalysisScope(BASIC_FILE, loader, new File(exclusionsFile), lifecycleEntrypoints);
|
||||||
for (int i = 0; i < J2SELibs.length; i++) {
|
for (int i = 0; i < J2SELibs.length; i++) {
|
||||||
JarFileModule lib = new JarFileModule(J2SELibs[i]);
|
JarFileModule lib = new JarFileModule(J2SELibs[i]);
|
||||||
scope.addToScope(scope.getPrimordialLoader(), lib);
|
scope.addToScope(scope.getPrimordialLoader(), lib);
|
||||||
|
@ -116,14 +123,15 @@ public class J2EEAnalysisScope extends AnalysisScope {
|
||||||
* @param lifecycleEntrypoints
|
* @param lifecycleEntrypoints
|
||||||
* Should EJB lifecycle entrypoints be considered as call graph
|
* Should EJB lifecycle entrypoints be considered as call graph
|
||||||
* entrypoints?
|
* entrypoints?
|
||||||
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public static J2EEAnalysisScope make(Module[] J2SELibs, Module[] J2EELibs, String exclusionsFile, ClassLoader loader,
|
public static J2EEAnalysisScope make(Module[] J2SELibs, Module[] J2EELibs, String exclusionsFile, ClassLoader loader,
|
||||||
boolean lifecycleEntrypoints) {
|
boolean lifecycleEntrypoints) throws IOException {
|
||||||
J2EEAnalysisScope scope;
|
J2EEAnalysisScope scope;
|
||||||
if (exclusionsFile == null) {
|
if (exclusionsFile == null) {
|
||||||
exclusionsFile = EXCLUSIONS_FILE;
|
exclusionsFile = EXCLUSIONS_FILE;
|
||||||
}
|
}
|
||||||
scope = new J2EEAnalysisScope(BASIC_FILE, loader, exclusionsFile, lifecycleEntrypoints);
|
scope = new J2EEAnalysisScope(BASIC_FILE, loader, new File(exclusionsFile), lifecycleEntrypoints);
|
||||||
for (int i = 0; i < J2SELibs.length; i++) {
|
for (int i = 0; i < J2SELibs.length; i++) {
|
||||||
scope.addToScope(scope.getPrimordialLoader(), J2SELibs[i]);
|
scope.addToScope(scope.getPrimordialLoader(), J2SELibs[i]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package com.ibm.wala.j2ee.client.impl;
|
package com.ibm.wala.j2ee.client.impl;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.jar.JarFile;
|
import java.util.jar.JarFile;
|
||||||
|
|
||||||
|
@ -62,15 +63,17 @@ public abstract class J2EEAbstractAnalysisEngine extends AbstractAnalysisEngine
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set up the AnalysisScope object
|
* Set up the AnalysisScope object
|
||||||
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
protected void buildAnalysisScope() {
|
protected void buildAnalysisScope() throws IOException {
|
||||||
buildAnalysisScope(null);
|
buildAnalysisScope(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set up the AnalysisScope object
|
* Set up the AnalysisScope object
|
||||||
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
protected void buildAnalysisScope(String exclusionsFile) {
|
protected void buildAnalysisScope(String exclusionsFile) throws IOException {
|
||||||
// set up the scope of the analysis
|
// set up the scope of the analysis
|
||||||
ClassLoader cl = J2EEAbstractAnalysisEngine.class.getClassLoader();
|
ClassLoader cl = J2EEAbstractAnalysisEngine.class.getClassLoader();
|
||||||
if (j2seLibs == null) {
|
if (j2seLibs == null) {
|
||||||
|
|
|
@ -21,6 +21,7 @@ public class HttpServletRequest
|
||||||
private final java.util.Hashtable<String, String> headers = new java.util.Hashtable<String, String>();
|
private final java.util.Hashtable<String, String> headers = new java.util.Hashtable<String, String>();
|
||||||
|
|
||||||
public HttpServletRequest() {
|
public HttpServletRequest() {
|
||||||
|
super();
|
||||||
headers.put("header", "value");
|
headers.put("header", "value");
|
||||||
headers.get("header");
|
headers.get("header");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue