当前位置: 首页>>代码示例>>Java>>正文


Java JerseyEnvironment类代码示例

本文整理汇总了Java中io.dropwizard.jersey.setup.JerseyEnvironment的典型用法代码示例。如果您正苦于以下问题:Java JerseyEnvironment类的具体用法?Java JerseyEnvironment怎么用?Java JerseyEnvironment使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


JerseyEnvironment类属于io.dropwizard.jersey.setup包,在下文中一共展示了JerseyEnvironment类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: run

import io.dropwizard.jersey.setup.JerseyEnvironment; //导入依赖的package包/类
@Override
public void run(
        ConerCoreConfiguration conerCoreConfiguration,
        Environment environment
) throws Exception {
    initComponents(conerCoreConfiguration);
    JerseyEnvironment jersey = environment.jersey();
    jersey.register(components.eventsResource());
    jersey.register(components.eventRegistrationsResource());
    jersey.register(components.eventRunsResource());
    jersey.register(components.eventResultsResource());
    jersey.register(components.handicapGroupsResource());
    jersey.register(components.handicapGroupSetsResource());
    jersey.register(components.competitionGroupsResource());
    jersey.register(components.competitionGroupSetsResource());
    jersey.register(components.domainServiceExceptionMapper());
    jersey.register(components.runtimeExceptionUnwrappingMapper());

    optionallyRegisterHsqlDatabaseManagerSwingTask(environment, conerCoreConfiguration);
}
 
开发者ID:caeos,项目名称:coner-core,代码行数:21,代码来源:ConerCoreApplication.java

示例2: registerGuiceBound

import io.dropwizard.jersey.setup.JerseyEnvironment; //导入依赖的package包/类
/**
 * Registers any Guice-bound providers or root resources.
 */
public static void registerGuiceBound(Injector injector, final JerseyEnvironment environment) {
  while (injector != null) {
    for (Key<?> key : injector.getBindings().keySet()) {
      Type type = key.getTypeLiteral().getType();
      if (type instanceof Class) {
        Class<?> c = (Class) type;
        if (isProviderClass(c)) {
          logger.info("Registering {} as a provider class", c.getName());
          environment.register(c);
        } else if (isRootResourceClass(c)) {
          // Jersey rejects resources that it doesn't think are acceptable
          // Including abstract classes and interfaces, even if there is a valid Guice binding.
          if(Resource.isAcceptable(c)) {
            logger.info("Registering {} as a root resource class", c.getName());
            environment.register(c);
          } else {
            logger.warn("Class {} was not registered as a resource. Bind a concrete implementation instead.", c.getName());
          }
        }

      }
    }
    injector = injector.getParent();
  }
}
 
开发者ID:rvs-fluid-it,项目名称:microservice-bundle,代码行数:29,代码来源:JerseyUtil.java

示例3: checkAdminGuiceFeature

import io.dropwizard.jersey.setup.JerseyEnvironment; //导入依赖的package包/类
private void checkAdminGuiceFeature(final Environment environment, final JerseyEnvironment jerseyEnvironment)
{
    try
    {
        Feature feature = new Feature()
        {
            @Override
            public boolean configure(FeatureContext context)
            {
                for ( Object obj : environment.jersey().getResourceConfig().getSingletons() )
                {
                    if ( obj instanceof InternalFeatureRegistrations )
                    {
                        ((InternalFeatureRegistrations)obj).apply(context);
                    }
                }
                return true;
            }
        };
        jerseyEnvironment.register(feature);
    }
    catch ( Exception ignore )
    {
        // ignore - GuiceBundle not added
    }
}
 
开发者ID:soabase,项目名称:soabase,代码行数:27,代码来源:SoaBundle.java

示例4: internalRun

import io.dropwizard.jersey.setup.JerseyEnvironment; //导入依赖的package包/类
@Override
protected void internalRun(Configuration configuration, Environment environment)
{
    Metric metric = new Gauge<Integer>()
    {
        final Random random = new Random();

        @Override
        public Integer getValue()
        {
            return random.nextInt(100);
        }
    };
    environment.metrics().register("goodbye-random", metric);

    environment.jersey().register(GoodbyeResource.class);
    JerseyEnvironment adminJerseyEnvironment = SoaBundle.getFeatures(environment).getNamedRequired(JerseyEnvironment.class, SoaFeatures.ADMIN_NAME);
    adminJerseyEnvironment.register(GoodbyeAdminResource.class);
}
 
开发者ID:soabase,项目名称:soabase,代码行数:20,代码来源:GoodbyeApp.java

示例5: registerGuiceBound

import io.dropwizard.jersey.setup.JerseyEnvironment; //导入依赖的package包/类
/**
 * Registers any Guice-bound providers or root resources.
 */
