Creating a custom TBO
As my first blogpost, I decided to start off easy and do a (modified) repost of my blogpost on the EMC Community site on how to develop a custom TBO: https://community.emc.com/people/BartThierens/blog/2010/03/15/steps-to-create-a-custom-tbo
The question on how to create a custom TBO is frequently asked on the internet (specifically the EMC and other Documentum related forums), and although there are many other tutorials out there, I felt the need to write down the steps once again in a simple, yet explanatory manner.
"Type-based business objects (TBOs) are the most common types of
business objects. They correspond to custom object types in the Docbase
and used to apply custom business logic to those object types. You
create a TBO by extending a DFC object such as DFDocument.
Type-based objects allow developers to override the typical DFC
methods to add validation logic or change the way that the original
methods behave. You can also add your own custom methods for your own
purposes. Because all objects are created via the object factory, your
TBO is guaranteed to be used even by existing Documentum clients." (dmdeveloper.com)
Steps to create a custom TBO for a type in Composer:
- Create a Type-artifact for your custom type (ie. custom_type or whatever)
- Create an interface ICustomType that extends IDfSysObject or any of its subtypes (even custom ones): IDfFolder, IDfDocument, IMyPreviousCustomDocument. In this example we'll use IDfFolder.
public interface ICustomType extends
IDfFolder, IDfBusinessObject
{
//optional custom methods
}
- Create a class CustomType that implements ICustomType and IDfDynamicInheritance, and
also extends DfSysObject (or DfFolder, DfDocument, ...) if your interface extended another interface than IDfSysObject).
public class CustomType extends DfFolder implements ICustomType, IDfDynamicInheritance
{
//implement optional methods you have defined in the interface
}
- Package the interface and implementation in 2 different jars.
- Create JAR Definition-artifacts for the 2 jars (ie. custom_type_tbo_impl and custom_type_tbo_inter).
- If you have used thirdparty libraries, create jardefs for them aswell and put those in a Java Library-module.
- Create a Module-artifact of TBO-type (give it the same name as your custom type: custom_type) and set the implementation-jardef (+ set the class) and interface-jardef + optional dependencies or required modules.
- dependencies = if you used thirdparty libraries
- required modules = if your TBO implementation references SBO's, TBO's or similar.
- Install the Composer Project in the docbase.
To
view the changes (example webtop):
- Clear your cache (delete the <tomcat>/bin/documentum/cache folder).
- Delete the work folder (delete <tomcat>/work/Catalina)
-
not always needed, but to be safe.
- Clear your browser cache (delete cookies, temp files, ...).
To
use your TBO in your development:
- Add the interface-jarto the classpath of any development projects (Eclipse, Composer,...).
- No need for the implementation-jar as you'll only work with the interface
- Documentum returns proxy-classes that implement your interface but are not the same type as your implementation
- interface: ICustomType
- implementation: CustomType
- object returned from DCTM: CustomType__PROXY
- No need to add your jars to the classpath of the webtop-webapp. webtop downloads them to
<tomcat>/bin/documentum/cache/... dynamically when it needs them.
A Composer Project with an example is added to this blogpost if you want to try it out (change .txt to .zip).
I hope this
helped you out...
For more info or questions, feel free to comment, pm or mail.
Cheers,
Bart
Submitted by bart.thierens on Wed, 24/03/2010 - 10:57.
Attachment
There is a file attached to the blogpost: http://www.docbyte.com/files/Docbyte_CustomTBOExample.txt
Download it, change .txt to .zip and extract it.
Bart