https://github.com/aditosoftware/picoservice
A minimalist registry for java services using serviceloader
https://github.com/aditosoftware/picoservice
service-discovery serviceloader
Last synced: 5 months ago
JSON representation
A minimalist registry for java services using serviceloader
- Host: GitHub
- URL: https://github.com/aditosoftware/picoservice
- Owner: aditosoftware
- License: mit
- Created: 2015-03-25T10:12:55.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2022-08-16T15:37:32.000Z (almost 4 years ago)
- Last Synced: 2025-08-27T00:40:48.767Z (10 months ago)
- Topics: service-discovery, serviceloader
- Language: Java
- Size: 34.2 KB
- Stars: 3
- Watchers: 7
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# picoservice
Picoservice is a java library for service registration and service lookup. With it, you can find classes that have special meaning in your project. Internally it uses java's `ServiceLoader` so it integrates nicely with you build tools. Nothing magical is happening here.
Picoservice is focused on its main purpose: registration and lookup. For registration, you have to annotate a custom annotation with `@PicoService`. Each class annotated with that custom annotation can afterwards be found by using `IPicoRegistry.INSTANCE.find(Class pSearchedType, Class pAnnotationClass)`.
Get started
------------
The easiest way to get started with picoservice is using the following snippet in your pom.xml.
```xml
de.adito.picoservice
picoservice
1.1.7
```
Example of usage
----------------
Custom annotation which is put on classes for registration:
```java
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@PicoService
public @interface TestAnno
{
int value();
}
```
Annotated class 1:
```java
@TestAnno(10)
public class TestAnnotated
{
}
```
Annotated class 2:
```java
@TestAnno(20)
public class TestAnnotated2
{
}
```
Find those classes:
```java
public class Test
{
public static void main(String[] args)
{
Map, TestAnno> map = IPicoRegistry.INSTANCE.find(Object.class, TestAnno.class);
}
}
```