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 INCLUDED_BINARYURP_SOURCE_BRIDGEFACTORY_HXX 25 #define INCLUDED_BINARYURP_SOURCE_BRIDGEFACTORY_HXX 26 27 #include "sal/config.h" 28 29 #include <list> 30 #include <map> 31 32 #include "boost/noncopyable.hpp" 33 #include "com/sun/star/bridge/XBridgeFactory.hpp" 34 #include "com/sun/star/lang/XServiceInfo.hpp" 35 #include "com/sun/star/uno/Exception.hpp" 36 #include "com/sun/star/uno/Reference.hxx" 37 #include "com/sun/star/uno/RuntimeException.hpp" 38 #include "cppuhelper/compbase2.hxx" 39 #include "sal/types.h" 40 41 namespace com { namespace sun { namespace star { 42 namespace connection { class XConnection; } 43 namespace uno { 44 class XComponentContext; 45 class XInterface; 46 } 47 } } } 48 49 namespace binaryurp { 50 51 // That BridgeFactory derives from XComponent appears to be a historic mistake; 52 // the implementation does not care about a disposed state: 53 54 typedef 55 cppu::WeakComponentImplHelper2< 56 com::sun::star::lang::XServiceInfo, 57 com::sun::star::bridge::XBridgeFactory > 58 BridgeFactoryBase; 59 60 class BridgeFactory: 61 private osl::Mutex, public BridgeFactoryBase, private boost::noncopyable 62 { 63 public: 64 static com::sun::star::uno::Reference< com::sun::star::uno::XInterface > 65 SAL_CALL static_create( 66 com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > 67 const & xContext) 68 SAL_THROW((com::sun::star::uno::Exception)); 69 70 static rtl::OUString SAL_CALL static_getImplementationName(); 71 72 static com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL 73 static_getSupportedServiceNames(); 74 75 void removeBridge( 76 com::sun::star::uno::Reference< com::sun::star::bridge::XBridge > 77 const & bridge); 78 79 using BridgeFactoryBase::acquire; 80 using BridgeFactoryBase::release; 81 82 private: 83 explicit BridgeFactory( 84 com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > 85 const & context); 86 87 virtual ~BridgeFactory(); 88 89 virtual rtl::OUString SAL_CALL getImplementationName() 90 throw (com::sun::star::uno::RuntimeException); 91 92 virtual sal_Bool SAL_CALL supportsService(rtl::OUString const & ServiceName) 93 throw (com::sun::star::uno::RuntimeException); 94 95 virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL 96 getSupportedServiceNames() throw (com::sun::star::uno::RuntimeException); 97 98 virtual com::sun::star::uno::Reference< com::sun::star::bridge::XBridge > 99 SAL_CALL createBridge( 100 rtl::OUString const & sName, rtl::OUString const & sProtocol, 101 com::sun::star::uno::Reference< 102 com::sun::star::connection::XConnection > const & aConnection, 103 com::sun::star::uno::Reference< 104 com::sun::star::bridge::XInstanceProvider > const & 105 anInstanceProvider) 106 throw ( 107 com::sun::star::bridge::BridgeExistsException, 108 com::sun::star::lang::IllegalArgumentException, 109 com::sun::star::uno::RuntimeException); 110 111 virtual com::sun::star::uno::Reference< com::sun::star::bridge::XBridge > 112 SAL_CALL getBridge( 113 rtl::OUString const & sName) 114 throw (com::sun::star::uno::RuntimeException); 115 116 virtual 117 com::sun::star::uno::Sequence< 118 com::sun::star::uno::Reference< com::sun::star::bridge::XBridge > > 119 SAL_CALL getExistingBridges() throw (com::sun::star::uno::RuntimeException); 120 121 typedef 122 std::list< 123 com::sun::star::uno::Reference< com::sun::star::bridge::XBridge > > 124 BridgeList; 125 126 typedef 127 std::map< 128 rtl::OUString, 129 com::sun::star::uno::Reference< com::sun::star::bridge::XBridge > > 130 BridgeMap; 131 132 com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > 133 context_; 134 BridgeList unnamed_; 135 BridgeMap named_; 136 }; 137 138 } 139 140 #endif 141