Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

er.changenotification
Class ERCNNotificationCoordinator  view ERCNNotificationCoordinator download ERCNNotificationCoordinator.java

java.lang.Object
  extended byer.changenotification.ERCNNotificationCoordinator
All Implemented Interfaces:
javax.jms.ExceptionListener

public class ERCNNotificationCoordinator
extends java.lang.Object
implements javax.jms.ExceptionListener

ERCNNotificationCoordinator is the primary controller of the change notification for enterprise objects. It manages the single connection to the JMS server, and creates ERCNPublisher and ERCNSubscriber objects and registers them as the observers to handle change notifications.

When the application finishes launching, it checks properties and initializes the framework. It can also perform necessary clean-up operations when the application is about to terminate.

The framework works transparently and you will not have to call any methods on the framework. Just add this framework to application project as an external framework and put necessary properties to your property file.

The current implementation supports concurrent request handling (multi threaded operations.) It only supports the changes in the default EOObjectStoreCoordinator.

Properties:
Put the following properties into WebObjects.properties file under your home directory, or into Properties file and register it under the applications project's Resouces group.

 
 # entities *not* to synchronize
 #er.changenotification.entitiesNotToSynchronize = (TalentPhoto)
 er.changenotification.entitiesNotToSynchronize = ()
 
 # change types to track; Can contain inserted, updated and deleted. 
 er.changenotification.changeTypesToTrack = (inserted, updated, deleted)
 
 # JMS topic name (Destination object) to pass the notifications. 
 # Specify one and register it from the OpenJMS administration tool or 
 # configuration file. 
 er.changenotification.jms.topicName = business logic group 1
 
 # whether or not the JMS subscriber is durable; 
 # prevents to miss change notifications by temporaly 
 # network disruptions. 
 # 
 # false - suggested for development 
 # true  - suggested for deployment
 # 
 # If it's set to true, you need properly to shut down the applications 
 # (e.g. shut down it from JavaMonitor or calling application's 
 # terminate() method), otherwise JMS provider will try to keep  
 # all changes even after application is shut down. 
 er.changenotification.jms.durableSubscribers = false
 
 


Field Summary
private  NSArray _changeTypesToTrack
           
private  javax.jms.TopicConnection _connection
           
private  javax.naming.Context _context
           
private static ERCNNotificationCoordinator _coordinator
           
private  NSArray _entitiesNotToSynchronize
           
private  boolean _isInitialized
           
private  boolean _isSubscriberDurable
           
private  boolean _isTerminated
           
private  ERCNPublisher _publisher
           
private  ERCNSubscriber _subscriber
           
private  javax.jms.Topic _topic
           
private  java.lang.String _topicName
           
static er.extensions.ERXLogger log
          logging support
 
Constructor Summary
private ERCNNotificationCoordinator()
           
 
Method Summary
 NSArray changeTypesToTrack()
           
protected  javax.jms.TopicConnection connection()
           
static ERCNNotificationCoordinator coordinator()
           
static EODatabaseContext databaseContextForEntityNamed(java.lang.String entityName, EOEditingContext editingContext)
           
 NSArray entitiesNotToSynchronize()
           
 void finalize()
          Called on an object by the Virtual Machine at most once, at some point after the Object is determined unreachable but before it is destroyed.
protected  java.lang.String id()
           
 void initialize(NSNotification notification)
           
 void onException(javax.jms.JMSException exception)
           
 void setChageTypesToTrack(NSArray newChageTypesToTrack)
           
 void setEntitiesNotToSynchronize(NSArray newEntitiesNotToSynchronize)
           
 void terminate()
          releases JMS resouces, including closing the connection.
protected  javax.jms.Topic topic()
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

public static final er.extensions.ERXLogger log
logging support


_coordinator

private static final ERCNNotificationCoordinator _coordinator

_publisher

private ERCNPublisher _publisher

_subscriber

private ERCNSubscriber _subscriber

_entitiesNotToSynchronize

private NSArray _entitiesNotToSynchronize

_changeTypesToTrack

private NSArray _changeTypesToTrack

_context

private javax.naming.Context _context

_connection

private javax.jms.TopicConnection _connection

_topic

private javax.jms.Topic _topic

_topicName

private java.lang.String _topicName

_isSubscriberDurable

private boolean _isSubscriberDurable

_isInitialized

private boolean _isInitialized

_isTerminated

private boolean _isTerminated
Constructor Detail

ERCNNotificationCoordinator

private ERCNNotificationCoordinator()
Method Detail

coordinator

public static ERCNNotificationCoordinator coordinator()

entitiesNotToSynchronize

public NSArray entitiesNotToSynchronize()

setEntitiesNotToSynchronize

public void setEntitiesNotToSynchronize(NSArray newEntitiesNotToSynchronize)

changeTypesToTrack

public NSArray changeTypesToTrack()

setChageTypesToTrack

public void setChageTypesToTrack(NSArray newChageTypesToTrack)

topic

protected javax.jms.Topic topic()

connection

protected javax.jms.TopicConnection connection()

id

protected java.lang.String id()

initialize

public void initialize(NSNotification notification)

terminate

public void terminate()
releases JMS resouces, including closing the connection.

This method is supposed to be called by the applicaiton's terminate method.


finalize

public void finalize()
              throws java.lang.Throwable
Description copied from class: java.lang.Object
Called on an object by the Virtual Machine at most once, at some point after the Object is determined unreachable but before it is destroyed. You would think that this means it eventually is called on every Object, but this is not necessarily the case. If execution terminates abnormally, garbage collection does not always happen. Thus you cannot rely on this method to always work. For finer control over garbage collection, use references from the java.lang.ref package.

Virtual Machines are free to not call this method if they can determine that it does nothing important; for example, if your class extends Object and overrides finalize to do simply super.finalize().

finalize() will be called by a java.lang.Thread that has no locks on any Objects, and may be called concurrently. There are no guarantees on the order in which multiple objects are finalized. This means that finalize() is usually unsuited for performing actions that must be thread-safe, and that your implementation must be use defensive programming if it is to always work.

If an Exception is thrown from finalize() during garbage collection, it will be patently ignored and the Object will still be destroyed.

It is allowed, although not typical, for user code to call finalize() directly. User invocation does not affect whether automatic invocation will occur. It is also permitted, although not recommended, for a finalize() method to "revive" an object by making it reachable from normal code again.

Unlike constructors, finalize() does not get called for an object's superclass unless the implementation specifically calls super.finalize().

The default implementation does nothing.


onException

public void onException(javax.jms.JMSException exception)
Specified by:
onException in interface javax.jms.ExceptionListener

databaseContextForEntityNamed

public static EODatabaseContext databaseContextForEntityNamed(java.lang.String entityName,
                                                              EOEditingContext editingContext)