org.glassfish.jersey.internal.inject.Binder Java Examples

The following examples show how to use org.glassfish.jersey.internal.inject.Binder. 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: AbstractLambdaContextReferencingBinderIntTest.java    From jrestless with Apache License 2.0 6 votes vote down vote up
@Override
protected Application configure() {
	ResourceConfig application = new ResourceConfig();
	application.register(new AbstractLambdaContextReferencingBinder() {
		@Override
		protected void configure() {
			bindReferencingLambdaContextFactory();
		}
	});
	testService = mock(TestService.class);

	lambdaContextProvider = mock(LambdaContextProvider.class);

	Binder binder = new InstanceBinder.Builder()
			.addInstance(testService, TestService.class, Singleton.class)
			.addInstance(lambdaContextProvider, LambdaContextProvider.class, Singleton.class)
			.build();
	application.register(binder);

	application.register(TestResource.class);
	application.register(LambdaContextSetter.class);
	return application;
}
 
Example #2
Source File: FnFutureRequestHandlerTest.java    From jrestless with Apache License 2.0 5 votes vote down vote up
private FnTestObjectHandler createAndStartHandler(ResourceConfig config, TestService testService) {
    Binder binder = new InstanceBinder.Builder().addInstance(testService, TestService.class).build();
    config.register(binder);
    config.register(TestResource.class);
    config.register(SomeCheckedAppExceptionMapper.class);
    config.register(SomeUncheckedAppExceptionMapper.class);
    config.register(GlobalExceptionMapper.class);
    FnTestObjectHandler handler = new FnTestObjectHandler();
    handler.init(config);
    handler.start();
    handler.setRuntimeContext(runtimeContext);
    return handler;
}
 
Example #3
Source File: BackendServiceFactory.java    From jrestless-examples with Apache License 2.0 5 votes vote down vote up
public static Binder createBinder() {
	return new AbstractBinder() {
		@Override
		protected void configure() {
			bindFactory(BackendServiceFactory.class).to(BackendService.class).in(Singleton.class);
		}
	};
}
 
Example #4
Source File: JRestlessHandlerContainerIntTest.java    From jrestless with Apache License 2.0 5 votes vote down vote up
@BeforeEach
public void setup() {
	testService = mock(ArticleService.class);
	Binder binder = new InstanceBinder.Builder().addInstance(testService, ArticleService.class).build();

	container = new JRestlessHandlerContainer<JRestlessContainerRequest>(
			new ResourceConfig().register(TestResource.class).register(binder).register(RolesAllowedDynamicFeature.class));
	container.onStartup();
}
 
Example #5
Source File: SimpleRequestHandlerIntTest.java    From jrestless with Apache License 2.0 5 votes vote down vote up
@BeforeEach
public void setup() {
	ResourceConfig config = new ResourceConfig();
	testService = mock(TestService.class);
	Binder binder = new InstanceBinder.Builder().addInstance(testService, TestService.class).build();
	config.register(binder);
	config.register(TestResource.class);
	handler = new SimpleRequestHandlerImpl();
	handler.init(config);
	handler.start();
}
 
Example #6
Source File: FnRequestHandlerIntTest.java    From jrestless with Apache License 2.0 5 votes vote down vote up
private FnRequestHandler createAndStartHandler(ResourceConfig config, TestService testService) {
    Binder binder = new InstanceBinder.Builder().addInstance(testService, TestService.class).build();
    config.register(binder);
    config.register(TestResource.class);
    config.register(ApplicationPathFilter.class);
    FnRequestHandler handler = new FnRequestHandler(){};
    handler.init(config);
    handler.start();
    handler.setRuntimeContext(runtimeContext);
    return handler;
}
 
Example #7
Source File: SnsRequestHandlerIntTest.java    From jrestless with Apache License 2.0 5 votes vote down vote up
@BeforeEach
public void setup() {
	ResourceConfig config = new ResourceConfig();
	config.register(SnsFeature.class);
	testService = mock(TestService.class);
	Binder binder = new InstanceBinder.Builder().addInstance(testService, TestService.class).build();
	config.register(binder);
	config.register(TestResource.class);
	handler = new SnsRequestObjectHandlerImpl();
	handler.init(config);
	handler.start();
}
 
