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
|
/*******************************************************************************
* Copyright (c) 2004, 2007 Boeing.
* 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:
* Boeing - initial API and implementation
*******************************************************************************/
package org.eclipse.osee.framework.core.server.internal.session;
import java.util.Map;
import org.eclipse.osee.framework.core.model.cache.IOseeDataAccessor;
import org.eclipse.osee.framework.core.server.IApplicationServerManager;
import org.eclipse.osee.framework.core.server.IAuthenticationManager;
import org.eclipse.osee.framework.core.server.ISessionManager;
import org.eclipse.osee.framework.core.server.internal.BuildTypeDataProvider;
import org.eclipse.osee.framework.core.server.internal.BuildTypeIdentifier;
import org.eclipse.osee.framework.core.util.AbstractTrackingHandler;
import org.eclipse.osee.framework.database.IOseeDatabaseService;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
/**
* @author Roberto E. Escobar
*/
public final class SessionManagerTrackingHandler extends AbstractTrackingHandler {
private static final Class<?>[] SERVICE_DEPENDENCIES = new Class<?>[] {IOseeDatabaseService.class,
IApplicationServerManager.class, IAuthenticationManager.class};
private ServiceRegistration registration;
private ISessionDataStoreSync dataStoreSync;
private ISessionManager sessionManager;
@Override
public Class<?>[] getDependencies() {
return SERVICE_DEPENDENCIES;
}
@Override
public void onActivate(BundleContext context, Map<Class<?>, Object> services) {
IOseeDatabaseService databaseService = getService(IOseeDatabaseService.class, services);
IApplicationServerManager serverManager = getService(IApplicationServerManager.class, services);
IAuthenticationManager authenticationManager = getService(IAuthenticationManager.class, services);
String serverId = serverManager.getId();
BuildTypeIdentifier identifier = new BuildTypeIdentifier(new BuildTypeDataProvider());
SessionFactory sessionFactory = new SessionFactory(identifier);
ISessionQuery sessionQuery = new DatabaseSessionQuery(serverId, databaseService);
IOseeDataAccessor<Session> accessor =
new DatabaseSessionAccessor(serverId, sessionFactory, sessionQuery, databaseService);
SessionCache sessionCache = new SessionCache(accessor);
sessionManager =
new SessionManagerImpl(serverId, sessionFactory, sessionQuery, sessionCache, authenticationManager);
registration = context.registerService(ISessionManager.class.getName(), sessionManager, null);
dataStoreSync = new SessionDataStoreSync(sessionCache);
dataStoreSync.start();
}
@Override
public void onDeActivate() {
if (registration != null) {
if (dataStoreSync != null) {
dataStoreSync.stop();
}
registration.unregister();
}
}
}
|