Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!

Andi Eska

+ Follow
since Jun 20, 2003
Andi likes ...
Eclipse IDE VI Editor BSD
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Andi Eska

Achin Gupta wrote:

this is not getting compiled. can,t get the problem. please help.

There is a return statement missing in the case of o instanceof pr544 and ((pr544)o).ivar!=this.ivar

i.e. the return statement is missing after

The other thing is, if you overwrite the equals method you'also have to overwrite hashCode.

By definition, if two objects are equal, their hash code must also be equal. If you override the equals() method, you change the way two objects are equated and Object's implementation of hashCode() is no longer valid.

see Object as a Superclass - the hashCodeMethod
9 years ago

deepak carter wrote:
String s={"tcs","wipro","cognizant"}

how to sort this without using sort method

Which sort Method do you mean? Arrays.sort() ?

The easiest way is to use Arrays.sort().

String[] s={"tcs","wipro","cognizant"}

If that's not an option: you may have a look at BubbleSort Jeff Heaton

9 years ago
The purpose of the visitor pattern is to separate an algorithm from the object structure it operates on.
It seems to me that is not the pattern you are looking for.

You need a pattern that allows you to simplify your conditional logic and that can be done using the Command_pattern
An Example how the Command Pattern can be used to handle Requests can be found on Peter Roses Blog

Another pattern in conjunction with the Command Pattern that may help you is the Chain-of-responsibility_pattern
You'll have to pass create a copy of the original passed values otherwise you perform the same permutations on the permutated values
which produces the duplicates in your result.

simply create a copy at the passed values as the beginning of your permute method, like

And the result will be:123,132,213,231,312,321
as expected.

9 years ago

deepak bhai wrote:represent it , its not aligned properly please help me in this regard. ]

A very easy way is to use String.fomat(...) instead of java.lang.DecimalFormat and specify the width and precision

The following code produces an 2x2 array of right aligned float values

9 years ago

Not mohammed wrote:Hi,

I want to read first 10 lines of a text file and then write the same into a new file:

You'll have to call flush() of your writer additionally it is recomended to close all your streams.
The call to flush is optional when you call close() on a Writer.
In Java 7 you can use the Autocloseable feature i.e. you don't have to call the close method explicitly.

A working example looks something like

9 years ago

Avinash Ga wrote:can you post your wsdl?

Whom do you mean? The original poster? From your question it's not clear whom you are asking.
I can post my but it will not help anything. It's the "same" you'll get when you use the webservice classes from the original post and start the server.
9 years ago

Paul Clapham wrote:And to indulge in even wilder speculation, it looks like it's possible to put infinite loops into the chain of Exception causes:

Although I haven't tried this to see whether it's actually forbidden in some way; the documentation doesn't appear to forbid that code.

No, that's not possible the initCause throws an IllegalArgumentException, that's documented in Throwable#initCause

9 years ago
There is a nice article from Martin Fowers about Inversion of Control Containers and the Dependency Injection pattern
which will hopefully answer all your questions
9 years ago

Rajesh Khan wrote:I am currently consuming a C++ webservice using JAX. (I generated the files using wsimport).
How can i create a server webservice using the existing WSDL file.?

Use wsimport -s sources -d generated http://localhost:6661/oper/?wsdl.
this also generates the WebService (server) Interface.

Rajesh Khan wrote:
Any suggestions what might be going wrong ??
I get the following Errors

Seems like your client is sending a request your java web-service can not handle.

Try to implement the generated WebService interface using the wsimport tool as described above.

You may also compare your original wsdl file and the wsdl file of the java web service for example http://localhost:6661/oper/?wsdl
to see if there are any differences.

9 years ago

shreyas Kulkarni wrote:Can anyone please tell me what are the advantages of using Null object pattern? I tried to search too. I used it in my doubly linked list as first and last node(head and tail) but I am not able to figure out its use.

Using the Null Object Pattern you can avoid null checks and NullPointerExceptions

The Null Object pattern is described in
Robert C. Martins book Agile Software Development, Principles, Patterns, and Practices

Here is the example - let's assume that you have an application that check whether the user is authenticated:

and the code that returns the reference to the User object looks like this:

This way the code that checks whether our user is authenticated should look like the following snippet:

Checking whether the object is null is not only a boilerplate code but it can also give you a lot of bugs e.g. if you forget to check whether the object is null.

And here the Null Object can help you:


plus cleaner client code:


Problem here is the Ws-A will send the request to Ws-B this request &responses I could not log at WS-A.

In this case WS-A is the client of WS-B.

You need to capture SOAP Message on the client side (WS-A). This can be done the following way:


9 years ago

If, however, you also call those private methods from an unsynced method or block, then, yes, you have to sync those private methods.

As long as those private method don't access any fields i.e. class level variables it's not necessary to sync those private methods.

If I have a class that is accessed by multiple threads (e.g. Spring bean with singleton scope used in a web application) can I chain methods safely without synchronizing.

The other question wouldn't it be better to use a request scope bean so that there is no need to synchronize the method(s).

You have a handler for service-A which logs the request and response, and your service-A sends a request to service-B?
If you want service-B to log request and response your service-B needs a similar "log handler" as service-A.

If you only want to look at the SOAP messages run with glassfish with the JVM argument.

Monitoring SOAP Messages Made Easy With JAX-WS RI 2.0.1
How to set "jvm option" or "system properties" in GlassFish ?

9 years ago