@Test public void testInitWithoutServletContext() { new Expectations() {{ restPlugin.isEnabled(); result = false; initContext.dependency(RestPlugin.class); result = restPlugin; }}; underTest.init(initContext); }
@Override public InitState init(InitContext initContext) { RestPlugin restPlugin = initContext.dependency(RestPlugin.class); if (restPlugin.isEnabled()) { RestConfig restConfig = restPlugin.getRestConfig(); Set<Class<?>> resources = new HashSet<>(); Set<Class<?>> providers = new HashSet<>(); List<RestProvider> restProviders = initContext.dependencies(RestProvider.class); for (RestProvider restProvider : restProviders) { resources.addAll(restProvider.resources()); providers.addAll(filterClasses(restProvider.providers())); } if (LOGGER.isDebugEnabled()) { LOGGER.debug("{} JAX-RS resource(s) detected: {}", resources.size(), resources); } else { LOGGER.info("{} JAX-RS resource(s) detected (set logger to DEBUG to see them)", resources.size()); } if (LOGGER.isDebugEnabled()) { LOGGER.debug("{} JAX-RS provider(s) detected: {}", providers.size(), providers); } else { LOGGER.info("{} JAX-RS provider(s) detected (set logger to DEBUG to see them)", providers.size()); } Set<Class<?>> enabledFeatures = new HashSet<>(); if (isMultipartFeaturePresent()) { enabledFeatures.add(MultiPartFeature.class); LOGGER.debug("Multipart feature is enabled"); } if (isFreemarkerFeaturePresent()) { enabledFeatures.add(FreemarkerMvcFeature.class); LOGGER.debug("FreeMarker feature is enabled"); } if (isJspFeaturePresent()) { enabledFeatures.add(JspMvcFeature.class); LOGGER.debug("JSP feature is enabled"); } for (Class<?> featureClass : filterClasses(restConfig.getFeatures())) { enabledFeatures.add(featureClass); LOGGER.debug("Feature {} is enabled", featureClass.getCanonicalName()); } Map<String, Object> jersey2Properties = buildJerseyProperties(restConfig); if (LOGGER.isTraceEnabled()) { for (Map.Entry<String, Object> entry : jersey2Properties.entrySet()) { LOGGER.debug("Jersey property {} = {}", entry.getKey(), entry.getValue()); } } jersey2filterDefinition = new FilterDefinition("jersey2", SeedServletContainer.class); jersey2filterDefinition.setPriority(SeedFilterPriority.JERSEY); jersey2filterDefinition.setAsyncSupported(true); jersey2filterDefinition.addMappings(new FilterDefinition.Mapping(restConfig.getPath() + "/*")); jersey2filterDefinition.addInitParameters(buildInitParams(jersey2Properties)); seedServletContainer = new SeedServletContainer(resources, providers, enabledFeatures, jersey2Properties); LOGGER.info("Jersey 2 serving JAX-RS resources on {}/*", restConfig.getPath()); } return InitState.INITIALIZED; }
Jersey2Plugin extends AbstractPlugin implements WebProvider { @Override public InitState init(InitContext initContext) { RestPlugin restPlugin = initContext.dependency(RestPlugin.class); if (restPlugin.isEnabled()) { RestConfig restConfig = restPlugin.getRestConfig(); Set<Class<?>> resources = new HashSet<>(); Set<Class<?>> providers = new HashSet<>(); List<RestProvider> restProviders = initContext.dependencies(RestProvider.class); for (RestProvider restProvider : restProviders) { resources.addAll(restProvider.resources()); providers.addAll(filterClasses(restProvider.providers())); } if (LOGGER.isDebugEnabled()) { LOGGER.debug("{} JAX-RS resource(s) detected: {}", resources.size(), resources); } else { LOGGER.info("{} JAX-RS resource(s) detected (set logger to DEBUG to see them)", resources.size()); } if (LOGGER.isDebugEnabled()) { LOGGER.debug("{} JAX-RS provider(s) detected: {}", providers.size(), providers); } else { LOGGER.info("{} JAX-RS provider(s) detected (set logger to DEBUG to see them)", providers.size()); } Set<Class<?>> enabledFeatures = new HashSet<>(); if (isMultipartFeaturePresent()) { enabledFeatures.add(MultiPartFeature.class); LOGGER.debug("Multipart feature is enabled"); } if (isFreemarkerFeaturePresent()) { enabledFeatures.add(FreemarkerMvcFeature.class); LOGGER.debug("FreeMarker feature is enabled"); } if (isJspFeaturePresent()) { enabledFeatures.add(JspMvcFeature.class); LOGGER.debug("JSP feature is enabled"); } for (Class<?> featureClass : filterClasses(restConfig.getFeatures())) { enabledFeatures.add(featureClass); LOGGER.debug("Feature {} is enabled", featureClass.getCanonicalName()); } Map<String, Object> jersey2Properties = buildJerseyProperties(restConfig); if (LOGGER.isTraceEnabled()) { for (Map.Entry<String, Object> entry : jersey2Properties.entrySet()) { LOGGER.debug("Jersey property {} = {}", entry.getKey(), entry.getValue()); } } jersey2filterDefinition = new FilterDefinition("jersey2", SeedServletContainer.class); jersey2filterDefinition.setPriority(SeedFilterPriority.JERSEY); jersey2filterDefinition.setAsyncSupported(true); jersey2filterDefinition.addMappings(new FilterDefinition.Mapping(restConfig.getPath() + "/*")); jersey2filterDefinition.addInitParameters(buildInitParams(jersey2Properties)); seedServletContainer = new SeedServletContainer(resources, providers, enabledFeatures, jersey2Properties); LOGGER.info("Jersey 2 serving JAX-RS resources on {}/*", restConfig.getPath()); } return InitState.INITIALIZED; } }
Jersey2Plugin extends AbstractPlugin implements WebProvider { @Override public InitState init(InitContext initContext) { RestPlugin restPlugin = initContext.dependency(RestPlugin.class); if (restPlugin.isEnabled()) { RestConfig restConfig = restPlugin.getRestConfig(); Set<Class<?>> resources = new HashSet<>(); Set<Class<?>> providers = new HashSet<>(); List<RestProvider> restProviders = initContext.dependencies(RestProvider.class); for (RestProvider restProvider : restProviders) { resources.addAll(restProvider.resources()); providers.addAll(filterClasses(restProvider.providers())); } if (LOGGER.isDebugEnabled()) { LOGGER.debug("{} JAX-RS resource(s) detected: {}", resources.size(), resources); } else { LOGGER.info("{} JAX-RS resource(s) detected (set logger to DEBUG to see them)", resources.size()); } if (LOGGER.isDebugEnabled()) { LOGGER.debug("{} JAX-RS provider(s) detected: {}", providers.size(), providers); } else { LOGGER.info("{} JAX-RS provider(s) detected (set logger to DEBUG to see them)", providers.size()); } Set<Class<?>> enabledFeatures = new HashSet<>(); if (isMultipartFeaturePresent()) { enabledFeatures.add(MultiPartFeature.class); LOGGER.debug("Multipart feature is enabled"); } if (isFreemarkerFeaturePresent()) { enabledFeatures.add(FreemarkerMvcFeature.class); LOGGER.debug("FreeMarker feature is enabled"); } if (isJspFeaturePresent()) { enabledFeatures.add(JspMvcFeature.class); LOGGER.debug("JSP feature is enabled"); } for (Class<?> featureClass : filterClasses(restConfig.getFeatures())) { enabledFeatures.add(featureClass); LOGGER.debug("Feature {} is enabled", featureClass.getCanonicalName()); } Map<String, Object> jersey2Properties = buildJerseyProperties(restConfig); if (LOGGER.isTraceEnabled()) { for (Map.Entry<String, Object> entry : jersey2Properties.entrySet()) { LOGGER.debug("Jersey property {} = {}", entry.getKey(), entry.getValue()); } } jersey2filterDefinition = new FilterDefinition("jersey2", SeedServletContainer.class); jersey2filterDefinition.setPriority(SeedFilterPriority.JERSEY); jersey2filterDefinition.setAsyncSupported(true); jersey2filterDefinition.addMappings(new FilterDefinition.Mapping(restConfig.getPath() + "/*")); jersey2filterDefinition.addInitParameters(buildInitParams(jersey2Properties)); seedServletContainer = new SeedServletContainer(resources, providers, enabledFeatures, jersey2Properties); LOGGER.info("Jersey 2 serving JAX-RS resources on {}/*", restConfig.getPath()); } return InitState.INITIALIZED; }  }
Jersey2Plugin extends AbstractPlugin implements WebProvider { @Override public InitState init(InitContext initContext) { RestPlugin restPlugin = initContext.dependency(RestPlugin.class); if (restPlugin.isEnabled()) { RestConfig restConfig = restPlugin.getRestConfig(); Set<Class<?>> resources = new HashSet<>(); Set<Class<?>> providers = new HashSet<>(); List<RestProvider> restProviders = initContext.dependencies(RestProvider.class); for (RestProvider restProvider : restProviders) { resources.addAll(restProvider.resources()); providers.addAll(filterClasses(restProvider.providers())); } if (LOGGER.isDebugEnabled()) { LOGGER.debug("{} JAX-RS resource(s) detected: {}", resources.size(), resources); } else { LOGGER.info("{} JAX-RS resource(s) detected (set logger to DEBUG to see them)", resources.size()); } if (LOGGER.isDebugEnabled()) { LOGGER.debug("{} JAX-RS provider(s) detected: {}", providers.size(), providers); } else { LOGGER.info("{} JAX-RS provider(s) detected (set logger to DEBUG to see them)", providers.size()); } Set<Class<?>> enabledFeatures = new HashSet<>(); if (isMultipartFeaturePresent()) { enabledFeatures.add(MultiPartFeature.class); LOGGER.debug("Multipart feature is enabled"); } if (isFreemarkerFeaturePresent()) { enabledFeatures.add(FreemarkerMvcFeature.class); LOGGER.debug("FreeMarker feature is enabled"); } if (isJspFeaturePresent()) { enabledFeatures.add(JspMvcFeature.class); LOGGER.debug("JSP feature is enabled"); } for (Class<?> featureClass : filterClasses(restConfig.getFeatures())) { enabledFeatures.add(featureClass); LOGGER.debug("Feature {} is enabled", featureClass.getCanonicalName()); } Map<String, Object> jersey2Properties = buildJerseyProperties(restConfig); if (LOGGER.isTraceEnabled()) { for (Map.Entry<String, Object> entry : jersey2Properties.entrySet()) { LOGGER.debug("Jersey property {} = {}", entry.getKey(), entry.getValue()); } } jersey2filterDefinition = new FilterDefinition("jersey2", SeedServletContainer.class); jersey2filterDefinition.setPriority(SeedFilterPriority.JERSEY); jersey2filterDefinition.setAsyncSupported(true); jersey2filterDefinition.addMappings(new FilterDefinition.Mapping(restConfig.getPath() + "/*")); jersey2filterDefinition.addInitParameters(buildInitParams(jersey2Properties)); seedServletContainer = new SeedServletContainer(resources, providers, enabledFeatures, jersey2Properties); LOGGER.info("Jersey 2 serving JAX-RS resources on {}/*", restConfig.getPath()); } return InitState.INITIALIZED; }  @Override String name(); @Override Collection<Class<?>> requiredPlugins(); @Override InitState init(InitContext initContext); @Override Object nativeUnitModule(); @Override List<ServletDefinition> servlets(); @Override List<FilterDefinition> filters(); @Override List<ListenerDefinition> listeners(); }
Jersey2Plugin extends AbstractPlugin implements WebProvider { @Override public InitState init(InitContext initContext) { RestPlugin restPlugin = initContext.dependency(RestPlugin.class); if (restPlugin.isEnabled()) { RestConfig restConfig = restPlugin.getRestConfig(); Set<Class<?>> resources = new HashSet<>(); Set<Class<?>> providers = new HashSet<>(); List<RestProvider> restProviders = initContext.dependencies(RestProvider.class); for (RestProvider restProvider : restProviders) { resources.addAll(restProvider.resources()); providers.addAll(filterClasses(restProvider.providers())); } if (LOGGER.isDebugEnabled()) { LOGGER.debug("{} JAX-RS resource(s) detected: {}", resources.size(), resources); } else { LOGGER.info("{} JAX-RS resource(s) detected (set logger to DEBUG to see them)", resources.size()); } if (LOGGER.isDebugEnabled()) { LOGGER.debug("{} JAX-RS provider(s) detected: {}", providers.size(), providers); } else { LOGGER.info("{} JAX-RS provider(s) detected (set logger to DEBUG to see them)", providers.size()); } Set<Class<?>> enabledFeatures = new HashSet<>(); if (isMultipartFeaturePresent()) { enabledFeatures.add(MultiPartFeature.class); LOGGER.debug("Multipart feature is enabled"); } if (isFreemarkerFeaturePresent()) { enabledFeatures.add(FreemarkerMvcFeature.class); LOGGER.debug("FreeMarker feature is enabled"); } if (isJspFeaturePresent()) { enabledFeatures.add(JspMvcFeature.class); LOGGER.debug("JSP feature is enabled"); } for (Class<?> featureClass : filterClasses(restConfig.getFeatures())) { enabledFeatures.add(featureClass); LOGGER.debug("Feature {} is enabled", featureClass.getCanonicalName()); } Map<String, Object> jersey2Properties = buildJerseyProperties(restConfig); if (LOGGER.isTraceEnabled()) { for (Map.Entry<String, Object> entry : jersey2Properties.entrySet()) { LOGGER.debug("Jersey property {} = {}", entry.getKey(), entry.getValue()); } } jersey2filterDefinition = new FilterDefinition("jersey2", SeedServletContainer.class); jersey2filterDefinition.setPriority(SeedFilterPriority.JERSEY); jersey2filterDefinition.setAsyncSupported(true); jersey2filterDefinition.addMappings(new FilterDefinition.Mapping(restConfig.getPath() + "/*")); jersey2filterDefinition.addInitParameters(buildInitParams(jersey2Properties)); seedServletContainer = new SeedServletContainer(resources, providers, enabledFeatures, jersey2Properties); LOGGER.info("Jersey 2 serving JAX-RS resources on {}/*", restConfig.getPath()); } return InitState.INITIALIZED; }  @Override String name(); @Override Collection<Class<?>> requiredPlugins(); @Override InitState init(InitContext initContext); @Override Object nativeUnitModule(); @Override List<ServletDefinition> servlets(); @Override List<FilterDefinition> filters(); @Override List<ListenerDefinition> listeners();  }