This week's book giveaway is in the OCP forum.
We're giving away four copies of OCP Java SE 8 Programmer II Exam Study Guide and have Kathy Sierra, Bert Bates, & Elizabeth Robson on-line!
See this thread for details.
Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!

S Reddy

Ranch Hand
+ Follow
since May 17, 2007
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
12
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by S Reddy


I don't see any downside in having to make POJOs implement Serializable. But just thinking that why somebody else has to force me to do something when it is not absolutely necessary?
If I am going to use hibernate in distributed environment I would make POJOs serializable anyway, hibernate shouldn't forcing me.

And If it ts that Secondary cache implementations needed, why only IDs need Serializable and not actual entities?
I see that hibernate's session.get() and load() methods is accepting only Serializable IDs as argument to get Entities.

As per my understanding of hibernate, it will generate an SQL statement and send it to DBMS when it needs to get a row from DB.
It will never need to send a java object over network.

In that case why hibernate is forcing serialization on us? It can easily use Class to accept IDs.
Even if Serialization has many benefits, I would like to take that decision of making ID objects Serializable on my own.
Is there any specific reason there which I am missing?



above code is printing "Greenwich Mean Time" When I pass "Hongkong", "US/Eastern" as TZ. It is working fine for "GMT", "IST", "JST", "UST", "Asia/Hong_Kong", etc...

Why is it behaving so?... I have taken all above names by using the following code only

9 years ago
I got following answer from Java_Official Yahoo Group.

I think this is because Spring use reflection to initiate your bean and invoke its method.
So even the bean class itself is not visible for the bean factory it still can access it.

Even if it knows that my bean class is there.... it shouldn't access my class because both are in different packages.

According to java rules, only public classes can be accessed from other packages. For this reason only we will specify the class which has main() method (it should be invoked by JVM) as public. Right?
I have a non-public bean class in the package "demo.beans" with some setter methods.


I am setting these values in the Spring configuration file. But, setter injection should be failed since my bean class is in different package and BeanFactory (or XmlBeanFactory) is in different package.

Spring Client Application:


Configuration file:


But, it is running normally. How BeanFactory was able to access my bean class ( with default access ), which is in the other package? How JVM allows this?

If there wasn't a main method, could Mix4 create more Mix4's, like say within a method right in the same class of Mix4?



You can create the object of same class from any method.
10 years ago
It is a rule in Java that you have to allow to send Array of String object to main, whether you will pass parameters at run time or not. Even you don't have any need to send parameters through command line you must write main method like

public static void main(String[] a)

you can use any identifier name in the place of a.
10 years ago
There is no code given in the book. He just mentioned that abstract classes should not contain static blocks. I am just confused why java was developed like that?
10 years ago
There is no explanation. The book is "Java 2 Complete Reference, 5th edition" by TATA - McGraw Hill. Author is: Herbert Schildt.
10 years ago
I have read "abstract classes shouldn't contain static blocks" from Complete reference book. Is this true?

When static blocks are associated with class, why they couldn't be included in abstract classes?
10 years ago
http://java.sun.com/blueprints/patterns/SessionFacade.html

The above link says SessionFacade will reduce network calls made to the server. But how - putting a session bean between client and server - will reduce network calls? We have to still make all the calls to the SessionFacade which is other side on the network. Then how it will reduce network traffic?
DispatchAction and LookupDispatchAction both are used to combine related operations into a single class, so that they can share common resources like helper methods without exposing them to other classes.

DispatchAction selects the method to execute depending on the request parameter value which is configured in the xml file. This will be problematic for internationalized applications since the values will be different for different locales. So, LookupDispatchAction looks into the resource bundle file and find out the corresponding key name. We can map this key name to a method name by overriding the getKeyMethodMap() method.
10 years ago