View Javadoc

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.portals.bridges.jsf;
17  
18  import javax.faces.FacesException;
19  import javax.faces.context.FacesContext;
20  import javax.faces.context.FacesContextFactory;
21  import javax.faces.lifecycle.Lifecycle;
22  import javax.portlet.PortletContext;
23  import javax.portlet.PortletRequest;
24  import javax.portlet.PortletResponse;
25  
26  /***
27   * <p>
28   * Loads the {@link PortletFacesContextImpl}
29   * </p>
30   * 
31   * @author <a href="dlestrat@apache.org">David Le Strat </a>
32   */
33  public class FacesContextFactoryImpl extends FacesContextFactory
34  {
35      /***
36       * @see javax.faces.context.FacesContextFactory#getFacesContext(java.lang.Object,
37       *      java.lang.Object, java.lang.Object, javax.faces.lifecycle.Lifecycle)
38       */
39      public FacesContext getFacesContext(Object context, Object request, Object response, Lifecycle lifecycle) 
40              throws FacesException
41      {       
42          if (context instanceof PortletContext)
43          {
44              PortletFacesContextImpl facesContext = new PortletFacesContextImpl( 
45                      (PortletContext) context,  
46                      (PortletRequest) request,
47                      (PortletResponse) response);
48              return facesContext;
49          }
50          else
51          {
52              throw new FacesException("Unsupported context type " + context.getClass().getName());
53          }
54      }
55  }