|
|
Blog entries in category "Java" shown here:
Show entries in category : Whateveah | Java | All |
RESTful Web Services with JAX-WS
Here is my article on RESTful Web Services and some best practices to consider when developing them with JAX-WS.Posted by sameert ( Aug 18 2006, 12:00:00 AM EDT ) Permalink Comments [0]
JAXWS 2.0.1 Performance Improvements
JAX-WS 2.0 shipped as an FCS version before JavaOne (2006/05/09). JAXWS 2.0.1 is a overhaul of JAXWS 2.0 RI for improved performance and better pluggability to allow other technologies like WSIT to be layered on top. It still conforms to the same JSR spec. The team has spent a lot of cycles trying to optimize JAX-WS performance and the results can be seen in the graph below.Between JAX-RPC and JAX-WS 2.0.1 (ie the rearchitected implementation), performance has impoved between approximately 70% depending on the test cases. The graph below shows a comparison of JAX-RPC vs JAXWS 2.0 and JAXWS 2.0 vs JAXWS 2.0.1
![]() JAX-RPC 1.1 vs JAX-WS 2.0.1 |
JAX-WS 2.0 was a rewrite from ground up of JAX-RPC and included a lot of new features (like integration with JAXB 2.0) which contributed to a slight regression in performance. Performance has been at the center of the implementation rearchitecture.Some enhancements include
- Revisiting some of the key abstractions
- For example. avioded using StAX and going straight from JAXB to OutputStream. This reduces the number of layers and avoids the escaping, character encoding and namespace management done by StAX.
- Better handling of properties Prior to JAXWS 2.0.1 a HashMap was used to hold properties that were all pre-evaluated and in fact read more often than written.In JAX-WS 2.0.1 a distributed property set with lazy evaluation is used.
- Collapsing the stack where ever possible
- For example, initially a byte image of the whole message was kept around and a DOM built for the whole message to access headers. This inadvertently led to XML being parsed twice.
To avoid this JAXWS 2.0.1 uses a stream buffer which records infoset to necklace-like data structure and allows it to be replayed later. It's not randomly accessible though.
It supports various XML API's. Eg reads via XMLStreamReader and writes via XMLStreamWriter; or fire SAX events to ContentHandler.
- For example, initially a byte image of the whole message was kept around and a DOM built for the whole message to access headers. This inadvertently led to XML being parsed twice.
- Reducing the number of special purpose interfaces.
- For example no more custom hooks for JavaEE
- Better handling of endpointaddress property. In JAXWS 2.0 implementation this was stored in a string and then converted to a new URL() everytime. In the 2.0.1 implmentation its stored as a URL in the distributed property set and a URI is created for storing proxy information which is used by the JDK's URL.openStream()
Posted by sameert ( Aug 16 2006, 01:30:00 PM EDT ) Permalink Comments [0]
750cc's of pure power
Posted by sameert ( Aug 15 2006, 12:00:00 AM EDT ) Permalink Comments [0]
SWE 645 @ George Mason University
I was pleased to find out that another graduate level course is using my book on Web Services as a text book. SWE 645 at George Mason university.Posted by sameert ( Aug 12 2006, 05:01:27 PM EDT ) Permalink Comments [0]
Tango performance
In a recent exercise in tracking performance with WSIT (aka Tango), our project to enable interoperability between the Java platform and Windows Communication Foundation (WCF), we noticed a significant regression in JAX-WS performance. Tango builds on top of JAX-WS with additional pipes.The rearchitected branch of JAX-WS has a notion of pipes - following the pipe and filter architectural style. Turns out a chunk of the regression was originating from one of the pipes creating a JAXB context for every request, rather than caching it. Kohsuke sent out an email to the Tango dev mailing list, that can be found here. These actually apply to all developers in general using JAX-WS and JAXB. Context creation and factory lookups are expensive operations and shouldnt be repeated , especially for every request !
Posted by sameert ( Jul 29 2006, 04:55:49 PM EDT ) Permalink Comments [0]
DWR and Web Services
JAX-WS services can be easily accessed via a browser using AJAX technologies like Direct Web Remoting(DWR) to enable client access. The PurchaseOrder web service example discussed previously can easily be accessed from web pages with some simple JavaScript. Simply wrap the service proxy in a JavaBean,include the DWR Jar and configuration file in the WAR and access the JavaBean object in the JavaScript. Details on how to conifgure DWR can be found in the article here For our example the web page looks like<script type='text/javascript' src='/docliteralfromwsdl-war/dwr/interface/POServiceDAO.js'></script>
<script type='text/javascript' src='/docliteralfromwsdl-war/dwr/engine.js'></script>
<script type='text/javascript' src='/docliteralfromwsdl-war/dwr/util.js'></script>
<script>
function createPO() {
POServiceDAO.createPO(showPO);
}
function showPO(order){
document.getElementById("field1").innerHTML = DWRUtil.toDescriptiveString(order, 2);
sendPO(order);
}
function sendPO(order){
POServiceDAO.sendPO(showStatus,order);
}
function showStatus(status) {
document.getElementById("field2").innerHTML = status.timestamp ;
document.getElementById("field3").innerHTML = status.orderid ;
}
</script>
The full war modified from the previous example fan be downloaded here The advantages of DWR in particualr is that the proxy is located on the server and is serialized via JavaScript to the client. So architecturally you can have services that are located in the DMZ or even backends that are not exposd to clients directly. The other advantage is performance, when the cilent proxy and service are colocated you can avoid the serialization over the wire and use the JAX-WS local transport. Ahh the possibilities !!
Posted by sameert ( Jul 24 2006, 12:54:18 PM EDT ) Permalink Comments [0]
Accelerating Java XML digital signature performance
If you are considering using XML Digital signatures in real world application, a recommened article for reading published by our group can be found here Posted by sameert ( Jul 19 2006, 05:07:34 PM EDT ) Permalink Comments [0]
Who's tapping my brainwaves ?
So I came across this website today.(local copy here) You pick a two digit number, add the digits and subtract it from the number and they predict what you had thought off. I tried it once - ahh a fluke, second time - thought it was random... but ten times in a row is not coincidence. I am now convinced my brain was somehow wiretapped. Not sure how they do it, but it freaked me out just a tad bit ! Maybe I should wear tin foil hats as in the movie Signs
Posted by sameert ( Jul 18 2006, 04:58:17 PM EDT ) Permalink Comments [2]
Accessing JAX-WS endpoints with Java WebStart
Java Web Start is a software distribution technology and can be used to distribute JAX-WS clients. Essentially one writes and deploys a JNLP file on the server. The example I will use is the one described in a previous entry here. You still need to sign the jar files to grant them security permissions and Java Web Start also works on a sandbox model. Here is the except of the JNLP file. Note that you can use either the applet-desc or application-desc tag depending on your code. We use the applet-desc since our previous example was an Applet jar. Also you dont need the JAX-WS runtime on the client if you use Java SE 6 or Mustang and set <j2se version="1.6+" />
<?xml version="1.0" encoding="utf-8"?> <jnlp spec="1.0+" codebase="http://localhost:8080" href="webstart.jnlp"> <information> <title>JAX-WS WebStart Demo</title> <vendor>Sun Microsystems</vendor> <homepage href="http://localhost:8080" /> <description>A Java Webstart test</description> </information> <resources> <j2se version="1.5+" /> <jar href="SignedApplet.jar" /> <jar href="sjavaee.jar" /> <jar href="sappserv-ws.jar" /> </resources> <security> <all-permissions /> </security> <applet-desc main-class="JAXWSApplet" name="JAXWSApplet" width="640" height="256"/> <param name="endpointURL" value="http://localhost:8080/docliteralfromwsdl-war/jaxws"/> </applet-desc> </jnlp>
Posted by sameert ( Jul 16 2006, 06:28:24 PM EDT ) Permalink Comments [0]
Accessing JAX-WS endpoints from Applets
Though the usecase for such an application is rare, some developers want to access JAX-WS web services via Applets - this is indeed possible. To demonstrate the steps, lets use the endpoint based on the "Using XML in the SOAP body" strategy described here. Assuming you have the endpoint deployed successfully, modify the client to work as an Applet. For our example we will have a simple TextArea and Button to make the web service call and display the results.The source for the Applet can be found in file JAXWSApplet.java To get this Applet running a few basic steps need take placea) Package the Applet and artifacts generated by the wsimport in a Jar file
b) Make the JAX-WS runtime available to the client. If you're using Java SE 6.0 (Mustang) and the browser plugin for that, then you should be all set. However if you're using J2SE 1.5 or an older version of Java then the JAX-WS Jars need to be made available to the browser. You can make these available in one of two ways. i) Get the JAX-WS distribution from Java.net and get the jars from the lib directory or ii) If you're using JAX-WS with Glassfish then locate the appserv-ws.jar and javaee.jar files in the lib directory.
c) Sign all the necessary JAR files using keytool and the jarsigner utility. This is a two step process that involves key generation and Jar file signing. A good technical article detailing this can be found here keytool -genkey -alias signFiles -keystore mystore -keypass mykeypass -dname cn=Sun -storepass mystorepass
jarsigner -keystore mystore -storepass mystorepass -keypass mykeypass -signedjar SignedApplet.jar JAXWSApplet.jar signFiles
d) Place the signed JAR files and the HTML page with the Applet tag on the web server. In Glassfish, simply place all these contents in the glassfish\docroot directory
Run the above example using targets in the following order to first build deploy and test the endpoint using a stand alone client ant create-war deploy-war run-wsdl-client. Then run the target sign-jaxws-ri which packages the Applet , signs the applet and signs the Glassfish Jars, plaing them in the build/signedjars directory along with an HTML file. Place the contents of this directory on your web server.Access the web page through the browser or appletviewer and you should see a result similar to the screen below when the button is pressed.
Have iPod - Will get hit by lightning
A recent story in the Denver Post details how a teen mowing the lawn and listening to an iPod got hit by lightening. The general theory is that the iPod acted as an antenna. Pictures and story here and here. Let the lawsuits begin !Posted by sameert ( Jul 12 2006, 01:49:50 PM EDT ) Permalink Comments [0]
Mice that smoke and drink
A while back I came across this mouse on the pavement going around in circles. No matter what you did it would not budge, kept chasing its tail. At that time I had hypothesized that it was simply stoned. Today I came across a research note titled "Alcohol and Nicotine: A Sobering Combination?" that citied a study in which mice were subjected to high dosed combinations of nicotine and alcohol to prove that they "could not balance enough to rear up on their hind legs" when they were exposed to both elements. This is used to draw the inference that "individuals who smoke and drink at the same time might feel more alert than if they consume alcohol alone". I kid you not.
This particular mouse may well have been an experimental escapee. The actual paper can be found here
Posted by sameert ( Jun 27 2006, 12:53:06 PM EDT ) Permalink Comments [0]
Birds dropping Acid in LA
Turns out Pelicans in Huntington Beach, CA have been acting dazed and confused (like the Led Zep song) and flying into windshields. The wildlife director says disorientation is because of domoic acid poisoning. Full report titled "Plastered Pelican in Detox After Flying Through Windshield" in LATimes Thats how crazy the world is - even birds are dropping acid.Posted by sameert ( Jun 26 2006, 05:21:46 PM EDT ) Permalink Comments [0]
Many faces of Bombay
Time magazine's Alex Perry recently did a report on Bombay. There is an online slideshow and audio commentary available here. Some of the photographs are really good and bring out the socio-economic contrast and diversity. Posted by sameert ( Jun 22 2006, 12:00:00 AM EDT ) Permalink Comments [0]
Birds without wings, words of wisdom and David Gray
I first came across David Gray in 2001 and I thought his voice was a mordern day UK version of Bob Dylan.
Five years later, I pop in the newly acquired complete discography set in my player.Here are some lyrics. A good example is Birds without wings or My Oh My. Words of wisdom indeed ?Posted by sameert ( Jun 21 2006, 02:27:12 AM EDT ) Permalink Comments [0]
Resonate
Posted by sameert ( Jun 19 2006, 12:00:00 AM EDT ) Permalink Comments [0]
Need weed ? Go to Home Depot.
Found this really funny but true story.
"Last week, a contractor bought a bathroom vanity at a Tewksbury,Massachusetts Home Depot and discovered two 50-pound "bricks" of grass inside. Elsewhere in the state, a plumber purchased a similar product at an unnamed "hardware store" and opened it to find 40 pounds of weed plus 3 kilograms of cocaine. Police and DEA officials have swept a dozen Home Depots in the state and found other loaded vanities."
CNN News story herePosted by sameert ( Jun 15 2006, 12:00:00 AM EDT ) Permalink Comments [0]
American image in India
The pew center published another report on international attitudes towards the US. This clipping is from a newspaper summarizing the Indian results which show a slight increase in approval ratings for Bush. A higher percentage of people in India, than in the US, believe that the US efforts to set up a democracy in Iraq will succeed.
Why am I not surprised with these results ?
Posted by sameert ( Jun 14 2006, 11:37:32 PM EDT ) Permalink Comments [0]
Parking tickets suck !
I happen to spend some time in the city these last few months and my car seems to attract the meter maids like ants to honey. I think its my out of state plates- eitherway, almost every time, its within minutes of the meter running out that I get slapped - so I m now turning to ParkingTickets.com to take them up on their guarantee and fight my stack of tickets. Power to the peoples !Update : 07/03/2006 Got my first dismissal from Boston. Net cost = parkingticket.com fee = 50%of fine.
Posted by sameert ( Jun 09 2006, 05:24:11 PM EDT ) Permalink Comments [2]
JAX-WS and the upcoming Apocalypse
I ve often wondered what it takes and how one goes about becomes a strategy analyst, sitting in Think Tanks and being in the business of predicting the past. I came across Richard Monson-Haefel's blog critiqing how bad JAX-WS was and then subsequently eating his own words. As pointed out by James,an analyst actually eating his own words and somewhat retracting in position, may actually be a sign that the rapture is coming !Posted by sameert ( Jun 06 2006, 01:19:00 PM EDT ) Permalink Comments [0]
Real World Web Services Performance on CoolThreads
| Out of the box scalability for the SunFire T1000 and T2000 boxes (CoolThreads technology)Glassfish using an internally developed macro benchmark that stresses all of the JWSDP API's (JAX-WS, JAX-RPC,JAXB, StAX, XWSS etc) and simulates a real world web services application middle tier application. | |
| Scalability with some tunings on the JVM and the application server such as acceptor threads > number of users |
Posted by sameert ( Jun 05 2006, 12:00:00 AM EDT ) Permalink Comments [0]
Money to burn & devices to buy
I used to think my cell phone was on the expensive side, till I came across the $1000 Nokia handset. And now they both seem cheap compared to the $31,850 Vertu. Yes thats -Thirty some thousand dollars -and not a misplaced decimal. To put it in context, thats slightly more than a BMW 3 series which starts at $30,900 If you happen to buy one of these outrageously priced handsets, consider making a donation of the same amount to my personal charity. The charity (visa, mastercard,amex & paypal accepted) can be reached at s.t@sun.com
Posted by sameert ( Jun 03 2006, 06:28:34 PM EDT ) Permalink Comments [0]
US Missile base for sale on eBay
Posted by sameert ( May 31 2006, 12:00:00 AM EDT ) Permalink Comments [0]
Crazy
Everytime I visit San Francisco (this time for JavaOne 2006) I m somewhat frustrated with the high number of
homeless people,most visibly mentally ill on the streets and the seemingly apathetic attitude of the residents. Alsmost everytime I m here one of them decides to chase me down the street - typically around the BART stop
on Market. I picked up Pete Early's book Crazy - a touching and educating account of a "fathers search thourgh American mental health madness" that uses his experience with son (Mike) and a dozen or so other individuals, to discuss the complicated intermingling of public policies,civil rights, the justice system, police and peoples attitudes. The primary focus is really how all this makes it difficult for relatives to get help for people with mental illness like BPD & schizophrenia. It led me to think about a picture I once saw in Boston's Kennedy museum about the "lunatic asylums" in the 30's and Kennedy's reforms and how treatments have shifted from elctroshock to Freudian psychoanalysis/behavior modification, institutionalization,de-institutianization, trans-institutionalization to dopamine theories and a pill popping,chemically justified,cure-all culture today.
The book had some interesting numbers - to paraphrase - in 1955 there were 560,000 Americans being treated in state hospitals. With some math, this would extrapolate to about 1 million today - but only 55,000 are institutionalized. The rest are presumably on the streets and in prisons. LA county jail houses 3000 disturbed patients per day.The cost for this - about $135,000 per "untreated" patient per year.
So how does this compare to India ? Asylums which would be considered mideval in the US- still exist in India. Even though a 25 million number was floated here .. I doubt its accuracy.Its very unlikely that people on the street are "mentally ill" - they are on the street not because they're un-treated and prescription-less,but because of poverty. Most live with their families probably because of the "insufficient facilities for hospitalization even when the illness was acute" and because of the culturally close knit family structure
Food for thought !
Posted by sameert ( May 30 2006, 01:50:24 PM EDT ) Permalink Comments [1]
Performance for RESTful Web Services with JAX-WS
| RESTful web services with JAX-WS show some interesting performance characteristics. I ran some tests with WSTest/Japex. The first graphic shows a comparison of a few different method calls using a RESTful endpoint and a WSDL based SOAP endpoint - both doing the same thing i.e accepting XML, Unmarshalling it with JAXB, doing something and Marshalling results back using JAXB. The client does no work in both cases and uses POST operations. As seen, the performance is more or less the same in the firt tests but tends to do better for the non-rest cases for the medium and larger paylods. This is probably more because of the tight integration in the non-rest case between JAX-WS and JAXB with optimized code paths rather than anything else. | |
| In another comparison for the same endpoints (RESTful and WSDL based) with a filp on the client for an HTTP GET/POST each, shows how for the POST operation the performance is slightly better for the REST endpoint and significantly better for the GET operation. This is because the test sends the same XML request data and can leverage the HTTP caching framework provided by the server for GET operations. Glassfish servlet/jsp caching details can be found here but with no config the default is 30sec, enough for our test. | |
![]() |
So how do endpoints compare when the caching framework is not leveraged (request data is randomized) ? RESTful endpoints perform slightly better but as expected there is almost no difference in GET/POST operations for the same RESTful endpoint. |
Posted by sameert ( May 23 2006, 02:52:30 PM EDT ) Permalink Comments [1]
Some J1 2006 sessions
Marc Hadley presented an interesting session today at JavaOne 2006 on RESTful web services. His deck can be found hereAnother cool session was on Groovy presented by Rod Cope. Details here. The demo at the end was interesting, though not really practical- it did get the geeks in the audience going aahhh.Always a good sign for a presentation.
Slides for our Web Services Performance session can be found here BOF-2593 and for the technical session TS-9263 on Web Services can be found TS-9263
Posted by sameert ( May 17 2006, 12:00:00 AM EDT ) Permalink Comments [0]
Protest music 2006
Popped in Neil Young's new album Living with War today after listening to the review on NPR. Intersting collection of protest songs with an electric, bluesy sound - including a track labled "Lets impeach the president". Thats a lot of verbage from someone who supported Reagan. The local stations seem to be selectively playing the title track only - no surprise there.
Posted by sameert
( May 12 2006, 12:00:00 AM EDT )
Permalink
Comments [0]
Nickle and Dimed
Managed to finish Barbara Ehrenreich's book "Nickle and Dimed" earlier. I didnt really get impacted as much by it as some other people mostly because I had seen Morgan Spurlok's episode of 30 days a while back which dealt with the same issue of surviving on minimum wage jobs - with the same conclusions.
The book somehow didnt seem that interesting either - mostly because the authors treatment lacked depth about the experience - or she may have just tried to do too much wih too few pages. Posted by sameert ( May 01 2006, 12:00:00 AM EDT ) Permalink Comments [0]
Hanging monkeys
Received a rather official notice in my email today and couldnt help but laugh.During a recent Security walkthrough, a figurine of a monkey was found hanging from a emergency strobe light in one of the Burlington Campus buildings. Hanging anything from emergency strobes, exit signs or sprinkler systems is strictly prohibited. We would appreciate your cooperation in meeting this safety code.Only at Sun !
Posted by sameert ( Apr 26 2006, 11:12:01 AM EDT ) Permalink Comments [0]
Path_info showing up as null in Glassfish JAX-WS
I was trying to deploy some JAX-WS endpoints in Glassfish and for some reason this was always returning a null.String path = (String)mc.get(MessageContext.PATH_INFO); Turns out that the url-pattern must terminate in a *
<servlet-mapping>
<servlet-name>sample_webservice</servlet-name>
<url-pattern>/jaxws/*</url-pattern>
</servlet-mapping>
The /jaxws/* was the key. When the url-pattern was just /jaxws the endpoint kept showing up as a HTTP-404 error.
Once I added the * in the web.xml - voila ! Will eyeball the jax-ws code to figureout why it does this when I get some time. For now the * fix works.
Posted by sameert ( Apr 25 2006, 12:00:00 AM EDT ) Permalink Comments [1]
Hudson build tool
I recently got an overview of Hudson from Kohsuke . Its the coolest build tool I ve seen. Started out as his pet projects and is now used for building Glassfish. Hudson includes the ability to plug in multiple computers and share time/offload work into a cluster - and its all open source. Posted by sameert ( Apr 24 2006, 10:51:00 AM EDT ) Permalink Comments [0]
Sri Lankan hip-hop-bibbity-bop dillema
Popped in the Arular album from Sri Lankan/UK singer MIA in my office today. Funky upbeat music and some of it is hilarious! However what pissed me off a bit is that MIA (Maya Arulpragasam) has links to a rather dubious group as reported here , here and here among other places. It also looks from her blog that because of her links to LTTE, homeland security wont let her in the US or something.
Ok so here is the moral dillema - I like some of the music - and the fact that someone endured and overcome adversity to shine - is commendable. But have I just contributed to global unrest that particularly affects southeast asia, by patronizing this artist ?
Posted by sameert ( Apr 21 2006, 12:00:00 AM EDT ) Permalink Comments [0]
Self help 101@Sun
While browsing other Sun bloggers, I came across FlexRex - prefer to be anonymous- colleague's self help blog .
Which is a weird coincidence since I had just popped in the Turnin Brakes in my office.
The track titled "Self-Help" from the Ether Song album, goes something like "...Breathe in good, breathe out bad..."
Most of it is too Deepak Chopra for my taste, but is a "lucid trip through ambient rock corridors".
Posted by sameert ( Apr 18 2006, 12:00:00 AM EDT ) Permalink Comments [0]
Someone needs a new routing algorithm
Not sure if Mr Dave Givens is doing this out of desperation ; or , as so many others have pointed out - simply because of an IQ deficiency. It sure seems like Cisco needs to design a new routing algorithm for their employee and his "record" 7+ hour, 372Mile(~600Km) commute from Yosemite to the Cisco office in San Jose.
In case you're wondering, the cool image above is that of a Capillary routing algorithm referenced from this paper Posted by sameert ( Apr 17 2006, 12:00:00 AM EDT ) Permalink Comments [1]
Why I work at Sun ?
Besides the fact that its the only 30,000 + employee corporation I know off, where your office is called a "campus" and people can show up in destructed jeans, with their dogs, piercings and mountain bikes - have offices (not cubes) with fish tanks, Pink Floyd posters and blow up Alien dolls-
I get to do what I like - a certain level of freedom doing it -like giving cool names to projects I work on (Galactica)- and work with a bunch of extremely interesting people with diverse tastes outside IT.
All you need to do is peek at blogs.sun.com or look at blogs like Chris Saul's on offroading in Dubai, Jen Crosby's Racing blog, Steve Goldmans flying blog or the SectOfRama passion for coffee to get an idea of what I mean...
Posted by sameert ( Apr 15 2006, 08:45:55 PM EDT ) Permalink Comments [3]
Server GC in CLR
The .NET CLR has a tonne of counters that allow you to get detailed information about what the CLR is doing with memory, Threading, garbage collection etc. Details in the MSDN guide at There are some other things that arent that well documented. For example the CLR's GC has two modes: Server GC and WorkStation GC as alluded to in this MSDN article.The default is the workstation gc, to enable the server the app.config file should contain something like<Configuration> <runtime> <gcServer enabled=“true“ /> </runtime> </Configuration>Also the GC can run concurrently (somewhat similar to parallelGC in Java) and is turned "on" by default. This is suitable for heavy user interaction based apps.To switch it off the configuration would need to be changed again to
<configuration> <runtime> <gcConcurrent enabled="false"/> </runtime> </configuration>Also I came across a tip to use the SoS (Son of Strike) debugger in Visual studio for debugging apps that are a mix of managed/unmanaged code. To do this enable “unmanaged code” debugging option in Project properties-Debug and set a breakpoint in the code. When hit open the “immediate window” and load SOS debugger extension through the “.load sos” command. Here is a detailed article on using SoS
Posted by sameert ( Apr 10 2006, 12:00:00 AM EDT ) Permalink Comments [0]
CLR Native JIT'ing
As I mentioned earlier, the NGEN tool in the CLR can be used to force the JIT to compile the IL to native format. You can also use it directly on an exe. For example
C:\TEMP\TestApp\TestApp\bin\Release>ngen install TestApp.exe
Microsoft (R) CLR Native Image Generator - Version 2.0.50727.42
Copyright (C) Microsoft Corporation 1998-2002. All rights reserved.
Installing assembly C:\TEMP\TestApp\TestApp\bin\Release\TestApp.exe
Compiling 1 assembly:
Compiling assembly C:\TEMP\TestApp\TestApp\bin\Release\TestApp.exe ...
TestApp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
This results in the native image of the executable being generated in the Native assembly cache and the file
can be inspected here. (You need to do this from a DOS prompt as this dir may not show up in explorer)
C:\WINNT\assembly\NativeImages_v2.0.50727_32\TestApp\3d175dbade97d648b002a9881f995ca8>dir Directory of C:\WINNT\assembly\NativeImages_v2.0.50727_32\TestApp\3d175dbade97d648b002a9881f995ca8 04/06/2006 08:12 PMTo verify that the native image is indeed being used at runtime, you can use the Assembly Binding Log Viewer (Fuslogvw.exe) tool. Fire it up, change the settings and log location, start your app and hit refresh. Something like this will show up verifying that the native image is being used.. 04/06/2006 08:12 PM .. 04/06/2006 08:12 PM 13,824 TestApp.ni.exe 1 File(s) 13,824 bytes 2 Dir(s) 774,688,768 bytes free
The general guideline seems to be that one should test out the performance for both native/non native images. Just because its native doesnt really mean it will perform better but you may be able to reduce the memory footprint,and share memory pages across applications. Theres some detail around this in an April 2005 MSDN mag article here.
Posted by sameert ( Apr 09 2006, 12:00:00 AM EDT ) Permalink Comments [0]
Too far gone
Came across a report from the Pew Research Center according to which "57% of teens who use the Internet could be considered Content Creators....they have created a blog or webpage, posted original artwork, photography, stories or videos online or remixed online content into their own new creations...about 87% of those ages 12-17 use the Internet... 51% online teens report downloading music..." Complete report can be found here.
Like Mick Jagger was singing...
"..I would spend my childhood days,
Lost in starry dreams
And now watch my children,
Just downloading them to screens.."
Posted by sameert ( Apr 08 2006, 12:00:00 AM EDT ) Permalink Comments [0]
An Apple a day, kept Windows at bay - till now anyways
Apple has released "Boot Camp" which allows you to boot the Intel based Mac with Windows XP. For years die hard Mac users have shunned Windows and anything to do with Microsoft. I m personally not a Mac user and have never understood this facination but now theres an Intel based Mac and people want to run Windows on it. Besides the cool-factor, can what could possibly be the purpose of this seemingly futile exercise ?Jog your memory a bit to 1997 and theres at least a 150 million reasons why.
Posted by sameert ( Apr 07 2006, 03:03:49 AM EDT ) Permalink Comments [0]
Someone stop the iPod madness
Ok so 50 million people have iPods in the US alone and some of them actually have a 2" screen for video playback. Now what video would one possibly want to see obscured by your own thumb prints ? Yes -I ve actually seen some guys with this -portable porn - for the perv on the go ! But besides that...?Question - How come the guys in Iraq cant get body armor but I can buy three dozen different types of 'protective covers' for an iPod down the street ?
And whats with the ridiculous accessories like the iPod sock for $29.00, which is more than a pair of real socks at Nordstroms? Does it get frost bite ?
Apple has a good cash cow going with their properitary iTunes, "Protected AAC" file format and an entire iPod economy is milking it every which way. Way back in 2005 the tally was 250 million paid for downloadble songs and they were talking about selling 1.25m songs a day so its no surpirse people are crying foul!
Having said all that- my nano does look sleek in its new aluminium case!
Posted by sameert ( Apr 06 2006, 12:00:00 AM EDT ) Permalink Comments [0]
Playing in the cold
Notice a contemporary phenomena in the picture? Lighters replaced with LCD's from cell phones - welcome to the digitized, pixelified, downloadable-uploadable generation of the disconnected-connected.
Posted by sameert ( Apr 04 2006, 12:00:00 AM EDT ) Permalink Comments [2]
Runaway boyfriend - no reward offered ?
Notice seen on a pillar in Somerville - for a runaway boyfriend. No finders reward was mentioned to retreive the absconding individual,so we didnt bother going bar to bar looking for Mr Lenz. Posted by sameert ( Apr 02 2006, 01:58:20 AM EST ) Permalink Comments [0]
Oracle Spatial Database
I ve been using some of Oracle 10g's new Spatial features and their Java Spatial API lately. The flexibility and features it provides for GIS type applications simply rocks. For example you can create a table and have a colum that is of type SDO_GEOMETRY and store the coordiates in terms of X,Y (like longitude and latitude) or other Geometric/GML data. The API allows you to then query that Spatially indexed colum in a variety of ways. For example you can use the JDBC API to queryslect ... where sdo_filter (mycolumname ,sdo_geometry(2003,null,null,sdo_elem_info_array(1,1003,3),sdo_ordinate_array (0,0,600,800))) = 'TRUE'returns all the points as oracle.spatial.geometry.JGeometry objects that are in the MBR (mean bounding rectangle) from 0,0 to 600,800 ! With the set of coordinates in hand you can link them up and draw a route similar to what you see in Google or mapquest when you query for driving directions. Theres a bunch of other operators that allow you to insert/query a variety of geometic shapes for range and nearest neighbour information. Pretty cool ! Posted by sameert ( Mar 29 2006, 10:40:34 PM EST ) Permalink Comments [0]
On Snow Patrol
C# and SubMaps
It took me a while to figure out why my C# code wasnt working as expected today. After much debugging it turned out that C# doesnt have a clean SubMap implementation, or least one that I could find. What I was assuming will work wasnt quite cutting it.In Java you can easily get a subMap using string keys based on a regular expression magically. For example the code, Prints out something like...TreeMapsortedMap = new TreeMap (); for(int i = 0;i<10;i++) sortedMap.put("SomeKey_"+i, "SomeValue"); System.out.println(sortedMap); String low = "SomeKey_3", high = "SomeKey~"; System.out.println(low); System.out.println(high); {SomeKey_0=SomeValue, SomeKey_1=SomeValue, SomeKey_2=SomeValue, SomeKey_3=SomeValue, SomeKey_4=SomeValue, SomeKey_5=SomeValue, SomeKey_6=SomeValue, SomeKey_7=SomeValue, SomeKey_8=SomeValue, SomeKey_9=SomeValue} SomeKey_3 SomeKey~ {SomeKey_3=SomeValue, SomeKey_4=SomeValue, SomeKey_5=SomeValue, SomeKey_6=SomeValue, SomeKey_7=SomeValue, SomeKey_8=SomeValue, SomeKey_9=SomeValue}
The closest way of doing this in C# is a bit of a hack using the System.Collections.SortedList and the Comparer classes and its specific to what I was trying to do.I replace the regex ~ with a series of 9's.
public static SortedList SubMap(SortedList list, System.Object lowerLimit, System.Object upperLimit) {
string upperStr = upperLimit.ToString();
if (upperStr.EndsWith("~"))
upperLimit = upperStr.Replace("~", "999999999999999");
Comparer comparer = Comparer.Default;
SortedList newList = new SortedList();
if (list != null){
if ((list.Count > 0) &&(comparer.Compare(lowerLimit,upperLimit) <1)){
int index = 0;
while (comparer.Compare(list.GetKey(index), lowerLimit) < 0)
index++;
for (; index < list.Count; index++){
if (comparer.Compare(list.GetKey(index), upperLimit) > 0)
break;
newList.Add(list.GetKey(index), list[list.GetKey(index)]);
}
}
}
return newList;
}
Certainly not clean but its all I can think of right now. For all the C# code floating on the web I couldnt find a SubMap implementation that does what the J2SE classes do. Anyone have any better ideas ?
Posted by sameert
( Mar 25 2006, 03:31:39 AM EST )
Permalink
Comments [0]
Finally - The $1000 cell phone
Looking for a replacement, I came across the Nokia 8801, the first in the 8800 series retailing for $800. Throw in the accessories and tax and youre looking at over $1000. Its not a PDA, a PocketPC and certainly not a laptop - even though its priced close to one. Increasingly phones are trying to do more of everything and are getting better at doing nothing. For that kind of money, it better power my car and do my laundry!
Posted by sameert
( Mar 23 2006, 12:00:00 AM EST )
Permalink
Comments [0]
C#, Assembiles and JITing
The last few days I ve been doing more C# than anything else. Never thought it would come to this! So heres my first post on some notes I ve taken.In .NET an assembly is a reusable, self-describing, versionable deployment unit for types and resources. Because it is self-describing, it allows the .NET runtime to fully understand the application and enforce dependency and versioning rules. Unlike Java—in which both a stand-alone application and a component library are deployed as a .jar file—assemblies come in four types or formats and essentially consist of a manifest that contains the assembly metadata, one or more modules and other resource files such as icons etc.
- exe. A console executable. The application must contain one entry point defined in the Main method. There is also a tool called the MSIL Disassembler ( Ildasm.exe ) which is a counterpart of the MSIL Assembler (Ilasm.exe) which takes the portable executable (PE) file that contains Microsoft intermediate language (MSIL) code and creates a text file suitable as input to Ilasm.exe. - talk about round trip decompilation?
- Library. A library (DLL) that can be used by other assemblies.
- Module. A nonexecutable collection of compiled code for use in other assemblies.
- winexe. A graphical Windows executable. The assembly must contain one entry point.
Another concept similar to Java is that of shared asseblys (just like Jars are shared in an app server) . But .NET does not have the concept of class loaders or class paths so the CLR looks in only once place - the Global Assembly Cache (GAC) which is really a directory (usually %Systemroot%\assembly or %Systemroot%\assembly) where the CLR can locate such shared assemblies. There is a tool called the GAC tool (gacutil.exe) to install shared assemblies in the GAC. To share an assembly requires it to have globally unique name (aka a strong name) which consists of the name, version information, culture information, and a public key for cryptography. To create a public key, the .NET Framework provides a strong name tool called sn.exe, which creates a key file that can be referenced in the AssemblyInfo.cs. For my example I used sn–k WSTest.snk and created an Assembly.cs that contained something like
using System.Reflection;
using System.Runtime.CompilerServices;
[assembly: AssemblyTitle("WSTest")]
[assembly: AssemblyDescription("WSTest app ")]
[assembly: AssemblyCompany("Sun Microsystems")]
[assembly: AssemblyProduct("WSTest")]
[assembly: AssemblyCopyright("This is the property of Sun Microsystems ")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyKeyFile("WSTest.snk")]
Now to create the WSTest.dll with with a strong name: csc /target:library /out:WSTest.dll WStest.cs AssemblyInfo.cs and then stored it in the GAC using gacutil /i WSTest.dll
Boom ! We have a shared assembly. So whats the idea - well the plan was to JIT it up and see what happenes with performance.
Theres a bunch of detail on the MSDN website about how runtime objects are created and another link on pros/cons of JIT'ing Essentially when a reference to an object is first encountered, the JITer loads a stub for
each method that matches that method's declaration.When the same method is later invoked, the IL for it is compiled and the stub is
replaced with the address of the method's compiled code. This happens each time
a method is invoked for the first time, and the resulting native code is cached
so that it can be reused the next time the assembly is loaded during that
session. The JIT compiled code is not actually stored on disk and reused for subsequent executions of the
same application. This actually can be done if needed with what Microsoft calls the Native Image Generator - Ngen.exe that a pre-compiles (pre-JIT) IL application code into native machine language code after installation. . A quick peek inside teh C:\WINNT\assembly folder shows that not all shared assemblys are in fact JIT compiled to native code. (see x86 and MSIL as proc arch) . The reason is apparently that JIT performs lots of on-the-fly optimizations when compiling MSIL. Many of
these optimizations, particularly those involving the use of registers and
memory, are driven by the current demands made on the system. Compiling
assemblies in one large batch prevents these optimizations from being made and
therefore may actually result in slower final code for the server side execution.
Hmm....Did'nt we do this five or more years back with the JDK 1.1.x HotSpot VM ?
Posted by sameert
( Mar 22 2006, 11:00:00 AM EST )
Permalink
Comments [0]
American Vertigo
American Vertigo is an intertesing read to say the least. Bernard-Henri Levy presents a view of the US as an outsider and says a few things that I can identify with... The book follows in the steps of Tocqueville's publication Democracy in America (1831- I think - havent read it yet) available online here. The NYMag has a neat review of the book here .
Posted by sameert
( Mar 21 2006, 10:22:44 PM EST )
Permalink
Comments [0]
Who's dime is it anyway ?
Finally - a pratical use for the junk that is Roomba
Two fellow geeks took the Roomba vacuum, tricked it up and played real life Frogger with it on the streets of Austin. I m glad someone found a practical use for that piece of over hyped electornic junk.
The entire photo gallery can be found here
Posted by sameert
( Mar 16 2006, 09:29:10 PM EST )
Permalink
Comments [0]
Goonda music
I came across some new music recently - what sounded like Punjabi Gangstah rap and found it worth buying yet strange at many different levels.First in the US, unlike the UK,theres no such thing as an Asian gang thats remotely involved anyone from the sub-continent and second because I ve never quite fully understood the fascination some second/third generation Indian teens have with dressing all hip-hop ghetto - loose baggies with with underwear showing, timberlands with laces untied and all the rest that goes along with that.
Heres an example Bohemia's album Pesa Nasha Pyar (Translation: Money, Drugs, Love)
Eitherway-I'll leave the analyis to the anthropology grads and the CD's in my car.
Posted by sameert ( Mar 13 2006, 10:03:24 PM EST ) Permalink Comments [0]
A billion equals 100 Crores
Forbes recently came out with its list of Billionaires for 2006. There are now 23 Indians in that list with a few first timers.Wipro's Azim Premji is the second richest Indian, with a net worth of $13.3 billion. He is followed by Mukesh Ambani ($8.5 billion), Anil Ambani ($5.7 billion), real estate developer Kushal Pal Singh ($5 billion owns DLF), Interstingly its one of DLF's propperties I mentioned below at $1000 a yard....Sunil Mittal ($4.9 billion), Kumarmangalam Birla ($4.4 billion) and Shiv Nadar ($4 billion). The notable Indian newcomers to the Forbes's big league include Tulsi Tanti ($1.4 billion), who owns Asia's largest windfarm, online gaming mogul Anurag Dikshit ($3.3 billion) and liquor baron Vijay Mallya ($1 billion) who just started Kingfisher Airlines - yes as in the beer Kingfisher !According to Forbes - strong stock markets around the world, with the US remaining a notable exception (surprise surprise) have contributed to this surge in wealth.
Hopefully next time this list will have some Indian women in there as well! Posted by sameert ( Mar 10 2006, 08:45:14 PM EST ) Permalink Comments [0]
Fennel after meals
Crunch these numbers - residential property (land only) is about $1000 a yard in the outskirts of Delhi and is sold out, two bedroom apts miles outside Delhi are selling for $85-150K - the economy is growing at 6-7% and equity based mutual funds are projecting returns of 35% !
Coincidently Mr Bush was also visiting around the same time making all kinds of nu-clear and un-clear deals and I actually agree with him on one thing he said . The size of the middle class in India 300 mill - thats about the size of the entire US population today. Thats 300 mill strong consumer market thats buying everything from Ford cars, Levis, Nokia Razr's to McDonald burgers. All you need to do is look around in India and its evident that while some companies may be outsouring jobs, a larger chunk of them are doing all they can to tap into this new and growing market and produce upwardly pointing quarterly profit graphs.
Theres still a lot that hasnt changed though - for example you can still get away with murder ! Posted by sameert ( Mar 08 2006, 11:12:13 AM EST ) Permalink Comments [0]
Fix You - X&Y;
Coldplay - Fix you Posted by sameert ( Feb 12 2006, 01:00:00 AM EST ) Permalink Comments [0]Are you documented - JWSDP 2.0 on Glassfish - Arrgh !
You're left wondering - what the heck ! And like any other developer I did the rinse and repeat - and landed up in the same spot on any machine I touched.
It turns out theres a bug in the installer. If you dont export the display (yes even in console mode) it silently exits at the end. The funny part is on the first box I exported the display to try the GUI (which I didnt use because it was slow over the network) so it worked. Took me a half a day and a bunch of emails to figure out that this is a "known" but "undocumented" bug.
Consider it documented here now :)
Posted by sameert ( Jan 27 2006, 04:53:12 PM EST ) Permalink Comments [0]
Remember what you searched for in June 2005 ?
So the subpoena requires Google , AOL and Yahoo to hand over information about searches, websites and foo-bar from June-July 2005. Do you remember what you searched for in that period ?While its funny, it does make you think, especially if you use Google as your primary "toolbar" search engine. Every thought, idea or ideas you've even flirted with in a search, (was always being) tracked, possibly linked and now being correlated back to you using the simple IP address. Heres a CNET faq . Posted by sameert ( Jan 20 2006, 11:36:12 AM EST ) Permalink Comments [0]
The eye in the sky
I was playing around with a bunch of GIS software out there and its amazing what you can do. Heres a satellite picture of the Sun campus zoomed to 25 yard resolution. You can actually see blinds in some of the windows ! If you zoom the picture in photoshop, you can read the time on the clock tower at 4:10 pm !EsUVee ?
Theres this wierd campaign on , apparently sponsored by the govt, to stop SUV roll-overs with better tyre pressure and speed slower speeds. Perhaps the messasge should be not to buy gas guzzing monstrosities in the first place ?
Posted by sameert
( Dec 16 2005, 10:13:40 AM EST )
Permalink
HP's Niagara bashing site
HP put this up earlier, its supposed to be a "HP's Niagara Bashing" site as reported by CNETIt almost reads as though HP fears that which is inevitible in the IT industry - change !
After reading it, I felt more inclined to buy a Niagara box, at least thats what a friend of mine commented :) Posted by sameert ( Dec 09 2005, 10:51:57 AM EST ) Permalink Comments [0]
If you think your office space sucks....
If you think your cube is dark,damp and claustrophobic, think of what it must be like to work out of a bunker. This is taking the "buried in work" phrase quite literally.
Symantec's UK facility is buit in a decommissioned cold war
nuclear bunker
Posted by sameert
( Nov 28 2005, 08:23:31 PM EST )
Permalink
Comments [0]
Longhorn, India and marketing !
I was a little surpised when my seventh grader nephew in India asked me if I was going to get Longhorn when it comes out in 2006 ? When I asked if he had heard of Linux or Solaris he drew a blank. It seems that the hype and buzz that the marketing machine, churning away at MS, has created, seems to be working - not just in the US but globally. Maybe someone needs to take 1-oh-1 lessons from these guys in how to get the word out about some of the cool stuff at Sun Posted by sameert ( Aug 05 2005, 12:17:14 PM EDT ) Permalink Comments [0]JavaOne & Microsoft
The JavaOne 2005 is special indeed. This will be the first time Microsoft will be there. There is a special one day Interoperability track scheduled for 06/29 and my BoF-9911 is a part of that. More details here Posted by sameert ( Jun 09 2005, 09:12:44 PM EDT ) Permalink Comments [0]Motivation
| Thanks to Adobe, I ve now started questioning why I need to hit the gym anymore ! |
John Hagel & SOA
So according to what I read here, he encourages CIOs "to approach architecture from the outside-in starting with the challenging issues of orchestrating IT resources across enterprise boundaries and then addressing the easier issues of orchestrating IT resources within enterprises boundaries"Hmm...This is contrary to what most arhictects I know believe. But it makes good sense. Some customers seem to be using web services heavily to integrate with business partners, mostly because of necessity and partially because of perceived cost reductions. Posted by sameert ( Mar 31 2005, 02:27:48 AM EST ) Permalink Comments [0]
CEC Conference
I presented a Technical Session on SOA and Web Services at CEC (Customer Engineering Conference) this weekend. CEC is an intersting Sun conference witth a set of general sessions by people like Hal Stern,Jonathan Schwartz and other executives; followed by Technical Sessions on various topics.My talk with Inderjeet Singh was on SOA with Java and we discussed one of my pet projects- the Java Blueprints Catalog Posted by sameert ( Mar 03 2005, 04:10:48 PM EST ) Permalink Comments [0]
Sys-Cons XMLEdge 2005
I did a session on Web Services performance at the XMLEdge 2005 Conference in Boston. Looks like they messed up the description a bit on their web page, but the brochure was printed right. Posted by sameert ( Feb 18 2005, 02:42:25 AM EST ) Permalink Comments [0]More on Interoperability and Document Based Web Services
Part 2 of the white paper has been posted on java.sun.com where we examine some of the strategies discussed earlier around Document Based Web Services, and demonstrate interoperability with C#. Posted by sameert ( Jan 28 2005, 11:26:44 AM EST ) Permalink Comments [0]CT Java users group meeting
I did a presentation around best practices for developing webservices yesterday at the Connecticut Java users group. The review and summary can be found here
Posted by sameert
( Jan 19 2005, 12:00:00 AM EST )
Permalink
Comments [0]
XML-2004
So I attended and presented at XML-2004 this year.It was my first time at this conference, and I have to say this- its by far the neatest XML-Web services conference I ve seen. My paper and tutorial can be found on the conference website at http://www.xmlconference.org Posted by sameert ( Nov 19 2004, 10:12:29 PM EST ) Permalink
Video of session
JavaLive has posted the video of the session as "Web Services Architecture Best Practices" here. There were many attendees and thanks to everyone for their interest ! Posted by sameert ( Oct 20 2004, 01:10:10 PM EDT ) PermalinkJava Conference in Boston
Java Live (Boston) Oct 17-19
Posted by sameert ( Oct 18 2004, 10:46:11 AM EDT ) Permalink
Interview with Sameer Tyagi
The J2EE Website indicthreads.com recently interviewed me on SOA & Web Services. The transcript can be found here http://indicthreads.com/index.php?option=com_content&task;=view&id;=48&Itemid;=55 Posted by sameert ( Oct 12 2004, 03:12:00 PM EDT ) PermalinkPresentation at Application Development Users Group
Application Development & Deployment UG Session(New York), Oct 6-8
Posted by sameert ( Oct 06 2004, 10:46:11 AM EDT ) Permalink
Java BluePrints for Service Oriented Architecture
You can find the transcript of the SOA chat with the Java Blueprints team here :
SDN Chat Sessions Java BluePrints for Service Oriented Architecture
Also the Java Blueprints Catalog is at http://bpcatalog.dev.java.net Posted by sameert ( Sep 20 2004, 10:46:11 AM EDT ) Permalink
Patterns and Strategies for Building Document-Based Web Services
So here is my perspective on document oriented Web Services .
Patterns and Strategies for Building Document-Based Services Services http://java.sun.com/developer/technicalArticles/xml/jaxrpcpatterns/ Posted by sameert ( Sep 18 2004, 10:43:11 AM EDT ) Permalink
Upcoming speaking schedule
Application Development & Deployment UG Session(New York), Oct 6-8
Java Live (Boston) Oct 17-19
XML 2004 (Wash DC) Nov 15-19
Posted by sameert ( Sep 13 2004, 12:44:27 PM EDT ) Permalink





