KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > slide > event > ContentModifiedNotifier


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */

17 package org.apache.slide.event;
18
19 import org.apache.slide.common.Domain;
20 import org.apache.slide.common.Uri;
21 import org.apache.slide.util.conf.Configurable;
22 import org.apache.slide.util.conf.Configuration;
23 import org.apache.slide.util.conf.ConfigurationException;
24 import org.apache.slide.util.logger.Logger;
25
26 /**
27  * Fires an UriModifiedEvent whenever an Uri is modified.
28  *
29  */

30 public class ContentModifiedNotifier extends ContentAdapter implements
31         Configurable {
32     
33     protected static final String JavaDoc LOG_CHANNEL = ContentModifiedNotifier.class.getName();
34     
35     public ContentModifiedNotifier() {
36         Domain.log( "Creating ContentModifiedNotifier", LOG_CHANNEL, Logger.DEBUG );
37     }
38
39     public void create( ContentEvent event ) {
40         notify( event );
41     }
42     
43     public void fork( ContentEvent event ) {
44         // TODO: find out what "fork" does and if it needs watching.
45
notify( event );
46     }
47     
48     public void merge( ContentEvent event ) {
49         // TODO: find out what "merge" does and if it needs watching.
50
notify( event );
51     }
52      
53     public void remove( ContentEvent event ) {
54         notify( event );
55     }
56      
57     public void retrieve( ContentEvent event ) {
58         notify( event );
59     }
60      
61     public void store( ContentEvent event ) {
62         notify( event );
63     }
64      
65     public void configure(Configuration configuration)
66             throws ConfigurationException {
67         /*
68          * TODO: Configure the notification mechanism (http, jms, javagroups)
69          */

70     }
71     
72     public void notify( ContentEvent event ) {
73         /*
74          * TODO: Modify this to actually send the event to the other systems in a cluster.
75          * Maybe this should be subclassed to allow different messaging implementations?
76          */

77         Domain.log( "Called ContentModifiedNotifier.notify for " + event.getUri(), LOG_CHANNEL, Logger.DEBUG );
78         if ( UriModifiedEvent.URIMODIFIED.isEnabled() ) {
79             EventDispatcher.getInstance().fireEvent(
80                 UriModifiedEvent.URIMODIFIED, new UriModifiedEvent(this, new Uri( event.getNamespace(), event.getUri() )));
81         } else {
82             Domain.log( "Can't notify, UriModifiedEvent is disabled.", LOG_CHANNEL, Logger.DEBUG );
83         }
84     }
85
86 }
87
Popular Tags