SkillAgentSearch skills...

Gipsy

Groovy version of Jipsy, a configurable AST Transformation to simplify the use of the Service Provider Interface.

Install / Use

/learn @kordamp/Gipsy
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

= Gipsy :author: Andres Almiray :linkattrs: :project-owner: kordamp :project-name: gipsy :project-groupId: org.kordamp.gipsy :project-artifactId: gipsy :project-version: 1.2.0

ifdef::env-github[] :tip-caption: :bulb: :note-caption: :information_source: :important-caption: :heavy_exclamation_mark: :caution-caption: :fire: :warning-caption: :warning: endif::[]

image::media/gipsy-logo.png[]

image:http://img.shields.io/github/actions/workflow/status/{project-owner}/{project-name}/early-access.yml?branch=master&logo=github&label=Build["Build Status", link="https://github.com/{project-owner}/{project-name}/actions"] image:https://img.shields.io/maven-central/v/{project-groupId}/{project-artifactId}.svg[Download, link="https://search.maven.org/#search|ga|1|g:{project-groupId} AND a:{project-artifactId}"]


Groovy version of https://github.com/kordamp/jipsy[Jipsy], a configurable AST Transformation to simplify the use of the Service Provider Interface.

== Introduction

Gipsy delivers the same functionality that https://github.com/kordamp/jipsy[Jipsy] does but uses Groovy's AST Transformations instead of JDK6' Annotation Processor.

As explained at the http://docs.oracle.com/javase/6/docs/api/java/util/ServiceLoader.html[service loader documentation], services must follow certain rules in order to be considered as such; they also must be registered using an standard location based on a naming convention. The following rules apply to classes that may be considered services

. The class must implement at least one target interface (the service interface). . The class must provide a no-args constructor. . The class must be public. . The class name should be added to a file named META-INF/services/<target_interface_name>

This library provides a mechanism for enforcing those rules by simply adding an annotation on each service implementation, for example say there exists the following Calculator service interface

[source,groovy]

package com.acme

interface Calculator { double add(double a, double b) }

A basic implementation of such service may be as follows

[source,groovy]

package com.acme

@org.kordamp.jipsy.annotations.ServiceProviderFor(Calculator) class BasicCalculator implements Calculator { double add(double a, double b) { a + b } }

Notice that Gipsy reuses the same annotations from Jipsy. Compile your code. If you look closely at your project's output you'll see a file named META-INF/services/com.acme.Calculator whose contents should look similar to

[source] [subs="verbatim,attributes"]

Generated by org.kordamp.gipsy.transform.service.ServiceProviderProcessor ({project-version})

com.acme.BasicCalculator

Et voilà! There are no additional sources to be touched nor files to be created; Jipsy will take care of the boiler plate.

== Installing

Gipsy requires the following dependencies

  • jipsy-processor-{project-version}
  • groovy-all-3.0.7

Gipsy can be downloaded directly from Maven Central, configure it via Maven or Gradle.

Maven [subs="verbatim,attributes"]

<dependency> <groupId>{project-groupId}</groupId> <artifactId>{project-name}</artifactId> <version>{project-version}</version> <scope>provided</scope> </dependency> ----

Gradle [subs="verbatim,attributes"]

dependencies { annotationProcessor '{project-groupId}:{project-name}:{project-version}' compileOnly 'org.kordamp.jipsy:jipsy-annotations:{project-version}' }

== Creating Your Own AST Transformations

TBD

View on GitHub
GitHub Stars14
CategoryDevelopment
Updated2y ago
Forks0

Languages

Java

Security Score

75/100

Audited on Apr 12, 2023

No findings