JCR Support 4 Dropwizard Project

Parent bundle for Dropwizard to support Java Content Repository

License

License

Categories

Categories

DropWizard Container Microservices
GroupId

GroupId

com.github.justcoke
ArtifactId

ArtifactId

dropwizard-jcr-parent
Last Version

Last Version

1.1.0-rc4
Release Date

Release Date

Type

Type

pom
Description

Description

JCR Support 4 Dropwizard Project
Parent bundle for Dropwizard to support Java Content Repository
Project URL

Project URL

http://github.com/justcoke/dropwizard-jcr
Source Code Management

Source Code Management

https://github.com/justcoke/dropwizard-jcr.git

Download dropwizard-jcr-parent

How to add to project

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

Dependencies

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

  • dropwizard-jcr
  • dropwizard-jackrabbit

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