01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */package org.apache.geronimo.jetty6.cluster;
17:
18: import org.apache.geronimo.clustering.SessionManager;
19: import org.apache.geronimo.gbean.GBeanInfo;
20: import org.apache.geronimo.gbean.GBeanInfoBuilder;
21: import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
22: import org.apache.geronimo.jetty6.PreHandler;
23: import org.apache.geronimo.jetty6.SessionHandlerFactory;
24: import org.mortbay.jetty.servlet.SessionHandler;
25:
26: /**
27: *
28: * @version $Rev$ $Date$
29: */
30: public class ClusteredSessionHandlerFactory implements
31: SessionHandlerFactory {
32: private final SessionManager sessionManager;
33:
34: public ClusteredSessionHandlerFactory(SessionManager sessionManager) {
35: this .sessionManager = sessionManager;
36: }
37:
38: public SessionHandler createHandler(PreHandler preHandler) {
39: ClusteredSessionManager clusteredSessionManager = new ClusteredSessionManager(
40: sessionManager);
41: return new ClusteredSessionHandler(clusteredSessionManager,
42: preHandler);
43: }
44:
45: public static final GBeanInfo GBEAN_INFO;
46:
47: public static final String GBEAN_REF_SESSION_MANAGER = "SessionManager";
48:
49: static {
50: GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(
51: "Clustered Web Application Handler Factory",
52: ClusteredSessionHandlerFactory.class,
53: NameFactory.GERONIMO_SERVICE);
54:
55: infoFactory.addReference(GBEAN_REF_SESSION_MANAGER,
56: SessionManager.class, NameFactory.GERONIMO_SERVICE);
57:
58: infoFactory.addInterface(SessionHandlerFactory.class);
59:
60: infoFactory
61: .setConstructor(new String[] { GBEAN_REF_SESSION_MANAGER });
62:
63: GBEAN_INFO = infoFactory.getBeanInfo();
64: }
65:
66: public static GBeanInfo getGBeanInfo() {
67: return GBEAN_INFO;
68: }
69: }
|