2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.openecomp.sdc;
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;
29 public static void main(String[] args) throws Exception {
30 // The port that we should run on can be set into an environment
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()) {
37 // String webPort = "9998";
39 final Server server = new Server(Integer.valueOf(webPort));
40 server.addEventListener((Listener) new FEAppContextListener());
41 final WebAppContext root = new WebAppContext();
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
48 // container. Setting parent loader priority to true changes this
51 // http://wiki.eclipse.org/Jetty/Reference/Jetty_Classloading
52 root.setParentLoaderPriority(true);
54 final String webappDirLocation = "src/main/webapp/";
55 root.setDescriptor(webappDirLocation + "/WEB-INF/web.xml");
56 root.setResourceBase(webappDirLocation);
58 server.setHandler(root);