X-Git-Url: https://gerrit.akraino.org/r/gitweb?p=validation.git;a=blobdiff_plain;f=ui%2Fsrc%2Fmain%2Fjava%2Forg%2Fakraino%2Fvalidation%2Fui%2Fconf%2FUiUtils.java;fp=ui%2Fsrc%2Fmain%2Fjava%2Forg%2Fakraino%2Fvalidation%2Fui%2Fconfig%2FAppInitializer.java;h=7ef82345f1e5f16bfec4298d842923b45a7ff6de;hp=d79b2aef6f232b52a3cfe4c3217faa625949863e;hb=2879b2ee5e1e2815e5f43cb802352bf2878397af;hpb=ce4ad29dc48317cc7cb60fe433072ac46dea2ebb diff --git a/ui/src/main/java/org/akraino/validation/ui/config/AppInitializer.java b/ui/src/main/java/org/akraino/validation/ui/conf/UiUtils.java similarity index 55% rename from ui/src/main/java/org/akraino/validation/ui/config/AppInitializer.java rename to ui/src/main/java/org/akraino/validation/ui/conf/UiUtils.java index d79b2ae..7ef8234 100644 --- a/ui/src/main/java/org/akraino/validation/ui/config/AppInitializer.java +++ b/ui/src/main/java/org/akraino/validation/ui/conf/UiUtils.java @@ -1,19 +1,19 @@ /* * Copyright (c) 2019 AT&T Intellectual Property. All rights reserved. * - * 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 + * 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 * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. See the License for the specific language governing + * permissions and limitations under the License. */ -package org.akraino.validation.ui.config; +package org.akraino.validation.ui.conf; import java.lang.reflect.Field; import java.util.Comparator; @@ -22,15 +22,7 @@ import java.util.concurrent.PriorityBlockingQueue; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; -import javax.servlet.ServletContext; -import javax.servlet.ServletException; -import javax.servlet.ServletRegistration; - -import org.springframework.web.WebApplicationInitializer; -import org.springframework.web.context.support.AnnotationConfigWebApplicationContext; -import org.springframework.web.servlet.DispatcherServlet; - -public class AppInitializer implements WebApplicationInitializer { +public class UiUtils { private static final int QUEUE_CAPACITY = 500; private static final int EXECUTOR_SIZE = 20; // the number of threads to keep in the pool, even if @@ -43,29 +35,15 @@ public class AppInitializer implements WebApplicationInitializer { // terminating. private static final PriorityBlockingQueue BLOCKING_QUEUE = new PriorityBlockingQueue(QUEUE_CAPACITY, new CFRunnableComparator()); - public static ExecutorService executorService = new ThreadPoolExecutor(EXECUTOR_SIZE, - EXECUTOR_MAX_SIZE, KEEPALIVE_TIME, TimeUnit.SECONDS, BLOCKING_QUEUE); - - @Override - public void onStartup(ServletContext container) throws ServletException { - - AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext(); - ctx.register(AppConfig.class); - ctx.setServletContext(container); + public static ExecutorService executorService = + new ThreadPoolExecutor(EXECUTOR_SIZE, EXECUTOR_MAX_SIZE, KEEPALIVE_TIME, TimeUnit.SECONDS, BLOCKING_QUEUE); - ServletRegistration.Dynamic servlet = container.addServlet("dispatcher", new DispatcherServlet(ctx)); - - servlet.setLoadOnStartup(1); - servlet.addMapping("/"); - - } + public static final String NEXUS_URL = "https://nexus.akraino.org/content/sites/logs"; private static class CFRunnableComparator implements Comparator { @Override @SuppressWarnings("unchecked") public int compare(Runnable runnable1, Runnable runnable2) { - // T might be AsyncSupply, UniApply, etc., but we want to - // compare our original Runnables. return ((Comparable) unwrap(runnable1)).compareTo(unwrap(runnable2)); } @@ -73,8 +51,6 @@ public class AppInitializer implements WebApplicationInitializer { try { Field field = runnable.getClass().getDeclaredField("fn"); field.setAccessible(true); - // NB: For performance-intensive contexts, you may want to - // cache these in a ConcurrentHashMap, Field>. return field.get(runnable); } catch (IllegalAccessException | NoSuchFieldException e) { throw new IllegalArgumentException("Couldn't unwrap " + runnable, e);