Search in sources :

Example 1 with DatarouterInjector

use of io.datarouter.inject.DatarouterInjector in project datarouter by hotpads.

the class BaseDatarouterServletContextListener method buildExecuteOnActionsLists.

private void buildExecuteOnActionsLists(ServletContextEvent event) {
    DatarouterInjector injector = getInjector(event.getServletContext());
    Scanner.of(listenerClasses).map(injector::getInstance).forEach(allListeners::add);
    Scanner.of(webListenerClasses).map(injector::getInstance).each(listener -> listener.setServletContext(event.getServletContext())).forEach(allListeners::add);
    Scanner.of(allListeners).splitBy(DatarouterAppListener::safeToExecuteInParallel).map(Scanner::list).map(listeners -> new Pair<>(listeners.get(0).safeToExecuteInParallel() ? ExecutionMode.PARALLEL : ExecutionMode.SYNCHRONOUS, listeners)).forEach(listenersByExecutionMods::add);
}
Also used : DatarouterInjector(io.datarouter.inject.DatarouterInjector) Scanner(io.datarouter.scanner.Scanner) Logger(org.slf4j.Logger) ParallelScannerContext(io.datarouter.scanner.ParallelScannerContext) LoggerFactory(org.slf4j.LoggerFactory) Function(java.util.function.Function) Collectors(java.util.stream.Collectors) Executors(java.util.concurrent.Executors) ArrayList(java.util.ArrayList) NamedThreadFactory(io.datarouter.util.concurrent.NamedThreadFactory) List(java.util.List) ServletContextEvent(javax.servlet.ServletContextEvent) ExecutorServiceTool(io.datarouter.util.concurrent.ExecutorServiceTool) InjectorRetriever(io.datarouter.web.inject.InjectorRetriever) Duration(java.time.Duration) ThreadFactory(java.util.concurrent.ThreadFactory) Pair(io.datarouter.util.tuple.Pair) Collections(java.util.Collections) ServletContextListener(javax.servlet.ServletContextListener) ExecutorService(java.util.concurrent.ExecutorService) PhaseTimer(io.datarouter.util.timer.PhaseTimer) Scanner(io.datarouter.scanner.Scanner) DatarouterInjector(io.datarouter.inject.DatarouterInjector) Pair(io.datarouter.util.tuple.Pair)

Example 2 with DatarouterInjector

use of io.datarouter.inject.DatarouterInjector in project datarouter by hotpads.

the class RequestCachingFilter method init.

@Override
public void init(FilterConfig filterConfig) {
    DatarouterInjector injector = getInjector(filterConfig.getServletContext());
    webSettingRoot = injector.getInstance(DatarouterWebSettingRoot.class);
}
Also used : DatarouterInjector(io.datarouter.inject.DatarouterInjector) DatarouterWebSettingRoot(io.datarouter.web.config.DatarouterWebSettingRoot)

Example 3 with DatarouterInjector

use of io.datarouter.inject.DatarouterInjector in project datarouter by hotpads.

the class TraceFilter method init.

@Override
public void init(FilterConfig filterConfig) {
    DatarouterInjector injector = getInjector(filterConfig.getServletContext());
    serverName = injector.getInstance(ServerName.class);
    trace2BufferForLocal = injector.getInstance(Trace2ForLocalFilterToMemoryBuffer.class);
    trace2BufferForPublisher = injector.getInstance(Trace2ForPublisherFilterToMemoryBuffer.class);
    traceSettings = injector.getInstance(DatarouterTraceFilterSettingRoot.class);
    urlBuilder = injector.getInstance(TraceUrlBuilder.class);
    currentSessionInfo = injector.getInstance(CurrentSessionInfo.class);
    handlerMetrics = injector.getInstance(HandlerMetrics.class);
    serviceName = injector.getInstance(ServiceName.class);
}
Also used : Trace2ForLocalFilterToMemoryBuffer(io.datarouter.trace.conveyor.local.Trace2ForLocalFilterToMemoryBuffer) DatarouterInjector(io.datarouter.inject.DatarouterInjector) ServiceName(io.datarouter.web.config.service.ServiceName) ServerName(io.datarouter.storage.config.properties.ServerName) HandlerMetrics(io.datarouter.web.handler.HandlerMetrics) Trace2ForPublisherFilterToMemoryBuffer(io.datarouter.trace.conveyor.publisher.Trace2ForPublisherFilterToMemoryBuffer) DatarouterTraceFilterSettingRoot(io.datarouter.trace.settings.DatarouterTraceFilterSettingRoot) TraceUrlBuilder(io.datarouter.trace.service.TraceUrlBuilder) CurrentSessionInfo(io.datarouter.web.user.session.CurrentSessionInfo)

Example 4 with DatarouterInjector

use of io.datarouter.inject.DatarouterInjector in project datarouter by hotpads.

the class StaticFileFilter method init.

@Override
public void init(FilterConfig filterConfig) {
    this.filterConfig = filterConfig;
    this.requestDispatcher = filterConfig.getServletContext().getNamedDispatcher("default");
    DatarouterInjector injector = getInjector(filterConfig.getServletContext());
    staticFileFilterConfig = injector.getInstance(StaticFileFilterConfig.class);
}
Also used : DatarouterInjector(io.datarouter.inject.DatarouterInjector)

Aggregations

DatarouterInjector (io.datarouter.inject.DatarouterInjector)4 ParallelScannerContext (io.datarouter.scanner.ParallelScannerContext)1 Scanner (io.datarouter.scanner.Scanner)1 ServerName (io.datarouter.storage.config.properties.ServerName)1 Trace2ForLocalFilterToMemoryBuffer (io.datarouter.trace.conveyor.local.Trace2ForLocalFilterToMemoryBuffer)1 Trace2ForPublisherFilterToMemoryBuffer (io.datarouter.trace.conveyor.publisher.Trace2ForPublisherFilterToMemoryBuffer)1 TraceUrlBuilder (io.datarouter.trace.service.TraceUrlBuilder)1 DatarouterTraceFilterSettingRoot (io.datarouter.trace.settings.DatarouterTraceFilterSettingRoot)1 ExecutorServiceTool (io.datarouter.util.concurrent.ExecutorServiceTool)1 NamedThreadFactory (io.datarouter.util.concurrent.NamedThreadFactory)1 PhaseTimer (io.datarouter.util.timer.PhaseTimer)1 Pair (io.datarouter.util.tuple.Pair)1 DatarouterWebSettingRoot (io.datarouter.web.config.DatarouterWebSettingRoot)1 ServiceName (io.datarouter.web.config.service.ServiceName)1 HandlerMetrics (io.datarouter.web.handler.HandlerMetrics)1 InjectorRetriever (io.datarouter.web.inject.InjectorRetriever)1 CurrentSessionInfo (io.datarouter.web.user.session.CurrentSessionInfo)1 Duration (java.time.Duration)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1