IBM WebSphere DataPower Community Forum IBM Webspere DataPower XI50
October 07, 2008, 08:04:14 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: IBM WebSphere DataPower SOA Appliance Forum - Just Launched come share your knowledge!!! These forums will be a great place to build a community. This site is not associated with IBM.
 
   Home   Help Search Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: JAXP: XSLT coprocessor  (Read 154 times)
erik
Newbie
*
Offline Offline

Posts: 4


View Profile
« on: June 26, 2008, 04:07:50 PM »

Hello,

I'm using JAXP (Java XML Transformation API) in my java application. It delegates XSLT transformations to datapower via JAXP.

I'm able to do it, but I have several and random errors when running a load test.

I'm setting the attributes XAIp and XAPort (datapower ip and port) in the TransformationFactory.

Is connection pooling enabled by default? is there any other setting that I must set to optimize?

Thanks,

Erik Bengtson
Logged
erik
Newbie
*
Offline Offline

Posts: 4


View Profile
« Reply #1 on: June 27, 2008, 08:29:32 AM »

Never mind. I found it.

I will post a sample code ASAP.
Logged
erik
Newbie
*
Offline Offline

Posts: 4


View Profile
« Reply #2 on: July 07, 2008, 07:07:21 AM »

Code:
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.StringReader;
import java.io.StringWriter;

import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;

import com.datapower.xml.xslt.xa.xaConnectionException;
import com.datapower.xml.xslt.xa.xaTransformerConfigurationException;

public class Test
{
public static int errorcount = 0;
private static final class Tranform implements Runnable
{
private final StreamResult result;
private final StreamSource xml;
private final TransformerFactory factory;

private Tranform(StreamResult result, TransformerFactory factory, StreamSource xml)
{
this.result = result;
this.factory = factory;
this.xml = xml;
}

public void run()
{
StreamSource xslt = new StreamSource(new File("./AddressTransform.xsl"));
try
{

Transformer t = factory.newTransformer(xslt);
t.transform(xml, result);
}
catch (xaConnectionException e)
{
errorcount++;
// retry, probably connection exhausted
e.printStackTrace();

}
catch (xaTransformerConfigurationException e)
{
errorcount++;
// retry, probably connection exhausted
e.printStackTrace();
}
catch (TransformerException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}

public static void main(String[] args) throws Exception
{

final TransformerFactory factory = com.datapower.xml.xslt.xa.xaTransformerFactory.newInstance();
factory.setAttribute("XAIP", "10.0.0.1");
factory.setAttribute("XAPort", "7050");
factory.setAttribute("XADebug", "true");
factory.setAttribute("XAForceRefresh", "true");
factory.setAttribute("XAValidate", "true");
//factory.setAttribute("XAClientId", "none");
//factory.setAttribute("XAStylesheetTimeout", "5000");

factory.setAttribute("XAConnectionLimits", "5:40");
StringWriter writer = new StringWriter();
final StreamResult result = new StreamResult(writer);
int count = 10;
long start = System.currentTimeMillis();
Thread[] t = new Thread[count];

for (int i = 0; i < count; i++)
{
String s = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"+
"<address:getAddressInfo xmlns:address=\"http://something\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://something AddressMsg.xsd\">"+
"<address:name>"+
"<address:title>Mr.</address:title>"+
"<address:firstName>Mary"+i+"</address:firstName>"+
"<address:lastName>Lou</address:lastName>"+
"</address:name>"+
"</address:getAddressInfo>";
//StreamSource xml = new StreamSource(new File("./AddressReq.xml"));
StreamSource xml = new StreamSource(new StringReader(s));

t[i] = new Thread(new Tranform(result, factory, xml));
}
for (int i = 0; i < count; i++)
{
t[i].start();
}
for (int i = 0; i < count; i++)
{
t[i].join();
}
System.out.println(writer.getBuffer().toString());
System.out.println("Execution time "+(System.currentTimeMillis()-start)+" ms. Number of errors "+errorcount);

System.out.flush();
}
}
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  



Powered by SMF | SMF © 2006-2007, Simple Machines LLC
Seo4Smf © Webmaster's Talks
This Site is not associated with IBM