KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > portal > event > subscriber > impl > DefaulCopletDataEventSubscriber


1 /*
2  * Copyright 1999-2002,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 package org.apache.cocoon.portal.event.subscriber.impl;
17
18 import java.util.Iterator JavaDoc;
19 import java.util.List JavaDoc;
20
21 import org.apache.cocoon.portal.PortalService;
22 import org.apache.cocoon.portal.coplet.CopletData;
23 import org.apache.cocoon.portal.coplet.CopletInstanceData;
24 import org.apache.cocoon.portal.event.CopletDataEvent;
25 import org.apache.cocoon.portal.event.Event;
26 import org.apache.cocoon.portal.event.EventManager;
27 import org.apache.cocoon.portal.event.Receiver;
28 import org.apache.cocoon.portal.event.impl.ChangeCopletsJXPathEvent;
29 import org.apache.cocoon.portal.event.impl.CopletJXPathEvent;
30 import org.apache.cocoon.portal.profile.ProfileManager;
31
32 /**
33  *
34  * @author <a HREF="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
35  *
36  * @version CVS $Id: DefaulCopletDataEventSubscriber.java 219049 2005-07-14 15:11:52Z cziegeler $
37  */

38 public final class DefaulCopletDataEventSubscriber
39 implements Receiver {
40
41     /**
42      * Constructor
43      */

44     public DefaulCopletDataEventSubscriber() {
45         // nothing to do
46
}
47
48     /**
49      * @see Receiver
50      */

51     public void inform(CopletDataEvent e, PortalService service) {
52         CopletData data = (CopletData)e.getTarget();
53         List JavaDoc instances = null;
54
55         ProfileManager profileManager = service.getComponentManager().getProfileManager();
56         instances = profileManager.getCopletInstanceData(data);
57
58         if ( instances != null && e instanceof ChangeCopletsJXPathEvent ) {
59             EventManager eventManager = service.getComponentManager().getEventManager();
60             final String JavaDoc path = ((ChangeCopletsJXPathEvent)e).getPath();
61             final Object JavaDoc value = ((ChangeCopletsJXPathEvent)e).getValue();
62                     
63             Iterator JavaDoc i = instances.iterator();
64             while ( i.hasNext() ) {
65                 CopletInstanceData current = (CopletInstanceData) i.next();
66                 Event event = new CopletJXPathEvent(current, path, value);
67                 eventManager.send(event);
68             }
69         }
70     }
71
72 }
73
Popular Tags