⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 writing a bundle-based server application.htm

📁 OSGI 开发指南源代码|实例|入门及相关的文档
💻 HTM
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<!-- saved from url=(0066)http://www.eclipse.org/equinox/server/http_writing_application.php -->
<HTML xmlns="http://www.w3.org/1999/xhtml"><HEAD><TITLE>Writing a bundle-based server application</TITLE>
<META content="Equinox Committers" name=author>
<META 
content="equinox, osgi, framework, runtime, incubator, server, servlet, http" 
name=keywords>
<META http-equiv=Content-Type content=text/html;charset=utf-8><LINK 
href="Writing a bundle-based server application_files/reset-fonts-grids.css" 
type=text/css rel=stylesheet><LINK 
href="Writing a bundle-based server application_files/menu.css" type=text/css 
rel=stylesheet><LINK 
href="Writing a bundle-based server application_files/reset.css" type=text/css 
rel=stylesheet><LINK media=screen 
href="Writing a bundle-based server application_files/layout.css" type=text/css 
rel=stylesheet><LINK media=screen 
href="Writing a bundle-based server application_files/header.css" type=text/css 
rel=stylesheet><LINK media=screen 
href="Writing a bundle-based server application_files/footer.css" type=text/css 
rel=stylesheet><LINK media=screen 
href="Writing a bundle-based server application_files/visual.css" type=text/css 
rel=stylesheet><!--[if IE]><LINK media=screen 
href="Writing a bundle-based server application_files/ie_style.css" 
type=text/css rel=stylesheet><![endif]--><!--[if IE 6]><LINK media=screen 
href="Writing a bundle-based server application_files/ie6_style.css" 
type=text/css rel=stylesheet><![endif]--><!-- Dependencies --><!-- Source File --><LINK 
href="Writing a bundle-based server application_files/equinox.css" type=text/css 
rel=stylesheet>
<META content="MSHTML 6.00.3790.1830" name=GENERATOR></HEAD>
<BODY>
<DIV id=novaWrapper>
<DIV id=clearHeader>
<DIV id=logo><IMG alt=Eclipse.org 
src="Writing a bundle-based server application_files/eclipse.png"> </DIV>
<DIV id=otherSites>
<DIV id=sites>
<UL id=sitesUL>
  <LI><A href="http://www.eclipseplugincentral.com/"><IMG 
  alt="Eclipse Plugin Central" 
  src="Writing a bundle-based server application_files/network-wired-bw.png">&nbsp;
  <DIV>Eclipse Plugin Central</DIV></A></LI>
  <LI><A href="http://live.eclipse.org/"><IMG alt="Eclipse Live" 
  src="Writing a bundle-based server application_files/audio-input-microphone-bw.png">&nbsp;
  <DIV>Eclipse Live</DIV></A></LI>
  <LI><A href="https://bugs.eclipse.org/bugs/"><IMG alt=Bugzilla 
  src="Writing a bundle-based server application_files/system-search-bw.png">&nbsp;
  <DIV>Bugzilla</DIV></A></LI>
  <LI><A href="http://www.planeteclipse.org/"><IMG alt="Planet Eclipse" 
  src="Writing a bundle-based server application_files/audio-card.png">&nbsp;
  <DIV>Planet Eclipse</DIV></A></LI>
  <LI><A href="http://wiki.eclipse.org/"><IMG alt="Eclipse Wiki" 
  src="Writing a bundle-based server application_files/accessories-text-editor-bw.png">&nbsp;
  <DIV>Eclipse Wiki</DIV></A></LI>
  <LI><A href="http://portal.eclipse.org/"><IMG alt="MyFoundation Portal" 
  src="Writing a bundle-based server application_files/preferences-system-network-proxy-bw.png">
  <DIV>My Foundation Portal</DIV></A></LI></UL></DIV></DIV></DIV>
<DIV id=header>
<DIV id=menu>
<UL>
  <LI><A href="http://www.eclipse.org/" target=_self>Home</A> </LI>
  <LI><A href="http://www.eclipse.org/users/" target=_self>Users</A> </LI>
  <LI><A href="http://www.eclipse.org/membership/" target=_self>Members</A> 
