org.glassfish.jersey.media.multipart.MultiPartFeature Java Examples
The following examples show how to use
org.glassfish.jersey.media.multipart.MultiPartFeature.
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: ApiClient.java From openapi-generator with Apache License 2.0 | 8 votes |
/** * Build the Client used to make HTTP requests. * @param debugging Debug setting * @return Client */ protected Client buildHttpClient(boolean debugging) { final ClientConfig clientConfig = new ClientConfig(); clientConfig.register(MultiPartFeature.class); clientConfig.register(json); clientConfig.register(JacksonFeature.class); clientConfig.property(HttpUrlConnectorProvider.SET_METHOD_WORKAROUND, true); // turn off compliance validation to be able to send payloads with DELETE calls clientConfig.property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true); if (debugging) { clientConfig.register(new LoggingFeature(java.util.logging.Logger.getLogger(LoggingFeature.DEFAULT_LOGGER_NAME), java.util.logging.Level.INFO, LoggingFeature.Verbosity.PAYLOAD_ANY, 1024*50 /* Log payloads up to 50K */)); clientConfig.property(LoggingFeature.LOGGING_FEATURE_VERBOSITY, LoggingFeature.Verbosity.PAYLOAD_ANY); // Set logger to ALL java.util.logging.Logger.getLogger(LoggingFeature.DEFAULT_LOGGER_NAME).setLevel(java.util.logging.Level.ALL); } else { // suppress warnings for payloads with DELETE calls: java.util.logging.Logger.getLogger("org.glassfish.jersey.client").setLevel(java.util.logging.Level.SEVERE); } performAdditionalClientConfiguration(clientConfig); ClientBuilder clientBuilder = ClientBuilder.newBuilder(); customizeClientBuilder(clientBuilder); clientBuilder = clientBuilder.withConfig(clientConfig); return clientBuilder.build(); }
Example #2
Source File: AdminApiKeyStoreTlsAuthTest.java From pulsar with Apache License 2.0 | 6 votes |
WebTarget buildWebClient() throws Exception { ClientConfig httpConfig = new ClientConfig(); httpConfig.property(ClientProperties.FOLLOW_REDIRECTS, true); httpConfig.property(ClientProperties.ASYNC_THREADPOOL_SIZE, 8); httpConfig.register(MultiPartFeature.class); ClientBuilder clientBuilder = ClientBuilder.newBuilder().withConfig(httpConfig) .register(JacksonConfigurator.class).register(JacksonFeature.class); SSLContext sslCtx = KeyStoreSSLContext.createClientSslContext( KEYSTORE_TYPE, CLIENT_KEYSTORE_FILE_PATH, CLIENT_KEYSTORE_PW, KEYSTORE_TYPE, BROKER_TRUSTSTORE_FILE_PATH, BROKER_TRUSTSTORE_PW); clientBuilder.sslContext(sslCtx).hostnameVerifier(NoopHostnameVerifier.INSTANCE); Client client = clientBuilder.build(); return client.target(brokerUrlTls.toString()); }
Example #3
Source File: Server.java From Stargraph with MIT License | 6 votes |
void start() { try { Config config = stargraph.getMainConfig(); String urlStr = config.getString("networking.rest-url"); ResourceConfig rc = new ResourceConfig(); rc.register(LoggingFilter.class); rc.register(JacksonFeature.class); rc.register(MultiPartFeature.class); rc.register(CatchAllExceptionMapper.class); rc.register(SerializationExceptionMapper.class); rc.register(AdminResourceImpl.class); rc.register(new KBResourceImpl(stargraph)); rc.register(new QueryResourceImpl(stargraph)); httpServer = GrizzlyHttpServerFactory.createHttpServer(URI.create(urlStr), rc, true); logger.info(marker, "Stargraph listening on {}", urlStr); } catch (Exception e) { throw new StarGraphException(e); } }
Example #4
Source File: TestMultiMaster.java From dremio-oss with Apache License 2.0 | 6 votes |
private static Client newClient() { JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider(); ObjectMapper objectMapper = JSONUtil.prettyMapper(); JSONUtil.registerStorageTypes(objectMapper, DremioTest.CLASSPATH_SCAN_RESULT, ConnectionReader.of(DremioTest.CLASSPATH_SCAN_RESULT, DremioTest.DEFAULT_SABOT_CONFIG)); objectMapper.registerModule( new SimpleModule() .addDeserializer(JobDataFragment.class, new JsonDeserializer<JobDataFragment>() { @Override public JobDataFragment deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException { return jsonParser.readValueAs(DataPOJO.class); } } ) ); provider.setMapper(objectMapper); return ClientBuilder.newBuilder().register(provider).register(MultiPartFeature.class).build(); }
Example #5
Source File: AdminApiTlsAuthTest.java From pulsar with Apache License 2.0 | 6 votes |
WebTarget buildWebClient(String user) throws Exception { ClientConfig httpConfig = new ClientConfig(); httpConfig.property(ClientProperties.FOLLOW_REDIRECTS, true); httpConfig.property(ClientProperties.ASYNC_THREADPOOL_SIZE, 8); httpConfig.register(MultiPartFeature.class); ClientBuilder clientBuilder = ClientBuilder.newBuilder().withConfig(httpConfig) .register(JacksonConfigurator.class).register(JacksonFeature.class); X509Certificate trustCertificates[] = SecurityUtility.loadCertificatesFromPemFile( getTLSFile("ca.cert")); SSLContext sslCtx = SecurityUtility.createSslContext( false, trustCertificates, SecurityUtility.loadCertificatesFromPemFile(getTLSFile(user + ".cert")), SecurityUtility.loadPrivateKeyFromPemFile(getTLSFile(user + ".key-pk8"))); clientBuilder.sslContext(sslCtx).hostnameVerifier(NoopHostnameVerifier.INSTANCE); Client client = clientBuilder.build(); return client.target(brokerUrlTls.toString()); }
Example #6
Source File: NiFiRegistryResourceConfig.java From nifi-registry with Apache License 2.0 | 6 votes |
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 #7
Source File: MCRJerseyRestApp.java From mycore with GNU General Public License v3.0 | 6 votes |
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 #8
Source File: TestMasterDown.java From dremio-oss with Apache License 2.0 | 6 votes |
private static void initMasterClient() { JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider(); ObjectMapper objectMapper = JSONUtil.prettyMapper(); JSONUtil.registerStorageTypes(objectMapper, DremioTest.CLASSPATH_SCAN_RESULT, ConnectionReader.of(DremioTest.CLASSPATH_SCAN_RESULT, DremioTest.DEFAULT_SABOT_CONFIG)); objectMapper.registerModule( new SimpleModule() .addDeserializer(JobDataFragment.class, new JsonDeserializer<JobDataFragment>() { @Override public JobDataFragment deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException { return jsonParser.readValueAs(DataPOJO.class); } } ) ); provider.setMapper(objectMapper); masterClient = ClientBuilder.newBuilder().register(provider).register(MultiPartFeature.class).build(); WebTarget rootTarget = masterClient.target("http://localhost:" + masterDremioDaemon.getWebServer().getPort()); masterApiV2 = rootTarget.path(API_LOCATION); }
Example #9
Source File: SFAPIEntryPoint.java From sailfish-core with Apache License 2.0 | 6 votes |
public SFAPIEntryPoint() { register(MultiPartFeature.class); register(ServiceResource.class); register(MatrixResource.class); register(DictionaryResource.class); register(SFRestApiListener.class); register(ResponseResolver.class); register(TestscriptRunResource.class); register(EnvironmentResource.class); register(ActionsResource.class); register(StatisticsResource.class); register(MachineLearningResource.class); register(MachineLearningResourceV2.class); register(BigButtonResource.class); register(TestLibraryResource.class); register(SailfishInfoResource.class); register(JacksonFeature.class); register(StorageResource.class); register(InternalResources.class); register(VariableSetsResource.class); register(ConfigurationResource.class); register(CommonExceptionMapper.class); register(WebApplicationExceptionMapper.class); }
Example #10
Source File: NulsResourceConfig.java From nuls with MIT License | 6 votes |
public NulsResourceConfig() { register(io.swagger.jaxrs.listing.ApiListingResource.class); register(io.swagger.jaxrs.listing.AcceptHeaderApiListingResource.class); register(NulsSwaggerSerializers.class); register(MultiPartFeature.class); register(RpcServerFilter.class); register(JacksonJsonProvider.class); Collection<Object> list = SpringLiteContext.getAllBeanList(); for (Object object : list) { if (object.getClass().getAnnotation(Path.class) != null) { Log.debug("register restFul resource:{}", object.getClass()); register(object); } } }
Example #11
Source File: TestMasterDown.java From dremio-oss with Apache License 2.0 | 6 votes |
private static void initClient() { JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider(); ObjectMapper objectMapper = JSONUtil.prettyMapper(); JSONUtil.registerStorageTypes(objectMapper, DremioTest.CLASSPATH_SCAN_RESULT, ConnectionReader.of(DremioTest.CLASSPATH_SCAN_RESULT, DremioTest.DEFAULT_SABOT_CONFIG)); objectMapper.registerModule( new SimpleModule() .addDeserializer(JobDataFragment.class, new JsonDeserializer<JobDataFragment>() { @Override public JobDataFragment deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException { return jsonParser.readValueAs(DataPOJO.class); } } ) ); provider.setMapper(objectMapper); client = ClientBuilder.newBuilder().register(provider).register(MultiPartFeature.class).build(); WebTarget rootTarget = client.target("http://localhost:" + currentDremioDaemon.getWebServer().getPort()); currentApiV2 = rootTarget.path(API_LOCATION); }
Example #12
Source File: RecordPermissionsRestTest.java From mobi with GNU Affero General Public License v3.0 | 6 votes |
@Override protected Application configureApp() throws Exception { MockitoAnnotations.initMocks(this); vf = getValueFactory(); recordJson = IOUtils.toString(getClass().getResourceAsStream("/recordPolicy.json"), "UTF-8"); recordIRI = vf.createIRI("http://mobi.com/records/testRecord1"); recordPolicyIRI = vf.createIRI("http://mobi.com/policies/record/https%3A%2F%2Fmobi.com%2Frecords%testRecord1"); policyPolicyIRI = vf.createIRI("http://mobi.com/policies/policy/record/https%3A%2F%2Fmobi.com%2Frecords%testRecord1"); invalidIRI = vf.createIRI("urn:invalidRecordId"); IRI type = vf.createIRI("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"); IRI policyType = vf.createIRI(Policy.TYPE); recordStatement = vf.createStatement(recordPolicyIRI, type, policyType); policyStatement = vf.createStatement(policyPolicyIRI, type, policyType); rest = new RecordPermissionsRest(); rest.setVf(vf); rest.setPolicyManager(policyManager); rest.setRepo(repo); return new ResourceConfig() .register(rest) .register(UsernameTestFilter.class) .register(MultiPartFeature.class); }
Example #13
Source File: ApiClient.java From cyberduck with GNU General Public License v3.0 | 6 votes |
/** * Build the Client used to make HTTP requests. * @param debugging Debug setting * @return Client */ protected Client buildHttpClient(boolean debugging) { final ClientConfig clientConfig = new ClientConfig(); clientConfig.register(MultiPartFeature.class); clientConfig.register(json); clientConfig.register(JacksonFeature.class); clientConfig.property(HttpUrlConnectorProvider.SET_METHOD_WORKAROUND, true); if (debugging) { clientConfig.register(new LoggingFeature(java.util.logging.Logger.getLogger(LoggingFeature.DEFAULT_LOGGER_NAME), java.util.logging.Level.INFO, LoggingFeature.Verbosity.PAYLOAD_ANY, 1024*50 /* Log payloads up to 50K */)); clientConfig.property(LoggingFeature.LOGGING_FEATURE_VERBOSITY, LoggingFeature.Verbosity.PAYLOAD_ANY); // Set logger to ALL java.util.logging.Logger.getLogger(LoggingFeature.DEFAULT_LOGGER_NAME).setLevel(java.util.logging.Level.ALL); } performAdditionalClientConfiguration(clientConfig); return ClientBuilder.newClient(clientConfig); }
Example #14
Source File: EmissaryServer.java From emissary with Apache License 2.0 | 6 votes |
private ContextHandler buildMVCHandler() { final ResourceConfig application = new ResourceConfig(); application.register(MultiPartFeature.class); // setup mustache templates application.property(MustacheMvcFeature.TEMPLATE_BASE_PATH, "/templates"); application.register(MustacheMvcFeature.class).packages("emissary.server.mvc"); ServletHolder mvcHolder = new ServletHolder(new org.glassfish.jersey.servlet.ServletContainer(application)); // mvcHolder.setInitOrder(1); ServletContextHandler mvcHolderContext = new ServletContextHandler(ServletContextHandler.SESSIONS); mvcHolderContext.addServlet(mvcHolder, "/*"); return mvcHolderContext; }
Example #15
Source File: DelimitedRestTest.java From mobi with GNU Affero General Public License v3.0 | 6 votes |
@Override protected Application configureApp() throws Exception { vf = getValueFactory(); mf = getModelFactory(); OrmFactory<User> userFactory = getRequiredOrmFactory(User.class); user = userFactory.createNew(vf.createIRI("http://mobi.com/users/" + UsernameTestFilter.USERNAME)); MockitoAnnotations.initMocks(this); rest = new DelimitedRest(); rest.setDelimitedConverter(converter); rest.setMappingManager(mappingManager); rest.setEngineManager(engineManager); rest.setVf(vf); rest.setTransformer(transformer); rest.setRdfImportService(rdfImportService); rest.setOntologyImportService(ontologyImportService); rest.start(); return new ResourceConfig() .register(rest) .register(MultiPartFeature.class) .register(UsernameTestFilter.class); }
Example #16
Source File: ApiClient.java From openapi-generator with Apache License 2.0 | 6 votes |
/** * Build the Client used to make HTTP requests. * @param debugging Debug setting * @return Client */ protected Client buildHttpClient(boolean debugging) { final ClientConfig clientConfig = new ClientConfig(); clientConfig.register(MultiPartFeature.class); clientConfig.register(json); clientConfig.register(JacksonFeature.class); clientConfig.property(HttpUrlConnectorProvider.SET_METHOD_WORKAROUND, true); // turn off compliance validation to be able to send payloads with DELETE calls clientConfig.property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true); if (debugging) { clientConfig.register(new LoggingFeature(java.util.logging.Logger.getLogger(LoggingFeature.DEFAULT_LOGGER_NAME), java.util.logging.Level.INFO, LoggingFeature.Verbosity.PAYLOAD_ANY, 1024*50 /* Log payloads up to 50K */)); clientConfig.property(LoggingFeature.LOGGING_FEATURE_VERBOSITY, LoggingFeature.Verbosity.PAYLOAD_ANY); // Set logger to ALL java.util.logging.Logger.getLogger(LoggingFeature.DEFAULT_LOGGER_NAME).setLevel(java.util.logging.Level.ALL); } else { // suppress warnings for payloads with DELETE calls: java.util.logging.Logger.getLogger("org.glassfish.jersey.client").setLevel(java.util.logging.Level.SEVERE); } performAdditionalClientConfiguration(clientConfig); ClientBuilder clientBuilder = ClientBuilder.newBuilder(); customizeClientBuilder(clientBuilder); clientBuilder = clientBuilder.withConfig(clientConfig); return clientBuilder.build(); }
Example #17
Source File: ApiClient.java From cyberduck with GNU General Public License v3.0 | 6 votes |
/** * Build the Client used to make HTTP requests. * @param debugging Debug setting * @return Client */ protected Client buildHttpClient(boolean debugging) { final ClientConfig clientConfig = new ClientConfig(); clientConfig.register(MultiPartFeature.class); clientConfig.register(json); clientConfig.register(JacksonFeature.class); clientConfig.property(HttpUrlConnectorProvider.SET_METHOD_WORKAROUND, true); if(debugging) { clientConfig.register(new LoggingFeature(java.util.logging.Logger.getLogger(LoggingFeature.DEFAULT_LOGGER_NAME), java.util.logging.Level.INFO, LoggingFeature.Verbosity.PAYLOAD_ANY, 1024 * 50 /* Log payloads up to 50K */)); clientConfig.property(LoggingFeature.LOGGING_FEATURE_VERBOSITY, LoggingFeature.Verbosity.PAYLOAD_ANY); // Set logger to ALL java.util.logging.Logger.getLogger(LoggingFeature.DEFAULT_LOGGER_NAME).setLevel(java.util.logging.Level.ALL); } performAdditionalClientConfiguration(clientConfig); return ClientBuilder.newClient(clientConfig); }
Example #18
Source File: MattermostClient.java From mattermost4j with Apache License 2.0 | 6 votes |
protected Client buildClient(Consumer<ClientBuilder> httpClientConfig) { ClientBuilder builder = ClientBuilder.newBuilder() .register(new MattermostModelMapperProvider(ignoreUnknownProperties)) .register(JacksonFeature.class).register(MultiPartFeature.class) // needs for PUT request with null entity // (/commands/{command_id}/regen_token) .property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true); if (clientLogLevel != null) { builder.register(new LoggingFeature(Logger.getLogger(getClass().getName()), clientLogLevel, Verbosity.PAYLOAD_ANY, 100000)); } httpClientConfig.accept(builder); return builder.build(); }
Example #19
Source File: WebClient.java From dremio-oss with Apache License 2.0 | 6 votes |
private WebTarget getWebClient( DACConfig dacConfig) throws IOException, GeneralSecurityException { final JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider(); provider.setMapper(JSONUtil.prettyMapper()); ClientBuilder clientBuilder = ClientBuilder.newBuilder() .register(provider) .register(MultiPartFeature.class); if (dacConfig.webSSLEnabled()) { this.setTrustStore(clientBuilder, dacConfig); } final Client client = clientBuilder.build(); return client.target(format("%s://%s:%d", dacConfig.webSSLEnabled() ? "https" : "http", dacConfig.thisNode, dacConfig.getHttpPort())).path("apiv2"); }
Example #20
Source File: WebService.java From pulsar with Apache License 2.0 | 5 votes |
public void addRestResources(String basePath, String javaPackages, boolean requiresAuthentication, Map<String,Object> attributeMap) { ResourceConfig config = new ResourceConfig(); config.packages("jersey.config.server.provider.packages", javaPackages); config.register(JsonMapperProvider.class); config.register(MultiPartFeature.class); ServletHolder servletHolder = new ServletHolder(new ServletContainer(config)); servletHolder.setAsyncSupported(true); addServlet(basePath, servletHolder, requiresAuthentication, attributeMap); }
Example #21
Source File: CommitRestTest.java From mobi with GNU Affero General Public License v3.0 | 5 votes |
@Override protected Application configureApp() throws Exception { vf = getValueFactory(); mf = getModelFactory(); typeIRI = vf.createIRI(com.mobi.ontologies.rdfs.Resource.type_IRI); recordFactory = getRequiredOrmFactory(Record.class); OrmFactory<Commit> commitFactory = getRequiredOrmFactory(Commit.class); OrmFactory<User> userFactory = getRequiredOrmFactory(User.class); testCommits = Arrays.stream(COMMIT_IRIS) .map(s -> commitFactory.createNew(vf.createIRI(s))) .collect(Collectors.toList()); entityCommits = Arrays.stream(ENTITY_IRI) .map(s -> commitFactory.createNew(vf.createIRI(s))) .collect(Collectors.toList()); testRecord = recordFactory.createNew(vf.createIRI(RECORD_IRI)); testRecord.setProperty(vf.createLiteral("Title"), vf.createIRI(DCTERMS.TITLE.stringValue())); user = userFactory.createNew(vf.createIRI(USER_IRI)); MockitoAnnotations.initMocks(this); when(bNodeService.deskolemize(any(Model.class))).thenAnswer(i -> i.getArgumentAt(0, Model.class)); rest = new CommitRest(); injectOrmFactoryReferencesIntoService(rest); rest.setVf(vf); rest.setEngineManager(engineManager); rest.setTransformer(transformer); rest.setCatalogManager(catalogManager); rest.setbNodeService(bNodeService); return new ResourceConfig() .register(rest) .register(UsernameTestFilter.class) .register(MultiPartFeature.class); }
Example #22
Source File: TestApplication.java From registry with Apache License 2.0 | 5 votes |
@Override public void run(TestConfiguration testConfiguration, Environment environment) throws Exception { StorageManager storageManager = getCacheBackedDao(testConfiguration); final TagService tagService = new CatalogTagService(storageManager); final TagCatalogResource tagCatalogResource = new TagCatalogResource(tagService); environment.jersey().register(tagCatalogResource); environment.jersey().register(MultiPartFeature.class); }
Example #23
Source File: ConfluentRegistryCompatibleResourceTest.java From registry with Apache License 2.0 | 5 votes |
private WebTarget createRootTarget(String rootUrl) { Client client = ClientBuilder.newBuilder() .property(ClientProperties.FOLLOW_REDIRECTS, Boolean.TRUE) .build(); client.register(MultiPartFeature.class); return client.target(rootUrl); }
Example #24
Source File: Resources.java From pulsar with Apache License 2.0 | 5 votes |
public static Set<Class<?>> getApiV2Resources() { return new HashSet<>( Arrays.asList( FunctionsApiV2Resource.class, WorkerApiV2Resource.class, WorkerStatsApiV2Resource.class, MultiPartFeature.class )); }
Example #25
Source File: MCRJerseyDefaultConfiguration.java From mycore with GNU General Public License v3.0 | 5 votes |
/** * Setup features. By default the multi part feature and every mycore feature * class in "org.mycore.frontend.jersey.feature". * * @param resourceConfig the jersey resource configuration */ protected void setupFeatures(ResourceConfig resourceConfig) { // multi part resourceConfig.register(MultiPartFeature.class); // mycore features resourceConfig.packages("org.mycore.frontend.jersey.feature"); }
Example #26
Source File: ApiServer.java From dcos-commons with Apache License 2.0 | 5 votes |
@VisibleForTesting ApiServer(SchedulerConfig schedulerConfig, Collection<Object> resources) { this.port = schedulerConfig.getApiServerPort(); this.server = JettyHttpContainerFactory.createServer( UriBuilder.fromUri("http://0.0.0.0/").port(this.port).build(), new ResourceConfig(MultiPartFeature.class).registerInstances(new HashSet<>(resources)), false /* don't start yet. wait for start() call below. */); this.startTimeout = schedulerConfig.getApiServerInitTimeout(); ServletContextHandler context = new ServletContextHandler(); // Serve metrics registry content at these paths: Metrics.configureMetricsEndpoints( context, "/v1/metrics", "/v1/metrics/prometheus"); // Serve resources at their declared paths relative to root: context .addServlet( new ServletHolder( new ServletContainer( new ResourceConfig(MultiPartFeature.class) .registerInstances(new HashSet<>(resources)) ) ), "/*"); // Passthru handler: Collect basic metrics on queries, and store those metrics in the registry // TODO(nickbp): reimplement InstrumentedHandler with better/more granular metrics // (e.g. resource being queried) final InstrumentedHandler instrumentedHandler = new InstrumentedHandler(Metrics.getRegistry()); instrumentedHandler.setHandler(context); server.setHandler(instrumentedHandler); }
Example #27
Source File: RequestHandler.java From jrestless-examples with Apache License 2.0 | 5 votes |
public RequestHandler() { // configure the application with the resource init(new ResourceConfig() .register(GatewayFeature.class) .register(MultiPartFeature.class) .register(EncodingFilter.class) .register(GZipEncoder.class) .packages("com.jrestless.aws.examples")); start(); }
Example #28
Source File: MappingRestTest.java From mobi with GNU Affero General Public License v3.0 | 5 votes |
@Override protected Application configureApp() throws Exception { vf = getValueFactory(); ModelFactory mf = getModelFactory(); catalogId = vf.createIRI(CATALOG_IRI); recordId = vf.createIRI(MAPPING_RECORD_IRI); IRI branchId = vf.createIRI(BRANCH_IRI); mappingRecordFactory = getRequiredOrmFactory(MappingRecord.class); OrmFactory<User> userFactory = getRequiredOrmFactory(User.class); fakeModel = mf.createModel(); fakeModel.add(vf.createIRI(MAPPING_IRI), vf.createIRI("http://test.org/isTest"), vf.createLiteral(true)); record = mappingRecordFactory.createNew(recordId); user = userFactory.createNew(vf.createIRI("http://test.org/" + UsernameTestFilter.USERNAME)); MockitoAnnotations.initMocks(this); when(configProvider.getLocalCatalogIRI()).thenReturn(catalogId); when(sesameTransformer.mobiModel(any(org.eclipse.rdf4j.model.Model.class))).thenAnswer(i -> Values.mobiModel(i.getArgumentAt(0, org.eclipse.rdf4j.model.Model.class))); when(sesameTransformer.mobiIRI(any(org.eclipse.rdf4j.model.IRI.class))).thenAnswer(i -> Values.mobiIRI(i.getArgumentAt(0, org.eclipse.rdf4j.model.IRI.class))); when(sesameTransformer.sesameModel(any(Model.class))).thenAnswer(i -> Values.sesameModel(i.getArgumentAt(0, Model.class))); when(sesameTransformer.sesameStatement(any(Statement.class))).thenAnswer(i -> Values.sesameStatement(i.getArgumentAt(0, Statement.class))); rest = new MappingRest(); rest.setManager(manager); rest.setVf(vf); rest.setTransformer(sesameTransformer); rest.setEngineManager(engineManager); rest.setConfigProvider(configProvider); rest.setCatalogManager(catalogManager); mappingJsonld = IOUtils.toString(getClass().getResourceAsStream("/mapping.jsonld")); return new ResourceConfig() .register(rest) .register(UsernameTestFilter.class) .register(MultiPartFeature.class); }
Example #29
Source File: BaseTestServer.java From dremio-oss with Apache License 2.0 | 5 votes |
private static void initClient(ObjectMapper mapper) throws Exception { setBinder(createBinder(currentDremioDaemon.getBindingProvider())); if (!Files.exists(new File(folder0.getRoot().getAbsolutePath() + "/testplugins").toPath())) { TestUtilities.addDefaultTestPlugins(l(CatalogService.class), folder0.newFolder("testplugins").toString()); } setPopulator(new SampleDataPopulator( l(SabotContext.class), newSourceService(), newDatasetVersionMutator(), l(UserService.class), newNamespaceService(), DEFAULT_USERNAME )); final JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider(); provider.setMapper(mapper); client = ClientBuilder.newBuilder() .property(FEATURE_AUTO_DISCOVERY_DISABLE, true) .register(provider) .register(MultiPartFeature.class) .build(); rootTarget = client.target("http://localhost:" + currentDremioDaemon.getWebServer().getPort()); final WebTarget livenessServiceTarget = client.target("http://localhost:" + currentDremioDaemon.getLivenessService().getLivenessPort()); metricsEndpoint = livenessServiceTarget.path("metrics"); apiV2 = rootTarget.path(API_LOCATION); publicAPI = rootTarget.path(PUBLIC_API_LOCATION); if (isMultinode()) { masterApiV2 = client.target("http://localhost:" + masterDremioDaemon.getWebServer().getPort()).path(API_LOCATION); masterPublicAPI = client.target("http://localhost:" + masterDremioDaemon.getWebServer().getPort()).path(PUBLIC_API_LOCATION); } else { masterApiV2 = apiV2; masterPublicAPI = publicAPI; } }
Example #30
Source File: TestHdfs.java From dremio-oss with Apache License 2.0 | 5 votes |
@BeforeClass public static void init() throws Exception { assumeNonMaprProfile(); startMiniDfsCluster(TestHdfs.class.getName()); String[] hostPort = dfsCluster.getNameNode().getHostAndPort().split(":"); host = hostPort[0]; port = Integer.parseInt(hostPort[1]); fs.mkdirs(new Path("/dir1/"), new FsPermission(FsAction.ALL, FsAction.ALL, FsAction.ALL)); fs.mkdirs(new Path("/dir1/json"), new FsPermission(FsAction.ALL, FsAction.ALL, FsAction.ALL)); fs.mkdirs(new Path("/dir1/text"), new FsPermission(FsAction.ALL, FsAction.ALL, FsAction.ALL)); fs.mkdirs(new Path("/dir1/parquet"), new FsPermission(FsAction.ALL, FsAction.ALL, FsAction.ALL)); fs.mkdirs(new Path("/dir2"), new FsPermission(FsAction.ALL, FsAction.ALL, FsAction.ALL)); fs.copyFromLocalFile(false, true, new Path(FileUtils.getResourceAsFile("/datasets/users.json").getAbsolutePath()), new Path("/dir1/json/users.json")); fs.setPermission(new Path("/dir1/json/users.json"), new FsPermission(FsAction.ALL, FsAction.ALL, FsAction.ALL)); try (Timer.TimedBlock b = Timer.time("TestHdfs.@BeforeClass")) { dremioDaemon = DACDaemon.newDremioDaemon( DACConfig .newDebugConfig(DremioTest.DEFAULT_SABOT_CONFIG) .autoPort(true) .allowTestApis(true) .writePath(folder.getRoot().getAbsolutePath()) .clusterMode(ClusterMode.LOCAL) .serveUI(true), DremioTest.CLASSPATH_SCAN_RESULT, new DACDaemonModule()); dremioDaemon.init(); dremioBinder = BaseTestServer.createBinder(dremioDaemon.getBindingProvider()); JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider(); provider.setMapper(JSONUtil.prettyMapper()); client = ClientBuilder.newBuilder().register(provider).register(MultiPartFeature.class).build(); } }