001: package com.mockrunner.gen.jar;
002:
003: import java.util.ArrayList;
004: import java.util.HashMap;
005: import java.util.HashSet;
006: import java.util.List;
007: import java.util.Map;
008: import java.util.Set;
009:
010: public class MockrunnerJars {
011: private static List mockrunnerJars;
012: private static List standardInterfaceJars;
013: private static List jee5OnlyJars;
014: private static Map permissions;
015: private static Set strutsJars;
016: private static Set webJ2EEJars;
017: private static Set otherJ2EEJars;
018: private static Set mockEJBJars;
019: private static Set xmlJars;
020:
021: static {
022: mockrunnerJars = new ArrayList();
023: mockrunnerJars.add("mockrunner.jar");
024: mockrunnerJars.add("mockrunner-ejb.jar");
025: mockrunnerJars.add("mockrunner-jdbc.jar");
026: mockrunnerJars.add("mockrunner-jms.jar");
027: mockrunnerJars.add("mockrunner-jca.jar");
028: mockrunnerJars.add("mockrunner-servlet.jar");
029: mockrunnerJars.add("mockrunner-tag.jar");
030: mockrunnerJars.add("mockrunner-struts.jar");
031:
032: permissions = new HashMap();
033: permissions.put("mockrunner.jar", new Permission(true, true,
034: true, true, true));
035: permissions.put("mockrunner-ejb.jar", new Permission(false,
036: false, true, true, false));
037: permissions.put("mockrunner-jdbc.jar", new Permission(false,
038: false, false, false, true));
039: permissions.put("mockrunner-jms.jar", new Permission(false,
040: false, true, false, false));
041: permissions.put("mockrunner-jca.jar", new Permission(false,
042: false, true, false, false));
043: permissions.put("mockrunner-servlet.jar", new Permission(false,
044: true, false, false, true));
045: permissions.put("mockrunner-tag.jar", new Permission(false,
046: true, false, false, true));
047: permissions.put("mockrunner-struts.jar", new Permission(true,
048: true, false, false, true));
049:
050: standardInterfaceJars = new ArrayList();
051: standardInterfaceJars.add("servlet-api.jar");
052: standardInterfaceJars.add("jsp-api.jar");
053: standardInterfaceJars.add("el-api.jar");
054: standardInterfaceJars.add("jboss-j2ee.jar");
055: standardInterfaceJars.add("servlet.jar");
056:
057: jee5OnlyJars = new ArrayList();
058: jee5OnlyJars.add("jasper.jar");
059: jee5OnlyJars.add("jasper-el.jar");
060:
061: strutsJars = new HashSet();
062: strutsJars.add("struts-core-1.3.8.jar");
063:
064: webJ2EEJars = new HashSet();
065: webJ2EEJars.add("servlet-api.jar");
066: webJ2EEJars.add("jsp-api.jar");
067: webJ2EEJars.add("el-api.jar");
068: webJ2EEJars.add("jasper.jar");
069: webJ2EEJars.add("jasper-el.jar");
070: webJ2EEJars.add("servlet.jar");
071:
072: otherJ2EEJars = new HashSet();
073: otherJ2EEJars.add("jboss-j2ee.jar");
074:
075: mockEJBJars = new HashSet();
076: mockEJBJars.add("mockejb.jar");
077:
078: xmlJars = new HashSet();
079: xmlJars.add("xercesImpl.jar");
080: xmlJars.add("xml-apis.jar");
081: xmlJars.add("nekohtml.jar");
082: xmlJars.add("jdom.jar");
083: }
084:
085: public static List getMockrunnerJars() {
086: return mockrunnerJars;
087: }
088:
089: public static List getStandardInterfaceJars() {
090: return standardInterfaceJars;
091: }
092:
093: public static List getJEE5OnlyJars() {
094: return jee5OnlyJars;
095: }
096:
097: public static Permission getPermission(String jar) {
098: return (Permission) permissions.get(jar);
099: }
100:
101: public static class Permission {
102: private boolean isStrutsDependencyAllowed = false;
103: private boolean isWebJ2EEDependencyAllowed = false;
104: private boolean isOtherJ2EEDependencyAllowed = false;
105: private boolean isMockEJBDependencyAllowed = false;
106: private boolean isXMLDependencyAllowed = false;
107:
108: public Permission(boolean isStrutsDependencyAllowed,
109: boolean isWebJ2EEDependencyAllowed,
110: boolean isOtherJ2EEDependencyAllowed,
111: boolean isMockEJBDependencyAllowed,
112: boolean isXMLDependencyAllowed) {
113: this .isStrutsDependencyAllowed = isStrutsDependencyAllowed;
114: this .isWebJ2EEDependencyAllowed = isWebJ2EEDependencyAllowed;
115: this .isOtherJ2EEDependencyAllowed = isOtherJ2EEDependencyAllowed;
116: this .isMockEJBDependencyAllowed = isMockEJBDependencyAllowed;
117: this .isXMLDependencyAllowed = isXMLDependencyAllowed;
118: }
119:
120: public boolean isOtherJ2EEDependencyAllowed() {
121: return isOtherJ2EEDependencyAllowed;
122: }
123:
124: public boolean isStrutsDependencyAllowed() {
125: return isStrutsDependencyAllowed;
126: }
127:
128: public boolean isWebJ2EEDependencyAllowed() {
129: return isWebJ2EEDependencyAllowed;
130: }
131:
132: public boolean isMockEJBDependencyAllowed() {
133: return isMockEJBDependencyAllowed;
134: }
135:
136: public boolean isXMLDependencyAllowed() {
137: return isXMLDependencyAllowed;
138: }
139:
140: public Set getProhibited(Set dependentJars) {
141: Set jars = new HashSet(dependentJars);
142: if (!isStrutsDependencyAllowed) {
143: jars.removeAll(strutsJars);
144: }
145: if (!isWebJ2EEDependencyAllowed) {
146: jars.removeAll(webJ2EEJars);
147: }
148: if (!isOtherJ2EEDependencyAllowed) {
149: jars.removeAll(otherJ2EEJars);
150: }
151: if (!isMockEJBDependencyAllowed) {
152: jars.removeAll(mockEJBJars);
153: }
154: if (!isXMLDependencyAllowed) {
155: jars.removeAll(xmlJars);
156: }
157: Set finalSet = new HashSet(dependentJars);
158: finalSet.removeAll(jars);
159: return finalSet;
160: }
161: }
162: }
|