Details
-
Type: Bug
-
Status: Closed
-
Priority: Major
-
Resolution: Fixed
-
Affects Version/s: 3.2
-
Fix Version/s: 3.3
-
Component/s: Push Library
-
Labels:None
-
Environment:ICEpush, ICEfaces, JSP
Description
-
Hide
- simple.war
- 2.90 MB
- Ted Goddard
-
- pushall.jsp 0.2 kB
- pushed.jsp 0.3 kB
- pushed.xhtml 0.4 kB
- pushit.xhtml 0.4 kB
- region.jsp 0.1 kB
- WEB-INF/classes/org/.../mobi/alert/.DS_Store 6 kB
- WEB-INF/classes/org/.../admin/MinBean.class 0.9 kB
- WEB-INF/classes/org/.../admin/MinBean.java 0.6 kB
- WEB-INF/faces-config.xml 0.3 kB
- WEB-INF/lib/icefaces.jar 329 kB
- WEB-INF/lib/icepush.jar 342 kB
- WEB-INF/lib/javax.faces.jar 2.47 MB
- WEB-INF/web.xml 2 kB
Activity
- All
- Comments
- History
- Activity
- Remote Attachments
- Subversion
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).
— 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;
- icepush/core/src/main/java/org/icepush/servlet/ICEpushServlet.java (revision 33350)
-
@@ -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;
- icepush/core/src/main/java/org/icepush/servlet/MainServlet.java (revision 33350)
-
+ public synchronized static MainServlet getInstance(ServletContext context) {
+ MainServlet mainServlet = (MainServlet) context
+ .getAttribute(MainServlet.class.getName());
+ if (null == mainServlet)
+ return mainServlet;
+ }
+
public MainServlet(final ServletContext context)
MainServlet.getInstance() is now used rather than the MainServlet constructor for initializing ICEpush.
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.