X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=support%2Fcdi%2Fsrc%2Fmain%2Fjava%2Forg%2Fwamblee%2Finject%2FInjectorCache.java;fp=support%2Fcdi%2Fsrc%2Fmain%2Fjava%2Forg%2Fwamblee%2Finject%2FInjectorCache.java;h=0000000000000000000000000000000000000000;hb=31a079a01ae642f63c74521674d40bdf9c4ec298;hp=24a0f2c4969c5826b43aed6b2a975884aa418f26;hpb=1440f7475e4a7d3ae9e6e756b3a58572a57e9521;p=utils diff --git a/support/cdi/src/main/java/org/wamblee/inject/InjectorCache.java b/support/cdi/src/main/java/org/wamblee/inject/InjectorCache.java deleted file mode 100644 index 24a0f2c4..00000000 --- a/support/cdi/src/main/java/org/wamblee/inject/InjectorCache.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright 2005-2010 the original author or authors. - * - * 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.wamblee.inject; - -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -import org.wamblee.cdi.CdiInjector; - -/** - * Cache of {@link CdiInjector}s for efficiency to avoid duplicate analysis of a - * given class. - * - * @author Erik Brakkee - */ -public class InjectorCache { - - private Map injectors; - - private InjectorFactory injectorFactory; - - /** - * Constructs an empty cache. - * - * @param aMgr - * Bean manager. - */ - public InjectorCache(InjectorFactory aInjectorFactory) { - injectorFactory = aInjectorFactory; - injectors = new ConcurrentHashMap(); - } - - /** - * Gets the injector for a given class. This returns a cached injector or - * creates a new injector and caches it. - * - * @param aClass - * Class to find injector for. - * @return Injector. - */ - public Injector getInjector(Class aClass) { - Injector injector = injectors.get(aClass.getName()); - if (injector == null) { - // create and add injector - // NOTE: in rare circumstances this will lead to parallel - // creation of - // an injector for the same class. However, only one of them - // will be the final one - // in the map. There are no side effects of this duplicate - // creation of injectors. - injector = injectorFactory.create(aClass); - injectors.put(aClass.getName(), injector); - } - return injector; - } -}