summaryrefslogtreecommitdiffstats
path: root/config-model/src/main/java/com/yahoo/vespa/model/container/jersey/Jersey2Servlet.java
blob: 06775d59654ceb2d52d1d82c2969cc9280ba28ae (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// 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);
    }

}