public static void registerGuiceBound(Injector injector, final JerseyEnvironment environment) {
    while (injector != null) {
        for (Key<?> key : injector.getBindings().keySet()) {
            Type type = key.getTypeLiteral().getType();
            if (type instanceof Class) {
                Class<?> c = (Class) type;
                if (isProviderClass(c)) {
                    logger.info("Registering {} as a provider class", c.getName());
                    environment.register(c);
                } else if (isRootResourceClass(c)) {
                    // Jersey rejects resources that it doesn't think are acceptable
                    // Including abstract classes and interfaces, even if there is a valid Guice binding.
                    if (Resource.isAcceptable(c)) {
                        logger.info("Registering {} as a root resource class", c.getName());
                        environment.register(c);
                    } else {
                        logger.warn("Class {} was not registered as a resource. Bind a concrete implementation instead.", c.getName());
                    }
                }

            }
        }
        injector = injector.getParent();
    }
}
 
开发者ID:robeio,项目名称:robe,代码行数:29,代码来源:JerseyUtil.java

示例6: run

import io.dropwizard.jersey.setup.JerseyEnvironment; //导入依赖的package包/类
@Override
public void run(Object configuration, Environment environment) {
    boolean debuggable = false;
    if(configuration instanceof JerseyDebuggable) {
        debuggable = ((JerseyDebuggable) configuration).isJerseyDebuggable();
    }
    
    JerseyEnvironment jersey = environment.jersey();
    jersey.register(new DebugErrorMessageJsonMessageBodyWriter(objectMapper));
    jersey.register(new DebugErrorMessagePlainMessageBodyWriter());
    jersey.register(new ErrorMessagePlainMessageBodyWriter());
    
    jersey.register(new LoggingDebugExceptionMapper<Throwable>(debuggable) {});
    jersey.register(new LoggingDebugExceptionMapper<BaseWebApplicationException>(debuggable) {});
    
    //enable returning validation errors
    jersey.enable("jersey.config.beanValidation.enableOutputValidationErrorEntity.server");
}
 
开发者ID:jclawson,项目名称:dropwizardry,代码行数:19,代码来源:DropwizardryJerseyBundle.java

示例7: givenHealthCheckManagerWithPassingTest_whenInitialized_thenTestsAreHealthy

import io.dropwizard.jersey.setup.JerseyEnvironment; //导入依赖的package包/类
@Test
public void givenHealthCheckManagerWithPassingTest_whenInitialized_thenTestsAreHealthy() throws Exception{

    JerseyEnvironment jerseyEnvironment = mock(JerseyEnvironment.class);

    ArgumentCaptor<TestStatusResource> argumentCaptor = ArgumentCaptor.forClass(TestStatusResource.class);

    new Atam4j.Atam4jBuilder(jerseyEnvironment)
            .withTestClasses(PassingTestWithNoCategory.class)
            .withInitialDelay(0)
            .build()
            .initialise();
    verify(jerseyEnvironment).register(argumentCaptor.capture());

    TestStatusResource value = argumentCaptor.getValue();
    assertNotNull(value);

    checkThatWeEventuallyGetSuccess(value);
}
 
开发者ID:atam4j,项目名称:atam4j,代码行数:20,代码来源:Atam4jIntegrationTest.java

示例8: givenHealthCheckManagerUsingAnnotationScanning_whenInitialized_thenTestsAreHealthy

import io.dropwizard.jersey.setup.JerseyEnvironment; //导入依赖的package包/类
@Test
public void givenHealthCheckManagerUsingAnnotationScanning_whenInitialized_thenTestsAreHealthy() throws Exception{
    JerseyEnvironment jerseyEnvironment = mock(JerseyEnvironment.class);

    ArgumentCaptor<TestStatusResource> argumentCaptor = ArgumentCaptor.forClass(TestStatusResource.class);

    new Atam4j.Atam4jBuilder(jerseyEnvironment)
            .withInitialDelay(0)
            .build()
            .initialise();
    verify(jerseyEnvironment).register(argumentCaptor.capture());

    TestStatusResource value = argumentCaptor.getValue();
    assertNotNull(value);

    checkThatWeEventuallyGetSuccess(value);
}
 
开发者ID:atam4j,项目名称:atam4j,代码行数:18,代码来源:Atam4jIntegrationTest.java

示例9: run

import io.dropwizard.jersey.setup.JerseyEnvironment; //导入依赖的package包/类
@Override
public void run(final CredentialStorageConfiguration configuration,
        final Environment environment) throws Exception {
    final JedisManaged jedisManaged = this.buildJedis(configuration.getRedis());
    environment.lifecycle().manage(jedisManaged);
    final PetiteContainer petiteContainer = this.petite.getPetiteContainer();
    this.registerExternalDependencies(configuration, environment, jedisManaged,
            petiteContainer);

    environment.getObjectMapper().setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE);
    environment.jersey().register(petiteContainer.getBean(CredentialResource.class));

    // Admin resources.
    final JerseyEnvironment adminJerseyEnvironment = this.adminResourceBundle
            .getJerseyEnvironment();
    adminJerseyEnvironment.register(petiteContainer.getBean(AuditResource.class));

    // Health checks
    environment.healthChecks().register("redis",
            this.petite.getPetiteContainer().getBean(RedisHealthCheck.class));
}
 
