2 * Copyright 2012-2015 the original author or authors.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.onap.music;
19 import javax.annotation.PostConstruct;
20 import javax.ws.rs.ApplicationPath;
21 import org.glassfish.jersey.server.ResourceConfig;
22 import org.onap.music.rest.RestMusicAdminAPI;
23 import org.onap.music.rest.RestMusicDataAPI;
24 import org.onap.music.rest.RestMusicHealthCheckAPI;
25 import org.onap.music.rest.RestMusicLocksAPI;
26 import org.onap.music.rest.RestMusicQAPI;
27 import org.onap.music.rest.RestMusicTestAPI;
28 import org.onap.music.rest.RestMusicVersionAPI;
29 import org.springframework.beans.factory.annotation.Value;
30 import org.springframework.stereotype.Component;
31 import io.swagger.jaxrs.config.BeanConfig;
32 import io.swagger.jaxrs.listing.ApiListingResource;
33 import io.swagger.jaxrs.listing.SwaggerSerializers;
36 public class JerseyConfig extends ResourceConfig {
38 @Value("${spring.jersey.application-path:/}")
39 private String apiPath;
41 public JerseyConfig() {
42 this.registerEndpoints();
47 this.configureSwagger();
50 private void registerEndpoints() {
51 register(RestMusicAdminAPI.class);
52 register(RestMusicDataAPI.class);
53 register(RestMusicLocksAPI.class);
54 register(RestMusicQAPI.class);
55 register(RestMusicTestAPI.class);
56 register(RestMusicVersionAPI.class);
57 register(RestMusicHealthCheckAPI.class);
60 private void configureSwagger() {
61 // Available at localhost:port/swagger.json
62 this.register(ApiListingResource.class);
63 this.register(SwaggerSerializers.class);
65 BeanConfig config = new BeanConfig();
66 config.setConfigId("MUSIC");
67 config.setTitle("MUSIC");
68 config.setVersion("v2");
69 config.setContact("Thomas Nelson");
70 config.setSchemes(new String[] { "http", "https" });
71 config.setBasePath("/MUSIC/rest");
72 config.setResourcePackage("org.onap.music");
73 config.setPrettyPrint(true);