Skip to content

Commit b5cc51d

Browse files
committed
Upload first version
1 parent 4836baf commit b5cc51d

11 files changed

Lines changed: 953 additions & 0 deletions

File tree

README.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# stiletto
2+
Launch system that allows classes to be invoked in phases to make sure all dependencies are satisfied.
3+
4+
## Features
5+
* Custom phases
6+
* Builder-style
7+
8+
## Installation
9+
10+
#### Using Maven
11+
Add the following to your `pom.xml`-file:
12+
13+
```xml
14+
<dependency>
15+
<groupId>com.github.pyknic</groupId>
16+
<artifactId>rocket</artifactId>
17+
<version>1.0.0</version>
18+
</dependency>
19+
```
20+
21+
#### Using Gradle
22+
Add the following to your `build.gradle`-file:
23+
```gradle
24+
compile group: 'com.github.pyknic', name: 'rocket', version: '1.0.0'
25+
```
26+
27+
## Usage
28+
The launch system follows a builder pattern where the two interfaces `Rocket` and `RocketBuilder` are central.
29+
30+
### Configuration
31+
The builder pattern allows Rocket to be built by appending types available for launching. If the dependency graph is incomplete or contains cyclic dependencies when the `RocketBuilder.build()`-method is invoked, then an `RocketException` is thrown.
32+
33+
```java
34+
// Create a new Launcher with a number of instances.
35+
Rocket rocket = Rocket.builder(Phase.class)
36+
.with(foo)
37+
.with(bar)
38+
.with(baz)
39+
.build();
40+
```
41+
42+
### Define Phases
43+
Phases are defined by creating an `enum` class and passing it to the `Rocket.builder(...)`-method.
44+
45+
```java
46+
// Define an enum with three phases.
47+
enum Phase {
48+
INIT,
49+
UPDATE,
50+
DESTROY
51+
}
52+
```
53+
54+
### Add Action
55+
Actions can be added to a class by adding the `@Execute`-annotation to the method. If the method takes any parameters, they will be injected automatically. Methods with the same phase will be invoked in a order that guarantees that all the arguments have already passed that stage.
56+
57+
```java
58+
class ExampleComponent {
59+
60+
@Execute("init")
61+
void onInit() {
62+
...
63+
}
64+
65+
@Execute("update")
66+
void onUpdate(OtherComponent other) {
67+
...
68+
}
69+
70+
}
71+
```
72+
73+
## License
74+
Copyright 2017 Emil Forslund
75+
76+
Licensed under the Apache License, Version 2.0 (the "License");
77+
you may not use this file except in compliance with the License.
78+
You may obtain a copy of the License at
79+
80+
[http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)
81+
82+
Unless required by applicable law or agreed to in writing, software
83+
distributed under the License is distributed on an "AS IS" BASIS,
84+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
85+
See the License for the specific language governing permissions and
86+
limitations under the License.

license_header.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
Copyright (c) ${currentYear}, Emil Forslund. All Rights Reserved.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License"); You may not
5+
use this file except in compliance with the License. You may obtain a copy of
6+
the License at:
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
License for the specific language governing permissions and limitations under
14+
the License.
15+
16+

