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.RestMusicAdminAPI;
29 import org.onap.music.rest.RestMusicDataAPI;
30 import org.onap.music.rest.RestMusicHealthCheckAPI;
31 import org.onap.music.rest.RestMusicLocksAPI;
32 import org.onap.music.rest.RestMusicQAPI;
33 import org.onap.music.rest.RestMusicTestAPI;
34 import org.onap.music.rest.RestMusicVersionAPI;
35 import org.springframework.beans.factory.annotation.Value;
36 import org.springframework.stereotype.Component;
39 public class JerseyConfig extends ResourceConfig {
41 @Value("${spring.jersey.application-path:/}")
42 private String apiPath;
44 public JerseyConfig() {
45 this.registerEndpoints();
46 register(MusicExceptionMapper.class);
51 this.configureSwagger();
54 private void registerEndpoints() {
55 register(RestMusicAdminAPI.class);
56 register(RestMusicDataAPI.class);
57 register(RestMusicLocksAPI.class);
58 register(RestMusicConditionalAPI.class);
59 register(RestMusicQAPI.class);
60 register(RestMusicTestAPI.class);
61 register(RestMusicVersionAPI.class);
62 register(RestMusicHealthCheckAPI.class);
66 private void configureSwagger() {
67 // Available at localhost:port/swagger.json
68 this.register(ApiListingResource.class);
69 this.register(SwaggerSerializers.class);
71 BeanConfig config = new BeanConfig();
72 config.setConfigId("MUSIC");
73 config.setTitle("MUSIC");
74 config.setVersion("v2");
75 config.setContact("Thomas Nelson");
76 config.setSchemes(new String[] {"http", "https"});
77 config.setBasePath("/MUSIC/rest");
78 config.setResourcePackage("org.onap.music");
79 config.setPrettyPrint(true);