mirror of https://github.com/reiseburo/whoas
Update after code review comments
- Remove unnecessary dependencies from build.gradle - For easy plug in for thirdparty queues and runners, use class names to create them - Fixes #11
This commit is contained in:
parent
9e3b180483
commit
5a8bc06243
|
@ -27,10 +27,6 @@ repositories {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// DEPENDENCY MANAGEMENT
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
configurations {
|
||||
localJavadocs
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile 'org.codehaus.groovy:groovy-all:2.3.9+'
|
||||
compile 'org.glassfish.jersey.core:jersey-client:2.6+'
|
||||
|
@ -47,7 +43,6 @@ dependencies {
|
|||
[
|
||||
'dropwizard-core',
|
||||
'dropwizard-configuration',
|
||||
'dropwizard-hibernate',
|
||||
].each {
|
||||
compile withSources("io.dropwizard:${it}:0.8.0-rc1")
|
||||
}
|
||||
|
@ -91,7 +86,6 @@ groovydoc {
|
|||
def withSources(String dependency) {
|
||||
['sources'].each {
|
||||
def sourceDependency = dependencies.create("${dependency}:${it}")
|
||||
configurations.localJavadocs.dependencies.add(sourceDependency)
|
||||
}
|
||||
return dependency
|
||||
}
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
package com.github.lookout.whoas
|
||||
|
||||
|
||||
import io.dropwizard.Configuration;
|
||||
import io.dropwizard.Configuration
|
||||
|
||||
/**
|
||||
* The interface to create the whoas factory based on configuration
|
||||
* @param < T > Configuration class that extends dropwizard configuration
|
||||
*/
|
||||
public interface WhoasConfiguration<T extends Configuration> {
|
||||
WhoasFactory getWhoasFactory(T configuration);
|
||||
}
|
|
@ -3,42 +3,79 @@ package com.github.lookout.whoas
|
|||
import com.fasterxml.jackson.annotation.JsonProperty
|
||||
import org.hibernate.validator.constraints.NotEmpty;
|
||||
|
||||
/**
|
||||
* Class to create different types of queues and runners
|
||||
*/
|
||||
public class WhoasFactory {
|
||||
|
||||
/**
|
||||
* Type of queue to create in whoas
|
||||
*/
|
||||
@JsonProperty
|
||||
@NotEmpty
|
||||
String queueType
|
||||
|
||||
public getQueueType() {
|
||||
/**
|
||||
* Get function for queue type in the factory
|
||||
*
|
||||
* @return queue type in the factory
|
||||
*/
|
||||
public String getQueueType() {
|
||||
return queueType
|
||||
}
|
||||
|
||||
public setQueueType(String 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
|
||||
|
||||
public getRunnerType() {
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
* @return allocated queue
|
||||
*/
|
||||
public AbstractHookQueue buildQueue() {
|
||||
if(queueType == "InMemoryQueue") {
|
||||
return new InMemoryQueue()
|
||||
}
|
||||
return null
|
||||
return Class.forName(this.queueType).newInstance()
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocate and return runner based on stored runner type
|
||||
*
|
||||
* @param hookQueue queue to associate with allocated runner
|
||||
* @return
|
||||
*/
|
||||
public AbstractHookRunner buildRunner(AbstractHookQueue hookQueue) {
|
||||
if(runnerType == "SequentialHookRunner") {
|
||||
return new SequentialHookRunner(hookQueue)
|
||||
}
|
||||
return null
|
||||
return Class.forName(this.runnerType).getConstructor(AbstractHookQueue.class).
|
||||
newInstance(hookQueue)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue