Wednesday, December 13, 2006

Wednesday, August 02, 2006

Thursday, June 29, 2006

Friday, June 23, 2006

Outskirts of Dubai, UAE

Streaming API for XML (STAX)

JSR 173: Streaming API for XML:
The Streaming API for XML (StAX) parsing will specify a Java-based, pull-parsing API for XML. The streaming API gives parsing control to the programmer by exposing a simple iterator based API. This allows the programmer to ask for the next event (pull the event) and allows state to be stored in a procedural fashion. The following example reads an XML document and modifies it by inserting a new tag at a specific location.

package com.myco.stax;
import java.io.FileInputStream;
import javax.xml.stream.*;
import javax.xml.stream.events.*;
import javax.xml.namespace.QName;

public class StAX_Iterator {

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

System.out.println("Starting parser..");
//Read input XML
XMLEventReader eventReader = XMLInputFactory.newInstance().createXMLEventReader(new FileInputStream("C:/STAX/xmlpull/RawBidSet.xml"));

//Configure output stream.
XMLOutputFactory factory = XMLOutputFactory.newInstance();
XMLEventFactory eventFac = XMLEventFactory.newInstance();
XMLEventWriter ew = factory.createXMLEventWriter(new java.io.FileOutputStream("C:/STAX/xmlpull/rbs-modified.xml"),"UTF-8");


while(eventReader.hasNext()) {
XMLEvent event = eventReader.next();
if(event != null){
//Pipe everything other than comments into the outputstream
if(! (event instanceof com.bea.xml.stream.events.CommentEvent)){
ew.add(event);
}
}

//Insert a new tag called mrid after the <name> tag inside every <GeneratingBid> or <LoadBid> or <InterTieBid> tag
if (event instanceof StartElement && ( ((StartElement)event).getName().getLocalPart().equals("GeneratingBid") ((StartElement)event).getName().getLocalPart().equals("LoadBid") ((StartElement)event).getName().getLocalPart().equals("InterTieBid") ) ) {

while(eventReader.hasNext()){
event = eventReader.next();
if(!(event instanceof com.bea.xml.stream.events.CommentEvent)){
ew.add(event);
}
if (event instanceof EndElement && (((EndElement)event).getName().getLocalPart().equals("name"))) {
ew.add(eventFac.createStartElement("",null,"mrid"));
ew.add(eventFac.createCharacters("QWE123"));
ew.add(eventFac.createEndElement("",null,"mrid"));
break;
}
}
}
}

ew.close();
System.out.println("Done.");

} //end main

} //end class

Tuesday, October 25, 2005

Tuesday, September 20, 2005

Support for SOAP Attachments in Document/Literal Service

