View Javadoc

1   /*
2    * $Id: JcaService.java 21307 2011-02-17 15:35:44Z dfeist $
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.module.jca;
12  
13  import org.mule.api.MuleContext;
14  import org.mule.api.MuleEvent;
15  import org.mule.api.MuleException;
16  import org.mule.api.processor.MessageProcessor;
17  import org.mule.api.processor.MessageProcessorChainBuilder;
18  import org.mule.module.jca.i18n.JcaMessages;
19  import org.mule.service.AbstractService;
20  
21  /**
22   * <code>JcaService</code> Is the type of service used in Mule when embedded inside
23   * an app server using JCA. In the future we might want to use one of the existing
24   * models.
25   */
26  public class JcaService extends AbstractService
27  {
28  
29      /**
30       * Serial version
31       */
32      private static final long serialVersionUID = -1510441245219710451L;
33  
34      
35      public JcaService(MuleContext muleContext)
36      {
37          super(muleContext);
38      }
39      
40      /**
41       * This is the synchronous call method and not supported by components managed in
42       * a JCA container
43       * 
44       * @param event
45       * @throws MuleException
46       */
47      public MuleEvent sendEvent(MuleEvent event) throws MuleException
48      {
49          throw new UnsupportedOperationException("sendEvent()");
50      }
51  
52      public boolean isPaused()
53      {
54          // JcaService is a wrapper for a hosted service implementation and
55          // therefore cannot be paused by mule
56          return false;
57      }
58  
59      protected void waitIfPaused(MuleEvent event) throws InterruptedException
60      {
61          // JcaService is a wrapper for a hosted service implementation and
62          // therefore cannot be paused by mule
63      }
64  
65      protected void doPause() 
66      {
67          throw new UnsupportedOperationException(JcaMessages.cannotPauseResumeJcaComponent().getMessage());
68      }
69  
70      protected void doResume() 
71      {
72          throw new UnsupportedOperationException(JcaMessages.cannotPauseResumeJcaComponent().getMessage());
73      }
74  
75      @Override
76      protected void addMessageProcessors(MessageProcessorChainBuilder builder)
77      {
78          builder.chain(new MessageProcessor()
79          {
80              // Wrap to prevent lifecycle propagation. Component is given lifecycle
81              // directly by AbstractService
82              public MuleEvent process(MuleEvent event) throws MuleException
83              {
84                  return component.process(event);
85              }
86          });
87      }
88  }