1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef __FRAMEWORK_JOBS_JOBEXECUTOR_HXX_ 25 #define __FRAMEWORK_JOBS_JOBEXECUTOR_HXX_ 26 27 //_______________________________________ 28 // my own includes 29 30 #include <jobs/configaccess.hxx> 31 #include <threadhelp/threadhelpbase.hxx> 32 #include <macros/xinterface.hxx> 33 #include <macros/xtypeprovider.hxx> 34 #include <macros/xserviceinfo.hxx> 35 #include <macros/debug.hxx> 36 #include <stdtypes.h> 37 #include <general.h> 38 39 //_______________________________________ 40 // interface includes 41 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 42 #include <com/sun/star/task/XJobExecutor.hpp> 43 #include <com/sun/star/lang/XComponent.hpp> 44 #include <com/sun/star/container/XContainerListener.hpp> 45 #include <com/sun/star/lang/XEventListener.hpp> 46 #include <com/sun/star/document/XEventListener.hpp> 47 #include <com/sun/star/frame/XModuleManager.hpp> 48 49 //_______________________________________ 50 // other includes 51 #include <cppuhelper/weak.hxx> 52 #include <rtl/ustring.hxx> 53 54 //_______________________________________ 55 // namespace 56 57 namespace framework{ 58 59 //_______________________________________ 60 // public const 61 62 //_______________________________________ 63 /** 64 @short implements a job executor, which can be triggered from any code 65 @descr It uses the given trigger event to locate any registered job service 66 inside the configuration and execute it. Of course it controls the 67 lifetime of such jobs too. 68 */ 69 class JobExecutor : public css::lang::XTypeProvider 70 , public css::lang::XServiceInfo 71 , public css::task::XJobExecutor 72 , public css::container::XContainerListener // => lang.XEventListener 73 , public css::document::XEventListener 74 , private ThreadHelpBase 75 , public ::cppu::OWeakObject 76 { 77 //___________________________________ 78 // member 79 80 private: 81 82 /** reference to the uno service manager */ 83 css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMGR; 84 85 /** reference to the module info service */ 86 css::uno::Reference< css::frame::XModuleManager > m_xModuleManager; 87 88 /** cached list of all registered event names of cfg for call optimization. */ 89 OUStringList m_lEvents; 90 91 /** we listen at the configuration for changes at the event list. */ 92 ConfigAccess m_aConfig; 93 94 //___________________________________ 95 // native interface methods 96 97 public: 98 99 JobExecutor( const css::uno::Reference< css::lang::XMultiServiceFactory >& xSMGR ); 100 virtual ~JobExecutor( ); 101 102 //___________________________________ 103 // uno interface methods 104 105 public: 106 107 // XInterface, XTypeProvider, XServiceInfo 108 FWK_DECLARE_XINTERFACE 109 FWK_DECLARE_XTYPEPROVIDER 110 DECLARE_XSERVICEINFO 111 112 // task.XJobExecutor 113 virtual void SAL_CALL trigger( const ::rtl::OUString& sEvent ) throw(css::uno::RuntimeException); 114 115 // document.XEventListener 116 virtual void SAL_CALL notifyEvent( const css::document::EventObject& aEvent ) throw(css::uno::RuntimeException); 117 118 // container.XContainerListener 119 virtual void SAL_CALL elementInserted( const css::container::ContainerEvent& aEvent ) throw(css::uno::RuntimeException); 120 virtual void SAL_CALL elementRemoved ( const css::container::ContainerEvent& aEvent ) throw(css::uno::RuntimeException); 121 virtual void SAL_CALL elementReplaced( const css::container::ContainerEvent& aEvent ) throw(css::uno::RuntimeException); 122 123 // lang.XEventListener 124 virtual void SAL_CALL disposing( const css::lang::EventObject& aEvent ) throw(css::uno::RuntimeException); 125 }; 126 127 } // namespace framework 128 129 #endif // __FRAMEWORK_JOBS_JOBEXECUTOR_HXX_ 130