Tabnine Logo
JRestlessHandlerContainer
Code IndexAdd Tabnine to your IDE (free)

How to use
JRestlessHandlerContainer
in
com.jrestless.core.container

Best Java code snippets using com.jrestless.core.container.JRestlessHandlerContainer (Showing top 20 results out of 315)

origin: bbilger/jrestless

/**
 * Shortcut for
 * {@link #handleRequest(JRestlessContainerRequest, JRestlessResponseWriter, SecurityContext, Consumer)}
 * with noop containerRequestEnhancer.
 *
 * @param request
 * @param responseWriter
 * @param securityContext
 */
public void handleRequest(@Nonnull RequestT request, @Nonnull JRestlessResponseWriter responseWriter,
    @Nonnull SecurityContext securityContext) {
  handleRequest(request, responseWriter, securityContext, req -> { });
}
origin: bbilger/jrestless

/**
 * Initializes the container using the given application.
 * <p>
 * May be called once, only.
 *
 * @param application
 * @param parentManager
 */
public final void init(@Nonnull Application application, @Nullable Object parentManager) {
  requireNonNull(application);
  init(new JRestlessHandlerContainer<>(application, createBinder(), parentManager));
}
origin: bbilger/jrestless

/**
 * Creates a container request from the given input and delegates it to the
 * application.
 *
 * @param request
 * @param responseWriter
 *            the response writer.
 * @param securityContext
 *            the security context of the request.
 * @param containerRequestEnhancer
 *            additional container request customizer.
 */
public void handleRequest(@Nonnull RequestT request, @Nonnull JRestlessResponseWriter responseWriter,
    @Nonnull SecurityContext securityContext, @Nonnull Consumer<ContainerRequest> containerRequestEnhancer) {
  requireNonNull(responseWriter, "responseWriter may not be null");
  requireNonNull(containerRequestEnhancer, "containerRequestExtender may not be null");
  ContainerRequest containerRequest = createContainerRequest(request,
      new JRestlessContainerResponseWriter(responseWriter), securityContext);
  containerRequestEnhancer.accept(containerRequest);
  handleRequest(containerRequest);
}
origin: bbilger/jrestless

@Override
public void reload() {
  reload(getConfiguration());
}
origin: bbilger/jrestless

@Test
public void reload_ConfigGiven_ShouldResetAppHandler() {
  ResourceConfig config = new ApplicationHandler().getConfiguration();
  ApplicationHandler newAppHandler = mock(ApplicationHandler.class);
  doReturn(newAppHandler).when(container).createNewApplicationHandler(any());
  container.reload(config);
  assertSame(newAppHandler, container.getApplicationHandler());
}
origin: bbilger/jrestless

@Test
public void reload_ConfigGiven_ShouldCreateAppHandlerUsingConfiguration() {
  ResourceConfig config = new ApplicationHandler().getConfiguration();
  container.reload(config);
  verify(container, times(1)).createNewApplicationHandler(config);
}
origin: bbilger/jrestless

public void createContainerRequest_NoRequestBaseUriGiven_ShouldPass() {
  JRestlessContainerRequest request = createAnyRequest();
  when(request.getBaseUri()).thenReturn(null);
  container.createContainerRequest(request, mock(ContainerResponseWriter.class), mock(SecurityContext.class));
}
origin: bbilger/jrestless

@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();
}
origin: bbilger/jrestless

/**
 * Stops the container.
 * <p>
 * May be called once, only.
 * <p>
 * {@link #start()} must be called, first.
 */
public final void stop() {
  checkState(started, "container has already been stopped");
  container.onShutdown();
  started = false;
}
origin: bbilger/jrestless

/**
 * Starts the container.
 * <p>
 * May be called once, only.
 * <p>
 * One of the init methods must be called, first.
 */
public final void start() {
  checkState(initialized, "handler has not been initialized");
  checkState(!started, "container has already been started");
  container.onStartup();
  started = true;
}
origin: bbilger/jrestless

@Override
public void reload(ResourceConfig configuration) {
  LOG.info("reloading container...");
  appHandler.onShutdown(this);
  appHandler = createNewApplicationHandler(configuration);
  appHandler.onReload(this);
  appHandler.onStartup(this);
  LOG.info("reloaded container");
}
origin: bbilger/jrestless

