public static URL locateContextConfig ( String webappRootContext , String userSpecifiedContextLocation , URL defaultLocation ) { // Assertions. if ( webappRootContext == null ) { String msg = "Argument 'webappRootContext' cannot be null." ; throw new IllegalArgumentException ( msg ) ; } // NB: Both 'userSpecifiedContextLocation' & 'defaultLocation' may be null URL rslt = null ; if ( userSpecifiedContextLocation != null ) { /* * SPECIAL HANDLING: We remove a leaving slash ('/') here because, when * no protocol is specified, the expectation is that the path is * evaluated from the root of the webapp ('webappRootContext'). If we * didn't, the ResourceHelper would incorrectly interpret these as the * root of the protocol, which is likely 'file:/' or 'jndi:/'. */ if ( userSpecifiedContextLocation . startsWith ( "/" ) ) { userSpecifiedContextLocation = userSpecifiedContextLocation . substring ( 1 ) ; } rslt = ResourceHelper . evaluate ( webappRootContext , userSpecifiedContextLocation ) ; } else { rslt = defaultLocation ; // may be null... } return rslt ; }
Locate the configuration file if present for a Portlet or Servlet .