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/acting CopletSetDataAction.java
Date Mon, 21 Jun 2004 11:09:45 GMT
cziegeler    2004/06/21 04:09:45

  Modified:    src/blocks/portal/java/org/apache/cocoon/portal/coplet/adapter/impl
                        CachingURICopletAdapter.java
               src/blocks/portal/java/org/apache/cocoon/portal
                        PortalComponentManager.java
               src/blocks/portal/java/org/apache/cocoon/portal/impl
                        DefaultPortalComponentManager.java
               src/blocks/portal/java/org/apache/cocoon/portal/acting
                        CopletSetDataAction.java
  Log:
  Changes to coplets should be propagated through events
  
  Revision  Changes    Path
  1.6       +4 -4      cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/coplet/adapter/impl/CachingURICopletAdapter.java
  
  Index: CachingURICopletAdapter.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/coplet/adapter/impl/CachingURICopletAdapter.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- CachingURICopletAdapter.java	25 Apr 2004 20:09:34 -0000	1.5
  +++ CachingURICopletAdapter.java	21 Jun 2004 11:09:45 -0000	1.6
  @@ -119,11 +119,11 @@
   
                   bi.deserialize(bc.getSAXFragment());
               } else {
  -            this.toCache(coplet, bc.getSAXFragment());
  +                this.toCache(coplet, bc.getSAXFragment());
   
  -            this.toSAXFromCache(coplet, contentHandler);
  +                this.toSAXFromCache(coplet, contentHandler);
  +            }
           }
  -    }
       }
   
       /**
  
  
  
  1.3       +7 -1      cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/PortalComponentManager.java
  
  Index: PortalComponentManager.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/PortalComponentManager.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- PortalComponentManager.java	5 Mar 2004 13:02:08 -0000	1.2
  +++ PortalComponentManager.java	21 Jun 2004 11:09:45 -0000	1.3
  @@ -16,6 +16,7 @@
   package org.apache.cocoon.portal;
   
   import org.apache.cocoon.portal.coplet.CopletFactory;
  +import org.apache.cocoon.portal.event.EventManager;
   import org.apache.cocoon.portal.layout.LayoutFactory;
   import org.apache.cocoon.portal.layout.renderer.Renderer;
   import org.apache.cocoon.portal.profile.ProfileManager;
  @@ -60,4 +61,9 @@
        * Get the layout factory
        */
       LayoutFactory getLayoutFactory();
  +    
  +    /**
  +     * Get the event manager
  +     */
  +    EventManager getEventManager();
   }
  
  
  
  1.5       +26 -1     cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/impl/DefaultPortalComponentManager.java
  
  Index: DefaultPortalComponentManager.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/impl/DefaultPortalComponentManager.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DefaultPortalComponentManager.java	5 Mar 2004 13:02:13 -0000	1.4
  +++ DefaultPortalComponentManager.java	21 Jun 2004 11:09:45 -0000	1.5
  @@ -33,6 +33,7 @@
   import org.apache.cocoon.portal.LinkService;
   import org.apache.cocoon.portal.PortalComponentManager;
   import org.apache.cocoon.portal.coplet.CopletFactory;
  +import org.apache.cocoon.portal.event.EventManager;
   import org.apache.cocoon.portal.layout.LayoutFactory;
   import org.apache.cocoon.portal.layout.renderer.Renderer;
   import org.apache.cocoon.portal.profile.ProfileManager;
  @@ -48,6 +49,12 @@
    * 
    * @version CVS $Id$
    */
  +/**
  + * @author CZiegeler
  + *
  + * To change the template for this generated type comment go to
  + * Window - Preferences - Java - Code Generation - Code and Comments
  + */
   public class DefaultPortalComponentManager
       extends AbstractLogEnabled
       implements PortalComponentManager, Serviceable, Disposable, ThreadSafe, Configurable
{
  @@ -76,6 +83,8 @@
       
       protected LayoutFactory layoutFactory;
       
  +    protected EventManager eventManager;
  +    
       /* (non-Javadoc)
        * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
        */
  @@ -112,6 +121,20 @@
       }
   
       /* (non-Javadoc)
  +     * @see org.apache.cocoon.portal.PortalComponentManager#getEventManager()
  +     */
  +    public EventManager getEventManager() {
  +        if ( null == this.eventManager ) {
  +            try {
  +                this.eventManager = (EventManager)this.manager.lookup( EventManager.ROLE
);
  +            } catch (ServiceException e) {
  +                throw new CascadingRuntimeException("Unable to lookup event manager with
role " + EventManager.ROLE, e);
  +            }
  +        }
  +        return this.eventManager;
  +    }
  +    
  +    /* (non-Javadoc)
        * @see org.apache.avalon.framework.activity.Disposable#dispose()
        */
       public void dispose() {
  @@ -134,6 +157,8 @@
               this.copletFactory = null;
               this.layoutFactory = null;
               this.manager = null;
  +            this.manager.release(this.eventManager);
  +            this.eventManager = null;
           }
       }
   
  
  
  
  1.4       +12 -6     cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/acting/CopletSetDataAction.java
  
  Index: CopletSetDataAction.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/acting/CopletSetDataAction.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- CopletSetDataAction.java	15 Mar 2004 18:18:19 -0000	1.3
  +++ CopletSetDataAction.java	21 Jun 2004 11:09:45 -0000	1.4
  @@ -20,13 +20,16 @@
   import org.apache.avalon.framework.configuration.ConfigurationException;
   import org.apache.avalon.framework.parameters.Parameters;
   import org.apache.avalon.framework.service.ServiceException;
  +import org.apache.cocoon.ProcessingException;
   import org.apache.cocoon.acting.ServiceableAction;
   import org.apache.cocoon.environment.ObjectModelHelper;
   import org.apache.cocoon.environment.Redirector;
   import org.apache.cocoon.environment.SourceResolver;
   import org.apache.cocoon.portal.Constants;
   import org.apache.cocoon.portal.PortalService;
  -import org.apache.commons.jxpath.JXPathContext;
  +import org.apache.cocoon.portal.event.Event;
  +import org.apache.cocoon.portal.event.Publisher;
  +import org.apache.cocoon.portal.event.impl.CopletJXPathEvent;
   
   /**
    * Using this action, you can set values in a coplet
  @@ -46,7 +49,7 @@
           try {
   
               portalService = (PortalService)this.manager.lookup(PortalService.ROLE);
  -
  +            
               // determine coplet id
               String copletId = null;            
               Map context = (Map)objectModel.get(ObjectModelHelper.PARENT_CONTEXT);
  @@ -63,18 +66,21 @@
                   throw new ConfigurationException("copletId must be passed in the object
model either directly (e.g. by using ObjectModelAction) or within the parent context.");
               }
           
  -            JXPathContext jxpathContext = JXPathContext.newContext(portalService.getComponentManager().getProfileManager().getCopletInstanceData(copletId));
               // now traverse parameters:
               // parameter name is path
               // parameter value is value
               // if the value is null or empty, the value is not set!
               final String[] names = parameters.getNames();
               if ( names != null ) {
  +                final Publisher publisher = portalService.getComponentManager().getEventManager().getPublisher();
                   for(int i=0; i<names.length; i++) {
                       final String path = names[i];
                       final String value = parameters.getParameter(path, null );
                       if ( value != null && value.trim().length() > 0 ) {
  -                        jxpathContext.setValue(path, value);
  +                        final Event event = new CopletJXPathEvent(portalService.getComponentManager().getProfileManager().getCopletInstanceData(copletId),
  +                                path,
  +                                value);
  +                        publisher.publish(event);
                       }
                   }
               }
  @@ -82,7 +88,7 @@
               return EMPTY_MAP;
           
           } catch (ServiceException e) {
  -            throw new ConfigurationException("ComponentException ", e);
  +            throw new ProcessingException("Unable to lookup component.", e);
           } finally {
               this.manager.release(portalService);
           }
  
  
  

Mime
View raw message