ICEpush
  1. ICEpush
  2. PUSH-217

ICEpush coexistence for JSF and JSP

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 3.2
    • Fix Version/s: 3.3
    • Component/s: Push Library
    • Labels:
      None
    • Environment:
      ICEpush, ICEfaces, JSP

      Description

      ICEpush should support push for both JSF and JSP pages in the same application. A recent test shows that push no longer functions when both are active.

        Activity

        Ted Goddard created issue -
        Ted Goddard made changes -
        Field Original Value New Value
        Attachment simple.war [ 15426 ]
        Ted Goddard made changes -
        Attachment simple.war [ 15426 ]
        Ted Goddard made changes -
        Attachment simple.war [ 15427 ]
        Ted Goddard made changes -
        Attachment simple.war [ 15428 ]
        Ted Goddard made changes -
        Attachment simple.war [ 15427 ]
        Hide
        Ted Goddard added a comment - - edited

        Pages to be updated via push:

        http://localhost:8080/simple/pushed.jsp
        http://localhost:8080/simple/pushed.jsf

        Pages initiating update via push:

        http://localhost:8080/simple/pushall.jsp (simply load to cause push)
        http://localhost:8080/simple/pushit.jsf (press button to push)

        If the FacesServlet is commented out in web.xml, then the pure JSP example will function. If org.icepush.servlet.ICEpushServlet is commented out, JSF will function. It appears that JSF is also loaded automatically even if the servlet is not registered if a JSF page is fetched.

        Show
        Ted Goddard added a comment - - edited Pages to be updated via push: http://localhost:8080/simple/pushed.jsp http://localhost:8080/simple/pushed.jsf Pages initiating update via push: http://localhost:8080/simple/pushall.jsp (simply load to cause push) http://localhost:8080/simple/pushit.jsf (press button to push) If the FacesServlet is commented out in web.xml, then the pure JSP example will function. If org.icepush.servlet.ICEpushServlet is commented out, JSF will function. It appears that JSF is also loaded automatically even if the servlet is not registered if a JSF page is fetched.
        Hide
        Ted Goddard added a comment -

        The issue lies with the instantiation of the ICEpush MainServlet. Modification to a getInstance() method rather than a constructor resolves this (where the MainServlet instance is stored as a ServletContext/application scope attribute).

        Show
        Ted Goddard added a comment - The issue lies with the instantiation of the ICEpush MainServlet. Modification to a getInstance() method rather than a constructor resolves this (where the MainServlet instance is stored as a ServletContext/application scope attribute).
        Hide
        Ted Goddard added a comment -

        — core/src/main/java/org/icefaces/impl/push/servlet/ICEpushResourceHandler.java (revision 33350)
        +++ core/src/main/java/org/icefaces/impl/push/servlet/ICEpushResourceHandler.java (working copy)
        @@ -38,7 +38,7 @@
        import javax.servlet.http.HttpServletRequest;
        import javax.servlet.http.HttpServletResponse;
        import java.io.IOException;
        -import java.lang.reflect.Constructor;
        +import java.lang.reflect.Method;
        import java.util.Arrays;
        import java.util.Collection;
        import java.util.Iterator;
        @@ -170,8 +170,11 @@
        if (mainServlet == null) {
        Class mainServletClass = (Class) ExtensionRegistry.getBestExtension(servletContext, "org.icepush.MainServlet");
        try {

        • Constructor mainServletConstructor = mainServletClass.getConstructor(new Class[] {ServletContext.class});
          - mainServlet = (MainServlet) mainServletConstructor.newInstance(servletContext);
          + Method mainServletGet = mainServletClass
          + .getMethod("getInstance",
          + new Class[]{ServletContext.class}

          );
          + mainServlet = (MainServlet) mainServletGet
          + .invoke(null, servletContext);
          } catch (Exception e) {
          log.log(Level.SEVERE, "Cannot instantiate extension org.icepush.MainServlet.", e);
          throw new RuntimeException(e);
          Index: icepush/core/src/main/java/org/icepush/servlet/ICEpushServlet.java
          ===================================================================

            • icepush/core/src/main/java/org/icepush/servlet/ICEpushServlet.java (revision 33350)
              +++ icepush/core/src/main/java/org/icepush/servlet/ICEpushServlet.java (working copy)
              @@ -25,7 +25,7 @@
              import javax.servlet.http.HttpServletRequest;
              import javax.servlet.http.HttpServletResponse;
              import java.io.IOException;
              -import java.lang.reflect.Constructor;
              +import java.lang.reflect.Method;
              import java.util.logging.Level;
              import java.util.logging.Logger;

        @@ -38,8 +38,10 @@
        ServletContext servletContext = servletConfig.getServletContext();
        Class mainServletClass = (Class) ExtensionRegistry.getBestExtension(servletContext, "org.icepush.MainServlet");
        try {

        • Constructor mainServletConstructor = mainServletClass.getConstructor(new Class[] {ServletContext.class});
          - mainServlet = (PseudoServlet) mainServletConstructor.newInstance(servletContext);
          + Method mainServletGet = mainServletClass.getMethod("getInstance",
          + new Class[]{ServletContext.class}

          );
          + mainServlet = (PseudoServlet) mainServletGet
          + .invoke(null, servletContext);
          } catch (Exception e) {
          Log.log(Level.SEVERE, "Cannot instantiate extension org.icepush.MainServlet.", e);
          throw new ServletException(e);
          Index: icepush/core/src/main/java/org/icepush/servlet/MainServlet.java
          ===================================================================

            • icepush/core/src/main/java/org/icepush/servlet/MainServlet.java (revision 33350)
              +++ icepush/core/src/main/java/org/icepush/servlet/MainServlet.java (working copy)
              @@ -47,6 +47,16 @@
              protected Configuration configuration;
              protected boolean terminateConnectionOnShutdown;

        + public synchronized static MainServlet getInstance(ServletContext context) {
        + MainServlet mainServlet = (MainServlet) context
        + .getAttribute(MainServlet.class.getName());
        + if (null == mainServlet)

        { + mainServlet = new MainServlet(context); + context.setAttribute(MainServlet.class.getName(), mainServlet); + }

        + return mainServlet;
        + }
        +
        public MainServlet(final ServletContext context)

        { this(context, true); }
        Show
        Ted Goddard added a comment - — core/src/main/java/org/icefaces/impl/push/servlet/ICEpushResourceHandler.java (revision 33350) +++ core/src/main/java/org/icefaces/impl/push/servlet/ICEpushResourceHandler.java (working copy) @@ -38,7 +38,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; -import java.lang.reflect.Constructor; +import java.lang.reflect.Method; import java.util.Arrays; import java.util.Collection; import java.util.Iterator; @@ -170,8 +170,11 @@ if (mainServlet == null) { Class mainServletClass = (Class) ExtensionRegistry.getBestExtension(servletContext, "org.icepush.MainServlet"); try { Constructor mainServletConstructor = mainServletClass.getConstructor(new Class[] {ServletContext.class}); - mainServlet = (MainServlet) mainServletConstructor.newInstance(servletContext); + Method mainServletGet = mainServletClass + .getMethod("getInstance", + new Class[]{ServletContext.class} ); + mainServlet = (MainServlet) mainServletGet + .invoke(null, servletContext); } catch (Exception e) { log.log(Level.SEVERE, "Cannot instantiate extension org.icepush.MainServlet.", e); throw new RuntimeException(e); Index: icepush/core/src/main/java/org/icepush/servlet/ICEpushServlet.java =================================================================== icepush/core/src/main/java/org/icepush/servlet/ICEpushServlet.java (revision 33350) +++ icepush/core/src/main/java/org/icepush/servlet/ICEpushServlet.java (working copy) @@ -25,7 +25,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; -import java.lang.reflect.Constructor; +import java.lang.reflect.Method; import java.util.logging.Level; import java.util.logging.Logger; @@ -38,8 +38,10 @@ ServletContext servletContext = servletConfig.getServletContext(); Class mainServletClass = (Class) ExtensionRegistry.getBestExtension(servletContext, "org.icepush.MainServlet"); try { Constructor mainServletConstructor = mainServletClass.getConstructor(new Class[] {ServletContext.class}); - mainServlet = (PseudoServlet) mainServletConstructor.newInstance(servletContext); + Method mainServletGet = mainServletClass.getMethod("getInstance", + new Class[]{ServletContext.class} ); + mainServlet = (PseudoServlet) mainServletGet + .invoke(null, servletContext); } catch (Exception e) { Log.log(Level.SEVERE, "Cannot instantiate extension org.icepush.MainServlet.", e); throw new ServletException(e); Index: icepush/core/src/main/java/org/icepush/servlet/MainServlet.java =================================================================== icepush/core/src/main/java/org/icepush/servlet/MainServlet.java (revision 33350) +++ icepush/core/src/main/java/org/icepush/servlet/MainServlet.java (working copy) @@ -47,6 +47,16 @@ protected Configuration configuration; protected boolean terminateConnectionOnShutdown; + public synchronized static MainServlet getInstance(ServletContext context) { + MainServlet mainServlet = (MainServlet) context + .getAttribute(MainServlet.class.getName()); + if (null == mainServlet) { + mainServlet = new MainServlet(context); + context.setAttribute(MainServlet.class.getName(), mainServlet); + } + return mainServlet; + } + public MainServlet(final ServletContext context) { this(context, true); }
        Ted Goddard made changes -
        Assignee Ted Goddard [ ted.goddard ]
        Repository Revision Date User Message
        ICEsoft Public SVN Repository #33363 Thu Feb 07 15:55:50 MST 2013 ted.goddard MainServlet.getInstance for shared JSF JSP ICEpush (PUSH-217)
        Files Changed
        Commit graph MODIFY /icepush/trunk/icepush/core/src/main/java/org/icepush/servlet/MainServlet.java
        Commit graph MODIFY /icepush/trunk/icepush/core/src/main/java/org/icepush/servlet/ICEpushServlet.java
        Repository Revision Date User Message
        ICEsoft Public SVN Repository #33364 Thu Feb 07 15:56:04 MST 2013 ted.goddard MainServlet.getInstance for shared JSF JSP ICEpush (PUSH-217)
        Files Changed
        Commit graph MODIFY /icefaces3/trunk/icefaces/core/src/main/java/org/icefaces/impl/push/servlet/ICEpushResourceHandler.java
        Hide
        Ted Goddard added a comment -

        MainServlet.getInstance() is now used rather than the MainServlet constructor for initializing ICEpush.

        Show
        Ted Goddard added a comment - MainServlet.getInstance() is now used rather than the MainServlet constructor for initializing ICEpush.
        Ted Goddard made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Ken Fyten made changes -
        Status Resolved [ 5 ] Closed [ 6 ]

          People

          • Assignee:
            Ted Goddard
            Reporter:
            Ted Goddard
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: