9696import org .glassfish .jersey .model .internal .RankedComparator ;
9797import org .glassfish .jersey .model .internal .RankedComparator .Order ;
9898import org .glassfish .jersey .model .internal .RankedProvider ;
99+ import org .glassfish .jersey .process .internal .ChainableStage ;
99100import org .glassfish .jersey .process .internal .Stage ;
100101import org .glassfish .jersey .process .internal .Stages ;
101102import org .glassfish .jersey .server .internal .ConfigHelper ;
108109import org .glassfish .jersey .server .internal .monitoring .MonitoringContainerListener ;
109110import org .glassfish .jersey .server .internal .process .ReferencesInitializer ;
110111import org .glassfish .jersey .server .internal .process .RequestProcessingContext ;
111- import org .glassfish .jersey .server .internal .routing .RoutedInflectorExtractorStage ;
112- import org .glassfish .jersey .server .internal .routing .Router ;
113- import org .glassfish .jersey .server .internal .routing .RoutingStage ;
114- import org .glassfish .jersey .server .internal .routing .RuntimeModelBuilder ;
112+ import org .glassfish .jersey .server .internal .routing .Routing ;
115113import org .glassfish .jersey .server .model .ComponentModelValidator ;
116114import org .glassfish .jersey .server .model .ModelProcessor ;
117115import org .glassfish .jersey .server .model .ModelValidationException ;
118116import org .glassfish .jersey .server .model .Resource ;
119- import org .glassfish .jersey .server .model .ResourceMethodInvoker ;
120117import org .glassfish .jersey .server .model .ResourceModel ;
121118import org .glassfish .jersey .server .model .internal .ModelErrors ;
122119import org .glassfish .jersey .server .monitoring .ApplicationEvent ;
162159 * @author Jakub Podlesak (jakub.podlesak at oracle.com)
163160 * @author Marek Potociar (marek.potociar at oracle.com)
164161 * @author Libor Kramolis (libor.kramolis at oracle.com)
165- *
166162 * @see ResourceConfig
167163 * @see javax.ws.rs.core.Configuration
168164 * @see org.glassfish.jersey.server.spi.ContainerProvider
@@ -446,7 +442,9 @@ private void initialize() {
446442
447443 if (extScopes .length == 1 ) {
448444 for (final ComponentProvider p : componentProviders ) {
449- if (p .bind (extScopes [0 ], new HashSet <Class <?>>(){{add (ExternalRequestScope .class );}})) {
445+ if (p .bind (extScopes [0 ], new HashSet <Class <?>>() {{
446+ add (ExternalRequestScope .class );
447+ }})) {
450448 extScopesFound = true ;
451449 break ;
452450 }
@@ -463,7 +461,7 @@ private void initialize() {
463461
464462 if (!extScopesFound ) {
465463 final DynamicConfiguration configuration = Injections .getConfiguration (locator );
466- final ScopedBindingBuilder <ExternalRequestScope > binder = Injections .newBinder ((ExternalRequestScope )ServerRuntime .NOOP_EXTERNAL_REQ_SCOPE ).to (ExternalRequestScope .class );
464+ final ScopedBindingBuilder <ExternalRequestScope > binder = Injections .newBinder ((ExternalRequestScope ) ServerRuntime .NOOP_EXTERNAL_REQ_SCOPE ).to (ExternalRequestScope .class );
467465 Injections .addBinding (binder , configuration );
468466 configuration .commit ();
469467 }
@@ -474,7 +472,7 @@ private void initialize() {
474472 }
475473
476474 final Iterable <ApplicationEventListener > appEventListeners = Providers .getAllProviders (locator ,
477- ApplicationEventListener .class , new RankedComparator <ApplicationEventListener >());
475+ ApplicationEventListener .class , new RankedComparator <ApplicationEventListener >());
478476
479477 if (appEventListeners .iterator ().hasNext ()) {
480478 compositeListener = new CompositeApplicationEventListener (appEventListeners );
@@ -520,25 +518,20 @@ private void initialize() {
520518
521519 msgBodyWorkers = locator .getService (MessageBodyWorkers .class );
522520
523- final RuntimeModelBuilder runtimeModelBuilder = new RuntimeModelBuilder (locator , runtimeConfig , msgBodyWorkers ,
524- locator .getService (ResourceMethodInvoker .Builder .class ));
525- runtimeModelBuilder .setProcessingProviders (processingProviders );
526-
527521 // assembly request processing chain
528- /**
529- * Root hierarchical request matching acceptor.
530- * Invoked in a single linear stage as part of the main linear accepting chain.
531- */
532- final Router resourceRoutingRoot = runtimeModelBuilder .buildModel (resourceModel .getRuntimeResourceModel (), false );
533-
534522 final ReferencesInitializer referencesInitializer = locator .createAndInitialize (ReferencesInitializer .class );
535523 final ContainerFilteringStage preMatchRequestFilteringStage = new ContainerFilteringStage (
536524 processingProviders .getPreMatchFilters (),
537525 processingProviders .getGlobalResponseFilters ());
538- final RoutingStage routingStage = new RoutingStage (resourceRoutingRoot );
539- final ContainerFilteringStage resourceFilteringStage = new ContainerFilteringStage (
540- processingProviders .getGlobalRequestFilters (), null );
541- final RoutedInflectorExtractorStage routedInflectorExtractorStage = new RoutedInflectorExtractorStage ();
526+ final ChainableStage <RequestProcessingContext > routingStage = Routing .forModel (resourceModel .getRuntimeResourceModel ())
527+ .locator (locator )
528+ .resourceContext (jerseyResourceContext )
529+ .configuration (runtimeConfig )
530+ .entityProviders (msgBodyWorkers )
531+ .processingProviders (processingProviders )
532+ .buildStage ();
533+ final ContainerFilteringStage resourceFilteringStage =
534+ new ContainerFilteringStage (processingProviders .getGlobalRequestFilters (), null );
542535 /**
543536 * Root linear request acceptor. This is the main entry point for the whole request processing.
544537 */
@@ -547,7 +540,7 @@ private void initialize() {
547540 .to (preMatchRequestFilteringStage )
548541 .to (routingStage )
549542 .to (resourceFilteringStage )
550- .build (routedInflectorExtractorStage );
543+ .build (Routing . matchedEndpointExtractor () );
551544 this .runtime = locator .createAndInitialize (ServerRuntime .Builder .class )
552545 .build (rootStage , compositeListener , processingProviders );
553546
0 commit comments