KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > portal > aspect > impl > RequestAspectDataStore


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.aspect.impl;
17
18 import org.apache.avalon.framework.CascadingRuntimeException;
19 import org.apache.avalon.framework.parameters.ParameterException;
20 import org.apache.avalon.framework.parameters.Parameterizable;
21 import org.apache.avalon.framework.parameters.Parameters;
22 import org.apache.avalon.framework.service.ServiceException;
23 import org.apache.cocoon.portal.LinkService;
24 import org.apache.cocoon.portal.aspect.Aspectalizable;
25 import org.apache.cocoon.portal.coplet.CopletInstanceData;
26 import org.apache.cocoon.portal.event.impl.ChangeAspectDataEvent;
27 import org.apache.cocoon.portal.event.impl.ChangeCopletInstanceAspectDataEvent;
28
29 /**
30  * An aspect data store is a component that manages aspect data objects.
31  *
32  * @author <a HREF="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
33  *
34  * @version CVS $Id: RequestAspectDataStore.java 30932 2004-07-29 17:35:38Z vgritsenko $
35  */

36 public class RequestAspectDataStore
37     extends TemporaryAspectDataStore
38     implements Parameterizable {
39     
40     protected String JavaDoc requestParameterName;
41     
42     public void setAspectData(Aspectalizable owner, String JavaDoc aspectName, Object JavaDoc data) {
43         super.setAspectData(owner, aspectName, data);
44
45         // create persistence
46
ChangeAspectDataEvent e;
47         if ( owner instanceof CopletInstanceData) {
48             e = new ChangeCopletInstanceAspectDataEvent((CopletInstanceData)owner, aspectName, data);
49         } else {
50             e = new ChangeAspectDataEvent( owner, aspectName, data );
51         }
52         if ( this.requestParameterName != null ) {
53             e.setRequestParameterName( this.requestParameterName );
54         }
55         LinkService service = null;
56         try {
57             service = (LinkService)this.manager.lookup(LinkService.ROLE);
58             service.addEventToLink( e );
59         } catch (ServiceException ce) {
60             throw new CascadingRuntimeException("Unable to lookup link service.", ce);
61         } finally {
62             this.manager.release( service );
63         }
64         
65     }
66
67     /* (non-Javadoc)
68      * @see org.apache.avalon.framework.parameters.Parameterizable#parameterize(org.apache.avalon.framework.parameters.Parameters)
69      */

70     public void parameterize(Parameters pars) throws ParameterException {
71         requestParameterName = pars.getParameter("parameter-name", null);
72     }
73
74 }
75
Popular Tags