Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 :
21 : #include <cacheddynamicresultset.hxx>
22 : #include <com/sun/star/sdbc/XResultSet.hpp>
23 : #include <cachedcontentresultset.hxx>
24 : #include <osl/diagnose.h>
25 : #include <comphelper/processfactory.hxx>
26 :
27 : using namespace com::sun::star::lang;
28 : using namespace com::sun::star::sdbc;
29 : using namespace com::sun::star::ucb;
30 : using namespace com::sun::star::uno;
31 :
32 : using ::rtl::OUString;
33 :
34 0 : CachedDynamicResultSet::CachedDynamicResultSet(
35 : Reference< XDynamicResultSet > xOrigin
36 : , const Reference< XContentIdentifierMapping > & xContentMapping
37 : , const Reference< XMultiServiceFactory > & xSMgr )
38 : : DynamicResultSetWrapper( xOrigin, comphelper::getComponentContext(xSMgr) )
39 0 : , m_xContentIdentifierMapping( xContentMapping )
40 : {
41 0 : impl_init();
42 0 : }
43 :
44 0 : CachedDynamicResultSet::~CachedDynamicResultSet()
45 : {
46 0 : impl_deinit();
47 0 : }
48 :
49 : //virtual
50 0 : void SAL_CALL CachedDynamicResultSet
51 : ::impl_InitResultSetOne( const Reference< XResultSet >& xResultSet )
52 : {
53 0 : DynamicResultSetWrapper::impl_InitResultSetOne( xResultSet );
54 : OSL_ENSURE( m_xSourceResultOne.is(), "need source resultset" );
55 :
56 : Reference< XResultSet > xCache(
57 0 : new CachedContentResultSet( m_xContext, m_xSourceResultOne, m_xContentIdentifierMapping ) );
58 :
59 0 : osl::Guard< osl::Mutex > aGuard( m_aMutex );
60 0 : m_xMyResultOne = xCache;
61 0 : }
62 :
63 : //virtual
64 0 : void SAL_CALL CachedDynamicResultSet
65 : ::impl_InitResultSetTwo( const Reference< XResultSet >& xResultSet )
66 : {
67 0 : DynamicResultSetWrapper::impl_InitResultSetTwo( xResultSet );
68 : OSL_ENSURE( m_xSourceResultTwo.is(), "need source resultset" );
69 :
70 : Reference< XResultSet > xCache(
71 0 : new CachedContentResultSet( m_xContext, m_xSourceResultTwo, m_xContentIdentifierMapping ) );
72 :
73 0 : osl::Guard< osl::Mutex > aGuard( m_aMutex );
74 0 : m_xMyResultTwo = xCache;
75 0 : }
76 :
77 : //--------------------------------------------------------------------------
78 : // XInterface methods.
79 : //--------------------------------------------------------------------------
80 0 : XINTERFACE_COMMON_IMPL( CachedDynamicResultSet )
81 :
82 0 : Any SAL_CALL CachedDynamicResultSet
83 : ::queryInterface( const Type& rType )
84 : throw ( RuntimeException )
85 : {
86 : //list all interfaces inclusive baseclasses of interfaces
87 :
88 0 : Any aRet = DynamicResultSetWrapper::queryInterface( rType );
89 0 : if( aRet.hasValue() )
90 0 : return aRet;
91 :
92 : aRet = cppu::queryInterface( rType,
93 : static_cast< XTypeProvider* >( this )
94 : , static_cast< XServiceInfo* >( this )
95 0 : );
96 0 : return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
97 : }
98 :
99 : //--------------------------------------------------------------------------
100 : // XTypeProvider methods.
101 : //--------------------------------------------------------------------------
102 : //list all interfaces exclusive baseclasses
103 0 : XTYPEPROVIDER_IMPL_4( CachedDynamicResultSet
104 : , XTypeProvider
105 : , XServiceInfo
106 : , XDynamicResultSet
107 : , XSourceInitialization
108 : );
109 :
110 : //--------------------------------------------------------------------------
111 : // XServiceInfo methods.
112 : //--------------------------------------------------------------------------
113 :
114 0 : XSERVICEINFO_NOFACTORY_IMPL_1( CachedDynamicResultSet,
115 : OUString( "com.sun.star.comp.ucb.CachedDynamicResultSet" ),
116 : OUString( CACHED_DRS_SERVICE_NAME ) );
117 :
118 : //--------------------------------------------------------------------------
119 : // own methds. ( inherited )
120 : //--------------------------------------------------------------------------
121 : //virtual
122 0 : void SAL_CALL CachedDynamicResultSet
123 : ::impl_disposing( const EventObject& Source )
124 : throw( RuntimeException )
125 : {
126 0 : DynamicResultSetWrapper::impl_disposing( Source );
127 0 : m_xContentIdentifierMapping.clear();
128 0 : }
129 :
130 : //--------------------------------------------------------------------------
131 : //--------------------------------------------------------------------------
132 : // class CachedDynamicResultSetFactory
133 : //--------------------------------------------------------------------------
134 : //--------------------------------------------------------------------------
135 :
136 0 : CachedDynamicResultSetFactory::CachedDynamicResultSetFactory(
137 0 : const Reference< XMultiServiceFactory > & rSMgr )
138 : {
139 0 : m_xSMgr = rSMgr;
140 0 : }
141 :
142 0 : CachedDynamicResultSetFactory::~CachedDynamicResultSetFactory()
143 : {
144 0 : }
145 :
146 : //--------------------------------------------------------------------------
147 : // CachedDynamicResultSetFactory XInterface methods.
148 : //--------------------------------------------------------------------------
149 :
150 0 : XINTERFACE_IMPL_3( CachedDynamicResultSetFactory,
151 : XTypeProvider,
152 : XServiceInfo,
153 : XCachedDynamicResultSetFactory );
154 :
155 : //--------------------------------------------------------------------------
156 : // CachedDynamicResultSetFactory XTypeProvider methods.
157 : //--------------------------------------------------------------------------
158 :
159 0 : XTYPEPROVIDER_IMPL_3( CachedDynamicResultSetFactory,
160 : XTypeProvider,
161 : XServiceInfo,
162 : XCachedDynamicResultSetFactory );
163 :
164 : //--------------------------------------------------------------------------
165 : // CachedDynamicResultSetFactory XServiceInfo methods.
166 : //--------------------------------------------------------------------------
167 :
168 0 : XSERVICEINFO_IMPL_1( CachedDynamicResultSetFactory,
169 : OUString( "com.sun.star.comp.ucb.CachedDynamicResultSetFactory" ),
170 0 : OUString( CACHED_DRS_FACTORY_NAME ) );
171 :
172 : //--------------------------------------------------------------------------
173 : // Service factory implementation.
174 : //--------------------------------------------------------------------------
175 :
176 0 : ONE_INSTANCE_SERVICE_FACTORY_IMPL( CachedDynamicResultSetFactory );
177 :
178 : //--------------------------------------------------------------------------
179 : // CachedDynamicResultSetFactory XCachedDynamicResultSetFactory methods.
180 : //--------------------------------------------------------------------------
181 :
182 : //virtual
183 0 : Reference< XDynamicResultSet > SAL_CALL CachedDynamicResultSetFactory
184 : ::createCachedDynamicResultSet(
185 : const Reference< XDynamicResultSet > & SourceStub
186 : , const Reference< XContentIdentifierMapping > & ContentIdentifierMapping )
187 : throw( RuntimeException )
188 : {
189 0 : Reference< XDynamicResultSet > xRet;
190 0 : xRet = new CachedDynamicResultSet( SourceStub, ContentIdentifierMapping, m_xSMgr );
191 0 : return xRet;
192 : }
193 :
194 :
195 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|