View Javadoc

1   /*
2    * Copyright (C) The Apache Software Foundation. All rights reserved.
3    *
4    * This software is published under the terms of the Apache Software License
5    * version 1.1, a copy of which has been included with this distribution in
6    * the LICENSE file.
7    * 
8    * $Id: SubscriptionDigester.java 155459 2005-02-26 13:24:44Z dirkv $
9    */
10  package org.apache.commons.messagelet.model;
11  
12  import org.apache.commons.digester.Digester;
13  
14  /** <p><code>MessengerDigester</code> is a digester of Messenger objects so 
15    * that JMS Messengers can be created from an XML config file.</p>
16    *
17    * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
18    * @version $Revision: 155459 $
19    */
20  public class SubscriptionDigester extends Digester {
21  
22      // default implementation classes
23      private String subscriptionsClass = "org.apache.commons.messagelet.model.SubscriptionList";
24      private String subscriptionClass = "org.apache.commons.messagelet.model.Subscription";
25      private String listenerClass = "org.apache.commons.messagelet.impl.MessageServletDispatcher";
26      private String bridgeClass = "org.apache.commons.messagelet.BridgeMDO";
27      private String distributeBridgeClass = "org.apache.commons.messagelet.DistributeBridgeMDO";
28      private String stopWatchClass = "org.apache.commons.messenger.tool.StopWatchMessageListener";
29      private String consumerThreadClass = "org.apache.commons.messagelet.ConsumerThread";
30      
31      public SubscriptionDigester() {
32      }
33      
34      // Implementation methods
35      //-------------------------------------------------------------------------    
36  
37      /** Configure the parsing rules that will be used to process 
38       * the cache config file
39       */
40      protected void configure() {
41          if (configured) {
42              return;
43          }
44          else {
45              configured = true;
46          }
47          
48          String path = "subscriptions";
49          
50          addObjectCreate( path, subscriptionsClass, "className" );
51          addSetProperties( path );
52      
53          path = "subscriptions/subscription";
54          addObjectCreate( path, subscriptionClass, "className" );
55          addSetProperties( path );        
56          addSetNext( path, "addSubscription",
57             "org.apache.commons.messagelet.model.Subscription"
58          );        
59  
60          addCallMethod( "subscriptions/subscription/servlet", "setServlet", 0);
61          
62          path = "subscriptions/subscription/consumerThread";
63          addObjectCreate( path, consumerThreadClass, "className" );
64          addSetProperties( path );
65          addSetNext( path, "setConsumerThread",
66             consumerThreadClass
67          );
68  
69          path = "subscriptions/subscription/listener";
70          addObjectCreate( path, listenerClass, "className" );
71          addSetProperties( path );
72          addSetNext( path, "setMessageListener",
73             "javax.jms.MessageListener"
74          );
75  
76  
77          
78          path = "subscriptions/subscription/stopWatch";
79          addObjectCreate( path, stopWatchClass, "className" );
80          addSetProperties( path );
81          addSetNext( path, "setMessageListener",
82             "javax.jms.MessageListener"
83          );
84  
85          
86          path = "subscriptions/subscription/bridge";
87          addObjectCreate( path, bridgeClass, "className" );
88          addSetProperties( path );
89          addSetNext( path, "setMessageListener",
90             "javax.jms.MessageListener"
91          );
92          
93          path = "subscriptions/subscription/distributeBridge";
94          addObjectCreate( path, distributeBridgeClass, "className" );
95          addSetProperties( path );
96          addSetNext( path, "setMessageListener",
97             "javax.jms.MessageListener"
98          );
99          
100         addCallMethod("subscriptions/subscription/distributeBridge/subject", "addOutputSubject", 0);        
101     }
102 }