Wednesday, October 22, 2008

Reformat and Optimise code in IDEA

These are the shortcuts to reformat and optimize the code.

Alt+Ctrl+L / Alt+Ctrl+O

Sunday, October 12, 2008

hessian binary web service protocol

The Hessian binary web service protocol makes web services usable without requiring a large framework, and without learning yet another alphabet soup of protocols. Because it is a binary protocol, it is well-suited to sending binary data without any need to extend the protocol with attachments.
http://hessian.caucho.com/#Java

In our project i needed to write a test client in C# to use Exposed java API methods.For that I used HessianC#. I added hessiancsharp.dll to the .NET project.
http://www.hessiancsharp.org/

in Java , its like this.
bean id="advertisementService" class="org.springframework.remoting.caucho.HessianProxyFactoryBean"
description Proxy for the user service using HTTP. /description
property name="serviceUrl" value="${admanager.url}remoting/secured/advertisementService"/
property name="serviceInterface" value="com.fastsearch.admomentum.admanager.advertisement.client.ExposedAdvertisementService"/
property name="serializerFactory" ref="hessianSerializer"/
property name="username" value="advertiser@test.com"/
property name="password" value="password"/
/bean

Thursday, October 2, 2008

XSLT

XSL stands for EXtensible Stylesheet Language. The World Wide Web Consortium (W3C) started to develop XSL because there was a need for an XML-based style sheet language. XSLT stands for XSL Transformations. We can use XSLT to transform XML documents into other formats, like XHTML.
http://www.w3schools.com/xsl/default.asp
In my project i used it to transform xml document to csv file.
TransformBillingXmlToCsv.xml

xsl:template name="amount"
xsl:text " /xsl:text
xsl:value-of select="currencySymbol"/
xsl:text /xsl:text
xsl:choose
xsl:when test="currencySymbol = 'JPY'"
xsl:value-of select='format-number(value, "#.")'/
/xsl:when
xsl:otherwise
xsl:value-of select='format-number(value, "#.00")'/
/xsl:otherwise
/xsl:choose
xsl:text " /xsl:text
/xsl:template

(tag characters are removed from above sample code)
Here i had to use XSLT format-number() Function and XSLT Element.

http://www.w3schools.com/XSL/func_formatnumber.asp
http://www.w3schools.com/xsl/el_when.asp