Coverage report

  %line %branch
org.apache.commons.jelly.tags.jetty.SocketListenerTag
79% 
93% 

 1  
 /*
 2  
  * Copyright 2002,2004 The Apache Software Foundation.
 3  
  *
 4  
  * Licensed under the Apache License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  *      http://www.apache.org/licenses/LICENSE-2.0
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 
 17  
 package org.apache.commons.jelly.tags.jetty;
 18  
 
 19  
 import java.io.IOException;
 20  
 
 21  
 import org.apache.commons.jelly.JellyTagException;
 22  
 import org.apache.commons.jelly.TagSupport;
 23  
 import org.apache.commons.jelly.XMLOutput;
 24  
 
 25  
 import org.mortbay.http.SocketListener;
 26  
 import org.mortbay.util.InetAddrPort;
 27  
 
 28  
 /**
 29  
  * Declare a socket listener for a Jetty http server
 30  
  *
 31  
  * @author  rtl
 32  
  * @version $Id: SocketListenerTag.java,v 1.3 2002/07/14 12:38:22 dion Exp $
 33  
  */
 34  1
 public class SocketListenerTag extends TagSupport {
 35  
 
 36  
     /** parameter port with default*/
 37  10
     private int _port = JettyHttpServerTag.DEFAULT_PORT;
 38  
 
 39  
     /** parameter host, with default */
 40  10
     private String _host = JettyHttpServerTag.DEFAULT_HOST;
 41  
 
 42  
     /** Creates a new instance of SocketListenerTag */
 43  10
     public SocketListenerTag() {
 44  10
     }
 45  
 
 46  
     /**
 47  
      * Perform the tag functionality. In this case, add a socket listener
 48  
      * for the specified host and port to the parent server,
 49  
      *
 50  
      * @param xmlOutput where to send output
 51  
      * @throws Exception when an error occurs
 52  
      */
 53  
     public void doTag(XMLOutput xmlOutput) throws JellyTagException {
 54  10
         JettyHttpServerTag httpserver = (JettyHttpServerTag) findAncestorWithClass(
 55  
             JettyHttpServerTag.class);
 56  10
         if ( httpserver == null ) {
 57  0
             throw new JellyTagException( "<socketListener> tag must be enclosed inside a <server> tag" );
 58  
         }
 59  
 
 60  
         try {
 61  10
             httpserver.addListener(
 62  
                 new SocketListener(class="keyword">new InetAddrPort(getHost(), getPort())));
 63  10
         }
 64  
         catch (IOException e) {
 65  0
             throw new JellyTagException(e);
 66  
         }
 67  
 
 68  10
         invokeBody(xmlOutput);
 69  10
     }
 70  
 
 71  
     //--------------------------------------------------------------------------
 72  
     // Property accessors/mutators
 73  
     //--------------------------------------------------------------------------
 74  
     /**
 75  
      * Getter for property port.
 76  
      *
 77  
      * @return value of property port.
 78  
      */
 79  
     public int getPort() {
 80  10
         return _port;
 81  
     }
 82  
 
 83  
     /**
 84  
      * Setter for property port.
 85  
      *
 86  
      * @param port New value of property port.
 87  
      */
 88  
     public void setPort(int port) {
 89  9
         _port = port;
 90  9
     }
 91  
 
 92  
     /**
 93  
      * Getter for property host.
 94  
      *
 95  
      * @return value of property host.
 96  
      */
 97  
     public String getHost() {
 98  10
         return _host;
 99  
     }
 100  
 
 101  
     /**
 102  
      * Setter for property host.
 103  
      *
 104  
      * @param host New value of property host.
 105  
      */
 106  
     public void setHost(String host) {
 107  0
         _host = host;
 108  0
     }
 109  
 
 110  
 }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.