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

Saturday, 25 September 2010

JDeveloper 11g: Using Log4j in ADF view object

Just like the entity object instance, covered here, the process for an ADF view object, goes like this. First, you add the library as shown in the image on your left hand side. Second, you create a log4j.properties file in:

C:\...\Model\src

 similar to the following example:


# Set root logger level to INFO and its only appender to ConsoleOut.
log4j.rootLogger=INFO, ConsoleOut


# ConsoleOut is set to be a ConsoleAppender.
log4j.appender.ConsoleOut=org.apache.log4j.ConsoleAppender


# ConsoleOut uses PatternLayout.
log4j.appender.ConsoleOut.layout=org.apache.log4j.PatternLayout
log4j.appender.ConsoleOut.layout.ConversionPattern=%-5p: [%d] %c{1} - %m%n


log4j.logger.org.apache.jsp=DEBUG
#Addon for
com.sun.faces.level=FINE






Third, if you want to use logging in several view objects, you need to edit your view object super class code like that:

package tuhra.model.framework;

import oracle.jbo.server.ViewRowImpl;

import org.apache.log4j.Logger;

public class TuhraViewRowImpl extends ViewRowImpl {
  protected Logger logger = Logger.getLogger(this.getClass());
}


and your view object code like that:

public class AllEmployeesRowImpl extends TuhraViewRowImpl implements AllEmployeesRow {...
     public void defineDefaultImage(Number newDefaultImageId){
 ...
                      if (logger.isDebugEnabled())
                         logger.debug("Default Image has been defined!");


 }
}

Next your diagnostic message appears in the log output window:

INFO : [2010-09-25 11:55:18,739] AllEmployeesRowImpl - DefaultImage has been defined!
Finally, if you need more tips about appenders:
http://www.mobilefish.com/developer/log4j/log4j_quickguide_appenders.html

The full source code is available on line:
http://code.google.com/p/nickaiva-blogspot/downloads/list

and is given without any guarantee of support whatsoever.

Thursday, 23 September 2010

Estimate the taxi fare for your routes in Athens, Greece

Many people and mostly tourists, protest about the exorbitant fares paid to taxi drivers, especially in Athens, in greater Attica and other areas. In order to help the passengers in estimating beforehand their fare, I shall publish about  a Greek site, that is it has some text in Greek, I am afraid! So, you can visit the following blog url: http://www.zee.gr/taxi/ and click on taxi estimator to enter your starting point and destination, just by clicking on the map!

Thursday, 16 September 2010

JDeveloper 11g:Using Log4j in an ADF application module

This is another concise instance for using Log4j in  an ADF application module, that is  in a  model project. The steps are quite similar:
starting with adding the log4j library, as shown in the image on your left hand side.
Next,  you need to create a log4j.properties file, within:

C:\...\Model\src

just  like the following:


# Set root logger level to INFO and its only appender to ConsoleOut.
log4j.rootLogger=INFO, ConsoleOut
# ConsoleOut is set to be a ConsoleAppender.
log4j.appender.ConsoleOut=org.apache.log4j.ConsoleAppender
# ConsoleOut uses PatternLayout.
log4j.appender.ConsoleOut.layout=org.apache.log4j.PatternLayout
log4j.appender.ConsoleOut.layout.ConversionPattern=%-5p: [%d] %c{1} - %m%n
log4j.logger.org.apache.jsp=DEBUG
#Addon for
com.sun.faces.level=FINE



Third, you need to edit your code just like that:

...

import org.apache.log4j.Logger;

...

public class TuhraServiceImpl extends TuhraApplicationModuleImpl implements TuhraService {

  private Logger logger = Logger.getLogger(this.getClass());

...

public void createNewImageForEmployee(Number employeeId, String imageName){

...
   if (logger.isDebugEnabled())
      logger.debug("New image has been created!");   

    }

}


Finally,  you should see your logger message appear in the log output window;


INFO : [2010-09-16 10:26:16,517] TuhraServiceImpl - New image has been created!

Would you like to refactor?

Moreover, you could move the code line below:


private Logger logger = Logger.getLogger(this.getClass());


 to the super class:


package tuhra.model.framework;
 

import oracle.jbo.server.ApplicationModuleImpl;
import org.apache.log4j.Logger;

public class TuhraApplicationModuleImpl extends ApplicationModuleImpl {

  protected Logger logger = Logger.getLogger(this.getClass().getName());

}



Once more, your custom  logger message should appear in the log output :


INFO : [2010-09-16 15:20:02,247] TuhraServiceImpl - New image has been created!

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/

Tuesday, 14 September 2010

International Herald Tribune edition is now available in Greece, by Kathimerini

For those interested in learning news from the inside, about Greece: 
http://www.ekathimerini.com/

Comments on Oracle SOA Suite 11g R1 Developer's Guide, by Matt Wright and Antony Reynolds

