Search in sources :

Example 1 with Task

use of io.dropwizard.servlets.tasks.Task in project dropwizard by dropwizard.

the class AdminEnvironment method logTasks.

private void logTasks() {
    final StringBuilder stringBuilder = new StringBuilder(1024).append(String.format("%n%n"));
    for (Task task : tasks.getTasks()) {
        final String taskClassName = firstNonNull(task.getClass().getCanonicalName(), task.getClass().getName());
        stringBuilder.append(String.format("    %-7s /tasks/%s (%s)%n", "POST", task.getName(), taskClassName));
    }
    LOGGER.info("tasks = {}", stringBuilder.toString());
}
Also used : LogConfigurationTask(io.dropwizard.servlets.tasks.LogConfigurationTask) GarbageCollectionTask(io.dropwizard.servlets.tasks.GarbageCollectionTask) Task(io.dropwizard.servlets.tasks.Task)

Example 2 with Task

use of io.dropwizard.servlets.tasks.Task in project dropwizard by dropwizard.

the class AdminEnvironmentTest method addsATaskServlet.

@Test
public void addsATaskServlet() throws Exception {
    final Task task = new Task("thing") {

        @Override
        public void execute(ImmutableMultimap<String, String> parameters, PrintWriter output) throws Exception {
        }
    };
    env.addTask(task);
    handler.setServer(new Server());
    handler.start();
    final ServletRegistration registration = handler.getServletHandler().getServletContext().getServletRegistration("tasks");
    assertThat(registration.getMappings()).containsOnly("/tasks/*");
}
Also used : Task(io.dropwizard.servlets.tasks.Task) ServletRegistration(javax.servlet.ServletRegistration) Server(org.eclipse.jetty.server.Server) ImmutableMultimap(com.google.common.collect.ImmutableMultimap) PrintWriter(java.io.PrintWriter) Test(org.junit.Test)

Aggregations

Task (io.dropwizard.servlets.tasks.Task)2 ImmutableMultimap (com.google.common.collect.ImmutableMultimap)1 GarbageCollectionTask (io.dropwizard.servlets.tasks.GarbageCollectionTask)1 LogConfigurationTask (io.dropwizard.servlets.tasks.LogConfigurationTask)1 PrintWriter (java.io.PrintWriter)1 ServletRegistration (javax.servlet.ServletRegistration)1 Server (org.eclipse.jetty.server.Server)1 Test (org.junit.Test)1