blob: 1ebd20ca17bb43c8fa267113fac9d17b90711313 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
/*******************************************************************************
* Copyright (c) 2006 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* David Knibb initial implementation
* Matthew Webster Eclipse 3.2 changes
*******************************************************************************/
package org.eclipse.equinox.weaving.aspectj;
import java.util.Properties;
import org.eclipse.equinox.service.weaving.IWeavingService;
import org.eclipse.osgi.service.debug.DebugOptions;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
/**
* The main plugin class to be used in the desktop.
*/
public class WeavingServicePlugin implements BundleActivator {
public static boolean DEBUG;
public static boolean verbose = Boolean
.getBoolean("org.aspectj.osgi.verbose");
//The shared instance.
private static WeavingServicePlugin plugin;
/**
* The constructor.
*/
public WeavingServicePlugin() {
plugin = this;
// IWeavingContext iwc = new WeavingContext(null,null);//force bundle to be resolved
}
/**
* Returns the shared instance.
*/
public static WeavingServicePlugin getDefault() {
return plugin;
}
/**
* This method is called upon plug-in activation
*/
public void start(final BundleContext context) throws Exception {
loadOptions(context);
if (verbose)
System.err
.println("[org.aspectj.osgi.service.weaving] info Starting AspectJ weaving service ...");
final String serviceName = IWeavingService.class.getName();
// ServiceFactory factory = new WeavingServiceFactory();
final IWeavingService weavingService = new WeavingService();
final Properties props = new Properties();
// context.registerService(serviceName, factory, props);
context.registerService(serviceName, weavingService, props);
// System.out.println("WeavingServicePlugin.start() - registered WeavingService");
}
/**
* This method is called when the plug-in is stopped
*/
public void stop(final BundleContext context) throws Exception {
plugin = null;
}
private void loadOptions(final BundleContext context) {
// all this is only to get the application args
DebugOptions service = null;
final ServiceReference reference = context
.getServiceReference(DebugOptions.class.getName());
if (reference != null)
service = (DebugOptions) context.getService(reference);
if (service == null) return;
try {
DEBUG = service.getBooleanOption(
"org.aspectj.osgi.service.weaving/debug", false);
} finally {
// we have what we want - release the service
context.ungetService(reference);
}
}
}
|