org.glassfish.jersey.server.ServerProperties Java Examples

The following examples show how to use org.glassfish.jersey.server.ServerProperties. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JettyServerProvider.java    From browserup-proxy with Apache License 2.0 8 votes vote down vote up
@Inject
public JettyServerProvider(@Named("port") int port, @Named("address") String address, MitmProxyManager proxyManager) throws UnknownHostException {
    OpenApiResource openApiResource = new OpenApiResource();
    openApiResource.setConfigLocation(SWAGGER_CONFIG_NAME);

    ResourceConfig resourceConfig = new ResourceConfig();
    resourceConfig.packages(SWAGGER_PACKAGE);
    resourceConfig.register(openApiResource);
    resourceConfig.register(proxyManagerToHkBinder(proxyManager));
    resourceConfig.register(JacksonFeature.class);
    resourceConfig.register(ConstraintViolationExceptionMapper.class);
    resourceConfig.registerClasses(LoggingFilter.class);

    resourceConfig.property(ServerProperties.BV_SEND_ERROR_IN_RESPONSE, true);
    resourceConfig.property(ServerProperties.WADL_FEATURE_DISABLE, true);

    ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
    context.setContextPath("/");

    context.addFilter(GuiceFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));;
    context.addServlet(DefaultServlet.class, "/");
    context.addServlet(new ServletHolder(new ServletContainer(resourceConfig)), "/*");

    server = new Server(new InetSocketAddress(InetAddress.getByName(address), port));
    server.setHandler(context);
}
 
Example #2
Source File: JerseyConfig.java    From devicehive-java-server with Apache License 2.0 6 votes vote down vote up
public JerseyConfig() {
    scan("com.devicehive.resource.converters",
            "com.devicehive.resource.exceptions",
            "com.devicehive.resource.filter");

    registerClasses(PluginApiInfoResourceImpl.class,
            PluginResourceImpl.class);

    property(ServerProperties.BV_SEND_ERROR_IN_RESPONSE, true);

    register(RequestContextFilter.class);
    register(LoggingFeature.class);
    register(ContentTypeFilter.class);

    register(io.swagger.jaxrs.listing.ApiListingResource.class);
    register(io.swagger.jaxrs.listing.SwaggerSerializers.class);
}
 
Example #3
Source File: JerseyConfig.java    From devicehive-java-server with Apache License 2.0 6 votes vote down vote up
public JerseyConfig() {
    scan("com.devicehive.resource.converters",
            "com.devicehive.resource.exceptions",
            "com.devicehive.resource.filter");

    registerClasses(ApiInfoResourceImpl.class,
            ConfigurationResourceImpl.class,
            DeviceCommandResourceImpl.class,
            DeviceNotificationResourceImpl.class,
            DeviceResourceImpl.class,
            NetworkResourceImpl.class,
            DeviceTypeResourceImpl.class,
            WelcomeResourceImpl.class,
            UserResourceImpl.class);

    property(ServerProperties.BV_SEND_ERROR_IN_RESPONSE, true);

    register(RequestContextFilter.class);
    register(LoggingFeature.class);
    register(ContentTypeFilter.class);

    register(io.swagger.jaxrs.listing.ApiListingResource.class);
    register(io.swagger.jaxrs.listing.SwaggerSerializers.class);
}
 
Example #4
Source File: JerseyConfig.java    From devicehive-java-server with Apache License 2.0 6 votes vote down vote up
public JerseyConfig() {
    scan("com.devicehive.resource.converters",
            "com.devicehive.resource.exceptions",
            "com.devicehive.resource.filter");

    registerClasses(AuthApiInfoResourceImpl.class,
            JwtTokenResourceImpl.class);

    property(ServerProperties.BV_SEND_ERROR_IN_RESPONSE, true);

    register(RequestContextFilter.class);
    register(LoggingFeature.class);
    register(ContentTypeFilter.class);

    register(io.swagger.jaxrs.listing.ApiListingResource.class);
    register(io.swagger.jaxrs.listing.SwaggerSerializers.class);
}
 
