blob: a6934b7269eff2769161b325a8aa37e27632dcd7 (
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
|
package org.eclipse.ecf.internal.sync;
import java.util.Dictionary;
import java.util.Properties;
import org.eclipse.ecf.internal.sync.doc.cola.ColaSynchronizationStrategyFactory;
import org.eclipse.ecf.internal.sync.doc.identity.IdentitySynchronizationStrategyFactory;
import org.eclipse.ecf.sync.IServiceConstants;
import org.eclipse.ecf.sync.doc.IDocumentSynchronizationStrategyFactory;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
public class Activator implements BundleActivator {
public static final String PLUGIN_ID = "org.eclipse.ecf.sync";
private static Activator bundle;
private ServiceRegistration colaServiceRegistration;
private ServiceRegistration identityServiceRegistration;
private BundleContext context;
IDocumentSynchronizationStrategyFactory identity;
IDocumentSynchronizationStrategyFactory cola;
public static Activator getDefault() {
return bundle;
}
/*
* (non-Javadoc)
* @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext ctxt) throws Exception {
bundle = this;
this.context = ctxt;
this.identity = new IdentitySynchronizationStrategyFactory();
this.cola = new ColaSynchronizationStrategyFactory();
// Register identity synchronizer service
final Dictionary identityServiceProps = new Properties();
identityServiceProps.put(IServiceConstants.SYNCSTRATEGY_TYPE_PROPERTY, IdentitySynchronizationStrategyFactory.SYNCHSTRATEGY_TYPE);
identityServiceProps.put(IServiceConstants.SYNCSTRATEGY_PROVIDER_PROPETY, IdentitySynchronizationStrategyFactory.SYNCHSTRATEGY_PROVIDER);
identityServiceRegistration = this.context.registerService(IDocumentSynchronizationStrategyFactory.class.getName(), this.identity, identityServiceProps);
// Register cola synchronizer service
final Dictionary colaServiceProps = new Properties();
colaServiceProps.put(IServiceConstants.SYNCSTRATEGY_TYPE_PROPERTY, ColaSynchronizationStrategyFactory.SYNCHSTRATEGY_TYPE);
colaServiceProps.put(IServiceConstants.SYNCSTRATEGY_PROVIDER_PROPETY, ColaSynchronizationStrategyFactory.SYNCHSTRATEGY_PROVIDER);
colaServiceRegistration = this.context.registerService(IDocumentSynchronizationStrategyFactory.class.getName(), this.cola, colaServiceProps);
}
/*
* (non-Javadoc)
* @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
if (colaServiceRegistration != null) {
colaServiceRegistration.unregister();
colaServiceRegistration = null;
}
if (identityServiceRegistration != null) {
identityServiceRegistration.unregister();
identityServiceRegistration = null;
}
if (this.identity != null) {
this.identity.dispose();
this.identity = null;
}
if (this.cola != null) {
this.cola.dispose();
this.cola = null;
}
this.context = null;
bundle = null;
}
}
|