killbill-uncached

server: various fixes * Fix the wiring to handle only REST

2/26/2013 3:01:07 PM

Details

bin/start-server 3(+3 -0)

diff --git a/bin/start-server b/bin/start-server
index e5b6582..2b42e28 100755
--- a/bin/start-server
+++ b/bin/start-server
@@ -32,6 +32,7 @@ DEBUG_OPTS_ECLIPSE_WAIT=" -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend
 MAVEN_OPTS=${MAVEN_OPTS-"-Xms512m -Xmx1024m -XX:MaxPermSize=512m -XX:MaxDirectMemorySize=512m -XX:+UseConcMarkSweepGC"}
 
 LOG="$SERVER/src/main/resources/logback.xml"
+LOG_DIR="$SERVER/logs"
 
 # From Argument Options
 PORT=8080
@@ -62,6 +63,8 @@ function build_properties() {
 }
 
 function start() {
+    mkdir -p $LOG_DIR
+
     local opts=`build_properties`
     local start_cmd="mvn $opts -Dlogback.configurationFile=$LOG -Dning.jmx.http.port=$PORT -Dxn.host.external.port=$PORT -DjettyPort=$PORT -Dxn.server.port=$PORT jetty:run"
 

server/pom.xml 31(+22 -9)

diff --git a/server/pom.xml b/server/pom.xml
index a794998..e446957 100644
--- a/server/pom.xml
+++ b/server/pom.xml
@@ -15,7 +15,8 @@
   ~ under the License.
   -->
 
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     <modelVersion>4.0.0</modelVersion>
     <parent>
         <groupId>com.ning.billing</groupId>
@@ -361,13 +362,6 @@
                 <artifactId>jetty-maven-plugin</artifactId>
                 <version>${jetty.version}</version>
                 <dependencies>
-                    <dependency><!-- For LogLevelCounterAppender -->
-                        <groupId>com.ning.jetty</groupId>
-                        <artifactId>ning-service-skeleton-log4j</artifactId>
-                        <version>${skeleton.version}</version>
-                        <classifier>selfcontained</classifier>
-                        <scope>runtime</scope>
-                    </dependency>
                     <!-- Needed to redirect Jetty logs to slf4j -->
                     <dependency>
                         <groupId>org.slf4j</groupId>
@@ -384,15 +378,34 @@
                         <artifactId>logback-classic</artifactId>
                         <version>${logback.version}</version>
                     </dependency>
+                    <dependency>
+                        <groupId>org.eclipse.jetty</groupId>
+                        <artifactId>jetty-deploy</artifactId>
+                        <version>${jetty.version}</version>
+                    </dependency>
+                    <dependency>
+                        <groupId>org.eclipse.jetty</groupId>
+                        <artifactId>jetty-jmx</artifactId>
+                        <version>${jetty.version}</version>
+                    </dependency>
                 </dependencies>
                 <configuration>
-                    <scanIntervalSeconds>60</scanIntervalSeconds>
+                    <jettyXml>${basedir}/src/main/jetty-config/ning-jetty-conf.xml</jettyXml>
+                    <contextXml>${basedir}/src/main/jetty-config/contexts/root.xml</contextXml>
                     <systemProperties>
                         <systemProperty>
+                            <!-- See root.xml -->
+                            <name>xn.jetty.webapps.defaultsDescriptor</name>
+                            <value>${basedir}/src/main/jetty-config/etc/webdefault.xml</value>
+                        </systemProperty>
+                        <systemProperty>
                             <name>logback.configurationFile</name>
                             <value>file:${basedir}/src/main/resources/logback.xml</value>
                         </systemProperty>
                     </systemProperties>
+                    <scanIntervalSeconds>0</scanIntervalSeconds>
+                    <stopPort>9966</stopPort>
+                    <stopKey>foo</stopKey>
                 </configuration>
             </plugin>
         </plugins>
diff --git a/server/src/main/java/com/ning/billing/server/listeners/KillbillGuiceListener.java b/server/src/main/java/com/ning/billing/server/listeners/KillbillGuiceListener.java
index aaf22b7..e40a5dc 100644
--- a/server/src/main/java/com/ning/billing/server/listeners/KillbillGuiceListener.java
+++ b/server/src/main/java/com/ning/billing/server/listeners/KillbillGuiceListener.java
@@ -26,6 +26,7 @@ import org.slf4j.LoggerFactory;
 
 import com.ning.billing.beatrix.bus.api.ExternalBus;
 import com.ning.billing.beatrix.lifecycle.DefaultLifecycle;
+import com.ning.billing.jaxrs.resources.JaxRsResourceBase;
 import com.ning.billing.jaxrs.util.KillbillEventHandler;
 import com.ning.billing.server.config.KillbillServerConfig;
 import com.ning.billing.server.healthchecks.KillbillHealthcheck;
@@ -76,6 +77,9 @@ public class KillbillGuiceListener extends SetupServer {
                 .addJMXExport(InternalBus.class)
                 .addJMXExport(ExternalBus.class)
                 .addModule(getModule())
+                // Don't filter all requests through Jersey, only the JAX-RS APIs (otherwise,
+                // things like static resources, favicon, etc. are 404'ed)
+                .setJerseyUriPattern(JaxRsResourceBase.PREFIX + "/.*")
                 .addJerseyResource("com.ning.billing.jaxrs.mappers")
                 .addJerseyResource("com.ning.billing.jaxrs.resources");
 
diff --git a/server/src/main/jetty-config/etc/webdefault.xml b/server/src/main/jetty-config/etc/webdefault.xml
index 19ae6ff..3c677f3 100755
--- a/server/src/main/jetty-config/etc/webdefault.xml
+++ b/server/src/main/jetty-config/etc/webdefault.xml
@@ -9,6 +9,57 @@
         Default web.xml file.
         This file is applied to a Web application before it's own WEB_INF/web.xml file
     </description>
+
+    <servlet>
+        <servlet-name>default</servlet-name>
+        <servlet-class>org.eclipse.jetty.servlet.DefaultServlet</servlet-class>
+        <init-param>
+            <param-name>aliases</param-name>
+            <param-value>false</param-value>
+        </init-param>
+        <init-param>
+            <param-name>acceptRanges</param-name>
+            <param-value>true</param-value>
+        </init-param>
+        <init-param>
+            <param-name>dirAllowed</param-name>
+            <param-value>false</param-value>
+        </init-param>
+        <init-param>
+            <param-name>welcomeServlets</param-name>
+            <param-value>false</param-value>
+        </init-param>
+        <init-param>
+            <param-name>redirectWelcome</param-name>
+            <param-value>false</param-value>
+        </init-param>
+        <init-param>
+            <param-name>maxCacheSize</param-name>
+            <param-value>256000000</param-value>
+        </init-param>
+        <init-param>
+            <param-name>maxCachedFileSize</param-name>
+            <param-value>200000000</param-value>
+        </init-param>
+        <init-param>
+            <param-name>maxCachedFiles</param-name>
+            <param-value>2048</param-value>
+        </init-param>
+        <init-param>
+            <param-name>gzip</param-name>
+            <param-value>true</param-value>
+        </init-param>
+        <init-param>
+            <param-name>etags</param-name>
+            <param-value>true</param-value>
+        </init-param>
+        <init-param>
+            <param-name>useFileMappedBuffer</param-name>
+            <param-value>true</param-value>
+        </init-param>
+        <load-on-startup>0</load-on-startup>
+    </servlet>
+
     <context-param>
         <param-name>org.mortbay.jetty.webapp.NoTLDJarPattern</param-name>
         <param-value>
diff --git a/server/src/main/webapp/favicon.ico b/server/src/main/webapp/favicon.ico
new file mode 100644
index 0000000..675f906
Binary files /dev/null and b/server/src/main/webapp/favicon.ico differ
diff --git a/server/src/main/webapp/index.html b/server/src/main/webapp/index.html
new file mode 100644
index 0000000..be6a5de
--- /dev/null
+++ b/server/src/main/webapp/index.html
@@ -0,0 +1,17 @@
+<!--
+  ~ Copyright 2010-2013 Ning, Inc.
+  ~
+  ~ Ning licenses this file to you under the Apache License, version 2.0
+  ~ (the "License"); you may not use this file except in compliance with the
+  ~ License.  You may obtain a copy of the License at:
+  ~
+  ~    http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+  ~ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+  ~ License for the specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+Welcome!
diff --git a/server/src/main/webapp/WEB-INF/web.xml b/server/src/main/webapp/WEB-INF/web.xml
index 23a2813..dfe356d 100644
--- a/server/src/main/webapp/WEB-INF/web.xml
+++ b/server/src/main/webapp/WEB-INF/web.xml
@@ -2,10 +2,8 @@
 <web-app
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns="http://java.sun.com/xml/ns/javaee"
-        xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
         version="2.5">
-    <display-name>irs</display-name>
     <listener>
         <!-- Initialize Shiro WebEnvironment and put it into the ServletContext -->
         <listener-class>org.apache.shiro.web.env.EnvironmentLoaderListener</listener-class>
@@ -43,13 +41,10 @@
         <listener-class>com.ning.billing.server.listeners.KillbillGuiceListener</listener-class>
     </listener>
 
-    <!-- ServletHandler#handle requires a backend servlet, it won't be used though (handled by Guice) -->
-    <servlet>
-        <servlet-name>log-invalid-resources</servlet-name>
-        <servlet-class>com.ning.jetty.core.servlets.LogInvalidResourcesServlet</servlet-class>
-    </servlet>
+    <!-- ServletHandler#handle requires a backend servlet. Besides, this will also be used to serve static resources,
+         such as the favicon or the welcome page -->
     <servlet-mapping>
-        <servlet-name>log-invalid-resources</servlet-name>
+        <servlet-name>default</servlet-name>
         <url-pattern>/*</url-pattern>
     </servlet-mapping>
 </web-app>