@Test
public void getConfiguration_ShouldReturnAppHandlerConfiguration() {
  ResourceConfig config = mock(ResourceConfig.class);
  when(appHandler.getConfiguration()).thenReturn(config);
  assertSame(config, container.getConfiguration());
}
origin: bbilger/jrestless

@Test
public void reload_ConfigGiven_ShouldShutdownOldAppHandler() {
  ResourceConfig config = new ApplicationHandler().getConfiguration();
  container.reload(config);
  verify(appHandler, times(1)).onShutdown(container);
}
origin: bbilger/jrestless

@Test
public void reload_ConfigGiven_ShouldStartNewAppHandler() {
  ResourceConfig config = new ApplicationHandler().getConfiguration();
  ApplicationHandler newAppHandler = mock(ApplicationHandler.class);
  doReturn(newAppHandler).when(container).createNewApplicationHandler(any());
  container.reload(config);
  verify(newAppHandler, times(1)).onStartup(container);
}
origin: bbilger/jrestless

@Test
public void createContainerRequest_NoRequestGiven_ShouldThrowNpe() {
  assertThrows(NullPointerException.class, () -> container.createContainerRequest(null, mock(ContainerResponseWriter.class), mock(SecurityContext.class)));
}
origin: bbilger/jrestless

@Test
public void reload_NoConfigGiven_ShouldCreateAppHandlerUsingCurrentConfig() {
  doNothing().when(container).reload(any());
  ResourceConfig config = container.getConfiguration();
  container.reload();
  verify(container, times(1)).reload(config);
}
origin: bbilger/jrestless

@Test
public void onShutdown_ShouldShutdownAppHandler() {
  container.onShutdown();
  verify(appHandler, times(1)).onShutdown(container);
}
origin: bbilger/jrestless

@Test
public void onStartup_ShouldStartAppHandler() {
  container.onStartup();
  verify(appHandler, times(1)).onStartup(container);
}
origin: bbilger/jrestless

@Test
public void handleRequest_ContainerRequestGiven_ShouldInvokeAppHandler() {
  ContainerRequest request = mock(ContainerRequest.class);
  container.handleRequest(request);
  verify(container, times(1)).handleRequest(eq(request));
}
origin: bbilger/jrestless

@Test
public void reload_ConfigGiven_ShouldReloadNewAppHandler() {
  ResourceConfig config = new ApplicationHandler().getConfiguration();
  ApplicationHandler newAppHandler = mock(ApplicationHandler.class);
  doReturn(newAppHandler).when(container).createNewApplicationHandler(any());
  container.reload(config);
  verify(newAppHandler, times(1)).onReload(container);
}
com.jrestless.core.containerJRestlessHandlerContainer

Javadoc

Jersey container for any kind of serverless requests.

An implementation of Container that allows handling serverless requests ( #handleRequest(JRestlessContainerRequest,JRestlessResponseWriter,SecurityContext)).

Most used methods

  • handleRequest
    Delegates the container request to the application.
  • <init>
  • createContainerRequest
    Creates a new ContainerRequest for the given input.
  • createNewApplicationHandler
  • getConfiguration
  • onShutdown
    Inform this container that the server is being stopped. This method must be implicitly called before
  • onStartup
    Inform this container that the server has been started. This method must be implicitly called after
  • reload
  • getApplicationHandler

Popular in Java

  • Updating database using SQL prepared statement
  • runOnUiThread (Activity)
  • getSystemService (Context)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • Component (java.awt)
    A component is an object having a graphical representation that can be displayed on the screen and t
  • BufferedWriter (java.io)
    Wraps an existing Writer and buffers the output. Expensive interaction with the underlying reader is
  • IOException (java.io)
    Signals a general, I/O-related error. Error details may be specified when calling the constructor, a
  • Socket (java.net)
    Provides a client-side TCP socket.
  • SQLException (java.sql)
    An exception that indicates a failed JDBC operation. It provides the following information about pro
  • Modifier (javassist)
    The Modifier class provides static methods and constants to decode class and member access modifiers
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now