KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mule > impl > model > direct > DirectComponent


1 /*
2  * $Id: DirectComponent.java 3798 2006-11-04 04:07:14Z aperepel $
3  * --------------------------------------------------------------------------------------
4  * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com
5  *
6  * The software in this package is published under the terms of the MuleSource MPL
7  * license, a copy of which has been included with this distribution in the
8  * LICENSE.txt file.
9  */

10
11 package org.mule.impl.model.direct;
12
13 import org.mule.impl.MuleDescriptor;
14 import org.mule.impl.MuleMessage;
15 import org.mule.impl.model.AbstractComponent;
16 import org.mule.impl.model.DefaultMuleProxy;
17 import org.mule.impl.model.MuleProxy;
18 import org.mule.umo.UMOEvent;
19 import org.mule.umo.UMOException;
20 import org.mule.umo.UMOMessage;
21 import org.mule.umo.lifecycle.InitialisationException;
22 import org.mule.umo.model.UMOModel;
23
24 import java.util.List JavaDoc;
25
26 /**
27  * A direct component invokes the service component directly without any threading or
28  * pooling, even when the nvocation is asynchronous
29  *
30  * @author <a HREF="mailto:ross.mason@symphonysoft.com">Ross Mason</a>
31  * @version $Revision: 3798 $
32  */

33 public class DirectComponent extends AbstractComponent
34 {
35     /**
36      * Serial version
37      */

38     private static final long serialVersionUID = -8590955440156945732L;
39
40     protected List JavaDoc interceptorList = null;
41     protected MuleProxy proxy;
42
43     public DirectComponent(MuleDescriptor descriptor, UMOModel model)
44     {
45         super(descriptor, model);
46     }
47
48     protected void doInitialise() throws InitialisationException
49     {
50
51         try
52         {
53             Object JavaDoc component = lookupComponent();
54             proxy = new DefaultMuleProxy(component, descriptor, null);
55             proxy.setStatistics(getStatistics());
56         }
57         catch (UMOException e)
58         {
59             throw new InitialisationException(e, this);
60         }
61     }
62
63     protected UMOMessage doSend(UMOEvent event) throws UMOException
64     {
65
66         Object JavaDoc obj = proxy.onCall(event);
67         if (obj instanceof UMOMessage)
68         {
69             return (UMOMessage)obj;
70         }
71         else
72         {
73             return new MuleMessage(obj, event.getMessage());
74         }
75     }
76
77     protected void doDispatch(UMOEvent event) throws UMOException
78     {
79         proxy.onCall(event);
80     }
81
82     protected void doStop() throws UMOException
83     {
84         proxy.stop();
85     }
86
87     protected void doStart() throws UMOException
88     {
89         proxy.start();
90     }
91
92     protected void doPause()
93     {
94         proxy.suspend();
95     }
96
97     protected void doResume()
98     {
99         proxy.resume();
100     }
101
102     protected void doDispose()
103     {
104         proxy.dispose();
105     }
106 }
107
Popular Tags