Skip to content

Commit

Permalink
Remove deprecated registering methods
Browse files Browse the repository at this point in the history
  • Loading branch information
emmanuel-keller committed Feb 27, 2018
1 parent 9f5802e commit c918f39
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 31 deletions.
20 changes: 3 additions & 17 deletions src/main/java/com/qwazr/extractor/ExtractorManager.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
/*
* Copyright 2015-2017 Emmanuel Keller / QWAZR
* Copyright 2015-2018 Emmanuel Keller / QWAZR
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>¬org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
Expand All @@ -15,13 +14,10 @@
*/
package com.qwazr.extractor;

import com.qwazr.server.ApplicationBuilder;
import com.qwazr.server.GenericServerBuilder;
import com.qwazr.utils.ClassLoaderUtils;
import com.qwazr.utils.LoggerUtils;

import javax.ws.rs.core.MultivaluedHashMap;
import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.ServiceLoader;
import java.util.Set;
Expand Down Expand Up @@ -54,22 +50,12 @@ public ExtractorManager() {

}

public ExtractorManager registerServices() throws IOException, ClassNotFoundException {
public ExtractorManager registerServices() {
ServiceLoader.load(ParserInterface.class, Thread.currentThread().getContextClassLoader())
.forEach(this::register);
return this;
}

public ExtractorManager registerContextAttribute(final GenericServerBuilder builder) {
builder.contextAttribute(this);
return this;
}

public ExtractorManager registerWebService(final ApplicationBuilder builder) {
builder.singletons(service);
return this;
}

public ExtractorServiceInterface getService() {
return service;
}
Expand Down
21 changes: 7 additions & 14 deletions src/main/java/com/qwazr/extractor/ExtractorServer.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2015-2017 Emmanuel Keller / QWAZR
* Copyright 2015-2018 Emmanuel Keller / QWAZR
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -26,7 +26,6 @@
import com.qwazr.server.configuration.ServerConfiguration;

import java.io.IOException;
import java.net.URISyntaxException;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.ExecutorService;
Expand All @@ -35,10 +34,8 @@
public class ExtractorServer implements BaseServer {

private final GenericServer server;
private final ExtractorManager extractorManager;

private ExtractorServer(final ServerConfiguration configuration)
throws IOException, URISyntaxException, ClassNotFoundException {
private ExtractorServer(final ServerConfiguration configuration) throws IOException {
final ExecutorService executorService = Executors.newCachedThreadPool();
final GenericServerBuilder builder = GenericServer.of(configuration, executorService);

Expand All @@ -49,12 +46,12 @@ private ExtractorServer(final ServerConfiguration configuration)
final ApplicationBuilder webServices = ApplicationBuilder.of("/*").classes(RestApplication.JSON_CLASSES).
singletons(new WelcomeShutdownService());

new ClusterManager(executorService, configuration).registerProtocolListener(builder, services)
.registerContextAttribute(builder)
.registerWebService(webServices);
final ClusterManager clusterManager =
new ClusterManager(executorService, configuration).registerProtocolListener(builder, services);
webServices.singletons(clusterManager.getService());

extractorManager = new ExtractorManager().registerContextAttribute(builder).registerWebService(webServices);
extractorManager.registerServices();
final ExtractorManager extractorManager = new ExtractorManager().registerServices();
webServices.singletons(extractorManager.getService());

builder.getWebServiceContext().jaxrs(webServices);
server = builder.build();
Expand All @@ -65,10 +62,6 @@ public GenericServer getServer() {
return server;
}

public ExtractorServiceInterface getService() {
return extractorManager.getService();
}

public static void main(final String... args) throws Exception {
new ExtractorServer(new ServerConfiguration(args)).start();
}
Expand Down

0 comments on commit c918f39

Please sign in to comment.