01: /*
02: *
03: * Copyright 2007 Florin T.PATRASCU
04: *
05: * Licensed under the Apache License, Version 2.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * 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: *
17: */
18:
19: package ca.flop.jpublish;
20:
21: import org.jpublish.JPublishContext;
22: import org.jpublish.action.Action;
23: import org.springframework.context.ApplicationContext;
24: import org.springframework.web.context.support.WebApplicationContextUtils;
25:
26: import javax.servlet.ServletContext;
27:
28: /**
29: * For simplicity it may be a good idea to make a base class that extends JPublish Actions,
30: * and make a method that will return the Spring ApplicationContext
31: *
32: * @author <a href="mailto:florin.patrascu@gmail.com">Florin T.PATRASCU</a>
33: * @since $Revision$ (created: Jul 17, 2006 10:21:29 PM)
34: */
35: public abstract class SpringActionSupport implements Action {
36: public static final String SPRING = "JPublishSpring";
37:
38: /**
39: * @param context the JPublish context
40: * @return a Spring application context
41: */
42: protected final ApplicationContext getApplicationContext(
43: JPublishContext context) {
44: ServletContext sc = context.getApplication();
45: return WebApplicationContextUtils
46: .getRequiredWebApplicationContext(sc);
47: }
48: }
|