You can extend Content Engine functionality with your own server components by implementing the following Java™ interfaces in the com.filenet.api.engine package:
EventActionHandler
. An implementation of this interface executes as part of a subscription, when a subscribed system or custom event is triggered.DocumentLifecycleActionHandler
. An implementation of this interface executes as part of a lifecycle policy attached to a document or document class, when a document state is changed. Document states are user-defined.DocumentClassifier
. An implementation of this interface automatically classifies a new document based on its mime type.An event action handler can be configured to run synchronously or asynchronously. A lifecycle action handler always runs synchronously, and a document classifier always runs asynchronously.
This topic provides restrictions and best practices for implementing an event action handler, lifecycle action handler, and document classifier. As a group, all implementation types are generically referred to as "action handlers."
For additional information about these interfaces, see EventActionHandler, DocumentLifecycleActionHandler, and DocumentClassifier in the Javadoc™ documentation. To view sample source code implementations of these interfaces, go to this Content Engine directory: <drive>:/Program Files/Filenet/Content Engine/samples.
showMessageDialog
and showInputDialog
methods are forbidden.Updating the source object in an synchronous event action handler results in persistence issues. When the event handler is called, a Save
method is already in progress for the source object. The actual persistence of this object will occur shortly after the completion of any event handlers that must execute. If another Save
method were to be explicitly called in the event handler, one of two things could happen:
Save
method would cause another set of subscriptions to be triggered for the object being saved. This would likely result in another event handler executing recursively, causing a loop that would only end with a stack overflow in the server, or a transaction timeout. This recursive loop can also occur if you attempt to call Save
on a copy of the source object.Save
method would cause the persisting of the object to occur twice. Since the server blocks this case by checking the epoch of the object, this would also cause the transaction to fail.Save
method on the fetched source object of the event, as long as there is no infinite loop to waste system resources.
Do not update the source object instance passed to the event handler because, in asynchronous mode, the source object may already have changed before the event handler executes, and, therefore, the event's source object may be obsolete.
...
ClassDefinition myNewDocSubclass = createDocSubclass();
Document doc = Factory.Document.createInstance(objectStore, myNewDocSubclass.get_SymbolicName());
doc.save(RefreshMode.REFRESH);
If an event requires a long running task to execute, consider changing the timeout setting, or using a queued component or another mechanism to defer the work beyond the limit of the transaction. The EJB transaction timeout is defined in the Java 2 Enterprise Edition (J2EE) application server console. The default value of this timeout is different on each application server. See your application server documentation for information on this default and how to change it.
...
catch (IOException e)
{
ErrorRecord er[] = {new ErrorRecord (e)};
throw new EngineRuntimeException(
e, ExceptionCode.EVENT_HANDLER_THREW, er);
}
All messages will go to the application server's log file. For more information about the Content Engine exception-handling framework, see Exception-Handling Concepts.
System.out.println()
call.