Wednesday, 6 October 2010
JDeveloper 11g: Using assert() for testing and debugging
protected void doDML(int operation, TransactionEvent e) {
if (operation == DML_UPDATE) {
...
histStartDate = row.getEndDate();
/*Check whether end date equals current date*/
/*if (histStartDate.equals(new Date(Date.getCurrentDate()))){
System.out.println("End date equals current date!");
}*/
assert(histStartDate.equals(new Date(Date.getCurrentDate() ) )) :
"End date equals current date! ";
Another trivial example from an ejb client follows:
public class PlaceBidClient {
public static void main(String [] args) {
...
Bid bid = placeBid.addBid("Lila", Long.valueOf(100), 2001.50);
System.out.println("Bid Successful, BidId Received is:" + bid.getBidId());
assert(bid.getBidId() == 502):"BidId Received is "+bid.getBidId();
}
}
Finally, when run, the log output reads:
-javaagent:C:\Oracle\Middleware\jdev_11gR1\jdeveloper\..\modules\org.eclipse.persistence_1.0.0.0_2-0.jar -Duser.language=en -Duser.country=US -ea actionbazaar.buslogic.client.PlaceBidClient
Exception in thread "main" java.lang.AssertionError: BidId Received is 393
at actionbazaar.buslogic.client.PlaceBidClient.main(PlaceBidClient.java:24)Bid Successful, BidId Received is:393
Sunday, 3 October 2010
A free site for sports funs: http://www.woop.gr/
Finally, if you would like to try other online tv channels there is http://2onlinetv.com.
Saturday, 25 September 2010
JDeveloper 11g: Using Log4j in ADF view object
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
Thursday, 16 September 2010
JDeveloper 11g:Using Log4j in an ADF application module

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!
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
http://www.ekathimerini.com/
Comments on Oracle SOA Suite 11g R1 Developer's Guide, by Matt Wright and Antony Reynolds
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
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
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
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!
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