Example #5
Source File: Jersey2Plugin.java    From seed with Mozilla Public License 2.0 6 votes vote down vote up
private Map<String, Object> buildJerseyProperties(RestConfig restConfig) {
    Map<String, Object> jerseyProperties = new HashMap<>();

    // Default configuration values
    jerseyProperties.put(ServletProperties.FILTER_FORWARD_ON_404, true);
    jerseyProperties.put(ServerProperties.WADL_FEATURE_DISABLE, true);

    // User-defined configuration values
    jerseyProperties.putAll(restConfig.getJerseyProperties());

    // Forced configuration values
    jerseyProperties.put(ServletProperties.FILTER_CONTEXT_PATH, restConfig.getPath());
    if (isJspFeaturePresent()) {
        jerseyProperties.put(JspMvcFeature.TEMPLATE_BASE_PATH, restConfig.getJspPath());
    }

    return jerseyProperties;
}
 
Example #6
Source File: HelixRestServer.java    From helix with Apache License 2.0 6 votes vote down vote up
protected ResourceConfig getResourceConfig(HelixRestNamespace namespace, ServletType type) {
  ResourceConfig cfg = new ResourceConfig();
  cfg.packages(type.getServletPackageArray());
  cfg.setApplicationName(namespace.getName());

  // Enable the default statistical monitoring MBean for Jersey server
  cfg.property(ServerProperties.MONITORING_STATISTICS_MBEANS_ENABLED, true);
  cfg.property(ContextPropertyKeys.SERVER_CONTEXT.name(),
      new ServerContext(namespace.getMetadataStoreAddress(), namespace.isMultiZkEnabled(),
          namespace.getMsdsEndpoint()));
  if (type == ServletType.DEFAULT_SERVLET) {
    cfg.property(ContextPropertyKeys.ALL_NAMESPACES.name(), _helixNamespaces);
  } else {
    cfg.property(ContextPropertyKeys.METADATA.name(), namespace);
  }

  cfg.register(new CORSFilter());
  cfg.register(new AuditLogFilter(_auditLoggers));
  return cfg;
}
 
Example #7
Source File: RestResourceConfig.java    From Cheddar with Apache License 2.0 6 votes vote down vote up
@Autowired
public RestResourceConfig(final ApplicationContext applicationContext) {
    property("contextConfig", applicationContext);
    scanner = new ClassPathScanningCandidateComponentProvider(true);
    scanner.resetFilters(false);
    scanner.addIncludeFilter(new AnnotationTypeFilter(Path.class));
    scanner.addIncludeFilter(new AnnotationTypeFilter(Provider.class));
    register(RequestContextFilter.class);
    register(MultiPartFeature.class);
    register(ObjectMapperProvider.class);
    register(JacksonFeature.class);
    registerResources("com.clicktravel.cheddar.rest.exception.mapper", "com.clicktravel.cheddar.server.http.filter",
            "com.clicktravel.cheddar.server.rest.resource.status", "com.clicktravel.services",
            "com.clicktravel.cheddar.rest.body.writer");
    property(ServerProperties.LOCATION_HEADER_RELATIVE_URI_RESOLUTION_DISABLED, true);
    property(ServerProperties.WADL_FEATURE_DISABLE, true);
}
 
Example #8
Source File: TajoRestService.java    From tajo with Apache License 2.0 6 votes vote down vote up
@Override
protected void serviceInit(Configuration conf) throws Exception {
  GsonFeature gsonFeature = new GsonFeature(PlanGsonHelper.registerAdapters());
  
  ClientApplication clientApplication = new ClientApplication(masterContext);
  ResourceConfig resourceConfig = ResourceConfig.forApplication(clientApplication)
      .register(gsonFeature)
      .register(LoggingFilter.class)
      .property(ServerProperties.FEATURE_AUTO_DISCOVERY_DISABLE, true)
      .property(ServerProperties.METAINF_SERVICES_LOOKUP_DISABLE, true);
  TajoConf tajoConf = (TajoConf) conf;

  InetSocketAddress address = tajoConf.getSocketAddrVar(TajoConf.ConfVars.REST_SERVICE_ADDRESS);
  URI restServiceURI = new URI("http", null, address.getHostName(), address.getPort(), "/rest", null, null);
  int workerCount = TajoConf.getIntVar(tajoConf, TajoConf.ConfVars.REST_SERVICE_RPC_SERVER_WORKER_THREAD_NUM);
  restServer = NettyRestServerFactory.createNettyRestServer(restServiceURI, resourceConfig, workerCount, false);

  super.serviceInit(conf);
  
  LOG.info("Tajo Rest Service initialized.");
}
 
