Skip to content
Draft
36 changes: 36 additions & 0 deletions dropwizard-5x-migration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
type: specs.openrewrite.org/v1beta/recipe
name: org.example.Dropwizard2to5Migration
displayName: Dropwizard 2.x to 5.x Migration
description: Migrates a Dropwizard application from version 2.x to 5.x.
tags:
- dropwizard
- migration
- java

recipeList:
- org.openrewrite.maven.ChangePropertyValue:
key: dropwizard.version
newValue: 5.0.0-rc.3
- org.openrewrite.maven.ChangeDependencyGroupIdAndArtifactId:
oldGroupId: org.hibernate
oldArtifactId: hibernate-core
newGroupId: org.hibernate.orm
newArtifactId: hibernate-core
- org.openrewrite.java.ChangeType:
oldFullyQualifiedTypeName: io.dropwizard.Application
newFullyQualifiedTypeName: io.dropwizard.core.Application
- org.openrewrite.java.ChangeType:
oldFullyQualifiedTypeName: io.dropwizard.Configuration
newFullyQualifiedTypeName: io.dropwizard.core.Configuration
- org.openrewrite.java.ChangeType:
oldFullyQualifiedTypeName: io.dropwizard.cli.Command
newFullyQualifiedTypeName: io.dropwizard.core.cli.Command
- org.openrewrite.java.ChangeType:
oldFullyQualifiedTypeName: io.dropwizard.setup.Environment
newFullyQualifiedTypeName: io.dropwizard.core.setup.Environment
- org.openrewrite.java.ChangeType:
oldFullyQualifiedTypeName: io.dropwizard.setup.Bootstrap
newFullyQualifiedTypeName: io.dropwizard.core.setup.Bootstrap
- org.openrewrite.java.ChangeType:
oldFullyQualifiedTypeName: io.dropwizard.setup.AdminEnvironment
newFullyQualifiedTypeName: io.dropwizard.core.setup.AdminEnvironment
71 changes: 53 additions & 18 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<dropwizard.version>2.1.10</dropwizard.version>
<dropwizard.version>5.0.0-rc.3</dropwizard.version>
<lombok.version>1.18.34</lombok.version>
<cglib.version>3.3.0</cglib.version>
<guava.version>33.2.1-jre</guava.version>
Expand Down Expand Up @@ -147,7 +147,7 @@
<artifactId>dropwizard-db</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<groupId>org.hibernate.orm</groupId>
<artifactId>hibernate-core</artifactId>
</dependency>
<dependency>
Expand Down Expand Up @@ -199,6 +199,11 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>jakarta.ws.rs</groupId>
<artifactId>jakarta.ws.rs-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
Expand Down Expand Up @@ -311,22 +316,22 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.6.3</version>
<configuration>
<source>17</source>
</configuration>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- <plugin>-->
<!-- <groupId>org.apache.maven.plugins</groupId>-->
<!-- <artifactId>maven-javadoc-plugin</artifactId>-->
<!-- <version>3.6.3</version>-->
<!-- <configuration>-->
<!-- <source>17</source>-->
<!-- </configuration>-->
<!-- <executions>-->
<!-- <execution>-->
<!-- <id>attach-javadocs</id>-->
<!-- <goals>-->
<!-- <goal>jar</goal>-->
<!-- </goals>-->
<!-- </execution>-->
<!-- </executions>-->
<!-- </plugin>-->
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
Expand All @@ -338,6 +343,36 @@
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
<plugin>
<groupId>org.openrewrite.maven</groupId>
<artifactId>rewrite-maven-plugin</artifactId>
<version>6.13.0</version>
<configuration>
<activeRecipes>
<recipe>org.openrewrite.java.migrate.jakarta.JavaxMigrationToJakarta</recipe>
<recipe>org.example.Dropwizard2to5Migration</recipe>
</activeRecipes>
<configLocation>${maven.multiModuleProjectDirectory}/dropwizard-5x-migration.yml</configLocation>
</configuration>
<dependencies>
<!-- Include rewrite-java and rewrite-maven modules -->
<dependency>
<groupId>org.openrewrite</groupId>
<artifactId>rewrite-java</artifactId>
<version>8.58.0</version>
</dependency>
<dependency>
<groupId>org.openrewrite</groupId>
<artifactId>rewrite-maven</artifactId>
<version>8.58.0</version>
</dependency>
<dependency>
<groupId>org.openrewrite.recipe</groupId>
<artifactId>rewrite-migrate-java</artifactId>
<version>3.13.0</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
<repositories>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import io.appform.dropwizard.sharding.sharding.BalancedShardManager;
import io.appform.dropwizard.sharding.sharding.ShardBlacklistingStore;
import io.appform.dropwizard.sharding.sharding.ShardManager;
import io.dropwizard.Configuration;
import io.dropwizard.core.Configuration;
import lombok.extern.slf4j.Slf4j;

import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
import io.appform.dropwizard.sharding.sharding.NoopShardBlacklistingStore;
import io.appform.dropwizard.sharding.sharding.ShardBlacklistingStore;
import io.appform.dropwizard.sharding.sharding.ShardingKey;
import io.dropwizard.Configuration;
import io.dropwizard.ConfiguredBundle;
import io.dropwizard.core.ConfiguredBundle;
import io.dropwizard.core.Configuration;
import java.lang.annotation.Annotation;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
Expand All @@ -28,7 +28,8 @@
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;
import javax.persistence.Entity;

import jakarta.persistence.Entity;
import lombok.NonNull;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ClassUtils;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import io.appform.dropwizard.sharding.sharding.LegacyShardManager;
import io.appform.dropwizard.sharding.sharding.ShardBlacklistingStore;
import io.appform.dropwizard.sharding.sharding.ShardManager;
import io.dropwizard.Configuration;
import io.dropwizard.core.Configuration;
import lombok.extern.slf4j.Slf4j;

