Thank you for visiting! If you liked the site, please add a bookmark, else add a critical comment! Would you like to visit Greece? Traditional Greek flag This real estate site is only available in Greek! The holy mountain

Wednesday 8 September 2010

JDeveloper 11g:Using Log4j in stateful EJB

Since the use of log4j has proven to be a very popular subject for the readers, another code snippet for your Model project will be  given as an example. In case you prefer ADF business components, you can find an example too. If you 'd also like an example for a backing bean for your ViewController project this time, you  can have it here
First, one has to double click the project, so that the window of the libraries appears, in order to add the Log4j jar library. 
Second, navigate to C:\...\Model\src to create the log4j.properties file:

# **Set root logger level to DEBUG and its only appender to A.
log4j.rootLogger=DEBUG, A
# ***** A is set to be a ConsoleAppender.
log4j.appender.A=org.apache.log4j.ConsoleAppender
# ***** A uses PatternLayout.
log4j.appender.A.layout=org.apache.log4j.PatternLayout
log4j.appender.A.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n


Finally, if one 'd like to use log4j within a  stateful EJB class, the source code is similar:

...
import org.apache.log4j.Logger;

@Stateful(name = "PlaceOrder", mappedName = "ejb3inaction-Model-PlaceOrder")
@Remote
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)  
public class PlaceOrderBean implements PlaceOrder {
    Logger logger =Logger.getLogger(this.getClass().getSimpleName());
...
    @Remove                                                          
    @TransactionAttribute(TransactionAttributeType.REQUIRED)         
    public Long confirmOrder() {
      ...
      em.persist(order);            
      if (logger.isDebugEnabled())
         logger.debug("******************Order confirmed!**************");
      return order.getOrderId();
    }
...
}
Thus, one gets the following log output from the integrated Weblogic server:

Run startup time: 9656 ms.
[Application ejb3inaction deployed to Server Instance IntegratedWebLogicServer]
<2010-09-08 16:00:18.4--ServerSession(1576505)--EclipseLink, version: Eclipse Persistence Services - 2.0.2.v20100323-r6872>
<2010-09-08 16:00:18.416--ServerSession(1576505)--Server: WebLogic Server 10.3.3.0  Fri Apr 9 00:05:28 PDT 2010 1321401 >
<2010-09-08 16:00:18.837--ServerSession(1576505)--file:/C:/Users/Nick/AppData/Roaming/JDeveloper/system11.1.1.3.37.56.60/o.j2ee/drs/ejb3inaction/ModelEJB.jar/_Model login successful>
0    [[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'] INFO  PlaceOrder_i7ibfi_Impl  - ******************Order confirmed!**************


In case you prefer working with Eclipse, the process is quite similar. See for example:
http://snippets.dzone.com/posts/show/3248
Finally, if you need more tips about appenders:
http://www.mobilefish.com/developer/log4j/log4j_quickguide_appenders.html

https://logging.apache.org/log4j/2.x/ 

Sunday 5 September 2010

Comments on Teach yourself JavaScript in 24 hours by Michael Moncur, 4rth Edition

On the bright side, the text is clear, well structured without any spelling errors. Its chapters are structured in such a tidy and concise way, so that its title actually corresponds to its content exactly; a series of timed tutorial lessons, a do it yourself learning course. Each chapter has its questions and answers sections, quiz questions and relevant answers and finally exercises. Its source code is complete and available. The lesson about debugging, DOM and forms validation is valuable as a reference.
On the dark side, the reader has to know  beforehand, some programming essentials,  since the text does not analytically present some subjects in great length and depth, i.e. some complained about the coverage of  loops.
All in all, the book is a success, now in its 4rth edition, offering an introductory course in JavaScript for experienced programmers. Moreover, it is very useful as a reference, offering a wealth of information in its appendixes: other JavaScript resources, tools etc.

Saturday 4 September 2010

Comments on Oracle Application Server 10g: J2EE Deployment and Administration, by Michael Wessler, Erin Mulder, Rob Harrop, Jan Machacek, Apress

On the bright side, the text is very well organized, tight, well written, without spelling errors. It describes  thoroughly all the options available in each screen shot. There are also some tips and  hints about performance tuning, such as using web cache. Its source code is available online as well.
On the dark side, the text resembles more of a manual than a learning course. It has no tutorials, nor end of chapter step by step exercises for the reader to implement on his own, in order i.e. to actually measure any performance gains. The book was published back in 2004 and I quote an interesting paragraph of its presentation text, which can be found at: http://apress.com/book/view/9781590592359
"Oracle Application Server 10g: J2EE Deployment and Administration focuses on the latest version of Oracle's fully J2EE-certified application server (previously called Oracle9iAS). Oracle Corp. is aggressively attacking this market with a new lost-cost version of the server, as well as a program to move BEA customers onto Oracle free of charge. Adoption interest is growing rapidly amidst favorable reports regarding performance and reliability."
All in all, the book might be of use to web administrators with old J2EE 1.3, already running servers. Today, its content is mostly deprecated, as OAS end of life is approaching.