Example #9
Source File: WebServerModule.java    From datacollector with Apache License 2.0 6 votes vote down vote up
@Provides(type = Type.SET)
ContextConfigurator provideJersey() {
  return new ContextConfigurator() {
    @Override
    public void init(ServletContextHandler context) {
      // REST API that requires authentication
      ServletHolder protectedRest = new ServletHolder(new ServletContainer());
      protectedRest.setInitParameter(
          ServerProperties.PROVIDER_PACKAGES, SWAGGER_PACKAGE + "," +
          RestAPI.class.getPackage().getName()
      );
      protectedRest.setInitParameter(ServletProperties.JAXRS_APPLICATION_CLASS, RestAPIResourceConfig.class.getName());
      context.addServlet(protectedRest, "/rest/*");

      RJson.configureRJsonForSwagger(Json.mapper());

      // REST API that it does not require authentication
      ServletHolder publicRest = new ServletHolder(new ServletContainer());
      publicRest.setInitParameter(ServerProperties.PROVIDER_PACKAGES, PublicRestAPI.class.getPackage().getName());
      publicRest.setInitParameter(ServletProperties.JAXRS_APPLICATION_CLASS, RestAPIResourceConfig.class.getName());
      context.addServlet(publicRest, "/public-rest/*");
    }
  };
}
 
Example #10
Source File: DisconnectedSSOManager.java    From datacollector with Apache License 2.0 6 votes vote down vote up
public void registerResources(ServletContextHandler handler) {
  ServletHolder jerseyServlet = new ServletHolder(ServletContainer.class);
  jerseyServlet.setInitParameter(ServerProperties.PROVIDER_PACKAGES, getClass().getPackage().getName());
  jerseyServlet.setInitParameter(
      ServletProperties.JAXRS_APPLICATION_CLASS,
      DisconnectedResourceConfig.class.getName()
  );
  handler.addServlet(jerseyServlet, SECURITY_RESOURCES);

  AuthenticationResourceHandler authenticationResourceHandler =
      new AuthenticationResourceHandler(getAuthentication(), false);

  handler.setAttribute(DISCONNECTED_SSO_AUTHENTICATION_HANDLER_ATTR, authenticationResourceHandler);

  handler.setAttribute(DISCONNECTED_SSO_SERVICE_ATTR, getSsoService());

  ServletHolder login = new ServletHolder(new DisconnectedLoginServlet((DisconnectedSSOService) getSsoService()));
  handler.addServlet(login, DisconnectedLoginServlet.URL_PATH);

  ServletHolder logout = new ServletHolder(new DisconnectedLogoutServlet((DisconnectedSSOService) getSsoService()));
  handler.addServlet(logout, DisconnectedLogoutServlet.URL_PATH);
}
 
Example #11
Source File: RESTServer.java    From pravega with Apache License 2.0 6 votes vote down vote up
public RESTServer(LocalController localController, ControllerService controllerService, AuthHandlerManager pravegaAuthManager, RESTServerConfig restServerConfig, ConnectionFactory connectionFactory) {
    this.objectId = "RESTServer";
    this.restServerConfig = restServerConfig;
    final String serverURI = "http://" + restServerConfig.getHost() + "/";
    this.baseUri = UriBuilder.fromUri(serverURI).port(restServerConfig.getPort()).build();

    final Set<Object> resourceObjs = new HashSet<>();
    resourceObjs.add(new PingImpl());
    resourceObjs.add(new StreamMetadataResourceImpl(localController, controllerService, pravegaAuthManager, connectionFactory));

    final ControllerApplication controllerApplication = new ControllerApplication(resourceObjs);
    this.resourceConfig = ResourceConfig.forApplication(controllerApplication);
    this.resourceConfig.property(ServerProperties.BV_SEND_ERROR_IN_RESPONSE, true);

    // Register the custom JSON parser.
    this.resourceConfig.register(new CustomObjectMapperProvider());

}
 
Example #12
Source File: BaseApplicaionConfig.java    From jeesuite-libs with Apache License 2.0 6 votes vote down vote up
public BaseApplicaionConfig() {
	//设置默认时区
	System.setProperty("user.timezone","Asia/Shanghai");
	
	register(ValidationContextResolver.class);
	property(ServerProperties.BV_SEND_ERROR_IN_RESPONSE, true);
    property(ServerProperties.BV_DISABLE_VALIDATE_ON_EXECUTABLE_OVERRIDE_CHECK, true);
			
	this.packages(packages());
	
	register(ObjectMapperResolver.class);
	register(JacksonFeature.class);
	register(JacksonJsonProvider.class);
	register(new BaseExceptionMapper(createExcetionWrapper()));
	register(RequestContextFilter.class);
	
	register(DefaultWebFilter.class);
	//
	if(FilterConfig.apiDocEnabled()){
		register(SwaggerSerializers.class);
	}
}
 
