Commits

Stephen McKamey  committed ee5c847

moving MVC classes into own JAR

  • Participants
  • Parent commits 2f1f96f

Comments (0)

Files changed (6)

File duel-js/target/duel.min.js

-var duel=function(x){function y(a){this.value=a}function j(a){switch(typeof a){case "object":return!a?0:z(a)?2:a instanceof y?5:a instanceof Date?4:3;case "function":return 1;case "undefined":return 0;default:return 4}}function p(a){return typeof a==="function"}function n(){this.value=n.FAST?"":[]}function v(a){return a<10?"0"+a:a}function A(a){var b,c;switch(j(a)){case 4:return a instanceof Date?a.getUTCFullYear()+"-"+v(a.getUTCMonth()+1)+"-"+v(a.getUTCDate())+" "+v(a.getUTCHours())+":"+v(a.getUTCMinutes())+
-":"+v(a.getUTCSeconds())+" Z":""+a;case 0:return"";case 2:b=new n;for(var e=0,d=a.length;e<d;e++)c?b.append(", "):c=!0,b.append(A(a[e]));return b.toString();case 3:b=new n;b.append("{");for(e in a)a.hasOwnProperty(e)&&(c?b.append(", "):c=!0,b.append(e,"=",A(a[e])));b.append("}");return b.toString()}return a}function q(a){z(a)||(a=["",a]);this.value=a}function s(a,b){switch(j(b)){case 2:if(b[0]==="")for(var c=1,e=b.length;c<e;c++)s(a,b[c]);else a.push(b);break;case 3:c=a[1];if(j(c)===3)for(e in b)b.hasOwnProperty(e)&&
+var duel=function(x){function y(a){this.value=a}function j(a){switch(typeof a){case "object":return!a?0:z(a)?2:a instanceof y?5:a instanceof Date?4:3;case "function":return 1;case "undefined":return 0;default:return 4}}function p(a){return typeof a==="function"}function n(){this.value=n.FAST?"":[]}function v(a){return a<10?"0"+a:a}function A(a){var b,c;switch(j(a)){case 4:if(a instanceof Date)return a.getUTCFullYear()+"-"+v(a.getUTCMonth()+1)+"-"+v(a.getUTCDate())+" "+v(a.getUTCHours())+":"+v(a.getUTCMinutes())+
+":"+v(a.getUTCSeconds())+" Z";return""+a;case 0:return"";case 2:b=new n;for(var e=0,d=a.length;e<d;e++)c?b.append(", "):c=!0,b.append(A(a[e]));return b.toString();case 3:b=new n;b.append("{");for(e in a)a.hasOwnProperty(e)&&(c?b.append(", "):c=!0,b.append(e,"=",A(a[e])));b.append("}");return b.toString()}return a}function q(a){z(a)||(a=["",a]);this.value=a}function s(a,b){switch(j(b)){case 2:if(b[0]==="")for(var c=1,e=b.length;c<e;c++)s(a,b[c]);else a.push(b);break;case 3:c=a[1];if(j(c)===3)for(e in b)b.hasOwnProperty(e)&&
 (c[e]=b[e]);else a.splice(1,0,b);break;case 4:c=a.length-1;c>0&&j(a[c])===4?a[c]=""+a[c]+b:b!==""&&a.push(""+b);break;case 0:break;default:a.push(b)}}function t(a,b,c,e,d,f){var h=j(a[1])===3;if(a.length===(h?3:2))return l(a[a.length-1],b,c,e,d,f);for(var g=[""],h=h?2:1,i=a.length;h<i;h++)s(g,l(a[h],b,c,e,d,f));return g}function D(a,b,c,e,d,f){for(var h=1,g=a.length;h<g;h++){var i=a[h],k=i[1].test;if(j(i[1])===3&&k&&(p(k)&&(k=k(b,c,e,d)),!k))continue;return t(i,b,c,e,d,f)}return null}function M(a){j(a)!==
-2&&(a=["",a]);var b=function(b){try{var e=l(a,b,0,1,null);return new q(e)}catch(d){return new q("["+d+"]")}};b.getView=function(){return a};return b}function N(a){return typeof a!=="string"?a:a.replace(/[&<>]/g,function(a){switch(a){case "&":return"&amp;";case "<":return"&lt;";case ">":return"&gt;";default:return a}})}function O(a){return typeof a!=="string"?a:a.replace(/[&<>"]/g,function(a){switch(a){case "&":return"&amp;";case "<":return"&lt;";case ">":return"&gt;";case '"':return"&quot;";default:return a}})}
-function E(a,b){var c=b[0]||"",e=b.length,d=1,f,h=P[c];if(c.charAt(0)==="!")b[0]==="!DOCTYPE"?a.append("<!DOCTYPE ",b[1],">"):a.append("<\!--",b[1],"--\>");else{if(c){a.append("<",c);f=b[d];if(j(f)===3){for(var g in f)if(f.hasOwnProperty(g)){a.append(" ",g);var i=f[g];j(i)!==0&&a.append('="',O(i),'"')}d++}h&&a.append(" /");a.append(">")}for(;d<e;d++)f=b[d],z(f)?E(a,f):a.append(N(f));c&&!h&&a.append("</",c,">")}}function F(a){try{var b=new n;E(b,a);return b.toString()}catch(c){return"["+c+"]"}}function r(a){if(a){if(a.charAt(0)===
-"!")return m.createComment(a==="!"?"":a.substr(1)+" ")}else{if(m.createDocumentFragment)return m.createDocumentFragment();a=""}return a.toLowerCase()==="style"&&m.createStyleSheet?m.createStyleSheet():m.createElement(a)}function w(a,b){if(b){var c=(a.tagName||"").toLowerCase();if(a.nodeType===8)b.nodeType===3&&(a.nodeValue+=b.nodeValue);else if(c==="table"&&a.tBodies)if(b.tagName)if((c=b.tagName.toLowerCase())&&c!=="tbody"&&c!=="thead"){var e=a.tBodies.length>0?a.tBodies[a.tBodies.length-1]:null;
-e||(e=r(c==="th"?"thead":"tbody"),a.appendChild(e));e.appendChild(b)}else a.canHaveChildren!==!1&&a.appendChild(b);else{if(b.nodeType===11)for(;b.firstChild;)w(a,b.removeChild(b.firstChild))}else if(c==="style"&&m.createStyleSheet)a.cssText=b;else if(a.canHaveChildren!==!1)a.appendChild(b);else if(c==="object"&&b.tagName&&b.tagName.toLowerCase()==="param"){try{a.appendChild(b)}catch(d){}try{if(a.object)a.object[b.name]=b.value}catch(f){}}}}function G(a,b,c){typeof c==="string"&&(c=new Function("event",
-c));p(c)&&(a[b]=c)}function H(a,b){if(b.name&&m.attachEvent&&!a.parentNode)try{var c=r("<"+a.tagName+" name='"+b.name+"'>");a.tagName===c.tagName&&(a=c)}catch(e){}for(var d in b)if(b.hasOwnProperty(d)){var c=b[d],f=j(c);if(d)f===0&&(c="",f=4),d=Q[d.toLowerCase()]||d,d==="style"?typeof a.style.cssText!=="undefined"?a.style.cssText=c:a.style=c:d==="class"?a.className=c:R[d]?(G(a,d,c),u[d]&&G(a,u[d],c)):f===4?(a.setAttribute(d,c),u[d]&&a.setAttribute(u[d],c)):(a[d]=c,u[d]&&(a[u[d]]=c))}return a}function I(a){return!!a&&
-a.nodeType===3&&(!a.nodeValue||!/\S/.exec(a.nodeValue))}function J(a,b){if(a&&a.nodeType===3&&b.exec(a.nodeValue))a.nodeValue=a.nodeValue.replace(b,"")}function B(a){if(a){for(;I(a.firstChild);)a.removeChild(a.firstChild);for(J(a.firstChild,S);I(a.lastChild);)a.removeChild(a.lastChild);J(a.lastChild,T)}}function K(a,b){var c=a[b];if(c){try{delete a[b]}catch(e){a[b]=void 0}if(!p(c))try{c=new Function(""+c)}catch(d){c=null}}return c}function L(a){if(a){var b=K(a,"$init");b&&b.call(a);(b=K(a,"$load"))?
-setTimeout(function(){b.call(a);b=a=null},0):b=a=null}}function C(a,b){for(var c=1,e=b.length;c<e;c++){var d=b[c];switch(j(d)){case 2:var f=d[0],d=C(r(f),d);if(f==="html")return B(d),L(d),d;w(a,d);break;case 4:d!==""&&w(a,m.createTextNode(""+d));break;case 3:a.nodeType===1&&(a=H(a,d));break;case 5:var f=w,h=a;var g=d,d=r("div");d.innerHTML=""+g;B(d);if(d.childNodes.length===1)d=d.firstChild;else{for(g=r("");d.firstChild;)g.appendChild(d.firstChild);d=g}f(h,d)}}B(a);L(a);if(a.nodeType===11&&a.childNodes.length===
-1)a=a.firstChild;return a}var m=x.document;y.prototype.toString=function(){return this.value};var z=Array.isArray||function(a){return a instanceof Array};n.FAST=!x.ScriptEngineMajorVersion;n.prototype.append=function(a,b,c){n.FAST?(this.value+=a,b!==null&&b!==void 0&&(this.value+=b,c!==null&&c!==void 0&&(this.value+=c))):this.value.push.apply(this.value,arguments)};n.prototype.clear=function(){this.value=n.FAST?"":[]};n.prototype.toString=function(){return n.FAST?this.value:this.value.join("")};var l;
-l=function(a,b,c,e,d,f){switch(j(a)){case 1:return A(a(b,c,e,d));case 2:var h=a[0]||"";switch(h){case "$for":a:{var g=a[1]||{},h=[""],i;if(g.hasOwnProperty("count")){i=g.count;p(i)&&(i=i(b,c,e,d));g.hasOwnProperty("data")?(g=g.data,p(g)&&(g=g(b,c,e,d))):g=b;for(b=0;b<i;b++)s(h,t(a,g,b,i,null,f))}else{if(g.hasOwnProperty("in")){var k=g["in"];p(k)&&(k=k(b,c,e,d));if(j(k)===3){g=[];for(i in k)k.hasOwnProperty(i)&&g.push(i);for(b=0,i=g.length;b<i;b++)s(h,t(a,k[g[b]],b,i,g[b],f));a=h;break a}g=k}else g=
-g.each,p(g)&&(g=g(b,c,e,d));b=j(g);if(b===2)for(b=0,i=g.length;b<i;b++)s(h,t(a,g[b],b,i,null,f));else b!==0&&(h=t(a,g,0,1,null,f))}a=h}return a;case "$xor":return D(a,b,c,e,d,f);case "$if":return D(["$xor",a],b,c,e,d,f);case "$call":f=a[1]||{};if(f.view){h=l(f.view,b,c,e,d);g=f.hasOwnProperty("data")?l(f.data,b,c,e,d):b;i=f.hasOwnProperty("index")?l(f.index,b,c,e,d):c;k=f.hasOwnProperty("count")?l(f.count,b,c,e,d):e;b=f.hasOwnProperty("key")?l(f.key,b,c,e,d):d;c={};for(e=a.length-1;e>=2;e--)d=a[e],
-f=d[1]||{},f.hasOwnProperty("name")&&(c[f.name]=d);a=h&&p(h.getView)?l(h.getView(),g,i,k,b,c):null}else a=null;return a;case "$part":return h=(a[1]||{}).name||"",h=f&&f.hasOwnProperty(h)?f[h]:a,t(h,b,c,e,d)}h=[h];g=1;for(i=a.length;g<i;g++)s(h,l(a[g],b,c,e,d,f));return h;case 3:f={};for(h in a)a.hasOwnProperty(h)&&(f[h]=l(a[h],b,c,e,d));return f}return a};var o=x.duel=function(a){return p(a)&&p(a.getView)?a:M(a)};o.raw=o.raw=function(a){return new y(a)};var P={area:!0,base:!0,basefont:!0,br:!0,col:!0,
-frame:!0,hr:!0,img:!0,input:!0,isindex:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,wbr:!0};q.prototype.toString=function(){return F(this.value)};o.write=o.write=function(a,b,c,e,d){a=o(a).getView();a=l(a,b,c,e,d);m.write(F(a))};var Q={rowspan:"rowSpan",colspan:"colSpan",cellpadding:"cellPadding",cellspacing:"cellSpacing",tabindex:"tabIndex",accesskey:"accessKey",hidefocus:"hideFocus",usemap:"useMap",maxlength:"maxLength",readonly:"readOnly",contenteditable:"contentEditable"},u={enctype:"encoding",
-onscroll:"DOMMouseScroll"},R={onblur:!0,onchange:!0,onclick:!0,ondblclick:!0,onerror:!0,onfocus:!0,onkeydown:!0,onkeypress:!0,onkeyup:!0,onload:!0,onmousedown:!0,onmouseenter:!0,onmouseleave:!0,onmousemove:!0,onmouseout:!0,onmouseover:!0,onmouseup:!0,onresize:!0,onscroll:!0,onselect:!0,onsubmit:!0,onunload:!0},S=/^[\r\n]+/,T=/[\r\n]+$/;q.prototype.toDOM=q.prototype.toDOM=function(){try{return C(r(this.value[0]),this.value)}catch(a){return m.createTextNode("["+a+"]")}};q.prototype.reload=q.prototype.reload=
-function(){var a=m;try{var b=this.toDOM();a.replaceChild(b,a.documentElement);if(a.createStyleSheet){for(var c=b.firstChild;c&&(c.tagName||"")!=="HEAD";)c=c.nextSibling;for(var e=c&&c.firstChild;e;){if((e.tagName||"")==="LINK")e.href=e.href;e=e.nextSibling}}}catch(d){a=a.open("text/html"),a.write(this.toString()),a.close()}};o.attr=o.attr=function(a,b,c,e,d,f){j(a)===4&&(a=m.getElementById(a));a&&(b=l(b,c,e,d,f),H(a,b))};o.replace=o.replace=function(a,b,c,e,d,f){j(a)===4&&(a=m.getElementById(a));
+2&&(a=["",a]);var b=function(b){try{var e=l(a,b,0,1,null);return new q(e)}catch(d){return new q("["+d+"]")}};b.getView=function(){return a};return b}function N(a){if(typeof a!=="string")return a;return a.replace(/[&<>]/g,function(a){switch(a){case "&":return"&amp;";case "<":return"&lt;";case ">":return"&gt;";default:return a}})}function O(a){if(typeof a!=="string")return a;return a.replace(/[&<>"]/g,function(a){switch(a){case "&":return"&amp;";case "<":return"&lt;";case ">":return"&gt;";case '"':return"&quot;";
+default:return a}})}function E(a,b){var c=b[0]||"",e=b.length,d=1,f,h=P[c];if(c.charAt(0)==="!")b[0]==="!DOCTYPE"?a.append("<!DOCTYPE ",b[1],">"):a.append("<\!--",b[1],"--\>");else{if(c){a.append("<",c);f=b[d];if(j(f)===3){for(var g in f)if(f.hasOwnProperty(g)){a.append(" ",g);var i=f[g];j(i)!==0&&a.append('="',O(i),'"')}d++}h&&a.append(" /");a.append(">")}for(;d<e;d++)f=b[d],z(f)?E(a,f):a.append(N(f));c&&!h&&a.append("</",c,">")}}function F(a){try{var b=new n;E(b,a);return b.toString()}catch(c){return"["+
+c+"]"}}function r(a){if(a){if(a.charAt(0)==="!")return m.createComment(a==="!"?"":a.substr(1)+" ")}else{if(m.createDocumentFragment)return m.createDocumentFragment();a=""}if(a.toLowerCase()==="style"&&m.createStyleSheet)return m.createStyleSheet();return m.createElement(a)}function w(a,b){if(b){var c=(a.tagName||"").toLowerCase();if(a.nodeType===8)b.nodeType===3&&(a.nodeValue+=b.nodeValue);else if(c==="table"&&a.tBodies)if(b.tagName)if((c=b.tagName.toLowerCase())&&c!=="tbody"&&c!=="thead"){var e=
+a.tBodies.length>0?a.tBodies[a.tBodies.length-1]:null;e||(e=r(c==="th"?"thead":"tbody"),a.appendChild(e));e.appendChild(b)}else a.canHaveChildren!==!1&&a.appendChild(b);else{if(b.nodeType===11)for(;b.firstChild;)w(a,b.removeChild(b.firstChild))}else if(c==="style"&&m.createStyleSheet)a.cssText=b;else if(a.canHaveChildren!==!1)a.appendChild(b);else if(c==="object"&&b.tagName&&b.tagName.toLowerCase()==="param"){try{a.appendChild(b)}catch(d){}try{if(a.object)a.object[b.name]=b.value}catch(f){}}}}function G(a,
+b,c){typeof c==="string"&&(c=new Function("event",c));p(c)&&(a[b]=c)}function H(a,b){if(b.name&&m.attachEvent&&!a.parentNode)try{var c=r("<"+a.tagName+" name='"+b.name+"'>");a.tagName===c.tagName&&(a=c)}catch(e){}for(var d in b)if(b.hasOwnProperty(d)){var c=b[d],f=j(c);if(d)f===0&&(c="",f=4),d=Q[d.toLowerCase()]||d,d==="style"?typeof a.style.cssText!=="undefined"?a.style.cssText=c:a.style=c:d==="class"?a.className=c:R[d]?(G(a,d,c),u[d]&&G(a,u[d],c)):f===4?(a.setAttribute(d,c),u[d]&&a.setAttribute(u[d],
+c)):(a[d]=c,u[d]&&(a[u[d]]=c))}return a}function I(a){return!!a&&a.nodeType===3&&(!a.nodeValue||!/\S/.exec(a.nodeValue))}function J(a,b){if(a&&a.nodeType===3&&b.exec(a.nodeValue))a.nodeValue=a.nodeValue.replace(b,"")}function B(a){if(a){for(;I(a.firstChild);)a.removeChild(a.firstChild);for(J(a.firstChild,S);I(a.lastChild);)a.removeChild(a.lastChild);J(a.lastChild,T)}}function K(a,b){var c=a[b];if(c){try{delete a[b]}catch(e){a[b]=void 0}if(!p(c))try{c=new Function(""+c)}catch(d){c=null}}return c}function L(a){if(a){var b=
+K(a,"$init");b&&b.call(a);(b=K(a,"$load"))?setTimeout(function(){b.call(a);b=a=null},0):b=a=null}}function C(a,b){for(var c=1,e=b.length;c<e;c++){var d=b[c];switch(j(d)){case 2:var f=d[0],d=C(r(f),d);if(f==="html")return B(d),L(d),d;w(a,d);break;case 4:d!==""&&w(a,m.createTextNode(""+d));break;case 3:a.nodeType===1&&(a=H(a,d));break;case 5:var f=w,h=a;var g=d,d=r("div");d.innerHTML=""+g;B(d);if(d.childNodes.length===1)d=d.firstChild;else{for(g=r("");d.firstChild;)g.appendChild(d.firstChild);d=g}f(h,
+d)}}B(a);L(a);if(a.nodeType===11&&a.childNodes.length===1)a=a.firstChild;return a}var m=x.document;y.prototype.toString=function(){return this.value};var z=Array.isArray||function(a){return a instanceof Array};n.FAST=!x.ScriptEngineMajorVersion;n.prototype.append=function(a,b,c){n.FAST?(this.value+=a,b!==null&&b!==void 0&&(this.value+=b,c!==null&&c!==void 0&&(this.value+=c))):this.value.push.apply(this.value,arguments)};n.prototype.clear=function(){this.value=n.FAST?"":[]};n.prototype.toString=function(){return n.FAST?
+this.value:this.value.join("")};var l;l=function(a,b,c,e,d,f){switch(j(a)){case 1:return A(a(b,c,e,d));case 2:var h=a[0]||"";switch(h){case "$for":a:{var g=a[1]||{},h=[""],i;if(g.hasOwnProperty("count")){i=g.count;p(i)&&(i=i(b,c,e,d));g.hasOwnProperty("data")?(g=g.data,p(g)&&(g=g(b,c,e,d))):g=b;for(b=0;b<i;b++)s(h,t(a,g,b,i,null,f))}else{if(g.hasOwnProperty("in")){var k=g["in"];p(k)&&(k=k(b,c,e,d));if(j(k)===3){g=[];for(i in k)k.hasOwnProperty(i)&&g.push(i);b=0;for(i=g.length;b<i;b++)s(h,t(a,k[g[b]],
+b,i,g[b],f));a=h;break a}g=k}else g=g.each,p(g)&&(g=g(b,c,e,d));b=j(g);if(b===2){b=0;for(i=g.length;b<i;b++)s(h,t(a,g[b],b,i,null,f))}else b!==0&&(h=t(a,g,0,1,null,f))}a=h}return a;case "$xor":return D(a,b,c,e,d,f);case "$if":return D(["$xor",a],b,c,e,d,f);case "$call":f=a[1]||{};if(f.view){h=l(f.view,b,c,e,d);g=f.hasOwnProperty("data")?l(f.data,b,c,e,d):b;i=f.hasOwnProperty("index")?l(f.index,b,c,e,d):c;k=f.hasOwnProperty("count")?l(f.count,b,c,e,d):e;b=f.hasOwnProperty("key")?l(f.key,b,c,e,d):d;
+c={};for(e=a.length-1;e>=2;e--)d=a[e],f=d[1]||{},f.hasOwnProperty("name")&&(c[f.name]=d);a=h&&p(h.getView)?l(h.getView(),g,i,k,b,c):null}else a=null;return a;case "$part":return h=(a[1]||{}).name||"",h=f&&f.hasOwnProperty(h)?f[h]:a,t(h,b,c,e,d)}h=[h];g=1;for(i=a.length;g<i;g++)s(h,l(a[g],b,c,e,d,f));return h;case 3:f={};for(h in a)a.hasOwnProperty(h)&&(f[h]=l(a[h],b,c,e,d));return f}return a};var o=x.duel=function(a){return p(a)&&p(a.getView)?a:M(a)};o.raw=o.raw=function(a){return new y(a)};var P=
+{area:!0,base:!0,basefont:!0,br:!0,col:!0,frame:!0,hr:!0,img:!0,input:!0,isindex:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,wbr:!0};q.prototype.toString=function(){return F(this.value)};o.write=o.write=function(a,b,c,e,d){a=o(a).getView();a=l(a,b,c,e,d);m.write(F(a))};var Q={rowspan:"rowSpan",colspan:"colSpan",cellpadding:"cellPadding",cellspacing:"cellSpacing",tabindex:"tabIndex",accesskey:"accessKey",hidefocus:"hideFocus",usemap:"useMap",maxlength:"maxLength",readonly:"readOnly",contenteditable:"contentEditable"},
+u={enctype:"encoding",onscroll:"DOMMouseScroll"},R={onblur:!0,onchange:!0,onclick:!0,ondblclick:!0,onerror:!0,onfocus:!0,onkeydown:!0,onkeypress:!0,onkeyup:!0,onload:!0,onmousedown:!0,onmouseenter:!0,onmouseleave:!0,onmousemove:!0,onmouseout:!0,onmouseover:!0,onmouseup:!0,onresize:!0,onscroll:!0,onselect:!0,onsubmit:!0,onunload:!0},S=/^[\r\n]+/,T=/[\r\n]+$/;q.prototype.toDOM=q.prototype.toDOM=function(){try{return C(r(this.value[0]),this.value)}catch(a){return m.createTextNode("["+a+"]")}};q.prototype.reload=
+q.prototype.reload=function(){var a=m;try{var b=this.toDOM();a.replaceChild(b,a.documentElement);if(a.createStyleSheet){for(var c=b.firstChild;c&&(c.tagName||"")!=="HEAD";)c=c.nextSibling;for(var e=c&&c.firstChild;e;){if((e.tagName||"")==="LINK")e.href=e.href;e=e.nextSibling}}}catch(d){a=a.open("text/html"),a.write(this.toString()),a.close()}};o.attr=o.attr=function(a,b,c,e,d,f){j(a)===4&&(a=m.getElementById(a));a&&(b=l(b,c,e,d,f),H(a,b))};o.replace=o.replace=function(a,b,c,e,d,f){j(a)===4&&(a=m.getElementById(a));
 if(a&&a.parentNode){b=o(b).getView();b=l(b,c,e,d,f);try{b=C(r(b[0]),b)}catch(h){b=m.createTextNode("["+h+"]")}a.parentNode.replaceChild(b,a)}};return o}(window);

File duel-runtime/src/main/java/org/duelengine/duel/rs/DuelController.java

-package org.duelengine.duel.rs;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.StreamingOutput;
-import org.duelengine.duel.DuelContext;
-import org.duelengine.duel.DuelView;
-
-/**
- * Simple MVC-style controller for using DUEL views in JAX-RS
- */
-public abstract class DuelController {
-
-	protected abstract DuelContext getViewContext();
-
-	/**
-	 * Builds a view result
-	 */
-	protected ViewResult view(Class<? extends DuelView> view) {
-		return new ViewResult(view, this.getViewContext());
-	}
-
-	/**
-	 * Renders an error message to the response
-	 */
-	protected StreamingOutput error(final Exception ex) {
-		return new StreamingOutput() {
-			@Override
-			public void write(OutputStream stream)
-				throws IOException, WebApplicationException {
-
-				new OutputStreamWriter(stream, "UTF-8").write(ex.toString());
-			}
-		};
-	}
-}

File duel-runtime/src/main/java/org/duelengine/duel/rs/ViewResult.java

-package org.duelengine.duel.rs;
-
-import java.util.Map;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.StreamingOutput;
-import org.duelengine.duel.DuelContext;
-import org.duelengine.duel.DuelView;
-
-/**
- * Simple adapter for rendering DUEL views in JAX-RS
- */
-public class ViewResult implements StreamingOutput {
-
-	private final DuelContext context;
-	private final DuelView view;
-
-	public ViewResult(Class<? extends DuelView> view, DuelContext context) {
-
-		if (view == null) {
-			throw new NullPointerException("view");
-		}
-		try {
-			this.view = view.newInstance();
-		} catch (Exception ex) {
-			throw new WebApplicationException(ex, Response.Status.INTERNAL_SERVER_ERROR);
-		}
-
-		this.context = (context != null) ? context : new DuelContext();
-	}
-
-	public ViewResult data(Object data) {
-		this.context.setData(data);
-
-		return this;
-	}
-
-	public ViewResult extras(Map<String, ?> extras) {
-		this.context.putExtras(extras);
-
-		return this;
-	}
-
-	public ViewResult extra(String ident, Object value) {
-		this.context.putExtra(ident, value);
-
-		return this;
-	}
-
-	@Override
-	public void write(OutputStream stream)
-		throws IOException, WebApplicationException {
-
-		Writer output = new OutputStreamWriter(stream, this.context.getFormat().getEncoding());
-
-		try {
-			this.view.render(this.context.setOutput(output));
- 			output.flush();
-
-		} catch (Exception ex) {
-			throw new WebApplicationException(ex, Response.Status.INTERNAL_SERVER_ERROR);
-
- 		} finally {
-			this.context.setOutput(null);
-		}
-	}
-}

File duel-runtime/src/main/java/org/duelengine/duel/util/ClassEnumerator.java

-package org.duelengine.duel.util;
-
-import java.io.*;
-import java.net.*;
-import java.util.*;
-import java.util.jar.*;
-
-/**
- * Utility for enumerating available classes in a particular package
- */
-public final class ClassEnumerator {
-
-	private static final String CLASS_FILE = ".class";
-	private static final String JAR_FILE = ".jar";
-
-	/**
-	 * Loads classes in the specified package from the current thread ClassLoader
-	 * @param packageName
-	 * @return
-	 * @throws IOException
-	 * @throws ClassNotFoundException
-	 */
-	public static Set<Class<?>> getClasses(String packageName)
-			throws IOException, ClassNotFoundException {
-
-		return getClasses(packageName, Thread.currentThread().getContextClassLoader());
-	}
-
-	/**
-	 * Loads classes in the specified package from the specified ClassLoader
-	 * @param packageName
-	 * @param loader
-	 * @return
-	 * @throws IOException
-	 * @throws ClassNotFoundException
-	 */
-	public static Set<Class<?>> getClasses(String packageName, ClassLoader loader)
-			throws IOException, ClassNotFoundException {
-
-		String path = packageName.replace('.', '/');
-		Enumeration<URL> resources = loader.getResources(path);
-		if (resources == null) {
-			return Collections.emptySet();
-		}
-
-		Set<Class<?>> classes = new HashSet<Class<?>>();
-		while (resources.hasMoreElements()) {
-			String filePath = resources.nextElement().getPath();
-			if (filePath == null) {
-				continue;
-			}
-
-			// decode URL encoded characters
-			filePath = URLDecoder.decode(filePath, "UTF-8");
-
-			int bang = filePath.indexOf('!');
-			if ((bang > 0) & (filePath.lastIndexOf(JAR_FILE) > 0)) {
-				String jarPath = filePath.substring(0, bang).substring(filePath.lastIndexOf(':')+1);
-				classes.addAll(getFromJAR(path, jarPath));
-
-			} else {
-				classes.addAll(getFromDirectory(packageName, new File(filePath)));
-			}
-		}
-
-		return classes;
-	}
-
-	/**
-	 * Loads classes in the specified package from the specified directory
-	 * @param packageName
-	 * @param directory
-	 * @return
-	 * @throws ClassNotFoundException
-	 */
-	public static Set<Class<?>> getFromDirectory(String packageName, File directory)
-			throws ClassNotFoundException {
-
-		Set<Class<?>> classes = new HashSet<Class<?>>();
-		if (directory.exists()) {
-			for (String file : directory.list()) {
-				if (file.endsWith(CLASS_FILE)) {
-					String name = packageName + '.' + file.substring(0, file.lastIndexOf('.'));;
-					classes.add(Class.forName(name));
-				}
-			}
-		}
-		return classes;
-	}
-
-	/**
-	 * Loads classes in the specified package from the specified JAR
-	 * @param packageName
-	 * @param jar
-	 * @return
-	 * @throws FileNotFoundException
-	 * @throws IOException
-	 * @throws ClassNotFoundException
-	 */
-	public static Set<Class<?>> getFromJAR(String packageName, String jar)
-			throws FileNotFoundException, IOException, ClassNotFoundException {
-
-		JarInputStream jarFile = new JarInputStream(new FileInputStream(jar));
-		Set<Class<?>> classes = new HashSet<Class<?>>();
-
-		JarEntry jarEntry;
-		while ((jarEntry = jarFile.getNextJarEntry()) != null) {
-			String className = jarEntry.getName();
-			if (className.endsWith(CLASS_FILE)) {
-				className = className.substring(0, className.lastIndexOf('.'));
-				if (className.startsWith(packageName)) {
-					classes.add(Class.forName(className.replace('/', '.')));
-				}
-			}
-		}
-
-		return classes;
-	}
-}

File duel-runtime/src/main/java/org/duelengine/duel/util/DefaultWrapperServlet.java

-package org.duelengine.duel.util;
-
-import java.io.IOException;
-import javax.servlet.*;
-import javax.servlet.http.*;
-
-/**
- * Simple wrapper for passing the request onto the default servlet
- */
-public class DefaultWrapperServlet extends HttpServlet {
-
-	private static final long serialVersionUID = -351152009226372681L;
-
-	public void doGet(HttpServletRequest request, HttpServletResponse response)
-		throws ServletException, IOException {
-
-		getServletContext().getNamedDispatcher("default").forward(
-			new HttpServletRequestWrapper(request) {
-				public String getServletPath() { return ""; }
-			},
-			response);
-	}
-}

File duel-runtime/src/main/java/org/duelengine/duel/util/NeverExpireFilter.java

-package org.duelengine.duel.util;
-
-import java.io.IOException;
-import java.util.*;
-import javax.servlet.*;
-import javax.servlet.http.*;
-
-/**
- * Sets cache control to "never" expire.
- *
- * Only use for SHA1-named CDN resources which change name as content changes.
- * 
- * http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html
- * 
- * To mark a response as "never expires," an origin server sends an
- * Expires date approximately one year from the time the response is sent.
- * HTTP/1.1 servers SHOULD NOT send Expires dates more than one year in the future.
- */
-public class NeverExpireFilter implements Filter {
-
-	// this just needs to be far out, do not need to worry about leap year
-	private static final long ONE_YEAR = 365L * 24L * 60L * 60L * 1000L;
-
-	public void init(FilterConfig config) {}
-
-	public void destroy() {}
-
-	public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
-
-		if (response instanceof HttpServletResponse) {
-			HttpServletResponse httpResponse = (HttpServletResponse)response;
-
-			// expire one year from now
-			long expiryDate = new Date().getTime() + ONE_YEAR;
-
-			// add cache control response headers
-			httpResponse.setDateHeader("Expires", expiryDate);
-		}
-
-		chain.doFilter(request, response);
-	}
-}