Jive Forums API (5.5.20.2-oracle) Developer Javadocs

com.jivesoftware.forum.gateway
Class DefaultGatewayManager

java.lang.Object
  extended by com.jivesoftware.forum.gateway.DefaultGatewayManager
All Implemented Interfaces:
JivePropertyListener, JiveManager, ForumListener, GatewayManager

public class DefaultGatewayManager
extends java.lang.Object
implements GatewayManager, JivePropertyListener, JiveManager, ForumListener

Manages gateways for a forum, which synchronize the forum with external data sources such as an NNTP newsgroup or email account.

Notes: The default implementation also only knows how to instantiate Gateway implementations that have either a default constructor or one that accepts a ForumFactory and Forum as arguments.

The importing tasks and exportings tasks will only run on the machine that is designated as the senior cluster member. If this machine is removed from the cluster, the tasks will run on the next machine that becomes sr. cluster member.

See Also:
Gateway

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.jivesoftware.forum.gateway.GatewayManager
GatewayManager.Type
 
Field Summary
static java.lang.String IMPORT_INTERVAL_PROPERTY
           
static java.lang.String IMPORT_THREAD_POOL_SIZE_PROPERTY
           
 
Fields inherited from interface com.jivesoftware.forum.gateway.GatewayManager
GATEWAY_EXPORT_RETRY
 
Constructor Summary
DefaultGatewayManager(ForumFactory factory)
          Creates a new GatewayManager.
 
Method Summary
protected  void clusterReInitialize()
          This method is called by a cluster task to reset private variables with values from the database
 void create(Gateway gateway)
          Allows you to add a new gateway to the system
 Gateway createGatewayInstance(Forum forum, java.lang.String type)
          Used to create and return an instance of a gateway based off the gateway settings, this gateway won't be installed as a new persistent gateway.
 void destroy()
          Attempts to shutdown all threads associated with this class
 void executeOnce(Gateway gateway, java.util.Date afterDate)
          Used to execute a import/export on a gateway immediately, the gateway does not need to be a persistent gateway.
 void exportData(ForumMessage message)
          Exports an individual message through all gateways.
 void forumAdded(ForumEvent event)
          Fired when a forum has been added to the system.
 void forumDeleted(ForumEvent event)
          Fired when a forum is about to be deleted from the system.
 void forumMerged(ForumEvent event)
          Fired when a forum is merged into another forum.
 void forumModified(ForumEvent event)
          Fired when a forum is modified.
 void forumMoved(ForumEvent event)
          Fired when a forum has been moved from one category to another.
 Gateway getGateway(long gatewayID)
          Returns a gateway by its id.
 java.util.Collection getGateways()
          Returns all the gateways, this collection is unmodifiable.
 java.util.Collection getGateways(Forum forum)
          Returns all the gateways for a forum.
 GlobalGatewaySettings getGlobalGatewaySettings()
          Returns the global settings for gateways.
 void initialize()
          Initialize the manager.
 void jivePropertyAdded(JivePropertyEvent jivePropertyEvent)
          If the import interval jive property is changed the import task timer is restarted with the new value
 void jivePropertyModified(JivePropertyEvent jivePropertyEvent)
          Restart the import interval if the jive proeprty is changed
 void jivePropertyRemoved(JivePropertyEvent jivePropertyEvent)
          If the import interval jive property is changed the import task timer is restarted with the new value
 void registerCustomGatewayType(java.lang.String type, java.lang.Class clazz)
          Used to register a custom gateway manager implementation.
 void remove(Forum forum)
          Deletes all gateways for this context by removing their properties and stopping them from running.
 void remove(Gateway gateway)
          Delete a specific gateway
protected  void startImportTask()
          Start/restart the gateway import task
 void update(Gateway gateway)
          This method must be called if gateway settings changes are to be persisted.
 void update(GlobalGatewaySettings globalGatewaySettings)
          Updates the global gateway setting.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

IMPORT_INTERVAL_PROPERTY

public static final java.lang.String IMPORT_INTERVAL_PROPERTY
See Also:
Constant Field Values

IMPORT_THREAD_POOL_SIZE_PROPERTY

public static final java.lang.String IMPORT_THREAD_POOL_SIZE_PROPERTY
See Also:
Constant Field Values
Constructor Detail

DefaultGatewayManager

public DefaultGatewayManager(ForumFactory factory)
Creates a new GatewayManager. It will load existing values from the persistent store.

Method Detail

create

public void create(Gateway gateway)
Allows you to add a new gateway to the system

Specified by:
create in interface GatewayManager
Parameters:
gateway - The gatway to add

update

public void update(Gateway gateway)
This method must be called if gateway settings changes are to be persisted.

Specified by:
update in interface GatewayManager
Parameters:
gateway - gateway who settings to persist

remove

public void remove(Forum forum)
Deletes all gateways for this context by removing their properties and stopping them from running.

Specified by:
remove in interface GatewayManager

remove

public void remove(Gateway gateway)
            throws UnauthorizedException
Description copied from interface: GatewayManager
Delete a specific gateway

Specified by:
remove in interface GatewayManager
Throws:
UnauthorizedException

getGateways

public java.util.Collection getGateways(Forum forum)
Returns all the gateways for a forum. You cannot add/ gateways using this mechanism, you must use the create/remove/update methods.

