KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > myfaces > context > FacesContextFactoryImpl


1 /*
2  * Copyright 2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.ServletFacesContextImpl;
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 JavaDoc;
28 import javax.servlet.ServletRequest JavaDoc;
29 import javax.servlet.ServletResponse JavaDoc;
30
31 /**
32  * DOCUMENT ME!
33  * @author Manfred Geiler (latest modification by $Author: matzew $)
34  * @version $Revision: 1.12 $ $Date: 2005/01/26 17:03:10 $
35  */

36 public class FacesContextFactoryImpl
37         extends FacesContextFactory
38 {
39     public FacesContext getFacesContext(Object JavaDoc context,
40                                         Object JavaDoc request,
41                                         Object JavaDoc response,
42                                         Lifecycle lifecycle)
43             throws FacesException
44     {
45         if (context instanceof ServletContext JavaDoc)
46         {
47             return new ServletFacesContextImpl((ServletContext JavaDoc)context,
48                                                (ServletRequest JavaDoc)request,
49                                                (ServletResponse JavaDoc)response);
50         }
51         
52         if (context instanceof PortletContext)
53         {
54             return new ServletFacesContextImpl((PortletContext)context,
55                                                (PortletRequest)request,
56                                                (PortletResponse)response);
57         }
58         
59         throw new FacesException("Unsupported context type " + context.getClass().getName());
60     }
61 }
62
Popular Tags