From: <st...@us...> - 2010-05-27 11:47:16
|
Revision: 8303 http://smartfrog.svn.sourceforge.net/smartfrog/?rev=8303&view=rev Author: steve_l Date: 2010-05-27 11:47:10 +0000 (Thu, 27 May 2010) Log Message: ----------- SFOS-1489 Add JAX-RS application component which registers classes Modified Paths: -------------- trunk/core/components/jersey/src/org/smartfrog/services/www/jaxrs/JaxRsApplication.java trunk/core/components/jersey/src/org/smartfrog/services/www/jaxrs/JaxRsServicesImpl.java trunk/core/components/jersey/src/org/smartfrog/services/www/jaxrs/components.sf trunk/core/components/jersey/test/org/smartfrog/services/www/jaxrs/test/components.sf trunk/core/components/jersey/test/org/smartfrog/services/www/jaxrs/test/testapp/components.sf Added Paths: ----------- trunk/core/components/jersey/src/org/smartfrog/services/www/jaxrs/jetty/ trunk/core/components/jersey/src/org/smartfrog/services/www/jaxrs/jetty/components.sf trunk/core/components/jersey/src/org/smartfrog/services/www/jaxrs/jetty/webresources/ trunk/core/components/jersey/src/org/smartfrog/services/www/jaxrs/jetty/webresources/index.html Modified: trunk/core/components/jersey/src/org/smartfrog/services/www/jaxrs/JaxRsApplication.java =================================================================== --- trunk/core/components/jersey/src/org/smartfrog/services/www/jaxrs/JaxRsApplication.java 2010-05-26 21:04:30 UTC (rev 8302) +++ trunk/core/components/jersey/src/org/smartfrog/services/www/jaxrs/JaxRsApplication.java 2010-05-27 11:47:10 UTC (rev 8303) @@ -32,7 +32,6 @@ package org.smartfrog.services.www.jaxrs; -import org.smartfrog.sfcore.logging.Log; import org.smartfrog.sfcore.logging.LogSF; import org.smartfrog.sfcore.prim.Prim; @@ -43,7 +42,7 @@ */ public class JaxRsApplication extends Application { - + private final JaxRsServicesImpl owner; private LogSF log; @@ -59,7 +58,7 @@ public JaxRsLocalServices getLocalServices() { return owner; } - + public Prim getOwner() { return owner; } Modified: trunk/core/components/jersey/src/org/smartfrog/services/www/jaxrs/JaxRsServicesImpl.java =================================================================== --- trunk/core/components/jersey/src/org/smartfrog/services/www/jaxrs/JaxRsServicesImpl.java 2010-05-26 21:04:30 UTC (rev 8302) +++ trunk/core/components/jersey/src/org/smartfrog/services/www/jaxrs/JaxRsServicesImpl.java 2010-05-27 11:47:10 UTC (rev 8303) @@ -79,16 +79,42 @@ aClass = SFClassLoader.forName(classname); } catch (ClassNotFoundException e) { throw new SmartFrogDeploymentException( - "Endpoint class " + name + " value \"" + classname + "\" does not load", + "Endpoint class " + name + + " value \"" + classname + + "\" does not load in " + + getRuntimeString() + + ". Cause: " + e, e, this); } - endpoints.put(classname, createEndpoint(aClass)); + try { + Object endpointer = createEndpoint(aClass); + endpoints.put(classname, endpointer); + } catch (IllegalArgumentException e) { + throw new SmartFrogDeploymentException( + "Endpoint class " + name + " value \"" + classname + + "\" cannot be loaded in " + + getRuntimeString() + + ". Cause: " + e, + e, + this); + } catch (UnsupportedOperationException e) { + + } } } /** + * Get the runtime description + * + * @return the runtime + */ + public String getRuntimeString() { + return getRuntime().toString(); + } + + /** * {@inheritDoc} */ @Override Modified: trunk/core/components/jersey/src/org/smartfrog/services/www/jaxrs/components.sf =================================================================== --- trunk/core/components/jersey/src/org/smartfrog/services/www/jaxrs/components.sf 2010-05-26 21:04:30 UTC (rev 8302) +++ trunk/core/components/jersey/src/org/smartfrog/services/www/jaxrs/components.sf 2010-05-27 11:47:10 UTC (rev 8303) @@ -39,4 +39,82 @@ endpointClasses extends DATA { } -} \ No newline at end of file +} + +JaxRsConstants extends DATA { + //servlet name + servletName "javax.ws.rs.application"; +} + +JaxRsServlet extends Servlet { + name "JaxRsServlet"; + pathSpec "/*"; +} + +/** + * add jersey-specific options here + */ +JaxRsServletContext extends ServletContext { + +} + +/** + * Jersey specific values + */ +JerseyConstants extends DATA { + + servletClassName jersey10className; + jersey10className "com.sun.jersey.spi.container.servlet.ServletContainer"; + jersey11className "com.sun.jersey.server.impl.container.servlet.ServletAdaptor"; + initParamResourceConfigClass "com.sun.jersey.config.property.resourceConfigClass"; + initParamResourceConfigClassName "com.sun.jersey.api.core.PackagesResourceConfig"; + //set to a ; separated list of packages + initParamPackagesToScan "com.sun.jersey.config.property.packages"; +} + +/** + * This stuff isn't very well documented -use your search engine of choice + * to find details on it + * http://kingsfleet.blogspot.com/2008/10/running-jax-rcjerseyjsr311-on-weblogic.html + * http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/index.jsp?topic=/com.ibm.websphere.web20fepjaxrs.doc/info/ae/ae/twbs_jaxrs_configwebxml.html + + */ + +JerseyServlet extends JaxRsServlet { + //packages to Scan + packagesToScan "org.smarfrog.services.www.jaxrs"; + + initParams [ + [JerseyConstants:initParamResourceConfigClass, JerseyConstants:initParamResourceConfigClassName], + [JerseyConstants:initParamPackagesToScan, packagesToScan] + ]; + + className JerseyConstants:servletClassName; +} + +/** + * add jersey-specific options here + */ +JerseyServletContext extends JaxRsServletContext { + +} + + +/** + * A compound that deploys the servlet context and related servlets + */ +JerseyCompound extends Compound { + server TBD; + contextPath "/"; + + context extends JerseyServletContext { + server LAZY PARENT:server; + contextPath PARENT:contextPath; + resourcePackage "/org/smartfrog/services/www/jaxrs/jetty/webresources/"; + } + + jerseyServlet extends JerseyServlet { + context LAZY PARENT:context; + } + +} Added: trunk/core/components/jersey/src/org/smartfrog/services/www/jaxrs/jetty/components.sf =================================================================== --- trunk/core/components/jersey/src/org/smartfrog/services/www/jaxrs/jetty/components.sf (rev 0) +++ trunk/core/components/jersey/src/org/smartfrog/services/www/jaxrs/jetty/components.sf 2010-05-27 11:47:10 UTC (rev 8303) @@ -0,0 +1,34 @@ +/* (C) Copyright 2010 Hewlett-Packard Development Company, LP + +Disclaimer of Warranty + +The Software is provided "AS IS," without a warranty of any kind. ALL +EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, +INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE HEREBY +EXCLUDED. SmartFrog is not a Hewlett-Packard Product. The Software has +not undergone complete testing and may contain errors and defects. It +may not function properly and is subject to change or withdrawal at +any time. The user must assume the entire risk of using the +Software. No support or maintenance is provided with the Software by +Hewlett-Packard. Do not install the Software if you are not accustomed +to using experimental software. + +Limitation of Liability + +TO THE EXTENT NOT PROHIBITED BY LAW, IN NO EVENT WILL HEWLETT-PACKARD +OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR +FOR SPECIAL, INDIRECT, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, +HOWEVER CAUSED REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF +OR RELATED TO THE FURNISHING, PERFORMANCE, OR USE OF THE SOFTWARE, OR +THE INABILITY TO USE THE SOFTWARE, EVEN IF HEWLETT-PACKARD HAS BEEN +ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. FURTHERMORE, SINCE THE +SOFTWARE IS PROVIDED WITHOUT CHARGE, YOU AGREE THAT THERE HAS BEEN NO +BARGAIN MADE FOR ANY ASSUMPTIONS OF LIABILITY OR DAMAGES BY +HEWLETT-PACKARD FOR ANY REASON WHATSOEVER, RELATING TO THE SOFTWARE OR +ITS MEDIA, AND YOU HEREBY WAIVE ANY CLAIM IN THIS REGARD. + +*/ + +#include "/org/smartfrog/services/jetty/components.sf" + Added: trunk/core/components/jersey/src/org/smartfrog/services/www/jaxrs/jetty/webresources/index.html =================================================================== --- trunk/core/components/jersey/src/org/smartfrog/services/www/jaxrs/jetty/webresources/index.html (rev 0) +++ trunk/core/components/jersey/src/org/smartfrog/services/www/jaxrs/jetty/webresources/index.html 2010-05-27 11:47:10 UTC (rev 8303) @@ -0,0 +1,10 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" + "http://www.w3.org/TR/html4/loose.dtd"> +<html> +<head> + <title>Jersey</title> +</head> +<body> + +</body> +</html> \ No newline at end of file Modified: trunk/core/components/jersey/test/org/smartfrog/services/www/jaxrs/test/components.sf =================================================================== --- trunk/core/components/jersey/test/org/smartfrog/services/www/jaxrs/test/components.sf 2010-05-26 21:04:30 UTC (rev 8302) +++ trunk/core/components/jersey/test/org/smartfrog/services/www/jaxrs/test/components.sf 2010-05-27 11:47:10 UTC (rev 8303) @@ -34,7 +34,7 @@ #include "/org/smartfrog/services/www/jaxrs/test/testapp/components.sf" #include "/org/smartfrog/services/assertions/components.sf" -JerseyApplication extends Compound { +Java6JerseyApplication extends Compound { jerseyServer extends JerseyHttpServer { port 5050; @@ -44,6 +44,24 @@ } +JerseyApplication extends JerseyCompound { + + jetty extends LocalJettyServer { + host CoreJettyServer:ANY_HOST; + jettyhome "undefined"; + } + + server LAZY jetty:server; + + jaxRsApp extends TestJaxRsApp; + +} + + + + JerseyApplicationTest extends ExpectDeploy { + + action extends JerseyApplication; } Modified: trunk/core/components/jersey/test/org/smartfrog/services/www/jaxrs/test/testapp/components.sf =================================================================== --- trunk/core/components/jersey/test/org/smartfrog/services/www/jaxrs/test/testapp/components.sf 2010-05-26 21:04:30 UTC (rev 8302) +++ trunk/core/components/jersey/test/org/smartfrog/services/www/jaxrs/test/testapp/components.sf 2010-05-27 11:47:10 UTC (rev 8303) @@ -31,11 +31,14 @@ */ #include "/org/smartfrog/services/www/components.sf" #include "/org/smartfrog/services/www/jaxrs/components.sf" +//jetty server +#include "/org/smartfrog/services/jetty/examples/local_test_jetty_server.sf" TestJaxRsApp extends JaxRsServices { - + PACKAGE "org.smartfrog.services.www.jaxrs.test.testapp"; endpointClasses extends DATA { - error "org.smartfrog.services.www.jaxrs.test.testapp.ErrorResource"; - echo "org.smartfrog.services.www.jaxrs.test.testapp.EchoResource"; + error ( PACKAGE ++ ".ErrorResource"); + echo ( PACKAGE ++ ".EchoResource"); } } + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |