Posts filed under 'technical'

Java: Overriding Vs Hiding

Here is an interesting piece of code in Java. Say there are two classes, one extending another:
class A {
public static void sampleMethod1() {
System.out.println("In sampleMethod1:A");
}
public void sampleMethod2(){
System.out.println("In sampleMethod2:A");
}
}


class B extends A {
public static void sampleMethod1() {
System.out.println("In sampleMethod1:B");
}
public void sampleMethod2() {
System.out.println("In sampleMethod2:B");
}
}

What is the output of the following:
1. A a = new B();
a.sampleMethod1();

2. B b = new B();
((A)b).sampleMethod1();

3. A a = new B();
a.sampleMethod2();

4. B b = new B();
((A)b).sampleMethod2()

Interestingly, its not possible to invoke a method in the parent which is overridden in the child class, from a child class instance. Its a dependency on the runtime object type. At the same time, you can always invoke a static method hidden in the child class by type casting it or using an object reference of type its parent. Its a static binding at class level.

Add comment September 11, 2008

Downloading WSDL using JDeveloper 10g

If you are working on Web services and want to download a WSDL to your local system, here is a nice tool from JDeveloper 10g. If you don’t already have JDeveloper with you, download recent 10g version from here:

http://www.oracle.com/technology/software/products/jdev/htdocs/soft10131.html (Get the J2EE or Studio version). Run the below command:

java -jar wsa.jar -fetchWSDL -wsdl <WSDL_URL> -output <LOCAL_OUTPUT_DIR>

The wsa.jar will be under <JDev_INSTALL_DIR>/webservices/lib folder. This will download the WSDL including all referred XSDs, if any, to your local drive.

So why do you have to do this? First, this makes life easier when you create a client proxy or use the WSDL in orchestrating a business process or defining an Enterprise Service Bus (ESB). All these tools will have the capability to refer to the WSDL URL and corresponding schemas automatically even if they are not present in the local disk, but they make separate HTTP calls to access them each time, which makes the entire process too long. For example, if you try to create a JDev proxy referring to the WSDL present at your server, it can take up to 30 minutes, where as with a downloaded WSDL, it will be over within 5 minutes… :)

Add comment September 8, 2008


Categories

Blogroll

Friends

General

Feeds

 

December 2009
M T W T F S S
« Oct    
 123456
78910111213
14151617181920
21222324252627
28293031  

Recent Posts

Firefox 3