01: /**
02: * Copyright 2006 Webmedia Group Ltd.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: **/package org.araneaframework.framework.router;
16:
17: import java.util.HashMap;
18: import java.util.Map;
19: import org.araneaframework.Environment;
20: import org.araneaframework.core.StandardEnvironment;
21: import org.araneaframework.framework.SessionServiceContext;
22:
23: /**
24: * A {@link org.araneaframework.framework.router.BaseServiceRouterService} which handles sessions.
25: * Enriches the environment with an object of this class under the key
26: * SessionServiceContext.class.
27: *
28: * @author "Toomas Römer" <toomas@webmedia.ee>
29: */
30: public class StandardSessionServiceRouterService extends
31: BaseServiceRouterService {
32: protected Environment getChildEnvironment(Object serviceId)
33: throws Exception {
34: Map entries = new HashMap();
35: entries.put(SessionServiceContext.class,
36: new ServiceRouterContextImpl(serviceId));
37: return new StandardEnvironment(super
38: .getChildEnvironment(serviceId), entries);
39: }
40:
41: private class ServiceRouterContextImpl extends
42: BaseServiceRouterService.ServiceRouterContextImpl implements
43: SessionServiceContext {
44: protected ServiceRouterContextImpl(Object serviceId) {
45: super (serviceId);
46: }
47: }
48:
49: protected Object getServiceKey() throws Exception {
50: return SessionServiceContext.SESSION_SERVICE_KEY;
51: }
52: }
|