Wednesday, 29 January 2014

1Z0-807 Java EE 6 Enterprise Architect Certified Master Exam

follow-up of [2]

Pfew! Made it! Woohoo! I had answered 73% of questions correctly, and I needed 71%. I should've studied more.

It is Multiple-Choice, and some of the wrong possible answers are really quite close to correct.

Then again, who has to answer a Architectural Question in their business careers in less than 2.5 minutes on average, really?

On to the next step, the Assignment!!

The exam

Most of the exam questions were regarding business use cases.

The exam questions can be broadly separated into three distinct categories:
use cases
of imaginary companies seeking to change/re-evaluate (a part of) their current outdated infrastructure in some fashion
questions on design patterns
when to use them, what their characteristics are, etc. *)
questions on JEE technologies
when would you apply which technologies, given some Non-Functional Requirements (NFR)

*) Seems the books "Core J2EE Patterns", "Real World Java EE Patterns: Rethinking Best Practices" and "Design Patterns: Elements of Reusable Object-Oriented Software" really did help, and were fascinating reads in and of themselves.

References

[1] 1Z0-807 Java EE 6 Enterprise Architect Certified Master Exam
http://education.oracle.com/pls/web_prod-plq-dad/db_pages.getpage?page_id=5001&get_params=p_exam_id:1Z0-807
[2] Architect Enterprise Applications with Java EE - Course
http://randomthoughtsonjavaprogramming.blogspot.nl/2013/09/architect-enterprise-applications-with.html

Tuesday, 21 January 2014

Simple Logging

Had a Dickens of a time, getting logging to work. I thought it would be as simple as assigning a ConsoleHandler to my logger.

Turns out that there's a Loglevel on the ConsoleHandler as well, and it is set to INFO level messages by default.

Just setting the log level on the Logger itself to Level.ALL is just not enough.

The example here is sufficient for the most basic logging of simple one-class Hello-world applications.

Of course, you can always use System.out.println statements instead for simple one-class applications, but I think it's a bad habit to get into.


Configuration


Logging configuration can be done by means of a properties file.[1][2]

The properties file can be added during the startup as VM parameters, for example -Djava.util.logging.config.file=/home/mrbear/NetBeansProjects/jtail/logging.properties.

If no properties file is provided, the default is "lib/logging.properties" in the JRE directory.[2] The default file will only show INFO messages.

The following example will show all logging all of the time.

For information on programmable logging (Class-based), see the references.

The Global Logger

To make logging even in simple cases, as easy as possible, the global logger was introduced and in Java 7 it is easily referenced.
System.out.println("x=" + x);
Can therefore be replaced by:
Logger.getGlobal().finest("x=" + x);
Unfortunately, you still have to set the LogLevel appropriately, similarly as displayed in the first code example above.

Update 2015/03/26: added the Global logger info.

References

[1] Java Logging - Configuration
http://tutorials.jenkov.com/java-logging/configuration.html
[2] LogManager - Javadoc
http://docs.oracle.com/javase/7/docs/api/java/util/logging/LogManager.html