001 /* 002 * Copyright (C) The Apache Software Foundation. All rights reserved. 003 * 004 * This software is published under the terms of the Apache Software License 005 * version 1.1, a copy of which has been included with this distribution in 006 * the LICENSE file. 007 * 008 * $Id: SubscriptionDigester.java 155459 2005-02-26 13:24:44Z dirkv $ 009 */ 010 package org.apache.commons.messagelet.model; 011 012 import org.apache.commons.digester.Digester; 013 014 /** <p><code>MessengerDigester</code> is a digester of Messenger objects so 015 * that JMS Messengers can be created from an XML config file.</p> 016 * 017 * @author <a href="mailto:jstrachan@apache.org">James Strachan</a> 018 * @version $Revision: 155459 $ 019 */ 020 public class SubscriptionDigester extends Digester { 021 022 // default implementation classes 023 private String subscriptionsClass = "org.apache.commons.messagelet.model.SubscriptionList"; 024 private String subscriptionClass = "org.apache.commons.messagelet.model.Subscription"; 025 private String listenerClass = "org.apache.commons.messagelet.impl.MessageServletDispatcher"; 026 private String bridgeClass = "org.apache.commons.messagelet.BridgeMDO"; 027 private String distributeBridgeClass = "org.apache.commons.messagelet.DistributeBridgeMDO"; 028 private String stopWatchClass = "org.apache.commons.messenger.tool.StopWatchMessageListener"; 029 private String consumerThreadClass = "org.apache.commons.messagelet.ConsumerThread"; 030 031 public SubscriptionDigester() { 032 } 033 034 // Implementation methods 035 //------------------------------------------------------------------------- 036 037 /** Configure the parsing rules that will be used to process 038 * the cache config file 039 */ 040 protected void configure() { 041 if (configured) { 042 return; 043 } 044 else { 045 configured = true; 046 } 047 048 String path = "subscriptions"; 049 050 addObjectCreate( path, subscriptionsClass, "className" ); 051 addSetProperties( path ); 052 053 path = "subscriptions/subscription"; 054 addObjectCreate( path, subscriptionClass, "className" ); 055 addSetProperties( path ); 056 addSetNext( path, "addSubscription", 057 "org.apache.commons.messagelet.model.Subscription" 058 ); 059 060 addCallMethod( "subscriptions/subscription/servlet", "setServlet", 0); 061 062 path = "subscriptions/subscription/consumerThread"; 063 addObjectCreate( path, consumerThreadClass, "className" ); 064 addSetProperties( path ); 065 addSetNext( path, "setConsumerThread", 066 consumerThreadClass 067 ); 068 069 path = "subscriptions/subscription/listener"; 070 addObjectCreate( path, listenerClass, "className" ); 071 addSetProperties( path ); 072 addSetNext( path, "setMessageListener", 073 "javax.jms.MessageListener" 074 ); 075 076 077 078 path = "subscriptions/subscription/stopWatch"; 079 addObjectCreate( path, stopWatchClass, "className" ); 080 addSetProperties( path ); 081 addSetNext( path, "setMessageListener", 082 "javax.jms.MessageListener" 083 ); 084 085 086 path = "subscriptions/subscription/bridge"; 087 addObjectCreate( path, bridgeClass, "className" ); 088 addSetProperties( path ); 089 addSetNext( path, "setMessageListener", 090 "javax.jms.MessageListener" 091 ); 092 093 path = "subscriptions/subscription/distributeBridge"; 094 addObjectCreate( path, distributeBridgeClass, "className" ); 095 addSetProperties( path ); 096 addSetNext( path, "setMessageListener", 097 "javax.jms.MessageListener" 098 ); 099 100 addCallMethod("subscriptions/subscription/distributeBridge/subject", "addOutputSubject", 0); 101 } 102 }