activemq-cpp-3.4.0

src/main/activemq/util/ServiceSupport.h

Go to the documentation of this file.
00001 /*
00002  * Licensed to the Apache Software Foundation (ASF) under one or more
00003  * contributor license agreements.  See the NOTICE file distributed with
00004  * this work for additional information regarding copyright ownership.
00005  * The ASF licenses this file to You under the Apache License, Version 2.0
00006  * (the "License"); you may not use this file except in compliance with
00007  * the License.  You may obtain a copy of the License at
00008  *
00009  *     http://www.apache.org/licenses/LICENSE-2.0
00010  *
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 
00018 #ifndef _ACTIVEMQ_UTIL_SERVICESUPPORT_H_
00019 #define SERVICESUPPORT_H_
00020 
00021 #include <activemq/util/Config.h>
00022 #include <activemq/util/Service.h>
00023 
00024 #include <decaf/util/concurrent/atomic/AtomicBoolean.h>
00025 #include <decaf/util/concurrent/CopyOnWriteArrayList.h>
00026 
00027 namespace activemq {
00028 namespace util {
00029 
00030     class ServiceListener;
00031     class ServiceStopper;
00032 
00038     class AMQCPP_API ServiceSupport : public Service {
00039     private:
00040 
00041         decaf::util::concurrent::atomic::AtomicBoolean started;
00042         decaf::util::concurrent::atomic::AtomicBoolean stopping;
00043         decaf::util::concurrent::atomic::AtomicBoolean stopped;
00044         decaf::util::concurrent::CopyOnWriteArrayList<ServiceListener*> listemers;
00045 
00046     public:
00047 
00048         ServiceSupport(const ServiceSupport&);
00049         ServiceSupport& operator=(const ServiceSupport&);
00050 
00051     public:
00052 
00053         ServiceSupport();
00054 
00055         virtual ~ServiceSupport();
00056 
00057     public:
00058 
00065         static void dispose(Service* service);
00066 
00071         void start();
00072 
00076         void stop();
00077 
00081         bool isStarted() const;
00082 
00086         bool isStopping() const;
00087 
00091         bool isStopped() const;
00092 
00097         void addServiceListener(ServiceListener* listener);
00098 
00103         void removeServiceListener(ServiceListener* llistener);
00104 
00105     protected:
00106 
00111         virtual void doStop(ServiceStopper* stopper) = 0;
00112 
00117         virtual void doStart() = 0;
00118 
00119     };
00120 
00121 }}
00122 
00123 #endif /* _ACTIVEMQ_UTIL_SERVICESUPPORT_H_ */