View Javadoc

1   /*
2    * $Id: MessageExchangePattern.java 19191 2010-08-25 21:05:23Z tcarlson $
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;
12  
13  public enum MessageExchangePattern
14  {    
15      ONE_WAY
16      {
17          @Override
18          public boolean hasResponse()
19          {
20              return false;
21          }
22      }, 
23      
24      REQUEST_RESPONSE
25      {
26          @Override
27          public boolean hasResponse()
28          {
29              return true;
30          }
31      }; 
32      
33      public abstract boolean hasResponse();
34  
35      public static MessageExchangePattern fromSyncFlag(boolean sync)
36      {
37          if (sync)
38          {
39              return REQUEST_RESPONSE;
40          }
41          else
42          {
43              return ONE_WAY;
44          }
45      }
46  
47      public static MessageExchangePattern fromString(String string)
48      {
49          String mepString = string.toUpperCase().replace('-', '_');
50          return MessageExchangePattern.valueOf(mepString);
51      }
52  }