Skip to main content
summaryrefslogtreecommitdiffstats
blob: c6bb9355906259ac9e485b44f9b813f58e67bb38 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<html><head>
      <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
   <title>Chapter&nbsp;27.&nbsp;Frameworks</title><link rel="stylesheet" type="text/css" href="css/docbook.css"><meta name="generator" content="DocBook XSL-NS Stylesheets V1.76.1"><meta name="keywords" content="jetty, servlet, servlet-api, cometd, http, spdy, websocket, eclipse, maven, java, server, software"><link rel="home" href="index.html" title="Jetty : The Definitive Reference"><link rel="up" href="development.html" title="Part&nbsp;IV.&nbsp;Jetty Development Guide"><link rel="prev" href="debugging-with-intellij.html" title="Debugging With IntelliJ"><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"><script type="text/javascript" src="js/shCore.js"></script><script type="text/javascript" src="js/shBrushJava.js"></script><script type="text/javascript" src="js/shBrushXml.js"></script><script type="text/javascript" src="js/shBrushBash.js"></script><script type="text/javascript" src="js/shBrushJScript.js"></script><script type="text/javascript" src="js/shBrushSql.js"></script><script type="text/javascript" src="js/shBrushProperties.js"></script><script type="text/javascript" src="js/shBrushPlain.js"></script><link type="text/css" rel="stylesheet" href="css/shCore.css"><link type="text/css" rel="stylesheet" href="css/shThemeEclipse.css"><link type="text/css" rel="stylesheet" href="css/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.2.3.v20140905</span></td><td style="width: 50%"><script type="text/javascript">  (function() {
            var cx = '016459005284625897022:obd4lsai2ds';
            var gcse = document.createElement('script');
            gcse.type = 'text/javascript';
            gcse.async = true;
            gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +
            '//www.google.com/cse/cse.js?cx=' + cx;
            var s = document.getElementsByTagName('script')[0];
            s.parentNode.insertBefore(gcse, s);
            })();
          </script><gcse:search></gcse:search></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&nbsp;27.&nbsp;Frameworks</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="debugging-with-intellij.html"><i class="icon-chevron-left"></i> Previous</a>&nbsp;</td><th width="60%" align="center">Part&nbsp;IV.&nbsp;Jetty Development Guide<br><a accesskey="p" href="index.html"><i class="icon-home"></i> Home</a></th><td width="20%" align="right">&nbsp;<a accesskey="n" href="framework-jetty-osgi.html">Next <i class="icon-chevron-right"></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 from 1 day to full product delivery
      </p></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a name="frameworks"></a>Chapter&nbsp;27.&nbsp;Frameworks</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><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><dt><span class="section"><a href="frameworks.html#d0e19602">Jetty-Spring Module</a></span></dt><dt><span class="section"><a href="frameworks.html#d0e19623">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="d0e19602"></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-startd=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="code">${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="code">${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="d0e19623"></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><div class="informalexample"><script type="syntaxhighlighter" class="brush: xml;toolbar: false">
          <![CDATA[
			
<?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>

		]]>
        </script></div></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="debugging-with-intellij.html"><i class="icon-chevron-left"></i> Previous</a>&nbsp;</td><td width="20%" align="center"><a accesskey="u" href="development.html"><i class="icon-chevron-up"></i> Top</a></td><td width="40%" align="right">&nbsp;<a accesskey="n" href="framework-jetty-osgi.html">Next <i class="icon-chevron-right"></i></a></td></tr><tr><td width="40%" align="left" valign="top">Debugging With IntelliJ&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="index.html"><i class="icon-home"></i> Home</a></td><td width="40%" align="right" valign="top">&nbsp;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/jetty-project/jetty-documentation">Contribute to this documentation at
                <span class="website"><i class="icon-github"></i> Github!</span></a></span><span style="float: right"><i>(Generated: 2014-10-25T01:00:35-07:00)</i></span></div></p><script 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" type="text/javascript">
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-1149868-7']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
    </script></body></html>

Back to the top