Skip to content

Commit

Permalink
#24 - Rename jex.inner -> jex.config
Browse files Browse the repository at this point in the history
  • Loading branch information
rbygrave committed Jul 19, 2021
1 parent 81197a9 commit ac57a7d
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public Jex.Server start(Jex jex, SpiRoutes routes, SpiServiceManager serviceMana
final ServiceManager manager = new ServiceManager(serviceManager, "http", "");
RouteHandler handler = new RouteHandler(routes, manager);

final int port = jex.inner.port;
final int port = jex.config.port;
final HttpServer httpServer = new HttpServerBuilder()
//.addHandler(clStaticHttpHandler, "cl")
//.addHandler(staticHttpHandler, "static")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public Jex.Server start(Jex jex, SpiRoutes routes, SpiServiceManager serviceMana
if (executor != null) {
server.setExecutor(executor);
}
int port = jex.inner.port;
int port = jex.config.port;
log.debug("starting server on port {}", port);
server.bind(new InetSocketAddress(port), 0);
server.start();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ class JettyBuilder {

private static final Logger log = LoggerFactory.getLogger(JettyBuilder.class);

private final Jex.Inner inner;
private final Jex.Config inner;
private final JettyServerConfig config;

JettyBuilder(Jex jex, JettyServerConfig config) {
this.inner = jex.inner;
this.inner = jex.config;
this.config = config;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ private JettyServerConfig initConfig(ServerConfig config) {
}

MultipartUtil initMultiPart() {
return new MultipartUtil(initMultipartConfigElement(jex.inner.multipartConfig));
return new MultipartUtil(initMultipartConfigElement(jex.config.multipartConfig));
}

MultipartConfigElement initMultipartConfigElement(UploadConfig uploadConfig) {
if (uploadConfig == null) {
final int fileThreshold = jex.inner.multipartFileThreshold;
final int fileThreshold = jex.config.multipartFileThreshold;
return new MultipartConfigElement(System.getProperty("java.io.tmpdir"), -1, -1, fileThreshold);
}
return new MultipartConfigElement(uploadConfig.location(), uploadConfig.maxFileSize(), uploadConfig.maxRequestSize(), uploadConfig.fileSizeThreshold());
Expand Down Expand Up @@ -113,7 +113,7 @@ protected ServletHolder initServletHolder() {

protected ServletContextHandler initServletContextHandler() {
final ServletContextHandler ch = config.contextHandler();
return ch != null ? ch : new ContextHandler(jex.inner.contextPath, config.sessions(), config.security());
return ch != null ? ch : new ContextHandler(jex.config.contextPath, config.sessions(), config.security());
}

protected SessionHandler initSessionHandler() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class JexHttpServlet extends HttpServlet {
this.routes = routes;
this.manager = manager;
this.staticHandler = staticHandler;
this.prefer405 = jex.inner.prefer405;
this.prefer405 = jex.config.prefer405;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class StaticHandlerFactory {

StaticHandler build(Jex jex, List<StaticFileSource> sourceList) {

StaticHandler handler = new StaticHandler(jex.inner.preCompressStaticFiles);
StaticHandler handler = new StaticHandler(jex.config.preCompressStaticFiles);
for (StaticFileSource source : sourceList) {
handler.addStaticFileConfig(source);
}
Expand Down
16 changes: 8 additions & 8 deletions avaje-jex/src/main/java/io/avaje/jex/Jex.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class Jex {
private final StaticFileConfig staticFiles;
private final Map<Class<?>, Object> attributes = new HashMap<>();

public final Inner inner = new Inner();
public final Config config = new Config();
private ServerConfig serverConfig;

private Jex() {
Expand Down Expand Up @@ -59,7 +59,7 @@ public <T> T attribute(Class<T> cls) {
return (T) attributes.get(cls);
}

public static class Inner {
public static class Config {
public int port = 7001;
public String host;
public String contextPath = "/";
Expand Down Expand Up @@ -132,15 +132,15 @@ public Routing routing() {
* Set the AccessManager.
*/
public Jex accessManager(AccessManager accessManager) {
this.inner.accessManager = accessManager;
this.config.accessManager = accessManager;
return this;
}

/**
* Set the JsonService.
*/
public Jex jsonService(JsonService jsonService) {
this.inner.jsonService = jsonService;
this.config.jsonService = jsonService;
return this;
}

Expand Down Expand Up @@ -172,15 +172,15 @@ public <T extends Exception> Jex exception(Class<T> exceptionClass, ExceptionHan
* Set the port to use.
*/
public Jex port(int port) {
this.inner.port = port;
this.config.port = port;
return this;
}

/**
* Set the context path.
*/
public Jex context(String contextPath) {
this.inner.contextPath = contextPath;
this.config.contextPath = contextPath;
return this;
}

Expand All @@ -203,7 +203,7 @@ public StaticFileConfig staticFiles() {
*/
public Jex register(TemplateRender renderer, String... extensions) {
for (String extension : extensions) {
inner.renderers.put(extension, renderer);
config.renderers.put(extension, renderer);
}
return this;
}
Expand All @@ -214,7 +214,7 @@ public Jex register(TemplateRender renderer, String... extensions) {
public Server start() {
final SpiRoutes routes = ServiceLoader.load(SpiRoutesProvider.class)
.findFirst().get()
.create(this.routing, this.inner.accessManager, this.inner.ignoreTrailingSlashes);
.create(this.routing, this.config.accessManager, this.config.ignoreTrailingSlashes);

final SpiServiceManager serviceManager = ServiceLoader.load(SpiServiceManagerProvider.class)
.findFirst().get()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ SpiServiceManager build() {
}

JsonService initJsonService() {
final JsonService jsonService = jex.inner.jsonService;
final JsonService jsonService = jex.config.jsonService;
if (jsonService != null) {
return jsonService;
}
Expand All @@ -165,7 +165,7 @@ boolean detectJackson() {

TemplateManager initTemplateMgr() {
TemplateManager mgr = new TemplateManager();
mgr.register(jex.inner.renderers);
mgr.register(jex.config.renderers);
for (TemplateRender render : ServiceLoader.load(TemplateRender.class)) {
mgr.registerDefault(render);
}
Expand Down

0 comments on commit ac57a7d

Please sign in to comment.