com.shipdream.lib.poke.Provider Maven / Gradle / Ivy
/*
* Copyright 2015 Kejun Xia
*
* 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 com.shipdream.lib.poke;
import com.shipdream.lib.poke.exception.CircularDependenciesException;
import com.shipdream.lib.poke.exception.ProvideException;
import com.shipdream.lib.poke.exception.ProviderMissingException;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Provider controls the injection type mapping as well as the scope by associated
* {@link ScopeCache}.
*/
public abstract class Provider {
/**
* Listener monitoring when the provider is referenced for the first time
*/
public interface OnInjectedListener {
/**
* Called provider is first time used to inject its content. The call is guaranteed to be
* invoked after all injectable fields of its content is fully injected.
* @param object Who is fully injected
*/
void onInjected(T object);
}
/**
* Listener will be called when the given provider is not referenced by any objects. The
* listener will be called before its cached instance is freed if there is a cache associated.
*/
public interface OnFreedListener {
/**
* listener to be invoked when when the given provider is not referenced by any objects.
*
* @param provider The provider whose content is not referenced by any objects.
*/
void onFreed(Provider provider);
}
private final Class type;
ScopeCache scopeCache;
private Annotation qualifier;
private Map © 2015 - 2025 Weber Informatics LLC | Privacy Policy