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 io.swagger.jaxrs.config.BeanConfig;
20 import io.swagger.jaxrs.listing.ApiListingResource;
21 import io.swagger.jaxrs.listing.SwaggerSerializers;
23 import javax.annotation.PostConstruct;
25 import org.glassfish.jersey.server.ResourceConfig;
26 import org.onap.music.conductor.conditionals.RestMusicConditionalAPI;
27 import org.onap.music.exceptions.MusicExceptionMapper;
28 import org.onap.music.rest.RestMusicDataAPI;
29 import org.onap.music.rest.RestMusicHealthCheckAPI;
30 import org.onap.music.rest.RestMusicLocksAPI;
31 import org.onap.music.rest.RestMusicQAPI;
32 import org.onap.music.rest.RestMusicTestAPI;
33 import org.onap.music.rest.RestMusicVersionAPI;
34 import org.springframework.beans.factory.annotation.Value;
35 import org.springframework.stereotype.Component;
38 public class JerseyConfig extends ResourceConfig {
40 @Value("${spring.jersey.application-path:/}")
41 private String apiPath;
43 public JerseyConfig() {
44 this.registerEndpoints();
45 register(MusicExceptionMapper.class);
50 this.configureSwagger();
53 private void registerEndpoints() {
54 register(RestMusicDataAPI.class);
55 register(RestMusicLocksAPI.class);
56 register(RestMusicConditionalAPI.class);
57 register(RestMusicQAPI.class);
58 register(RestMusicTestAPI.class);
59 register(RestMusicVersionAPI.class);
60 register(RestMusicHealthCheckAPI.class);
64 private void configureSwagger() {
65 // Available at localhost:port/swagger.json
66 this.register(ApiListingResource.class);
67 this.register(SwaggerSerializers.class);
69 BeanConfig config = new BeanConfig();
70 config.setConfigId("MUSIC");
71 config.setTitle("MUSIC");
72 config.setVersion("v2");
73 config.setContact("Thomas Nelson");
74 config.setSchemes(new String[] {"http", "https"});
75 config.setBasePath("/MUSIC/rest");
76 config.setResourcePackage("org.onap.music");
77 config.setPrettyPrint(true);