Lines 12-17
Link Here
|
12 |
package org.eclipse.osgi.internal.baseadaptor; |
12 |
package org.eclipse.osgi.internal.baseadaptor; |
13 |
|
13 |
|
14 |
import java.io.IOException; |
14 |
import java.io.IOException; |
|
|
15 |
import java.lang.reflect.Method; |
15 |
import java.net.MalformedURLException; |
16 |
import java.net.MalformedURLException; |
16 |
import java.net.URL; |
17 |
import java.net.URL; |
17 |
import java.security.*; |
18 |
import java.security.*; |
Lines 29-52
Link Here
|
29 |
import org.osgi.framework.Bundle; |
30 |
import org.osgi.framework.Bundle; |
30 |
|
31 |
|
31 |
/** |
32 |
/** |
32 |
* The default implemention of <code>BaseClassLoader</code>. This implementation extends |
33 |
* The default implementation of <code>BaseClassLoader</code>. This implementation extends |
33 |
* <code>ClassLoader</code>. |
34 |
* <code>ClassLoader</code>. |
34 |
* @see BaseClassLoader |
35 |
* @see BaseClassLoader |
35 |
* @see ClasspathManager |
36 |
* @see ClasspathManager |
36 |
*/ |
37 |
*/ |
37 |
public class DefaultClassLoader extends ClassLoader implements BaseClassLoader { |
38 |
public class DefaultClassLoader extends ClassLoader implements ParallelClassLoader { |
38 |
/** |
39 |
/** |
39 |
* A PermissionCollection for AllPermissions; shared across all ProtectionDomains when security is disabled |
40 |
* A PermissionCollection for AllPermissions; shared across all ProtectionDomains when security is disabled |
40 |
*/ |
41 |
*/ |
41 |
protected static final PermissionCollection ALLPERMISSIONS; |
42 |
protected static final PermissionCollection ALLPERMISSIONS; |
42 |
private final static String CLASS_CERTIFICATE_SUPPORT = "osgi.support.class.certificate"; //$NON-NLS-1$ |
43 |
private final static String CLASS_CERTIFICATE_SUPPORT = "osgi.support.class.certificate"; //$NON-NLS-1$ |
|
|
44 |
private final static String CLASS_LOADER_TYPE = "osgi.classloader.type"; //$NON-NLS-1$ |
45 |
private final static String CLASS_LOADER_TYPE_PARALLEL = "parallel"; //$NON-NLS-1$ |
43 |
private static final boolean CLASS_CERTIFICATE; |
46 |
private static final boolean CLASS_CERTIFICATE; |
|
|
47 |
private static final boolean PARALLEL_CAPABLE; |
44 |
static { |
48 |
static { |
45 |
CLASS_CERTIFICATE = Boolean.valueOf(FrameworkProperties.getProperty(CLASS_CERTIFICATE_SUPPORT, "true")).booleanValue(); //$NON-NLS-1$ |
49 |
CLASS_CERTIFICATE = Boolean.valueOf(FrameworkProperties.getProperty(CLASS_CERTIFICATE_SUPPORT, "true")).booleanValue(); //$NON-NLS-1$ |
46 |
AllPermission allPerm = new AllPermission(); |
50 |
AllPermission allPerm = new AllPermission(); |
47 |
ALLPERMISSIONS = allPerm.newPermissionCollection(); |
51 |
ALLPERMISSIONS = allPerm.newPermissionCollection(); |
48 |
if (ALLPERMISSIONS != null) |
52 |
if (ALLPERMISSIONS != null) |
49 |
ALLPERMISSIONS.add(allPerm); |
53 |
ALLPERMISSIONS.add(allPerm); |
|
|
54 |
boolean typeParallel = CLASS_LOADER_TYPE_PARALLEL.equals(FrameworkProperties.getProperty(CLASS_LOADER_TYPE)); |
55 |
boolean parallelCapable = false; |
56 |
try { |
57 |
if (typeParallel) { |
58 |
Method parallelCapableMetod = ClassLoader.class.getDeclaredMethod("registerAsParallelCapable", null); //$NON-NLS-1$ |
59 |
parallelCapableMetod.setAccessible(true); |
60 |
parallelCapable = ((Boolean) parallelCapableMetod.invoke(null, null)).booleanValue(); |
61 |
} |
62 |
} catch (Throwable e) { |
63 |
// must do everything to avoid failing in clinit |
64 |
parallelCapable = false; |
65 |
} |
66 |
PARALLEL_CAPABLE = parallelCapable; |
50 |
} |
67 |
} |
51 |
|
68 |
|
52 |
protected ClassLoaderDelegate delegate; |
69 |
protected ClassLoaderDelegate delegate; |
Lines 250-253
Link Here
|
250 |
public Bundle getBundle() { |
267 |
public Bundle getBundle() { |
251 |
return manager.getBaseData().getBundle(); |
268 |
return manager.getBaseData().getBundle(); |
252 |
} |
269 |
} |
|
|
270 |
|
271 |
public boolean isParallelCapable() { |
272 |
return PARALLEL_CAPABLE; |
273 |
} |
253 |
} |
274 |
} |