Skip to content

Commit

Permalink
Merge pull request #45 from harbby/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
harbby authored Dec 7, 2018
2 parents 098d6fe + f342e68 commit 7693515
Show file tree
Hide file tree
Showing 17 changed files with 114 additions and 482 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ allprojects {
joda_time: '2.9.3',
log4j12 : '1.7.21',
guice : '4.2.1',
gadtry : '1.1.0-rc1',
gadtry : '1.1.0',
guava : '25.1-jre',
jackson : '2.9.5',
jersey : '2.27'
Expand Down
15 changes: 1 addition & 14 deletions sylph-controller/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,7 @@ assemble.dependsOn 'build_webapp'
dependencies {
compile group: 'javax.servlet', name: 'javax.servlet-api', version: '3.1.0'
compile(project(':sylph-spi'))

compile('io.airlift:configuration:0.172') {
exclude(module: 'guice')
exclude(module: 'guava')
exclude(module: "guice-multibindings")
exclude(module: 'commons-lang3')
}
compile(group: 'com.google.inject.extensions', name: 'guice-multibindings', version: deps.guice) {
exclude(module: "guava")
}
compile(group: 'com.google.inject', name: 'guice', version: deps.guice) {
exclude(module: 'guava')
}


compile group: 'org.eclipse.jetty', name: 'jetty-server', version: deps.jetty
compile group: 'org.eclipse.jetty', name: 'jetty-webapp', version: deps.jetty
compile group: 'org.eclipse.jetty', name: 'jetty-servlets', version: deps.jetty
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,28 @@
*/
package ideal.sylph.controller;

import com.google.inject.Inject;
import com.github.harbby.gadtry.ioc.Autowired;
import ideal.sylph.spi.SylphContext;

import java.util.Properties;

import static java.util.Objects.requireNonNull;

/**
* 视图层目前 为实验功能
*
*/
public class ControllerApp
{
private ServerConfig config;
private SylphContext sylphContext;

@Inject
@Autowired
public ControllerApp(
ServerConfig config,
Properties properties,
SylphContext sylphContext
)
{
this.config = requireNonNull(config, "config is null");
this.config = new ServerConfig(requireNonNull(properties, "config is null"));
this.sylphContext = requireNonNull(sylphContext, "jobManager is null");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,36 +15,24 @@
*/
package ideal.sylph.controller;

import io.airlift.configuration.Config;

import javax.validation.constraints.Min;
import java.util.Properties;

public class ServerConfig
{
private int serverPort = 8080;
private int maxFormContentSize = 100;
private final int serverPort;
private final int maxFormContentSize;

@Config("web.server.port")
public ServerConfig setServerPort(int serverPort)
public ServerConfig(Properties properties)
{
this.serverPort = serverPort;
return this;
this.serverPort = Integer.parseInt(properties.getProperty("web.server.port", "8080"));
this.maxFormContentSize = Integer.parseInt(properties.getProperty("server.http.maxFormContentSize", "100"));
}

@Min(1000)
public int getServerPort()
{
return serverPort;
}

@Config("server.http.maxFormContentSize")
public ServerConfig setMaxFormContentSize(int maxFormContentSize)
{
this.maxFormContentSize = maxFormContentSize;
return this;
}

@Min(10)
public int getMaxFormContentSize()
{
return maxFormContentSize;
Expand Down
26 changes: 14 additions & 12 deletions sylph-main/src/main/java/ideal/sylph/main/SylphMaster.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@
*/
package ideal.sylph.main;

import com.google.common.collect.ImmutableList;
import com.google.inject.Injector;
import com.google.inject.Module;
import com.github.harbby.gadtry.ioc.Bean;
import com.github.harbby.gadtry.ioc.IocFactory;
import ideal.sylph.controller.ControllerApp;
import ideal.sylph.main.bootstrap.Bootstrap;
import ideal.sylph.main.server.RunnerLoader;
import ideal.sylph.main.server.ServerMainModule;
import ideal.sylph.main.server.SylphBean;
import ideal.sylph.main.service.JobManager;
import ideal.sylph.main.service.PipelinePluginLoader;
import ideal.sylph.main.util.PropertiesUtil;
import ideal.sylph.spi.job.JobStore;
import org.apache.log4j.PropertyConfigurator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;
import java.io.File;
import java.io.IOException;

import static java.util.Objects.requireNonNull;

Expand All @@ -49,17 +49,19 @@ private SylphMaster() {}
" *---------------------------------------------------*";

public static void main(String[] args)
throws IOException
{
PropertyConfigurator.configure(requireNonNull(System.getProperty("log4j.file"), "log4j.file not setting"));
List<Module> modules = ImmutableList.of(new ServerMainModule());
String configFile = System.getProperty("config");
Bean sylphBean = new SylphBean(PropertiesUtil.loadProperties(new File(configFile)));

/*2 Initialize Guice Injector */
try {
Injector injector = new Bootstrap(modules)
.name(SylphMaster.class.getSimpleName())
.strictConfig()
.requireExplicitBindings(false)
.initialize();
logger.info("========={} Bootstrap initialize...========", SylphMaster.class.getCanonicalName());
IocFactory injector = IocFactory.create(sylphBean,
binder -> binder.bind(ControllerApp.class).withSingle()
);

injector.getInstance(PipelinePluginLoader.class).loadPlugins();
injector.getInstance(RunnerLoader.class).loadPlugins();
injector.getInstance(JobStore.class).loadJobs();
Expand Down
194 changes: 0 additions & 194 deletions sylph-main/src/main/java/ideal/sylph/main/bootstrap/Bootstrap.java

This file was deleted.

Loading

0 comments on commit 7693515

Please sign in to comment.