db541a810caec17ef9bef09e232cad43f353f3b4
[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 package org.openecomp.sdc.asdctool;
21
22 import org.eclipse.jetty.server.Server;
23 import org.eclipse.jetty.servlet.ServletContextHandler;
24 import org.eclipse.jetty.servlet.ServletHolder;
25
26 /**
27  * Hello world!
28  */
29 public class App {
30
31     public static void main(String[] args) {
32         String asdcToolPort = "8087";
33         ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
34         context.setContextPath("/asdctool");
35         Server jettyServer = new Server(Integer.valueOf(asdcToolPort));
36         jettyServer.setHandler(context);
37         ServletHolder jerseyServlet = context.addServlet(org.glassfish.jersey.servlet.ServletContainer.class, "/*");
38         jerseyServlet.setInitOrder(0);
39
40         // Tells the Jersey Servlet which REST service/class to load.
41         // jerseyServlet.setInitParameter("jersey.config.server.provider.classnames",
42         // EntryPoint.class.getCanonicalName());
43         jerseyServlet.setInitParameter("jersey.config.server.provider.packages", "org.openecomp.sdc.asdctool.servlets");
44         jerseyServlet.setInitParameter("jersey.config.server.provider.classnames",
45             "org.glassfish.jersey.media.multipart.MultiPartFeature");
46
47         try {
48             jettyServer.start();
49
50             System.out.println("Server was started on port " + asdcToolPort);
51
52             jettyServer.join();
53
54         } catch (Exception e) {
55             e.printStackTrace();
56             System.exit(1);
57         } finally {
58             jettyServer.destroy();
59         }
60     }
61 }
62