Repackaging web.main
authorJan Lahoda <jlahoda@netbeans.org>
Sun, 08 Jan 2017 20:12:09 +0100
changeset 10392d3a933b12e4
parent 1038 1e294e9e1ef4
child 1040 f7b6892fd754
Repackaging web.main
remoting/server/scripts/web.sh
remoting/server/web/web.main/src/org/netbeans/modules/jackpot30/backend/main/MainPage.java
remoting/server/web/web.main/src/org/netbeans/modules/jackpot30/backend/main/WebMain.java
remoting/server/web/web.main/src/web/main/MainPage.java
remoting/server/web/web.main/src/web/main/WebMain.java
     1.1 --- a/remoting/server/scripts/web.sh	Sun Jan 08 20:11:55 2017 +0100
     1.2 +++ b/remoting/server/scripts/web.sh	Sun Jan 08 20:12:09 2017 +0100
     1.3 @@ -48,4 +48,4 @@
     1.4  for jar in $DIR/web/lib/*.jar; do
     1.5      classpath="$classpath:$jar"
     1.6  done
     1.7 -exec java $JACKPOT_WEB_OPTS -Djava.index.useMemCache=false -Xbootclasspath/p:$DIR/web/lib/nb-javac-api.jar:$DIR/web/lib/nb-javac-impl.jar -classpath "$classpath" web.main.WebMain "$@" "$DIR/web/public_html"
     1.8 +exec java $JACKPOT_WEB_OPTS -Djava.index.useMemCache=false -Xbootclasspath/p:$DIR/web/lib/nb-javac-api.jar:$DIR/web/lib/nb-javac-impl.jar -classpath "$classpath" org.netbeans.modules.jackpot30.backend.main.WebMain "$@" "$DIR/web/public_html"
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/remoting/server/web/web.main/src/org/netbeans/modules/jackpot30/backend/main/MainPage.java	Sun Jan 08 20:12:09 2017 +0100
     2.3 @@ -0,0 +1,60 @@
     2.4 +/*
     2.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
     2.6 + *
     2.7 + * Copyright 2011-2017 Oracle and/or its affiliates. All rights reserved.
     2.8 + *
     2.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
    2.10 + * Other names may be trademarks of their respective owners.
    2.11 + *
    2.12 + * The contents of this file are subject to the terms of either the GNU
    2.13 + * General Public License Version 2 only ("GPL") or the Common
    2.14 + * Development and Distribution License("CDDL") (collectively, the
    2.15 + * "License"). You may not use this file except in compliance with the
    2.16 + * License. You can obtain a copy of the License at
    2.17 + * http://www.netbeans.org/cddl-gplv2.html
    2.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
    2.19 + * specific language governing permissions and limitations under the
    2.20 + * License.  When distributing the software, include this License Header
    2.21 + * Notice in each file and include the License file at
    2.22 + * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
    2.23 + * particular file as subject to the "Classpath" exception as provided
    2.24 + * by Oracle in the GPL Version 2 section of the License file that
    2.25 + * accompanied this code. If applicable, add the following below the
    2.26 + * License Header, with the fields enclosed by brackets [] replaced by
    2.27 + * your own identifying information:
    2.28 + * "Portions Copyrighted [year] [name of copyright owner]"
    2.29 + *
    2.30 + * If you wish your version of this file to be governed by only the CDDL
    2.31 + * or only the GPL Version 2, indicate your decision by adding
    2.32 + * "[Contributor] elects to include this software in this distribution
    2.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
    2.34 + * single choice of license, a recipient has the option to distribute
    2.35 + * your version of this file under either the CDDL, the GPL Version 2 or
    2.36 + * to extend the choice of license to its licensees as provided above.
    2.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
    2.38 + * Version 2 license, then the option applies only if the new code is
    2.39 + * made subject to such option by the copyright holder.
    2.40 + *
    2.41 + * Contributor(s):
    2.42 + *
    2.43 + * Portions Copyrighted 2011 Sun Microsystems, Inc.
    2.44 + */
    2.45 +
    2.46 +package org.netbeans.modules.jackpot30.backend.main;
    2.47 +
    2.48 +import javax.ws.rs.GET;
    2.49 +import javax.ws.rs.Path;
    2.50 +
    2.51 +/**
    2.52 + *
    2.53 + * @author lahvac
    2.54 + */
    2.55 +@Path("/")
    2.56 +public class MainPage {
    2.57 +
    2.58 +    @GET
    2.59 +    public String main() {
    2.60 +        //XXX: should be constructed automatically from installed plugins
    2.61 +        return "<html><body><ul><li><a href='index/type/ui/search'>Search Type</a></li></ul></body></html>";
    2.62 +    }
    2.63 +}
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/remoting/server/web/web.main/src/org/netbeans/modules/jackpot30/backend/main/WebMain.java	Sun Jan 08 20:12:09 2017 +0100
     3.3 @@ -0,0 +1,165 @@
     3.4 +/*
     3.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
     3.6 + *
     3.7 + * Copyright 2011-2017 Oracle and/or its affiliates. All rights reserved.
     3.8 + *
     3.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
    3.10 + * Other names may be trademarks of their respective owners.
    3.11 + *
    3.12 + * The contents of this file are subject to the terms of either the GNU
    3.13 + * General Public License Version 2 only ("GPL") or the Common
    3.14 + * Development and Distribution License("CDDL") (collectively, the
    3.15 + * "License"). You may not use this file except in compliance with the
    3.16 + * License. You can obtain a copy of the License at
    3.17 + * http://www.netbeans.org/cddl-gplv2.html
    3.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
    3.19 + * specific language governing permissions and limitations under the
    3.20 + * License.  When distributing the software, include this License Header
    3.21 + * Notice in each file and include the License file at
    3.22 + * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
    3.23 + * particular file as subject to the "Classpath" exception as provided
    3.24 + * by Oracle in the GPL Version 2 section of the License file that
    3.25 + * accompanied this code. If applicable, add the following below the
    3.26 + * License Header, with the fields enclosed by brackets [] replaced by
    3.27 + * your own identifying information:
    3.28 + * "Portions Copyrighted [year] [name of copyright owner]"
    3.29 + *
    3.30 + * If you wish your version of this file to be governed by only the CDDL
    3.31 + * or only the GPL Version 2, indicate your decision by adding
    3.32 + * "[Contributor] elects to include this software in this distribution
    3.33 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
    3.34 + * single choice of license, a recipient has the option to distribute
    3.35 + * your version of this file under either the CDDL, the GPL Version 2 or
    3.36 + * to extend the choice of license to its licensees as provided above.
    3.37 + * However, if you add GPL Version 2 code and therefore, elected the GPL
    3.38 + * Version 2 license, then the option applies only if the new code is
    3.39 + * made subject to such option by the copyright holder.
    3.40 + *
    3.41 + * Contributor(s):
    3.42 + *
    3.43 + * Portions Copyrighted 2011 Sun Microsystems, Inc.
    3.44 + */
    3.45 +package org.netbeans.modules.jackpot30.backend.main;
    3.46 +
    3.47 +import com.sun.grizzly.http.embed.GrizzlyWebServer;
    3.48 +import com.sun.grizzly.http.servlet.ServletAdapter;
    3.49 +import com.sun.grizzly.tcp.http11.GrizzlyAdapter;
    3.50 +import com.sun.grizzly.tcp.http11.GrizzlyOutputStream;
    3.51 +import com.sun.grizzly.tcp.http11.GrizzlyRequest;
    3.52 +import com.sun.grizzly.tcp.http11.GrizzlyResponse;
    3.53 +import com.sun.jersey.spi.container.servlet.ServletContainer;
    3.54 +import java.io.File;
    3.55 +import java.io.IOException;
    3.56 +import java.io.InputStream;
    3.57 +import java.net.InetAddress;
    3.58 +import java.net.URL;
    3.59 +import java.util.ArrayList;
    3.60 +import java.util.Arrays;
    3.61 +import java.util.List;
    3.62 +import org.netbeans.modules.jackpot30.backend.base.AccessStatistics;
    3.63 +import org.netbeans.modules.jackpot30.backend.base.CategoryStorage;
    3.64 +import org.netbeans.modules.jackpot30.backend.base.RelStreamHandlerFactory;
    3.65 +import org.openide.util.Exceptions;
    3.66 +
    3.67 +/**
    3.68 + *
    3.69 + * @author lahvac
    3.70 + */
    3.71 +public class WebMain {
    3.72 +
    3.73 +    /**
    3.74 +     * @param args the command line arguments
    3.75 +     */
    3.76 +    public static void main(String... origArgs) throws IOException, InterruptedException {
    3.77 +        int port = 9998;
    3.78 +
    3.79 +        List<String> args = new ArrayList<String>(Arrays.asList(origArgs));
    3.80 +
    3.81 +        if (args.size() > 1 && "--port".equals(args.get(0))) {
    3.82 +            args.remove(0);
    3.83 +            port = Integer.parseInt(args.remove(0));
    3.84 +        }
    3.85 +
    3.86 +        if (args.size() != 1 && args.size() != 2) {
    3.87 +            System.err.println("Usage: java -jar " + WebMain.class.getProtectionDomain().getCodeSource().getLocation().getPath() + " [--port <port>] <cache> [<static-content>]");
    3.88 +            return ;
    3.89 +        }
    3.90 +
    3.91 +        CategoryStorage.setCacheRoot(new File(args.get(0)));
    3.92 +        
    3.93 +//        org.netbeans.ProxyURLStreamHandlerFactory.register();
    3.94 +        URL.setURLStreamHandlerFactory(new RelStreamHandlerFactory());
    3.95 +
    3.96 +        GrizzlyWebServer gws;
    3.97 +
    3.98 +        if (args.size() == 2) {
    3.99 +            gws = new GrizzlyWebServer(port, args.get(1));
   3.100 +        } else {
   3.101 +            gws = new GrizzlyWebServer(port);
   3.102 +        }
   3.103 +        
   3.104 +        if (port == 0) {
   3.105 +            gws.getSelectorThread().setAddress(InetAddress.getByName("localhost"));
   3.106 +        }
   3.107 +
   3.108 +        // Jersey web resources
   3.109 +        ServletAdapter jerseyAdapter = new ServletAdapter();
   3.110 +        jerseyAdapter.addInitParameter("com.sun.jersey.config.property.packages", "org.netbeans.modules.jackpot30");
   3.111 +        jerseyAdapter.addInitParameter("com.sun.jersey.spi.container.ContainerRequestFilters", AccessStatistics.class.getName());
   3.112 +//        jerseyAdapter.setContextPath("/");
   3.113 +        jerseyAdapter.setServletInstance(new ServletContainer());
   3.114 +
   3.115 +        // register all above defined adapters
   3.116 +        gws.addGrizzlyAdapter(new GrizzlyAdapter(){
   3.117 +            public void service(GrizzlyRequest request, GrizzlyResponse response){
   3.118 +                if (request.getRequestURI().contains("/index/icons/")) {
   3.119 +                    String icon = request.getRequestURI().substring("/index".length());
   3.120 +                    URL iconURL = WebMain.class.getResource(icon);
   3.121 +
   3.122 +                    if (iconURL == null) return;
   3.123 +
   3.124 +                    InputStream in = null;
   3.125 +                    GrizzlyOutputStream out = null;
   3.126 +
   3.127 +                    try {
   3.128 +                        in = iconURL.openStream();
   3.129 +                        out = response.createOutputStream();
   3.130 +
   3.131 +                        int read;
   3.132 +
   3.133 +                        while ((read = in.read()) != (-1)) {
   3.134 +                            out.write(read);
   3.135 +                        }
   3.136 +                    } catch (IOException ex) {
   3.137 +                        Exceptions.printStackTrace(ex);
   3.138 +                    } finally {
   3.139 +                        if (in != null) {
   3.140 +                            try {
   3.141 +                                in.close();
   3.142 +                            } catch (IOException ex) {
   3.143 +                                Exceptions.printStackTrace(ex);
   3.144 +                            }
   3.145 +                        }
   3.146 +                        if (out != null) {
   3.147 +                            try {
   3.148 +                                out.close();
   3.149 +                            } catch (IOException ex) {
   3.150 +                                Exceptions.printStackTrace(ex);
   3.151 +                            }
   3.152 +                        }
   3.153 +                    }
   3.154 +                }
   3.155 +                response.setStatus(404);
   3.156 +            }
   3.157 +        });
   3.158 +        gws.addGrizzlyAdapter(jerseyAdapter);
   3.159 +
   3.160 +        // let Grizzly run
   3.161 +        gws.start();
   3.162 +
   3.163 +        if (port == 0) {
   3.164 +            System.out.println("Running on port: " + gws.getSelectorThread().getPortLowLevel());
   3.165 +        }
   3.166 +    }
   3.167 +
   3.168 +}
     4.1 --- a/remoting/server/web/web.main/src/web/main/MainPage.java	Sun Jan 08 20:11:55 2017 +0100
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,60 +0,0 @@
     4.4 -/*
     4.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
     4.6 - *
     4.7 - * Copyright 2011 Oracle and/or its affiliates. All rights reserved.
     4.8 - *
     4.9 - * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
    4.10 - * Other names may be trademarks of their respective owners.
    4.11 - *
    4.12 - * The contents of this file are subject to the terms of either the GNU
    4.13 - * General Public License Version 2 only ("GPL") or the Common
    4.14 - * Development and Distribution License("CDDL") (collectively, the
    4.15 - * "License"). You may not use this file except in compliance with the
    4.16 - * License. You can obtain a copy of the License at
    4.17 - * http://www.netbeans.org/cddl-gplv2.html
    4.18 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
    4.19 - * specific language governing permissions and limitations under the
    4.20 - * License.  When distributing the software, include this License Header
    4.21 - * Notice in each file and include the License file at
    4.22 - * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
    4.23 - * particular file as subject to the "Classpath" exception as provided
    4.24 - * by Oracle in the GPL Version 2 section of the License file that
    4.25 - * accompanied this code. If applicable, add the following below the
    4.26 - * License Header, with the fields enclosed by brackets [] replaced by
    4.27 - * your own identifying information:
    4.28 - * "Portions Copyrighted [year] [name of copyright owner]"
    4.29 - *
    4.30 - * If you wish your version of this file to be governed by only the CDDL
    4.31 - * or only the GPL Version 2, indicate your decision by adding
    4.32 - * "[Contributor] elects to include this software in this distribution
    4.33 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
    4.34 - * single choice of license, a recipient has the option to distribute
    4.35 - * your version of this file under either the CDDL, the GPL Version 2 or
    4.36 - * to extend the choice of license to its licensees as provided above.
    4.37 - * However, if you add GPL Version 2 code and therefore, elected the GPL
    4.38 - * Version 2 license, then the option applies only if the new code is
    4.39 - * made subject to such option by the copyright holder.
    4.40 - *
    4.41 - * Contributor(s):
    4.42 - *
    4.43 - * Portions Copyrighted 2011 Sun Microsystems, Inc.
    4.44 - */
    4.45 -
    4.46 -package web.main;
    4.47 -
    4.48 -import javax.ws.rs.GET;
    4.49 -import javax.ws.rs.Path;
    4.50 -
    4.51 -/**
    4.52 - *
    4.53 - * @author lahvac
    4.54 - */
    4.55 -@Path("/")
    4.56 -public class MainPage {
    4.57 -
    4.58 -    @GET
    4.59 -    public String main() {
    4.60 -        //XXX: should be constructed automatically from installed plugins
    4.61 -        return "<html><body><ul><li><a href='index/type/ui/search'>Search Type</a></li></ul></body></html>";
    4.62 -    }
    4.63 -}
     5.1 --- a/remoting/server/web/web.main/src/web/main/WebMain.java	Sun Jan 08 20:11:55 2017 +0100
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,165 +0,0 @@
     5.4 -/*
     5.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
     5.6 - *
     5.7 - * Copyright 2011 Oracle and/or its affiliates. All rights reserved.
     5.8 - *
     5.9 - * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
    5.10 - * Other names may be trademarks of their respective owners.
    5.11 - *
    5.12 - * The contents of this file are subject to the terms of either the GNU
    5.13 - * General Public License Version 2 only ("GPL") or the Common
    5.14 - * Development and Distribution License("CDDL") (collectively, the
    5.15 - * "License"). You may not use this file except in compliance with the
    5.16 - * License. You can obtain a copy of the License at
    5.17 - * http://www.netbeans.org/cddl-gplv2.html
    5.18 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
    5.19 - * specific language governing permissions and limitations under the
    5.20 - * License.  When distributing the software, include this License Header
    5.21 - * Notice in each file and include the License file at
    5.22 - * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
    5.23 - * particular file as subject to the "Classpath" exception as provided
    5.24 - * by Oracle in the GPL Version 2 section of the License file that
    5.25 - * accompanied this code. If applicable, add the following below the
    5.26 - * License Header, with the fields enclosed by brackets [] replaced by
    5.27 - * your own identifying information:
    5.28 - * "Portions Copyrighted [year] [name of copyright owner]"
    5.29 - *
    5.30 - * If you wish your version of this file to be governed by only the CDDL
    5.31 - * or only the GPL Version 2, indicate your decision by adding
    5.32 - * "[Contributor] elects to include this software in this distribution
    5.33 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
    5.34 - * single choice of license, a recipient has the option to distribute
    5.35 - * your version of this file under either the CDDL, the GPL Version 2 or
    5.36 - * to extend the choice of license to its licensees as provided above.
    5.37 - * However, if you add GPL Version 2 code and therefore, elected the GPL
    5.38 - * Version 2 license, then the option applies only if the new code is
    5.39 - * made subject to such option by the copyright holder.
    5.40 - *
    5.41 - * Contributor(s):
    5.42 - *
    5.43 - * Portions Copyrighted 2011 Sun Microsystems, Inc.
    5.44 - */
    5.45 -package web.main;
    5.46 -
    5.47 -import com.sun.grizzly.http.embed.GrizzlyWebServer;
    5.48 -import com.sun.grizzly.http.servlet.ServletAdapter;
    5.49 -import com.sun.grizzly.tcp.http11.GrizzlyAdapter;
    5.50 -import com.sun.grizzly.tcp.http11.GrizzlyOutputStream;
    5.51 -import com.sun.grizzly.tcp.http11.GrizzlyRequest;
    5.52 -import com.sun.grizzly.tcp.http11.GrizzlyResponse;
    5.53 -import com.sun.jersey.spi.container.servlet.ServletContainer;
    5.54 -import java.io.File;
    5.55 -import java.io.IOException;
    5.56 -import java.io.InputStream;
    5.57 -import java.net.InetAddress;
    5.58 -import java.net.URL;
    5.59 -import java.util.ArrayList;
    5.60 -import java.util.Arrays;
    5.61 -import java.util.List;
    5.62 -import org.netbeans.modules.jackpot30.backend.base.AccessStatistics;
    5.63 -import org.netbeans.modules.jackpot30.backend.base.CategoryStorage;
    5.64 -import org.netbeans.modules.jackpot30.backend.base.RelStreamHandlerFactory;
    5.65 -import org.openide.util.Exceptions;
    5.66 -
    5.67 -/**
    5.68 - *
    5.69 - * @author lahvac
    5.70 - */
    5.71 -public class WebMain {
    5.72 -
    5.73 -    /**
    5.74 -     * @param args the command line arguments
    5.75 -     */
    5.76 -    public static void main(String... origArgs) throws IOException, InterruptedException {
    5.77 -        int port = 9998;
    5.78 -
    5.79 -        List<String> args = new ArrayList<String>(Arrays.asList(origArgs));
    5.80 -
    5.81 -        if (args.size() > 1 && "--port".equals(args.get(0))) {
    5.82 -            args.remove(0);
    5.83 -            port = Integer.parseInt(args.remove(0));
    5.84 -        }
    5.85 -
    5.86 -        if (args.size() != 1 && args.size() != 2) {
    5.87 -            System.err.println("Usage: java -jar " + WebMain.class.getProtectionDomain().getCodeSource().getLocation().getPath() + " [--port <port>] <cache> [<static-content>]");
    5.88 -            return ;
    5.89 -        }
    5.90 -
    5.91 -        CategoryStorage.setCacheRoot(new File(args.get(0)));
    5.92 -        
    5.93 -//        org.netbeans.ProxyURLStreamHandlerFactory.register();
    5.94 -        URL.setURLStreamHandlerFactory(new RelStreamHandlerFactory());
    5.95 -
    5.96 -        GrizzlyWebServer gws;
    5.97 -
    5.98 -        if (args.size() == 2) {
    5.99 -            gws = new GrizzlyWebServer(port, args.get(1));
   5.100 -        } else {
   5.101 -            gws = new GrizzlyWebServer(port);
   5.102 -        }
   5.103 -        
   5.104 -        if (port == 0) {
   5.105 -            gws.getSelectorThread().setAddress(InetAddress.getByName("localhost"));
   5.106 -        }
   5.107 -
   5.108 -        // Jersey web resources
   5.109 -        ServletAdapter jerseyAdapter = new ServletAdapter();
   5.110 -        jerseyAdapter.addInitParameter("com.sun.jersey.config.property.packages", "org.netbeans.modules.jackpot30");
   5.111 -        jerseyAdapter.addInitParameter("com.sun.jersey.spi.container.ContainerRequestFilters", AccessStatistics.class.getName());
   5.112 -//        jerseyAdapter.setContextPath("/");
   5.113 -        jerseyAdapter.setServletInstance(new ServletContainer());
   5.114 -
   5.115 -        // register all above defined adapters
   5.116 -        gws.addGrizzlyAdapter(new GrizzlyAdapter(){
   5.117 -            public void service(GrizzlyRequest request, GrizzlyResponse response){
   5.118 -                if (request.getRequestURI().contains("/index/icons/")) {
   5.119 -                    String icon = request.getRequestURI().substring("/index".length());
   5.120 -                    URL iconURL = WebMain.class.getResource(icon);
   5.121 -
   5.122 -                    if (iconURL == null) return;
   5.123 -
   5.124 -                    InputStream in = null;
   5.125 -                    GrizzlyOutputStream out = null;
   5.126 -
   5.127 -                    try {
   5.128 -                        in = iconURL.openStream();
   5.129 -                        out = response.createOutputStream();
   5.130 -
   5.131 -                        int read;
   5.132 -
   5.133 -                        while ((read = in.read()) != (-1)) {
   5.134 -                            out.write(read);
   5.135 -                        }
   5.136 -                    } catch (IOException ex) {
   5.137 -                        Exceptions.printStackTrace(ex);
   5.138 -                    } finally {
   5.139 -                        if (in != null) {
   5.140 -                            try {
   5.141 -                                in.close();
   5.142 -                            } catch (IOException ex) {
   5.143 -                                Exceptions.printStackTrace(ex);
   5.144 -                            }
   5.145 -                        }
   5.146 -                        if (out != null) {
   5.147 -                            try {
   5.148 -                                out.close();
   5.149 -                            } catch (IOException ex) {
   5.150 -                                Exceptions.printStackTrace(ex);
   5.151 -                            }
   5.152 -                        }
   5.153 -                    }
   5.154 -                }
   5.155 -                response.setStatus(404);
   5.156 -            }
   5.157 -        });
   5.158 -        gws.addGrizzlyAdapter(jerseyAdapter);
   5.159 -
   5.160 -        // let Grizzly run
   5.161 -        gws.start();
   5.162 -
   5.163 -        if (port == 0) {
   5.164 -            System.out.println("Running on port: " + gws.getSelectorThread().getPortLowLevel());
   5.165 -        }
   5.166 -    }
   5.167 -
   5.168 -}