1 /*
2  * Copyright 2002-2018 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 module hunt.stomp.core.CachingDestinationResolverProxy;
18 
19 import hunt.collection.Map;
20 // import java.util.concurrent.ConcurrentHashMap;
21 
22 // import hunt.framework.beans.factory.InitializingBean;
23 
24 
25 
26 /**
27  * {@link DestinationResolver} implementation that proxies a target DestinationResolver,
28  * caching its {@link #resolveDestination} results. Such caching is particularly useful
29  * if the destination resolving process is expensive (e.g. the destination has to be
30  * resolved through an external system) and the resolution results are stable anyway.
31  *
32  * @author Agim Emruli
33  * @author Juergen Hoeller
34  * @since 4.1
35  * @param (T) the destination type
36  * @see DestinationResolver#resolveDestination
37  */
38 class CachingDestinationResolverProxy(T) : DestinationResolver!(T) { // , InitializingBean
39 
40 	// private final Map!(string, T) resolvedDestinationCache = new ConcurrentHashMap<>();
41 
42 	
43 	// private DestinationResolver!(T) targetDestinationResolver;
44 
45 
46 	// /**
47 	//  * Create a new CachingDestinationResolverProxy, setting the target DestinationResolver
48 	//  * through the {@link #setTargetDestinationResolver} bean property.
49 	//  */
50 	// this() {
51 	// }
52 
53 	// /**
54 	//  * Create a new CachingDestinationResolverProxy using the given target
55 	//  * DestinationResolver to actually resolve destinations.
56 	//  * @param targetDestinationResolver the target DestinationResolver to delegate to
57 	//  */
58 	// this(DestinationResolver!(T) targetDestinationResolver) {
59 	// 	assert(targetDestinationResolver, "Target DestinationResolver must not be null");
60 	// 	this.targetDestinationResolver = targetDestinationResolver;
61 	// }
62 
63 
64 	// /**
65 	//  * Set the target DestinationResolver to delegate to.
66 	//  */
67 	// void setTargetDestinationResolver(DestinationResolver!(T) targetDestinationResolver) {
68 	// 	this.targetDestinationResolver = targetDestinationResolver;
69 	// }
70 
71 	// override
72 	// void afterPropertiesSet() {
73 	// 	if (this.targetDestinationResolver is null) {
74 	// 		throw new IllegalArgumentException("Property 'targetDestinationResolver' is required");
75 	// 	}
76 	// }
77 
78 
79 	// /**
80 	//  * Resolves and caches destinations if successfully resolved by the target
81 	//  * DestinationResolver implementation.
82 	//  * @param name the destination name to be resolved
83 	//  * @return the currently resolved destination or an already cached destination
84 	//  * @throws DestinationResolutionException if the target DestinationResolver
85 	//  * reports an error during destination resolution
86 	//  */
87 	// override
88 	// T resolveDestination(string name) throws DestinationResolutionException {
89 	// 	T destination = this.resolvedDestinationCache.get(name);
90 	// 	if (destination is null) {
91 	// 		assert(this.targetDestinationResolver !is null, "No target DestinationResolver set");
92 	// 		destination = this.targetDestinationResolver.resolveDestination(name);
93 	// 		this.resolvedDestinationCache.put(name, destination);
94 	// 	}
95 	// 	return destination;
96 	// }
97 
98 }