Thursday, June 18, 2009

Interfaces, Inheritence and Hibernate

How to choose: Inheritence or Interface?
  • Idea 1: If the relationship is more an "is a", use inheritance. If it is more a "can be", use interface. Examples: TextBox "is-a" Control, ArrayList "can-be" enumerated.
  • Idea 2: If your object is a specialization of another object, use inheritance. But if the feature that distinguishes the derived class from the base class is something that other classes may need to support as well, an interface is a better choice.

Monday, June 15, 2009

Flash Builder 4, Hibernate and Eclipse: Working Together

So, we at OLCC decided to give Flash Builder 4 (beta) a try. So far, we have been working only with a small sample using the JEE for its server tier, but already have learned a few valuable lessons:

Creating a New Flex Project
  • Accept the folder names flex_src, bin-debug; the FB4 doesn't deal correctly with non-default values.
  • After creating a project, go to .flexProperties and set the serverContextRoot="/YourProjectName". After opening Properties->Flex Server window, reset this value of serverContextRoot.
  • Instead of using mx:Text, there is now s:SimpleText control.
Error 404, when trying to Debug the application

When we got this, we saw the URL that FlashBuilder is trying to use to start the HTML wrapper is http://localhost:8080/ProjectNamebin-debug/Main.html. The bin-debug definitely shouldn't be there. We also noticed, that this same URL shows in the project properties on Flex Build Path page as the Server Root URL. It can't be fixed there, but we fixed it in the Debug run configuration. Trying to use Run instead of Debug was even more messy. For some reason, it tried to connect the debugger to the FlashPlayer (yes, in Run mode).

PermGen Issue

Also, recently, we had problem with running out of the space in PermGen. The only solution we found, was to reduce its size (yes, reduce!) from the default 256M to 128M.

The funny thing is, we had eclipse running fine for a long time. Then, when we installed a 2nd instance of eclipse, using a separate workspace, we started experiencing this problem. When we used the 256M, and any serious action crashed the Eclipse, we ran the eclipsec.exe which showed an error message "not able to find enough memory to start jvm with these options" or smth like this. That's why we have reduced the memory. We haven't had the PermGen issue since then. I don't understand this issue really, it's more a trial-and-error solution, but it works.


For Hibernate, we use:
  • Database Development perspective provided by eclipse
  • Hibernate installed via GlassFish admin console (we pointed eclipse compiler at it)
  • Hibernate Tools from JBoss Tools (installed just the hibernate tools through the eclipse update site
  • JavaDB bundled with GlassFish server
This configuration seems a good mix. That's it for now.

Tuesday, June 9, 2009

GlassFish Application Server: Introduction and More

This blog summarizes what I have found interesting or not-obvious about the Sun's open source enterprise application server called GlassFish. If you think, any of the info in this blog is not precise or just incorrect, feel free to comment.

  • Version 2.1 of GlassFish is the final version that implements Java EE 5. Version 3.0 of GlassFish is the first one that implements Java EE 6. It's a preview, but ready for production.
  • Server Domain: a new concept introduced into GlassFish that means one or more server instances that can be managed as a whole by an administrator. For developer, domain=server instance. For administrator, it can comprise of multiple, clustered server instances. Each domain, even if all domains are local, runs in its own JVM (there is also one JVM instance associated with the server administration/control, it seems). More info.
  • Virtual Server: to be finished...