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.aspect.impl;
18:
19: import org.apache.avalon.framework.CascadingRuntimeException;
20: import org.apache.avalon.framework.parameters.ParameterException;
21: import org.apache.avalon.framework.parameters.Parameterizable;
22: import org.apache.avalon.framework.parameters.Parameters;
23: import org.apache.avalon.framework.service.ServiceException;
24: import org.apache.cocoon.portal.LinkService;
25: import org.apache.cocoon.portal.aspect.Aspectalizable;
26: import org.apache.cocoon.portal.coplet.CopletInstanceData;
27: import org.apache.cocoon.portal.event.impl.ChangeAspectDataEvent;
28: import org.apache.cocoon.portal.event.impl.ChangeCopletInstanceAspectDataEvent;
29:
30: /**
31: * An aspect data store is a component that manages aspect data objects.
32: *
33: * @author <a href="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
34: *
35: * @version CVS $Id: RequestAspectDataStore.java 433543 2006-08-22 06:22:54Z crossley $
36: */
37: public class RequestAspectDataStore extends TemporaryAspectDataStore
38: implements Parameterizable {
39:
40: protected String requestParameterName;
41:
42: public void setAspectData(Aspectalizable owner, String aspectName,
43: Object data) {
44: super .setAspectData(owner, aspectName, data);
45:
46: // create persistence
47: ChangeAspectDataEvent e;
48: if (owner instanceof CopletInstanceData) {
49: e = new ChangeCopletInstanceAspectDataEvent(
50: (CopletInstanceData) owner, aspectName, data);
51: } else {
52: e = new ChangeAspectDataEvent(owner, aspectName, data);
53: }
54: if (this .requestParameterName != null) {
55: e.setRequestParameterName(this .requestParameterName);
56: }
57: LinkService service = null;
58: try {
59: service = (LinkService) this .manager
60: .lookup(LinkService.ROLE);
61: service.addEventToLink(e);
62: } catch (ServiceException ce) {
63: throw new CascadingRuntimeException(
64: "Unable to lookup link service.", ce);
65: } finally {
66: this .manager.release(service);
67: }
68:
69: }
70:
71: /* (non-Javadoc)
72: * @see org.apache.avalon.framework.parameters.Parameterizable#parameterize(org.apache.avalon.framework.parameters.Parameters)
73: */
74: public void parameterize(Parameters pars) throws ParameterException {
75: requestParameterName = pars
76: .getParameter("parameter-name", null);
77: }
78:
79: }
|