1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: multistratumbackend.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef CONFIGMGR_BACKEND_MULTISTRATUMBACKEND_HXX_
32 #define CONFIGMGR_BACKEND_MULTISTRATUMBACKEND_HXX_
34 #include <com/sun/star/configuration/backend/XBackend.hpp>
35 #include <com/sun/star/configuration/backend/XBackendEntities.hpp>
36 #include <com/sun/star/configuration/backend/XVersionedSchemaSupplier.hpp>
37 #include <com/sun/star/uno/XComponentContext.hpp>
38 #include <com/sun/star/lang/XInitialization.hpp>
39 #include <com/sun/star/lang/XServiceInfo.hpp>
40 #include <com/sun/star/uno/XInterface.hpp>
41 #include <com/sun/star/configuration/InvalidBootstrapFileException.hpp>
42 #include <com/sun/star/configuration/backend/BackendSetupException.hpp>
43 #include <com/sun/star/configuration/backend/XBackendChangesNotifier.hpp>
44 #include <com/sun/star/configuration/backend/XBackendChangesListener.hpp>
45 #include <cppuhelper/compbase7.hxx>
52 namespace configmgr
{ namespace backend
{
54 namespace css
= com::sun::star
;
55 namespace uno
= css::uno
;
56 namespace lang
= css::lang
;
57 namespace backenduno
= css::configuration::backend
;
60 Class implementing the Backend service for multibackend access.
61 It creates the required backends and coordinates access to them.
63 class MultiStratumBackend
: public cppu::WeakComponentImplHelper7
< backenduno::XBackend
, backenduno::XBackendEntities
, backenduno::XVersionedSchemaSupplier
, backenduno::XBackendChangesNotifier
, backenduno::XBackendChangesListener
, lang::XInitialization
, lang::XServiceInfo
> {
66 Service constructor from a service factory.
68 @param xContext component context
72 const uno::Reference
<uno::XComponentContext
>& xContext
) ;
74 ~MultiStratumBackend() ;
77 virtual void SAL_CALL
initialize(
78 const uno::Sequence
<uno::Any
>& aParameters
)
79 throw (uno::RuntimeException
, uno::Exception
,
80 css::configuration::InvalidBootstrapFileException
,
81 backenduno::BackendSetupException
) ;
83 // XVersionedSchemaSupplier
85 SAL_CALL
getSchemaVersion(const rtl::OUString
& aComponent
)
86 throw (backenduno::BackendAccessException
,
87 lang::IllegalArgumentException
,
88 uno::RuntimeException
) ;
91 virtual uno::Reference
<backenduno::XSchema
>
92 SAL_CALL
getComponentSchema(const rtl::OUString
& aComponent
)
93 throw (backenduno::BackendAccessException
,
94 lang::IllegalArgumentException
,
95 uno::RuntimeException
) ;
98 virtual uno::Sequence
<uno::Reference
<backenduno::XLayer
> >
99 SAL_CALL
listOwnLayers(const rtl::OUString
& aComponent
)
100 throw (backenduno::BackendAccessException
,
101 lang::IllegalArgumentException
,
102 uno::RuntimeException
) ;
104 virtual uno::Reference
<backenduno::XUpdateHandler
>
105 SAL_CALL
getOwnUpdateHandler(const rtl::OUString
& aComponent
)
106 throw (backenduno::BackendAccessException
,
107 lang::IllegalArgumentException
,
108 lang::NoSupportException
,
109 uno::RuntimeException
) ;
110 virtual uno::Sequence
<uno::Reference
<backenduno::XLayer
> > SAL_CALL
111 listLayers(const rtl::OUString
& aComponent
,
112 const rtl::OUString
& aEntity
)
113 throw (backenduno::BackendAccessException
,
114 lang::IllegalArgumentException
,
115 uno::RuntimeException
) ;
116 virtual uno::Reference
<backenduno::XUpdateHandler
> SAL_CALL
117 getUpdateHandler(const rtl::OUString
& aComponent
,
118 const rtl::OUString
& aEntity
)
119 throw (backenduno::BackendAccessException
,
120 lang::IllegalArgumentException
,
121 lang::NoSupportException
,
122 uno::RuntimeException
) ;
125 virtual rtl::OUString SAL_CALL
127 throw (uno::RuntimeException
);
129 virtual rtl::OUString SAL_CALL
131 throw (uno::RuntimeException
);
133 virtual sal_Bool SAL_CALL
134 supportsEntity( const rtl::OUString
& aEntity
)
135 throw (backenduno::BackendAccessException
, uno::RuntimeException
);
137 virtual sal_Bool SAL_CALL
138 isEqualEntity( const rtl::OUString
& aEntity
, const rtl::OUString
& aOtherEntity
)
139 throw ( backenduno::BackendAccessException
,
140 lang::IllegalArgumentException
,
141 uno::RuntimeException
);
144 virtual rtl::OUString SAL_CALL
getImplementationName()
145 throw (uno::RuntimeException
) ;
146 virtual sal_Bool SAL_CALL
supportsService(
147 const rtl::OUString
& aServiceName
)
148 throw (uno::RuntimeException
) ;
149 virtual uno::Sequence
<rtl::OUString
> SAL_CALL
150 getSupportedServiceNames(void) throw (uno::RuntimeException
) ;
152 // XBackendChangesNotifier
153 virtual void SAL_CALL
addChangesListener( const uno::Reference
<backenduno::XBackendChangesListener
>& xListner
,
154 const rtl::OUString
& aComponent
)
155 throw (::com::sun::star::uno::RuntimeException
);
158 virtual void SAL_CALL
removeChangesListener( const uno::Reference
<backenduno::XBackendChangesListener
>& xListner
,
159 const rtl::OUString
& aComponent
)
160 throw (::com::sun::star::uno::RuntimeException
);
162 // XBackendChangesListener
163 virtual void SAL_CALL
componentDataChanged(const backenduno::ComponentChangeEvent
& aEvent
)
164 throw (::com::sun::star::uno::RuntimeException
);
166 virtual void SAL_CALL
disposing( lang::EventObject
const & rSource
)
167 throw (uno::RuntimeException
);
169 void notifyListeners(const backenduno::ComponentChangeEvent
& aEvent
) const;
172 virtual void SAL_CALL
disposing();
174 /** Initialize the schema supplier backend
177 void initializeSchemaSupplier(const uno::Reference
<uno::XComponentContext
>& aContext
);
179 /** Initialize strata(SingleLayer or MultiLayer) backend
181 void initializeBackendStrata(const uno::Reference
<uno::XComponentContext
>& aContext
);
183 /** Get Layers from Backend Strata
185 uno::Sequence
<uno::Reference
<backenduno::XLayer
> >
186 searchSupportingStrata(sal_Int32 nNumLayer
,
187 rtl::OUString aEntity
,
188 const rtl::OUString
& aComponent
) ;
191 /** Find the Stratum that supports the specified Entity
192 * @return Number of Supported Strata
194 sal_Int32
findSupportingStratum(const rtl::OUString
& aEntity
) ;
198 Check state of MultiStratumBackend -
199 @return true if not disposed/uninitialized
202 /** Service factory */
203 uno::Reference
<lang::XMultiServiceFactory
> mFactory
;
204 /** Mutex for resource protection */
207 uno::Reference
<backenduno::XSchemaSupplier
> mSchemaSupplier
;
208 /** list of all backends */
209 std::vector
< uno::Reference
<uno::XInterface
> > mBackendStrata
;
211 rtl::OUString mOwnerEntity
;
213 /** Helper object that listens to the Strata Backends */
214 uno::Reference
<backenduno::XBackendChangesListener
> mStrataListener
;
215 /** List of higher level listeners */
216 typedef std::multimap
< rtl::OUString
, uno::Reference
<backenduno::XBackendChangesListener
> > ListenerList
;
217 ListenerList mListenerList
;
220 } } // configmgr.backend
222 #endif // CONFIGMGR_BACKEND_MULTISTRATUMBACKEND_HXX_