Example #13
Source File: MCRJerseyRestApp.java    From mycore with GNU General Public License v3.0 6 votes vote down vote up
protected MCRJerseyRestApp() {
    super();
    initAppName();
    property(ServerProperties.APPLICATION_NAME, getApplicationName());
    MCRJerseyDefaultConfiguration.setupGuiceBridge(this);
    String[] restPackages = getRestPackages();
    packages(restPackages);
    property(ServerProperties.RESPONSE_SET_STATUS_OVER_SEND_ERROR, true);
    register(MCRSessionFilter.class);
    register(MCRTransactionFilter.class);
    register(MultiPartFeature.class);
    register(MCRRestFeature.class);
    register(MCRCORSResponseFilter.class);
    register(MCRRequestScopeACLFilter.class);
    register(MCRIgnoreClientAbortInterceptor.class);
}
 
Example #14
Source File: KsqlRestApplication.java    From ksql-fork-with-deep-learning-function with Apache License 2.0 6 votes vote down vote up
@Override
public void configureBaseApplication(Configurable<?> config, Map<String, String> metricTags) {
  // Would call this but it registers additional, unwanted exception mappers
  // super.configureBaseApplication(config, metricTags);
  // Instead, just copy+paste the desired parts from Application.configureBaseApplication() here:
  JacksonMessageBodyProvider jsonProvider = new JacksonMessageBodyProvider(getJsonMapper());
  config.register(jsonProvider);
  config.register(JsonParseExceptionMapper.class);

  // Don't want to buffer rows when streaming JSON in a request to the query resource
  config.property(ServerProperties.OUTBOUND_CONTENT_LENGTH_BUFFER, 0);
  if (isUiEnabled) {
    loadUiWar();
    config.property(ServletProperties.FILTER_STATIC_CONTENT_REGEX, "/(static/.*|.*html)");
  }
}
 
Example #15
Source File: JerseyValidationTest.java    From parsec-libraries with Apache License 2.0 6 votes vote down vote up
@Override
protected Application configure() {
    //enable(TestProperties.LOG_TRAFFIC);
    //enable(TestProperties.DUMP_ENTITY);
    //
    // TODO: load web.xml directly
    // .property(
    //        "contextConfigLocation",
    //        "classpath:**/my-web-test-context.xml"
    //
    return new ResourceConfig(MyResource.class)
            .register(ParsecMoxyProvider.class)
            .register(JaxbExceptionMapper.class)
            .property(JaxbExceptionMapper.PROP_JAXB_DEFAULT_ERROR_CODE, JAXB_ERROR_CODE)
            .property(JaxbExceptionMapper.PROP_JAXB_DEFAULT_ERROR_MSG, JAXB_ERROR_MSG)
            .register(ValidationConfigurationContextResolver.class)
            .register(ParsecValidationExceptionMapper.class)
            .property(ParsecValidationExceptionMapper.PROP_VALIDATION_DEFAULT_ERROR_CODE, VALIDATION_ERROR_CODE)
            .property(ParsecValidationExceptionMapper.PROP_VALIDATION_DEFAULT_ERROR_MSG, VALIDATION_ERROR_MSG)
            .property(ServerProperties.METAINF_SERVICES_LOOKUP_DISABLE, true)
            .register(new MoxyJsonConfig().setFormattedOutput(true)
                    .property(MarshallerProperties.BEAN_VALIDATION_MODE, BeanValidationMode.NONE).resolver());

}
 
Example #16
Source File: NiFiRegistryResourceConfig.java    From nifi-registry with Apache License 2.0 6 votes vote down vote up
public NiFiRegistryResourceConfig(@Context ServletContext servletContext) {
    // register filters
    register(HttpMethodOverrideFilter.class);

    // register the exception mappers & jackson object mapper resolver
    packages("org.apache.nifi.registry.web.mapper");

    // register endpoints
    register(AccessPolicyResource.class);
    register(AccessResource.class);
    register(BucketResource.class);
    register(BucketFlowResource.class);
    register(BucketBundleResource.class);
    register(BundleResource.class);
    register(ExtensionResource.class);
    register(ExtensionRepoResource.class);
    register(FlowResource.class);
    register(ItemResource.class);
    register(TenantResource.class);
    register(ConfigResource.class);

    // register multipart feature
    register(MultiPartFeature.class);

    // include bean validation errors in response
    property(ServerProperties.BV_SEND_ERROR_IN_RESPONSE, true);

    // this is necessary for the /access/token/kerberos endpoint to work correctly
    // when sending 401 Unauthorized with a WWW-Authenticate: Negotiate header.
    // if this value needs to be changed, kerberos authentication needs to move to filter chain
    // so it can directly set the HttpServletResponse instead of indirectly through a JAX-RS Response
    property(ServerProperties.RESPONSE_SET_STATUS_OVER_SEND_ERROR, true);

    // configure jersey to ignore resource paths for actuator and swagger-ui
    property(ServletProperties.FILTER_STATIC_CONTENT_REGEX, "/(actuator|swagger/).*");
}
 
Example #17
Source File: JerseyApplication.java    From onedev with MIT License 6 votes vote down vote up
@Inject
public JerseyApplication(ServiceLocator serviceLocator) {
	GuiceBridge.getGuiceBridge().initializeGuiceBridge(serviceLocator);
	GuiceIntoHK2Bridge guiceBridge = serviceLocator.getService(GuiceIntoHK2Bridge.class);
    guiceBridge.bridgeGuiceInjector(AppLoader.injector);
    
    String disableMoxy = PropertiesHelper.getPropertyNameForRuntime(
    		CommonProperties.MOXY_JSON_FEATURE_DISABLE,
               getConfiguration().getRuntimeType());
       property(disableMoxy, true);
       property(ServerProperties.BV_SEND_ERROR_IN_RESPONSE, true);

       // add the default Jackson exception mappers
       register(JacksonFeature.class);
       
       packages(JerseyApplication.class.getPackage().getName());
       
    for (JerseyConfigurator configurator: AppLoader.getExtensions(JerseyConfigurator.class)) {
    	configurator.configure(this);
    }
}
 
Example #18
Source File: GrapheneRESTServer.java    From Graphene with GNU General Public License v3.0 6 votes vote down vote up
static ResourceConfig generateResourceConfig(Config config, Graphene graphene) {
	ResourceConfig rc = new ResourceConfig();

	// settings
	rc.property(ServerProperties.FEATURE_AUTO_DISCOVERY_DISABLE, true);
	rc.property(ServerProperties.BV_SEND_ERROR_IN_RESPONSE, true); // TODO: remove in production

	// basic features
	rc.register(CORSFilter.class);
	rc.register(JacksonFeature.class);
	rc.register(ValidationFeature.class);

	// custom resources
	GrapheneResourceFactory factory = new GrapheneResourceFactory(config, graphene);

	rc.register(factory.createResource(AdminResource.class));
	rc.register(factory.createResource(CoreferenceResource.class));
	rc.register(factory.createResource(DiscourseSimplificationResource.class));
	rc.register(factory.createResource(RelationExtractionResource.class));

	return rc;
}
 
Example #19
Source File: BaseApplicaionConfig.java    From azeroth with Apache License 2.0 6 votes vote down vote up
public BaseApplicaionConfig() {
    //设置默认时区
    System.setProperty("user.timezone", "Asia/Shanghai");

    register(ValidationContextResolver.class);
    property(ServerProperties.BV_SEND_ERROR_IN_RESPONSE, true);
    property(ServerProperties.BV_DISABLE_VALIDATE_ON_EXECUTABLE_OVERRIDE_CHECK, true);

    this.packages(packages());
    register(ObjectMapperResolver.class);
    register(JacksonFeature.class);
    register(JacksonJsonProvider.class);
    register(new BaseExceptionMapper(createExcetionWrapper()));
    register(RequestContextFilter.class);

    register(DefaultWebFilter.class);

    if (FilterConfig.apiDocEnabled()) {
        register(SwaggerSerializers.class);
    }
}
 
