You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by hu...@apache.org on 2004/06/01 02:55:50 UTC

cvs commit: jakarta-commons-sandbox/chain/apps/agility/src/java/org/apache/commons/agility/impl ResponseContext.java RequestContext.java HandlerCommand.java ControllerCatalog.java

husted      2004/05/31 17:55:50

  Added:       chain/apps/agility/src/java/org/apache/commons/agility/impl
                        ResponseContext.java RequestContext.java
                        HandlerCommand.java ControllerCatalog.java
  Log:
  Add controller application.
  
  Revision  Changes    Path
  1.1                  jakarta-commons-sandbox/chain/apps/agility/src/java/org/apache/commons/agility/impl/ResponseContext.java
  
  Index: ResponseContext.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/chain/apps/agility/src/java/org/apache/commons/agility/impl/ResponseContext.java,v 1.1 2004/06/01 00:55:50 husted Exp $
   * $Revision: 1.1 $
   * $Date: 2004/06/01 00:55:50 $
   *
   * Copyright 1999-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.commons.agility.impl;
  
  import org.apache.commons.agility.Response;
  import org.apache.commons.chain.impl.ContextBase;
  
  /**
   * Concrete implementation of Response based on a Common Chain Context.
   */
  public class ResponseContext extends ContextBase implements Response {
  
      /**
       * Name field.
       */
      private String name;
  
      /**
       * Constructor to create Response and set name.
       * @param name
       */
      public ResponseContext(String name) {
          super();
          this.name = name;
      }
  
      // See interface for Javadoc
      public String getName() {
          return name;
      }
  
  
  }
  
  
  
  1.1                  jakarta-commons-sandbox/chain/apps/agility/src/java/org/apache/commons/agility/impl/RequestContext.java
  
  Index: RequestContext.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/chain/apps/agility/src/java/org/apache/commons/agility/impl/RequestContext.java,v 1.1 2004/06/01 00:55:50 husted Exp $
   * $Revision: 1.1 $
   * $Date: 2004/06/01 00:55:50 $
   *
   * Copyright 1999-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.commons.agility.impl;
  
  import org.apache.commons.agility.Request;
  import org.apache.commons.agility.Response;
  import org.apache.commons.chain.impl.ContextBase;
  
  /**
   * Concrete implementation of Request based on a Commons Chain Context.
   */
  public class RequestContext extends ContextBase implements Request {
  
      /**
       * Name field.
       */
      private String name;
  
      /**
       * Response field.
       */
      private Response response;
  
      /**
       * Constructor to create Request and set name.
       * @param name
       */
      public RequestContext(String name) {
          super();
          this.name = name;
      }
  
      // See interface for Javadoc
      public String getName() {
          return name;
      }
  
      // See interface for Javadoc
      public Response getResponse() {
          return response;
      }
  
      // See interface for Javadoc
      public void setResponse(Response response) {
          this.response = response;
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/chain/apps/agility/src/java/org/apache/commons/agility/impl/HandlerCommand.java
  
  Index: HandlerCommand.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/chain/apps/agility/src/java/org/apache/commons/agility/impl/HandlerCommand.java,v 1.1 2004/06/01 00:55:50 husted Exp $
   * $Revision: 1.1 $
   * $Date: 2004/06/01 00:55:50 $
   *
   * Copyright 1999-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.commons.agility.impl;
  
  import org.apache.commons.agility.ProcessException;
  import org.apache.commons.agility.Request;
  import org.apache.commons.agility.RequestHandler;
  import org.apache.commons.agility.Response;
  import org.apache.commons.chain.Command;
  import org.apache.commons.chain.Context;
  
  /**
   * Concrete implementation of RequestHandler utilizing a Commons Chain Command.
   */
  public class HandlerCommand implements Command, RequestHandler {
      String name = null;
  
      // See interface for Javadoc
      public HandlerCommand(String name) {
          this.name = name;
      }
  
      // See interface for Javadoc
      public boolean execute(Context context) throws Exception {
          handle((Request) context);
          return true;
      }
  
      // See interface for Javadoc
      public String getName() {
          return name;
      }
  
      // See interface for Javadoc
      public void handle(Request request) throws ProcessException {
          try {
              String name = request.getName();
              Response response = new ResponseContext(name);
              request.setResponse(response);
          } catch (Exception e) {
              throw new ProcessException(e);
          }
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/chain/apps/agility/src/java/org/apache/commons/agility/impl/ControllerCatalog.java
  
  Index: ControllerCatalog.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/chain/apps/agility/src/java/org/apache/commons/agility/impl/ControllerCatalog.java,v 1.1 2004/06/01 00:55:50 husted Exp $
   * $Revision: 1.1 $
   * $Date: 2004/06/01 00:55:50 $
   *
   * Copyright 1999-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.commons.agility.impl;
  
  import org.apache.commons.agility.Controller;
  import org.apache.commons.agility.ProcessException;
  import org.apache.commons.agility.Request;
  import org.apache.commons.agility.RequestHandler;
  import org.apache.commons.chain.Command;
  import org.apache.commons.chain.impl.CatalogBase;
  
  /**
   * Concrete implemenation of Controller utilizing a Common Chain Catalog.
   */
  public class ControllerCatalog extends CatalogBase implements Controller {
  
      // See interface for Javadoc
      public void addHandler(RequestHandler handler) {
          this.addCommand(handler.getName(), (Command) handler);
      }
  
      // See interface for Javadoc
      public RequestHandler getHandler(String name) {
          return null;
      }
  
      // See interface for Javadoc
      public void process(Request request) throws ProcessException {
          RequestHandler handler = (RequestHandler) getCommand(request.getName());
          if (handler != null) handler.handle(request);
      }
  }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org