com.gentics.api.contentnode.publish
Interface CnMapPublishHandler


public interface CnMapPublishHandler

Interface for specific implementations that add additional functionality to publish into a ContentRepository. Implementations of this interface can be hooked into the publish process for specific ContentRepositories. The lifecycle is as follows:

  1. init(Map) Called once during the initialization process of the publish handler to take the instance into service
  2. #open() Called once for every publish handler when a transaction is started to write into the content repository
  3. createObject(Resolvable), updateObject(Resolvable), deleteObject(Resolvable) Repeatedly called for every created, updated, deleted object during the publish process or instant publishing
  4. commit() OR rollback() Called once for every publish handler at the end of every transaction (commit on success, rollback on failure)
  5. close() Called once for every publish handler at the end of every transaction
  6. destroy() Called once during shutdown to take the publish handler out of service
When any of that methods throws a CnMapPublishException, the publish process will fail (and the message of the exception will be shown in the publish log).
When instant publishing is not used for the content repository, the publish handlers are only used during a publish process and the whole publish process is done in a single transaction.
When instant publishing is used for the content repository, the publish handlers are also used for every object, which is instantly published into the content repository (which is done in a transaction). Additionally, the publish process will use a new transaction for every object it publishes.
Once a publish handler is initialized for a content repository, it will stay in service until either
  1. The server is shut down OR
  2. The publish handler entry is removed or modified. In this case, the existing instance will be taken out of service and a new instance will be created and initialized.


Method Summary
 void close()
          This method is called once at the end of any publish process.
 void commit()
          This method is called at the end of a successful publish process
 void createObject(com.gentics.api.lib.resolving.Resolvable object)
          This method is called for every object, which is created in the ContentRepository (was created/published since the last publish process into the respective ContentRepository).
 void deleteObject(com.gentics.api.lib.resolving.Resolvable object)
          This method is called for every object, which is removed from the ContentRepository (was deleted or taken offline since the last publish run).
 void destroy()
          This method is called at the end of the lifetime of this handler instance.
 void init(Map parameters)
          This method is called once for every configured instance to take the handler into service.
 void open(long timestamp)
          This method is called once for every configured instance for each publish run.
 void rollback()
          This method is called at the end of a failed publish process
 void updateObject(com.gentics.api.lib.resolving.Resolvable object)
          This method is called for every object, which needs to be updated in the ContentRepository (was changed since the last publish process).
 

Method Detail

init

void init(Map parameters)
          throws CnMapPublishException
This method is called once for every configured instance to take the handler into service. Implementations may read external configuration, and initialize needed resources.

Parameters:
map - of parameters given in the configuration
Throws:
CnMapPublishException - when the initialization of the handler failed with an unrecoverable error

open

void open(long timestamp)
          throws CnMapPublishException
This method is called once for every configured instance for each publish run. Implementations may open connections, prepare resources, etc. The handle methods createObject(Resolvable), updateObject(Resolvable) and deleteObject(Resolvable) will only be called after calling this method and until one of the methods commit() or rollback() is called to mark the (successful or not successful) end of the publish process.

Parameters:
timestamp - timestamp of the publish process
Throws:
CnMapPublishException - when an unrecoverable error occurred

createObject

void createObject(com.gentics.api.lib.resolving.Resolvable object)
                  throws CnMapPublishException
This method is called for every object, which is created in the ContentRepository (was created/published since the last publish process into the respective ContentRepository).

Parameters:
object - resolvable object containing all data that are written into the ContentRepository
Throws:
CnMapPublishException - when an unrecoverable error occurred

updateObject

void updateObject(com.gentics.api.lib.resolving.Resolvable object)
                  throws CnMapPublishException
This method is called for every object, which needs to be updated in the ContentRepository (was changed since the last publish process).

Parameters:
object - resolvable object containing all data that are written into the ContentRepository
Throws:
CnMapPublishException - when an unrecoverable error occurred

deleteObject

void deleteObject(com.gentics.api.lib.resolving.Resolvable object)
                  throws CnMapPublishException
This method is called for every object, which is removed from the ContentRepository (was deleted or taken offline since the last publish run).

Parameters:
object - resolvable object containing what? TODO does it contain all data from the ContentRepository or only the contentid?
Throws:
CnMapPublishException - when an unrecoverable error occurred

commit

void commit()
This method is called at the end of a successful publish process


rollback

void rollback()
This method is called at the end of a failed publish process


close

void close()
This method is called once at the end of any publish process. Implementations should free all resources and close all connections which were allocated/opened in #open().


destroy

void destroy()
This method is called at the end of the lifetime of this handler instance. Implementations should close all connections and free all resources which were allocated in init(Map).



Copyright © 2013 Gentics Software GmbH. All Rights Reserved.