Skip to content

Commit

Permalink
Merge pull request #1 from codecentric/codecentric-refactoring
Browse files Browse the repository at this point in the history
Codecentric refactoring
  • Loading branch information
danielkocot authored Mar 15, 2021
2 parents c65db42 + b546fd0 commit eaecd8f
Show file tree
Hide file tree
Showing 27 changed files with 176 additions and 107 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Maven Build

on: [push]

jobs:
build:
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v2

- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11

- name: Build with Maven
run: mvn -B install --no-transfer-progress --file pom.xml
56 changes: 56 additions & 0 deletions .github/workflows/release-to-maven-central.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: release-to-maven-central
on:
workflow_dispatch:
inputs:
releaseversion:
description: 'Release version'
required: true
default: '1.1.0'
jobs:
publish:
runs-on: ubuntu-latest
steps:
- run: echo "Will start a Maven Central upload with version ${{ github.event.inputs.releaseversion }}"

- uses: actions/checkout@v2

- name: Set up settings.xml for Maven Central Repository
uses: actions/setup-java@v1
with:
java-version: 11
server-id: oss.sonatype.org
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
gpg-passphrase: MAVEN_GPG_PASSPHRASE

- name: Set projects Maven version to GitHub Action GUI set version
run: mvn versions:set "-DnewVersion=${{ github.event.inputs.releaseversion }}" --no-transfer-progress

- name: Publish package
run: mvn --batch-mode clean deploy --no-transfer-progress -P central-deploy -DskipTests=true
env:
MAVEN_USERNAME: ${{ secrets.OSS_SONATYPE_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSS_SONATYPE_PASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}

- name: Generate changelog
id: changelog
uses: metcalfc/changelog-generator@v0.4.4
with:
myToken: ${{ secrets.GITHUB_TOKEN }}

- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.event.inputs.releaseversion }}
release_name: ${{ github.event.inputs.releaseversion }}
body: |
Grab the new version from Maven central https://repo1.maven.org/maven2/de/codecentric/reedelk/module-scheduler/${{ github.event.inputs.releaseversion }}/
### Things that changed in this release
${{ steps.changelog.outputs.changelog }}
draft: false
prerelease: false
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.reedelk</groupId>
<groupId>de.codecentric.reedelk</groupId>
<artifactId>module-parent</artifactId>
<version>1.0.6</version>
<version>2.0.0</version>
</parent>

<packaging>bundle</packaging>
<version>1.0.6</version>
<version>2.0.0</version>
<artifactId>module-scheduler</artifactId>

<properties>
Expand Down
8 changes: 0 additions & 8 deletions src/main/java/com/reedelk/scheduler/ModuleDefinition.java

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package de.codecentric.reedelk.scheduler;

import de.codecentric.reedelk.runtime.api.annotation.Module;

@Module("Scheduler Module")
public class ModuleDefinition {
}

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.reedelk.scheduler.component;
package de.codecentric.reedelk.scheduler.component;

import com.reedelk.runtime.api.annotation.*;
import com.reedelk.runtime.api.component.Implementor;
import de.codecentric.reedelk.runtime.api.annotation.*;
import de.codecentric.reedelk.runtime.api.component.Implementor;
import org.osgi.service.component.annotations.Component;

import static org.osgi.service.component.annotations.ServiceScope.PROTOTYPE;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.reedelk.scheduler.component;
package de.codecentric.reedelk.scheduler.component;

import com.reedelk.runtime.api.annotation.*;
import com.reedelk.runtime.api.component.Implementor;
import de.codecentric.reedelk.runtime.api.annotation.*;
import de.codecentric.reedelk.runtime.api.component.Implementor;
import org.osgi.service.component.annotations.Component;

import static org.osgi.service.component.annotations.ServiceScope.PROTOTYPE;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.reedelk.scheduler.component;
package de.codecentric.reedelk.scheduler.component;


import com.reedelk.runtime.api.annotation.*;
import com.reedelk.runtime.api.component.AbstractInbound;
import com.reedelk.scheduler.internal.attribute.SchedulerAttributes;
import com.reedelk.scheduler.internal.scheduler.SchedulerJob;
import com.reedelk.scheduler.internal.scheduler.SchedulingStrategyBuilder;
import de.codecentric.reedelk.runtime.api.annotation.*;
import de.codecentric.reedelk.runtime.api.component.AbstractInbound;
import de.codecentric.reedelk.scheduler.internal.attribute.SchedulerAttributes;
import de.codecentric.reedelk.scheduler.internal.scheduler.SchedulerJob;
import de.codecentric.reedelk.scheduler.internal.scheduler.SchedulingStrategyBuilder;
import org.osgi.service.component.annotations.Component;

