1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package org.microemu.app.classloader;
23
24 import java.util.List;
25 import java.util.Vector;
26
27 import org.microemu.app.ConfigurationException;
28
29 public class MIDletClassLoaderConfig {
30
31 public static final int DELEGATION_STRICT = 0;
32
33 public static final int DELEGATION_DELEGATING = 1;
34
35 public static final int DELEGATION_SYSTEM = 2;
36
37 int delegationType = DELEGATION_STRICT;
38
39 List appclasses = new Vector();
40
41 List appclasspath = new Vector();
42
43 public void setDelegationType(String delegationType) throws ConfigurationException {
44 if ("strict".equalsIgnoreCase(delegationType)) {
45 this.delegationType = DELEGATION_STRICT;
46 } else if ("delegating".equalsIgnoreCase(delegationType)) {
47 this.delegationType = DELEGATION_DELEGATING;
48 } else if ("system".equalsIgnoreCase(delegationType)) {
49 if ((appclasses.size() != 0) || (appclasspath.size() != 0)) {
50 throw new ConfigurationException("Can't extend system CLASSPATH");
51 }
52 this.delegationType = DELEGATION_SYSTEM;
53 } else {
54 throw new ConfigurationException("Unknown delegationType [" + delegationType + "]");
55 }
56 }
57
58 public boolean isClassLoaderDisabled() {
59 return (this.delegationType == DELEGATION_SYSTEM);
60 }
61
62 public void addAppClassPath(String path) throws ConfigurationException {
63 if (this.delegationType == DELEGATION_SYSTEM) {
64 throw new ConfigurationException("Can't extend system CLASSPATH");
65 }
66 appclasspath.add(path);
67 }
68
69 public void addAppClass(String className) throws ConfigurationException {
70 if (this.delegationType == DELEGATION_SYSTEM) {
71 throw new ConfigurationException("Can't extend system CLASSPATH");
72 }
73 appclasses.add(className);
74 }
75
76 }