[SDC] update configuration template in chef os
[sdc.git] / catalog-fe / src / test / java / org / openecomp / sdc / Main.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;
22
23 import org.eclipse.jetty.server.Server;
24 import org.eclipse.jetty.util.component.Container.Listener;
25 import org.eclipse.jetty.webapp.WebAppContext;
26 import org.openecomp.sdc.fe.listen.FEAppContextListener;
27
28 public class Main {
29         public static void main(String[] args) throws Exception {
30                 // The port that we should run on can be set into an environment
31                 // variable
32                 // Look for that variable and default to 8080 if it isn't there.
33                 String webPort = System.getenv("PORT");
34                 if (webPort == null || webPort.isEmpty()) {
35                         webPort = "8080";
36                 }
37                 // String webPort = "9998";
38
39                 final Server server = new Server(Integer.valueOf(webPort));
40                 server.addEventListener((Listener) new FEAppContextListener());
41                 final WebAppContext root = new WebAppContext();
42
43                 root.setContextPath("/sdc1");
44                 // Parent loader priority is a class loader setting that Jetty accepts.
45                 // By default Jetty will behave like most web containers in that it will
46                 // allow your application to replace non-server libraries that are part
47                 // of the
48                 // container. Setting parent loader priority to true changes this
49                 // behavior.
50                 // Read more here:
51                 // http://wiki.eclipse.org/Jetty/Reference/Jetty_Classloading
52                 root.setParentLoaderPriority(true);
53
54                 final String webappDirLocation = "src/main/webapp/";
55                 root.setDescriptor(webappDirLocation + "/WEB-INF/web.xml");
56                 root.setResourceBase(webappDirLocation);
57
58                 server.setHandler(root);
59
60                 server.start();
61                 server.join();
62         }
63 }