これはハックです。つまりServletConfig、基本的にはのパラメーターを含むオブジェクトServletです。インターフェイスには、実質的に同じメソッドと情報がありServletRegistrationます。したがって、構成パラメーターをそれ自体から引き出してServletContext、のカスタム実装に入力しても、すべて同じですServletConfig。これを試して:
ServletContextオブジェクトを取得する
FacesContext facesContext = FacesContext.getCurrentInstance();
ServletContext servletContext = (ServletContext) context.getExternalContext(); // Your servlet context here
サーブレット コンテキストから、目的のサーブレットのサーブレット登録オブジェクトを取得します
ServletRegistration reg = servletContext.getServletRegistration("theServlet"); //ServletRegistration contains all the info you'll need to populate a custom ServletConfig object
(2) から得た情報を使用して、のカスタム impl を設定します。ServletConfig
ServletConfig myServletConfig = new MyCustomServletConfig();
myServletConfig.setInitParams(reg.getInitParameters()); //do a simple transfer of content
最後のステップは単純化しすぎていますが、おわかりいただけると思います。
ServletContext#getServlet()以前のバージョンの Java EE (3.0 より前) を実行していた場合は、非推奨になった にアクセスできます。