Coverage Report - org.mule.transport.stdio.StdioConnector
 
Classes in this File Line Coverage Branch Coverage Complexity
StdioConnector
0%
0/19
0%
0/2
0
 
 1  
 /*
 2  
  * $Id: StdioConnector.java 19198 2010-08-25 21:43:19Z aperepel $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 5  
  *
 6  
  * The software in this package is published under the terms of the CPAL v1.0
 7  
  * license, a copy of which has been included with this distribution in the
 8  
  * LICENSE.txt file.
 9  
  */
 10  
 
 11  
 package org.mule.transport.stdio;
 12  
 
 13  
 import org.mule.api.MuleContext;
 14  
 import org.mule.api.construct.FlowConstruct;
 15  
 import org.mule.api.endpoint.InboundEndpoint;
 16  
 import org.mule.api.processor.MessageProcessor;
 17  
 import org.mule.api.transport.MessageReceiver;
 18  
 import org.mule.transport.AbstractConnector;
 19  
 import org.mule.transport.AbstractPollingMessageReceiver;
 20  
 
 21  
 import java.io.InputStream;
 22  
 import java.io.OutputStream;
 23  
 
 24  
 import org.apache.commons.io.IOUtils;
 25  
 
 26  
 /**
 27  
  * <code>StdioConnector</code> can send and receive Mule events over IO streams.
 28  
  */
 29  
 
 30  
 public abstract class StdioConnector extends AbstractConnector
 31  
 {
 32  
 
 33  
     public static final String STDIO = "stdio";
 34  
     public static final String STREAM_SYSTEM_IN = "system.in";
 35  
     public static final String STREAM_SYSTEM_OUT = "system.out";
 36  
     public static final String STREAM_SYSTEM_ERR = "system.err";
 37  
 
 38  
     protected OutputStream outputStream;
 39  
     protected InputStream inputStream;
 40  
 
 41  
     public StdioConnector(MuleContext context)
 42  
     {
 43  0
         super(context);
 44  0
     }
 45  
     
 46  
     @Override
 47  
     public MessageReceiver createReceiver(FlowConstruct flowConstruct, InboundEndpoint endpoint) throws Exception
 48  
     {
 49  0
         return serviceDescriptor.createMessageReceiver(this, flowConstruct, endpoint,
 50  
                                                        AbstractPollingMessageReceiver.DEFAULT_POLL_FREQUENCY);
 51  
     }
 52  
 
 53  
     @Override
 54  
     public void doStop()
 55  
     {
 56  
         // template method
 57  0
     }
 58  
 
 59  
     @Override
 60  
     protected void doDispose()
 61  
     {
 62  0
         IOUtils.closeQuietly(inputStream);
 63  0
         IOUtils.closeQuietly(outputStream);
 64  0
     }
 65  
 
 66  
     @Override
 67  
     public void doStart()
 68  
     {
 69  
         // template method
 70  0
     }
 71  
 
 72  
     public String getProtocol()
 73  
     {
 74  0
         return STDIO;
 75  
     }
 76  
 
 77  
     public InputStream getInputStream()
 78  
     {
 79  0
         return inputStream;
 80  
     }
 81  
 
 82  
     public void setInputStream(InputStream inputStream)
 83  
     {
 84  0
         this.inputStream = inputStream;
 85  0
     }
 86  
 
 87  
     public OutputStream getOutputStream()
 88  
     {
 89  0
         return outputStream;
 90  
     }
 91  
 
 92  
     public void setOutputStream(OutputStream outputStream)
 93  
     {
 94  0
         this.outputStream = outputStream;
 95  0
     }
 96  
 
 97  
     public void registerListener(InboundEndpoint endpoint, MessageProcessor listener, FlowConstruct flowConstruct) throws Exception
 98  
     {
 99  0
         if (receivers.size() > 0)
 100  
         {
 101  0
             throw new UnsupportedOperationException(
 102  
                 "You can only register one listener per system stream connector");
 103  
         }
 104  0
         super.registerListener(endpoint, listener, flowConstruct);
 105  0
     }
 106  
 }