Search in sources :

Example 1 with JettisonFeature

use of org.glassfish.jersey.jettison.JettisonFeature in project jersey by jersey.

the class CharsetTest method configureClient.

@Override
protected void configureClient(ClientConfig config) {
    super.configureClient(config);
    config.register(new JettisonFeature());
    config.register(MyJaxbContextResolver.class);
}
Also used : JettisonFeature(org.glassfish.jersey.jettison.JettisonFeature)

Example 2 with JettisonFeature

use of org.glassfish.jersey.jettison.JettisonFeature in project batfish by batfish.

the class Main method initPoolManager.

private static void initPoolManager() {
    ResourceConfig rcPool = new ResourceConfig(PoolMgrService.class).register(new JettisonFeature()).register(MultiPartFeature.class).register(CrossDomainFilter.class);
    if (_settings.getSslPoolDisable()) {
        URI poolMgrUri = UriBuilder.fromUri("http://" + _settings.getPoolBindHost()).port(_settings.getServicePoolPort()).build();
        _logger.infof("Starting pool manager at %s\n", poolMgrUri);
        GrizzlyHttpServerFactory.createHttpServer(poolMgrUri, rcPool);
    } else {
        URI poolMgrUri = UriBuilder.fromUri("https://" + _settings.getPoolBindHost()).port(_settings.getServicePoolPort()).build();
        _logger.infof("Starting pool manager at %s\n", poolMgrUri);
        CommonUtil.startSslServer(rcPool, poolMgrUri, _settings.getSslPoolKeystoreFile(), _settings.getSslPoolKeystorePassword(), _settings.getSslPoolTrustAllCerts(), _settings.getSslPoolTruststoreFile(), _settings.getSslPoolTruststorePassword(), ConfigurationLocator.class, Main.class);
    }
    _poolManager = new PoolMgr(_settings, _logger);
    _poolManager.startPoolManager();
}
Also used : MultiPartFeature(org.glassfish.jersey.media.multipart.MultiPartFeature) ResourceConfig(org.glassfish.jersey.server.ResourceConfig) JettisonFeature(org.glassfish.jersey.jettison.JettisonFeature) URI(java.net.URI)

Example 3 with JettisonFeature

use of org.glassfish.jersey.jettison.JettisonFeature in project jersey by jersey.

the class EntityTypesTest method configureClient.

@Override
protected void configureClient(final ClientConfig config) {
    super.configureClient(config);
    config.register(new JettisonFeature());
}
Also used : JettisonFeature(org.glassfish.jersey.jettison.JettisonFeature)

Example 4 with JettisonFeature

use of org.glassfish.jersey.jettison.JettisonFeature in project batfish by batfish.

the class Driver method mainRunWorkService.