Example #20
Source File: APIServer.java    From dremio-oss with Apache License 2.0 6 votes vote down vote up
protected void init(ScanResult result) {
  // FILTERS
  register(JSONPrettyPrintFilter.class);
  register(MediaTypeFilter.class);

  // RESOURCES
  for (Class<?> resource : result.getAnnotatedClasses(APIResource.class)) {
    register(resource);
  }

  // FEATURES
  register(DACAuthFilterFeature.class);
  register(DACJacksonJaxbJsonFeature.class);
  register(DACExceptionMapperFeature.class);

  // EXCEPTION MAPPERS
  register(JsonParseExceptionMapper.class);
  register(JsonMappingExceptionMapper.class);

  // PROPERTIES
  property(ServerProperties.RESPONSE_SET_STATUS_OVER_SEND_ERROR, "true");

  final String disableMoxy = PropertiesHelper.getPropertyNameForRuntime(CommonProperties.MOXY_JSON_FEATURE_DISABLE,
    getConfiguration().getRuntimeType());
  property(disableMoxy, true);
}
 
Example #21
Source File: ManagementApplication.java    From graviteeio-access-management with Apache License 2.0 5 votes vote down vote up
public ManagementApplication() {

        BeanConfig beanConfig = new BeanConfig();
        beanConfig.setVersion(Version.RUNTIME_VERSION.MAJOR_VERSION);
        beanConfig.setResourcePackage("io.gravitee.am.management.handlers.management.api.resources");
        beanConfig.setTitle("Gravitee.io - Access Management API");
        beanConfig.setBasePath("/management");
        beanConfig.setScan(true);

        register(OrganizationsResource.class);
        register(PlatformResource.class);
        register(CurrentUserResource.class);

        register(ObjectMapperResolver.class);
        register(ManagementExceptionMapper.class);
        register(UnrecognizedPropertyExceptionMapper.class);
        register(ThrowableMapper.class);
        register(ClientErrorExceptionMapper.class);
        register(Oauth2ExceptionMapper.class);
        register(ValidationExceptionMapper.class);
        register(JsonMappingExceptionMapper.class);
        register(WebApplicationExceptionMapper.class);

        register(UriBuilderRequestFilter.class);
        register(ByteArrayOutputStreamWriter.class);

        register(ApiListingResource.class);
        register(SwaggerSerializers.class);

        property(ServerProperties.BV_SEND_ERROR_IN_RESPONSE, true);
    }
 
Example #22
Source File: MetricsHttpServer.java    From metrics with Apache License 2.0 5 votes vote down vote up
public void start() {
        URI baseUri = UriBuilder.fromUri("http://localhost/").port(getPort()).build();

        Logger jerseyLogger = Logger.getLogger("org.glassfish.jersey");
        jerseyLogger.setLevel(Level.WARNING);

        resourceConfig.register(MetricsResource.class)
                .register(MetricsController.class)
                .property(ServerProperties.TRACING, TracingConfig.ON_DEMAND.name())
//                .register(new LoggingFilter(jerseyLogger, false))
                .register(new LoggingFeature(jerseyLogger))
                .register(JerseyEventListener.class)
                .register(FastJsonFeature.class);


        String bindingHost = System.getProperty(ALI_METRICS_BINDING_HOST, DEFAULT_BINDING_HOST);

        // set up map request response time for http server
        // http server will run a dedicated thread to check if the connection are expired and close them
        if (System.getProperty("sun.net.httpserver.maxReqTime") == null) {
            // set max time in seconds to wait for a request to finished
            System.setProperty("sun.net.httpserver.maxReqTime", "30");
        }
        if (System.getProperty("sun.net.httpserver.maxRspTime") == null) {
            // set max time in seconds to wait for a response to finished
            System.setProperty("sun.net.httpserver.maxRspTime", "30");
        }

        try {
            Class fastJsonAutoDiscoverClass = MetricsHttpServer.class.getClassLoader()
                    .loadClass("com.alibaba.fastjson.support.jaxrs.FastJsonAutoDiscoverable");
            Field autoDscoverField = fastJsonAutoDiscoverClass.getField("autoDiscover");
            autoDscoverField.set(null, false);
        } catch (Exception e) {
            // ignore
        }

        httpServer = HttpServerFactory.createHttpServer(baseUri, bindingHost, corePoolSize, maxPoolSize,
                keepAliveTimeout, maxQueueSize, resourceConfig);
    }
 
Example #23
Source File: JerseyConfig.java    From boot-makeover with Apache License 2.0 5 votes vote down vote up
public JerseyConfig() {
    property(ServerProperties.BV_SEND_ERROR_IN_RESPONSE, true);
    property(ServerProperties.JSON_PROCESSING_FEATURE_DISABLE, false);
    property(ServerProperties.MOXY_JSON_FEATURE_DISABLE, true);
    property(ServerProperties.WADL_FEATURE_DISABLE, true);
    register(LoggingFilter.class);
    register(JacksonFeature.class);
    register(HelloService.class);
}
 
