OFBiz Component Creation

Anchal Sharma
Viithiisys
Published in
3 min readMar 1, 2018

Introduction to Component

OFBiz is organized into groups of directories and files where some directories have a special meaning and are called “Components”. To find an OFBiz Component is to find the top-level directory where the Component begins and to locate the configuration file ofbiz-component.xml used to configure that Component. Following are the set of OFBiz components :-

  • Framework Components: The framework directory contains all the Components which are necessary to run OFBiz. Many of the other Components have dependencies on Components in this directory. This directory is loaded at the beginning during system initialization.
  • Application Components: The application directory contains Components that represent many of the business related Applications packaged with OFBiz. For example, you will find the manufacturing, content management, and order management Components and associated Applications in this directory.
  • Hot-deploy Components: The hot-deploy directory is intended for the placement of new Components and Applications. Out of the box it is empty, containing no OFBiz artifacts.
  • SpecialPurpose Components: The specialpurpose directory contains yet more OFBiz packaged Applications and Components. OFBiz components reside in the specialpurpose directory.

Setting it up :-

To create a new component, the following project parameters are used

  • PluginId: Mandatory.
  • PluginResourceName: Optional, default is the Capitalized value of pluginId.
  • WebappName: Optional, default is the value of pluginId.
  • BasePermission: Optional, default is the UPPERCASE value of pluginId.

Component Structure:

Sample Component Structure

Creating component:-

It’s very easy to setup a new component in OFBiz in plugin directory. By using this command you can start create a new component.

For Windows: > gradlew createPlugin -PpluginId=mycomponentFor Linux/Mac: $ ./gradlew createPlugin -PpluginId=mycomponent

or

For Windows: > gradlew createPlugin -PpluginId=mycomponent -PpluginResourceName=MyComponent -PwebappName=mypluginweb -PbasePermission=MYCOMPONENT`For Linux/Mac: $ ./gradlew createPlugin -PpluginId=mycomponent -PpluginResourceName=MyComponent -PwebappName=mypluginweb -PbasePermission=MYCOMPONENT`

where “mycomponent” is the name of the new component in the command.

The above commands achieve’s the following:

  • create a new plugin in /specialpurpose/mycomponent
  • add the plugin to /specialpurpose/component-load.xml

You can also delete the component by using this command:-

For Windows: > gradlew removePlugin -PpluginId=mycomponentFor Linux/Mac: $ ./gradlew removePlugin -PpluginId=mycomponent

Once the component is created, you should load its data (required to grant access rights to the “admin” user), you can easily do this by loading the demo data of OFBiz with the command.

Note: Depending on your Internet connection speed it might take a long time for this step to complete if you are using OFBiz for the first time as it needs to download all dependencies. So please be patient!

  • It builds OFBiz and loads the demo data.
For Windows: > gradlew loadDefaultFor Linux/Mac: $ ./gradlew loadDefault
  • It indicates that you are using a gradle wrapper. The wrapper is generally part of a project and it facilitates installation of gradle. It will compile all modules and leave you an executable jar (ofbiz.jar) in the “ofbiz/build/libs” directory.
For Windows: > gradlewFor Linux/Mac: $ ./gradlew
  • To run the server you can use this command.
For Windows: > gradlew ofbizFor Linux/Mac: $ ./gradlew ofbiz
  • To shutdown the server you can use this command.
For Windows: > gradlew “ofbiz--shutdown”For Linux/Mac: $ ./gradlew “ofbiz--shutdown”

By sharing the above blog I hope I have covered every aspect of component creation and it will also help to promote OFBiz and share implementation experiences among the users all over the world.

If you have any suggestions or queries related to this project you can comment below or ping me on Linkedin.

--

--