import static org.osgi.service.component.annotations.ServiceScope.PROTOTYPE;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.reedelk.scheduler.component;
package de.codecentric.reedelk.scheduler.component;

import com.reedelk.runtime.api.annotation.DisplayName;
import de.codecentric.reedelk.runtime.api.annotation.DisplayName;

public enum SchedulingStrategy {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.reedelk.scheduler.component;
package de.codecentric.reedelk.scheduler.component;

import com.reedelk.runtime.api.annotation.DisplayName;
import de.codecentric.reedelk.runtime.api.annotation.DisplayName;

public enum TimeUnit {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.reedelk.scheduler.internal;
package de.codecentric.reedelk.scheduler.internal;

import com.reedelk.scheduler.internal.scheduler.SchedulerProvider;
import de.codecentric.reedelk.scheduler.internal.scheduler.SchedulerProvider;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Deactivate;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package de.codecentric.reedelk.scheduler.internal.attribute;

import de.codecentric.reedelk.runtime.api.annotation.Type;
import de.codecentric.reedelk.runtime.api.annotation.TypeProperty;
import de.codecentric.reedelk.runtime.api.message.MessageAttributes;
import org.quartz.JobExecutionContext;

import static de.codecentric.reedelk.scheduler.internal.attribute.SchedulerAttributes.FIRED_AT;

@Type
@TypeProperty(name = FIRED_AT, type = long.class)
public class SchedulerAttributes extends MessageAttributes {

static final String FIRED_AT = "firedAt";

public SchedulerAttributes(JobExecutionContext executionContext) {
put(FIRED_AT, executionContext.getFireTime().getTime());
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
package com.reedelk.scheduler.internal.scheduler;

import com.reedelk.runtime.api.component.InboundEventListener;
import com.reedelk.runtime.api.message.Message;
import com.reedelk.runtime.api.message.MessageAttributes;
import com.reedelk.runtime.api.message.MessageBuilder;
import com.reedelk.scheduler.component.Scheduler;
import com.reedelk.scheduler.internal.attribute.SchedulerAttributes;
package de.codecentric.reedelk.scheduler.internal.scheduler;

import de.codecentric.reedelk.runtime.api.component.InboundEventListener;
import de.codecentric.reedelk.runtime.api.message.Message;
import de.codecentric.reedelk.runtime.api.message.MessageAttributes;
import de.codecentric.reedelk.runtime.api.message.MessageBuilder;
import de.codecentric.reedelk.scheduler.component.Scheduler;
import de.codecentric.reedelk.scheduler.internal.attribute.SchedulerAttributes;
import org.quartz.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import static com.reedelk.scheduler.internal.scheduler.Messages.Scheduler.ERROR_QUARTZ_CONTEXT;

public class ExecuteFlowJob implements Job {

private static final Logger logger = LoggerFactory.getLogger(ExecuteFlowJob.class);
Expand All @@ -30,7 +28,7 @@ public void execute(JobExecutionContext jobExecutionContext) throws JobExecution
try {
context = jobExecutionContext.getScheduler().getContext();
} catch (SchedulerException exception) {
String message = ERROR_QUARTZ_CONTEXT.format(exception.getMessage());
String message = Messages.Scheduler.ERROR_QUARTZ_CONTEXT.format(exception.getMessage());
logger.error(message, exception);
throw new JobExecutionException(exception);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.reedelk.scheduler.internal.scheduler;
package de.codecentric.reedelk.scheduler.internal.scheduler;

import com.reedelk.runtime.api.commons.FormattedMessage;
import de.codecentric.reedelk.runtime.api.commons.FormattedMessage;

public class Messages {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.reedelk.scheduler.internal.scheduler;
package de.codecentric.reedelk.scheduler.internal.scheduler;

import org.quartz.JobKey;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
package com.reedelk.scheduler.internal.scheduler;
package de.codecentric.reedelk.scheduler.internal.scheduler;

import com.reedelk.runtime.api.component.InboundEventListener;
import com.reedelk.runtime.api.exception.PlatformException;
import de.codecentric.reedelk.runtime.api.component.InboundEventListener;
import de.codecentric.reedelk.runtime.api.exception.PlatformException;
import org.quartz.*;
import org.quartz.impl.StdSchedulerFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Optional;

import static com.reedelk.scheduler.internal.scheduler.Messages.Scheduler.*;

public class SchedulerProvider {

private static final Logger logger = LoggerFactory.getLogger(SchedulerProvider.class);
Expand All @@ -21,7 +19,7 @@ public class SchedulerProvider {
quartzScheduler = new StdSchedulerFactory().getScheduler();
quartzScheduler.start();
} catch (SchedulerException exception) {
String message = ERROR_QUARTZ_SCHEDULER_INIT.format(exception.getMessage());
String message = Messages.Scheduler.ERROR_QUARTZ_SCHEDULER_INIT.format(exception.getMessage());
throw new PlatformException(message, exception);
}
}
Expand All @@ -42,7 +40,7 @@ public static void dispose() {
}
quartzScheduler = null;
} catch (SchedulerException exception) {
String message = ERROR_QUARTZ_SCHEDULER_DISPOSE.format(exception.getMessage());
String message = Messages.Scheduler.ERROR_QUARTZ_SCHEDULER_DISPOSE.format(exception.getMessage());
logger.warn(message, exception);
}
}
Expand All @@ -62,7 +60,7 @@ void deleteJob(JobKey jobKey) {
quartzScheduler.checkExists(jobKey);
quartzScheduler.deleteJob(jobKey);
} catch (SchedulerException exception) {
String message = ERROR_DELETE_JOB.format(jobKey.toString(), exception.getMessage());
String message = Messages.Scheduler.ERROR_DELETE_JOB.format(jobKey.toString(), exception.getMessage());
logger.warn(message, exception);
}
}
Expand All @@ -76,7 +74,7 @@ void scheduleJob(InboundEventListener listener, JobDetail job, Trigger trigger)
// Cleanup
getContext().ifPresent(schedulerContext -> schedulerContext.remove(jobID));
deleteJob(job.getKey());
String message = ERROR_SCHEDULE_JOB.format(jobID, exception.getMessage());
String message = Messages.Scheduler.ERROR_SCHEDULE_JOB.format(jobID, exception.getMessage());
throw new PlatformException(message, exception);
}
}
Expand All @@ -85,7 +83,7 @@ private Optional<SchedulerContext> getContext() {
try {
return Optional.ofNullable(quartzScheduler.getContext());
} catch (SchedulerException exception) {
String message = ERROR_QUARTZ_CONTEXT.format(exception.getMessage());
String message = Messages.Scheduler.ERROR_QUARTZ_CONTEXT.format(exception.getMessage());
logger.warn(message, exception);
return Optional.empty();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.reedelk.scheduler.internal.scheduler;
package de.codecentric.reedelk.scheduler.internal.scheduler;

import com.reedelk.scheduler.component.CronConfiguration;
import com.reedelk.scheduler.component.FixedFrequencyConfiguration;
import com.reedelk.scheduler.component.Scheduler;
import com.reedelk.scheduler.component.SchedulingStrategy;
import de.codecentric.reedelk.scheduler.component.CronConfiguration;
import de.codecentric.reedelk.scheduler.component.FixedFrequencyConfiguration;
import de.codecentric.reedelk.scheduler.component.Scheduler;
import de.codecentric.reedelk.scheduler.component.SchedulingStrategy;

import static com.reedelk.runtime.api.commons.ComponentPrecondition.Configuration.requireNotNull;
import static com.reedelk.runtime.api.commons.ComponentPrecondition.Configuration.requireTrue;
import static com.reedelk.scheduler.internal.scheduler.Messages.Scheduler.*;
import static de.codecentric.reedelk.runtime.api.commons.ComponentPrecondition.Configuration.requireNotNull;
import static de.codecentric.reedelk.runtime.api.commons.ComponentPrecondition.Configuration.requireTrue;
import static de.codecentric.reedelk.scheduler.internal.scheduler.Messages.Scheduler.*;

public class SchedulingStrategyBuilder {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package de.codecentric.reedelk.scheduler.internal.scheduler;

import de.codecentric.reedelk.runtime.api.component.InboundEventListener;

public interface SchedulingStrategyScheduler {

SchedulerJob schedule(InboundEventListener listener);
}
Loading

0 comments on commit eaecd8f

Please sign in to comment.