View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.module.jca;
8   
9   import org.mule.api.MuleContext;
10  import org.mule.api.MuleEvent;
11  import org.mule.api.MuleException;
12  import org.mule.api.processor.MessageProcessor;
13  import org.mule.api.processor.MessageProcessorChainBuilder;
14  import org.mule.module.jca.i18n.JcaMessages;
15  import org.mule.service.AbstractService;
16  
17  /**
18   * <code>JcaService</code> Is the type of service used in Mule when embedded inside
19   * an app server using JCA. In the future we might want to use one of the existing
20   * models.
21   */
22  public class JcaService extends AbstractService
23  {
24  
25      /**
26       * Serial version
27       */
28      private static final long serialVersionUID = -1510441245219710451L;
29  
30      
31      public JcaService(MuleContext muleContext)
32      {
33          super(muleContext);
34      }
35      
36      /**
37       * This is the synchronous call method and not supported by components managed in
38       * a JCA container
39       * 
40       * @param event
41       * @throws MuleException
42       */
43      public MuleEvent sendEvent(MuleEvent event) throws MuleException
44      {
45          throw new UnsupportedOperationException("sendEvent()");
46      }
47  
48      public boolean isPaused()
49      {
50          // JcaService is a wrapper for a hosted service implementation and
51          // therefore cannot be paused by mule
52          return false;
53      }
54  
55      protected void waitIfPaused(MuleEvent event) throws InterruptedException
56      {
57          // JcaService is a wrapper for a hosted service implementation and
58          // therefore cannot be paused by mule
59      }
60  
61      protected void doPause() 
62      {
63          throw new UnsupportedOperationException(JcaMessages.cannotPauseResumeJcaComponent().getMessage());
64      }
65  
66      protected void doResume() 
67      {
68          throw new UnsupportedOperationException(JcaMessages.cannotPauseResumeJcaComponent().getMessage());
69      }
70  
71      @Override
72      protected void addMessageProcessors(MessageProcessorChainBuilder builder)
73      {
74          builder.chain(new MessageProcessor()
75          {
76              // Wrap to prevent lifecycle propagation. Component is given lifecycle
77              // directly by AbstractService
78              public MuleEvent process(MuleEvent event) throws MuleException
79              {
80                  return component.process(event);
81              }
82          });
83      }
84  }