I take part in an SOA project where I have to create, test and deploy web services based on WSDL files supplied by a partner Co. We use Apache Axis 1.2. ( http://ws.apache.org/axis ) Recently I ran into a problem with one of the services which has an attachment as part of the request message. It is a "docment/literal" service by wsdl definition. I generate the java classes using wsdl2java. The service interface has 2 arguments - an object which holds information about the file being attached, and an org.apache.axis.attachments.OctetStream object, which is the attachment itself. When I invoke the service using the generated JUnit testcase, I keep getting a SAXException like "Invalid element in com.xyz.MyClass - myClass". This is an exception thrown by Axis BeanDeserializer at the server side.
 
Every thing magically starts working as soon as I change the binding style in wsdl to "RPC" instead of "document". Even if I first generate the code using wsdl with style="document" and then just change the style in server-config.wsdd to "style=RPC" at the time of deployment, it still works fine.
 
Is a document style web service allowed to have only one argument in the corresponding implementation java class? Is it failing because I have 2 arguments in there? I am basically seeing that the BeanDeserializer goes for a toss when deserializing the incoming request message. I intercepted the outgoing request at the client side and incoming request at the server side using Axis handlers. They look fine to me. Besides, the fact that the deserialization works when I change server-config.wsdd to "style=RPC" baffles me. I am attaching the files I used.

Tuesday, September 13, 2005

What is the glucose tolerance test like?

What is the glucose tolerance test like?

For 8 to 14 hours before the test, you can't eat or drink anything but sips of water, so you'll want to schedule it for first thing in the morning. (Don't smoke or exercise either.) For three days before the test, you'll be told to eat at least 150 grams of carbohydrate a day. (If you eat a normal diet and have an extra piece of bread at each meal, you'll likely be getting enough carbs.)

When you arrive for the test, the technician will take a blood sample to measure your fasting blood glucose level and then ask you to drink either a more concentrated dose or a larger volume of the glucose solution (containing 100 grams of glucose). Then brace yourself for three more arm pricks as they test your blood every hour for the next three hours. (You'll definitely need a source of distraction this time, as you'll have to stay seated in the waiting room between blood drawings. You might also want to bring a sandwich, so you can eat right after your final blood sample is drawn. You'll most likely be quite hungry.) The technician should alternate arms each time she draws your blood.

If one of the readings is abnormal, you may have to take another test later in your pregnancy. Or your practitioner may ask you to make some changes in your diet and exercise routine. If two or more of your readings are abnormal, you'll be diagnosed with gestational diabetes and you'll need to talk to your practitioner about a treatment plan. This chart shows the levels that the American Diabetes Association considers abnormal at each interval of the test:

Interval Abnormal reading
Fasting 95 mg/dl or higher
One-hour 180 mg/dl or higher
Two-hour 155 mg/dl or higher
Three-hour 140 mg/dl or higher
 

Tuesday, September 06, 2005

Tuesday, August 30, 2005

Monday, August 29, 2005

Getting the underlying JDBC Connection from JBoss wrapped Connect ion.

While using connection pools with xa-datasource and xa-connections, sometimes it becomes necessary to extract the underlying JDBC connection object from the wrapped connection object returned by a JBoss datasource look-up. This is especially the case when you want to invoke some of the non-standard methods which are provided by the DataSource and Connection implementations that you are using. We will use reflection to invoke the getUnderlyingConnection() method on the wrapped connection returned by ds.getConnection( ) at runtime.
 
private static Connection con;
private Connection jbosscon;
private Class wrappedConnectionClass;
private Method getUnderlyingConnectionMethod;
 
 
try {
            this.wrappedConnectionClass = getClass().getClassLoader().loadClass("org.jboss.resource.adapter.jdbc.WrappedConnection");
            this.getUnderlyingConnectionMethod = this.wrappedConnectionClass.getMethod("getUnderlyingConnection", (Class[]) null);
            Context jndiCntx = new InitialContext();
            
            DataSource ds = (javax.sql.DataSource)jndiCntx.lookup("java:/jdbc/sibr" );
            jbosscon = ds.getConnection(db_user,getUserPasswd(db_user));
            con = (Connection) this.getUnderlyingConnectionMethod.invoke(jbosscon, (Object[]) null);
            con.setAutoCommit(false);
}
catch (Exception e) {
           e.printStackTrace();
}

Some kind of monster (2004)

This was a DVD that I've been waiting to watch -  partly because I've been a Metallica fan in my younger years, and partly because of the voyeuristic pleasure associated with reality shows that seems to have taken over show-biz these days. Directors Bruce Sinofsky and Joe Berlinger have had previous experience with the band while making their critically acclaimed documentary Paradise Lost. They have made SKOM to be one hell of a back-stage "All access" pass which is both intense and hilarious at the same time..

Tuesday, August 23, 2005

St. Mary's Basilica





America's first Basilica, also co-cathedral for the twin cities of St. Paul and Minneapolis.

Monday, August 22, 2005

Autographs, Deep Purple



All the band members obliged to sign, and Steve Morse threw in a pick too! But this T ain't mine! ;-)

Kids wanna rock...



"War of bands" at Lakers' Park, Plymouth