Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release 1.0.0 #3

Open
wants to merge 28 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
b552bec
wip
dcdh Feb 25, 2024
a03d97e
add mongo
dcdh Feb 26, 2024
790b89b
define quarkus extensions yaml
dcdh Feb 27, 2024
c6cf3c9
tchitchi
dcdh Feb 29, 2024
a4675eb
split into multiple interceptors depending on the provider (one inter…
dcdh Mar 3, 2024
53efb78
regarding jdbc configuration are defined in build time so I've done t…
dcdh Mar 3, 2024
db8a226
little fix on mongo configuration
dcdh Mar 3, 2024
6519b03
add documentation
dcdh Mar 4, 2024
beee372
rewrite the jdbc configuration validation
dcdh Mar 4, 2024
61ca6f2
Do not build yet https://github.com/quarkusio/quarkus/issues/39169
dcdh Mar 5, 2024
6f3d368
revert to avoid release
dcdh Mar 6, 2024
7d8fb67
remove unused modules
dcdh Mar 6, 2024
2c3fdb0
make JdbcConfig runtime because not used in processor and the develop…
dcdh Mar 6, 2024
5538afd
add the option to create or not shedlock tables at startup
dcdh Mar 6, 2024
7260173
make it build
dcdh Mar 8, 2024
f46413f
remove unused code
dcdh Mar 8, 2024
099d8e9
try to fix build
dcdh Mar 8, 2024
51033f4
make it fails by not reusing postgres container between tests
dcdh Mar 8, 2024
036bf6b
avoid injecting a list regarding this issue https://github.com/quarku…
dcdh Mar 12, 2024
0e7125b
remove previously deleted dependency
dcdh Mar 12, 2024
80b88a2
bump Quarkus to 3.17.5
dcdh Dec 23, 2024
1679624
Revert "avoid injecting a list regarding this issue https://github.co…
dcdh Dec 24, 2024
5d783d1
rewrite tests - add mongo reactive - renaming
dcdh Dec 23, 2024
edf7661
Merge remote-tracking branch 'quarkiverse/main' into release/1.0.0
dcdh Dec 24, 2024
fe5d9f2
fix jdbc resource leaking
dcdh Dec 24, 2024
9b0f223
lock can be applied only on a method returning void type
dcdh Dec 24, 2024
5dbb764
check exception behavior
dcdh Dec 24, 2024
3f86e7c
remove injectable bean because an interceptor is application wide scoped
dcdh Dec 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions common/deployment/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.quarkiverse.shedlock</groupId>
<artifactId>quarkus-shedlock-common-parent</artifactId>
<version>999-SNAPSHOT</version>
</parent>
<artifactId>quarkus-shedlock-common-deployment</artifactId>
<name>Quarkus ShedLock - Common - Deployment</name>
<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-arc-deployment</artifactId>
</dependency>
<dependency>
<groupId>io.quarkiverse.shedlock</groupId>
<artifactId>quarkus-shedlock-common</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5-internal</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-devtools-testing</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-extension-processor</artifactId>
<version>${quarkus.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package io.quarkiverse.shedlock.common.deployment;

import io.quarkiverse.shedlock.common.runtime.DefaultInstantProvider;
import io.quarkus.arc.deployment.AdditionalBeanBuildItem;
import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;

public class CommonProcessor {
@BuildStep
void registerBeans(final BuildProducer<AdditionalBeanBuildItem> additionalBeanBuildItemProducer) {
additionalBeanBuildItemProducer.produce(AdditionalBeanBuildItem.builder()
.setUnremovable()
.addBeanClasses(DefaultInstantProvider.class)
.build());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package io.quarkiverse.shedlock.common.deployment;

import static org.assertj.core.api.Assertions.assertThat;

import jakarta.inject.Inject;

import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import io.quarkus.test.QuarkusUnitTest;

public class CommonSchedulerLockTest {
@RegisterExtension
static final QuarkusUnitTest unitTest = new QuarkusUnitTest()
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)
.addClasses(
DefaultSchedulerLock.class,
DefaultLockProvider.class,
DefaultSchedulerLockInterceptor.class,
LockableService.class)
.addAsResource(new StringAsset("quarkus.shedlock.defaults-lock-at-most-for=PT30S\n" +
"quarkus.datasource.devservices.reuse=false"),
"application.properties"));

@Inject
LockableService lockableService;

@Inject
DefaultLockProvider defaultLockProvider;

@Test
public void shouldIntercept() {
// Given

// When
lockableService.execute();

// Then
assertThat(defaultLockProvider.hasBeenCalled()).isTrue();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package io.quarkiverse.shedlock.common.deployment;

import java.util.Optional;

import jakarta.enterprise.context.ApplicationScoped;

import net.javacrumbs.shedlock.core.LockConfiguration;
import net.javacrumbs.shedlock.core.LockProvider;
import net.javacrumbs.shedlock.core.SimpleLock;

@ApplicationScoped
public class DefaultLockProvider implements LockProvider {
private boolean hasBeenCalled = false;

@Override
public Optional<SimpleLock> lock(final LockConfiguration lockConfiguration) {
hasBeenCalled = true;
return Optional.empty();
}

public boolean hasBeenCalled() {
return hasBeenCalled;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package io.quarkiverse.shedlock.common.deployment;

import java.lang.annotation.*;

import jakarta.enterprise.util.Nonbinding;
import jakarta.interceptor.InterceptorBinding;

import io.quarkiverse.shedlock.common.runtime.LockDuration;

@InterceptorBinding
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.TYPE, ElementType.METHOD })
@Inherited
public @interface DefaultSchedulerLock {
@Nonbinding
LockDuration lockDuration() default @LockDuration();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package io.quarkiverse.shedlock.common.deployment;

import java.lang.reflect.Method;
import java.util.Objects;

import jakarta.annotation.Priority;
import jakarta.interceptor.AroundInvoke;
import jakarta.interceptor.Interceptor;
import jakarta.interceptor.InvocationContext;

import io.quarkiverse.shedlock.common.runtime.InstantProvider;
import io.quarkiverse.shedlock.common.runtime.LockDuration;
import io.quarkiverse.shedlock.common.runtime.SchedulerLockInterceptorBase;
import io.quarkiverse.shedlock.common.runtime.ShedLockConfiguration;
import net.javacrumbs.shedlock.core.LockProvider;

@DefaultSchedulerLock
@Priority(3001)
@Interceptor
public class DefaultSchedulerLockInterceptor extends SchedulerLockInterceptorBase {
final DefaultLockProvider lockProvider;

protected DefaultSchedulerLockInterceptor(final ShedLockConfiguration shedLockConfiguration,
final InstantProvider instantProvider,
final DefaultLockProvider lockProvider) {
super(shedLockConfiguration, instantProvider);
this.lockProvider = Objects.requireNonNull(lockProvider);
}

@Override
@AroundInvoke
protected Object lock(InvocationContext context) throws Throwable {
return super.lock(context);
}

@Override
protected LockProvider lockProvider(Method method) {
return lockProvider;
}

@Override
protected LockDuration lockDuration(Method method) {
return method.getAnnotation(DefaultSchedulerLock.class).lockDuration();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package io.quarkiverse.shedlock.common.deployment;

import jakarta.enterprise.context.ApplicationScoped;

@ApplicationScoped
public class LockableService {
@DefaultSchedulerLock
void execute() {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package io.quarkiverse.shedlock.common.deployment;

import static org.assertj.core.api.Assertions.assertThat;

import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import io.quarkus.test.QuarkusUnitTest;

public class ShouldFailWhenDefaultLockAtMostForPropertyIsMissingTest {
@RegisterExtension
static final QuarkusUnitTest unitTest = new QuarkusUnitTest()
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class)
.addClasses(
DefaultSchedulerLock.class,
DefaultLockProvider.class,
DefaultSchedulerLockInterceptor.class,
LockableService.class))
.assertException(throwable -> assertThat(throwable)
.hasNoSuppressedExceptions()
.rootCause()
.hasMessage("Configuration validation failed:\n" +
"\tjava.util.NoSuchElementException: SRCFG00014: The config property quarkus.shedlock.defaults-lock-at-most-for is required but it could not be found in any config source")
.hasNoSuppressedExceptions());

@Test
public void test() {
Assertions.fail("Startup should have failed");
}
}
29 changes: 29 additions & 0 deletions common/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?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>io.quarkiverse.shedlock</groupId>
<artifactId>quarkus-shedlock-parent</artifactId>
<version>999-SNAPSHOT</version>
</parent>

<artifactId>quarkus-shedlock-common-parent</artifactId>
<name>Quarkus - ShedLock - Common</name>
<packaging>pom</packaging>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>net.javacrumbs.shedlock</groupId>
<artifactId>shedlock-core</artifactId>
<version>${shedlock.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<modules>
<module>runtime</module>
<module>deployment</module>
</modules>
</project>
54 changes: 54 additions & 0 deletions common/runtime/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.quarkiverse.shedlock</groupId>
<artifactId>quarkus-shedlock-common-parent</artifactId>
<version>999-SNAPSHOT</version>
</parent>
<artifactId>quarkus-shedlock-common</artifactId>
<name>Quarkus ShedLock - Common - Runtime</name>
<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-arc</artifactId>
</dependency>
<dependency>
<groupId>net.javacrumbs.shedlock</groupId>
<artifactId>shedlock-core</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-extension-maven-plugin</artifactId>
<version>${quarkus.version}</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>extension-descriptor</goal>
</goals>
<configuration>
<deployment>${project.groupId}:${project.artifactId}-deployment:${project.version}</deployment>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-extension-processor</artifactId>
<version>${quarkus.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package io.quarkiverse.shedlock.common.runtime;

import java.time.Instant;

import jakarta.enterprise.context.ApplicationScoped;

import io.quarkus.arc.DefaultBean;

@ApplicationScoped
@DefaultBean
public class DefaultInstantProvider implements InstantProvider {
@Override
public Instant now() {
return Instant.now();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package io.quarkiverse.shedlock.common.runtime;

import java.time.Instant;

public interface InstantProvider {
Instant now();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package io.quarkiverse.shedlock.common.runtime;

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

import jakarta.enterprise.util.Nonbinding;

@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.TYPE, ElementType.METHOD })
public @interface LockDuration {
@Nonbinding
String lockAtMostFor() default "";

@Nonbinding
String lockAtLeastFor() default "";
}
Loading