01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.cocoon.portal.event.subscriber.impl;
18:
19: import java.util.Iterator;
20: import java.util.List;
21:
22: import org.apache.cocoon.portal.PortalService;
23: import org.apache.cocoon.portal.coplet.CopletData;
24: import org.apache.cocoon.portal.coplet.CopletInstanceData;
25: import org.apache.cocoon.portal.event.CopletDataEvent;
26: import org.apache.cocoon.portal.event.Event;
27: import org.apache.cocoon.portal.event.EventManager;
28: import org.apache.cocoon.portal.event.Receiver;
29: import org.apache.cocoon.portal.event.impl.ChangeCopletsJXPathEvent;
30: import org.apache.cocoon.portal.event.impl.CopletJXPathEvent;
31: import org.apache.cocoon.portal.profile.ProfileManager;
32:
33: /**
34: *
35: * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
36: *
37: * @version CVS $Id: DefaulCopletDataEventSubscriber.java 433543 2006-08-22 06:22:54Z crossley $
38: */
39: public final class DefaulCopletDataEventSubscriber 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 instances = null;
54:
55: ProfileManager profileManager = service.getComponentManager()
56: .getProfileManager();
57: instances = profileManager.getCopletInstanceData(data);
58:
59: if (instances != null && e instanceof ChangeCopletsJXPathEvent) {
60: EventManager eventManager = service.getComponentManager()
61: .getEventManager();
62: final String path = ((ChangeCopletsJXPathEvent) e)
63: .getPath();
64: final Object value = ((ChangeCopletsJXPathEvent) e)
65: .getValue();
66:
67: Iterator i = instances.iterator();
68: while (i.hasNext()) {
69: CopletInstanceData current = (CopletInstanceData) i
70: .next();
71: Event event = new CopletJXPathEvent(current, path,
72: value);
73: eventManager.send(event);
74: }
75: }
76: }
77:
78: }
|