On the bright side, the text is well written in British English,  and neatly organized as well. It is based on the successful recipe of the previous book about 10g SOA and it's  divided in three parts: the first is a short introduction to the Oracle SOA Suite and its various components, and will give you an fast-paced, but limited hands-on, introduction to each of the key components. The second section provides a brief best-practice guide to applying the various components of the SOA Suite to implement a real-world SOA-based solution; it illustrates this through the development of an auction site (oBay) whose source code is actually missing! The final section covers other subjects, such as the packaging, deployment, testing, security, and administration of SOA applications.
On the dark side, some hands on practice although realistic, require a permanent connection to the internet, since currency rates conversion and stock exchange quotes are necessary for testing your BPEL process. These are not always available (I got many "Server too busy" messages) and this might hinder you from completing your practice correctly. Besides, the source code offered publicly, contains only the final solution, but no solutions for the intermediate steps, nor sample inputs for testing, i.e. EUR for the euro currency. Furthermore, the code for oBay application is actually missing and so is its installation guide, mentioned in the text. I think the approach about self contented practice taken by the other competitor: Getting started with Oracle SOA 11g suite is by far better. In fact, its step by step instructions are more exact and easier to follow.
In summary, the book offers a sound theoretical basis better than its competitor, but it is so much weaker in guidance  and in hands on practice. Moreover, some chapters, such as 18 about business rules, are rather purely descriptive and hence difficult to follow. Whether you need such a book which resembles the free on line Oracle Fusion SOA developer guide manual, it is up to you. It targets developers or  technical architects who work in the SOA domain. Of course there are some prerequisites, I quote: "You need basic understanding of the concepts of SOA, as well as some of the key standards in this field, including web services (SOAP, WSDL), XML Schemas, and XSLT (and XPath)". Finally, you need a fast computer, preferably with more than 4GB of memory, to setup the SOA suite.

Sunday, 12 September 2010

JDeveloper 11g:Using Log4j in ADF business components projects

In case you prefer using  ADF business components in your Model project, the procedure for using log4j logging is almost identical with the EJB way. You might also read an example on using logging within an ADF application module as well.
First, you need to add the library, by double clicking your Model project, as you can see on your left hand side.
Second, you need to create a log4j.properties file within:
C:\...\Model\src

just  like the following:


# Set root logger level to INFO and its only appender to ConsoleOut.
log4j.rootLogger=INFO, ConsoleOut

# ConsoleOut is set to be a ConsoleAppender.
log4j.appender.ConsoleOut=org.apache.log4j.ConsoleAppender

# ConsoleOut uses PatternLayout.
log4j.appender.ConsoleOut.layout=org.apache.log4j.PatternLayout
log4j.appender.ConsoleOut.layout.ConversionPattern=%-5p: [%d] %c{1} - %m%n

log4j.logger.org.apache.jsp=DEBUG
#Addon for
com.sun.faces.level=FINE



Third, you edit your entity object code like that:
...
import org.apache.log4j.Logger;



public class ImagesImpl extends TuhraEntityImpl {
...


    private Logger logger = Logger.getLogger(this.getClass());
  ...


    private void adjustImageUsages(RowSet newImageUsagesBeforePost) {
   ...

      if (logger.isDebugEnabled())
             logger.debug("ImageUsages has been adjusted");
        }

...
}

Finally the message you created appears in the log output window:
INFO : [2010-09-12 09:56:32,593] ImagesImpl - ImageUsages has been adjusted

Would you like to refactor?

Furthermore, if you use logging within multiple entity objects, you could move the declaration code line:

private Logger logger = Logger.getLogger(this.getClass());

to the super class:

package tuhra.model.framework;

import oracle.jbo.server.EntityImpl;
import org.apache.log4j.Logger;

public class TuhraEntityImpl extends EntityImpl {
  protected Logger logger = Logger.getLogger(this.getClass());
}



Upon commit, the logger output appears once more:

INFO : [2010-09-16 10:28:07,288] ImagesImpl - ImageUsages has been adjusted

For dynamic changes of logging levels, one can consult for example:
dynamically-changing-log-level-with-weblogic-log4j-jmx-and-wlst/


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/

Saturday, 11 September 2010

JDeveloper 11g:Using Log4j in a JSF backing bean

Another example which might prove useful to JSF or ADF developers,  is logging within a backing bean.
First, you need to add the Log4j.jar by double clicking the ViewController project. You can see the library window on your left handside, showind the jar already added. Note that you can use logging via log4j in combination with ADFLogger, that is if you are using ADF, or even without it.

Second, you need to create the log4j.properties file in ViewController/src. Another  log4j.properties sample file is given here, for your convenience:


# Set root logger level to INFO and its only appender to ConsoleOut.
log4j.rootLogger=INFO, ConsoleOut

# ConsoleOut is set to be a ConsoleAppender.
log4j.appender.ConsoleOut=org.apache.log4j.ConsoleAppender

# ConsoleOut uses PatternLayout.
log4j.appender.ConsoleOut.layout=org.apache.log4j.PatternLayout
log4j.appender.ConsoleOut.layout.ConversionPattern=%-5p: [%d] %c{1} - %m%n
log4j.logger.org.apache.jsp=DEBUG
#Addon for
com.sun.faces.level=FINE



