1 /*
2 * $Id$
3 *
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
19 * under the License.
20 */
21
22 package org.apache.tiles.servlet.context;
23
24 import org.apache.tiles.Initializable;
25 import org.apache.tiles.TilesApplicationContext;
26 import org.apache.tiles.context.AbstractTilesApplicationContextFactory;
27 import org.apache.tiles.context.TilesContextFactory;
28 import org.apache.tiles.context.TilesRequestContext;
29 import org.apache.tiles.context.TilesRequestContextFactory;
30
31 import javax.servlet.ServletContext;
32 import java.util.Map;
33
34 /**
35 * Creates an instance of the appropriate TilesApplicationContext
36 * implementation.
37 *
38 * @version $Rev$ $Date$
39 * @deprecated Use {@link ServletTilesApplicationContext} or
40 * {@link ServletTilesRequestContext}.
41 */
42 /**
43 * @author PTRNTN77A26E506O
44 *
45 */
46 /**
47 * @author PTRNTN77A26E506O
48 *
49 */
50 /**
51 * @author PTRNTN77A26E506O
52 *
53 */
54 @Deprecated
55 public class ServletTilesContextFactory implements TilesContextFactory {
56
57 /**
58 * The application context factory.
59 */
60 private AbstractTilesApplicationContextFactory contextFactory;
61
62 /**
63 * The request context factory.
64 */
65 private TilesRequestContextFactory requestContextFactory;
66
67 /**
68 * Constructor.
69 *
70 * @deprecated Do not use! No replacement.
71 */
72 @Deprecated
73 public ServletTilesContextFactory() {
74 contextFactory = new ServletTilesApplicationContextFactory();
75 requestContextFactory = new ServletTilesRequestContextFactory();
76 }
77
78 /** {@inheritDoc} */
79 public void init(Map<String, String> configParameters) {
80 if (contextFactory instanceof Initializable) {
81 ((Initializable) contextFactory).init(configParameters);
82 }
83 requestContextFactory.init(configParameters);
84 }
85
86 /** {@inheritDoc} */
87 public TilesApplicationContext createApplicationContext(Object context) {
88 return contextFactory.createApplicationContext(context);
89 }
90
91 /** {@inheritDoc} */
92 public TilesRequestContext createRequestContext(TilesApplicationContext context,
93 Object... requestItems) {
94 return requestContextFactory
95 .createRequestContext(context, requestItems);
96 }
97
98 /**
99 * Returns the original servlet context.
100 *
101 * @param context The application context.
102 * @return The original servlet context, if found.
103 * @deprecated Use {@link TilesApplicationContext#getContext()}.
104 */
105 @Deprecated
106 protected ServletContext getServletContext(TilesApplicationContext context) {
107 if (context instanceof ServletTilesApplicationContext) {
108 ServletTilesApplicationContext app = (ServletTilesApplicationContext) context;
109 return app.getServletContext();
110 }
111 return null;
112
113 }
114 }