Dropwizard JCR support

Addon bundle for Dropwizard to support JCR

License

License

Categories

Categories

DropWizard Container Microservices
GroupId

GroupId

com.github.justcoke
ArtifactId

ArtifactId

dropwizard-jcr
Last Version

Last Version

1.1.0-rc4
Release Date

Release Date

Type

Type

jar
Description

Description

Dropwizard JCR support
Addon bundle for Dropwizard to support JCR

Download dropwizard-jcr

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.justcoke/dropwizard-jcr/ -->
<dependency>
    <groupId>com.github.justcoke</groupId>
    <artifactId>dropwizard-jcr</artifactId>
    <version>1.1.0-rc4</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.justcoke/dropwizard-jcr/
implementation 'com.github.justcoke:dropwizard-jcr:1.1.0-rc4'
// https://jarcasting.com/artifacts/com.github.justcoke/dropwizard-jcr/
implementation ("com.github.justcoke:dropwizard-jcr:1.1.0-rc4")
'com.github.justcoke:dropwizard-jcr:jar:1.1.0-rc4'
<dependency org="com.github.justcoke" name="dropwizard-jcr" rev="1.1.0-rc4">
  <artifact name="dropwizard-jcr" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.justcoke', module='dropwizard-jcr', version='1.1.0-rc4')
)
libraryDependencies += "com.github.justcoke" % "dropwizard-jcr" % "1.1.0-rc4"
[com.github.justcoke/dropwizard-jcr "1.1.0-rc4"]

Dependencies

compile (2)

Group / Artifact Type Version
io.dropwizard : dropwizard-core jar
javax.jcr : jcr jar 2.0

test (3)

Group / Artifact Type Version
junit : junit jar 4.12
org.mockito : mockito-core jar 2.7.12
org.assertj : assertj-core jar 3.6.2

Project Modules

There are no modules declared in this project.

JCR support 4 dropwizard

Travis (Linux & MacOS build) Appveyor (Windows build) MavenCentral Dependency Status

A set of modules for connecting a Dropwizard app to a Java Content Repository

The set contains:

  • dropwizard-jcr - some basic jcr interfaces and classes
  • dropwizard-jackrabbit - support for jackrabbit (the reference implementation of jcr)
  • dropwizard-jackrabbit-example - a basic example dropwizard app that uses the dropwizard

Usage

This module assumes you are including it in a Dropwizard 0.9.0 application with dropwizard-guice wiring.

Include as a maven dependency:

<dependency>
    <groupId>com.github.justcoke</groupId>
    <artifactId>dropwizard-jackrabbit</artifactId>
    <version>${version.dropwizard-jackrabbit}</version>
</dependency>

Add configuration to your application's configuration class, like:

import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.dropwizard.Configuration;
import com.github.justcoke.dropwizard.jackrabbit.JackrabbitRepositoryFactory;

public class HelloWorldConfiguration extends Configuration {
	@Valid
	@NotNull
	@JsonProperty
	private JackrabbitRepositoryFactory repository = new JackrabbitRepositoryFactory();

	public JackrabbitRepositoryFactory getRepository() {
		return repository;
	}
}

Add reasonable configuration options to your application YML file:

...
repository:
    homeDir: <mandatory; path where to store the te repository>
    configFile: <xml-configuration of the jcr; if not set built in defaultRepository.xml will be used>
...

Make sure your Guice wiring "provides" the Repository as a bean so you are able to inject it in your business code:

import java.io.IOException;
import javax.inject.Named;
import javax.jcr.Repository;
import javax.jcr.RepositoryException;
import com.google.inject.AbstractModule;
import com.google.inject.Provides;

public class HelloWorldModule extends AbstractModule {
	...
	@Provides
	@Named("jcr")
	public Repository provideRepository(HelloWorldConfiguration configuration) {
		try {
			return configuration.getRepository().build(null);
		} catch (RepositoryException | IOException e) {
			e.printStackTrace();
			return null;
		}
	}
}

Finally in your application's main initialize() method, add your new HelloWorldModule to your guice bundle, for example:

import com.hubspot.dropwizard.guice.GuiceBundle;

	private GuiceBundle<HelloWorldConfiguration> guiceBundle = null;

	@Override
	public void initialize(Bootstrap<HelloWorldConfiguration> bootstrap) {
		// Guice
		guiceBundle = GuiceBundle.<HelloWorldConfiguration> newBuilder().addModule(new HelloWorldModule())
				.enableAutoConfig(getClass().getPackage().getName()).setConfigClass(HelloWorldConfiguration.class)
				.build();

		bootstrap.addBundle(guiceBundle);
	}

Also have look at the dropwizard-jackrabbit-example.

Versions

Version
1.1.0-rc4
0.2.3