cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject [3/3] git commit: [CXF-5962] Make LogBrowser sample also run in OSGi
Date Wed, 20 Aug 2014 08:15:16 GMT
[CXF-5962] Make LogBrowser sample also run in OSGi


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/fb052052
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/fb052052
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/fb052052

Branch: refs/heads/master
Commit: fb0520525f07041f42bc0562b4a15240bb757373
Parents: 8190545
Author: Akitoshi Yoshida <ay@apache.org>
Authored: Tue Aug 19 19:23:36 2014 +0200
Committer: Akitoshi Yoshida <ay@apache.org>
Committed: Wed Aug 20 10:14:23 2014 +0200

----------------------------------------------------------------------
 .../main/release/samples/logbrowser/README.txt  |  20 ++-
 .../src/main/release/samples/logbrowser/pom.xml |  61 ++++++-
 .../src/main/java/demo/service/Server.java      |   2 +-
 .../logbrowser/src/main/webapp/WEB-INF/web.xml  |  62 +++++++
 .../src/main/webapp/customer-service.html       | 179 +++++++++++++++++++
 .../src/main/webapp/jquery-1.4.2.min.js         | 154 ++++++++++++++++
 .../samples/logbrowser/webapp/WEB-INF/web.xml   |  62 -------
 .../logbrowser/webapp/customer-service.html     | 175 ------------------
 .../logbrowser/webapp/jquery-1.4.2.min.js       | 154 ----------------
 .../features/src/main/resources/features.xml    |  11 ++
 rt/management-web/pom.xml                       |   4 +
 11 files changed, 489 insertions(+), 395 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/fb052052/distribution/src/main/release/samples/logbrowser/README.txt
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/logbrowser/README.txt b/distribution/src/main/release/samples/logbrowser/README.txt
index 467becf..4b53588 100644
--- a/distribution/src/main/release/samples/logbrowser/README.txt
+++ b/distribution/src/main/release/samples/logbrowser/README.txt
@@ -6,7 +6,7 @@ located), the pom.xml file is used to build and run the demo.
 
 Using either UNIX or Windows:
 
-1) Build the project by typing:
+0) Build the project by typing:
     mvn clean install
 1) Start the server:
     mvn -Pserver 
@@ -18,3 +18,21 @@ Using either UNIX or Windows:
     http://localhost:9002/customer-service.html
 
 To remove the .class files, run "mvn clean".
+
+
+This sample project generates a war file which can be used in a servlet container
+or even in an OSGi container.
+
+Assuming you have a freshly intalled Apache Karaf-3.x,
+1) Start Karaf and at its console, type (note m.n corresponding the version numbers)
+   feature:repo-add cxf 3.m.n
+   feature:install war
+   feature:install cxf-management-web
+   install -s mvn:org.apache.cxf.samples/logbrowser/3.1.0-SNAPSHOT/war
+
+2) Open browser and go to:
+    http://localhost:8181/cxf-samples-logbrowser/log/browser/LogBrowser.html
+3) Add new endpoint with URL:
+    http://localhost:8181/cxf-samples-logbrowser/log/logs
+4) To generate custom log entry open new browser's window and go to:
+    http://localhost:8181/cxf-samples-logbrowser/customer-service.html

http://git-wip-us.apache.org/repos/asf/cxf/blob/fb052052/distribution/src/main/release/samples/logbrowser/pom.xml
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/logbrowser/pom.xml b/distribution/src/main/release/samples/logbrowser/pom.xml
index 09b08f9..9400d12 100644
--- a/distribution/src/main/release/samples/logbrowser/pom.xml
+++ b/distribution/src/main/release/samples/logbrowser/pom.xml
@@ -20,14 +20,65 @@
 <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/maven-v4_0_0.xsd">
     <modelVersion>4.0.0</modelVersion>
     <artifactId>logbrowser</artifactId>
-    <name>LogBrowser</name>
-    <description>LogBrowser</description>
+    <packaging>war</packaging>
+    <name>Apache CXF Samples LogBrowser</name>
+    <description>Apacher CXF Samples LogBrowser</description>
     <parent>
         <groupId>org.apache.cxf.samples</groupId>
         <artifactId>cxf-samples</artifactId>
         <version>3.1.0-SNAPSHOT</version>
         <relativePath>..</relativePath>
     </parent>
