ch09.html
来自「java2高级编程」· HTML 代码 · 共 985 行 · 第 1/3 页
HTML
985 行
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"><HTML><HEAD><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1"><META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css"><META NAME="GENERATOR" CONTENT="Adobe FrameMaker 6.0/HTML Export Filter"><LINK REL="STYLESHEET" HREF="CH09.css" CHARSET="ISO-8859-1" TYPE="text/css"><TITLE> Covered in this Chapter</TITLE></HEAD><BODY BGCOLOR="#ffffff"><P CLASS="CT"><A NAME="pgfId-1087399"></A>9</P><P CLASS="CT"><A NAME="pgfId-1087401"></A><A NAME="79290"></A>Deploying the Auction Application</P><P CLASS="Body"><A NAME="pgfId-1087402"></A>With the auction application tested, debugged, and tuned, you are ready to deploy it. In this chapter, <EM CLASS="CODE">Administration</EM> applet replaces the <EM CLASS="CODE">AuctionClient</EM> application so you can see how to deploy an applet; this process is a little more involved than deploying an application.</P><P CLASS="Body"><A NAME="pgfId-1087403"></A>To deploy the complete application, you bundle the application files, move the application files to their production locations, install Java Plug-In so auction administrators can run the <EM CLASS="CODE">Administration</EM> applet from their browsers, and install the <EM CLASS="CODE">Administration</EM> applet policy file. Java Plug-In is needed because the <EM CLASS="CODE">Administration</EM> applet is written with JDK 1.2 APIs, but the administrators' browsers will likely run an earlier version of the Java Runtime Environment™ (JRE) software. </P><P CLASS="Body"><A NAME="pgfId-1087404"></A>This chapter explains how to use the JAR file format to bundle and deploy the application files, and how to install Java Plug-In and a security policy file for the Solaris and Win32 platforms to run the <EM CLASS="CODE">Administration</EM> applet.</P><DIV><H4 CLASS="A"><A NAME="pgfId-1087405"></A>Covered in this Chapter</H4><UL><LI CLASS="BL"><A NAME="pgfId-1087406"></A>JAR File Format (page 290)</LI><LI CLASS="BL"><A NAME="pgfId-1087407"></A>Deploy to Solaris Operating System (page 295) </LI><LI CLASS="BL"><A NAME="pgfId-1087408"></A>Deploy to Win32 Platform (page 300)</LI></UL></DIV><DIV><H4 CLASS="A"><A NAME="pgfId-1087410"></A><A NAME="83178"></A>JAR File Format</H4><P CLASS="Body"><A NAME="pgfId-1087412"></A><A NAME="marker-1087411"></A>Java Archive file format is a compression and file packaging format and tool for bundling executable files with other related application files so they can be deployed as a single unit. The auction application has the following three sets of files to deploy to three different locations:</P><OL><LI CLASS="NLS"><A NAME="pgfId-1087413"></A>The HTML files that make up the auction application user interface deploy to a publicly accessible location under the Web server.</LI><LI CLASS="NL"><A NAME="pgfId-1087414"></A>The enterprise beans deploy to an internal location accessible to your production installation of the Enterprise JavaBeans server. </LI><LI CLASS="NL"><A NAME="pgfId-1087415"></A>The <EM CLASS="CODE">Administration</EM> applet deploys to an internal location accessible to <EM CLASS="CODE">auction</EM> administrators where it is run from their browsers.</LI></OL><DIV><H5 CLASS="B"><A NAME="pgfId-1087416"></A>Bundle and Deploy the HTML Files</H5><P CLASS="Body"><A NAME="pgfId-1087417"></A>Here is the list of HTML files that make up the auction application user interface: </P><UL><LI CLASS="BL"><A NAME="pgfId-1087418"></A><EM CLASS="CODE">all.html</EM></LI><LI CLASS="BL"><A NAME="pgfId-1087419"></A><EM CLASS="CODE">close.html </EM></LI><LI CLASS="BL"><A NAME="pgfId-1087420"></A><EM CLASS="CODE">details.html</EM></LI><LI CLASS="BL"><A NAME="pgfId-1087421"></A><EM CLASS="CODE">index.html </EM></LI><LI CLASS="BL"><A NAME="pgfId-1087422"></A><EM CLASS="CODE">juggler.med.gif</EM></LI><LI CLASS="BL"><A NAME="pgfId-1087423"></A><EM CLASS="CODE">new.html </EM></LI><LI CLASS="BL"><A NAME="pgfId-1087424"></A><EM CLASS="CODE">registration.html</EM></LI><LI CLASS="BL"><A NAME="pgfId-1087425"></A><EM CLASS="CODE">search.html </EM></LI><LI CLASS="BL"><A NAME="pgfId-1087426"></A><EM CLASS="CODE">sell.html</EM></LI></UL><P CLASS="Body"><A NAME="pgfId-1087430"></A><A NAME="marker-1087427"></A><A NAME="marker-1087428"></A><A NAME="marker-1087429"></A>And here is the <EM CLASS="CODE">jar</EM> command to bundle them. Everything goes on one line. This command is executed in the same directory with the files. If you execute the command from a directory other than where the files are found, specify the full or relative pathname as appropriate. </P><PRE CLASS="CODE"><A NAME="pgfId-1087431"></A>jar cvf HTML.jar all.html close.html details.html index.html juggler.med.gif new.html registration.html search.html sell.html</PRE><P CLASS="Body"><A NAME="pgfId-1087432"></A><EM CLASS="CODE">jar</EM> is the Java Archive command. If you type <EM CLASS="CODE">jar</EM> with no options, you get the following <EM CLASS="CODE">help</EM> screen. You can see from the <EM CLASS="CODE">help</EM> screen that the <EM CLASS="CODE">cf</EM> options to the <EM CLASS="CODE">jar</EM> command mean create a new JAR file named <EM CLASS="CODE">HTML.jar</EM> and put the list of files that follows into it. The new JAR file is placed in the current directory. </P><PRE CLASS="CODE"><A NAME="pgfId-1087433"></A>kq6py% jar </PRE><PRE CLASS="CODE"><A NAME="pgfId-1087434"></A>Usage: jar {ctxu}[vfm0M][jar-file][manifest-file][-C dir] files ... </PRE><PRE CLASS="CODE"><A NAME="pgfId-1087435"></A>Options: </PRE><PRE CLASS="CODE"><A NAME="pgfId-1087436"></A> -c create new archive </PRE><PRE CLASS="CODE"><A NAME="pgfId-1087437"></A> -t list table of contents for archive </PRE><PRE CLASS="CODE"><A NAME="pgfId-1087438"></A> -x extract named (or all) files from archive </PRE><PRE CLASS="CODE"><A NAME="pgfId-1087439"></A> -u update existing archive </PRE><PRE CLASS="CODE"><A NAME="pgfId-1087440"></A> -v generate verbose output on standard output </PRE><PRE CLASS="CODE"><A NAME="pgfId-1087441"></A> -f specify archive file name </PRE><PRE CLASS="CODE"><A NAME="pgfId-1087442"></A> -m include manifest information from specified manifest file </PRE><PRE CLASS="CODE"><A NAME="pgfId-1087443"></A> -0 store only; use no ZIP compression </PRE><PRE CLASS="CODE"><A NAME="pgfId-1087444"></A> -M Do not create a manifest file for the entries </PRE><PRE CLASS="CODE"><A NAME="pgfId-1087445"></A> -C change to the specified directory and include the following file </PRE><PRE CLASS="CODE"><A NAME="pgfId-1087446"></A>If any file is a directory then it is processed recursively. The manifest file name and the archive file name needs to be specified in the same order the 'm' and 'f' flags are specified. </PRE><PRE CLASS="CODE"><A NAME="pgfId-1087447"></A> </PRE><PRE CLASS="CODE"><A NAME="pgfId-1087448"></A>Example 1: to archive two class files into an archive called classes.jar: jar cvf classes.jar Foo.class Bar.class </PRE><PRE CLASS="CODE"><A NAME="pgfId-1087449"></A>Example 2: use an existing manifest file 'mymanifest' and archive all the files in the foo/ director into 'classes.jar': jar cvfm classes.jar mymanifest -C foo/ .</PRE><P CLASS="Body"><A NAME="pgfId-1087452"></A><A NAME="marker-1087450"></A><A NAME="marker-1087451"></A>To deploy the HTML files, all you have to do is move the <EM CLASS="CODE">HTML.jar</EM> file to a publicly accessible directory under the Web server and decompress the JAR file: </P><PRE CLASS="CODE"><A NAME="pgfId-1087453"></A>jar xvf HTML.jar</PRE><UL><P CLASS="NOTE"><A NAME="pgfId-1087454"></A>NOTE If you included a full or relative pathname when you added the files to the JAR file, the files are placed in the same directory structure when they are unpacked. </P></UL><P CLASS="Body"><A NAME="pgfId-1087455"></A>The JAR file contains a manifest file, <EM CLASS="CODE">META-INF/MANIFEST.MF</EM> that the <EM CLASS="CODE">jar</EM> tool automatically placed there. A manifest file contains information about the files packaged in the JAR file. You can tailor this information to enable JAR file functionality such as electronic signing, version control, package sealing, and more. </P></DIV><DIV><H5 CLASS="B"><A NAME="pgfId-1087456"></A>Bundle and Deploy the Enterprise Beans</H5><P CLASS="Body"><A NAME="pgfId-1087457"></A>Some Enterprise JavaBeans servers create the JAR file for you. However, if yours does not or if you just wonder how it's done, this section describes the steps. </P><P CLASS="Body"><A NAME="pgfId-1087458"></A>These are the server-side files you need to deploy the enterprise beans. This list is taken from the original auction application described in Chapter 2, Auction House Application, before any modifications were made. Note the inclusion of the deployment descriptor, and the container-generated stub and skel classes. </P><UL><P CLASS="NOTE"><A NAME="pgfId-1087459"></A>NOTE Because there are so many files, these steps bundle the example code into four JAR files, one each for the <EM CLASS="CODE">auction</EM>, <EM CLASS="CODE">registration</EM>, <EM CLASS="CODE">bidder</EM>, and <EM CLASS="CODE">seller</EM> packages. You could also bundle all the packages into one JAR file and deploy that instead.</P></UL><P CLASS="Body"><A NAME="pgfId-1087460"></A><EM CLASS="C-Code">auction</EM><EM CLASS="Bold"> Package. </EM>These are the application files in the auction package that make up the <EM CLASS="CODE">AuctionServlet</EM> servlet and <EM CLASS="CODE">AuctionItemBean</EM> enterprise bean. Because they are all to be installed in an auction directory accessible to the production Enterprise JavaBeans server, bundle them together so they can be unpacked in one step in the destination directory and placed in the auction subdirectory.</P><UL><LI CLASS="BL"><A NAME="pgfId-1087461"></A><EM CLASS="CODE">auction.AuctionServlet.class</EM></LI><LI CLASS="BL"><A NAME="pgfId-1087462"></A><EM CLASS="CODE">auction.AuctionItem.class </EM></LI><LI CLASS="BL"><A NAME="pgfId-1087463"></A><EM CLASS="CODE">auction.AuctionItemBean.class</EM></LI><LI CLASS="BL"><A NAME="pgfId-1087464"></A><EM CLASS="CODE">auction.AuctionItemHome.class </EM></LI><LI CLASS="BL"><A NAME="pgfId-1087465"></A><EM CLASS="CODE">auction.AuctionItemPK.class</EM></LI><LI CLASS="BL"><A NAME="pgfId-1087466"></A><EM CLASS="CODE">auction.DeploymentDescriptor.txt </EM></LI><LI CLASS="BL"><A NAME="pgfId-1087467"></A><EM CLASS="CODE">AuctionItemBeanHomeImpl_ServiceStub.class</EM></LI><LI CLASS="BL"><A NAME="pgfId-1087468"></A><EM CLASS="CODE">WLStub1h1153e3h2r4x3t5w6e82e6jd412c.class </EM></LI><LI CLASS="BL"><A NAME="pgfId-1087469"></A><EM CLASS="CODE">WLStub364c363d622h2j1j422a4oo2gm5o.class</EM></LI><LI CLASS="BL"><A NAME="pgfId-1087470"></A><EM CLASS="CODE">WLSkel1h1153e3h2r4x3t5w6e82e6jd412c.class </EM></LI><LI CLASS="BL"><A NAME="pgfId-1087471"></A><EM CLASS="CODE">WLSkel364c363d622h2j1j422a4oo2gm5o.class</EM></LI></UL><P CLASS="Body"><A NAME="pgfId-1087472"></A>Here is how to bundle them. Everything goes on one line, and the command is executed one directory above the place where the class files are located. </P><DIV><H6 CLASS="D"><A NAME="pgfId-1087473"></A><EM CLASS="Bold">Unix:</EM></H6><PRE CLASS="CODE"><A NAME="pgfId-1087474"></A>jar cvf auction.jar auction/*.class auction/*.txt</PRE></DIV><DIV><H6 CLASS="D"><A NAME="pgfId-1087475"></A><EM CLASS="Bold">Win32:</EM></H6><PRE CLASS="CODE"><A NAME="pgfId-1087476"></A>jar cvf auction.jar auction\*.class auction\*.txt</PRE><P CLASS="Body"><A NAME="pgfId-1087477"></A>Once the JAR file is copied to the destination directory for the enterprise beans, unpack it as follows. The extraction creates an <EM CLASS="CODE">auction</EM> directory with the class files in it. </P><PRE CLASS="CODE"><A NAME="pgfId-1087478"></A>jar xvf auction.jar</PRE><P CLASS="Body"><A NAME="pgfId-1087479"></A><EM CLASS="C-Code">Registration</EM><EM CLASS="Bold"> Package. </EM>Here are the application files in the registration package that make up the <EM CLASS="CODE">Registration</EM> enterprise bean. </P><UL><LI CLASS="BL"><A NAME="pgfId-1087480"></A><EM CLASS="CODE">registration.Registration.class</EM></LI><LI CLASS="BL"><A NAME="pgfId-1087481"></A><EM CLASS="CODE">registration.RegistrationBean.class </EM></LI><LI CLASS="BL"><A NAME="pgfId-1087482"></A><EM CLASS="CODE">registration.RegistrationHome.class</EM></LI><LI CLASS="BL"><A NAME="pgfId-1087483"></A><EM CLASS="CODE">registration.RegistrationPK.class </EM></LI><LI CLASS="BL"><A NAME="pgfId-1087484"></A><EM CLASS="CODE">registration.DeploymentDescriptor.txt</EM></LI><LI CLASS="BL"><A NAME="pgfId-1087485"></A><EM CLASS="CODE">RegistrationBeanHomeImpl_ServiceStub.class </EM></LI><LI CLASS="BL"><A NAME="pgfId-1087486"></A><EM CLASS="CODE">WLStub183w4u1f4e70p6j1r4k6z1x3f6yc21.class</EM></LI><LI CLASS="BL"><A NAME="pgfId-1087487"></A><EM CLASS="CODE">WLStub4z67s6n4k3sx131y4fi6w4x616p28.class </EM></LI><LI CLASS="BL"><A NAME="pgfId-1087488"></A><EM CLASS="CODE">WLSkel183w4u1f4e70p6j1r4k6z1x3f6yc21.class</EM></LI><LI CLASS="BL"><A NAME="pgfId-1087489"></A><EM CLASS="CODE">WLSkel4z67s6n4k3sx131y4fi6w4x616p28.class</EM></LI></UL><P CLASS="Body"><A NAME="pgfId-1087490"></A>Here is how to bundle them. Everything goes on one line, and the command is executed one directory above the place where the class files are located. </P></DIV><DIV><H6 CLASS="D"><A NAME="pgfId-1087491"></A><EM CLASS="Bold">Unix:</EM></H6><PRE CLASS="CODE"><A NAME="pgfId-1087492"></A>jar cvf registration.jar registration/*.class registration/*.txt</PRE></DIV><DIV><H6 CLASS="D"><A NAME="pgfId-1087493"></A><EM CLASS="Bold">Win32:</EM></H6><PRE CLASS="CODE"><A NAME="pgfId-1087494"></A>jar cvf registration.jar registration\*.class registration\*.txt</PRE><P CLASS="Body"><A NAME="pgfId-1087495"></A>Once the JAR file is copied to the destination directory for the enterprise beans, unpack it as follows. The extraction creates a <EM CLASS="CODE">registration</EM> directory with the class files in it. </P><PRE CLASS="CODE"><A NAME="pgfId-1087496"></A>jar xvf registration.jar</PRE><P CLASS="Body"><A NAME="pgfId-1087497"></A><EM CLASS="C-Code">bidder</EM><EM CLASS="Bold"> Package. </EM>Here are the application files in the bidder package that make up the <EM CLASS="CODE">
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?