cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject cvs commit: cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/event/subscriber/impl DefaultJXPathEventSubscriber.java
Date Thu, 11 Dec 2003 11:10:47 GMT
cziegeler    2003/12/11 03:10:47

  Modified:    src/blocks/portal/java/org/apache/cocoon/portal/aspect/impl
                        DefaultAspectDataHandler.java
               src/blocks/portal/java/org/apache/cocoon/portal/event/subscriber/impl
                        DefaultJXPathEventSubscriber.java
  Log:
  Ensure that changes of aspect datas don't get lost
  
  Revision  Changes    Path
  1.5       +23 -2     cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/aspect/impl/DefaultAspectDataHandler.java
  
  Index: DefaultAspectDataHandler.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/aspect/impl/DefaultAspectDataHandler.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DefaultAspectDataHandler.java	11 Dec 2003 09:56:58 -0000	1.4
  +++ DefaultAspectDataHandler.java	11 Dec 2003 11:10:47 -0000	1.5
  @@ -118,7 +118,7 @@
        * @see org.apache.cocoon.portal.aspect.AspectDataHandler#getAspectDatas(org.apache.cocoon.portal.aspect.Aspectalizable)
        */
       public Map getAspectDatas(Aspectalizable owner)  {
  -        Map datas = new HashMap();
  +        Map datas = new AspectDatasHashMap(owner, this);
           Iterator iter = this.description.getAspectDescriptions().iterator();
           while ( iter.hasNext() ) {
               AspectDescription current = (AspectDescription)iter.next();
  @@ -195,4 +195,25 @@
       public boolean isAspectSupported(String aspectName) {
           return (this.description.getAspectDescription(aspectName) != null);
       }
  +}
  +
  +final class AspectDatasHashMap extends HashMap {
  +    
  +    protected AspectDataHandler handler;
  +    protected Aspectalizable owner;
  +    
  +    public AspectDatasHashMap(Aspectalizable owner, AspectDataHandler handler) {
  +        this.handler = handler;
  +        this.owner = owner;
  +    }
  +    
  +    /* (non-Javadoc)
  +     * @see java.util.Map#put(java.lang.Object, java.lang.Object)
  +     */
  +    public Object put(Object key, Object value) {
  +        this.handler.setAspectData(this.owner, key.toString(), value);
  +        value = this.handler.getAspectData(this.owner, key.toString());
  +        return super.put(key, value);
  +    }
  +
   }
  
  
  
  1.2       +6 -3      cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/event/subscriber/impl/DefaultJXPathEventSubscriber.java
  
  Index: DefaultJXPathEventSubscriber.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/event/subscriber/impl/DefaultJXPathEventSubscriber.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultJXPathEventSubscriber.java	11 Dec 2003 09:30:17 -0000	1.1
  +++ DefaultJXPathEventSubscriber.java	11 Dec 2003 11:10:47 -0000	1.2
  @@ -87,8 +87,11 @@
        */
       public void inform(Event e) {
           final JXPathEvent event = (JXPathEvent)e;
  -        JXPathContext jxpathContext = JXPathContext.newContext(event.getTarget());
  -        jxpathContext.setValue(event.getPath(), event.getValue());
  +        final Object target = event.getTarget();
  +        if ( target != null ) {
  +            final JXPathContext jxpathContext = JXPathContext.newContext(target);
  +            jxpathContext.setValue(event.getPath(), event.getValue());
  +        }
       }
   
   }
  
  
  

Mime
View raw message