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
93
|
/*******************************************************************************
* 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.manager.servlet.internal;
import java.util.HashSet;
import java.util.Set;
import org.eclipse.osee.activity.api.ActivityLog;
import org.eclipse.osee.framework.core.data.OseeServerContext;
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.OseeHttpServlet;
import org.eclipse.osee.framework.manager.servlet.AdminServlet;
import org.eclipse.osee.framework.manager.servlet.SessionClientLoopbackServlet;
import org.eclipse.osee.framework.manager.servlet.SessionManagementServlet;
import org.eclipse.osee.logger.Log;
import org.osgi.framework.BundleContext;
import org.osgi.service.http.HttpService;
/**
* @author Roberto E. Escobar
*/
public class ServletRegistrationHandler {
private HttpService httpService;
private Log logger;
private ISessionManager sessionManager;
private IApplicationServerManager appServerManager;
private IAuthenticationManager authenticationManager;
private ActivityLog activityLog;
private final Set<String> contexts = new HashSet<>();
public void setSessionManager(ISessionManager sessionManager) {
this.sessionManager = sessionManager;
}
public void setAppServerManager(IApplicationServerManager appServerManager) {
this.appServerManager = appServerManager;
}
public void setAuthenticationManager(IAuthenticationManager authenticationManager) {
this.authenticationManager = authenticationManager;
}
public void setLogger(Log logger) {
this.logger = logger;
}
public Log getLogger() {
return logger;
}
public void setHttpService(HttpService httpService) {
this.httpService = httpService;
}
public synchronized void start(BundleContext context) {
ServletUtil.unregister(httpService, appServerManager, contexts);
registerServices(context);
}
public synchronized void stop() {
ServletUtil.unregister(httpService, appServerManager, contexts);
contexts.clear();
}
private void registerServices(BundleContext context) {
contexts.clear();
register(new SessionManagementServlet(logger, sessionManager, authenticationManager, activityLog),
OseeServerContext.SESSION_CONTEXT);
register(new SessionClientLoopbackServlet(logger, sessionManager), OseeServerContext.CLIENT_LOOPBACK_CONTEXT);
register(new AdminServlet(logger, context), "osee/console");
}
private void register(OseeHttpServlet servlet, String contexts) {
this.contexts.add(contexts);
ServletUtil.register(httpService, appServerManager, servlet, contexts);
}
public void setActivityLog(ActivityLog activityLog) {
this.activityLog = activityLog;
}
}
|