Class for Outcomes: StreamServletRealTimePlugin
Reference for the StreamServletRealTimePlugin
class, used for sending Outcome data to the Web Service connector.
Editing the Streams servlet web.xml
To make a plugin executable, you must edit the Streams servlet web.xml
file.
The Streams servlet web.xml
file is located under your Opportunity Detect run time installation in the following path:
RealTimeConnector/wlp/usr/servers/RealTimeConnector/dropins/RealTimeConnector/WEB-INF
.
Add the StreamServletRealTimePlugin class name to the following section of the Streams servlet web.xml
file, as follows. Note that line breaks have been added to fit the example on the page.
<init-param>
<param-name>PluginClassNames</param-name>
<param-value>com.ibm.unica.detect.interact.servlet.
StreamServletRealTimePluginImpl.com.company.ClassName</param-value>
</init-param>
Code examples
Your plugin must implement the StreamServletRealTimePlugin
interface, which has only one function: processRealtimeResponse
.
Here is an example of code that implements the interface.
package com.ibm.unica.detect.interact.servlet;
import java.util.Map;
@SuppressWarnings("rawtypes")
public interface StreamServletRealTimePlugin {
public void processRealTimeResponse(
final String audienceId,
final String audienceLevel,
final String componentId,
final long timestamp,
final Map response);
}
Here is an example of a plugin implementation that prints all output parameters into the servlet log file.
package com.ibm.unica.detect.interact.servlet;
import java.util.Map;
import org.apache.log4j.Logger;
@SuppressWarnings("rawtypes")
public class StreamServletRealTimePluginImpl
implements StreamServletRealTimePlugin {
private static Logger logger =
Logger.getLogger(StreamServletRealTimePluginImpl.class);
public void processRealTimeResponse(
final String audienceId,
final String audienceLevel,
final String componentId,
final long timestamp,
final Map response)
{
logger.info("audienceLevel: " + audienceLevel + ";
audienceId: " + audienceId + ";
componentId: " + componentId + ";
timestamp: " + timestamp + ";
processRealTimeResponse: " + response);
}
}