private static void mainRunWorkService() {
    if (_mainSettings.getTracingEnable() && !GlobalTracer.isRegistered()) {
        initTracer();
    }
    String protocol = _mainSettings.getSslDisable() ? "http" : "https";
    String baseUrl = String.format("%s://%s", protocol, _mainSettings.getServiceBindHost());
    URI baseUri = UriBuilder.fromUri(baseUrl).port(_mainSettings.getServicePort()).build();
    _mainLogger.debug(String.format("Starting server at %s\n", baseUri));
    ResourceConfig rc = new ResourceConfig(Service.class).register(new JettisonFeature());
    if (_mainSettings.getTracingEnable()) {
        rc.register(ServerTracingDynamicFeature.class);
    }
    try {
        if (_mainSettings.getSslDisable()) {
            GrizzlyHttpServerFactory.createHttpServer(baseUri, rc);
        } else {
            CommonUtil.startSslServer(rc, baseUri, _mainSettings.getSslKeystoreFile(), _mainSettings.getSslKeystorePassword(), _mainSettings.getSslTrustAllCerts(), _mainSettings.getSslTruststoreFile(), _mainSettings.getSslTruststorePassword(), ConfigurationLocator.class, Driver.class);
        }
        if (_mainSettings.getCoordinatorRegister()) {
            // this function does not return until registration succeeds
            registerWithCoordinatorPersistent();
        }
        if (_mainSettings.getParentPid() > 0) {
            if (SystemUtils.IS_OS_WINDOWS) {
                _mainLogger.errorf("Parent process monitoring is not supported on Windows. We'll live without it.");
            } else {
                Executors.newScheduledThreadPool(1).scheduleAtFixedRate(new CheckParentProcessTask(_mainSettings.getParentPid()), 0, PARENT_CHECK_INTERVAL_MS, TimeUnit.MILLISECONDS);
                SignalHandler handler = signal -> _mainLogger.infof("BFS: Ignoring signal %s\n", signal);
                Signal.handle(new Signal("INT"), handler);
            }
        }
        // sleep indefinitely, check for parent pid and coordinator each time
        while (true) {
            Thread.sleep(COORDINATOR_CHECK_INTERVAL_MS);
            /*
         * every time we wake up, we check if the coordinator has polled us recently
         * if not, re-register the service. the coordinator might have died and come back.
         */
            if (_mainSettings.getCoordinatorRegister() && new Date().getTime() - _lastPollFromCoordinator.getTime() > COORDINATOR_POLL_TIMEOUT_MS) {
                // this function does not return until registration succeeds
                registerWithCoordinatorPersistent();
            }
        }
    } catch (ProcessingException e) {
        String msg = "FATAL ERROR: " + e.getMessage() + "\n";
        _mainLogger.error(msg);
        System.exit(1);
    } catch (Exception ex) {
        String stackTrace = ExceptionUtils.getStackTrace(ex);
        _mainLogger.error(stackTrace);
        System.exit(1);
    }
}
Also used : Arrays(java.util.Arrays) Date(java.util.Date) ConfigurationLocator(org.batfish.config.ConfigurationLocator) LRUMap(org.apache.commons.collections4.map.LRUMap) BfConsts(org.batfish.common.BfConsts) MediaType(javax.ws.rs.core.MediaType) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ReporterConfiguration(com.uber.jaeger.Configuration.ReporterConfiguration) References(io.opentracing.References) Answer(org.batfish.datamodel.answers.Answer) Map(java.util.Map) RoutesByVrf(org.batfish.datamodel.collections.RoutesByVrf) ResourceConfig(org.glassfish.jersey.server.ResourceConfig) Signal(sun.misc.Signal) UriBuilder(javax.ws.rs.core.UriBuilder) URI(java.net.URI) RuntimeMXBean(java.lang.management.RuntimeMXBean) DataPlane(org.batfish.datamodel.DataPlane) Redirect(java.lang.ProcessBuilder.Redirect) SSLHandshakeException(javax.net.ssl.SSLHandshakeException) TaskStatus(org.batfish.common.BfConsts.TaskStatus) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Logger(java.util.logging.Logger) EnvironmentSettings(org.batfish.config.Settings.EnvironmentSettings) Task(org.batfish.common.Task) Executors(java.util.concurrent.Executors) Settings(org.batfish.config.Settings) List(java.util.List) Response(javax.ws.rs.core.Response) JettisonFeature(org.glassfish.jersey.jettison.JettisonFeature) ConstSampler(com.uber.jaeger.samplers.ConstSampler) CoordConsts(org.batfish.common.CoordConsts) ProcessingException(javax.ws.rs.ProcessingException) CacheBuilder(com.google.common.cache.CacheBuilder) SortedMap(java.util.SortedMap) QuestionException(org.batfish.common.QuestionException) ExceptionUtils(org.apache.commons.lang3.exception.ExceptionUtils) BatfishLogger(org.batfish.common.BatfishLogger) SignalHandler(sun.misc.SignalHandler) SamplerConfiguration(com.uber.jaeger.Configuration.SamplerConfiguration) ServerTracingDynamicFeature(io.opentracing.contrib.jaxrs2.server.ServerTracingDynamicFeature) ForwardingAnalysis(org.batfish.datamodel.ForwardingAnalysis) CommonUtil(org.batfish.common.util.CommonUtil) Client(javax.ws.rs.client.Client) HashMap(java.util.HashMap) BatfishException(org.batfish.common.BatfishException) ConcurrentMap(java.util.concurrent.ConcurrentMap) Level(java.util.logging.Level) TestrigSettings(org.batfish.config.Settings.TestrigSettings) BgpAdvertisementsByVrf(org.batfish.datamodel.collections.BgpAdvertisementsByVrf) ImmutableList(com.google.common.collect.ImmutableList) Version(org.batfish.common.Version) Configuration(org.batfish.datamodel.Configuration) ManagementFactory(java.lang.management.ManagementFactory) Nullable(javax.annotation.Nullable) SystemUtils(org.apache.commons.lang3.SystemUtils) GlobalTracer(io.opentracing.util.GlobalTracer) IOException(java.io.IOException) JSONArray(org.codehaus.jettison.json.JSONArray) InputStreamReader(java.io.InputStreamReader) AnswerStatus(org.batfish.datamodel.answers.AnswerStatus) SpanContext(io.opentracing.SpanContext) TimeUnit(java.util.concurrent.TimeUnit) Batch(org.batfish.common.Task.Batch) CleanBatfishException(org.batfish.common.CleanBatfishException) Paths(java.nio.file.Paths) Snapshot(org.batfish.common.Snapshot) ActiveSpan(io.opentracing.ActiveSpan) GrizzlyHttpServerFactory(org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory) BufferedReader(java.io.BufferedReader) WebTarget(javax.ws.rs.client.WebTarget) Cache(com.google.common.cache.Cache) Collections(java.util.Collections) Signal(sun.misc.Signal) SignalHandler(sun.misc.SignalHandler) ResourceConfig(org.glassfish.jersey.server.ResourceConfig) JettisonFeature(org.glassfish.jersey.jettison.JettisonFeature) URI(java.net.URI) Date(java.util.Date) SSLHandshakeException(javax.net.ssl.SSLHandshakeException) ProcessingException(javax.ws.rs.ProcessingException) QuestionException(org.batfish.common.QuestionException) BatfishException(org.batfish.common.BatfishException) IOException(java.io.IOException) CleanBatfishException(org.batfish.common.CleanBatfishException) ProcessingException(javax.ws.rs.ProcessingException)

