01: /*
02: * Copyright 2004 The Apache Software Foundation.
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: */
16: package org.apache.myfaces.context;
17:
18: import org.apache.myfaces.context.servlet.FacesContextImpl;
19:
20: import javax.faces.FacesException;
21: import javax.faces.context.FacesContext;
22: import javax.faces.context.FacesContextFactory;
23: import javax.faces.lifecycle.Lifecycle;
24: import javax.portlet.PortletContext;
25: import javax.portlet.PortletRequest;
26: import javax.portlet.PortletResponse;
27: import javax.servlet.ServletContext;
28: import javax.servlet.ServletRequest;
29: import javax.servlet.ServletResponse;
30:
31: /**
32: * DOCUMENT ME!
33: * @author Manfred Geiler (latest modification by $Author: matzew $)
34: * @version $Revision: 483860 $ $Date: 2006-12-08 08:08:05 +0100 (Fr, 08 Dez 2006) $
35: */
36: public class FacesContextFactoryImpl extends FacesContextFactory {
37: public FacesContext getFacesContext(Object context, Object request,
38: Object response, Lifecycle lifecycle) throws FacesException {
39: if (context == null) {
40: throw new NullPointerException("context");
41: }
42: if (request == null) {
43: throw new NullPointerException("request");
44: }
45: if (response == null) {
46: throw new NullPointerException("response");
47: }
48: if (lifecycle == null) {
49: throw new NullPointerException("lifecycle");
50: }
51:
52: if (context instanceof ServletContext) {
53: return new FacesContextImpl((ServletContext) context,
54: (ServletRequest) request,
55: (ServletResponse) response);
56: }
57:
58: if (context instanceof PortletContext) {
59: return new FacesContextImpl((PortletContext) context,
60: (PortletRequest) request,
61: (PortletResponse) response);
62: }
63:
64: throw new FacesException("Unsupported context type "
65: + context.getClass().getName());
66: }
67: }
|