View Javadoc

1   /*
2    * $Id: SedaModel.java 7963 2007-08-21 08:53:15Z dirk.olmes $
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 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.impl.model.seda;
12  
13  import org.mule.MuleManager;
14  import org.mule.config.PoolingProfile;
15  import org.mule.config.QueueProfile;
16  import org.mule.impl.MuleDescriptor;
17  import org.mule.impl.model.AbstractModel;
18  import org.mule.umo.UMOComponent;
19  import org.mule.umo.UMODescriptor;
20  
21  /**
22   * A Mule component service model that uses Seda principles to achieve high
23   * throughput by queueing events for components and processing them concurrently.
24   */
25  public class SedaModel extends AbstractModel
26  {
27  
28      /**
29       * The time out used for taking from the Seda Queue.
30       */
31      private int queueTimeout = MuleManager.getConfiguration().getSynchronousEventTimeout();
32  
33      /**
34       * Whether components in this model should be pooled or not.
35       */
36      private boolean enablePooling = true;
37  
38      /**
39       * Whether to create a new component for every request.
40       */
41      protected boolean componentPerRequest = false;
42  
43  
44      /**
45       * the pooling configuration used when initialising the component described by
46       * this descriptor.
47       */
48      protected PoolingProfile poolingProfile;
49  
50      /**
51       * The queuing profile for events received for this component
52       */
53      protected QueueProfile queueProfile;
54  
55  
56      public SedaModel()
57      {
58          super();
59          poolingProfile = new PoolingProfile();
60          queueProfile = new QueueProfile();
61      }
62  
63      /**
64       * Returns the model type name. This is a friendly identifier that is used to
65       * look up the SPI class for the model
66       * 
67       * @return the model type
68       */
69      public String getType()
70      {
71          return "seda";
72      }
73  
74      protected UMOComponent createComponent(UMODescriptor descriptor)
75      {
76          return new SedaComponent((MuleDescriptor) descriptor, this);
77      }
78  
79      public int getQueueTimeout()
80      {
81          return queueTimeout;
82      }
83  
84      public void setQueueTimeout(int queueTimeout)
85      {
86          this.queueTimeout = queueTimeout;
87      }
88  
89      public boolean isEnablePooling()
90      {
91          return enablePooling;
92      }
93  
94      public void setEnablePooling(boolean enablePooling)
95      {
96          this.enablePooling = enablePooling;
97      }
98  
99      public boolean isComponentPerRequest()
100     {
101         return componentPerRequest;
102     }
103 
104     public void setComponentPerRequest(boolean componentPerRequest)
105     {
106         this.componentPerRequest = componentPerRequest;
107     }
108 
109 
110     public PoolingProfile getPoolingProfile()
111     {
112         return poolingProfile;
113     }
114 
115     public void setPoolingProfile(PoolingProfile poolingProfile)
116     {
117         this.poolingProfile = poolingProfile;
118     }
119 
120     public QueueProfile getQueueProfile()
121     {
122         return queueProfile;
123     }
124 
125     public void setQueueProfile(QueueProfile queueProfile)
126     {
127         this.queueProfile = queueProfile;
128     }
129 }