Reputation: 714
I am attempting to create a Session Listener (and maybe later an application listener) for an xpage application running on 9.0.1. A google search did not present a lot of information, but did give a previous SO question.
As the answer of the question says, I created a file with the name "com.ibm.xsp.core.events.SessionListener". The sole content of this file is the full name
< package >.ClassName
of the class that implements
com.ibm.xsp.application.events.SessionListener
I already find it sort of odd that the two are not of the same package, but Ill let this pass for now.
Now is the question, where do I put the file. My classes are (for the moment) in the WebContent/WEB-INF/src folder which is added to the build path. Later, they will be a jar added to the project as a dependency. For right now, I am only concerned with getting it to work in the src folder.
I have tried to add a "folder" in WebContent/WEB-INF/src entitled "services" and to put the file there, no luck. I tried to put the services folder into the Code/Java folder (really unnecessary since it is just copied back into the WEB-INF folder). I tried to add it in WebContent/WEB-INF/services, no luck whether that folder was added to the build path or not, and I am really unsure what to try next.
The listener code is:
import java.io.Serializable;
import javax.servlet.http.HttpSessionEvent;
import com.ibm.xsp.application.ApplicationEx;
import com.ibm.xsp.application.events.SessionListener;
public class TestController implements SessionListener, Serializable{
/**
*
*/
private static final long serialVersionUID = 1L;
public void sessionCreated(ApplicationEx arg0, HttpSessionEvent arg1) {
System.out.println("in test session creation");
}
public void sessionDestroyed(ApplicationEx arg0, HttpSessionEvent arg1) {
System.out.println("in test session destruction");
}
}
Similarly, Id like to try to get an application listener up and running, but I have not tried that yet.
Upvotes: 1
Views: 292
Reputation: 491
As already mentioned, it needs to be in a META-INF folder - this works:
app1.nsf/Code/Java/META-INF/services/com.ibm.xsp.core.events.SessionListener
Also there's an issue tracked as SPR#RGAUA45NJA, where the SessionDestroyed methods on the SessionListener's aren't invoked. That's likely to be fixed in the next 9.0.1 FixPack (not fixed in FP5).
Upvotes: 1
Reputation: 2733
There is some similarity, IMO, to how the NSF hooks into the Domino server in the DesignerFacesServlet implementation I like to use. In that particular case, I'm registering a ServletFactory (local to my NSF); this registers in the NSF's /META-INF/services/com.ibm.xsp.adapter.servletFactory
file, which is stored in the Java source build path (generally NSF/Code/Java
or NSF/WEB-INF/src
, depending on which source location you're using). That file contains the fully qualified <package.ClassName> of the ServletFactory.
Here's a live example: https://github.com/edm00se/AnAppOfIceAndFire/blob/master/ODP/Code/Java/META-INF/services/com.ibm.xsp.adapter.servletFactory
The file's contents:
com.westeros.factory.ServletFactory
I'm sure someone with a better understanding of how the loading of NSF contents interacts with the Domino server could enlighten further.
Upvotes: 2