+    <build>
+      <plugins>
+	<plugin>
+	  <groupId>org.apache.maven.plugins</groupId>
+	  <artifactId>maven-war-plugin</artifactId>
+	  <configuration>
+	    <!-- excluding libs and classes/META-INF for OSGi -->
+	    <packagingExcludes>WEB-INF/lib/,WEB-INF/classes/META-INF/</packagingExcludes>
+	    <archive>
+                <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
+            </archive>
+	  </configuration>
+	</plugin>
+	<plugin>
+	    <groupId>org.apache.felix</groupId>
+	    <artifactId>maven-bundle-plugin</artifactId>
+	    <executions>
+                <execution>
+                    <id>bundle-manifest</id>
+                    <phase>process-classes</phase>
+                    <goals>
+                        <goal>manifest</goal>
+                    </goals>
+		</execution>
+            </executions>
+	    <extensions>true</extensions>
+	    <configuration>
+	        <supportedProjectTypes>
+		    <supportedProjectType>jar</supportedProjectType>
+		    <supportedProjectType>bundle</supportedProjectType>
+		    <supportedProjectType>war</supportedProjectType>
+		</supportedProjectTypes>
+		<instructions>
+		    <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
+		    <Bundle-Description>${project.description}</Bundle-Description>
+		    <Web-ContextPath>/cxf-samples-logbrowser</Web-ContextPath>
+		    <Bundle-ClassPath>.,WEB-INF/classes</Bundle-ClassPath>
+		    <Export-Package />
+		    <Import-Package>
+			org.apache.cxf.jaxrs.servlet,
+			org.apache.abdera.parser.stax,
+			com.ctc.wstx.stax,
+			org.apache.abdera,
+			*
+		    </Import-Package>
+		</instructions>
+	    </configuration>
+	</plugin>
+      </plugins>
+    </build>
     <profiles>
         <profile>
             <id>server</id>
@@ -87,6 +138,12 @@
         <dependency>
             <groupId>org.apache.abdera</groupId>
             <artifactId>abdera-parser</artifactId>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.apache.james</groupId>
+                    <artifactId>apache-mime4j-core</artifactId>
+                </exclusion>
+	    </exclusions>
         </dependency>
         <dependency>
             <groupId>org.eclipse.jetty</groupId>