开发者ID:mtakaki,项目名称:CredentialStorageService,代码行数:22,代码来源:CredentialStorageApplication.java

示例10: run

import io.dropwizard.jersey.setup.JerseyEnvironment; //导入依赖的package包/类
@Override
    public void run(ApiConfig configuration, Environment environment) throws Exception {
        LOGGER.info("api started up");
        injector = guiceBundle.getInjector();
        JerseyEnvironment jersey = environment.jersey();
        register(environment.lifecycle(), REFLECTIONS.getSubTypesOf(Managed.class)); // registers NbdServer


//        injector.getInstance(SessionFactory.class); //init DB
        installCorsFilter(environment);
        //init all Singletons semi-eagerly
        REFLECTIONS.getTypesAnnotatedWith(Singleton.class).forEach(injector::getInstance);
        final Set<Class<?>> resources = REFLECTIONS.getTypesAnnotatedWith(Path.class);
        register(jersey, resources);


        jersey.register(new LoggingExceptionMapper<Throwable>() {
            @Override
            protected String formatErrorMessage(long id, Throwable exception) {
                StringWriter sw = new StringWriter();
                PrintWriter pw = new PrintWriter(sw);
                exception.printStackTrace(pw);
                return sw.toString();
            }
        });
        jersey.register(new JsonProcessingExceptionMapper(true));
        jersey.register(new EarlyEofExceptionMapper());


        final TrivialAuthenticator instance = injector.getInstance(TrivialAuthenticator.class);
        environment.jersey().register(new AuthDynamicFeature(
                new BasicCredentialAuthFilter.Builder<Principal>()
                        .setAuthenticator(instance)
                        .setAuthorizer((principal, role) -> false)
                        .buildAuthFilter()));
        environment.jersey().register(RolesAllowedDynamicFeature.class);

    }
 
开发者ID:MineboxOS,项目名称:minebox,代码行数:39,代码来源:MinebdApplication.java

示例11: AuthenticationBootstrap

import io.dropwizard.jersey.setup.JerseyEnvironment; //导入依赖的package包/类
public AuthenticationBootstrap(JerseyEnvironment environment, UserDAO userDAO) {
    requireNonNull(environment);
    requireNonNull(environment);

    this.environment = environment;
    this.userDAO = userDAO;
}
 
开发者ID:adamkewley,项目名称:jobson,代码行数:8,代码来源:AuthenticationBootstrap.java

示例12: createTypicalAuthBootstrap

import io.dropwizard.jersey.setup.JerseyEnvironment; //导入依赖的package包/类
private static AuthenticationBootstrap createTypicalAuthBootstrap() {
    final UserDAO userDAO = mock(UserDAO.class);
    final Server s = new Server(0);
    final Servlet se = new ServletContainer();
    final JerseyEnvironment env = new JerseyEnvironment(new JerseyContainerHolder(se), new DropwizardResourceConfig());

    return new AuthenticationBootstrap(env, userDAO);
}
 
开发者ID:adamkewley,项目名称:jobson,代码行数:9,代码来源:CustomAuthenticatorConfigTest.java

示例13: run

import io.dropwizard.jersey.setup.JerseyEnvironment; //导入依赖的package包/类
@Override
public void run(T configuration, Environment environment) throws Exception {
    JerseyEnvironment jersey = environment.jersey();

    JerseyClientConfiguration clientConfiguration = clientConfigurationProvider.apply(configuration);
    Client client = getClient(environment, clientConfiguration);

    rxJerseyClientFeature.register(client);

    jersey.register(rxJerseyServerFeature);
    jersey.register(rxJerseyClientFeature);
}
 
开发者ID:alex-shpak,项目名称:rx-jersey,代码行数:13,代码来源:RxJerseyBundle.java

示例14: setUp

import io.dropwizard.jersey.setup.JerseyEnvironment; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    mockConfiguration = mock(DummyConfiguration.class);
    mockEnvironment = mock(Environment.class);
    mockLifecycle = mock(LifecycleEnvironment.class);
    mockJersey = mock(JerseyEnvironment.class);
    mockHealthchecks = mock(HealthCheckRegistry.class);
    when(mockEnvironment.lifecycle()).thenReturn(mockLifecycle);
    when(mockEnvironment.healthChecks()).thenReturn(mockHealthchecks);
}
 
开发者ID:serhuz,项目名称:dropwizard-morphia,代码行数:11,代码来源:BaseBundleTest.java

示例15: run

import io.dropwizard.jersey.setup.JerseyEnvironment; //导入依赖的package包/类
@Override
   public void run(DuctileDBServerConfiguration configuration, Environment environment) throws Exception {
MetricRegistry metrics = environment.metrics();
Metrics.initialize(metrics);

HealthCheckRegistry healthChecks = environment.healthChecks();

JerseyEnvironment jersey = environment.jersey();
jersey.setUrlPattern("/rest");

   }
 
开发者ID:PureSolTechnologies,项目名称:DuctileDB,代码行数:12,代码来源:DuctileDBServer.java


注:本文中的io.dropwizard.jersey.setup.JerseyEnvironment类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。