In a tough ride of JAIN-SLEE it is hard to remember everything on tips, to overcome such Stoppers creating this blog so that can refer it further :)
Step1 -----------------------
Create a public class which implements Serializable //Serializable for your convenient
Step2 -----------------------
That class should contain following methods
a public constructor with the parameters you want to pass when you fire an event
a public boolean equals method to check your current object is equals with passed argument
a private long Id would be generated at random when ever constructor is called
a public int hashcode method to return hash code value
getter methods of constructor's parameters
Example
import java.io.Serializable;
import java.util.Random;
import org.apache.log4j.Logger;
public class XyzEvent implements Serializable {
private long id;
private boolean successfull;
private static final Logger logger = Logger.getLogger(XyzEvent.class);
public MFToneDetected(boolean successfull) {
id = new Random().nextLong() ^ System.currentTimeMillis();
this.successfull= successfull;
}
public boolean equals(Object o) {
if (o == this)
return true;
if (o == null)
return false;
return (o instanceof XyzEvent) && ((XyzEvent) o).id == id;
}
public int hashCode() {
return (int) id;
}
public long getId() {
return id;
}
public boolean isSuccessfull(){
return successfull;
}
}
Step3 ------------------------
Now create Its event-jar.xml
which would look like this
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE event-jar PUBLIC "-//Sun Microsystems, Inc.//DTD JAIN SLEE Event 1.0//EN"
"http://java.sun.com/dtd/slee-event-jar_1_0.dtd">
<event-jar>
<event-definition>
<description>Custome Event</description>
<event-type-name>XyzEvent</event-type-name>
<event-type-vendor>org.sachin</event-type-vendor>
<event-type-version>1.0</event-type-version>
<event-class-name>XyzEvent</event-class-name>
</event-definition>
</event-jar>
Description could be any thing which describes cause of this event
Where the combination of event-type-name, event-type-vendor, and event-type-version makes it unique, in other words it would be identified by these defined three fields
And class name would be the name of class for which we are creating this event
Thats all we are Done with creation of Custom event ;)
Step4 ------------------------
Now comes step how to fire it from Sbbs
1st add mentioned code in SBB from which you want to fire this event suppose FireCustomEventSampleSbb
add event in FireCustomEventSampleSbb's sbb-jar.xml
<event event-direction="Fire">
<event-name>XyzEvent</event-name>
<event-type-ref>
<event-type-name>XyzEvent</event-type-name>
<event-type-vendor>org.sachin</event-type-vendor>
<event-type-version>1.0</event-type-version>
</event-type-ref>
</event>
event-direction should be Fire here
2nd add mentioned code to fire event in FireCustomEventSampleSbb
define abstract declaration of event
public abstract void fireXyzEvent(XyzEvent event,
ActivityContextInterface aci, javax.slee.Address address);
add this code from where you want to fire it
XyzEvent xyzEvent = new XyzEvent(true); //pass the values mentioned in XyzEvent class's cunstructor
fireXyzEvent(xyzEvent, this.getCustomEventACI(), null); //reffer SLEE API for parameter details
Step5 ------------------------
Sbb which is Listening to this custome event suppose ListenCustomEventSampleSbb
add event in ListenCustomEventSampleSbb's sbb-jar.xml
<event event-direction="Receive" initial-event="False">
<event-name>XyzEvent</event-name>
<event-type-ref>
<event-type-name>XyzEvent</event-type-name>
<event-type-vendor>org.sachin</event-type-vendor>
<event-type-version>1.0</event-type-version>
</event-type-ref>
</event>
add event listener ListenCustomEventSampleSbb
public void onXyzEvent(XyzEvent event,
ActivityContextInterface aci) {
}