jfarcand wrote:Can you elaboare more? Normally old application should still work as it is.
I am using GlassFish3 and am deploying my website as an OSGi bundle. I've had push working from PF 3.4 and PF 4.0.
In my application I declare a p:socket on a template page that all pages share as follows:
Code: Select all
<p:socket widgetVar="messageSocket" channel="#{pushChannelConstants.messageChannel}" onMessage="messageRouterFunction" autoConnect="false"/>
I handle connecting via the socket in a separate Javascript file.
My web.xml has the following items pertaining to push:
Code: Select all
<!-- This is for the required servlet for PrimeFaces push. -->
<servlet>
<servlet-name>Push Servlet</servlet-name>
<servlet-class>org.primefaces.push.PushServlet</servlet-class>
<!-- This appears to be a new option as of atmosphere 1.0.12. The property specifies
if order of message delivered to the client is not important. Default is false. -->
<init-param>
<param-name>org.atmosphere.cpr.Broadcaster.supportOutOfOrderBroadcast</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>org.atmosphere.cpr.broadcasterCacheClass</param-name>
<param-value>org.atmosphere.cache.UUIDBroadcasterCache</param-value>
</init-param>
<init-param>
<param-name>org.atmosphere.cpr.AtmosphereInterceptor</param-name>
<param-value>org.atmosphere.client.TrackMessageSizeInterceptor</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
<async-supported>true</async-supported>
</servlet>
<servlet-mapping>
<servlet-name>Push Servlet</servlet-name>
<url-pattern>/primepush/*</url-pattern>
</servlet-mapping>
And in my server side code I use the PushContext to send out messages to the channel defined above.
On my switch from PF 4.0 to PF 5.0, I swapped out the jars for PF 4.0 and Atmosphere 2.0.2 with PF 5.0 and Atmosphere 2.1.3. I have not updated the code to have a PushEndpoint. When I try to run the web bundle on loading of the bundle I see a warning that says "No Annotated class using @PushEndpoint found. Push will not work.".
When trying to perform actions on the web pages, none of the push aspects work. I do not see any of the messages being pushed to my browser when I try to debug, but I do not see any kind of server errors.
In the PushServlet class in PF 3.4 and PF 4.0, it appears that a PrimeAtmosphereHandler is registered automatically. Below is the snippet of the PF 4.0 PushServlet:
Code: Select all
public class PushServlet extends AtmosphereServlet
{
private final Logger logger = Logger.getLogger(PushServlet.class.getName());
public static final String RULES = "org.primefaces.push.rules";
public void init(ServletConfig sc)
throws ServletException
{
PushContext c = PushContextFactory.getDefault().getPushContext();
if (PushContextImpl.class.isAssignableFrom(c.getClass())) {
framework().asyncSupportListener((AsyncSupportListener)PushContextImpl.class.cast(c));
}
super.init(sc);
this.framework.interceptor(new AtmosphereResourceLifecycleInterceptor()).interceptor(new HeartbeatInterceptor()).interceptor(new TrackMessageSizeInterceptor()).interceptor(new SuspendTrackerInterceptor()).addAtmosphereHandler("/*", new PrimeAtmosphereHandler(configureRules(sc))).initAtmosphereHandler(sc);
}
In the PF 5.0 jar, I could not find any sort of registering for this handler. I suspect that is why I am not seeing any of the push messages and why I see the server error. So my question basically is, do I have to have an @PushEndpoint or is there a way that I can register the PrimeAtmosphereHandler to see if that fixes my problem? Ultimately, my confusion stems from the fact that the migration guide indicates that the PushContext is deprecated. I was assuming that Push would at least work for the time being for the upgrade and then I could work on restructuring my code to use an @PushEndpoint.