KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > portal > wsrp > adapter > WSRPEventAspect


1 /*
2  * Copyright 2005 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.wsrp.adapter;
17
18 import java.util.Enumeration JavaDoc;
19 import java.util.HashMap JavaDoc;
20 import java.util.Map JavaDoc;
21
22 import org.apache.cocoon.environment.ObjectModelHelper;
23 import org.apache.cocoon.environment.Request;
24 import org.apache.cocoon.portal.PortalService;
25 import org.apache.cocoon.portal.coplet.CopletInstanceData;
26 import org.apache.cocoon.portal.event.Event;
27 import org.apache.cocoon.portal.event.aspect.EventAspect;
28 import org.apache.cocoon.portal.event.aspect.EventAspectContext;
29
30 /**
31  * This event processes all wsrp related urls and fires {@link org.apache.cocoon.portal.wsrp.adapter.WSRPEvent}s.
32  *
33  * @author <a HREF="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
34  * @author <a HREF="mailto:malessandrini@s-und-n.de">Michel Alessandrini</a>
35  *
36  * @version $Id: WSRPEventAspect.java 264755 2005-08-30 10:29:21Z cziegeler $
37  */

38 public class WSRPEventAspect implements EventAspect {
39
40     public static final String JavaDoc REQUEST_PARAMETER_NAME = "cocoon-wsrpevent";
41
42     /**
43      * @see org.apache.cocoon.portal.event.aspect.EventAspect#process(org.apache.cocoon.portal.event.aspect.EventAspectContext, org.apache.cocoon.portal.PortalService)
44      */

45     public void process(EventAspectContext context, PortalService service) {
46         final Request request = ObjectModelHelper.getRequest(context.getObjectModel());
47         final String JavaDoc[] values = request.getParameterValues("cocoon-wsrpevent");
48         if ( values != null && values.length == 1 ) {
49             // create a wsrp event, first build map of parameters
50
final Map JavaDoc parameters = new HashMap JavaDoc();
51             final Enumeration JavaDoc parameterNames = request.getParameterNames();
52             while ( parameterNames.hasMoreElements() ) {
53                 final String JavaDoc name = (String JavaDoc)parameterNames.nextElement();
54                 if ( !REQUEST_PARAMETER_NAME.equals(name) ) {
55                     final String JavaDoc value = request.getParameter(name);
56                     parameters.put(name, value);
57                 }
58             }
59             final String JavaDoc copletid = values[0];
60             final CopletInstanceData cid = service.getComponentManager().getProfileManager().getCopletInstanceData(copletid);
61
62             final Event e = new WSRPEvent(cid, parameters);
63             service.getComponentManager().getEventManager().send(e);
64         }
65         context.invokeNext(service);
66     }
67 }
68
Popular Tags