// Path: src/main/java/org/spearal/SpearalContext.java
// public interface SpearalContext {
// 
// 	void configure(Configurable configurable);
// 	void configure(Configurable configurable, boolean append);
// 	
// 	Securizer getSecurizer();
// 	
// 	String alias(Class<?> cls);
// 	String unalias(String aliasedClassName);
// 	
// 	Class<?> loadClass(String classNames, Type target)
// 		throws SecurityException;
// 	Object newInstance(Class<?> cls);
// 	
// 	Property[] getProperties(Class<?> cls);
// 	
// 	Object instantiate(Type type, Object param)
// 		throws InstantiationException, IllegalAccessException;
// 	Object instantiate(Property property, Object param)
// 		throws InstantiationException, IllegalAccessException;
// 	Object instantiatePartial(Class<?> cls, Property[] partialProperties)
// 		throws InstantiationException, IllegalAccessException;
// 	
// 	Coder getCoder(Class<?> valueClass);
// 	
// 	String[] getUnfilterableProperties(Class<?> valueClass);
// 	
// 	Object convert(Object value, Type targetType);
// 	
// 	Property createProperty(String name, Field field, Method getter, Method setter);
// 	
// 	FilteredBeanDescriptor createDescriptor(SpearalPropertyFilter filter, Object value);
// }


import org.spearal.SpearalContext;
/**
 * == @Spearal ==>
 * 
 * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.spearal.impl.cache;


/**
 * @author Franck WOLFF
 */
public final class CopyOnWriteDualIdentityMap<K1, K2, V> {

	protected volatile DualIdentityMap<K1, K2, V> map;
	
	public CopyOnWriteDualIdentityMap(DualIdentityMap.ValueProvider<K1, K2, V> provider) {
		this.map = new DualIdentityMap<K1, K2, V>(provider, 1);
	}
	
	public V get(K1 key1, K2 key2) {
		return get().get(key1, key2);
	}
	
// Path: src/main/java/org/spearal/SpearalContext.java
// public interface SpearalContext {
// 
// 	void configure(Configurable configurable);
// 	void configure(Configurable configurable, boolean append);
// 	
// 	Securizer getSecurizer();
// 	
// 	String alias(Class<?> cls);
// 	String unalias(String aliasedClassName);
// 	
// 	Class<?> loadClass(String classNames, Type target)
// 		throws SecurityException;
// 	Object newInstance(Class<?> cls);
// 	
// 	Property[] getProperties(Class<?> cls);
// 	
// 	Object instantiate(Type type, Object param)
// 		throws InstantiationException, IllegalAccessException;
// 	Object instantiate(Property property, Object param)
// 		throws InstantiationException, IllegalAccessException;
// 	Object instantiatePartial(Class<?> cls, Property[] partialProperties)
// 		throws InstantiationException, IllegalAccessException;
// 	
// 	Coder getCoder(Class<?> valueClass);
// 	
// 	String[] getUnfilterableProperties(Class<?> valueClass);
// 	
// 	Object convert(Object value, Type targetType);
// 	
// 	Property createProperty(String name, Field field, Method getter, Method setter);
// 	
// 	FilteredBeanDescriptor createDescriptor(SpearalPropertyFilter filter, Object value);
// }


// Path: src/main/java/org/spearal/impl/cache/CopyOnWriteDualIdentityMap.java
import org.spearal.SpearalContext;

/**
 * == @Spearal ==>
 * 
 * Copyright (C) 2014 Franck WOLFF & William DRAI (http://www.spearal.io)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.spearal.impl.cache;


/**
 * @author Franck WOLFF
 */
public final class CopyOnWriteDualIdentityMap<K1, K2, V> {

	protected volatile DualIdentityMap<K1, K2, V> map;
	
	public CopyOnWriteDualIdentityMap(DualIdentityMap.ValueProvider<K1, K2, V> provider) {
		this.map = new DualIdentityMap<K1, K2, V>(provider, 1);
	}
	
	public V get(K1 key1, K2 key2) {
		return get().get(key1, key2);
	}
	
	public synchronized V putIfAbsent(SpearalContext context, K1 key1, K2 key2) {