[JBoss XML Binding Development] - performance test of fast jaxb, xb, jaxb
by alex.loubyansky@jboss.com
I've added JAXB to the mix. And also modified the test a bit.
There is ParsingCommand per framework (fast jaxb, xb and jaxb). run() method of each of them unmarshals Person object from the same person.xml one time.
These commands are executed one after the other. The time (in ms) is checked separately for the first run() and then for the next X repetitions.
The command executed first appears to do the "warm up" for the others (perhaps caching, classloading...). I.e. here are the results for the first run in different sequences:
fast jaxb - xb - jaxb:
fast jaxb total=123, avg=123.0
xb total=53, avg=53.0
jaxb total=9, avg=9.0
xb - fast jaxb - jaxb
fast jaxb total=7, avg=7.0
xb total=163, avg=163.0
jaxb total=9, avg=9.0
jaxb - xb - fast jaxb
fast jaxb total=7, avg=7.0
xb total=49, avg=49.0
jaxb total=127, avg=127.0
Here are the results for the next repetitions (i.e. not counting the first run) for sequence fast jaxb - xb - jaxb:
--- next 1 repetitions
fast jaxb total=2, avg=2.0
xb total=9, avg=9.0
jaxb total=3, avg=3.0
--- next 10 repetitions
fast jaxb total=15, avg=15.0
xb total=49, avg=49.0
jaxb total=38, avg=38.0
--- next 100 repetitions
fast jaxb total=106, avg=106.0
xb total=243, avg=243.0
jaxb total=177, avg=177.0
--- next 1000 repetitions
fast jaxb total=838, avg=838.0
xb total=1596, avg=1596.0
jaxb total=1368, avg=1368.0
So, apparently, fast jaxb is in fact the fastest (even in the first and worst warming up run).
For the protocol, here is the test code
private long perCommandReps = 1;
| public void testMixed() throws Exception
| {
| FastJaxbParsing fastJaxb = new FastJaxbParsing(perCommandReps);
| XBParsing xb = new XBParsing(perCommandReps);
| JAXBParsing jaxb = new JAXBParsing(perCommandReps);
|
| ParsingCommand[] c = new ParsingCommand[3];
| c[0] = fastJaxb;
| c[1] = xb;
| c[2] = jaxb;
|
| for(int j = 0; j < c.length; ++j)
| c[j].run();
|
| System.out.println("--- first run");
| System.out.println("fast jaxb total=" + fastJaxb.getTotal() + ", avg=" + fastJaxb.getAverage());
| System.out.println("xb total=" + xb.getTotal() + ", avg=" + xb.getAverage());
| System.out.println("jaxb total=" + jaxb.getTotal() + ", avg=" + jaxb.getAverage());
|
| for(int j = 0; j < c.length; ++j)
| c[j].reset();
|
| int repetitions = 1000;
| for(int i = 0; i < repetitions; ++i)
| {
| for(int j = 0; j < c.length; ++j)
| c[j].run();
| }
|
| System.out.println("--- next " + repetitions + " repetitions");
| System.out.println("fast jaxb total=" + fastJaxb.getTotal() + ", avg=" + fastJaxb.getAverage());
| System.out.println("xb total=" + xb.getTotal() + ", avg=" + xb.getAverage());
| System.out.println("jaxb total=" + jaxb.getTotal() + ", avg=" + jaxb.getAverage());
| }
|
| private static class JAXBParsing extends ParsingCommand
| {
| private JAXBContext ctx;
|
| protected JAXBParsing(long repetitions)
| {
| super(repetitions);
| }
|
| @Override
| protected void setup() throws Exception
| {
| super.setup();
| ctx = JAXBContext.newInstance(Person.class);
| }
|
| @Override
| protected Object parse() throws Exception
| {
| javax.xml.bind.Unmarshaller unmarshaller = ctx.createUnmarshaller();
| return unmarshaller.unmarshal(new InputSource(xmlUri));
| }
| }
|
| private static class XBParsing extends ParsingCommand
| {
| private static final UnmarshallerFactory factory = UnmarshallerFactory.newInstance();
| private SchemaBinding schema;
|
| protected XBParsing(long repetitions)
| {
| super(repetitions);
| }
|
| @Override
| protected void setup() throws Exception
| {
| super.setup();
| schema = JBossXBBuilder.build(Person.class);
| }
|
| @Override
| protected Object parse() throws Exception
| {
| Unmarshaller unmarshaller = factory.newUnmarshaller();
| return unmarshaller.unmarshal(xmlUri, schema);
| }
| }
|
| private static class FastJaxbParsing extends ParsingCommand
| {
| private static SAXParserFactory factory = SAXParserFactory.newInstance();
| static
| {
| factory.setNamespaceAware(true);
| }
|
| private Sax sax;
|
| protected FastJaxbParsing(long repetitions)
| {
| super(repetitions);
| }
|
| @Override
| protected Object parse() throws Exception
| {
| SAXParser parser = factory.newSAXParser();
| parser.parse(xmlUri, sax);
| return sax.getRoot();
| }
|
| @Override
| protected void setup() throws Exception
| {
| super.setup();
| HashMap<String, Handler> map = new HashMap<String, Handler>();
| map.put("urn:person", new Person_Parser());
| sax = new Sax(map);
| }
| }
|
| private static abstract class ParsingCommand
| {
| protected long repetitions;
| protected long total;
| protected String xmlUri;
| protected Object o;
|
| protected ParsingCommand(long repetitions)
| {
| this.repetitions = repetitions;
| }
|
| public void reset()
| {
| total = 0;
| o = null;
| }
|
| public long getTotal()
| {
| return total;
| }
|
| public double getAverage()
| {
| return ((double)total)/repetitions;
| }
|
| public long getRepetitions()
| {
| return repetitions;
| }
|
| public Object getResult()
| {
| return o;
| }
|
| protected void setup() throws Exception
| {
| xmlUri = Thread.currentThread().getContextClassLoader().getResource("person.xml").toExternalForm();
| }
|
| protected abstract Object parse() throws Exception;
|
| public void run() throws Exception
| {
| setup();
| for(int i = 0; i < repetitions; ++i)
| {
| long start = System.currentTimeMillis();
| o = parse();
| total += System.currentTimeMillis() - start;
| }
| }
| }
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4259154#4259154
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4259154
16 years, 6 months
[JBoss ESB Development] - Re: ClassCastException in CertificateLoginModule
by h.wolffenbuttel
I need to fill the AuthenticationRequest and it's filled with the following code:
| <http-bus busid="Http-GouwESB-Nulstand" context="/gouwesb/httpsgateway/Nulstand">
| <property name="authMethod" value="CLIENT-CERT"/>
| <property name="securityDomain" value="java:/jaas/CertLogin"/>
| <property name="securityRole" value="worker"/>
| </http-bus>
|
And the security is supposed to pickup the certificate information in the service declaration:
| <service category="HTTPService"
| description="WS Frontend speaks natively to the ESB"
| name="HTTPNulstandService">
|
| <security callbackHandler="org.jboss.soa.esb.services.security.auth.login.CertCallbackHandler"
| moduleName="CertLogin" rolesAllowed="worker" runAs="worker" useCallerIdentity="false">
| <property name="alias" value="xxxxxxx"/>
| </security>
|
| <listeners>
| <http-listener busidref="Http-GouwESB-Nulstand" is-gateway="true"
| maxThreads="1" name="Http-Nullstand-Gateway"/>
| <jms-listener busidref="NulstandEsbBus" is-gateway="false"
| maxThreads="1" name="JMS-Nulstand-ESBListener"/>
| </listeners>
| ...
| </service>
|
I don't know if this information does help? Do i need to use another module like CertRolesLoginModule?
Regards,
Hans
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4259151#4259151
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4259151
16 years, 6 months
[JBoss ESB Development] - Re: ClassCastException in CertificateLoginModule
by h.wolffenbuttel
hi,
Here is the class definition of org.jboss.security.auth.callback.ObjectCallback. I implements the interface Callback, but that interface is empty.
| * JBoss, Home of Professional Open Source.
| package org.jboss.security.auth.callback;
|
| import javax.security.auth.callback.Callback;
|
| /** An implementation of Callback that simply obtains an Object to be used
| as the authentication credential. Interpretation of the Object is up to
| the LoginModules that validate the credential.
|
| @author Scott.Stark(a)jboss.org
| @version $Revision: 57203 $
| */
| public class ObjectCallback implements Callback
| {
| private transient String prompt;
| private transient Object credential;
|
| /** Initialize the SecurityAssociationCallback
| */
| public ObjectCallback(String prompt)
| {
| this.prompt = prompt;
| }
|
| public String getPrompt()
| {
| return prompt;
| }
| public Object getCredential()
| {
| return credential;
| }
| public void setCredential(Object credential)
| {
| this.credential = credential;
| }
| public void clearCredential()
| {
| this.credential = null;
| }
| }
|
Regards,
Hans
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4259131#4259131
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4259131
16 years, 6 months