pom.xml

Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>com.github.pyknic</groupId>
8+
<artifactId>rocket</artifactId>
9+
<version>1.0.0-SNAPSHOT</version>
10+
11+
<name>Rocket</name>
12+
<description>
13+
Launch system that allows classes to be invoked in phases to make sure
14+
all dependencies are satisfied.
15+
</description>
16+
<url>https://www.github.com/Pyknic/rocket/</url>
17+
18+
<properties>
19+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
20+
<maven.compiler.source>1.8</maven.compiler.source>
21+
<maven.compiler.target>1.8</maven.compiler.target>
22+
</properties>
23+
24+
<licenses>
25+
<license>
26+
<name>Apache License, Version 2.0</name>
27+
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
28+
<distribution>repo</distribution>
29+
</license>
30+
</licenses>
31+
32+
<organization>
33+
<name>Emil Forslund</name>
34+
<url>http://github.com/pyknic</url>
35+
</organization>
36+
37+
<developers>
38+
<developer>
39+
<name>Emil Forslund</name>
40+
<email>emil@speedment.com</email>
41+
<organization>Speedment</organization>
42+
<organizationUrl>http://www.speedment.com</organizationUrl>
43+
</developer>
44+
</developers>
45+
46+
<dependencies>
47+
<dependency>
48+
<groupId>org.junit.jupiter</groupId>
49+
<artifactId>junit-jupiter-api</artifactId>
50+
<version>5.0.0-M3</version>
51+
<scope>test</scope>
52+
</dependency>
53+
</dependencies>
54+
55+
<scm>
56+
<connection>scm:git:git@github.com:pyknic/rocket.git</connection>
57+
<developerConnection>scm:git:git@github.com:pyknic/rocket.git</developerConnection>
58+
<url>git@github.com:pyknic/rocket.git</url>
59+
</scm>
60+
61+
<distributionManagement>
62+
<snapshotRepository>
63+
<id>ossrh</id>
64+
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
65+
</snapshotRepository>
66+
<repository>
67+
<id>ossrh</id>
68+
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2</url>
69+
</repository>
70+
</distributionManagement>
71+
72+
<build>
73+
<plugins>
74+
<plugin>
75+
<groupId>org.apache.maven.plugins</groupId>
76+
<artifactId>maven-compiler-plugin</artifactId>
77+
<version>3.6.1</version>
78+
<configuration>
79+
<compilerArgument>-Xlint:all</compilerArgument>
80+
<showWarnings>true</showWarnings>
81+
<showDeprecation>true</showDeprecation>
82+
</configuration>
83+
</plugin>
84+
85+
<plugin>
86+
<groupId>org.apache.felix</groupId>
87+
<artifactId>maven-bundle-plugin</artifactId>
88+
<version>3.2.0</version>
89+
<extensions>true</extensions>
90+
<configuration>
91+
<instructions>
92+
<Export-Package>
93+
com.github.pyknic.rocket
94+
</Export-Package>
95+
</instructions>
96+
</configuration>
97+
</plugin>
98+
</plugins>
99+
</build>
100+
101+
<profiles>
102+
<profile>
103+
<id>ossrh</id>
104+
<build>
105+
<plugins>
106+
<plugin>
107+
<groupId>com.mycila</groupId>
108+
<artifactId>license-maven-plugin</artifactId>
109+
<version>3.0</version>
110+
<configuration>
111+
<header>license_header.txt</header>
112+
<properties>
113+
<currentYear>2017</currentYear>
114+
</properties>
115+
<excludes>
116+
<exclude>**/README</exclude>
117+
<exclude>**/LICENSE</exclude>
118+
<exclude>**/*.xml</exclude>
119+
<exclude>**/*.iml</exclude>
120+
<exclude>**/package-info.java</exclude>
121+
<exclude>src/test/resources/**</exclude>
122+
<exclude>src/main/resources/**</exclude>
123+
</excludes>
124+
</configuration>
125+
<executions>
126+
<execution>
127+
<phase>generate-sources</phase>
128+
<goals>
129+
<goal>format</goal>
130+
</goals>
131+
</execution>
132+
</executions>
133+
</plugin>
134+
<plugin>
135+
<groupId>org.apache.maven.plugins</groupId>
136+
<artifactId>maven-source-plugin</artifactId>
137+
<version>3.0.1</version>
138+
<executions>
139+
<execution>
140+
<id>attach-sources</id>
141+
<goals>
142+
<goal>jar-no-fork</goal>
143+
</goals>
144+
</execution>
145+
</executions>
146+
</plugin>
147+
<plugin>
148+
<groupId>org.apache.maven.plugins</groupId>
149+
<artifactId>maven-javadoc-plugin</artifactId>
150+
<version>2.10.4</version>
151+
<executions>
152+
<execution>
153+
<id>attach-javadocs</id>
154+
<goals>
155+
<goal>jar</goal>
156+
</goals>
157+
</execution>
158+
</executions>
159+
<configuration>
160+
<docfilessubdirs>true</docfilessubdirs>
161+
<excludePackageNames>com.github.pyknic.rocket.internal</excludePackageNames>
162+
</configuration>
163+
</plugin>
164+
<plugin>
165+
<groupId>org.apache.maven.plugins</groupId>
166+
<artifactId>maven-gpg-plugin</artifactId>
167+
<version>1.6</version>
168+
<executions>
169+
<execution>
170+
<id>sign-artifacts</id>
171+
<phase>verify</phase>
172+
<goals>
173+
<goal>sign</goal>
174+
</goals>
175+
</execution>
176+
</executions>
177+
<configuration>
178+
<useAgent>true</useAgent>
179+
<keyname>${gpg.keyname}</keyname>
180+
<passphrase>${gpg.passphrase}</passphrase>
181+
<executable>${gpg.executable}</executable>
182+
</configuration>
183+
</plugin>
184+
<plugin>
185+
<groupId>org.sonatype.plugins</groupId>
186+
<artifactId>nexus-staging-maven-plugin</artifactId>
187+
<version>1.6.8</version>
188+
<extensions>true</extensions>
189+
<executions>
190+
<execution>
191+
<id>default-deploy</id>
192+
<phase>deploy</phase>
193+
<goals>
194+
<goal>deploy</goal>
195+
</goals>
196+
</execution>
197+
</executions>
198+
<configuration>
199+
<serverId>ossrh</serverId>
200+
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
201+
<autoReleaseAfterClose>true</autoReleaseAfterClose>
202+
</configuration>
203+
</plugin>
204+
</plugins>
205+
</build>
206+
</profile>
207+
</profiles>
208+
</project>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/**
2+
*
3+
* Copyright (c) 2017, Emil Forslund. All Rights Reserved.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License"); You may not
6+
* use this file except in compliance with the License. You may obtain a copy of
7+
* the License at:
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
* License for the specific language governing permissions and limitations under
15+
* the License.
16+
*/
17+
package com.github.pyknic.rocket;
18+
19+
import java.lang.annotation.ElementType;
20+
import java.lang.annotation.Inherited;
21+
import java.lang.annotation.Retention;
22+
import java.lang.annotation.RetentionPolicy;
23+
import java.lang.annotation.Target;
24+
25+
/**
26+
* Annotation that signals that a method should be invoked as part of a phase in
27+
* the launcher.
28+
*
29+
* @author Emil Forslund
30+
* @since 1.0.0
31+
*/
32+
@Inherited
33+
@Target({ElementType.METHOD})
34+
@Retention(RetentionPolicy.RUNTIME)
35+
public @interface Execute {
36+
37+
/**
38+
* Name of the phase to execute in. This should correspond to the result of
39+
* the {@link Enum#name()} method for that phase.
40+
*
41+
* @return the phase
42+
*/
43+
String value();
44+
45+
}

0 commit comments

Comments
 (0)