</LI>
  <LI><A href="http://www.eclipse.org/committers/" target=_self>Committers</A> 
  </LI>
  <LI><A href="http://www.eclipse.org/downloads/" target=_self>Downloads</A> 
  </LI>
  <LI><A href="http://www.eclipse.org/resources/" target=_self>Resources</A> 
  </LI>
  <LI><A href="http://www.eclipse.org/projects/" target=_self>Projects</A> </LI>
  <LI><A href="http://www.eclipse.org/org/" target=_self>About Us</A> 
</LI></UL></DIV>
<DIV id=search>
<FORM id=searchbox_017941334893793413703:sqfrdtd112s 
action=http://www.google.com/cse><INPUT type=hidden 
value=017941334893793413703:sqfrdtd112s name=cx> <INPUT id=searchBox size=25 
name=q> <INPUT id=searchButton type=submit value=Search name=sa> </FORM>
<SCRIPT src="Writing a bundle-based server application_files/brand.htm" 
type=text/javascript></SCRIPT>
</DIV></DIV>
<DIV class=faux id=novaContent><BR style="CLEAR: both; HEIGHT: 1em">
<DIV id=leftcol>
<UL id=leftnav>
  <LI><A href="http://wiki.eclipse.org/Equinox/">Wiki</A> 
  <LI><A href="http://eclipse.org/mail/">Mailing Lists</A> 
  <LI class=separator><A class=separator 
  href="http://www.eclipse.org/equinox/server/index.php">Components<IMG 
  src="Writing a bundle-based server application_files/separator.png"></A> 
  <LI><A href="http://eclipse.org/equinox/">Equinox</A> 
  <LI><A href="http://eclipse.org/eclipse/incubator">Incubator</A> 
  <LI class=separator><A class=separator>Related<IMG 
  src="Writing a bundle-based server application_files/separator.png"></A> 
  <LI><A href="http://eclipse.org/rt/">RT</A> 
  <LI><A href="http://eclipse.org/eclipse/">Eclipse</A> 
  <LI><A href="http://eclipse.org/pde/">PDE</A> 
  <LI><A href="http://eclipse.org/rap/">RAP</A> 
  <LI><A href="http://eclipse.org/ecf/">ECF</A> 
  <LI><A href="http://eclipse.org/eclipse/development/">Development</A> 
</LI></UL></DIV>
<DIV id=midcolumn>
<H1>Writing a bundle-based server application</H1>
<P class=bar>Overview</P>
<P>While Equinox can be setup to run servlets and JSPs in a variety of ways, the 
technique for writing the applications is the same. Use the steps here to create 
your application and then one of the server setups detailed in the <A 
href="http://www.eclipse.org/equinox/server/http_quickstart.php">Server-side 
quick start guide</A> to configure and run your server.</P>
<P class=bar>Writing the server application</P>
<P>The server application takes the form of static content, servlets and JSPs. 
You can use any combination of these. 
<UL>
  <LI><B>Create a new project</B> - Next you need to create a bundle to contain 
  the application. Your application can be made up of many bundles but here we 
  create just one. Create a new bundle project in the Eclipse IDE and call it 
  <CODE>com.example.http.application</CODE>. 
  <LI><B>Add resources to your project</B> - Add all of the static content files 
  you need for your application by creating a folder called 
  <CODE>web_files</CODE> and putting your files there. 
  <LI><B>Place the resources</B> - Now tell the server where your static content 
  lives within the bundle and where it should be placed in URL space. Create an 
  extension by creating a plugin.xml file with following content. <PRE><CODE>
&lt;plugin&gt;
  &lt;extension point="org.eclipse.equinox.http.registry.resources"&gt;
    &lt;resource
      alias="/files"
      base-name="/web_files"/&gt;
  &lt;/extension&gt;
