vmassol     2004/02/22 11:57:36

  Modified:    
scratchpad/cactus2/framework/src/main/org/apache/cactus/framework/internal/orchestrator
                        Orchestrator.java
               scratchpad/cactus2/framework/conf aspectwerkz.xml
               scratchpad/cactus2/samples/servlet/conf aspectwerkz.xml
  Added:       scratchpad/cactus2/framework/src/main/org/apache/cactus/framework/aspect
                        InitializationAspect.java
  Removed:     scratchpad/cactus2/framework/src/main/org/apache/cactus/framework/aspect
                        ListenerAspect.java OrchestratorAspect.java
  Log:
  refactoring
  
  Revision  Changes    Path
  1.2       +41 -41    
jakarta-cactus/scratchpad/cactus2/framework/src/main/org/apache/cactus/framework/internal/orchestrator/Orchestrator.java
  
  Index: Orchestrator.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-cactus/scratchpad/cactus2/framework/src/main/org/apache/cactus/framework/internal/orchestrator/Orchestrator.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Orchestrator.java 21 Feb 2004 16:39:30 -0000      1.1
  +++ Orchestrator.java 22 Feb 2004 19:57:36 -0000      1.2
  @@ -29,48 +29,48 @@
   
   public class Orchestrator
   {
  -    private int port = 7777;
  -    
  -    /**
  -     * Has the test listener socket been set up? 
  -     */
  -    private boolean isInitialized = false;
  +    private int port;
  +
  +    public Orchestrator(int port)
  +    {
  +        this.port = port;
  +    }
   
  -    public synchronized void initialize() throws Throwable
  +    public int getPort()
       {
  -        if (!this.isInitialized)
  -        {
  -            // Setup HTTP server and attach to it handlers to manage
  -            // the executing test and to manage retrieval of test results
  -
  -            HttpServer server = new HttpServer();
  -            SocketListener listener = new SocketListener();
  -            listener.setPort(this.port);
  -            server.addListener(listener);
  -
  -            HttpContext getTestContext = new HttpContext();
  -            getTestContext.setContextPath("/gettest");
  -            getTestContext.addHandler(new GetTestHandler());
  -            server.addContext(getTestContext);
  -
  -            HttpContext setTestContext = new HttpContext();
  -            setTestContext.setContextPath("/settest");
  -            setTestContext.addHandler(new SetTestHandler());
  -            server.addContext(setTestContext);
  -
  -            HttpContext getResultContext = new HttpContext();
  -            getResultContext.setContextPath("/getresult");
  -            getResultContext.addHandler(new GetResultHandler());
  -            server.addContext(getResultContext);
  -
  -            HttpContext setResultContext = new HttpContext();
  -            setResultContext.setContextPath("/setresult");
  -            setResultContext.addHandler(new SetResultHandler());
  -            server.addContext(setResultContext);
  -
  -            server.start();
  -            
  -            this.isInitialized = true;
  -        }
  +        return this.port;
  +    }
  +    
  +    public void start() throws Throwable
  +    {
  +        // Setup HTTP server and attach to it handlers to manage
  +        // the executing test and to manage retrieval of test results
  +
  +        HttpServer server = new HttpServer();
  +        SocketListener listener = new SocketListener();
  +        listener.setPort(getPort());
  +        server.addListener(listener);
  +
  +        HttpContext getTestContext = new HttpContext();
  +        getTestContext.setContextPath("/gettest");
  +        getTestContext.addHandler(new GetTestHandler());
  +        server.addContext(getTestContext);
  +
  +        HttpContext setTestContext = new HttpContext();
  +        setTestContext.setContextPath("/settest");
  +        setTestContext.addHandler(new SetTestHandler());
  +        server.addContext(setTestContext);
  +
  +        HttpContext getResultContext = new HttpContext();
  +        getResultContext.setContextPath("/getresult");
  +        getResultContext.addHandler(new GetResultHandler());
  +        server.addContext(getResultContext);
  +
  +        HttpContext setResultContext = new HttpContext();
  +        setResultContext.setContextPath("/setresult");
  +        setResultContext.addHandler(new SetResultHandler());
  +        server.addContext(setResultContext);
  +
  +        server.start();
       }
   }
  
  
  
  1.1                  
