[JAVA-13854] Half list moved (#12598)

* [JAVA-13854] added parent module

* [JAVA-13854] moved apache-tapestry(submodule) to web-modules(parent)

* [JAVA-13854] moved bootique(submodule) to web-modules(parent)

* [JAVA-13854] moved dropwizard(submodule) to web-modules(parent)

* [JAVA-13854] moved blade(submodule) to web-modules(parent)

* [JAVA-13854] moved java-lite(submodule) to web-modules(parent)

* [JAVA-13854] moved jooby(submodule) to web-modules(parent)

* [JAVA-13854] moved linkrest(submodule) to web-modules(parent)

* [JAVA-13854] moved ninja(submodule) to web-modules(parent)

* [JAVA-13854] moved ratpack(submodule) to web-modules(parent)

* [JAVA-13854] moved resteasy(submodule) to web-modules(parent)

* [JAVA-13854] moved restx(submodule) to web-modules(parent)

* [JAVA-13854] moved spark-java(submodule) to web-modules(parent)

* [JAVA-13854] moved vraptor(submodule) to web-modules(parent)

* [JAVA-13854] delete modules that were moved

* [JAVA-13854]

* [JAVA-13854]

* [JAVA-13854] delete ninja submodule  + moved raml(submodule) to web-modules(parent)

* [JAVA-13854] moved gwt(submodule) to web-modules(parent)

* [JAVA-13854] moved jakarta-ee(submodule) to web-modules(parent)

* [JAVA-13854] moved javax-servlets(submodule) to web-modules(parent)

* [JAVA-13854] moved javax-servlets-2(submodule) to web-modules(parent)

* [JAVA-13854] moved jee-7(submodule) to web-modules(parent)

* [JAVA-13854] moved play-framework(not a module) to web-modules

* [JAVA-13854] fix failing test

* [JAVA-13854] moved struts-2(submodule) to web-modules(parent)

* [JAVA-13854] moved wicket(submodule) to web-modules(parent)

* [JAVA-13854] deleted modules that were moved to web-modules

* JAVA-13854 Removed moved modules from the main pom.xml

Co-authored-by: panagiotiskakos <panagiotis.kakos@libra-is.com>
Co-authored-by: Dhawal Kapil <dhawalkapil@gmail.com>
This commit is contained in:
panos-kakos
2022-08-21 10:14:00 +01:00
committed by GitHub
parent 842a71ad92
commit 0b9549bd3e
755 changed files with 768 additions and 755 deletions
@@ -0,0 +1,51 @@
package com.baeldung.dropwizard.introduction;
import com.baeldung.dropwizard.introduction.configuration.ApplicationHealthCheck;
import com.baeldung.dropwizard.introduction.configuration.BasicConfiguration;
import com.baeldung.dropwizard.introduction.domain.Brand;
import com.baeldung.dropwizard.introduction.repository.BrandRepository;
import com.baeldung.dropwizard.introduction.resource.BrandResource;
import io.dropwizard.Application;
import io.dropwizard.configuration.ResourceConfigurationSourceProvider;
import io.dropwizard.setup.Bootstrap;
import io.dropwizard.setup.Environment;
import java.util.ArrayList;
import java.util.List;
public class IntroductionApplication extends Application<BasicConfiguration> {
public static void main(final String[] args) throws Exception {
new IntroductionApplication().run("server", "introduction-config.yml");
}
@Override
public void run(final BasicConfiguration basicConfiguration, final Environment environment) {
final int defaultSize = basicConfiguration.getDefaultSize();
final BrandRepository brandRepository = new BrandRepository(initBrands());
final BrandResource brandResource = new BrandResource(defaultSize, brandRepository);
environment
.jersey()
.register(brandResource);
final ApplicationHealthCheck healthCheck = new ApplicationHealthCheck();
environment
.healthChecks()
.register("application", healthCheck);
}
@Override
public void initialize(final Bootstrap<BasicConfiguration> bootstrap) {
bootstrap.setConfigurationSourceProvider(new ResourceConfigurationSourceProvider());
super.initialize(bootstrap);
}
private List<Brand> initBrands() {
final List<Brand> brands = new ArrayList<>();
brands.add(new Brand(1L, "Brand1"));
brands.add(new Brand(2L, "Brand2"));
brands.add(new Brand(3L, "Brand3"));
return brands;
}
}
@@ -0,0 +1,10 @@
package com.baeldung.dropwizard.introduction.configuration;
import com.codahale.metrics.health.HealthCheck;
public class ApplicationHealthCheck extends HealthCheck {
@Override
protected Result check() throws Exception {
return Result.healthy();
}
}
@@ -0,0 +1,20 @@
package com.baeldung.dropwizard.introduction.configuration;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.dropwizard.Configuration;
import javax.validation.constraints.NotNull;
public class BasicConfiguration extends Configuration {
@NotNull private final int defaultSize;
@JsonCreator
public BasicConfiguration(@JsonProperty("defaultSize") final int defaultSize) {
this.defaultSize = defaultSize;
}
public int getDefaultSize() {
return defaultSize;
}
}
@@ -0,0 +1,19 @@
package com.baeldung.dropwizard.introduction.domain;
public class Brand {
private final Long id;
private final String name;
public Brand(final Long id, final String name) {
this.id = id;
this.name = name;
}
public Long getId() {
return id;
}
public String getName() {
return name;
}
}
@@ -0,0 +1,32 @@
package com.baeldung.dropwizard.introduction.repository;
import com.baeldung.dropwizard.introduction.domain.Brand;
import com.google.common.collect.ImmutableList;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
public class BrandRepository {
private final List<Brand> brands;
public BrandRepository(final List<Brand> brands) {
this.brands = ImmutableList.copyOf(brands);
}
public List<Brand> findAll(final int size) {
return brands
.stream()
.limit(size)
.collect(Collectors.toList());
}
public Optional<Brand> findById(final Long id) {
return brands
.stream()
.filter(brand -> brand
.getId()
.equals(id))
.findFirst();
}
}
@@ -0,0 +1,35 @@
package com.baeldung.dropwizard.introduction.resource;
import com.baeldung.dropwizard.introduction.domain.Brand;
import com.baeldung.dropwizard.introduction.repository.BrandRepository;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import java.util.List;
import java.util.Optional;
@Path("/brands")
@Produces(MediaType.APPLICATION_JSON)
public class BrandResource {
private final int defaultSize;
private final BrandRepository brandRepository;
public BrandResource(final int defaultSize, final BrandRepository brandRepository) {
this.defaultSize = defaultSize;
this.brandRepository = brandRepository;
}
@GET
public List<Brand> getBrands(@QueryParam("size") final Optional<Integer> size) {
return brandRepository.findAll(size.orElse(defaultSize));
}
@GET
@Path("/{id}")
public Brand getById(@PathParam("id") final Long id) {
return brandRepository
.findById(id)
.orElseThrow(RuntimeException::new);
}
}
@@ -0,0 +1 @@
defaultSize: 5