Specified by:
getGateways in interface GatewayManager
Parameters:
forum - forum to grab gateways for
Returns:
all the gateways for the forum or an empty collecion if there are none.

getGateways

public java.util.Collection getGateways()
Returns all the gateways, this collection is unmodifiable. You cannot add/ gateways using this mechanism, you must use the create/remove/update methods.

This will return all gateways ordered by name.

Specified by:
getGateways in interface GatewayManager
Returns:
all the gateways or an empty collection if there are none.

jivePropertyAdded

public void jivePropertyAdded(JivePropertyEvent jivePropertyEvent)
If the import interval jive property is changed the import task timer is restarted with the new value

Specified by:
jivePropertyAdded in interface JivePropertyListener
Parameters:
jivePropertyEvent - event

jivePropertyRemoved

public void jivePropertyRemoved(JivePropertyEvent jivePropertyEvent)
If the import interval jive property is changed the import task timer is restarted with the new value

Specified by:
jivePropertyRemoved in interface JivePropertyListener
Parameters:
jivePropertyEvent - event

jivePropertyModified

public void jivePropertyModified(JivePropertyEvent jivePropertyEvent)
Restart the import interval if the jive proeprty is changed

Specified by:
jivePropertyModified in interface JivePropertyListener
Parameters:
jivePropertyEvent - event

exportData

public void exportData(ForumMessage message)
Exports an individual message through all gateways.

Parameters:
message - the message to export.

registerCustomGatewayType

public void registerCustomGatewayType(java.lang.String type,
                                      java.lang.Class clazz)
Used to register a custom gateway manager implementation.

Parameters:
type - type of manager
clazz - class to use

createGatewayInstance

public Gateway createGatewayInstance(Forum forum,
                                     java.lang.String type)
                              throws UnauthorizedException
Used to create and return an instance of a gateway based off the gateway settings, this gateway won't be installed as a new persistent gateway. If you wish to do that you must call the create(Gateway) method

Specified by:
createGatewayInstance in interface GatewayManager
Parameters:
forum - forum to create the gateway for
type - type of gateway to create
Returns:
an instance of the gateway
Throws:
UnauthorizedException

getGateway

public Gateway getGateway(long gatewayID)
Description copied from interface: GatewayManager
Returns a gateway by its id. If no gateway exists for this id null will be returned.

Specified by:
getGateway in interface GatewayManager
Parameters:
gatewayID - unique id of the gateway
Returns:
the gateway object that matches the id, if none then null.

initialize

public void initialize()
Description copied from interface: JiveManager
Initialize the manager. It is within this method that it is ok to create, access and/or otherwise use external classes (including caches). Until this method is called implementation should not access any external classes that could possibly either access one of the main Factory classes or any caches since doing so can cause deadlocks and possible clustering issues during startup.

This method is used internally by Jive during application startup and should not be called during normal usage of the class.

Specified by:
initialize in interface JiveManager

clusterReInitialize

protected void clusterReInitialize()
This method is called by a cluster task to reset private variables with values from the database


destroy

public void destroy()
Attempts to shutdown all threads associated with this class

Specified by:
destroy in interface JiveManager

startImportTask

protected void startImportTask()
Start/restart the gateway import task


executeOnce

public void executeOnce(Gateway gateway,
                        java.util.Date afterDate)
Used to execute a import/export on a gateway immediately, the gateway does not need to be a persistent gateway.

Usually the gateway passed in will have either have import enabled or export enabled, but probably not both.

Specified by:
executeOnce in interface GatewayManager
Parameters:
gateway - gateway to execute
afterDate - acquire messages after this date

update

public void update(GlobalGatewaySettings globalGatewaySettings)
Description copied from interface: GatewayManager
Updates the global gateway setting.

Specified by:
update in interface GatewayManager
Parameters:
globalGatewaySettings - globals settings to update

getGlobalGatewaySettings

public GlobalGatewaySettings getGlobalGatewaySettings()
Description copied from interface: GatewayManager
Returns the global settings for gateways.

Specified by:
getGlobalGatewaySettings in interface GatewayManager
Returns:
global settings for gateways.

forumAdded

public void forumAdded(ForumEvent event)
Description copied from interface: ForumListener
Fired when a forum has been added to the system.

Specified by:
forumAdded in interface ForumListener
Parameters:
event - the event object.

forumDeleted

public void forumDeleted(ForumEvent event)
Description copied from interface: ForumListener
Fired when a forum is about to be deleted from the system. This event will be fired when an individual forum is deleted or when the forum's category is deleted. Because various code pieces may depend on this event for performing cleanup tasks, it's guaranteed that this method will be called before the forum is deleted from the database.

Specified by:
forumDeleted in interface ForumListener
Parameters:
event - the event object.

forumModified

public void forumModified(ForumEvent event)
Description copied from interface: ForumListener
Fired when a forum is modified.

Specified by:
forumModified in interface ForumListener
Parameters:
event - the event object.

forumMoved

public void forumMoved(ForumEvent event)
Description copied from interface: ForumListener
Fired when a forum has been moved from one category to another.

Specified by:
forumMoved in interface ForumListener
Parameters:
event - the event object.

forumMerged

public void forumMerged(ForumEvent event)
Description copied from interface: ForumListener
Fired when a forum is merged into another forum.

Specified by:
forumMerged in interface ForumListener
Parameters:
event - the event object.

Jive Forums Project Page

Copyright © 1999-2006 Jive Software.