ServletContext servletContext )
{
String uri = InternalUtils.getDecodedServletPath( request );
assert uri.charAt( 0 ) == '/' : uri;
String backingClassName = FileUtils.stripFileExtension( uri.substring( 1 ).replace( '/', '.' ) );
FacesBackingBean currentBean = InternalUtils.getFacesBackingBean( request );
//
// If there is no current backing bean, or if the current one doesn't match the desired classname, create one.
//
if ( currentBean == null || ! currentBean.getClass().getName().equals( backingClassName ) )
{
FacesBackingBean bean = null;
if ( FileUtils.uriEndsWith( uri, FACES_EXTENSION ) || FileUtils.uriEndsWith( uri, JSF_EXTENSION ) )
{
bean = loadFacesBackingBean( request, servletContext, backingClassName );
//
// If we didn't create (or failed to create) a backing bean, and if this is a JSF request, then create
// a default one. This ensures that there will be a place for things like page inputs, that get stored
// in the backing bean across postbacks to the same JSF.
//
if ( bean == null ) bean = new DefaultFacesBackingBean();
//
// If we created a backing bean, invoke its create callback, and tell it to store itself in the session.
//
if ( bean != null )
{
try
{
bean.create( request, response, servletContext );
}
catch ( Exception e )
{
_log.error( "Error while creating backing bean instance of " + backingClassName, e );
}
bean.persistInSession( request, response );
return bean;
}
}
//