Moonshine

Container for services


Service container

Moonshine introduces an organizational unit bigger than a class - Service

What the Service is?
  • while class groups fields and methods, Service groups classes
  • contains exposed (public) and private classes
  • can depend on other services
  • has a lifecycle - can be started and stopped
What is Moonshine for?
  • structuring complex applications
  • promoting reusability
  • maintaining code flexibility
  • exceptionally easy and powerful testing
Testability
  • allows true Test Driven Development
  • can easily test multiple implementations
  • JUnit support - container starts as a part of your tests
Configurability
  • only one central configuration file
  • allows tests specific configuration
  • enables multiple configurations testing
Legal info
  • Apache licensed - free to use for everyone, for both commercial and non-commercial uses

How to start?

1. Bootstrap new project

Execute

mvn archetype:generate \
	-DarchetypeGroupId=org.atteo.moonshine \
	-DarchetypeArtifactId=service-archetype

2. Select the services

Add selected services to the POM file

<dependency>
	<groupId>org.atteo.moonshine</groupId>
	<artifactId>jetty</artifactId>
</dependency>
<dependency>
	<groupId>org.atteo.moonshine</groupId>
	<artifactId>resteasy</artifactId>
</dependency>
				

3. Create REST service

Create file 'src/main/java/HelloWorldResource.java'

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;

@Path("/")
@Produces("application/text")
public class HelloWorldResource {
	@GET
	public String get() {
		return "Hello World!";
	}
}
				

4. Start the container

Execute the following line from console:

mvn exec:java -Djetty.port=8080
				

Go to http://localhost:8080/ to see the result


Documentation

Tutorial - a quick introduction to the basic features

Manual - in-depth description of the framework

Examples - sample projects

Javadocs - find your service description