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

io.datakernel.di.impl.CompiledBinding Maven / Gradle / Ivy

Go to download

DataKernel has an extremely lightweight DI with ground-breaking design principles. It supports nested scopes, singletons, object factories, modules and plugins which allow to transform graph of dependencies at startup time without any reflection.

The newest version!
package io.datakernel.di.impl;

import java.util.concurrent.atomic.AtomicReferenceArray;

/**
 * This is defined as an abstract class and not a functional interface so that
 * any anonymous class usage is compiled as a inner class and not a method with invokedynamic instruction.
 * This is needed for compiled bindings to be applicable for later specialization.
 */
public interface CompiledBinding {
	@SuppressWarnings("Convert2Lambda")
	CompiledBinding MISSING_OPTIONAL_BINDING = new CompiledBinding() {
		@Override
		public Object getInstance(AtomicReferenceArray[] scopedInstances, int synchronizedScope) {
			return null;
		}
	};

	R getInstance(AtomicReferenceArray[] scopedInstances, int synchronizedScope);

	@SuppressWarnings("unchecked")
	static  CompiledBinding missingOptionalBinding() {
		return (CompiledBinding) MISSING_OPTIONAL_BINDING;
	}
}