Use of url-pattern in Push servlet mapping

UI Components for JSF
Post Reply
Jeremy Pool
Posts: 2
Joined: 18 Nov 2013, 20:37

16 Jul 2014, 17:06

I am seeking clarification on the role of the <url-pattern> specification in the <servlet-mapping> descriptor for the Push Servlet, and the relationship, if any, between the url-pattern and the names of channels used in eventBus publishing. I have built a proof-of-concept PF Push example that works fine, and, following examples seen elsewhere, used the following <servlet-mapping> descriptor for the Push Servlet:

Code: Select all

  <servlet-mapping>
	<servlet-name>Push Servlet</servlet-name>
	<url-pattern>/primepush/*</url-pattern>
  </servlet-mapping>
In my application code I publish Push messages using the following kind of call:

Code: Select all

		EventBus eventBus = EventBusFactory.getDefault().eventBus();
		eventBus.publish("/clock", clock_val);
and the receiving xhtml page specifies the same "/clock" channel:

Code: Select all

		<p:socket onMessage="handleMessage" channel="/clock" />
This all works fine. What I don't understand is the role, if any, of the "/primepush/*" url-pattern. It seems like I could specify any pattern here, and it would have no impact on the functioning of my small proof-of-concept app, where I am just pushing short String messages to a web page from a background thread to get asynchronous updates. In what situations does the url-pattern matter?

kukeltje
Expert Member
Posts: 9605
Joined: 17 Jun 2010, 13:34
Location: Netherlands

17 Jul 2014, 16:14

it's just as with normal servlets... You can, in those cases, also put whatever you want in there, as long as the client knows what to use. With the push framework, the client is automagically notified of the url, so it transparently works

Jeremy Pool
Posts: 2
Joined: 18 Nov 2013, 20:37

18 Jul 2014, 23:06

Thank you for, kukeltje, for the clarification. It still isn't completely clear to me in what situation you might actually need to pay attention to the Push Servlet mapping's url-pattern value. In my example, no code, either on the java side or the xhtml side, needs to specify a path that reflects the Push Servlet mapping's url-pattern path. (The channel, on the other hand, obviously has to be consistent in the various places that it is used: on the java side in the @PushEndPoint annotation and in the eventBus.publish calls, and on the xhtml side in the channel attribute of the <p:socket> tag.)

The two PrimeFaces Push examples in the PF 5 Users Guide also don't seem to make any use of the value (/primepush/*) specified as the url-pattern in the Push Servlet's mapping shown near the beginning of the PF Push section of the Guide (p.526). There is only one other place in the Users Guide where the string "primepush" is found, and this is on p.534 in the discussion of proxies in the "Tips & Tricks" part of the PF Push documentation. Maybe this example relates to my question, but I don't really understand the point being made in this section.

smithh032772
Posts: 6144
Joined: 10 Sep 2011, 21:10

19 Jul 2014, 15:55

PrimeFaces Push = atmosphere

So, click URL below and read as much as possible on the atmosphere wiki.

https://github.com/Atmosphere/atmospher ... -WebSocket
Howard

PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome

Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache

kukeltje
Expert Member
Posts: 9605
Joined: 17 Jun 2010, 13:34
Location: Netherlands

24 Jul 2014, 21:36

Jeremy Pool wrote:here is only one other place in the Users Guide where the string "primepush" is found, and this is on p.534 in the discussion of proxies in the "Tips & Tricks" part of the PF Push documentation. Maybe this example relates to my question, but I don't really understand the point being made in this section.
Some reverse proxy servers cannot proxy the 'protocols' Athmosphere uses. So you have to 'bypass' the proxies then. In that case you can use a full url (including protocol and port) in that config part. The client will then use that full url instead of the relative path in the context of the application.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 45 guests