Dropwizard Jackrabbit

Addon bundle for Dropwizard to support JCR reference implementation Jackrabbit

License

License

Categories

Categories

DropWizard Container Microservices
GroupId

GroupId

com.github.justcoke
ArtifactId

ArtifactId

dropwizard-jackrabbit
Last Version

Last Version

1.1.0-rc4
Release Date

Release Date

Type

Type

jar
Description

Description

Dropwizard Jackrabbit
Addon bundle for Dropwizard to support JCR reference implementation Jackrabbit

Download dropwizard-jackrabbit

How to add to project

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

Dependencies

compile (3)

Group / Artifact Type Version
com.github.justcoke : dropwizard-jcr jar 1.1.0-rc4
org.apache.jackrabbit : jackrabbit-core jar 2.10.1
org.apache.derby : derby jar 10.5.3.0_1

provided (1)

Group / Artifact Type Version
org.slf4j : slf4j-api jar

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