4444 return CloudcosxmlService;
4545}
4646@implementation QCloudCOSXMLService
47- @synthesize sessionManager = _sessionManager;
4847static QCloudCOSXMLService *COSXMLService = nil ;
4948
5049+ (QCloudCOSXMLService *)defaultCOSXML {
@@ -58,13 +57,6 @@ + (QCloudCOSXMLService *)defaultCOSXML {
5857
5958+ (QCloudCOSXMLService *)registerDefaultCOSXMLWithConfiguration : (QCloudServiceConfiguration *)configuration {
6059 @synchronized (self) {
61- if (COSXMLService) {
62- @throw [NSException
63- exceptionWithName: QCloudErrorDomain
64- reason: [NSString stringWithFormat:
65- @" 默认的COSXMLService已存在,如有新的配置,请通过 registerCOSXMLWithConfiguration:withKey:重新注册" ]
66- userInfo: nil ];
67- }
6860 COSXMLService = [[QCloudCOSXMLService alloc ] initWithConfiguration: configuration];
6961 if (!configuration.isCloseShareLog ) {
7062#if TARGET_OS_IOS
@@ -85,20 +77,8 @@ + (QCloudCOSXMLService *)cosxmlServiceForKey:(NSString *)key {
8577 return cosxmlService;
8678}
8779
88- + (void )removeCOSXMLWithKey : (NSString *)key {
89- [QCloudCOSXMLServiceCache () removeObjectForKey: key];
90- }
91-
9280+ (QCloudCOSXMLService *)registerCOSXMLWithConfiguration : (QCloudServiceConfiguration *)configuration withKey : (NSString *)key ;
9381{
94- if ([self hasServiceForKey: key]) {
95- @throw [NSException
96- exceptionWithName: QCloudErrorDomain
97- reason: [NSString
98- stringWithFormat:
99- @" key: %@ COSXMLService已存在,如有新的配置,请通过 registerCOSXMLWithConfiguration:withKey:重新注册" , key]
100- userInfo: nil ];
101- }
10282 QCloudCOSXMLService *cosxmlService = [[QCloudCOSXMLService alloc ] initWithConfiguration: configuration];
10383 [QCloudCOSXMLServiceCache () setObject: cosxmlService forKey: key];
10484 return cosxmlService;
@@ -133,12 +113,22 @@ - (NSString *)getURLWithBucket:(NSString *)bucket
133113 return [resultURL copy ];
134114}
135115
136- + (BOOL )hasServiceForKey : (NSString *)key {
116+ + (BOOL )hasCosxmlServiceForKey : (NSString *)key {
137117 if (nil == [QCloudCOSXMLServiceCache () objectForKey: key]) {
138118 return NO ;
139119 } else {
140120 return YES ;
141121 }
142122}
123+ + (BOOL )hasServiceForKey : (NSString *)key {
124+ return [QCloudCOSXMLService hasCosxmlServiceForKey: key];
125+ }
126+
127+ + (void )removeCosxmlServiceWithKey : (NSString *)key {
128+ [QCloudCOSXMLServiceCache () removeObjectForKey: key];
129+ }
130+ + (void )removeCOSXMLWithKey : (NSString *)key {
131+ [self removeCosxmlServiceWithKey: key];
132+ }
143133
144134@end
0 commit comments