http://git-wip-us.apache.org/repos/asf/cxf/blob/fb052052/distribution/src/main/release/samples/logbrowser/src/main/java/demo/service/Server.java
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/logbrowser/src/main/java/demo/service/Server.java
b/distribution/src/main/release/samples/logbrowser/src/main/java/demo/service/Server.java
index 2373433..53aed96 100644
--- a/distribution/src/main/release/samples/logbrowser/src/main/java/demo/service/Server.java
+++ b/distribution/src/main/release/samples/logbrowser/src/main/java/demo/service/Server.java
@@ -47,7 +47,7 @@ public class Server {
         WebAppContext webappcontext = new WebAppContext();
         webappcontext.setContextPath("/");
 
-        webappcontext.setWar("webapp");
+        webappcontext.setWar("src/main/webapp");
 
         HandlerCollection handlers = new HandlerCollection();
         handlers.setHandlers(new Handler[] {webappcontext, new DefaultHandler()});

http://git-wip-us.apache.org/repos/asf/cxf/blob/fb052052/distribution/src/main/release/samples/logbrowser/src/main/webapp/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/logbrowser/src/main/webapp/WEB-INF/web.xml
b/distribution/src/main/release/samples/logbrowser/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..cd164ea
--- /dev/null
+++ b/distribution/src/main/release/samples/logbrowser/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements. See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership. The ASF 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.
+-->
+<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
version="2.5" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee           http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
+    <servlet>
+        <servlet-name>CustomerService</servlet-name>
+        <display-name>CustomerService</display-name>
+        <servlet-class>org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet</servlet-class>
+        <init-param>
+            <param-name>javax.ws.rs.Application</param-name>
+            <param-value>demo.service.App</param-value>
+        </init-param>
+        <init-param>
+            <param-name>jaxrs.inInterceptors</param-name>
+            <param-value>
+                org.apache.cxf.interceptor.LoggingInInterceptor
+            </param-value>
+        </init-param>
+        <init-param>
+            <param-name>jaxrs.outInterceptors</param-name>
+            <param-value>
+                org.apache.cxf.interceptor.LoggingOutInterceptor
+            </param-value>
+        </init-param>
+        <load-on-startup>1</load-on-startup>
+    </servlet>
+    <servlet>
+        <servlet-name>BrowserServlet</servlet-name>
+        <display-name>BrowserServlet</display-name>
+        <servlet-class>org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet</servlet-class>
+        <init-param>
+            <param-name>javax.ws.rs.Application</param-name>
+            <param-value>demo.logbrowser.App</param-value>
+        </init-param>
+        <load-on-startup>2</load-on-startup>
+    </servlet>
+    <servlet-mapping>
+        <servlet-name>BrowserServlet</servlet-name>
+        <url-pattern>/log/*</url-pattern>
+    </servlet-mapping>
+    <servlet-mapping>
+        <servlet-name>CustomerService</servlet-name>
+        <url-pattern>/service/*</url-pattern>
+    </servlet-mapping>
+</web-app>
+<!-- END SNIPPET: webxml -->

http://git-wip-us.apache.org/repos/asf/cxf/blob/fb052052/distribution/src/main/release/samples/logbrowser/src/main/webapp/customer-service.html
----------------------------------------------------------------------
diff --git a/distribution/src/main/release/samples/logbrowser/src/main/webapp/customer-service.html
b/distribution/src/main/release/samples/logbrowser/src/main/webapp/customer-service.html
new file mode 100644
index 0000000..97c2ceb
--- /dev/null
+++ b/distribution/src/main/release/samples/logbrowser/src/main/webapp/customer-service.html
@@ -0,0 +1,179 @@
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements. See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership. The ASF 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.
+  -->
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+    <title>Customer Service</title>
+
+    <style type="text/css">
+        label {
+            width: 5em;
+            float: left;
+            text-align: right;
+            margin-right: 0.5em;
+            display: block;
+        }
+        .submit a {
+            margin-left: 5.5em;
+        }
+        .submit input {
+            margin-left: 8em;
+        }
+    </style>
+
+    <script type="text/javascript" src="./jquery-1.4.2.min.js"></script>
+    
+    <script type="text/javascript">
+
+        var wloc = window.location.pathname;
+	wloc = wloc.substring(0, wloc.lastIndexOf('/'));
+
+        function buildCustomerAsString(id, name) {
+            return "{ \"Customer\" : { \"id\" : \"" + id + "\", \"name\" : \"" + name +"\"
} }";
+        }
+
+        $(document).ready(function() {
+            $("#addOrUpdateCustomerButton").click(function() {
+                var isError = false;
+
+                var id = $("#addOrUpdateCustomerForm INPUT[name='customer.id']").val();
+                if (id == null || id == "") {
+                    alert("Field 'ID' can't be empty");
+                    isError = true;
+                }
+
+                var name = $("#addOrUpdateCustomerForm INPUT[name='customer.name']").val();
+                if (name == null || name == "") {
+                    alert("Field 'Name' can't be empty");
+                    isError = true;
+                }
+
+                if (isError) {
+                    return;
+                }
+
+                $.ajax({
+                    type: "POST",
+                    url : wloc + "/service/customers/",
+                    contentType : "application/json",
+                    data : buildCustomerAsString(id, name),
+                    complete : function(xhr) {
+                        if (xhr.status == 200) {
+                            alert("Customer added/updated successfully");
+                        } else {
+                            alert("Error occurred");
+                        }
+                    }
+                });
+            });
+
+            $("#getCustomerButton").click(function() {
+                var id = $("#getCustomerForm INPUT[name='customer.id']").val();
+                if (id == null || id == "") {
+                    alert("Field 'ID' can't be empty");
+                    return;
+                }
+
+                $.ajax({
+                    type: "GET",
+                    url : wloc + "/service/customers/" + id,
+                    dataType : "text",
+                    complete : function(xhr) {
+                        if (xhr.status == 200) {
+                            alert(xhr.responseText);
+                        } else if (xhr.status == 204) {
+                            alert("Customer, with specified ID, doesn't exist");
+                        } else {
+                            alert("Error occurred");
+                        }        
+                    }
+                });
+            });
+
+            $("#deleteCustomerButton").click(function() {
+                var id = $("#deleteCustomerForm INPUT[name='customer.id']").val();
+                if (id == null || id == "") {
+                    alert("Field 'ID' can't be empty");
+                    return;
+                }
+
+                $.ajax({
+                    type: "DELETE",
+                    url : wloc + "/service/customers/" + id,
+                    complete : function(xhr) {
+                        if (xhr.status == 200) {
+                            alert("Customer deleted successfully");
+                        } else if (xhr.status == 304) {
+                            alert("Customer, with specified ID, doesn't exist");
+                        } else {
+                            alert("Error occurred");
+                        }
+                    }
+                });
+            });
+
+            $("INPUT.digits").keyup(function () { 
+                this.value = this.value.replace(/[^0-9\.]/g,'');
+            });
+        });
+    </script>
+</head>
+<body>
+
+<div>
+    <h1>Customer Service</h1>
+
+    <h2>Add or update customer</h2>
+    <form id="addOrUpdateCustomerForm" action="#">
+        <p>
+            <label>ID:</label>
+            <input name="customer.id" class="digits" type="text" size="3"/>
+        </p>
+
+        <p>
+            <label>Name:</label>
+            <input name="customer.name" type="text" size="30"/>
+        </p>
+
+        <p class="submit"><a id="addOrUpdateCustomerButton" href="#">Add or Update</a></p>
+    </form>
+
+    <h2>Get customer</h2>
+    <form id="getCustomerForm" action="#">
+        <p>
+            <label>ID:</label>
+            <input name="customer.id" class="digits" type="text" size="3"/>
+        </p>
+
+        <p class="submit"><a id="getCustomerButton" href="#">Get</a></p>
+    </form>
+
+    <h2>Delete customer</h2>
+    <form id="deleteCustomerForm" action="#">
+        <p>
+            <label>ID:</label>
+            <input name="customer.id" class="digits" type="text" size="3"/>
+        </p>
+
+        <p class="submit"><a id="deleteCustomerButton" href="#">Delete</a></p>
+    </form>
+</div>
+</body>
+</html>


Mime
View raw message