|
Lines 14-19
Link Here
|
| 14 |
import java.util.Dictionary; |
14 |
import java.util.Dictionary; |
| 15 |
import java.util.Hashtable; |
15 |
import java.util.Hashtable; |
| 16 |
import org.eclipse.osgi.framework.debug.FrameworkDebugOptions; |
16 |
import org.eclipse.osgi.framework.debug.FrameworkDebugOptions; |
|
|
17 |
import org.eclipse.osgi.service.environment.ExecutionEnvironmentService; |
| 17 |
import org.osgi.framework.*; |
18 |
import org.osgi.framework.*; |
| 18 |
import org.osgi.service.condpermadmin.ConditionalPermissionAdmin; |
19 |
import org.osgi.service.condpermadmin.ConditionalPermissionAdmin; |
| 19 |
|
20 |
|
|
Lines 22-41
Link Here
|
| 22 |
*/ |
23 |
*/ |
| 23 |
|
24 |
|
| 24 |
public class SystemBundleActivator implements BundleActivator { |
25 |
public class SystemBundleActivator implements BundleActivator { |
| 25 |
protected BundleContext context; |
26 |
private BundleContext context; |
| 26 |
protected SystemBundle bundle; |
27 |
private Framework framework; |
| 27 |
protected Framework framework; |
28 |
private ServiceRegistration packageAdmin; |
| 28 |
protected ServiceRegistration packageAdmin; |
29 |
private ServiceRegistration securityAdmin; |
| 29 |
protected ServiceRegistration securityAdmin; |
30 |
private ServiceRegistration startLevel; |
| 30 |
protected ServiceRegistration startLevel; |
31 |
private ServiceRegistration debugOptions; |
| 31 |
protected ServiceRegistration debugOptions; |
32 |
private ServiceRegistration eeService; |
| 32 |
|
33 |
|
| 33 |
public SystemBundleActivator() { |
34 |
public SystemBundleActivator() { |
| 34 |
} |
35 |
} |
| 35 |
|
36 |
|
| 36 |
public void start(BundleContext context) throws Exception { |
37 |
public void start(BundleContext context) throws Exception { |
| 37 |
this.context = context; |
38 |
this.context = context; |
| 38 |
bundle = (SystemBundle) context.getBundle(); |
39 |
SystemBundle bundle = (SystemBundle) context.getBundle(); |
| 39 |
framework = bundle.framework; |
40 |
framework = bundle.framework; |
| 40 |
|
41 |
|
| 41 |
if (framework.packageAdmin != null) |
42 |
if (framework.packageAdmin != null) |
|
Lines 48-53
Link Here
|
| 48 |
if ((dbgOptions = FrameworkDebugOptions.getDefault()) != null) |
49 |
if ((dbgOptions = FrameworkDebugOptions.getDefault()) != null) |
| 49 |
debugOptions = register(new String[] {org.eclipse.osgi.service.debug.DebugOptions.class.getName()}, dbgOptions); |
50 |
debugOptions = register(new String[] {org.eclipse.osgi.service.debug.DebugOptions.class.getName()}, dbgOptions); |
| 50 |
|
51 |
|
|
|
52 |
eeService = register(new String[] {ExecutionEnvironmentService.class.getName()}, new ExecutionEnvironmentServiceImpl(bundle)); |
| 51 |
// Always call the adaptor.frameworkStart() at the end of this method. |
53 |
// Always call the adaptor.frameworkStart() at the end of this method. |
| 52 |
framework.adaptor.frameworkStart(context); |
54 |
framework.adaptor.frameworkStart(context); |
| 53 |
// attempt to resolve all bundles |
55 |
// attempt to resolve all bundles |
|
Lines 70-78
Link Here
|
| 70 |
startLevel.unregister(); |
72 |
startLevel.unregister(); |
| 71 |
if (debugOptions != null) |
73 |
if (debugOptions != null) |
| 72 |
debugOptions.unregister(); |
74 |
debugOptions.unregister(); |
| 73 |
|
75 |
if (eeService != null) |
|
|
76 |
eeService.unregister(); |
| 74 |
framework = null; |
77 |
framework = null; |
| 75 |
bundle = null; |
|
|
| 76 |
this.context = null; |
78 |
this.context = null; |
| 77 |
} |
79 |
} |
| 78 |
|
80 |
|
|
Lines 82-91
Link Here
|
| 82 |
*/ |
84 |
*/ |
| 83 |
protected ServiceRegistration register(String[] names, Object service) { |
85 |
protected ServiceRegistration register(String[] names, Object service) { |
| 84 |
Hashtable properties = new Hashtable(7); |
86 |
Hashtable properties = new Hashtable(7); |
| 85 |
Dictionary headers = bundle.getHeaders(); |
87 |
Dictionary headers = context.getBundle().getHeaders(); |
| 86 |
properties.put(Constants.SERVICE_VENDOR, headers.get(Constants.BUNDLE_VENDOR)); |
88 |
properties.put(Constants.SERVICE_VENDOR, headers.get(Constants.BUNDLE_VENDOR)); |
| 87 |
properties.put(Constants.SERVICE_RANKING, new Integer(Integer.MAX_VALUE)); |
89 |
properties.put(Constants.SERVICE_RANKING, new Integer(Integer.MAX_VALUE)); |
| 88 |
properties.put(Constants.SERVICE_PID, bundle.getBundleId() + "." + service.getClass().getName()); //$NON-NLS-1$ |
90 |
properties.put(Constants.SERVICE_PID, context.getBundle().getBundleId() + "." + service.getClass().getName()); //$NON-NLS-1$ |
| 89 |
return context.registerService(names, service, properties); |
91 |
return context.registerService(names, service, properties); |
| 90 |
} |
92 |
} |
| 91 |
|
93 |
|