public BridgePhaseBaseImpl(PortletConfig portletConfig, BridgeConfig bridgeConfig) {

    this.portletConfig = portletConfig;
    this.bridgeConfig = bridgeConfig;
    this.portletName = portletConfig.getPortletName();
    this.bridgeRequestScopePreserved =
        PortletConfigParam.BridgeRequestScopePreserved.getBooleanValue(portletConfig);

    this.portletContext =
        BridgePortletContextFactory.getPortletContextInstance(portletConfig.getPortletContext());

    // Initialize the incongruity context implementation.
    this.incongruityContext = IncongruityContextFactory.getIncongruityContextInstance();

    // Get the bridge request scope cache from the factory.
    this.bridgeRequestScopeCache =
        BridgeRequestScopeCacheFactory.getBridgeRequestScopeCacheInstance(portletContext);

    // Get the default lifecycle instance from the factory.
    LifecycleFactory lifecycleFactory =
        (LifecycleFactory) FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
    String lifecycleId = this.portletContext.getInitParameter(Bridge.LIFECYCLE_ID);

    if (lifecycleId == null) {
      lifecycleId = LifecycleFactory.DEFAULT_LIFECYCLE;
    }

    this.facesLifecycle = lifecycleFactory.getLifecycle(lifecycleId);
  }
  protected synchronized Lifecycle getFacesLifecycle() {
    if (lifecycle == null) {
      // Acquire our Lifecycle instance
      LifecycleFactory lifecycleFactory =
          (LifecycleFactory) FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
      lifecycle = lifecycleFactory.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
    }

    return lifecycle;
  }
Пример #3
0
  @Override
  public void init(ServletConfig servletConfig) throws ServletException {
    this.servletConfig = servletConfig;

    facesContextFactory =
        (FacesContextFactory) FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
    LifecycleFactory lifecycleFactory =
        (LifecycleFactory) FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
    lifecycle = lifecycleFactory.getLifecycle(getLifecycleId());
  }
  /**
   * Jsf dispatch page.
   *
   * @param fctx the faces context
   * @param page the pge
   */
  private void jsfDispatchPage(FacesContext fctx, String page) {
    LifecycleFactory lf =
        (LifecycleFactory) FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
    Lifecycle lifecycle = lf.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
    ViewHandler vh = fctx.getApplication().getViewHandler();
    fctx.getViewRoot().setRenderKitId(vh.calculateRenderKitId(fctx));
    fctx.setViewRoot(vh.createView(fctx, page));

    // view rendering
    try {
      lifecycle.render(fctx);
    } catch (Exception e) {
      LOG.log(Level.INFO, "Error while rendering page. Attempting again" + page, e);
      lifecycle.render(fctx);
    } finally {
      fctx.release();
    }
  }
Пример #5
0
  /**
   * Acquire the factory instances we will require.
   *
   * @throws ServletException if, for any reason, the startup of this Faces application failed. This
   *     includes errors in the config file that is parsed before or during the processing of this
   *     <code>init()</code> method.
   */
  public void init(ServletConfig servletConfig) throws ServletException {

    // Save our ServletConfig instance
    this.servletConfig = servletConfig;

    // Acquire our FacesContextFactory instance
    try {
      facesContextFactory =
          (FacesContextFactory) FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
    } catch (FacesException e) {
      ResourceBundle rb = LOGGER.getResourceBundle();
      String msg = rb.getString("severe.webapp.facesservlet.init_failed");
      Throwable rootCause = (e.getCause() != null) ? e.getCause() : e;
      LOGGER.log(Level.SEVERE, msg, rootCause);
      throw new UnavailableException(msg);
    }

    // Acquire our Lifecycle instance
    try {
      LifecycleFactory lifecycleFactory =
          (LifecycleFactory) FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
      String lifecycleId;

      // First look in the servlet init-param set
      if (null == (lifecycleId = servletConfig.getInitParameter(LIFECYCLE_ID_ATTR))) {
        // If not found, look in the context-param set
        lifecycleId = servletConfig.getServletContext().getInitParameter(LIFECYCLE_ID_ATTR);
      }

      if (lifecycleId == null) {
        lifecycleId = LifecycleFactory.DEFAULT_LIFECYCLE;
      }
      lifecycle = lifecycleFactory.getLifecycle(lifecycleId);
      initHttpMethodValidityVerification();
    } catch (FacesException e) {
      Throwable rootCause = e.getCause();
      if (rootCause == null) {
        throw e;
      } else {
        throw new ServletException(e.getMessage(), rootCause);
      }
    }
  }
Пример #6
0
  public boolean isOrderCorrect() {

    LifecycleFactory factory =
        (LifecycleFactory) FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
    Lifecycle l = factory.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
    PhaseListener[] listeners = l.getPhaseListeners();
    List<PhaseListener> list = new ArrayList<PhaseListener>();
    for (PhaseListener listener : listeners) {
      if (listener.getClass().getName().contains("com.sun.faces.systest.model.PhaseListener")) {
        list.add(listener);
      }
    }
    listeners = list.toArray(new PhaseListener[list.size()]);
    String[] suffixes = {"C", "B", "A", "D"};
    for (int i = 0; i < listeners.length; i++) {
      if (!listeners[i].getClass().getName().endsWith(suffixes[i])) {
        System.out.println("INCORRECT DOCUMENT ORDERING: " + Arrays.toString(listeners));
        return false;
      }
    }

    return true;
  }