For your servlet proxy to correctly render and pass through your code, you implement a
Java™ interface class that is contained in the
TririgaCustomTask.jar file.
About this task
The com.tririga.custom package is the only package that you can use to
create an implementation class. The class must be unique. You can have only one
IConnect
implementation class per ClassLoader record. The ClassLoader record
name and the Java class that implements
IConnect
must have the same name. For example, if your class is named
MyFirstConnector
, then you must also identify your ClassLoader record with the
name MyFirstConnector
.
After you configure your servlet proxy, you can access the connector.
-
Create a Java class in the
com.tririga.custom package.
For example, you create a class that is named
MyFirstConnector
.
-
Implement the com.tririga.pub.adapter.IConnect
Java interface through the
execute
method in the IConnect
class.
For example, if your class is named
MyFirstConnector
, you create the
following
code:
public class MyFirstConnector implements IConnect {
public void execute(TririgaWS tws, HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
//your code goes here
}
}
This
example has a handle to a
TririgaWS
interface class. This class is the Java interface for the
IBM
TRIRIGA Connector for Business Applications API. The example also shows a
basic request and response that you would normally have in a Java servlet.
-
Add your code to the
execute
method where it says //your code goes
here
.
Continuing with the example, to print a web page (
.html) with the
words "Hello World", you insert the following
code:
PrintWriter out = response.getWriter();
try{
response.setContentType("text/html");
out.println("<html><head></head><body marginwidth='0' marginheight='0'
style='margin:0;padding:0;border:0;'>");
out.print("Hello World");
out.println("</body></html>");
out.flush();
} finally {
if(out!=null)out.close();
}
-
Compile your Java class and add it to a
.jar file.
For example, you compile your MyFirstConnector
class and add it to a
.jar file that is named
MyFirstConnector.jar.
-
Go to .
-
Add your ClassLoader record.
For example, add your ClassLoader record with the name
MyFirstConnector
.
-
In the record, add a resource file so you can upload your
MyFirstConnector.jar file.
-
Save the record.