Service Repository

Repository to group all available services (stateless and statefull). The intention is have some point where all the internal project services are defined

Лицензия

Лицензия

Группа

Группа

org.bytemechanics
Идентификатор

Идентификатор

service-repository
Последняя версия

Последняя версия

1.3.1
Дата

Дата

Тип

Тип

jar
Описание

Описание

Service Repository
Repository to group all available services (stateless and statefull). The intention is have some point where all the internal project services are defined
Организация-разработчик

Организация-разработчик

Byte Mechanics
Система контроля версий

Система контроля версий

https://github.com/bytemechanics/service-repository

Скачать service-repository

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/org.bytemechanics/service-repository/ -->
<dependency>
    <groupId>org.bytemechanics</groupId>
    <artifactId>service-repository</artifactId>
    <version>1.3.1</version>
</dependency>
// https://jarcasting.com/artifacts/org.bytemechanics/service-repository/
implementation 'org.bytemechanics:service-repository:1.3.1'
// https://jarcasting.com/artifacts/org.bytemechanics/service-repository/
implementation ("org.bytemechanics:service-repository:1.3.1")
'org.bytemechanics:service-repository:jar:1.3.1'
<dependency org="org.bytemechanics" name="service-repository" rev="1.3.1">
  <artifact name="service-repository" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.bytemechanics', module='service-repository', version='1.3.1')
)
libraryDependencies += "org.bytemechanics" % "service-repository" % "1.3.1"
[org.bytemechanics/service-repository "1.3.1"]

Зависимости

test (5)

Идентификатор библиотеки Тип Версия
org.spockframework : spock-core jar 1.1-groovy-2.4
org.codehaus.groovy : groovy-all jar 2.4.13
net.bytebuddy : byte-buddy jar 1.7.9
org.objenesis : objenesis jar 2.6
cglib : cglib jar 3.2.6

Модули Проекта

Данный проект не имеет модулей.

Service Repository

Latest version Quality Gate Coverage License

Service Repository it's a library to simplify the task to define and unify the distinct services existing inside any application. Allows:

  • Create stateful services (singletons)
  • Create stateless services acting as service factory

Motivation

With the dependency injection development has become easier and faster, but with large projects increase the dificulty to start working with a preexistent project and it's difficult to understand by novice developers. For this reason we propose to go back to the old style factories, but with more fashion approach Of course you are free to use it as base for another dependency injection mechanism, but this is not the final intention

Quick start

  1. First of all include the Jar file in your compile and execution classpath.

Maven

	<dependency>
		<groupId>org.bytemechanics</groupId>
		<artifactId>service-repository</artifactId>
		<version>X.X.X</version>
	</dependency>

Graddle

dependencies {
    compile 'org.bytemechanics:service-repository:X.X.X'
}
  1. Create your service repository
package mypackage;
import org.bytemechanics.service.repository.ServiceSupplier;
import org.bytemechanics.service.repository.beans.DefaultServiceSupplier;
import org.bytemechanics.service.repository.ServiceRepository;
public enum MyServiceRepository implements ServiceRepository{
	MY_SERVICE_0ARG(MyService.class,MyServiceImpl.class),
	MY_SERVICE_SUPPLIER_0ARG(MyService.class,() -> new MyServiceImpl()),
	MY_SINGLETON_SERVICE_0ARG(MyService.class,true,MyServiceImpl.class),
	MY_SINGLETON_SERVICE_SUPPLIER_0ARG(MyService.class,true,() -> new MyServiceImpl()),
	;	
	private final ServiceSupplier serviceSupplier;	
	<T> MyServiceRepository(final Class<T> _adapter,final Class<? extends T> _implementation,final Object... _args){
		this.serviceSupplier=ServiceSupplier.builder(_adapter)
												.name(name())
												.implementation(_implementation)
												.args(_args)
											.build();
	}
	<T> MyServiceRepository(final Class<T> _adapter,final Supplier<? extends T> _implementationSupplier){
		this.serviceSupplier=ServiceSupplier.builder(_adapter)
												.name(name())
												.supplier(_implementationSupplier)
											.build();
	}
	<T> MyServiceRepository(final Class<T> _adapter,final boolean _singleton,final Class<? extends T> _implementation,final Object... _args){
		this.serviceSupplier=ServiceSupplier.builder(_adapter)
												.name(name())
												.singleton(_singleton)
												.implementation(_implementation)
												.args(_args)
											.build();
	}
	<T> MyServiceRepository(final Class<T> _adapter,final boolean _singleton,final Supplier<? extends T> _implementationSupplier){
		this.serviceSupplier=ServiceSupplier.builder(_adapter)
												.name(name())
												.singleton(_singleton)
												.supplier(_implementationSupplier)
											.build();
	}
	@Override
	public ServiceSupplier getServiceSupplier() {
		return this.serviceSupplier;
	}
	public static final void startup(){
		ServiceRepository.startup(Stream.of(MyServiceRepository.values()));
	}
	public static final void shutdown(){
		ServiceRepository.shutdown(Stream.of(MyServiceRepository.values()));
	}
	public static final void reset(){
		ServiceRepository.reset(Stream.of(MyServiceRepository.values()));
	}
}
  1. get service instance

Directly (with exceptions)

MyServiceRepository.MY_SINGLETON_SERVICE_0ARG.get();

Directly (with exceptions) casted

MyServiceRepository.MY_SINGLETON_SERVICE_0ARG.get(MyService.class);

Optional (without exceptions)

MyServiceRepository.MY_SINGLETON_SERVICE_0ARG.tryGet();

Optional (without exceptions) casted

MyServiceRepository.MY_SINGLETON_SERVICE_0ARG.tryGet(MyService.class);
org.bytemechanics

ByteMechanics Foundation

Foundation dedicated to provide opensource libraries and resources to simplify developers life

Версии библиотеки

Версия
1.3.1
1.3.0
1.2.1
1.2.0
1.0.1
1.0.0