Example #8
Source File: GatewayRequestObjectHandlerIntTest.java    From jrestless with Apache License 2.0 5 votes vote down vote up
private GatewayRequestObjectHandlerImpl createAndStartHandler(ResourceConfig config, TestService testService) {
	config.register(GatewayFeature.class);
	Binder binder = new InstanceBinder.Builder().addInstance(testService, TestService.class).build();
	config.register(binder);
	config.register(TestResource.class);
	config.register(EncodingFilter.class);
	config.register(GZipEncoder.class);
	config.register(SomeCheckedAppExceptionMapper.class);
	config.register(SomeUncheckedAppExceptionMapper.class);
	config.register(GlobalExceptionMapper.class);
	GatewayRequestObjectHandlerImpl handler = new GatewayRequestObjectHandlerImpl();
	handler.init(config);
	handler.start();
	return handler;
}
 
Example #9
Source File: ServiceRequestObjectHandlerIntTest.java    From jrestless with Apache License 2.0 5 votes vote down vote up
@BeforeEach
public void setup() {
	ResourceConfig config = new ResourceConfig();
	config.register(ServiceFeature.class);
	testService = mock(TestService.class);
	Binder binder = new InstanceBinder.Builder().addInstance(testService, TestService.class).build();
	config.register(binder);
	config.register(TestResource.class);
	handler = spy(new ServiceRequestObjectHandlerImpl());
	handler.init(config);
	handler.start();
}
 
Example #10
Source File: FnRequestHandler.java    From jrestless with Apache License 2.0 4 votes vote down vote up
@Override
protected final Binder createBinder() {
	return new InputBinder();
}
 
Example #11
Source File: ServiceRequestHandler.java    From jrestless with Apache License 2.0 4 votes vote down vote up
@Override
protected final Binder createBinder() {
	return new ServiceRequestBinder();
}
 
Example #12
Source File: SnsRequestHandler.java    From jrestless with Apache License 2.0 4 votes vote down vote up
@Override
protected final Binder createBinder() {
	return new SnsRecordBinder();
}
 
Example #13
Source File: WebActionRequestHandler.java    From jrestless with Apache License 2.0 4 votes vote down vote up
@Override
protected final Binder createBinder() {
	return new WebActionBinder();
}
 
Example #14
Source File: SimpleRequestHandler.java    From jrestless with Apache License 2.0 4 votes vote down vote up
protected Binder createBinder() {
	return null;
}
 
Example #15
Source File: GatewayRequestHandler.java    From jrestless with Apache License 2.0 4 votes vote down vote up
@Override
protected final Binder createBinder() {
	return new GatewayBinder();
}
 
Example #16
Source File: JRestlessHandlerContainer.java    From jrestless with Apache License 2.0 2 votes vote down vote up
/**
 * Creates a new JRestless container.
 *
 * @param application
 *            JAX-RS / Jersey application to be deployed on the JRestless
 *            container
 * @param binder
 *            the binder
 */
public JRestlessHandlerContainer(@Nonnull Application application, @Nullable Binder binder) {
	this(new ApplicationHandler(requireNonNull(application), binder));
}
 
Example #17
Source File: JRestlessHandlerContainer.java    From jrestless with Apache License 2.0 2 votes vote down vote up
/**
 * Creates a new JRestless container.
 *
 * @param application
 *            JAX-RS / Jersey application to be deployed on the JRestless
 *            container
 * @param customBinder
 *            additional custom bindings used during
 *            {@link org.glassfish.jersey.internal.inject.InjectionManager}
 *            creation
 * @param parentManager
 *            parent used in
 *            {@link org.glassfish.jersey.internal.inject.InjectionManager}
 *            for a specific DI provider
 */
public JRestlessHandlerContainer(@Nonnull Application application, @Nullable Binder customBinder,
		@Nullable Object parentManager) {
	this(new ApplicationHandler(requireNonNull(application), customBinder, parentManager));
}