00001 /* 00002 * ServiceEvent.hpp 00003 * 00004 * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. 00005 * 00006 * Oracle is a registered trademarks of Oracle Corporation and/or its 00007 * affiliates. 00008 * 00009 * This software is the confidential and proprietary information of Oracle 00010 * Corporation. You shall not disclose such confidential and proprietary 00011 * information and shall use it only in accordance with the terms of the 00012 * license agreement you entered into with Oracle. 00013 * 00014 * This notice may not be removed or altered. 00015 */ 00016 #ifndef COH_SERVICE_EVENT_HPP 00017 #define COH_SERVICE_EVENT_HPP 00018 00019 #include "coherence/lang.ns" 00020 00021 #include "coherence/util/Event.hpp" 00022 #include "coherence/util/Listeners.hpp" 00023 00024 COH_OPEN_NAMESPACE2(coherence,util) 00025 00026 class Service; 00027 00028 00029 /** 00030 * An event which indicates that a Service state has changed: 00031 * <ul> 00032 * <li>a service is starting</li> 00033 * <li>a service has started</li> 00034 * <li>a service is stopping</li> 00035 * <li>a service has stopped</li> 00036 * </ul> 00037 * A ServiceEvent object is sent as an argument to the ServiceListener 00038 * interface methods. 00039 * 00040 * @see Service 00041 * @see ServiceListener 00042 * 00043 * @author jh 2007.12.13 00044 */ 00045 class COH_EXPORT ServiceEvent 00046 : public class_spec<ServiceEvent, 00047 extends<Event> > 00048 { 00049 friend class factory<ServiceEvent>; 00050 00051 // ----- handle definitions --------------------------------------------- 00052 00053 public: 00054 /** 00055 * Service Handle definition. 00056 */ 00057 typedef TypedHandle<Service> ServiceHandle; 00058 00059 /** 00060 * Service View definition. 00061 */ 00062 typedef TypedHandle<const Service> ServiceView; 00063 00064 00065 // ----- Id definition -------------------------------------------------- 00066 00067 public: 00068 typedef enum 00069 { 00070 service_starting = 1, // the service is starting 00071 service_started = 2, // the service has started 00072 service_stopping = 3, // the service is stopping 00073 service_stopped = 4 // the service has stopped 00074 } Id; 00075 00076 00077 // ----- constructors --------------------------------------------------- 00078 00079 protected: 00080 /** 00081 * Create a new ServiceEvent instance. 00082 * 00083 * @param vService the Service that fired the event 00084 * @param identity the event's ID, one of the Id enum values 00085 */ 00086 ServiceEvent(ServiceView vService, Id identity); 00087 00088 private: 00089 /** 00090 * Blocked copy constructor. 00091 */ 00092 ServiceEvent(const ServiceEvent&); 00093 00094 00095 // ----- ServiceEvent interface ----------------------------------------- 00096 00097 public: 00098 /** 00099 * Dispatch this event to the specified listeners collection. 00100 * 00101 * @param vListeners the listeners collection 00102 * 00103 * @throws ClassCastException if any of the targets is not an instance of 00104 * the ServiceListener interface 00105 */ 00106 virtual void dispatch(Listeners::View vListeners) const; 00107 00108 00109 // ----- Object interface ----------------------------------------------- 00110 00111 public: 00112 /** 00113 * {@inheritDoc} 00114 */ 00115 virtual TypedHandle<const String> toString() const; 00116 00117 00118 // ----- accessors ------------------------------------------------------ 00119 00120 public: 00121 /** 00122 * Return this event's ID. 00123 * 00124 * @return the event ID, one of the Id enum values 00125 */ 00126 virtual Id getId() const; 00127 00128 /** 00129 * Return the Service that fired the event. 00130 * 00131 * @return the Service 00132 */ 00133 virtual ServiceView getService() const; 00134 00135 00136 // ----- data members --------------------------------------------------- 00137 00138 protected: 00139 /** 00140 * The event's ID. 00141 */ 00142 Id m_id; 00143 }; 00144 00145 COH_CLOSE_NAMESPACE2 00146 00147 #endif // COH_SERVICE_EVENT_HPP