##Dropwizard-Bundler##
Dropwizard-Bundler is a set of Dropwizard extensions, which provides
- Guice support and auto discovery of modules, bundles, resources and more (1)
- Auto Rest support and Swagger for @Redis and @Elastic annotated model classes - (1 2)
- Auto persist based on model usage - (1)
###KickStart### For a kickstart introduction, take a look at the ImdbSample, and BundlerImdbAppExampleTest
To see it in action:
- Install and start a local Redis server
- Run the BundlerImdbAppExample class
- Then browse to localhost:8090/swagger and play around with the Redis, Elastic and API tabs.
####WalkThrough ImdbSample####
Given a data model class, such as:
public class ImdbInfo {
@Id public String imdbID;
public String Title;
public Integer Year;
public String Director;
...
}
Adding @Redis/@Elastic on top:
@Redis
@Elastic
public class ImdbInfo {
@Id public String imdbID;
public String Title;
public Integer Year;
public String Director;
...
}
Enables you to use RedisClient/ElasticClient for basic peristence:
@Inject RedisClient redisClient;
@Inject ElasticClient elasticClient;
...
redisClient.put(imdbInfo);
elasticClient.put(imdbInfo);
redisClient.get(ImdbInfo.class, "id1");
...
#####RefModel#####
RedisClient also provides getByProperty
:
List<ImdbInfo> list =
redisClient.getByProperty(ImdbInfo.class, RefModel.ImdbInfo.Title.name(), "Pulp Fiction");
Where RefModel is an auto generated class, representing model class properties - and can be addressed statically
//generated ...
public interface RefModel {
@RefPackage("my.app.model...")
public enum ImdbInfo { imdbID, Title, Year, Director, Plot }
}
The properties that are actually used in the code, generated into RefScheme class:
//generated ...
public interface RefScheme {
@RefPackage("my.app.model...")
public enum ImdbInfo { Title, Director } //only title and director
}
And each property is used as an index when persisting - for Redis as keys (1), and for Elastic as mapping (2)