diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2012-09-14 18:08:57 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2012-09-14 18:24:49 +0200 |
commit | 9ac86f484b0c278aafbce685ed19d3ea005ee8f8 (patch) | |
tree | cf2fe16d76992bcbd1bd89a8693c5f4996cd55f2 /ucb | |
parent | 2e284203da7f9882842111265f5f68ea0a145065 (diff) |
Improvement on previous commit, UCB clean up
* As UCB is only ever initialized with "Local"/"Office", remove this
configuration vector completely. The "create" ctor creates an instance
internally initialized with those "Local"/"Office" keys. Special (test) code
can still instantiate an uninitialized one via plain createInstance. And for
backwards compatilibity process startup still ensures to create an initialized
instance early, in case there is still code out there (in extensions) that
later calls plain createInstance and expects to get the already-initialized
(single) instance.
* XInitialization is an "implementation detail" of the UniversalContentBroker
service, do not expose in XUniversalContentBroker.
* ucbhelper/configurationkeys.hxx is no longer needed and is removed.
* ucbhelper/contentbroker.hxx is an empty wrapper and is removed; however, that
requires ucbhelper::Content constructors to take explicit XComponentContext
arguments now.
* The only remaining code in ucbhelper/source/client/contentbroker.cxx is
Android-only InitUCBHelper. Is that relevant still?
Change-Id: I3f7bddd0456bffbcd13590c66d9011915c760f28
Diffstat (limited to 'ucb')
-rw-r--r-- | ucb/Library_ucpftp1.mk | 1 | ||||
-rw-r--r-- | ucb/qa/complex/tdoc/CheckContentProvider.java | 8 | ||||
-rw-r--r-- | ucb/qa/complex/tdoc/CheckTransientDocumentsContent.java | 2 | ||||
-rw-r--r-- | ucb/qa/complex/tdoc/CheckTransientDocumentsContentProvider.java | 2 | ||||
-rw-r--r-- | ucb/qa/complex/ucb/UCB.java | 28 | ||||
-rw-r--r-- | ucb/source/core/ucb.cxx | 39 | ||||
-rw-r--r-- | ucb/source/core/ucb.hxx | 1 | ||||
-rw-r--r-- | ucb/source/ucp/expand/ucpexpand.cxx | 5 | ||||
-rw-r--r-- | ucb/source/ucp/ext/ucpext_content.cxx | 4 | ||||
-rw-r--r-- | ucb/source/ucp/ext/ucpext_datasupplier.cxx | 2 | ||||
-rw-r--r-- | ucb/source/ucp/ftp/ftpcontentprovider.cxx | 24 | ||||
-rw-r--r-- | ucb/test/com/sun/star/comp/ucb/GlobalTransfer_Test.java | 1 |
12 files changed, 56 insertions, 61 deletions
diff --git a/ucb/Library_ucpftp1.mk b/ucb/Library_ucpftp1.mk index 69e938ce9d8d..e588649e2f30 100644 --- a/ucb/Library_ucpftp1.mk +++ b/ucb/Library_ucpftp1.mk @@ -32,6 +32,7 @@ $(eval $(call gb_Library_set_componentfile,ucpftp1,ucb/source/ucp/ftp/ucpftp1)) $(eval $(call gb_Library_use_sdk_api,ucpftp1)) $(eval $(call gb_Library_use_libraries,ucpftp1,\ + comphelper \ cppu \ cppuhelper \ sal \ diff --git a/ucb/qa/complex/tdoc/CheckContentProvider.java b/ucb/qa/complex/tdoc/CheckContentProvider.java index b41f04e656d3..7e82ba795a08 100644 --- a/ucb/qa/complex/tdoc/CheckContentProvider.java +++ b/ucb/qa/complex/tdoc/CheckContentProvider.java @@ -122,7 +122,7 @@ public class CheckContentProvider { XContentProvider xContentProvider = UnoRuntime.queryInterface(XContentProvider.class, o); - // create the ucb + // create unconfigured ucb XContentIdentifierFactory xContentIdentifierFactory = UnoRuntime.queryInterface(XContentIdentifierFactory.class, xMSF.createInstance("com.sun.star.ucb.UniversalContentBroker")); // create a content identifier from the ucb for tdoc @@ -185,7 +185,7 @@ public class CheckContentProvider { Object o = xMSF.createInstance("com.sun.star.comp.ucb.TransientDocumentsContentProvider"); XContentProvider xContentProvider = UnoRuntime.queryInterface(XContentProvider.class, o); - // create the ucb + // create unconfigured ucb XContentIdentifierFactory xContentIdentifierFactory = UnoRuntime.queryInterface(XContentIdentifierFactory.class, xMSF.createInstance("com.sun.star.ucb.UniversalContentBroker")); // create a content identifier from the ucb for tdoc @@ -220,7 +220,7 @@ public class CheckContentProvider { Object o = xMSF.createInstance("com.sun.star.comp.ucb.TransientDocumentsContentProvider"); XContentProvider xContentProvider = UnoRuntime.queryInterface(XContentProvider.class, o); - // create the ucb + // create unconfigured ucb XContentIdentifierFactory xContentIdentifierFactory = UnoRuntime.queryInterface(XContentIdentifierFactory.class, xMSF.createInstance("com.sun.star.ucb.UniversalContentBroker")); // create a content identifier from the ucb for tdoc @@ -255,7 +255,7 @@ public class CheckContentProvider { XContentProvider xContentProvider = UnoRuntime.queryInterface(XContentProvider.class, o); - // create the ucb + // create unconfigured ucb XContentIdentifierFactory xContentIdentifierFactory = UnoRuntime.queryInterface(XContentIdentifierFactory.class, xMSF.createInstance("com.sun.star.ucb.UniversalContentBroker")); // create a content identifier from the ucb for tdoc diff --git a/ucb/qa/complex/tdoc/CheckTransientDocumentsContent.java b/ucb/qa/complex/tdoc/CheckTransientDocumentsContent.java index 2898792eca18..7ad0dc07e59a 100644 --- a/ucb/qa/complex/tdoc/CheckTransientDocumentsContent.java +++ b/ucb/qa/complex/tdoc/CheckTransientDocumentsContent.java @@ -74,7 +74,7 @@ public class CheckTransientDocumentsContent { */ @Test public void checkTransientDocumentsContent() { try { - // create the ucb + // create unconfigured ucb XContentIdentifierFactory xContentIdentifierFactory = UnoRuntime.queryInterface(XContentIdentifierFactory.class, xMSF.createInstance("com.sun.star.ucb.UniversalContentBroker")); XContentProvider xContentProvider = diff --git a/ucb/qa/complex/tdoc/CheckTransientDocumentsContentProvider.java b/ucb/qa/complex/tdoc/CheckTransientDocumentsContentProvider.java index 29059e0ce3d1..6697709180c2 100644 --- a/ucb/qa/complex/tdoc/CheckTransientDocumentsContentProvider.java +++ b/ucb/qa/complex/tdoc/CheckTransientDocumentsContentProvider.java @@ -85,7 +85,7 @@ public class CheckTransientDocumentsContentProvider { XContentProvider xContentProvider = UnoRuntime.queryInterface(XContentProvider.class, o); - // create the ucb + // create unconfigured ucb XContentIdentifierFactory xContentIdentifierFactory = UnoRuntime.queryInterface(XContentIdentifierFactory.class, xMSF.createInstance("com.sun.star.ucb.UniversalContentBroker")); // create a content identifier from the ucb for tdoc diff --git a/ucb/qa/complex/ucb/UCB.java b/ucb/qa/complex/ucb/UCB.java index 95cc501b5270..2296b7530037 100644 --- a/ucb/qa/complex/ucb/UCB.java +++ b/ucb/qa/complex/ucb/UCB.java @@ -29,7 +29,6 @@ import java.util.List; import java.util.ArrayList; import com.sun.star.beans.Property; -import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.sdbc.XResultSet; import com.sun.star.sdbc.XRow; // import com.sun.star.uno.XComponentContext; @@ -54,20 +53,14 @@ import static org.junit.Assert.*; * It should be always: dir,filename. */ public class UCB { - private Object ucb; + private XUniversalContentBroker ucb; // public String[] getTestMethodNames() { // return new String[] {"checkWrongFtpConnection"}; // } - public void init(XMultiServiceFactory xmsf) throws Exception { - String[] keys = new String[2]; - keys[0] = "Local"; - keys[1] = "Office"; - ucb = - xmsf.createInstanceWithArguments( - "com.sun.star.ucb.UniversalContentBroker", - keys); + public void init() throws Exception { + ucb = UniversalContentBroker.create(connection.getComponentContext()); } public void delete(String filename) throws Exception { @@ -193,8 +186,8 @@ public class UCB { public Object getContent(String path) throws Exception { - XContentIdentifier id = (UnoRuntime.queryInterface(XContentIdentifierFactory.class, ucb)).createContentIdentifier(path); - return (UnoRuntime.queryInterface(XContentProvider.class, ucb)).queryContent(id); + XContentIdentifier id = ucb.createContentIdentifier(path); + return ucb.queryContent(id); } public static interface Verifier { @@ -204,10 +197,9 @@ public class UCB { @Test public void checkWrongFtpConnection() { //localhost ;Lo-1.Germany.sun.com; 10.16.65.155 try { - XMultiServiceFactory xLocMSF = getMSF(); String acountUrl = "ftp://noname:nopasswd@nohost"; System.out.println(acountUrl); - init(xLocMSF); + init(); Object content = getContent(acountUrl); OpenCommandArgument2 aArg = new OpenCommandArgument2(); @@ -232,14 +224,6 @@ public class UCB { // System.exit(0); } - - - private XMultiServiceFactory getMSF() - { - final XMultiServiceFactory xMSF1 = UnoRuntime.queryInterface(XMultiServiceFactory.class, connection.getComponentContext().getServiceManager()); - return xMSF1; - } - // setup and close connections @BeforeClass public static void setUpConnection() throws Exception { System.out.println("setUpConnection()"); diff --git a/ucb/source/core/ucb.cxx b/ucb/source/core/ucb.cxx index 4d454c2e4f30..c3ad4337460f 100644 --- a/ucb/source/core/ucb.cxx +++ b/ucb/source/core/ucb.cxx @@ -372,17 +372,34 @@ void SAL_CALL UniversalContentBroker::initialize( throw( com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException ) { - //@@@ At the moment, there's a problem when one (non-one-instance) factory - // 'wraps' another (one-instance) factory, causing this method to be - // called several times: - m_aArguments = aArguments; - - oslInterlockedCount nCount = osl_incrementInterlockedCount(&m_nInitCount); - if (nCount == 1) - configureUcb(); - else - osl_decrementInterlockedCount(&m_nInitCount); - // make the possibility of overflow less likely... + { + osl::MutexGuard aGuard(m_aMutex); + if (m_aArguments.getLength() != 0) + { + if (aArguments.getLength() != 0 + && !(m_aArguments.getLength() == 2 + && aArguments.getLength() == 2 + && m_aArguments[0] == aArguments[0] + && m_aArguments[1] == aArguments[1])) + { + throw IllegalArgumentException( + "UCB reinitialized with different arguments", + static_cast< cppu::OWeakObject * >(this), 0); + } + return; + } + if (aArguments.getLength() == 0) + { + m_aArguments.realloc(2); + m_aArguments[0] <<= OUString("Local"); + m_aArguments[1] <<= OUString("Office"); + } + else + { + m_aArguments = aArguments; + } + } + configureUcb(); } //========================================================================= diff --git a/ucb/source/core/ucb.hxx b/ucb/source/core/ucb.hxx index f12386fe94ab..8cd61e413f0a 100644 --- a/ucb/source/core/ucb.hxx +++ b/ucb/source/core/ucb.hxx @@ -57,6 +57,7 @@ class UniversalContentBroker : public com::sun::star::ucb::XUniversalContentBroker, public com::sun::star::lang::XTypeProvider, public com::sun::star::lang::XServiceInfo, + public com::sun::star::lang::XInitialization, public com::sun::star::util::XChangesListener { public: diff --git a/ucb/source/ucp/expand/ucpexpand.cxx b/ucb/source/ucp/expand/ucpexpand.cxx index 3f75376e1249..4e2aadef6843 100644 --- a/ucb/source/ucp/expand/ucpexpand.cxx +++ b/ucb/source/ucp/expand/ucpexpand.cxx @@ -63,6 +63,7 @@ typedef ::cppu::WeakComponentImplHelper2< //============================================================================== class ExpandContentProviderImpl : protected MutexHolder, public t_impl_helper { + uno::Reference< uno::XComponentContext > m_xComponentContext; uno::Reference< util::XMacroExpander > m_xMacroExpander; OUString expandUri( uno::Reference< ucb::XContentIdentifier > const & xIdentifier ) const; @@ -75,6 +76,7 @@ public: inline ExpandContentProviderImpl( uno::Reference< uno::XComponentContext > const & xComponentContext ) : t_impl_helper( m_mutex ), + m_xComponentContext( xComponentContext ), m_xMacroExpander( xComponentContext->getValueByName( OUSTR("/singletons/com.sun.star.util.theMacroExpander") ), @@ -216,7 +218,8 @@ uno::Reference< ucb::XContent > ExpandContentProviderImpl::queryContent( ::ucbhelper::Content ucb_content; if (::ucbhelper::Content::create( - uri, uno::Reference< ucb::XCommandEnvironment >(), ucb_content )) + uri, uno::Reference< ucb::XCommandEnvironment >(), + m_xComponentContext, ucb_content )) { return ucb_content.get(); } diff --git a/ucb/source/ucp/ext/ucpext_content.cxx b/ucb/source/ucp/ext/ucpext_content.cxx index 6e47cad61aa9..290a49570c6d 100644 --- a/ucb/source/ucp/ext/ucpext_content.cxx +++ b/ucb/source/ucp/ext/ucpext_content.cxx @@ -286,7 +286,7 @@ namespace ucb { namespace ucp { namespace ext if ( aOpenCommand.Sink.is() ) { const ::rtl::OUString sPhysicalContentURL( getPhysicalURL() ); - ::ucbhelper::Content aRequestedContent( sPhysicalContentURL, i_rEvironment ); + ::ucbhelper::Content aRequestedContent( sPhysicalContentURL, i_rEvironment, comphelper::ComponentContext(m_xSMgr).getUNOContext() ); aRet = aRequestedContent.executeCommand( ::rtl::OUString( "open" ), makeAny( aOpenCommand ) ); } } @@ -502,7 +502,7 @@ namespace ucb { namespace ucp { namespace ext case E_EXTENSION_CONTENT: { const ::rtl::OUString sPhysicalContentURL( getPhysicalURL() ); - ::ucbhelper::Content aRequestedContent( sPhysicalContentURL, i_rEnv ); + ::ucbhelper::Content aRequestedContent( sPhysicalContentURL, i_rEnv, comphelper::ComponentContext(m_xSMgr).getUNOContext() ); // translate the property request Sequence< ::rtl::OUString > aPropertyNames( i_rProperties.getLength() ); diff --git a/ucb/source/ucp/ext/ucpext_datasupplier.cxx b/ucb/source/ucp/ext/ucpext_datasupplier.cxx index 29356a7e68e5..aec7058c1f24 100644 --- a/ucb/source/ucp/ext/ucpext_datasupplier.cxx +++ b/ucb/source/ucp/ext/ucpext_datasupplier.cxx @@ -178,7 +178,7 @@ namespace ucb { namespace ucp { namespace ext case E_EXTENSION_CONTENT: { const ::rtl::OUString sPackageLocation( m_pImpl->m_xContent->getPhysicalURL() ); - ::ucbhelper::Content aWrappedContent( sPackageLocation, getResultSet()->getEnvironment() ); + ::ucbhelper::Content aWrappedContent( sPackageLocation, getResultSet()->getEnvironment(), comphelper::ComponentContext(m_pImpl->m_xSMgr).getUNOContext() ); // obtain the properties which our result set is set up for from the wrapped content Sequence< ::rtl::OUString > aPropertyNames(1); diff --git a/ucb/source/ucp/ftp/ftpcontentprovider.cxx b/ucb/source/ucp/ftp/ftpcontentprovider.cxx index a7b281129e62..7d9db3d8b582 100644 --- a/ucb/source/ucp/ftp/ftpcontentprovider.cxx +++ b/ucb/source/ucp/ftp/ftpcontentprovider.cxx @@ -33,7 +33,8 @@ *************************************************************************/ -#include <ucbhelper/contentbroker.hxx> +#include <com/sun/star/ucb/UniversalContentBroker.hpp> +#include <comphelper/componentcontext.hxx> #include <osl/socket.hxx> #include "ftpcontentprovider.hxx" #include "ftpcontent.hxx" @@ -258,23 +259,10 @@ FTPContentProvider::getHttpProvider() throw(RuntimeException) { // used for access to ftp-proxy - ucbhelper::ContentBroker *pBroker = ucbhelper::ContentBroker::get(); - - if(pBroker) { - Reference<XContentProviderManager > xManager( - pBroker->getContentProviderManagerInterface()); - - if(xManager.is()) - return - xManager->queryContentProvider( - rtl::OUString("http:")); - else - throw RuntimeException( - rtl::OUString( "bad ucbhelper::ContentBroker"), - *this); - } else - return 0; - + return + UniversalContentBroker::create( + comphelper::ComponentContext(m_xSMgr).getUNOContext())-> + queryContentProvider("http:"); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/ucb/test/com/sun/star/comp/ucb/GlobalTransfer_Test.java b/ucb/test/com/sun/star/comp/ucb/GlobalTransfer_Test.java index 7017bec2ed25..a84516e0f4a4 100644 --- a/ucb/test/com/sun/star/comp/ucb/GlobalTransfer_Test.java +++ b/ucb/test/com/sun/star/comp/ucb/GlobalTransfer_Test.java @@ -64,6 +64,7 @@ public final class GlobalTransfer_Test extends ComplexTestCase { XMultiServiceFactory xMSF = (XMultiServiceFactory)param.getMSF(); oObj = xMSF.createInstance( "com.sun.star.ucb.UniversalContentBroker" ); + // unconfigured instance } catch(com.sun.star.uno.Exception e) { e.printStackTrace((PrintWriter)log); |