Third, you need to code! The example bean code follows:
...
import org.apache.log4j.Logger;
...
public class ImageUploadBean extends TuhraBackingBean implements Serializable {
  private Logger logger = Logger.getLogger(this.getClass());
 
...
 private void insertRows() {
...
    if (logger.isDebugEnabled())
       logger.debug("Succeeded in adding new image!");
    }
}

Finally, your message appears in the log window:

INFO : [2010-09-11 21:47:52,005] ImageUploadBean - Succeeded in adding new image!

Would you like to refactor?

Furthermore, if you use logging in several beans, you could move the declaration code line:

private Logger logger = Logger.getLogger(this.getClass());
 


to the super class TuhraBackingBean:

package tuhra.view.framework;

import oracle.adf.model.BindingContext;

import oracle.binding.BindingContainer;

import org.apache.log4j.Logger;

/**the purpose of this framework class is to
access the commonly used properties.
 */
public abstract class TuhraBackingBean {
   
    protected Logger logger = Logger.getLogger(this.getClass());
 
  /**the purpose of this framework method is to
  access the bindings programmatically.
   */
    public BindingContainer getBindings() {
        return BindingContext.getCurrent().getCurrentBindingsEntry();
    }
}

Then the log outputs once more:
INFO : [2010-09-16 09:46:37,767] TuhraServiceImpl - New image has been created!
INFO : [2010-09-16 09:46:37,767] ImageUploadBean - Succeeded in adding new image!


where the first info message comes from the application module code (this could be another example I suppose!), while the second from the aforementioned backing bean. You could follow more or less the same steps for JDeveloper 10g too.
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/ 

Beware of Greeks Bearing Bonds Business: vanityfair.com

This is an article written by a journalist, who actually visited Greece to see for himself. He saw quite a lot, even if he only stayed for a while, unlike the Greek politicians who have been ruling for decades! Go ahead: Beware of Greeks Bearing Bonds Business: vanityfair.com

Thursday, 9 September 2010

Comments on Project Management Body of Knowledge, PMI

On  the bright side, the text is well written,  in American English and  neatly organized, without any misspellings or errors. Its style is formal and actually contains all there is to know, in order to sit for the project management institute examinations. Its scope is by far more general than the compTIA Project + exam guide, which  focuses mainly on IT projects. The forth edition is revised and now includes new additions, such as requirements gathering.
On the dark side, some of the paragraphs can be so long that studying it, might become a drudgery. Moreover, there are no questions and answers, exercises or problems for the reader to solve. in order to reinforce learning.
All in all, this is the bible of the manager, full of information, but its formal structure resembles more of  a reference manual, not a course book to prepare for the exam.


Comments on Mesoscale Meteorological Modeling, 2nd Edition Volume 78 By Roger A. Pielke, Sr.

On the bright side, the text is well organized, without many misspellings or typographical errors. The book aims to graduate level readers and researchers. It offers a wealth of information, bibliography references and chapter notes.
 On the dark side, the thermodynamics chapter has been reported to have some ambiguities about i.e.  conservation of heat.  During my postgraduate studies I was assigned to study the 1rst edition of the book, so as to be examined orally. Thus, in the absence of exercises or questions,  I had to write my own, corresponding to each paragraph of text. I suppose having spent such a large amount of time and effort made me wonder, whether the newer edition offered such supplements. I am afraid it doesn't!
All in all, the book is advanced text and the reader is assumed to have perfect knowledge of several topics, especially statistical physics. Its second edition proves its success, but as far as  the student  is concerned, adding some sort of practice would mean great help.

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.

Wednesday, 1 September 2010

JDeveloper 10g: Deployment of JHeadstart application to OAS 10.1.2


A common demand by customers in the public sector, is keeping their usually many years old, existing application server installations intact and rarely upgrade to newer versions. Others say that buying new hardware is far too expensive. Sometimes compatibility reasons, i.e. simultaneous use of older Oracle forms applications, tie you up. Furthermore, why should one mess up a smoothly up and running   1.3 JEE application server, after all?
Developer's nightmare
The sad thing is that customers usually inform you of such requirements, only when you have already finished testing at the current version of the J2EE container of the Oracle Application Server or OAS, the one embedded in JDeveloper (that is in our case: 10.1.3) and the contemporary stand alone J2EE 1.4 OC4J instance!
Whatever the extra cost of effort, time and money, the developer is to conform to the customer rules. The integrated scope changes control process mentioned in the Project Management Body of Knowledge are vastly considered purely theoretical in Greek software houses. In practice, the competition is very hard, no manager can afford a displeased customer. On the other hand, bear in mind that plain programmers are dispensable. I only wonder what are the working conditions abroad? Please respond, with as many details as possible!
So, if you are finally stuck to the older version of OAS, you might consult a brief deployment guide to a test server at :
http://code.google.com/p/nickaiva-blogspot/downloads/detail?name=DeployToOAS_v2.pdf&can=2&q=
Perhaps reading it, might save you some time and frustration...

Further critical references concerning ADF:

Tales from the trenches by Dr. Dorsey. Coauthor of JDeveloper 10g hanbook.