| <html><head> |
| <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> |
| <title>Chapter 29. Frameworks</title><link rel="stylesheet" type="text/css" href="css/docbook.css"><meta name="generator" content="DocBook XSL Stylesheets V1.79.1"><meta name="keywords" content="jetty, servlet, servlet-api, cometd, http, websocket, eclipse, maven, java, server, software"><link rel="home" href="index.html" title="Jetty"><link rel="up" href="jetty-dev-guide.html" title="Part IV. Jetty Development Guide"><link rel="prev" href="continuations-patterns.html" title="Common Continuation Patterns"><link rel="next" href="framework-jetty-osgi.html" title="OSGI"><link xmlns:jfetch="java:org.eclipse.jetty.xslt.tools.JavaSourceFetchExtension" xmlns:fetch="java:org.eclipse.jetty.xslt.tools.SourceFetchExtension" xmlns:d="http://docbook.org/ns/docbook" xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" xmlns:xslthl="http://xslthl.sf.net" xmlns:gcse="http://www.google.com" xmlns:date="http://exslt.org/dates-and-times" rel="shortcut icon" href="images/favicon.ico"><link rel="stylesheet" href="css/highlighter/foundation.css"><script src="js/highlight.pack.js"></script><script> |
| hljs.initHighlightingOnLoad(); |
| </script><link type="text/css" rel="stylesheet" href="css/font-awesome/font-awesome.min.css"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><table xmlns:jfetch="java:org.eclipse.jetty.xslt.tools.JavaSourceFetchExtension" xmlns:fetch="java:org.eclipse.jetty.xslt.tools.SourceFetchExtension" xmlns:d="http://docbook.org/ns/docbook" xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" xmlns:xslthl="http://xslthl.sf.net" xmlns:gcse="http://www.google.com" xmlns:date="http://exslt.org/dates-and-times"><tr><td style="width: 25%"><a href="http://www.eclipse.org/jetty"><img src="images/jetty-header-logo.png" alt="Jetty Logo"></a><br><span style="font-size: small"> |
| Version: 9.4.29.v20200521</span></td><td style="width: 50%"></td></tr></table><div xmlns:jfetch="java:org.eclipse.jetty.xslt.tools.JavaSourceFetchExtension" xmlns:fetch="java:org.eclipse.jetty.xslt.tools.SourceFetchExtension" xmlns:d="http://docbook.org/ns/docbook" xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" xmlns:xslthl="http://xslthl.sf.net" xmlns:gcse="http://www.google.com" xmlns:date="http://exslt.org/dates-and-times" class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 29. Frameworks</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="continuations-patterns.html"><i class="fa fa-chevron-left" aria-hidden="true"></i> Previous</a> </td><th width="60%" align="center">Part IV. Jetty Development Guide<br><a accesskey="p" href="index.html"><i class="fa fa-home" aria-hidden="true"></i> Home</a></th><td width="20%" align="right"> <a accesskey="n" href="framework-jetty-osgi.html">Next <i class="fa fa-chevron-right" aria-hidden="true"></i></a></td></tr></table><hr></div><div xmlns:jfetch="java:org.eclipse.jetty.xslt.tools.JavaSourceFetchExtension" xmlns:fetch="java:org.eclipse.jetty.xslt.tools.SourceFetchExtension" xmlns:d="http://docbook.org/ns/docbook" xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" xmlns:xslthl="http://xslthl.sf.net" xmlns:gcse="http://www.google.com" xmlns:date="http://exslt.org/dates-and-times" class="jetty-callout"><h5 class="callout"><a href="http://www.webtide.com/">Contact the core Jetty developers at |
| <span class="website">www.webtide.com</span></a></h5><p> |
| private support for your internal/customer projects ... custom extensions and distributions ... versioned snapshots for indefinite support ... |
| scalability guidance for your apps and Ajax/Comet projects ... development services for sponsored feature development |
| </p></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a name="frameworks"></a>Chapter 29. Frameworks</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl class="toc"><dt><span class="section"><a href="frameworks.html#framework-jetty-spring">Spring Setup</a></span></dt><dt><span class="section"><a href="framework-jetty-osgi.html">OSGI</a></span></dt><dt><span class="section"><a href="framework-weld.html">Weld</a></span></dt><dt><span class="section"><a href="framework-metro.html">Metro</a></span></dt></dl></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="framework-jetty-spring"></a>Spring Setup</h2></div></div></div><div class="toc"><dl class="toc"><dt><span class="section"><a href="frameworks.html#_jetty_spring_module">Jetty-Spring Module</a></span></dt><dt><span class="section"><a href="frameworks.html#_using_spring_to_configure_jetty">Using Spring to Configure Jetty</a></span></dt></dl></div><p>You can assemble and configure Jetty in code or with almost any IoC style framework including Spring. |
| If all you want to do is setup a Jetty server in your stock Spring usage, simply look at the xml snippet below as an example. |
| If you want to replace the jetty-xml being used to start the normal Jetty distribution with spring, you may do so however currently it will not leverage the rest of the module system.</p><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="_jetty_spring_module"></a>Jetty-Spring Module</h3></div></div></div><p>The skeleton of a jetty spring module can be enabled from the jetty-distribution via the <a class="link" href="startup-modules.html" title="Managing Startup Modules">module mechanism</a>. |
| For example:</p><div class="screenexample"><pre class="screen">$ java -jar start.jar --add-to-start=spring</pre></div><p>This (or the alternative <a class="link" href="start-jar.html" title="Using start.jar">--add-to-start</a>=spring command) creates a <code class="literal">${jetty.home}/lib/spring</code> directory and populates it with the jetty-spring integration jar. |
| It does NOT supply the spring jars and their dependencies. |
| You will need to download these and place them into jetty’s classpath - you can use the <code class="literal">${jetty.home}/lib/spring</code> directory created by spring.mod for this purpose.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a name="_using_spring_to_configure_jetty"></a>Using Spring to Configure Jetty</h3></div></div></div><p>Configuring Jetty via Spring is simply a matter of calling the API as Spring beans. |
| The following is an example mimicking the default jetty startup configuration.</p><pre xmlns:jfetch="java:org.eclipse.jetty.xslt.tools.JavaSourceFetchExtension" xmlns:fetch="java:org.eclipse.jetty.xslt.tools.SourceFetchExtension" xmlns:d="http://docbook.org/ns/docbook" xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" xmlns:xslthl="http://xslthl.sf.net" xmlns:gcse="http://www.google.com" xmlns:date="http://exslt.org/dates-and-times"><code><?xml version="1.0" encoding="UTF-8"?> |
| <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd"> |
| |
| <!-- =============================================================== --> |
| <!-- Configure the Jetty Server with Spring --> |
| <!-- This file is the similar to jetty.xml, but written in spring --> |
| <!-- XmlBeanFactory format. --> |
| <!-- =============================================================== --> |
| |
| <beans> |
| <bean id="contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/> |
| <bean id="server" name="Main" class="org.eclipse.jetty.server.Server" init-method="start" destroy-method="stop"> |
| <constructor-arg> |
| <bean id="threadPool" class="org.eclipse.jetty.util.thread.QueuedThreadPool"> |
| <property name="minThreads" value="10"/> |
| <property name="maxThreads" value="50"/> |
| </bean> |
| </constructor-arg> |
| <property name="connectors"> |
| <list> |
| <bean id="connector" class="org.eclipse.jetty.server.ServerConnector"> |
| <constructor-arg ref="server"/> |
| <property name="port" value="8080"/> |
| </bean> |
| </list> |
| </property> |
| <property name="handler"> |
| <bean id="handlers" class="org.eclipse.jetty.server.handler.HandlerCollection"> |
| <property name="handlers"> |
| <list> |
| <ref bean="contexts"/> |
| <bean id="defaultHandler" class="org.eclipse.jetty.server.handler.DefaultHandler"/> |
| </list> |
| </property> |
| </bean> |
| </property> |
| <property name="beans"> |
| <list> |
| <bean id="deploymentManager" class="org.eclipse.jetty.deploy.DeploymentManager"> |
| <property name="contexts" ref="contexts"/> |
| <property name="appProviders"> |
| <list> |
| <bean id="webAppProvider" class="org.eclipse.jetty.deploy.providers.WebAppProvider"> |
| <property name="monitoredDirName" value="webapps"/> |
| <property name="scanInterval" value="1"/> |
| <property name="extractWars" value="true"/> |
| </bean> |
| </list> |
| </property> |
| </bean> |
| </list> |
| </property> |
| </bean> |
| </beans></code></pre></div></div></div><script type="text/javascript"> |
| SyntaxHighlighter.all() |
| </script><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="continuations-patterns.html"><i class="fa fa-chevron-left" aria-hidden="true"></i> Previous</a> </td><td width="20%" align="center"><a accesskey="u" href="jetty-dev-guide.html"><i class="fa fa-chevron-up" aria-hidden="true"></i> Top</a></td><td width="40%" align="right"> <a accesskey="n" href="framework-jetty-osgi.html">Next <i class="fa fa-chevron-right" aria-hidden="true"></i></a></td></tr><tr><td width="40%" align="left" valign="top">Common Continuation Patterns </td><td width="20%" align="center"><a accesskey="h" href="index.html"><i class="fa fa-home" aria-hidden="true"></i> Home</a></td><td width="40%" align="right" valign="top"> OSGI</td></tr></table></div><p xmlns:jfetch="java:org.eclipse.jetty.xslt.tools.JavaSourceFetchExtension" xmlns:fetch="java:org.eclipse.jetty.xslt.tools.SourceFetchExtension" xmlns:d="http://docbook.org/ns/docbook" xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" xmlns:xslthl="http://xslthl.sf.net" xmlns:gcse="http://www.google.com" xmlns:date="http://exslt.org/dates-and-times"><div class="jetty-callout"> |
| See an error or something missing? |
| <span class="callout"><a href="http://github.com/eclipse/jetty.project">Contribute to this documentation at |
| <span class="website"><i class="fa fa-github" aria-hidden="true"></i> Github!</span></a></span><span style="float: right"><i>(Generated: 2020-05-21)</i></span></div></p></body></html> |