import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,14 @@
import io.appform.dropwizard.sharding.sharding.NoopShardBlacklistingStore;
import io.appform.dropwizard.sharding.sharding.ShardBlacklistingStore;
import io.appform.dropwizard.sharding.sharding.ShardManager;
import io.dropwizard.Configuration;
import io.dropwizard.ConfiguredBundle;
import io.dropwizard.setup.Bootstrap;
import io.dropwizard.setup.Environment;
import io.dropwizard.core.ConfiguredBundle;
import io.dropwizard.core.Configuration;
import io.dropwizard.core.setup.Bootstrap;
import io.dropwizard.core.setup.Environment;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.hibernate.SessionFactory;

import java.util.Arrays;
import java.util.List;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import io.appform.dropwizard.sharding.sharding.BalancedShardManager;
import io.appform.dropwizard.sharding.sharding.ShardBlacklistingStore;
import io.appform.dropwizard.sharding.sharding.ShardManager;
import io.dropwizard.Configuration;
import io.dropwizard.core.Configuration;
import lombok.extern.slf4j.Slf4j;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import io.appform.dropwizard.sharding.sharding.LegacyShardManager;
import io.appform.dropwizard.sharding.sharding.ShardBlacklistingStore;
import io.appform.dropwizard.sharding.sharding.ShardManager;
import io.dropwizard.Configuration;
import io.dropwizard.core.Configuration;
import lombok.extern.slf4j.Slf4j;

import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,16 @@
import io.appform.dropwizard.sharding.sharding.ShardBlacklistingStore;
import io.appform.dropwizard.sharding.sharding.ShardManager;
import io.appform.dropwizard.sharding.sharding.impl.ConsistentHashBucketIdExtractor;
import io.dropwizard.Configuration;
import io.dropwizard.core.Configuration;
import io.dropwizard.core.setup.Bootstrap;
import io.dropwizard.core.setup.Environment;
import io.dropwizard.db.PooledDataSourceFactory;
import io.dropwizard.setup.Bootstrap;
import io.dropwizard.setup.Environment;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import lombok.val;
import org.apache.commons.collections.MapUtils;
import org.hibernate.SessionFactory;

import java.util.Arrays;
import java.util.List;
import java.util.Map;
Expand All @@ -67,18 +73,12 @@
import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import lombok.val;
import org.apache.commons.collections.MapUtils;
import org.hibernate.SessionFactory;

/**
* Base for Multi-Tenant sharding bundles. Clients cannot use this. Use one of the derived classes.
*/
@Slf4j
public abstract class MultiTenantDBShardingBundleBase<T extends Configuration> extends
BundleCommonBase<T> {
public abstract class MultiTenantDBShardingBundleBase<T extends Configuration> extends BundleCommonBase<T> {

@Getter
private Map<String, List<SessionFactory>> sessionFactories = Maps.newHashMap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
package io.appform.dropwizard.sharding.caching;


import org.hibernate.criterion.DetachedCriteria;

import java.util.List;
import java.util.function.Function;

Expand All @@ -38,15 +36,15 @@ public interface RelationalCache<V> {
void put(String parentKey, Object key, V entity);

/**
* Write through method that will be called if cache enabled {@link io.appform.dropwizard.sharding.dao.CacheableRelationalDao#select(String, DetachedCriteria, int, int, Function)} is used
* Write through method that will be called if cache enabled {@link io.appform.dropwizard.sharding.dao.CacheableRelationalDao#select(String, io.appform.dropwizard.sharding.query.QuerySpec, int, int, Function)} is used
*
* @param parentKey The key of the parent that the entity is related to
* @param entities List of entities that needs to be written into cache
*/
void put(String parentKey, List<V> entities);

/**
* Write through method that will be called if cache enabled {@link io.appform.dropwizard.sharding.dao.CacheableRelationalDao#select(String, DetachedCriteria, int, int, Function)} is used
* Write through method that will be called if cache enabled {@link io.appform.dropwizard.sharding.dao.CacheableRelationalDao#select(String, io.appform.dropwizard.sharding.query.QuerySpec, int, int, Function)} is used
*
* @param parentKey The key of the parent that the entity is related to
* @param entities List of entities that needs to be written into cache
Expand All @@ -72,15 +70,15 @@ public interface RelationalCache<V> {
V get(String parentKey, Object key);

/**
* Read through method that will be called if a cache enabled {@link io.appform.dropwizard.sharding.dao.CacheableRelationalDao#select(String, DetachedCriteria, int, int, Function)} is used
* Read through method that will be called if a cache enabled {@link io.appform.dropwizard.sharding.dao.CacheableRelationalDao#select(String, io.appform.dropwizard.sharding.query.QuerySpec, int, int, Function)} is used
*
* @param parentKey The key of the parent the entity is related to
* @return Entities that was read through the cache
*/
List<V> select(String parentKey);

/**
* Read through method that will be called if a cache enabled {@link io.appform.dropwizard.sharding.dao.CacheableRelationalDao#select(String, DetachedCriteria, int, int, Function)} is used
* Read through method that will be called if a cache enabled {@link io.appform.dropwizard.sharding.dao.CacheableRelationalDao#select(String, io.appform.dropwizard.sharding.query.QuerySpec, int, int, Function)} is used
*
* @param parentKey The key of the parent the entity is related to
* @return Entities that was read through the cache
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
import lombok.Singular;
import org.hibernate.validator.constraints.NotEmpty;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import java.util.List;

/**
Expand Down
Loading
Loading