Catalog alignment
[sdc.git] / asdctool / src / main / java / org / openecomp / sdc / asdctool / App.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.openecomp.sdc.asdctool;
22
23 import org.eclipse.jetty.server.Server;
24 import org.eclipse.jetty.servlet.ServletContextHandler;
25 import org.eclipse.jetty.servlet.ServletHolder;
26
27 /**
28  * Hello world!
29  *
30  */
31 public class App {
32         public static void main(String[] args) {
33
34                 String asdcToolPort = "8087";
35
36                 ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
37                 context.setContextPath("/asdctool");
38
39                 Server jettyServer = new Server(Integer.valueOf(asdcToolPort));
40                 jettyServer.setHandler(context);
41
42                 ServletHolder jerseyServlet = context.addServlet(org.glassfish.jersey.servlet.ServletContainer.class, "/*");
43                 jerseyServlet.setInitOrder(0);
44
45                 // Tells the Jersey Servlet which REST service/class to load.
46                 // jerseyServlet.setInitParameter("jersey.config.server.provider.classnames",
47                 // EntryPoint.class.getCanonicalName());
48                 jerseyServlet.setInitParameter("jersey.config.server.provider.packages", "org.openecomp.sdc.asdctool.servlets");
49                 jerseyServlet.setInitParameter("jersey.config.server.provider.classnames",
50                                 "org.glassfish.jersey.media.multipart.MultiPartFeature");
51
52                 try {
53                         jettyServer.start();
54
55                         System.out.println("Server was started on port " + asdcToolPort);
56
57                         jettyServer.join();
58
59                 } catch (Exception e) {
60                         e.printStackTrace();
61                         System.exit(1);
62                 } finally {
63                         jettyServer.destroy();
64                 }
65         }
66 }