# HG changeset patch # User Jaroslav Tulach # Date 1310910050 -7200 # Node ID 90be53f96e0c20cccc05866ecf8ce4e5ae07f59c # Parent 0ea04469967d47224f6215ea96f434c86ae09ebd webidor rewritten to run as glassfish application diff -r 0ea04469967d -r 90be53f96e0c webidor/nb-configuration.xml --- a/webidor/nb-configuration.xml Sun May 01 21:10:07 2011 +0200 +++ b/webidor/nb-configuration.xml Sun Jul 17 15:40:50 2011 +0200 @@ -26,18 +26,6 @@ therefore it is assumed to be part of version control checkout. Without this configuration present, some functionality in the IDE may be limited or fail altogether. --> - - - src/main/webapp/WEB-INF/applicationContext.xml - src/main/webapp/WEB-INF/dispatcher-servlet.xml - - - - src/main/webapp/WEB-INF/applicationContext.xml - src/main/webapp/WEB-INF/dispatcher-servlet.xml - - - - none + user diff -r 0ea04469967d -r 90be53f96e0c webidor/nbactions.xml --- a/webidor/nbactions.xml Sun May 01 21:10:07 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,60 +0,0 @@ - - - - - - run - - process-classes - org.codehaus.mojo:exec-maven-plugin:1.1.1:exec - - - runtime - -classpath %classpath cz.xelfi.quoridor.webidor.resources.Quoridor - java - - - - debug - - process-classes - org.codehaus.mojo:exec-maven-plugin:1.1.1:exec - - - runtime - -Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -classpath %classpath cz.xelfi.quoridor.webidor.resources.Quoridor - true - java - - - - profile - - process-classes - org.codehaus.mojo:exec-maven-plugin:1.1.1:exec - - - ${profiler.args} -classpath %classpath cz.xelfi.quoridor.webidor.resources.Quoridor - profile - ${profiler.java} - - - diff -r 0ea04469967d -r 90be53f96e0c webidor/pom.xml --- a/webidor/pom.xml Sun May 01 21:10:07 2011 +0200 +++ b/webidor/pom.xml Sun Jul 17 15:40:50 2011 +0200 @@ -8,116 +8,128 @@ cz.xelfi.quoridor 1.0 + cz.xelfi.quoridor webidor - jar + war ${webidorVersion} webidor server http://maven.apache.org - - - junit - junit - 4.5 - test - - - com.sun.jersey - jersey-core - ${jerseyVersion} - - - com.sun.jersey - jersey-grizzly2 - ${jerseyVersion} - - - com.sun.jersey - jersey-json - ${jerseyVersion} - jar - - - jaxb-api - javax.xml.bind - - - stax-api - stax - - - - - com.sun.jersey.jersey-test-framework - jersey-test-framework-http - ${jerseyVersion} - test - - - cz.xelfi.quoridor - quoridor - ${quoridorVersion} - jar - - - ${project.groupId} - wsdor - ${wsdorVersion} - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 2.0.2 - - 1.5 - 1.5 - - - - org.codehaus.mojo - exec-maven-plugin - - cz.xelfi.quoridor.webidor.resources.Quoridor - - - - maven-assembly-plugin - 2.2-beta-2 - - - create-executable-jar - package - - single - - - - all-zip.xml - - webidor-${version} - - - - - - org.apache.maven.plugins - maven-jar-plugin - - - - true - lib/ - cz.xelfi.quoridor.webidor.resources.Quoridor - - - - - - - Server with REST API for playing, inspecting and managing Quoridor games. + + ${project.build.directory}/endorsed + UTF-8 + gfv3ee6 + + + + + javax + javaee-web-api + 6.0 + provided + + + + junit + junit + 4.8.2 + test + + + com.sun.jersey + jersey-json + ${jerseyVersion} + jar + + + jaxb-api + javax.xml.bind + + + stax-api + stax + + + jersey-core + com.sun.jersey + + + + + com.sun.jersey.jersey-test-framework + jersey-test-framework-http + ${jerseyVersion} + test + + + ${project.groupId} + wsdor + ${wsdorVersion} + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.3.2 + + 1.6 + 1.6 + + ${endorsed.dir} + + + + + org.apache.maven.plugins + maven-war-plugin + 2.1.1 + + false + + + + org.apache.maven.plugins + maven-dependency-plugin + 2.1 + + + validate + + copy + + + ${endorsed.dir} + true + + + javax + javaee-endorsed-api + 6.0 + jar + + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.9 + + true + + + + + + + http://download.java.net/maven/2/ + restlib + default + Repository for library Library[restlib] + + - - - diff -r 0ea04469967d -r 90be53f96e0c webidor/src/main/java/cz/xelfi/quoridor/webidor/resources/Application.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/webidor/src/main/java/cz/xelfi/quoridor/webidor/resources/Application.java Sun Jul 17 15:40:50 2011 +0200 @@ -0,0 +1,15 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package cz.xelfi.quoridor.webidor.resources; + +import javax.ws.rs.ApplicationPath; + +/** + * + * @author Jaroslav Tulach + */ +@ApplicationPath("resources") +public class Application extends javax.ws.rs.core.Application { +} \ No newline at end of file diff -r 0ea04469967d -r 90be53f96e0c webidor/src/main/java/cz/xelfi/quoridor/webidor/resources/Quoridor.java --- a/webidor/src/main/java/cz/xelfi/quoridor/webidor/resources/Quoridor.java Sun May 01 21:10:07 2011 +0200 +++ b/webidor/src/main/java/cz/xelfi/quoridor/webidor/resources/Quoridor.java Sun Jul 17 15:40:50 2011 +0200 @@ -18,19 +18,16 @@ package cz.xelfi.quoridor.webidor.resources; -import com.sun.jersey.api.container.grizzly2.GrizzlyServerFactory; -import com.sun.jersey.api.core.PackagesResourceConfig; -import com.sun.jersey.api.core.ResourceConfig; import com.sun.jersey.api.json.JSONWithPadding; -import com.sun.jersey.spi.resource.Singleton; import java.io.File; import java.io.FileInputStream; import java.io.IOException; -import java.net.ServerSocket; import java.util.HashMap; import java.util.Map; import java.util.Properties; import java.util.UUID; +import javax.annotation.ManagedBean; +import javax.inject.Singleton; import javax.ws.rs.GET; import javax.ws.rs.PUT; import javax.ws.rs.Path; @@ -39,7 +36,6 @@ import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response.Status; -import org.glassfish.grizzly.http.server.HttpServer; /** * @@ -47,16 +43,17 @@ */ @Path("/") @Singleton -public final class Quoridor { +@ManagedBean +public class Quoridor { private final File path; private Games games; private Users users; private final Map loggedIn; public Quoridor() { - final String prop = System.getProperty("quoridor.dir"); // NOI18N + String prop = System.getProperty("quoridor.dir"); // NOI18N if (prop == null) { - throw new IllegalStateException("quoridor.dir property must be specified"); // NOI18N + prop = System.getProperty("user.dir") + File.separatorChar + ".quoridor"; // NOI18N } path = new File(prop); path.mkdirs(); @@ -144,53 +141,4 @@ return getUsers().getUserInfo(callback, id, ret); } } - - // - // start the server - // - - public static void main(String[] args) throws IOException, InterruptedException { - int port = 9222; - try { - port = Integer.parseInt(args[0]); - } catch (Exception ex) { - // OK - } - HttpServer s = start(port); - System.out.println( - "Quoridor started at port " + port + "\n" + "Hit enter to stop it..." - ); - if (args.length < 2 || !args[args.length - 1].equals("--kill")) { - System.out.println("Hit enter to stop it..."); - System.in.read(); - } else { - synchronized (Quoridor.class) { - Quoridor.class.wait(); - } - } - System.in.read(); - s.stop(); - System.exit(0); - } - - public static HttpServer start(int port) throws IOException { - if (port == -1) { - ServerSocket ss = new ServerSocket(0); - port =ss.getLocalPort(); - ss.close(); - } - final String baseUri = "http://localhost:" + port + "/"; - - if (System.getProperty("quoridor.dir") == null) { - File home = new File(System.getProperty("user.home")); - File quoridor = new File(home, ".quoridor"); - System.setProperty("quoridor.dir", quoridor.getPath()); - } - - ResourceConfig rc = new PackagesResourceConfig("cz.xelfi.quoridor.webidor"); - HttpServer server = GrizzlyServerFactory.createHttpServer(baseUri, rc); - server.start(); - return server; - } - } diff -r 0ea04469967d -r 90be53f96e0c webidor/src/main/webapp/WEB-INF/beans.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/webidor/src/main/webapp/WEB-INF/beans.xml Sun Jul 17 15:40:50 2011 +0200 @@ -0,0 +1,5 @@ + + + diff -r 0ea04469967d -r 90be53f96e0c webidor/src/main/webapp/index.jsp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/webidor/src/main/webapp/index.jsp Sun Jul 17 15:40:50 2011 +0200 @@ -0,0 +1,15 @@ +<%@page contentType="text/html" pageEncoding="UTF-8"%> + + + + + + Quoridor REST APIs + + +

Quoridor REST APIs!

+ + Get list of all games. + + diff -r 0ea04469967d -r 90be53f96e0c wsdor/pom.xml --- a/wsdor/pom.xml Sun May 01 21:10:07 2011 +0200 +++ b/wsdor/pom.xml Sun Jul 17 15:40:50 2011 +0200 @@ -63,16 +63,6 @@ com.sun.jersey - jersey-core - ${jerseyVersion} - - - com.sun.jersey - jersey-server - ${jerseyVersion} - - - com.sun.jersey jersey-json ${jerseyVersion} jar @@ -85,7 +75,17 @@ stax-api stax + + jersey-core + com.sun.jersey + + + javax + javaee-web-api + 6.0 + provided +