diff options
author | Harald Musum <musum@verizonmedia.com> | 2021-07-11 22:47:44 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-11 22:47:44 +0200 |
commit | 162330a00e6c5a3ed0a0567a99aaa340bb6bd347 (patch) | |
tree | 1eda97f4939f848f932a3e6dc0f8883e9a59b3cf | |
parent | 2b6306d9214a358d19e0faf609c4c152371469b8 (diff) | |
parent | 4baf27b1d1fcd2bc040f4ca240e8de2abb207cef (diff) |
Merge pull request #18589 from vespa-engine/remove-container-jersey-2
40 files changed, 1 insertions, 1194 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 1b1934a8a08..3598d259144 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,7 +65,6 @@ add_subdirectory(configutil) add_subdirectory(container-apache-http-client-bundle) add_subdirectory(container-core) add_subdirectory(container-disc) -add_subdirectory(container-jersey2) add_subdirectory(container-messagebus) add_subdirectory(container-search) add_subdirectory(container-search-gui) diff --git a/cloud-tenant-base-dependencies-enforcer/pom.xml b/cloud-tenant-base-dependencies-enforcer/pom.xml index 340123ae659..481211390e0 100644 --- a/cloud-tenant-base-dependencies-enforcer/pom.xml +++ b/cloud-tenant-base-dependencies-enforcer/pom.xml @@ -152,7 +152,6 @@ <include>com.yahoo.vespa:container-dev:*:jar:provided</include> <include>com.yahoo.vespa:container-disc:*:jar:provided</include> <include>com.yahoo.vespa:container-documentapi:*:jar:provided</include> - <include>com.yahoo.vespa:container-jersey2:*:jar:provided</include> <include>com.yahoo.vespa:container-messagebus:*:jar:provided</include> <include>com.yahoo.vespa:container-search-and-docproc:*:jar:provided</include> <include>com.yahoo.vespa:container-search:*:jar:provided</include> diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/ApplicationContainerCluster.java b/config-model/src/main/java/com/yahoo/vespa/model/container/ApplicationContainerCluster.java index 317ed0f66c7..59e9b1a2b4d 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/ApplicationContainerCluster.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/container/ApplicationContainerCluster.java @@ -34,8 +34,6 @@ import com.yahoo.vespa.model.container.component.Handler; import com.yahoo.vespa.model.container.component.Servlet; import com.yahoo.vespa.model.container.component.SystemBindingPattern; import com.yahoo.vespa.model.container.configserver.ConfigserverCluster; -import com.yahoo.vespa.model.container.jersey.Jersey2Servlet; -import com.yahoo.vespa.model.container.jersey.RestApi; import com.yahoo.vespa.model.container.xml.PlatformBundles; import com.yahoo.vespa.model.utils.FileSender; @@ -80,7 +78,6 @@ public final class ApplicationContainerCluster extends ContainerCluster<Applicat private final Set<FileReference> applicationBundles = new LinkedHashSet<>(); private final ConfigProducerGroup<Servlet> servletGroup; - private final ConfigProducerGroup<RestApi> restApiGroup; private final Set<String> previousHosts; private ContainerModelEvaluation modelEvaluation; @@ -95,7 +92,6 @@ public final class ApplicationContainerCluster extends ContainerCluster<Applicat public ApplicationContainerCluster(AbstractConfigProducer<?> parent, String configSubId, String clusterId, DeployState deployState) { super(parent, configSubId, clusterId, deployState, true); this.tlsClientAuthority = deployState.tlsClientAuthority(); - restApiGroup = new ConfigProducerGroup<>(this, "rest-api"); servletGroup = new ConfigProducerGroup<>(this, "servlet"); previousHosts = deployState.getPreviousModel().stream() .map(Model::allocatedHosts) @@ -121,8 +117,6 @@ public final class ApplicationContainerCluster extends ContainerCluster<Applicat if (modelEvaluation != null) modelEvaluation.prepare(containers); sendUserConfiguredFiles(deployState); - for (RestApi restApi : restApiGroup.getComponents()) - restApi.prepare(); } private void addAndSendApplicationBundles(DeployState deployState) { @@ -166,15 +160,6 @@ public final class ApplicationContainerCluster extends ContainerCluster<Applicat this.modelEvaluation = modelEvaluation; } - public final void addRestApi(RestApi restApi) { - restApiGroup.addComponent(ComponentId.fromString(restApi.getBindingPath()), restApi); - } - - public Map<ComponentId, RestApi> getRestApiMap() { - return restApiGroup.getComponentMap(); - } - - public Map<ComponentId, Servlet> getServletMap() { return servletGroup.getComponentMap(); } @@ -183,18 +168,12 @@ public final class ApplicationContainerCluster extends ContainerCluster<Applicat servletGroup.addComponent(servlet.getGlobalComponentId(), servlet); } - // Returns all servlets, including rest-api/jersey servlets. public Collection<Servlet> getAllServlets() { return allServlets().collect(Collectors.toCollection(ArrayList::new)); } private Stream<Servlet> allServlets() { - return Stream.concat(allJersey2Servlets(), - servletGroup.getComponents().stream()); - } - - private Stream<Jersey2Servlet> allJersey2Servlets() { - return restApiGroup.getComponents().stream().map(RestApi::getJersey2Servlet); + return servletGroup.getComponents().stream(); } public void setMemoryPercentage(Integer memoryPercentage) { this.memoryPercentage = memoryPercentage; diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/jersey/Jersey2Servlet.java b/config-model/src/main/java/com/yahoo/vespa/model/container/jersey/Jersey2Servlet.java deleted file mode 100644 index 06775d59654..00000000000 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/jersey/Jersey2Servlet.java +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.model.container.jersey; - -import com.yahoo.component.ComponentId; -import com.yahoo.component.ComponentSpecification; -import com.yahoo.component.VersionSpecification; -import com.yahoo.container.bundle.BundleInstantiationSpecification; -import com.yahoo.osgi.provider.model.ComponentModel; -import com.yahoo.vespa.model.container.component.Servlet; - -/** - * @author Tony Vaagenes - */ -public class Jersey2Servlet extends Servlet { - - public static final String BUNDLE = "container-jersey2"; - public static final String CLASS = "com.yahoo.container.servlet.jersey.JerseyServletProvider"; - public static final String BINDING_SUFFIX = "/*"; - - private static final ComponentId REST_API_NAMESPACE = ComponentId.fromString("rest-api"); - - public Jersey2Servlet(String bindingPath) { - super(new ComponentModel( - new BundleInstantiationSpecification(idSpecFromPath(bindingPath), - ComponentSpecification.fromString(CLASS), - ComponentSpecification.fromString(BUNDLE))), - bindingPath + BINDING_SUFFIX); - } - - private static ComponentSpecification idSpecFromPath(String path) { - return new ComponentSpecification(RestApi.idFromPath(path), - VersionSpecification.emptyVersionSpecification, - REST_API_NAMESPACE); - } - -} diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/jersey/RestApi.java b/config-model/src/main/java/com/yahoo/vespa/model/container/jersey/RestApi.java deleted file mode 100644 index be8209bcc4e..00000000000 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/jersey/RestApi.java +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.model.container.jersey; - -import com.yahoo.config.model.producer.AbstractConfigProducer; - -/** - * Represents a rest-api - * - * @author gjoranv - */ -public class RestApi extends AbstractConfigProducer<AbstractConfigProducer<?>> { - - private final String bindingPath; - private final Jersey2Servlet jerseyServlet; - private RestApiContext restApiContext; - - public RestApi(String bindingPath) { - super(idFromPath(bindingPath)); - this.bindingPath = bindingPath; - - jerseyServlet = createJersey2Servlet(this.bindingPath); - addChild(jerseyServlet); - } - - public static String idFromPath(String path) { - return path.replaceAll("/", "|"); - } - - private Jersey2Servlet createJersey2Servlet(String bindingPath) { - return new Jersey2Servlet(bindingPath); - } - - public String getBindingPath() { - return bindingPath; - } - - public void setRestApiContext(RestApiContext restApiContext) { - this.restApiContext = restApiContext; - addChild(restApiContext); - jerseyServlet.inject(restApiContext); - } - - public RestApiContext getContext() { return restApiContext; } - - public Jersey2Servlet getJersey2Servlet() { - return jerseyServlet; - } - - public void prepare() { - restApiContext.prepare(); - } -} diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/jersey/RestApiContext.java b/config-model/src/main/java/com/yahoo/vespa/model/container/jersey/RestApiContext.java deleted file mode 100644 index 390539b643a..00000000000 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/jersey/RestApiContext.java +++ /dev/null @@ -1,141 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.model.container.jersey; - -import com.yahoo.config.model.producer.AbstractConfigProducer; -import com.yahoo.container.bundle.BundleInstantiationSpecification; -import com.yahoo.container.di.config.JerseyBundlesConfig; -import com.yahoo.container.di.config.JerseyInjectionConfig; -import com.yahoo.container.di.config.JerseyInjectionConfig.Inject; -import com.yahoo.osgi.provider.model.ComponentModel; -import com.yahoo.vespa.model.container.ApplicationContainerCluster; -import com.yahoo.vespa.model.container.component.Component; -import com.yahoo.vespa.model.container.component.SimpleComponent; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.function.Predicate; -import java.util.logging.Logger; - -/** - * @author gjoranv - */ -public class RestApiContext extends SimpleComponent implements - JerseyBundlesConfig.Producer, - JerseyInjectionConfig.Producer -{ - private static final Logger log = Logger.getLogger(RestApi.class.getName()); - public static final String CONTAINER_CLASS = "com.yahoo.container.di.config.RestApiContext"; - - private final List<BundleInfo> bundles = new ArrayList<>(); - - // class name -> componentId - private final Map<String, String> injectComponentForClass = new LinkedHashMap<>(); - - private final String bindingPath; - - private ApplicationContainerCluster containerCluster; - - public RestApiContext(AbstractConfigProducer<?> ancestor, String bindingPath) { - super(componentModel(bindingPath)); - this.bindingPath = bindingPath; - - if (ancestor instanceof ApplicationContainerCluster) - containerCluster = (ApplicationContainerCluster)ancestor; - - } - - private static ComponentModel componentModel(String bindingPath) { - return new ComponentModel(BundleInstantiationSpecification.getFromStrings( - CONTAINER_CLASS + "-" + RestApi.idFromPath(bindingPath), - CONTAINER_CLASS, - null)); - } - - @Override - public void getConfig(JerseyBundlesConfig.Builder builder) { - builder.bundles(createBundlesConfig(bundles)); - } - - private List<JerseyBundlesConfig.Bundles.Builder> createBundlesConfig(List<BundleInfo> bundles) { - List<JerseyBundlesConfig.Bundles.Builder> builders = new ArrayList<>(); - for (BundleInfo b : bundles) { - builders.add( - new JerseyBundlesConfig.Bundles.Builder() - .spec(b.spec) - .packages(b.getPackagesToScan()) - ); - } - return builders; - } - - public void addBundles(Collection<BundleInfo> newBundles) { - bundles.addAll(newBundles); - } - - @Override - public void getConfig(JerseyInjectionConfig.Builder builder) { - for (Map.Entry<String, String> i : injectComponentForClass.entrySet()) { - builder.inject(new Inject.Builder() - .forClass(i.getKey()) - .instance(i.getValue())); - } - } - - @Override - public void validate() throws Exception { - super.validate(); - - if (bundles.isEmpty()) - log.warning("No bundles in rest-api '" + bindingPath + - "' - components will only be loaded from classpath."); - } - - public void prepare() { - if (containerCluster == null) return; - - containerCluster.getAllComponents().stream(). - filter(isCycleGeneratingComponent.negate()). - forEach(this::inject); - } - - - /* - * Example problem - * - * RestApiContext -> ApplicationStatusHandler -> ComponentRegistry<HttpServer> -> JettyHttpServer -> ComponentRegistry<Jersey2Servlet> -> RestApiContext - */ - private Predicate<Component> isCycleGeneratingComponent = component -> { - switch (component.getClassId().getName()) { - case CONTAINER_CLASS: - case Jersey2Servlet.CLASS: - case "com.yahoo.jdisc.http.server.jetty.JettyHttpServer": - case "com.yahoo.container.handler.observability.ApplicationStatusHandler": - return true; - default: - return false; - } - }; - - public static class BundleInfo { - // SymbolicName[:Version] - public final String spec; - - private final List<String> packagesToScan = new ArrayList<>(); - - public BundleInfo(String spec) { - this.spec = spec; - } - - public List<String> getPackagesToScan() { - return packagesToScan; - } - - public void addPackageToScan(String pkg) { - packagesToScan.add(pkg); - } - } - -} diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/jersey/xml/RestApiBuilder.java b/config-model/src/main/java/com/yahoo/vespa/model/container/jersey/xml/RestApiBuilder.java deleted file mode 100644 index 4aa5882119f..00000000000 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/jersey/xml/RestApiBuilder.java +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.model.container.jersey.xml; - -import com.yahoo.config.model.deploy.DeployState; -import com.yahoo.config.model.producer.AbstractConfigProducer; -import com.yahoo.text.XML; -import com.yahoo.vespa.model.builder.xml.dom.VespaDomBuilder; -import com.yahoo.vespa.model.container.jersey.RestApi; -import com.yahoo.vespa.model.container.jersey.RestApiContext; -import org.w3c.dom.Element; - -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -/** - * @author gjoranv - * @since 5.6 - */ -public class RestApiBuilder extends VespaDomBuilder.DomConfigProducerBuilder<RestApi> { - - @Override - protected RestApi doBuild(DeployState deployState, AbstractConfigProducer ancestor, Element spec) { - String bindingPath = spec.getAttribute("path"); - RestApi restApi = new RestApi(bindingPath); - - restApi.setRestApiContext(createRestApiContext(ancestor, spec, bindingPath)); - return restApi; - } - - private RestApiContext createRestApiContext(AbstractConfigProducer ancestor, Element spec, String bindingPath) { - RestApiContext restApiContext = new RestApiContext(ancestor, bindingPath); - - restApiContext.addBundles(getBundles(spec)); - - return restApiContext; - } - - private List<RestApiContext.BundleInfo> getBundles(Element spec) { - List<RestApiContext.BundleInfo> bundles = new ArrayList<>(); - for (Element bundleElement : XML.getChildren(spec, "components")) { - bundles.add(getBundle(bundleElement)); - } - return bundles; - } - - private RestApiContext.BundleInfo getBundle(Element bundleElement) { - RestApiContext.BundleInfo bundle = new RestApiContext.BundleInfo(bundleElement.getAttribute("bundle")); - - for (Element packageElement : XML.getChildren(bundleElement, "package")) - bundle.addPackageToScan(XML.getValue(packageElement)); - - return bundle; - } - - // TODO: use for naming injected components instead - private Map<String, String> getInjections(Element spec) { - Map<String, String> injectForClass = new LinkedHashMap<>(); - for (Element injectElement : XML.getChildren(spec, "inject")) { - injectForClass.put(injectElement.getAttribute("for-class"), - injectElement.getAttribute("component")); - } - return injectForClass; - } - -} diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilder.java b/config-model/src/main/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilder.java index 5bf8aa5228e..4b45979c698 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilder.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilder.java @@ -184,7 +184,6 @@ public class ContainerModelBuilder extends ConfigModelBuilder<ContainerModel> { addConfiguredComponents(deployState, cluster, spec); addSecretStore(cluster, spec, deployState); - throwUponRestApi(spec); // TODO: remove addServlets(deployState, spec, cluster); addModelEvaluation(spec, cluster, context); addModelEvaluationBundles(cluster); @@ -517,12 +516,6 @@ public class ContainerModelBuilder extends ConfigModelBuilder<ContainerModel> { return http; } - private void throwUponRestApi(Element spec) { - if(! XML.getChildren(spec, "rest-api").isEmpty()) { - throw new IllegalArgumentException("The 'rest-api' element is no longer allowed in services.xml."); - } - } - private void addServlets(DeployState deployState, Element spec, ApplicationContainerCluster cluster) { for (Element servletElem : XML.getChildren(spec, "servlet")) cluster.addServlet(new ServletBuilder().build(deployState, cluster, servletElem)); diff --git a/config-model/src/main/resources/schema/containercluster.rnc b/config-model/src/main/resources/schema/containercluster.rnc index 3679e53e257..992689a2189 100644 --- a/config-model/src/main/resources/schema/containercluster.rnc +++ b/config-model/src/main/resources/schema/containercluster.rnc @@ -12,7 +12,6 @@ ContainerCluster = element container | jdisc { } ContainerServices = - RestApi* & Servlet* & SearchInContainer? & DocprocInContainer? & @@ -128,22 +127,6 @@ Threadpool = element threadpool { element queue-size { xsd:nonNegativeInteger } } -# REST-API: - -RestApi = element rest-api { - attribute path { xsd:string { pattern = "\w[\w_/\-\.]*" } } & - attribute jersey2 { xsd:boolean }? & - element components { - attribute bundle { xsd:Name } & - element package { xsd:NCName }* - }* - -# element inject { -# attribute component { xsd:Name } & -# attribute for-name { xsd:Name } -# }* -} - # Servlet: Servlet = element servlet { diff --git a/config-model/src/test/java/com/yahoo/vespa/model/container/jersey/xml/RestApiTest.java b/config-model/src/test/java/com/yahoo/vespa/model/container/jersey/xml/RestApiTest.java deleted file mode 100644 index c858024f749..00000000000 --- a/config-model/src/test/java/com/yahoo/vespa/model/container/jersey/xml/RestApiTest.java +++ /dev/null @@ -1,149 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.model.container.jersey.xml; - -import com.yahoo.component.ComponentId; -import com.yahoo.config.model.test.TestUtil; -import com.yahoo.container.ComponentsConfig; -import com.yahoo.container.di.config.JerseyBundlesConfig; -import com.yahoo.jdisc.http.ServletPathsConfig; -import com.yahoo.vespa.model.container.component.Component; -import com.yahoo.vespa.model.container.jersey.Jersey2Servlet; -import com.yahoo.vespa.model.container.jersey.RestApi; -import com.yahoo.vespa.model.container.jersey.RestApiContext; -import com.yahoo.vespa.model.container.xml.ContainerModelBuilderTestBase; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import org.w3c.dom.Element; - -import java.util.HashSet; -import java.util.Set; -import java.util.stream.Collectors; - -import static org.hamcrest.CoreMatchers.containsString; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.not; -import static org.hamcrest.CoreMatchers.nullValue; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.contains; -import static org.hamcrest.Matchers.containsInAnyOrder; - -/** - * @author gjoranv - * @author bjorncs - */ -@Ignore // TODO: remove test -public class RestApiTest extends ContainerModelBuilderTestBase { - private static final String PATH = "rest/api"; - private static final String REST_API_CONTEXT_ID = RestApiContext.CONTAINER_CLASS + "-" + RestApi.idFromPath(PATH); - private static final String INJECTED_COMPONENT_ID = "injectedHandler"; - private static final String CLUSTER_ID = "container"; - - private static final Element restApiXml = TestUtil.parse( - "<container version=\"1.0\" id=\"" + CLUSTER_ID + "\">", - " <rest-api path=\"" + PATH + "\">", - " <components bundle=\"my-jersey-bundle:1.0\">", - " <package>com.yahoo.foo</package>", - " </components>", - " </rest-api>", - " <handler id=\"" + INJECTED_COMPONENT_ID + "\" />", - "</container>"); - - private RestApi restApi; - private Jersey2Servlet servlet; - private RestApiContext context; - - @Before - public void setup() throws Exception { - createModel(root, restApiXml); - root.validate(); - getContainerCluster(CLUSTER_ID).prepare(root.getDeployState()); - restApi = getContainerCluster(CLUSTER_ID).getRestApiMap().values().iterator().next(); - servlet = restApi.getJersey2Servlet(); - context = restApi.getContext(); - } - - @Test - public void jersey2_servlet_has_correct_binding_path() { - assertThat(servlet, not(nullValue())); - assertThat(servlet.bindingPath, is(PATH + "/*")); - } - - @Test - public void jersey2_servlet_has_correct_bundle_spec() { - assertThat(servlet.model.bundleInstantiationSpec.bundle.stringValue(), is(Jersey2Servlet.BUNDLE)); - } - - @Test - public void rest_api_path_is_included_in_servlet_config() { - ServletPathsConfig config = root.getConfig(ServletPathsConfig.class, servlet.getConfigId()); - assertThat(config.servlets(servlet.getComponentId().stringValue()).path(), is(PATH + "/*")); - } - - @Test - public void resource_bundles_are_included_in_config() { - JerseyBundlesConfig config = root.getConfig(JerseyBundlesConfig.class, context.getConfigId()); - assertThat(config.bundles().size(), is(1)); - assertThat(config.bundles(0).spec(), is("my-jersey-bundle:1.0")); - } - - @Test - public void packages_to_scan_are_included_in_config() { - JerseyBundlesConfig config = root.getConfig(JerseyBundlesConfig.class, context.getConfigId()); - assertThat(config.bundles(0).packages(), contains("com.yahoo.foo")); - } - - @Test - public void jersey2_servlet_is_included_in_components_config() { - ComponentsConfig config = root.getConfig(ComponentsConfig.class, CLUSTER_ID); - assertThat(config.toString(), containsString(".id \"" + servlet.getComponentId().stringValue() + "\"")); - } - - @Test - public void restApiContext_is_included_in_components_config() { - ComponentsConfig config = root.getConfig(ComponentsConfig.class, CLUSTER_ID); - assertThat(config.toString(), containsString(".id \"" + REST_API_CONTEXT_ID + "\"")); - } - - @Test - public void all_non_restApi_components_are_injected_to_RestApiContext() { - ComponentsConfig componentsConfig = root.getConfig(ComponentsConfig.class, CLUSTER_ID); - - Set<ComponentId> clusterChildrenComponentIds = getContainerCluster(CLUSTER_ID).getAllComponents().stream() - .map(Component::getComponentId) - .collect(Collectors.toSet()); - - Set<ComponentId> restApiChildrenComponentIds = restApi.getChildren().values().stream() - .map(child -> ((Component<?, ?>) child).getComponentId()) - .collect(Collectors.toSet()); - - //TODO: try replacing with filtering against RestApiContext.isCycleGeneratingComponent - ComponentId cycleInducingComponents = ComponentId.fromString("com.yahoo.container.handler.observability.ApplicationStatusHandler"); - - Set<ComponentId> expectedInjectedConfigIds = new HashSet<>(clusterChildrenComponentIds); - expectedInjectedConfigIds.removeAll(restApiChildrenComponentIds); - expectedInjectedConfigIds.remove(cycleInducingComponents); - - Set<ComponentId> injectedConfigIds = restApiContextConfig(componentsConfig).inject().stream() - .map(inject -> ComponentId.fromString(inject.id())) - .collect(Collectors.toSet()); - - // Verify that the two sets are equal. Split in two asserts to get decent failure messages. - assertThat( - "Not all required components are injected", - injectedConfigIds, - containsInAnyOrder(expectedInjectedConfigIds.toArray())); - assertThat( - "We inject some components that should not be injected", - expectedInjectedConfigIds, - containsInAnyOrder(injectedConfigIds.toArray())); - } - - private static ComponentsConfig.Components restApiContextConfig(ComponentsConfig config) { - return config.components().stream() - .filter(component -> component.classId().equals(RestApiContext.CONTAINER_CLASS)) - .findFirst() - .get(); - } - -} diff --git a/config-model/src/test/schema-test-files/services.xml b/config-model/src/test/schema-test-files/services.xml index 4ad7865c93b..8477f8fcbea 100644 --- a/config-model/src/test/schema-test-files/services.xml +++ b/config-model/src/test/schema-test-files/services.xml @@ -58,18 +58,6 @@ <group name="foo" environment="aws_stage" /> </secret-store> - <rest-api path="jersey1"> - <components bundle="my-bundle" /> - <components bundle="other-bundle"> - <package>com.yahoo.foo</package> - <package>com.yahoo.bar</package> - </components> - - </rest-api> - <rest-api path="jersey/2"> - <components bundle="my-bundle" /> - </rest-api> - <servlet id="my-servlet" class="com.yahoo.MyServlet" bundle="my-bundle"> <path>p/a/t/h</path> </servlet> diff --git a/config-model/src/test/schema-test-files/standalone-container.xml b/config-model/src/test/schema-test-files/standalone-container.xml index b77654521ee..a7769a2f57b 100644 --- a/config-model/src/test/schema-test-files/standalone-container.xml +++ b/config-model/src/test/schema-test-files/standalone-container.xml @@ -1,21 +1,6 @@ <?xml version="1.0" encoding="utf-8" ?> <!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> <container id='qrsCluster_1' version='1.0'> - <rest-api path="jersey1"> - <components bundle="my-bundle" /> - <components bundle="other-bundle" /> -<!-- - <inject component="foo-component" for-name="com.yahoo.Foo" /> - <inject component="bar-component" for-name="com.yahoo.Bar" /> ---> - </rest-api> - <rest-api path="jersey/2"> - <components bundle="my-bundle" /> - <components bundle="other-bundle"> - <package>com.yahoo.foo</package> - <package>com.yahoo.bar</package> - </components> - </rest-api> <servlet id="my-servlet" class="com.yahoo.MyServlet" bundle="my-bundle"> <path>p/a/t/h</path> diff --git a/configserver/pom.xml b/configserver/pom.xml index a237d7e00ad..ac98cfa5d5d 100644 --- a/configserver/pom.xml +++ b/configserver/pom.xml @@ -168,12 +168,6 @@ <scope>provided</scope> </dependency> <dependency> - <groupId>com.yahoo.vespa</groupId> - <artifactId>container-jersey2</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - </dependency> - <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> <scope>provided</scope> diff --git a/container-dev/pom.xml b/container-dev/pom.xml index cfe9c0a6d8e..6366022c342 100644 --- a/container-dev/pom.xml +++ b/container-dev/pom.xml @@ -96,11 +96,6 @@ </dependency> <dependency> <groupId>com.yahoo.vespa</groupId> - <artifactId>container-jersey2</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>com.yahoo.vespa</groupId> <artifactId>vespa_jersey2</artifactId> <version>${project.version}</version> <type>pom</type> diff --git a/container-disc/pom.xml b/container-disc/pom.xml index 1acd6043498..b255b6af02a 100644 --- a/container-disc/pom.xml +++ b/container-disc/pom.xml @@ -170,7 +170,6 @@ configgen.jar, config-bundle-jar-with-dependencies.jar, configdefinitions-jar-with-dependencies.jar, - container-jersey2-jar-with-dependencies.jar, container-search-and-docproc-jar-with-dependencies.jar, container-search-gui-jar-with-dependencies.jar, docprocs-jar-with-dependencies.jar, diff --git a/container-jersey2/.gitignore b/container-jersey2/.gitignore deleted file mode 100644 index ea8c4bf7f35..00000000000 --- a/container-jersey2/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/target diff --git a/container-jersey2/CMakeLists.txt b/container-jersey2/CMakeLists.txt deleted file mode 100644 index d2490563372..00000000000 --- a/container-jersey2/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -# Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -install_fat_java_artifact(container-jersey2) diff --git a/container-jersey2/OWNERS b/container-jersey2/OWNERS deleted file mode 100644 index 3b2ba1ede81..00000000000 --- a/container-jersey2/OWNERS +++ /dev/null @@ -1 +0,0 @@ -gjoranv diff --git a/container-jersey2/README.md b/container-jersey2/README.md deleted file mode 100644 index 43f83ddccbe..00000000000 --- a/container-jersey2/README.md +++ /dev/null @@ -1,4 +0,0 @@ -<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> -# JDisc Jersey integration - -The integration layer between JDisc and Jersey2. diff --git a/container-jersey2/abi-spec.json b/container-jersey2/abi-spec.json deleted file mode 100644 index 2f5ef3efb70..00000000000 --- a/container-jersey2/abi-spec.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "com.yahoo.container.jaxrs.annotation.Component": { - "superClass": "java.lang.Object", - "interfaces": [ - "java.lang.annotation.Annotation" - ], - "attributes": [ - "public", - "interface", - "abstract", - "annotation" - ], - "methods": [], - "fields": [] - } -}
\ No newline at end of file diff --git a/container-jersey2/pom.xml b/container-jersey2/pom.xml deleted file mode 100644 index 8f24b5edcb7..00000000000 --- a/container-jersey2/pom.xml +++ /dev/null @@ -1,89 +0,0 @@ -<?xml version="1.0"?> -<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> -<project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 - http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>com.yahoo.vespa</groupId> - <artifactId>parent</artifactId> - <version>7-SNAPSHOT</version> - <relativePath>../parent/pom.xml</relativePath> - </parent> - <artifactId>container-jersey2</artifactId> - <version>7-SNAPSHOT</version> - <packaging>container-plugin</packaging> - <dependencies> - - <!-- COMPILE scope --> - <dependency> - <groupId>org.ow2.asm</groupId> - <artifactId>asm</artifactId> - </dependency> - - - <!-- PROVIDED scope --> - <dependency> - <groupId>com.yahoo.vespa</groupId> - <artifactId>annotations</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>com.yahoo.vespa</groupId> - <artifactId>component</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>com.yahoo.vespa</groupId> - <artifactId>container-core</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>com.yahoo.vespa</groupId> - <artifactId>jdisc_core</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>com.yahoo.vespa</groupId> - <artifactId>vespa_jersey2</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - <type>pom</type> - </dependency> - <dependency> - <groupId>org.eclipse.jetty</groupId> - <artifactId>jetty-servlet</artifactId> - <scope>provided</scope> - </dependency> - - <!-- TEST scope --> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - </dependencies> - <build> - <plugins> - <plugin> - <groupId>com.yahoo.vespa</groupId> - <artifactId>bundle-plugin</artifactId> - <extensions>true</extensions> - </plugin> - <plugin> - <groupId>com.yahoo.vespa</groupId> - <artifactId>abi-check-plugin</artifactId> - </plugin> - <plugin> - <!-- Explicit for IntelliJ to detect correct language level from parent --> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-compiler-plugin</artifactId> - </plugin> - </plugins> - </build> -</project> diff --git a/container-jersey2/src/main/java/com/yahoo/container/jaxrs/annotation/Component.java b/container-jersey2/src/main/java/com/yahoo/container/jaxrs/annotation/Component.java deleted file mode 100644 index da8f35eaa00..00000000000 --- a/container-jersey2/src/main/java/com/yahoo/container/jaxrs/annotation/Component.java +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.container.jaxrs.annotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Annotation for injecting jdisc container components into jaxrs resources and providers - * @author Tony Vaagenes - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.PARAMETER) -public @interface Component {} - - diff --git a/container-jersey2/src/main/java/com/yahoo/container/jaxrs/annotation/package-info.java b/container-jersey2/src/main/java/com/yahoo/container/jaxrs/annotation/package-info.java deleted file mode 100644 index 8628d52bbb8..00000000000 --- a/container-jersey2/src/main/java/com/yahoo/container/jaxrs/annotation/package-info.java +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -/** - * @author Tony Vaagenes - */ -@PublicApi -@ExportPackage -package com.yahoo.container.jaxrs.annotation; - -import com.yahoo.api.annotations.PublicApi; -import com.yahoo.osgi.annotation.ExportPackage; diff --git a/container-jersey2/src/main/java/com/yahoo/container/servlet/jersey/ComponentGraphProvider.java b/container-jersey2/src/main/java/com/yahoo/container/servlet/jersey/ComponentGraphProvider.java deleted file mode 100644 index 7ff9646cb27..00000000000 --- a/container-jersey2/src/main/java/com/yahoo/container/servlet/jersey/ComponentGraphProvider.java +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.container.servlet.jersey; - -import com.yahoo.container.di.config.ResolveDependencyException; -import com.yahoo.container.di.config.RestApiContext; -import com.yahoo.container.jaxrs.annotation.Component; -import org.glassfish.hk2.api.Injectee; -import org.glassfish.hk2.api.InjectionResolver; -import org.glassfish.hk2.api.ServiceHandle; - -import javax.inject.Singleton; - -import java.lang.reflect.Type; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.stream.Collectors; - -/** - * Resolves jdisc container components for jersey 2 components. - * - * @author Tony Vaagenes - * @author ollivir - */ -@Singleton // jersey2 requirement: InjectionResolvers must be in the Singleton scope -public class ComponentGraphProvider implements InjectionResolver<Component> { - private Collection<RestApiContext.Injectable> injectables; - - public ComponentGraphProvider(Collection<RestApiContext.Injectable> injectables) { - this.injectables = injectables; - } - - @Override - public Object resolve(Injectee injectee, ServiceHandle<?> root) { - Class<?> wantedClass; - Type type = injectee.getRequiredType(); - if (type instanceof Class) { - wantedClass = (Class<?>) type; - } else { - throw new UnsupportedOperationException("Only classes are supported, got " + type); - } - - List<RestApiContext.Injectable> componentsWithMatchingType = new ArrayList<>(); - for (RestApiContext.Injectable injectable : injectables) { - if (wantedClass.isInstance(injectable.instance)) { - componentsWithMatchingType.add(injectable); - } - } - - if (componentsWithMatchingType.size() == 1) { - return componentsWithMatchingType.get(0).instance; - } else { - String injectionDescription = "class '" + wantedClass + "' to inject into Jersey resource/provider '" - + injectee.getInjecteeClass() + "')"; - if (componentsWithMatchingType.size() > 1) { - String ids = componentsWithMatchingType.stream().map(c -> c.id.toString()).collect(Collectors.joining(",")); - throw new ResolveDependencyException("Multiple components found of " + injectionDescription + ": " + ids); - } else { - throw new ResolveDependencyException("Could not find a component of " + injectionDescription + "."); - } - } - } - - @Override - public boolean isMethodParameterIndicator() { - return true; - } - - @Override - public boolean isConstructorParameterIndicator() { - return true; - } -} diff --git a/container-jersey2/src/main/java/com/yahoo/container/servlet/jersey/JerseyApplication.java b/container-jersey2/src/main/java/com/yahoo/container/servlet/jersey/JerseyApplication.java deleted file mode 100644 index 4c4e43bc8d5..00000000000 --- a/container-jersey2/src/main/java/com/yahoo/container/servlet/jersey/JerseyApplication.java +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.container.servlet.jersey; - -import javax.ws.rs.core.Application; - -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; - -/** - * @author Tony Vaagenes - * @author ollivir - */ -public class JerseyApplication extends Application { - private Set<Class<?>> classes; - - public JerseyApplication(Collection<Class<?>> resourcesAndProviderClasses) { - this.classes = new HashSet<>(resourcesAndProviderClasses); - } - - @Override - public Set<Class<?>> getClasses() { - return classes; - } -} diff --git a/container-jersey2/src/main/java/com/yahoo/container/servlet/jersey/JerseyServletProvider.java b/container-jersey2/src/main/java/com/yahoo/container/servlet/jersey/JerseyServletProvider.java deleted file mode 100644 index b8c714fd3e3..00000000000 --- a/container-jersey2/src/main/java/com/yahoo/container/servlet/jersey/JerseyServletProvider.java +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.container.servlet.jersey; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.datatype.jdk8.Jdk8Module; -import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; -import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider; -import com.yahoo.container.di.componentgraph.Provider; -import com.yahoo.container.di.config.RestApiContext; -import com.yahoo.container.di.config.RestApiContext.BundleInfo; -import com.yahoo.container.jaxrs.annotation.Component; -import org.eclipse.jetty.servlet.ServletHolder; -import org.glassfish.hk2.api.InjectionResolver; -import org.glassfish.hk2.api.TypeLiteral; -import org.glassfish.hk2.utilities.Binder; -import org.glassfish.hk2.utilities.binding.AbstractBinder; -import org.glassfish.jersey.media.multipart.MultiPartFeature; -import org.glassfish.jersey.server.ResourceConfig; -import org.glassfish.jersey.servlet.ServletContainer; -import org.objectweb.asm.ClassReader; - -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Optional; - -import static com.yahoo.container.servlet.jersey.util.ResourceConfigUtil.registerComponent; - -/** - * @author Tony Vaagenes - * @author ollivir - */ -@SuppressWarnings("unused") // Injected -public class JerseyServletProvider implements Provider<ServletHolder> { - - private final ServletHolder jerseyServletHolder; - - public JerseyServletProvider(RestApiContext restApiContext) { - this.jerseyServletHolder = new ServletHolder(new ServletContainer(resourceConfig(restApiContext))); - } - - private ResourceConfig resourceConfig(RestApiContext restApiContext) { - ResourceConfig resourceConfig = ResourceConfig - .forApplication(new JerseyApplication(resourcesAndProviders(restApiContext.getBundles()))); - - registerComponent(resourceConfig, componentInjectorBinder(restApiContext)); - registerComponent(resourceConfig, jacksonDatatypeJdk8Provider()); - resourceConfig.register(MultiPartFeature.class); - - return resourceConfig; - } - - private static Collection<Class<?>> resourcesAndProviders(Collection<BundleInfo> bundles) { - List<Class<?>> ret = new ArrayList<>(); - - for (BundleInfo bundle : bundles) { - for (String classEntry : bundle.getClassEntries()) { - Optional<String> className = detectResourceOrProvider(bundle.classLoader, classEntry); - className.ifPresent(cname -> ret.add(loadClass(bundle.symbolicName, bundle.classLoader, cname))); - } - } - return ret; - } - - private static Optional<String> detectResourceOrProvider(ClassLoader bundleClassLoader, String classEntry) { - try (InputStream inputStream = getResourceAsStream(bundleClassLoader, classEntry)) { - ResourceOrProviderClassVisitor visitor = ResourceOrProviderClassVisitor.visit(new ClassReader(inputStream)); - return visitor.getJerseyClassName(); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - private static InputStream getResourceAsStream(ClassLoader bundleClassLoader, String classEntry) { - InputStream is = bundleClassLoader.getResourceAsStream(classEntry); - if (is == null) { - throw new RuntimeException("No entry " + classEntry + " in bundle " + bundleClassLoader); - } else { - return is; - } - } - - private static Class<?> loadClass(String bundleSymbolicName, ClassLoader classLoader, String className) { - try { - return classLoader.loadClass(className); - } catch (Exception e) { - throw new RuntimeException("Failed loading class " + className + " from bundle " + bundleSymbolicName, e); - } - } - - private static Binder componentInjectorBinder(RestApiContext restApiContext) { - final ComponentGraphProvider componentGraphProvider = new ComponentGraphProvider(restApiContext.getInjectableComponents()); - final TypeLiteral<InjectionResolver<Component>> componentAnnotationType = new TypeLiteral<InjectionResolver<Component>>() { - }; - - return new AbstractBinder() { - @Override - public void configure() { - bind(componentGraphProvider).to(componentAnnotationType); - } - }; - } - - private static JacksonJaxbJsonProvider jacksonDatatypeJdk8Provider() { - JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider(); - provider.setMapper(new ObjectMapper().registerModule(new Jdk8Module()).registerModule(new JavaTimeModule())); - return provider; - } - - @Override - public ServletHolder get() { - return jerseyServletHolder; - } - - @Override - public void deconstruct() { - } - -} diff --git a/container-jersey2/src/main/java/com/yahoo/container/servlet/jersey/ResourceOrProviderClassVisitor.java b/container-jersey2/src/main/java/com/yahoo/container/servlet/jersey/ResourceOrProviderClassVisitor.java deleted file mode 100644 index bf53cec670e..00000000000 --- a/container-jersey2/src/main/java/com/yahoo/container/servlet/jersey/ResourceOrProviderClassVisitor.java +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.container.servlet.jersey; - -import org.objectweb.asm.AnnotationVisitor; -import org.objectweb.asm.ClassReader; -import org.objectweb.asm.ClassVisitor; -import org.objectweb.asm.Opcodes; -import org.objectweb.asm.Type; - -import javax.ws.rs.Path; -import javax.ws.rs.ext.Provider; - -import java.util.HashSet; -import java.util.Optional; -import java.util.Set; - -/** - * @author Tony Vaagenes - * @author ollivir - */ -public class ResourceOrProviderClassVisitor extends ClassVisitor { - private String className = null; - private boolean isPublic = false; - private boolean isAbstract = false; - - private boolean isInnerClass = false; - private boolean isStatic = false; - - private boolean isAnnotated = false; - - public ResourceOrProviderClassVisitor() { - super(Opcodes.ASM7); - } - - public Optional<String> getJerseyClassName() { - if (isJerseyClass()) { - return Optional.of(getClassName()); - } else { - return Optional.empty(); - } - } - - public boolean isJerseyClass() { - return isAnnotated && isPublic && !isAbstract && (!isInnerClass || isStatic); - } - - public String getClassName() { - assert (className != null); - return org.objectweb.asm.Type.getObjectType(className).getClassName(); - } - - @Override - public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) { - isPublic = isPublic(access); - className = name; - isAbstract = isAbstract(access); - } - - @Override - public void visitInnerClass(String name, String outerName, String innerName, int access) { - assert (className != null); - - if (name.equals(className)) { - isInnerClass = true; - isStatic = isStatic(access); - } - } - - @Override - public AnnotationVisitor visitAnnotation(String desc, boolean visible) { - isAnnotated |= annotationClassDescriptors.contains(desc); - return null; - } - - private static Set<String> annotationClassDescriptors = new HashSet<>(); - - static { - annotationClassDescriptors.add(Type.getDescriptor(Path.class)); - annotationClassDescriptors.add(Type.getDescriptor(Provider.class)); - } - - private static boolean isPublic(int access) { - return isSet(Opcodes.ACC_PUBLIC, access); - } - - private static boolean isStatic(int access) { - return isSet(Opcodes.ACC_STATIC, access); - } - - private static boolean isAbstract(int access) { - return isSet(Opcodes.ACC_ABSTRACT, access); - } - - private static boolean isSet(int bits, int access) { - return (access & bits) == bits; - } - - public static ResourceOrProviderClassVisitor visit(ClassReader classReader) { - ResourceOrProviderClassVisitor visitor = new ResourceOrProviderClassVisitor(); - classReader.accept(visitor, ClassReader.SKIP_DEBUG | ClassReader.SKIP_CODE | ClassReader.SKIP_FRAMES); - return visitor; - } -} diff --git a/container-jersey2/src/main/java/com/yahoo/container/servlet/jersey/util/ResourceConfigUtil.java b/container-jersey2/src/main/java/com/yahoo/container/servlet/jersey/util/ResourceConfigUtil.java deleted file mode 100644 index fdfcf6565cd..00000000000 --- a/container-jersey2/src/main/java/com/yahoo/container/servlet/jersey/util/ResourceConfigUtil.java +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.container.servlet.jersey.util; - -import org.glassfish.jersey.server.ResourceConfig; - -/** - * @author Tony Vaagenes - */ -public class ResourceConfigUtil { - /** - * Solves ambiguous reference to overloaded definition, see - * http://stackoverflow.com/questions/3313929/how-do-i-disambiguate-in-scala-between-methods-with-vararg-and-without - */ - public static void registerComponent(ResourceConfig config, Object component) { - config.register(component); - } -} diff --git a/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/AbstractResource.java b/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/AbstractResource.java deleted file mode 100644 index dfa3354032a..00000000000 --- a/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/AbstractResource.java +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.container.servlet.jersey.classvisitor; - -import javax.ws.rs.Path; - -/** - * @author Tony Vaagenes - */ -@Path("ignored") -public abstract class AbstractResource { - -} diff --git a/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/DummyAnnotation.java b/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/DummyAnnotation.java deleted file mode 100644 index ca6e20aba4d..00000000000 --- a/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/DummyAnnotation.java +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.container.servlet.jersey.classvisitor; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -/** - * @author Tony Vaagenes - */ -@Retention(RetentionPolicy.RUNTIME) -public @interface DummyAnnotation {} diff --git a/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/InnerClass.java b/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/InnerClass.java deleted file mode 100644 index 048ac4cdd9b..00000000000 --- a/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/InnerClass.java +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.container.servlet.jersey.classvisitor; - -import javax.ws.rs.Path; - -/** - * @author Tony Vaagenes - */ -public class InnerClass { - @Path("ignored") - public class Inner {} -} diff --git a/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/InterfaceResource.java b/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/InterfaceResource.java deleted file mode 100644 index d013028db19..00000000000 --- a/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/InterfaceResource.java +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.container.servlet.jersey.classvisitor; - -import javax.ws.rs.Path; - -/** - * @author Tony Vaagenes - */ -@Path("ignored") -public interface InterfaceResource { - -} diff --git a/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/NestedClass.java b/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/NestedClass.java deleted file mode 100644 index 11ff6364074..00000000000 --- a/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/NestedClass.java +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.container.servlet.jersey.classvisitor; - -import javax.ws.rs.Path; - -/** - * @author Tony Vaagenes - */ -public class NestedClass { - @Path("ignored") - public static class Nested {} -} diff --git a/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/NonPublicNestedClass.java b/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/NonPublicNestedClass.java deleted file mode 100644 index 8e4499fe6dc..00000000000 --- a/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/NonPublicNestedClass.java +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.container.servlet.jersey.classvisitor; - -import javax.ws.rs.Path; - -/** - * @author Tony Vaagenes - */ -public class NonPublicNestedClass { - @Path("ignored") - static class Nested {} -} diff --git a/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/Provider.java b/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/Provider.java deleted file mode 100644 index c2c605db22c..00000000000 --- a/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/Provider.java +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.container.servlet.jersey.classvisitor; - -/** - * @author Tony Vaagenes - */ -@javax.ws.rs.ext.Provider -public class Provider { -} diff --git a/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/Resource.java b/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/Resource.java deleted file mode 100644 index edfa2449fc3..00000000000 --- a/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/Resource.java +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.container.servlet.jersey.classvisitor; - -import javax.ws.rs.Path; - -/** - * @author Tony Vaagenes - */ -@Path("ignored") -public class Resource { -} diff --git a/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/ResourceOrProviderClassVisitorTest.java b/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/ResourceOrProviderClassVisitorTest.java deleted file mode 100644 index 1f5ccf4bb10..00000000000 --- a/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/ResourceOrProviderClassVisitorTest.java +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.container.servlet.jersey.classvisitor; - -import com.yahoo.container.servlet.jersey.ResourceOrProviderClassVisitor; -import org.junit.Test; -import org.objectweb.asm.ClassReader; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -public class ResourceOrProviderClassVisitorTest { - @Test - public void resource_is_detected() throws Exception { - assert_is_accepted(com.yahoo.container.servlet.jersey.classvisitor.Resource.class); - } - - @Test - public void provider_is_detected() throws Exception { - assert_is_accepted(com.yahoo.container.servlet.jersey.classvisitor.Provider.class); - } - - @Test - public void inner_class_is_ignored() throws Exception { - assert_is_ignored(com.yahoo.container.servlet.jersey.classvisitor.InnerClass.Inner.class); - } - - @Test - public void nested_public_class_is_detected() throws Exception { - assert_is_accepted(com.yahoo.container.servlet.jersey.classvisitor.NestedClass.Nested.class); - } - - @Test - public void nested_non_public_class_is_ignored() throws Exception { - assert_is_ignored(com.yahoo.container.servlet.jersey.classvisitor.NonPublicNestedClass.Nested.class); - } - - @Test - public void resource_with_multiple_annotations_is_detected() throws Exception { - assert_is_accepted(com.yahoo.container.servlet.jersey.classvisitor.ResourceWithMultipleAnnotations.class); - } - - @Test - public void interface_is_ignored() throws Exception { - assert_is_ignored(com.yahoo.container.servlet.jersey.classvisitor.InterfaceResource.class); - } - - @Test - public void abstract_class_is_ignored() throws Exception { - assert_is_ignored(com.yahoo.container.servlet.jersey.classvisitor.AbstractResource.class); - } - - @Test - public void className_is_equal_to_getName() throws Exception { - assertEquals(com.yahoo.container.servlet.jersey.classvisitor.Resource.class.getName(), analyzeClass(com.yahoo.container.servlet.jersey.classvisitor.Resource.class).getClassName()); - } - - public void assert_is_accepted(Class<?> clazz) throws Exception { - assertTrue(className(clazz) + " was not accepted", - analyzeClass(clazz).isJerseyClass()); - } - - public void assert_is_ignored(Class<?> clazz) throws Exception { - assertFalse(className(clazz) + " was not ignored", - analyzeClass(clazz).isJerseyClass()); - } - - public ResourceOrProviderClassVisitor analyzeClass(Class<?> clazz) throws Exception { - return ResourceOrProviderClassVisitor.visit(new ClassReader(className(clazz))); - } - - public String className(Class<?> clazz) { - return clazz.getName(); - } -} - - diff --git a/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/ResourceWithMultipleAnnotations.java b/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/ResourceWithMultipleAnnotations.java deleted file mode 100644 index 7047422736e..00000000000 --- a/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/ResourceWithMultipleAnnotations.java +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.container.servlet.jersey.classvisitor; - -import javax.ws.rs.Path; - -/** - * @author Tony Vaagenes - */ -@Path("ignored") -@DummyAnnotation -public class ResourceWithMultipleAnnotations { - -} diff --git a/dist/vespa.spec b/dist/vespa.spec index c92a4e9859b..d8e3653af39 100644 --- a/dist/vespa.spec +++ b/dist/vespa.spec @@ -794,7 +794,6 @@ fi %{_prefix}/lib/jars/config-provisioning-jar-with-dependencies.jar %{_prefix}/lib/jars/container-apache-http-client-bundle-jar-with-dependencies.jar %{_prefix}/lib/jars/container-disc-jar-with-dependencies.jar -%{_prefix}/lib/jars/container-jersey2-jar-with-dependencies.jar %{_prefix}/lib/jars/container-search-and-docproc-jar-with-dependencies.jar %{_prefix}/lib/jars/container-search-gui-jar-with-dependencies.jar %{_prefix}/lib/jars/defaults-jar-with-dependencies.jar @@ -61,7 +61,6 @@ <module>container-disc</module> <module>container-documentapi</module> <module>container-integration-test</module> - <module>container-jersey2</module> <module>container-messagebus</module> <module>container-search-and-docproc</module> <module>container-search</module> |