Creating a custom Module

You can customize and extend the Content Deployer worker by developing custom Content Deployer Modules in Java. A Module can also extend the default Modules to implement functionality that act on the Transport Package data structures.

A custom Module is a Java class that is loaded and called by the Content Deployer worker. The following example demonstrates how to flush the application server cache when new content is deployed:

package com.tridion.examples;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.tridion.transport.transportpackage.*;
import com.tridion.configuration.*;
import com.tridion.deployer.ProcessingException;
import com.tridion.deployer.Processor;
import com.tridion.deployer.Module;

public class CacheFlusher extends Module {
	private static Logger log = LoggerFactory.getLogger(CacheFlusher.class);

	//imaginary appserver API
	AppManager server = CachingAppServer.getManagerInstance();

	public CacheFlusher(Configuration config, Processor processor) 
		throws ConfigurationException {
		super(config, processor);
	}

	// This method is called once for each TransportPackage that is deployed.
	public void process(TransportPackage data) throws ProcessingException {
		try {
			server.flush(config.getAttribute("AppInstance"));
		} catch (ConfigurationException e) {
			log.error("Could not get custom configuration", e);
		}
	}
}