jakarta-cactus/scratchpad/cactus2/framework/src/main/org/apache/cactus/framework/aspect/InitializationAspect.java
  
  Index: InitializationAspect.java
  ===================================================================
  /* 
   * ========================================================================
   * 
   * Copyright 2004 The Apache Software Foundation.
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   * 
   *   http://www.apache.org/licenses/LICENSE-2.0
   * 
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   * 
   * ========================================================================
   */
  package org.apache.cactus.framework.aspect;
  
  import org.apache.cactus.framework.internal.orchestrator.Orchestrator;
  import org.codehaus.aspectwerkz.attribdef.Pointcut;
  import org.codehaus.aspectwerkz.attribdef.aspect.Aspect;
  import org.codehaus.aspectwerkz.joinpoint.JoinPoint;
  
  /**
   * Intercepts client side JUnit tests and initialize the Cactus system: 
   * <ul>
   *   <li>sets up PicoContainer,</li>
   *   <li>sets up the test listener socket if not set</li>
   * </ul>
   */
  public class InitializationAspect extends Aspect
  {
      /**
       * @Execution * *..TestCase+.test*()
       */
      private Pointcut interceptClientTest;
  
      /**
       * Has the Cactus system been already initialized? 
       */
      private boolean isInitialized = false;
      
      /**
       * @Around interceptClientTest
       */
      public synchronized Object initialize(JoinPoint joinPoint) 
          throws Throwable
      {
          if (!this.isInitialized)
          {
              // TODO: Create a Configuration component to externalize 
              // configuration data
              Orchestrator orchestrator = new Orchestrator(7777);
              orchestrator.start();
              
              this.isInitialized = true;
          }
          return joinPoint.proceed();
      }
  }
  
  
  
  1.4       +1 -1      jakarta-cactus/scratchpad/cactus2/framework/conf/aspectwerkz.xml
  
  Index: aspectwerkz.xml
  ===================================================================
  RCS file: 
/home/cvs/jakarta-cactus/scratchpad/cactus2/framework/conf/aspectwerkz.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- aspectwerkz.xml   21 Feb 2004 16:39:30 -0000      1.3
  +++ aspectwerkz.xml   22 Feb 2004 19:57:36 -0000      1.4
  @@ -1,3 +1,3 @@
   <?xml version="1.0" encoding="UTF-8"?>

   <!DOCTYPE aspectwerkz PUBLIC "-//AspectWerkz//DTD//EN" 
"http://aspectwerkz.codehaus.org/dtd/aspectwerkz.dtd";>

  -<aspectwerkz>
  <system id="cactus">
    <package name="org.apache.cactus.framework.aspect">
      <use-aspect class="OrchestratorAspect"/>
    </package>
  </system>
</aspectwerkz>

  +<aspectwerkz>
  <system id="cactus">
    <package name="org.apache.cactus.framework.aspect">
      <use-aspect class="InitializationAspect"/>
    </package>
  </system>
</aspectwerkz>

  
  
  
  1.4       +1 -1      
jakarta-cactus/scratchpad/cactus2/samples/servlet/conf/aspectwerkz.xml
  
  Index: aspectwerkz.xml
  ===================================================================
  RCS file: 
/home/cvs/jakarta-cactus/scratchpad/cactus2/samples/servlet/conf/aspectwerkz.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- aspectwerkz.xml   21 Feb 2004 16:39:30 -0000      1.3
  +++ aspectwerkz.xml   22 Feb 2004 19:57:36 -0000      1.4
  @@ -1,3 +1,3 @@
   <?xml version="1.0" encoding="UTF-8"?>

   <!DOCTYPE aspectwerkz PUBLIC "-//AspectWerkz//DTD//EN" 
"http://aspectwerkz.codehaus.org/dtd/aspectwerkz.dtd";>

  -<aspectwerkz>
  <system id="cactus">
    <package name="org.apache.cactus.sample.servlet">
      <use-aspect class="TestSampleServletAspectWerkz$GetRequestParametersTestAdvice"/>
    </package>
    <package name="org.apache.cactus.framework.aspect">
      <use-aspect class="OrchestratorAspect"/>
    </package>
  </system>
</aspectwerkz>

  +<aspectwerkz>
  <system id="cactus">
    <package name="org.apache.cactus.sample.servlet">
      <use-aspect class="TestSampleServletAspectWerkz$GetRequestParametersTestAdvice"/>
    </package>
    <package name="org.apache.cactus.framework.aspect">
      <use-aspect class="InitializationAspect"/>
    </package>
  </system>
</aspectwerkz>

  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to