[jboss-cvs] jboss-seam/src/ioc/org/jboss/seam/ioc/spring ...

Michael Youngstrom youngm at gmail.com
Thu Jun 14 19:08:04 EDT 2007


  User: myoungstrom
  Date: 07/06/14 19:08:04

  Modified:    src/ioc/org/jboss/seam/ioc/spring    SpringComponent.java
                        spring-1.3.xsd
  Added:       src/ioc/org/jboss/seam/ioc/spring   
                        SpringTaskExecutorDispatcher.java
  Log:
  Fixes for: JBSEAM-1459, JBSEAM-1458, JBSEAM-1377
  
  Revision  Changes    Path
  1.9       +15 -0     jboss-seam/src/ioc/org/jboss/seam/ioc/spring/SpringComponent.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: SpringComponent.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/ioc/org/jboss/seam/ioc/spring/SpringComponent.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -b -r1.8 -r1.9
  --- SpringComponent.java	14 Jun 2007 05:40:02 -0000	1.8
  +++ SpringComponent.java	14 Jun 2007 23:08:04 -0000	1.9
  @@ -1,11 +1,14 @@
   package org.jboss.seam.ioc.spring;
   
  +import java.util.Collections;
   import java.util.HashMap;
  +import java.util.List;
   import java.util.Map;
   
   import org.jboss.seam.Component;
   import org.jboss.seam.InterceptionType;
   import org.jboss.seam.ScopeType;
  +import org.jboss.seam.Component.BijectedAttribute;
   import org.jboss.seam.contexts.Contexts;
   import org.jboss.seam.contexts.Lifecycle;
   import org.jboss.seam.init.Initialization;
  @@ -254,4 +257,16 @@
       
       @Override
       protected void checkPersistenceContextForComponentType() {}
  +    
  +    /**
  +     * Ignore PersistenceContextAttributes if scope is stateless
  +     */
  +    @Override    
  +    public List<BijectedAttribute> getPersistenceContextAttributes()
  +    {
  +       if(getScope().equals(ScopeType.STATELESS)) {
  +          return Collections.emptyList();          
  +       }
  +       return super.getPersistenceContextAttributes();
  +    }
   }
  
  
  
  1.2       +11 -0     jboss-seam/src/ioc/org/jboss/seam/ioc/spring/spring-1.3.xsd
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: spring-1.3.xsd
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/ioc/org/jboss/seam/ioc/spring/spring-1.3.xsd,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -b -r1.1 -r1.2
  --- spring-1.3.xsd	22 May 2007 02:17:58 -0000	1.1
  +++ spring-1.3.xsd	14 Jun 2007 23:08:04 -0000	1.2
  @@ -30,4 +30,15 @@
   	    </xs:documentation>
   	</xs:annotation>
       </xs:element>
  +    
  +    <xs:element name="task-executor-dispatcher">
  +        <xs:complexType mixed="true">
  +            <xs:attributeGroup ref="components:attlist.component"/>
  +            <xs:attributeGroup ref="core:attlist.taskExecutorDispatcher"/>
  +        </xs:complexType>
  +    </xs:element>
  +    <xs:attributeGroup name="core:attlist.taskExecutorDispatcher">
  +        <xs:attribute name="task-executor" use="required"/>
  +        <xs:attribute name="schedule-dispatcher"/>
  +    </xs:attributeGroup>
   </xs:schema>
  
  
  
  1.1      date: 2007/06/14 23:08:04;  author: myoungstrom;  state: Exp;jboss-seam/src/ioc/org/jboss/seam/ioc/spring/SpringTaskExecutorDispatcher.java
  
  Index: SpringTaskExecutorDispatcher.java
  ===================================================================
  package org.jboss.seam.ioc.spring;
  
  import static org.jboss.seam.annotations.Install.BUILT_IN;
  
  import org.jboss.remoting.samples.chat.exceptions.InvalidArgumentException;
  import org.jboss.seam.Component;
  import org.jboss.seam.ScopeType;
  import org.jboss.seam.annotations.Create;
  import org.jboss.seam.annotations.Install;
  import org.jboss.seam.annotations.Name;
  import org.jboss.seam.annotations.Scope;
  import org.jboss.seam.core.AbstractDispatcher;
  import org.jboss.seam.core.Dispatcher;
  import org.jboss.seam.core.Schedule;
  import org.jboss.seam.core.TimerSchedule;
  import org.jboss.seam.core.Expressions.ValueExpression;
  import org.jboss.seam.intercept.InvocationContext;
  import org.springframework.core.task.TaskExecutor;
  
  /**
   * Dispatcher that can utilizes SpringTaskExecutors for non scheduled
   * asynchronous events but defer to another ScheduledDispatcher for Scheduled
   * asynchronous events.
   * 
   * @author Mike Youngstrom
   */
  @Scope(ScopeType.APPLICATION)
  @Name("org.jboss.seam.core.dispatcher")
  @Install(value=false, precedence=BUILT_IN)
  public class SpringTaskExecutorDispatcher<T, S> extends AbstractDispatcher<T, S>
  {
  
     private ValueExpression<Dispatcher<T, S>> scheduleDispatcher;
     private ValueExpression<TaskExecutor> taskExecutor;
     
     public T scheduleAsynchronousEvent(String type, Object... parameters)
     {
        taskExecutor.getValue().execute(
                 new RunnableAsynchronous(new AsynchronousEvent(type, parameters)));
        return null;
     }
  
     public T scheduleInvocation(InvocationContext invocation, Component component)
     {
        Schedule schedule = createSchedule(invocation);
        if (!TimerSchedule.ONCE_IMMEDIATELY.equals(schedule))
        {
           return getScheduleDispatcher().scheduleInvocation(invocation, component);
        }
        taskExecutor.getValue().execute(
                 new RunnableAsynchronous(new AsynchronousInvocation(invocation, component)));
        return null;
     }
  
     public T scheduleTimedEvent(String type, S schedule, Object... parameters)
     {
        return getScheduleDispatcher().scheduleTimedEvent(type, schedule, parameters);
     }
  
     protected Dispatcher<T, S> getScheduleDispatcher()
     {
        Dispatcher<T, S> dispatcher = scheduleDispatcher.getValue();
        if (scheduleDispatcher == null || scheduleDispatcher.getValue() == null)
        {
           throw new IllegalStateException(
                    "SpringTaskExecutorDispatcher does not support scheduled Events.  Provide a fallback scheduleDispatcher for timed events.");
        }
        return dispatcher;
     }
  
     /**
      * The dispatcher to handle scheduled events
      * 
      * @param scheduleDispatcher
      */
     public void setScheduleDispatcher(ValueExpression<Dispatcher<T, S>> scheduleDispatcher)
     {
        this.scheduleDispatcher = scheduleDispatcher;
     }
  
     /**
      * The Spring TaskExecutor to handle immediate asynchronous events
      * 
      * @param taskExecutor
      */
     public void setTaskExecutor(ValueExpression<TaskExecutor> taskExecutor)
     {
        this.taskExecutor = taskExecutor;
     }
  
     /**
      * Same as the one in ThreadPoolDispatcher. Perhaps area for reuse?
      */
     static class RunnableAsynchronous implements Runnable
     {
        private AbstractDispatcher.Asynchronous async;
  
        RunnableAsynchronous(Asynchronous async)
        {
           this.async = async;
        }
  
        public void run()
        {
           async.execute(null);
        }
     }
  }
  
  
  



More information about the jboss-cvs-commits mailing list