Example #24
Source File: MetricsResourceMethodApplicationListenerIntegrationTest.java    From rest-utils with Apache License 2.0 5 votes vote down vote up
@Override
public void setupResources(Configurable<?> config, TestRestConfig appConfig) {
  resourceConfig = config;
  config.register(PrivateResource.class);
  // ensures the dispatch error message gets shown in the response
  // as opposed to a generic error page
  config.property(ServerProperties.RESPONSE_SET_STATUS_OVER_SEND_ERROR, true);
}
 
Example #25
Source File: Application.java    From rest-utils with Apache License 2.0 5 votes vote down vote up
/**
 * Register standard components for a JSON REST application on the given JAX-RS configurable,
 * which can be either an ResourceConfig for a server or a ClientConfig for a Jersey-based REST
 * client.
 */
public void configureBaseApplication(Configurable<?> config, Map<String, String> metricTags) {
  T restConfig = getConfiguration();

  registerJsonProvider(config, restConfig, true);
  registerFeatures(config, restConfig);
  registerExceptionMappers(config, restConfig);

  config.register(new MetricsResourceMethodApplicationListener(getMetrics(), "jersey",
                                                               metricTags, restConfig.getTime()));

  config.property(ServerProperties.BV_SEND_ERROR_IN_RESPONSE, true);
  config.property(ServerProperties.WADL_FEATURE_DISABLE, true);
}
 
Example #26
Source File: MockApplication.java    From ksql-fork-with-deep-learning-function with Apache License 2.0 5 votes vote down vote up
@Override
public void setupResources(Configurable<?> configurable, KsqlRestConfig ksqlRestConfig) {
  configurable.register(new MockKsqlResources());
  configurable.register(streamedQueryResource);
  configurable.register(new MockStatusResource());
  configurable.property(ServerProperties.OUTBOUND_CONTENT_LENGTH_BUFFER, 0);
}
 
Example #27
Source File: ExceptionMapperTest.java    From sinavi-jfw with Apache License 2.0 5 votes vote down vote up
public static Application config() {
    return new ResourceConfig().property(ServerProperties.JSON_PROCESSING_FEATURE_DISABLE, true)
        .packages("jp.co.ctc_g.jse.core.rest.jersey")
        .register(ValidationConfigurationContextResolver.class)
        .register(LocaleContextFilter.class)
        .register(ObjectMapperProviderTest.class)
        .register(JacksonFeature.class);
}
 
Example #28
Source File: Application.java    From ameba with MIT License 5 votes vote down vote up
private void configureServer() {
    jmxEnabled = Boolean.parseBoolean((String) getProperty("jmx.enabled"));
    if (jmxEnabled && getProperty(ServerProperties.MONITORING_STATISTICS_MBEANS_ENABLED) == null)
        property(ServerProperties.MONITORING_STATISTICS_MBEANS_ENABLED, jmxEnabled);

    subscribeServerEvent();
}
 
Example #29
Source File: ValidationFeature.java    From ameba with MIT License 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public boolean configure(final FeatureContext context) {
    // disable Jersey default BeanValidation feature
    context.property(ServerProperties.BV_FEATURE_DISABLE, "true");
    context.register(new ValidationBinder())
            .register(ValidationExceptionMapper.class)
            .register(ValidationConfigurationContextResolver.class);
    return true;
}
 
Example #30
Source File: JerseyApplication.java    From XBDD with Apache License 2.0 5 votes vote down vote up
public JerseyApplication() {

		// Need to register all resources manually as spring fat jar doesn't like the resource scanning
		register(AdminUtils.class);
		register(Attachment.class);
		register(AutomationStatistics.class);
		register(BuildReOrdering.class);
		register(Environment.class);
		register(Favourites.class);
		register(Feature.class);
		register(MergeBuilds.class);
		register(Presence.class);
		register(PrintPDF.class);
		register(Recents.class);
		register(Report.class);
		register(Search.class);
		register(Stats.class);
		register(TagView.class);
		register(UploadAttachment.class);
		register(UserResource.class);

		EncodingFilter.enableFor(this, GZipEncoder.class);

		register(MultiPartFeature.class);

		property(ServerProperties.TRACING, TracingConfig.ON_DEMAND.name());
	}