mirror of https://github.com/reiseburo/whoas
Merge pull request #12 from GiriDandu/issue-3-whoas-needs-to-be-configurable
Issue 11 whoas needs to be configurable
This commit is contained in:
commit
98efd846ef
|
@ -1,3 +1,5 @@
|
|||
build/
|
||||
.idea/
|
||||
whoas.iml
|
||||
*.sw*
|
||||
.gradle/
|
||||
|
|
12
build.gradle
12
build.gradle
|
@ -24,6 +24,9 @@ repositories {
|
|||
mavenCentral()
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// DEPENDENCY MANAGEMENT
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
dependencies {
|
||||
compile 'org.codehaus.groovy:groovy-all:2.3.9+'
|
||||
compile 'org.glassfish.jersey.core:jersey-client:2.6+'
|
||||
|
@ -36,6 +39,14 @@ dependencies {
|
|||
|
||||
testCompile 'org.spockframework:spock-core:0.7-groovy-2.0'
|
||||
testCompile 'cglib:cglib-nodep:2.2.+'
|
||||
|
||||
[
|
||||
'dropwizard-core',
|
||||
'dropwizard-configuration',
|
||||
].each {
|
||||
compile "io.dropwizard:${it}:0.8.0-rc1"
|
||||
}
|
||||
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
@ -71,6 +82,7 @@ groovydoc {
|
|||
destinationDir file('docs/html5/groovydoc')
|
||||
shouldRunAfter test
|
||||
}
|
||||
|
||||
check.dependsOn groovydoc
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
package com.github.lookout.whoas
|
||||
|
||||
|
||||
import io.dropwizard.Configuration
|
||||
|
||||
/**
|
||||
* The interface to create the whoas factory based on configuration
|
||||
* The client of whoas will call with the configuration to create the whoas factory.
|
||||
* @param < T > Configuration class that extends dropwizard configuration
|
||||
*/
|
||||
public interface WhoasConfiguration<T extends Configuration> {
|
||||
WhoasFactory getWhoasFactory(T configuration);
|
||||
}
|
|
@ -0,0 +1,95 @@
|
|||
package com.github.lookout.whoas
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty
|
||||
import org.hibernate.validator.constraints.NotEmpty;
|
||||
|
||||
/**
|
||||
* This factory will allow clients of whoas to build
|
||||
* different queues like in memory, persistent etc and runners
|
||||
* like sequential.
|
||||
*/
|
||||
public class WhoasFactory {
|
||||
|
||||
/**
|
||||
* Type of queue to create in whoas
|
||||
*/
|
||||
@JsonProperty
|
||||
@NotEmpty
|
||||
String queueType
|
||||
|
||||
/**
|
||||
* Get function for queue type in the factory
|
||||
*
|
||||
* @return queue type in the factory
|
||||
*/
|
||||
public String getQueueType() {
|
||||
return queueType
|
||||
}
|
||||
|
||||
/**
|
||||
* Set function for the queue type in the factory
|
||||
*
|
||||
* @param queueType type of queue to store
|
||||
*/
|
||||
public void setQueueType(String queueType) {
|
||||
this.queueType = queueType
|
||||
}
|
||||
|
||||
/**
|
||||
* Type of runner to create in whoas
|
||||
*/
|
||||
@JsonProperty
|
||||
@NotEmpty
|
||||
String runnerType
|
||||
|
||||
/**
|
||||
* Get function for runner type in the factory
|
||||
*
|
||||
* @return runner type in the factory
|
||||
*/
|
||||
public String getRunnerType() {
|
||||
return runnerType
|
||||
}
|
||||
|
||||
/**
|
||||
* Set function for runner type in the factory
|
||||
*
|
||||
* @param runnerType type of the runner to store
|
||||
* @return
|
||||
*/
|
||||
public setRunnerType(String runnerType) {
|
||||
this.runnerType = runnerType
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocate and return the queue based on stored queue type.
|
||||
*
|
||||
* If the queue cannot be created, then this throws
|
||||
* IllegalAccessException - if the class or its nullary constructor is not accessible.
|
||||
* InstantiationException - if this Class represents an abstract class, an interface,
|
||||
* an array class, a primitive type, or void;
|
||||
* or if the class has no nullary constructor;
|
||||
* or if the instantiation fails for some other reason.
|
||||
* @return allocated queue
|
||||
*/
|
||||
public AbstractHookQueue buildQueue() {
|
||||
return Class.forName(this.queueType).newInstance()
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocate and return runner based on stored runner type
|
||||
*
|
||||
* If the runner cannot be created, then this throws
|
||||
* IllegalAccessException - if the class or its nullary constructor is not accessible.
|
||||
* InstantiationException - if this Class represents an abstract class, an interface,
|
||||
* an array class, a primitive type, or void;
|
||||
* or if the class has no nullary constructor;
|
||||
* or if the instantiation fails for some other reason.
|
||||
* @param hookQueue queue to associate with allocated runner
|
||||
* @return
|
||||
*/
|
||||
public AbstractHookRunner buildRunner(AbstractHookQueue hookQueue) {
|
||||
return Class.forName(this.runnerType).getConstructor(AbstractHookQueue.class).
|
||||
newInstance(hookQueue)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module external.linked.project.id="whoas" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="com.github.lookout" external.system.module.version="0.1.2" type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="false">
|
||||
<output url="file://$MODULE_DIR$/build/classes/main" />
|
||||
<output-test url="file://$MODULE_DIR$/build/classes/test" />
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/groovy" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/groovy" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" exported="" name="Gradle: org.codehaus.groovy:groovy-all:2.3.9" level="project" />
|
||||
<orderEntry type="library" exported="" name="Gradle: org.glassfish.jersey.core:jersey-client:2.6" level="project" />
|
||||
<orderEntry type="library" exported="" name="Gradle: com.fasterxml.jackson.core:jackson-databind:2.3.3" level="project" />
|
||||
<orderEntry type="library" exported="" name="Gradle: joda-time:joda-time:2.6" level="project" />
|
||||
<orderEntry type="library" exported="" name="Gradle: org.glassfish.jersey.core:jersey-common:2.6" level="project" />
|
||||
<orderEntry type="library" exported="" name="Gradle: javax.ws.rs:javax.ws.rs-api:2.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="Gradle: org.glassfish.hk2:hk2-api:2.2.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="Gradle: org.glassfish.hk2.external:javax.inject:2.2.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="Gradle: org.glassfish.hk2:hk2-locator:2.2.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="Gradle: com.fasterxml.jackson.core:jackson-annotations:2.3.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="Gradle: com.fasterxml.jackson.core:jackson-core:2.3.3" level="project" />
|
||||
<orderEntry type="library" exported="" name="Gradle: javax.annotation:javax.annotation-api:1.2" level="project" />
|
||||
<orderEntry type="library" exported="" name="Gradle: org.glassfish.jersey.bundles.repackaged:jersey-guava:2.6" level="project" />
|
||||
<orderEntry type="library" exported="" name="Gradle: org.glassfish.hk2:osgi-resource-locator:1.0.1" level="project" />
|
||||
<orderEntry type="library" exported="" name="Gradle: org.glassfish.hk2:hk2-utils:2.2.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="Gradle: org.glassfish.hk2.external:aopalliance-repackaged:2.2.0" level="project" />
|
||||
<orderEntry type="library" exported="" name="Gradle: org.javassist:javassist:3.18.1-GA" level="project" />
|
||||
<orderEntry type="library" exported="" name="Gradle: javax.inject:javax.inject:1" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Gradle: org.spockframework:spock-core:0.7-groovy-2.0" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Gradle: cglib:cglib-nodep:2.2.2" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Gradle: junit:junit-dep:4.10" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Gradle: org.hamcrest:hamcrest-core:1.3" level="project" />
|
||||
</component>
|
||||
</module>
|
Loading…
Reference in New Issue