本文整理汇总了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);
}
示例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();
}
}
示例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
}
}
示例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);
}
示例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();
}
}
示例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");
}
示例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);
}
示例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);
}
示例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));
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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");
}