&lt;/plugin&gt;
</CODE></PRE>
  <P>In the extension above, the <CODE>alias</CODE> attribute locates the 
  resources in URL space and the <CODE>base-name</CODE> attribute describes 
  where (in your bundle) the resources are located. So for example the file 
  index.html would live inside the <CODE>com.example.http.application</CODE> 
  bundle in the <CODE>web_files</CODE> folder and would be accessed using the 
  URL <CODE>http://localhost/files/index.html</CODE>. </P>
  <LI><B>Add some servlets</B> - You can also add servlets by implementing 
  classes that extent javax.serlvet.http.HttpServlet. Implement these in the 
  example project as you would any class. 
  <LI><B>Place the servlets</B> - As with the resources, you need to tell the 
  server where the servlets are and where they should show up in URL space. Add 
  the following XML to the plugin.xml file you created earlier. Ensure that this 
  new element is placed within the &lt;plugin&gt; element. Note that you can add 
  any number of &lt;resource&gt; elements in the one extension. <PRE><CODE>
  &lt;extension point="org.eclipse.equinox.http.registry.servlets"&gt;
    &lt;servlet
      alias="/test"
      class="com.example.servlet.MyServlet"/&gt;
  &lt;/extension&gt;
</CODE></PRE>
  <P>In the extension above, the <CODE>alias</CODE> attribute locates the 
  servlet in URL space and the <CODE>class</CODE> attribute identifies the class 
  that implements the servlet. So for example the servlet MyServlet would be 
  accessed using the URL <CODE>http://localhost/test</CODE>. Note that you can 
  add any number of &lt;servlet&gt; elements in the one extension. </P><!--		<li><b>Add some JSPs</b> - TBD</li>		<li><b>Place the JSPs</b> - TBD</li>--></LI></UL>
<P>&nbsp;</P></DIV>
<DIV id=rightcolumn>
<DIV class=sideitem>
<H6>Equinox links</H6>
<UL>
  <LI><A href="http://www.eclipse.org/equinox">home</A> 
  <LI><A href="http://www.eclipse.org/equinox/framework">framework</A> 
  <LI><A href="http://www.eclipse.org/equinox/bundles">bundles</A> 
  <LI><A href="http://www.eclipse.org/equinox/incubator">incubator</A> 
  <LI><A href="http://www.eclipse.org/equinox/server">server</A> 
  <LI><A href="http://www.eclipse.org/equinox/incubator/provisioning">p2</A> 
  <LI><A href="http://www.eclipse.org/equinox/security">security</A> 
  <LI><A href="http://wiki.eclipse.org/Equinox">wiki</A> 
  <LI><A href="http://www.eclipse.org/equinox/documents">documents</A> 
  <LI><A href="http://download.eclipse.org/equinox/">downloads</A> 
  <LI><A href="http://www.eclipse.org/equinox/resources.php">resources</A> 
  <LI><A href="http://wiki.eclipse.org/Equinox/Plan">planning</A> 
  <LI><A href="http://www.eclipse.org/equinox/faq.php">faq</A> 
</LI></UL></DIV></DIV>
<DIV id=rightcolumn>
<DIV class=sideitem>
<H6>Server links</H6>
<UL>
  <LI><A 
  href="http://www.eclipse.org/equinox/server/http_quickstart.php">quickstart</A> 

  <LI><A 
  href="http://www.eclipse.org/equinox/documents/index.php#server">documents</A> 
  </LI></UL></DIV></DIV>
<SCRIPT type=text/javascript>		var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");		document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));		</SCRIPT>

<SCRIPT type=text/javascript>		var pageTracker = _gat._getTracker("UA-910670-2");		pageTracker._initData();		pageTracker._trackPageview();		</SCRIPT>
<BR style="CLEAR: both; HEIGHT: 1em">&nbsp; </DIV>
<DIV id=clearFooter></DIV>
<DIV id=footer>
<UL id=footernav>
  <LI><A href="http://www.eclipse.org/">Home</A> 
  <LI><A href="http://www.eclipse.org/legal/privacy.php">Privacy Policy</A> 
  <LI><A href="http://www.eclipse.org/legal/termsofuse.php">Terms of Use</A> 
  <LI><A href="http://www.eclipse.org/legal/">Legal</A> 
  <LI><A href="http://www.eclipse.org/org/foundation/contact.php">Contact Us</A> 
  </LI></UL><SPAN id=copyright>Copyright © 2009 The Eclipse Foundation. All Rights 
Reserved.</SPAN> </DIV></DIV></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -