All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.pustike.inject.bind.ScopedBindingBuilder Maven / Gradle / Ivy

There is a newer version: 2.0.0
Show newest version
/*
 * Copyright (C) 2016-2017 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 io.github.pustike.inject.bind;

import java.lang.annotation.Annotation;

import io.github.pustike.inject.Injector;
import io.github.pustike.inject.Scope;

/**
 * A binding builder, which allows to specify the scope of binding.
 * @see javax.inject.Scope
 * @see javax.inject.Singleton
 */
public interface ScopedBindingBuilder {
    /**
     * Instances of this binding are created in the specified scope which should be already registered to the binder.
     * By default, the Singleton scope is registered to the binder.
     * For ex: 
{@code bind(Service.class).to(ServiceImpl.class).in(Singleton.class); }
* Or *
{@code
     * ThreadScope threadScope = new ThreadScope();
     * binder.bindScope(ThreadScoped.class, threadScope);
     * binder.bind(Service.class).to(ServiceImpl.class).in(ThreadScoped.class);
     * }
* @param scopeAnnotation the scope annotation, which should be already registered to the binder * @see Binder#bindScope(Class, Scope) * @see javax.inject.Singleton */ void in(Class scopeAnnotation); /** * Instances of this binding are created in the specified scope which should be already registered to the binder. * For ex: *
{@code
     * ThreadScope threadScope = new ThreadScope();
     * binder.bindScope(ThreadScoped.class, threadScope);
     * binder.bind(Service.class).to(ServiceImpl.class).in(thredScope);
     * }
* @param scope the scope instance, which should be already registered to the binder * @see Binder#bindScope(Class, Scope) */ void in(Scope scope); /** * Instructs the {@link Injector} to eagerly initialize this singleton-scoped binding upon creation. * For ex:
{@code binder.bind(Service.class).to(ServiceImpl.class).asEagerSingleton(); }
*/ void asEagerSingleton(); /** * Instructs the {@link Injector} to lazily initialize (only when requested), this singleton-scoped binding. * For ex:
{@code binder.bind(Service.class).to(ServiceImpl.class).asLazySingleton(); }
* @see javax.inject.Singleton */ void asLazySingleton(); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy