KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > activemq > xbean > XBeanBrokerService


1 /**
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one or more
4  * contributor license agreements. See the NOTICE file distributed with
5  * this work for additional information regarding copyright ownership.
6  * The ASF licenses this file to You under the Apache License, Version 2.0
7  * (the "License"); you may not use this file except in compliance with
8  * the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18 package org.apache.activemq.xbean;
19
20 import org.apache.activemq.broker.BrokerService;
21 import org.springframework.beans.factory.DisposableBean;
22 import org.springframework.beans.factory.InitializingBean;
23
24 /**
25  * An ActiveMQ Message Broker. It consists of a number of transport
26  * connectors, network connectors and a bunch of properties which can be used to
27  * configure the broker as its lazily created.
28  *
29  * @org.apache.xbean.XBean element="broker" rootElement="true"
30  * @org.apache.xbean.Defaults {code:xml}
31  * <broker test="foo.bar">
32  * lets.
33  * see what it includes.
34  * </broker>
35  * {code}
36  * @version $Revision: 1.1 $
37  */

38 public class XBeanBrokerService extends BrokerService implements InitializingBean, DisposableBean {
39
40     private boolean start = true;
41
42     public XBeanBrokerService() {
43     }
44
45     public void afterPropertiesSet() throws Exception JavaDoc {
46         if (start) {
47             start();
48         }
49     }
50
51     public void destroy() throws Exception JavaDoc {
52         stop();
53     }
54
55     public boolean isStart() {
56         return start;
57     }
58
59     /**
60      * Sets whether or not the broker is started along with the ApplicationContext it is defined within.
61      * Normally you would want the broker to start up along with the ApplicationContext but sometimes when working
62      * with JUnit tests you may wish to start and stop the broker explicitly yourself.
63      */

64     public void setStart(boolean start) {
65         this.start = start;
66     }
67 }
68
Popular Tags