Chapter 2. Java Development

In this chapter, we will cover

  • CLASSPATH basics
  • Java file naming conventions
  • Creating OFBiz Java Events
  • Creating OFBiz Java Services
  • Debugging
  • Calling an OFBiz Service from a Java program
  • Java programs and request parameters
  • Error messages: best practices
  • Using properties files
  • Sending e-mail
  • Manipulating XML files

Note

Note: This chapter is not intended to instruct Java developers planning to commit code back to the OFBiz project. Such code is subject to the OFBiz Contributors Best Practices document found at:

http://cwiki.apache.org/confluence/x/JIB2

Introduction

Before you can write effective OFBiz Java code, you need to understand some basics about the environment in which OFBiz operates. In the previous chapter, we learned that OFBiz executes within a JVM. That JVM, in turn, hosts a Java servlet container. The servlet container provides all the basic programming infrastructure necessary to build and run OFBiz web applications (sometimes referred to as "webapps").

Note

Out-of-the-box, bundled with the distribution, OFBiz embeds the Tomcat servlet container, http://apache.tomcat.org. It is possible to implement other servlet containers as well as run OFBiz within a Java application server such as JBoss, WebSphere®, or WebLogic®.

In this book, we first describe what it takes to develop OFBiz webapps. Traditionally, writing Java web applications has meant writing entire servlets. When writing OFBiz webapps, you typically do not write an entire servlet. Instead, you create one or more Java methods that are invoked by the OFBiz controller servlet either directly as an "Event" or "Service", or indirectly by another Java program.

Running inside a servlet container means that your OFBiz Java code will have access to all the resources necessary to communicate with client browsers; any other OFBiz Service, tool, or artifact on the runtime CLASSPATH; and effectively and efficiently interact with the database.

Beyond writing OFBiz Java-based Events and Services, it is also possible to write entirely new Java classes that may be placed on the CLASSPATH as desired. If placed on the CLASSPATH before OFBiz is restarted, these classes will automatically be loaded and available for use.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.18.198