Skip to content

Commit

Permalink
Merge branch 'release/1.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
vegegoku committed Dec 22, 2023
2 parents 8f566f8 + eb12a17 commit 096463b
Show file tree
Hide file tree
Showing 16 changed files with 1,071 additions and 27 deletions.
28 changes: 28 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#
# Copyright © 2019 Dominokit
#
# 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.
#

# These are supported funding model platforms

github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: Dominokit
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
62 changes: 62 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#
# Copyright © ${year} Dominokit
#
# 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.
#

name: Deploy

on:
push:
branches: [ main , development ]

jobs:
verify:
runs-on: ubuntu-20.04
strategy:
matrix:
java-version: [ 11 ]
steps:
- name: Check out Git repository
uses: actions/checkout@v3
- name: Install Java and Maven
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java-version }}
distribution: 'temurin'
- run: mvn verify -B -e

release:
needs: verify
runs-on: ubuntu-20.04
steps:
- name: Check out Git repository
uses: actions/checkout@v3

- name: Install Java and Maven
uses: actions/setup-java@v3
with:
java-version: 11
distribution: 'temurin'
server-id: ossrh
server-username: SONATYPE_USERNAME
server-password: SONATYPE_PASSWORD
- id: install-secret-key
name: Install gpg secret key
run: |
cat <(echo -e "${{ secrets.gpg_private_key }}") | gpg --batch --import
- name: publish
run: mvn --no-transfer-progress clean deploy -B -e -Dci=true -Dgpg.passphrase=${{ secrets.gpg_passphrase }}
env:
SONATYPE_USERNAME: ${{ secrets.nexus_username }}
SONATYPE_PASSWORD: ${{ secrets.nexus_password }}
36 changes: 13 additions & 23 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,24 +1,14 @@
# Compiled class file
*.class

# Log file
*.log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
replay_pid*
*.iml
*.bak
.DS_Store
.idea
.settings
.project
.classpath
out
target
dependency-reduced-pom.xml
gwt-unitCache
hs_err*
**/pom.xml.versionsBackup
5 changes: 3 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,15 @@
APPENDIX: How to apply the Apache License to your work.

To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]
Copyright {yyyy} {name of copyright owner}

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -199,3 +199,4 @@
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.

13 changes: 13 additions & 0 deletions LICENSE.header
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Copyright © ${year} ${name}

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.
142 changes: 140 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,140 @@
# domino-auto
Domino-auto is a simple and lightweight service loader for GWT/J2CL application that uses annotation processor to create a loader class that load instances of a specific service class.
![logoimage](https://raw.githubusercontent.com/DominoKit/DominoKit.github.io/master/logo/128.png)

<a href="https://github.com/DominoKit/domino-auto/actions?query=workflow:%22Deploy%22"><img src="https://github.com/DominoKit/domino-auto/workflows/Deploy/badge.svg" alt="Deploy"></a>
![Sonatype Nexus (Snapshots)](https://img.shields.io/badge/Snapshot-HEAD--SNAPSHOT-orange)
<a href="https://github.com/DominoKit/domino-auto/releases/"><img src="https://img.shields.io/github/release/DominoKit/domino-auto?include_prereleases=&amp;sort=semver&amp;color=14c398" alt="GitHub release"></a>
<a href="https://discord.gg/35UG3FhfHq"><img src="https://img.shields.io/badge/Discord-Join_chat-14c398?logo=discord&amp;logoColor=white" alt="Discord - Join chat"></a>
<a href="https://matrix.to/#/#DominoKit_domino:gitter.im"><img src="https://img.shields.io/badge/Element-Join_chat-14c398?logo=element&amp;logoColor=white" alt="Element - Join chat"></a>
<a href="#license"><img src="https://img.shields.io/badge/License-_Apache_2.0-14c398" alt="License"></a>
![GWT3/J2CL compatible](https://img.shields.io/badge/GWT3/J2CL-compatible-brightgreen.svg)

## Domino-auto
=====
Domino-auto is a simple and lightweight service loader for GWT/J2CL application that uses annotation processor to create
a loader class that load instances of a specific service class.

#### Dependencies

- The API dependency

```xml

<dependency>
<groupId>org.dominokit</groupId>
<artifactId>domino-auto-api</artifactId>
<version>[version]</version>
</dependency>
```

- The Processor dependency

```xml

<dependency>
<groupId>org.dominokit</groupId>
<artifactId>domino-auto-processor</artifactId>
<version>[version]</version>
<scope>provided</scope>
</dependency>
```

Or as s processor path in the compiler plugin :

```xml

<annotationProcessorPaths>
<path>
<groupId>org.dominokit</groupId>
<artifactId>domino-auto-processor</artifactId>
<version>[version]</version>
</path>
</annotationProcessorPaths>
```

### Usage

For a service to be utilized by this tool, it must adhere to the `DominoAutoService` marker interface and possess a
default constructor without arguments. Additionally, these services need to be declared as a `DominoAutoService` service
within the project's `META-INF`. When a service meets these criteria, you can use the `@DominoAuto` annotation on a
class or interface to specify the desired service interface. The processor then automatically generates a class that
aggregates all instances of the specified service.

### Example

Lets define the desired service interface

```java
public interface SampleService extends DominoAutoService {
void init();
}
```

The lets have different implementations

```java
package com.dominokit.samples;

public class FooSampleServiceImpl implements SampleService {
public void init(){
//Do something here
}
}

//-------------

package com.dominokit.samples;

public class BarSampleServiceImpl implements SampleService {
public void init(){
//Do something here
}
}
```
The project `META-INF` we register both implementations as services :

Create a file named `org.dominokit.auto.DominoAutoService` under the following path
`project root folder -> src -> main -> resources -> META-INF -> services`

In the file list the services with the full qualified class name

```java
com.dominokit.samples.FooSampleServiceImpl
com.dominokit.samples.BarSampleServiceImpl
```

Now in the client module from where you need to load the services, you create a class or interface and annotate it with `@DominoAuto`

```java
@DominoAuto(SampleService.class)
public interface SampleServiceAuto {
}
```

This will generate the following code :

```java
public class SampleServiceAuto_ServiceLoader {
public static List<SampleService> load() {
List<SampleService> services = new ArrayList();
services.add(new FooSampleServiceImpl());
services.add(new BarSampleServiceImpl());
return services;
}
}
```

Then we can use it like this :

```java
SampleServiceAuto_ServiceLoader.load()
.forEach(SampleService::init);
```









31 changes: 31 additions & 0 deletions domino-auto-api/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.dominokit</groupId>
<artifactId>domino-auto</artifactId>
<version>1.0.0</version>
</parent>

<artifactId>domino-auto-api</artifactId>
<packaging>gwt-lib</packaging>

<name>domino-auto-api</name>
<url>https://github.com/DominoKit/domino-auto-api</url>
<description>The client side module of domino-auto</description>

<build>
<plugins>
<plugin>
<groupId>net.ltgt.gwt.maven</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<configuration>
<moduleName>org.dominokit.auto.Auto</moduleName>
<moduleShortName>dominoauto</moduleShortName>
</configuration>
</plugin>
</plugins>
</build>
</project>
27 changes: 27 additions & 0 deletions domino-auto-api/src/main/java/org/dominokit/auto/DominoAuto.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright © 2019 Dominokit
*
* 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 org.dominokit.auto;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface DominoAuto {
Class<? extends DominoAutoService> value();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright © 2019 Dominokit
*
* 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 org.dominokit.auto;

public interface DominoAutoService {}
Loading

0 comments on commit 096463b

Please sign in to comment.