Aggregations

JettisonFeature (org.glassfish.jersey.jettison.JettisonFeature)4 URI (java.net.URI)2 Cache (com.google.common.cache.Cache)1 CacheBuilder (com.google.common.cache.CacheBuilder)1 ImmutableList (com.google.common.collect.ImmutableList)1 ReporterConfiguration (com.uber.jaeger.Configuration.ReporterConfiguration)1 SamplerConfiguration (com.uber.jaeger.Configuration.SamplerConfiguration)1 ConstSampler (com.uber.jaeger.samplers.ConstSampler)1 ActiveSpan (io.opentracing.ActiveSpan)1 References (io.opentracing.References)1 SpanContext (io.opentracing.SpanContext)1 ServerTracingDynamicFeature (io.opentracing.contrib.jaxrs2.server.ServerTracingDynamicFeature)1 GlobalTracer (io.opentracing.util.GlobalTracer)1 BufferedReader (java.io.BufferedReader)1 IOException (java.io.IOException)1 InputStreamReader (java.io.InputStreamReader)1 Redirect (java.lang.ProcessBuilder.Redirect)1 ManagementFactory (java.lang.management.ManagementFactory)1 RuntimeMXBean (java.lang.management.RuntimeMXBean)1 Paths (java.nio.file.Paths)1