ECLIPSE WEB TOOLS PLATFORM developing java web applications PHẦN 9 ppsx

75 361 0
ECLIPSE WEB TOOLS PLATFORM developing java web applications PHẦN 9 ppsx

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

574 CHAPTER 12 • Adding New Servers Figure 12.10 New Launch Configuration 4. You should see your GlassFish server adapter listed now. Select GlassFish and click the Next button. The GlassFish Runtime wizard opens (see Figure 12.12). Note how the wizard UI gets populated with form fields for the runtime properties you defined in the server definition file. 5. Specify the location of the GlassFish installation directory. Enter the loca- tion or select it using the Browse button. Note that a directory browse but- ton has been provided because the type of the property was directory. Click the Finish button. The Installed Runtimes preference page now lists GlassFish (see Figure 12.13). 6. You have now added the GlassFish server runtime environment and are ready to use it for a new Web project. In the Project Explorer view, right click and select New ᭤ Dynamic Web Project. The New Dynamic Web Project wizard opens (see Figure 12.14). Figure 12.11 New Server Runtime Figure 12.12 GlassFish Runtime 575 576 CHAPTER 12 • Adding New Servers Figure 12.13 Installed Runtimes—GlassFish Figure 12.14 New Dynamic Web Project Testing the Server Adapter 577 7. Enter TestWebProject as the project name and select GlassFish as the target runtime. Click the Next button. The Select Project Facets page is displayed (see Figure 12.15). Figure 12.15 Select Project Facets 8. Notice how the set of supported facets matches the allowed values that were defined in plugin.xml. Accept the defaults for other properties. Click Finish. WTP creates the project. Notice that a GlassFish library gets added to the proj- ect as defined by the runtime classpath provider extension (see Figure 12.16). 9. Create a simple JSP named index.jsp in the WebContent folder. Add some simple content to it. This completes the project setup. 10. You are now ready to run the JSP on GlassFish. In the Project Explorer, select index.jsp, right click, and invoke the Run As ᭤ Run on Server menu item. The Run On Server wizard opens (see Figure 12.17). 11. Create a new server configuration for the GlassFish runtime. Click Next to continue. You will see the server properties displayed (see Figure 12.18). These properties were also defined in the server definitions file. Enter the proper values. 12. Click Next to continue. The Add and Remove Projects page is displayed (see Figure 12.19). 578 CHAPTER 12 • Adding New Servers Figure 12.16 Dynamic Web Project—TestWebProject Figure 12.17 Define a New Server Testing the Server Adapter 579 Figure 12.18 GlassFish Server Figure 12.19 Add and Remove Projects 580 CHAPTER 12 • Adding New Servers Figure 12.20 Run On Server—index.jsp 13. A server configuration includes the list of dynamic Web projects. TestWebProject was automatically added for you, so simply click the Finish button. The wizard creates the server, starts it, publishes the TestWebProject project to it using the Ant scripts, and launches the Web browser using the URL for the JSP (see Figure 12.20). As the server starts and publishes, messages are displayed in the Console view. Summary In this chapter you learned about the server tools and how to extend WTP with a new generic server adapter. You developed and tested a generic server adapter for GlassFish. Summary 581 There is more to server tools than what was covered here. Generic server support is suitable for most purposes. However, you should also have a look at the custom adapters, such as the Tomcat plug-ins, to see how you can have full control over the server tools capability. If you would like to learn how to publish your server plug-ins as installable features, and provide links to your update sites, you should look at the Apache Geronimo plug-in. This page intentionally left blank CHAPTER 13 Supporting New File Types The limits of my language mean the limits of my world. 583 —Ludwig Wittgenstein At its core, an integrated development environment (IDE) assists a developer in working with various development artifacts. While some of the artifacts, such as server instances, may be intangible, most artifacts map to one or more files whose syntax is defined by programming languages. The IDE’s job is to simplify the task of working with these languages. There are a number of tools an IDE can provide to simplify development of language-specific files. A new file wizard handles tasks such as naming and place- ment of the file and can create a skeleton structure of the new file. A rich editor simplifies manual editing of the file with content assistance and syntax highlight- ing. Rich editors may also include a design or graphical view that provides an alternate visualization of the file. A validator, which will typically be integrated with the editor, checks the file to ensure it is compliant with the language specifica- tion. If a file requires compilation or some other form of transformation before it can be deployed, a facility for building the file should also be included. DocBook is an XML language for authoring documents such as books, articles, and reference pages (see Example 13.1). It can be obtained from the DocBook Web site: http://www.docbook.org Example 13.1 Listing of article.docbook <?xml version="1.0" encoding="UTF-8"?> <article> <title>Supporting New File Types</title> <para> At its core, an integrated development environment (IDE) assists a developer in working with various development artifacts. While some [...]... DocbookValidator .java (see Example 13.3) Example 13.3 Listing of DocbookValidator .java package org.eclipsewtp.docbook; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import import import import import import import import import import import import import org .eclipse. core.resources.IFile; org .eclipse. core.runtime.IStatus; org .eclipse. core.runtime.Status; org .eclipse. core.runtime.jobs.ISchedulingRule;... DocBook to Eclipse, it is a good idea to define the language to Eclipse Defining the language allows Eclipse to handle the tools and operations that surround the language in a coordinated and unified fashion For example, by defining the DocBook language with Eclipse it will allow editors, builders, and other tools to be defined specifically for the language The most effective way to inform Eclipse that... are more than just a few languages available in the Web space, including ASP, CSS, 586 CHAPTER 13 • Supporting New File Types HTML, Java, JavaScript, Perl, PHP, Ruby, WSDL, XML, XSD, and XSL While all of these languages are not required for every Web project, it is typical to use several of them DocBook, which can be used to document Web and other applications, is just one more language in the mix With... name="DocBook Validator" point="org .eclipse. wst.validation.validator"> ... framework The WTP Validation Framework Before creating a DocBook validator for Eclipse, you need to identify how the validator will interact with the Eclipse workbench In other words, what will the DocBook validator do in Eclipse? Following the example set by the Java compiler (the JDT is typically thought to represent the best of Eclipse) , the DocBook validator should contribute error and warning markers... org .eclipse. core.runtime.Status; org .eclipse. core.runtime.jobs.ISchedulingRule; org .eclipse. wst.validation.internal.core.ValidationException; org .eclipse. wst.validation.internal.operations.LocalizedMessage; org .eclipse. wst.validation.internal.provisional.core.IReporter; org .eclipse. wst.validation core.IValidationContext; org .eclipse. wst.validation core.IValidatorJob; org.w3c.dom.Document; org.w3c.dom.Element;... New Java Class wizard by selecting File ᭤ New ᭤ Class Enter the class name DocbookValidator and the package org.eclipsewtp.docbook Add the following interface to the list of interfaces (see Figure 13.2): org .eclipse. wst.validation.internal.provisional.core.IValidatorJob Figure 13.2 Creating the DocBook Validator Class The DocBook Validator 5 89 Click Finish The DocbookValidator class opens in the Java. .. advantage of all the tools and operations defined for the XML content type, such as the XML editor In this section you will define the DocBook content type to Eclipse by doing the following: 1 In the manifest editor, change to the Extensions tab and click Add Add an extension of type org .eclipse. core.runtime.contentTypes The platform defines this extension point to specify content types to Eclipse 2 Right... the dependencies tab, and add a dependency on org .eclipse. wst.validation The validation API depends on the core runtime plug-in for the scheduling of validation jobs and reporting validation status Specify a second dependency on the plug-in org .eclipse. core.runtime The DocBook validator will make use of Eclipse file resources in order to validate them In Eclipse, resources are represented by the IResource... the WTP tools that allow you to develop WSDL documents The tools define extension points and API that allow you to seamlessly integrate functionality for WSDL extensions into them The tools can also be extended to allow for custom validation This is useful when defining custom rules for WSDL documents such as those defined by your own organization or industry standard organizations like the Web Services . reside. Edit DocbookValidator .java (see Example 13.3). Example 13.3 Listing of DocbookValidator .java package org.eclipsewtp.docbook; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import. javax.xml.parsers.DocumentBuilderFactory; import org .eclipse. core.resources.IFile; import org .eclipse. core.runtime.IStatus; import org .eclipse. core.runtime.Status; import org .eclipse. core.runtime.jobs.ISchedulingRule; import org .eclipse. wst.validation.internal.core.ValidationException; import. for Eclipse, you need to identify how the val- idator will interact with the Eclipse workbench. In other words, what will the DocBook validator do in Eclipse? Following the example set by the Java

Ngày đăng: 07/08/2014, 00:22

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan