• No se han encontrado resultados

ANÁLISIS DE DATOS, DISCUSIÓN Y EVALUACIÓN

The Sun Java System Application Server integrates nicely with the NetBeans IDE, via both well-published interfaces (JSR 88) for configuration and deployment and NetBeans IDE

extensions called the J2EE Server Integration APIs (see http://j2eeserver.netbeans.org). Although the most complete runtime management tool for the application server is the Admin Console (a management tool in the form of a web page shown in Figure 10-25), some developer-oriented management features have been exposed from the IDE’s Runtime window under the Servers node. From there, for each registered server instance, you can view the server log file (for local servers), launch the Admin Console tool, explore the list of deployed J2EE applications or J2EE resources (and undeploy them), and more.

NetBeans IDE Tip

If you want to explore the entire content of an application server domain or to see the configuration files, the log files, or the repository of the deployed applications, you can add this domain directory in the IDE’s Favorites window.

By default, the Favorites window is not visible within the IDE, but you can display it in the explorer area of the IDE by choosing Windows |

Favorites. Then you can right-click the Favorites root node, choose Add to Favorites, and navigate to the application server’s domain directory. Once you have added this directory in the Favorites window, you can view those files in the IDE’s Source Editor and take advantage of other IDE features, such as the Validate XML command, which is useful for validating things such as the config/domain.xml file.

Server Log

The Sun Java System Application Server instance container process uses a log file to track system and user messages ranging from severe errors to informational messages describing the current state of the server. The server log file is an important source of information that a J2EE developer needs to use actively during development or deployment and execution of J2EE applications. There is one server log file per instance, usually located under the domain directory in the logs/server.log file. The NetBeans IDE can display the content of the most recent

lines of the server log via the server instance node popup menu called View Server Log. This menu is active only for local server instances, because the IDE needs access to the file. Server Management

For a registered application server instance, whether the server is local (on the same machine that the IDE is running on) or remote, the IDE offers extensive administration capabilities via the Runtime window tree view (shown in Figure 10-29).

Runtime window with the node for a Sun Java System Application Server instance selected Once the server is running, you can get read/write access to most of the developer-oriented administration parameters, such as:

[lb] The list of J2EE deployed applications, from where you can introspect their properties and undeploy them

[lb] The list of registered resources and their properties (JDBC resources, connection pools, Persistence Manager resources, JMS resources, JavaMail resources, JDNI names, and Connector and JVM settings)

Each of these management artifacts is represented as a node. The corresponding commands (Delete, Undeploy, Refresh, and so on) are available as popup menu items(when you right-click the node), and corresponding properties are available via the Properties popup menu item. For other management artifacts, you can always access them by opening the application server’s Admin Console (right-click the server’s node in the Runtime window and choose View Admin Console). This command opens a web browser that then displays the URL for the administration console.

JVM Options

The JVM parameters of a server instance are among the most important server administration parameters from a developer standpoint. You can access these parameters by right-clicking the server’s JVMs node in the Runtime window and choosing Properties. The Properties dialog box for the JVMs node is shown in Figure 10-30.

Property sheet for the JVMs node for an application server in the Runtime window

Use the server-classpath entry (shown as ServerProperty in the property sheet) when you want to add shared libraries or JAR files that would be used by all the J2EE

applications deployed to this server instance, as well as the necessary JDBC driver JAR files to access databases. Use the jvm-options parameter (shown as JVMOptions in the property sheet) to define Java options like HTTP proxies or options that would be relevant to the deployed J2EE applications. You can modify the java-home entry (shown as JavaHome in the property sheet) to change the location of the JDK used by the server instance.

Most of these settings require a server instance restart to take effect. The NetBeans IDE can figure out when a local instance has to restart, and at the next J2EE project deployment,

execution, or debugging session, the server is restarted automatically. For remote servers, you have to log into the remote machine to perform a server restart, as there is no command (CLI or Admin Console based) to restart a remote server in Sun Java System Application Server 8.1. JDBC Drivers

Using the Sun Resources template category in the New File wizard (shown in Figure 10-31), you can define J2EE resources such as:

[lb] JDBC connection pools [lb] JDBC resources [lb] JMS resources [lb] JavaMail resources [lb] Persistence resources Figure 10-31

New File wizard with the JDBC Connection Pool template selected

The wizard for the JDBC Connection Pool template (shown in Figure 10-32) is of particular help in improving your productivity. It enables you to create resources, either from live database connections registered within the NetBeans IDE or from a predefined list of well-known JDBC drivers— including all the Sun DataDirect drivers for DB2, Oracle, Microsoft SQL Server, and Sybase, as well as drivers for the Pointbase and Apache Derby databases. Note that in the Sun Java System Application Server 8.1 Platform Edition, only the Pointbase driver is provided. The Sun Datadirect drivers are included with the Standard Edition and Enterprise Edition of Sun Java System Application Server 8.1.

Choose Database Connection page for the JDBC Connection Pool template in the New File wizard

These server-specific resources are created under the setup directory, shown in the Projects window under the Server Resources node of the project. These server resources are then either automatically deployed to the server whenever the project is executed or manually registered, using the Register menu item, as shown in Figure 10-33.

Figure 10-33

Registering a database connection in a project

Double-clicking a server resource node opens the property sheet for this resource,, where you can modify all the necessary properties before doing a registration.

Figure 10-34

Server Properties

The server’s Properties dialog box (shown in Figure 10-35), accessible via the Properties menu item of a server node, allows the editing of the admin username or password, as well as the setting for enabling the IDE’s HTTP Monitor. This HTTP Monitor can work only for local application servers.

Figure 10-35

Properties dialog box for the Sun Java System Application Server Using JavaServer Faces Technology in a Web Application

Sun Java System Application Server 8.1 bundles all the latest JavaServer Faces (JSF) APIs and the JSF implementation out of the box, and these libraries are recognized by the NetBeans IDE. The JSF config DTDs are also registered in the IDE, meaning that XML code completion and validation are available in the IDE for the JSFconfig 1.0 and 1.1 XML files.

The JSF libraries are automatically in the web application project classpath when the project targets the Sun Application Server, so that all the classes are available to import and to use from your web application.

Furthermore, the Java BluePrints Solution Catalog is accessible directly through the IDE’s Help | BluePrints Solutions Catalog menu item and contains some web tier solutions that incorporate JSF technology, which are installable as IDE projects with one click. Install a solution, run the project, study it, debug it, modify it, and use it as a starting point for your JSF project. See Chapter 7 for more details.

Working with Ant

The NetBeans IDE’s Ant-based project system (introduced in Version 4.0 and extended in Version 4.1) is perhaps the biggest thing that sets NetBeans apart from other IDEs. All projects created within the NetBeans IDE rely on the Ant tool for building. This is also true for the J2EE project types like web applications, EJB modules, and J2EE applications. Therefore, these projects can be built either from the IDE or from outside the IDE using Ant 1.6.2.

The IDE-generated build script also includes targets for executing, debugging, and deploying the application. In NetBeans IDE 4.1, it is not possible to use these targets outside the IDE, because they would require an operational runtime environment. This limitation should go away in NetBeans IDE 4.2.

Another NetBeans IDE advantage is that all of the Sun Application Server 8.1 Ant optional tasks are registered in the IDE. These tasks include

[lb] sun-appserv-deploy [lb] sun-appserv-undeploy [lb] sun-appserv-instance [lb] sun-appserv-component [lb] sun-appserv-admin [lb] sun-appserv-input [lb] sun-appserv-update

So if you have existing Ant scripts that are using these Ant task extensions, you can run these

build.xml files directly from the IDE itself as though you were invoking the Sun Application

Server tool asant (which itself is a wrapper around Ant to declare these extensions).

For example, if you download all the J2EE samples for the Sun Application Server, all the samples can be built from the IDE using the sample build.xml files provided with the sample. You could make the samples visible in the IDE by choosing Window | Favorites, right-clicking the Favorites node, choosing Add to Favorites, and navigating to the directory to display. Once the samples are visible in the Favorites window, you can navigate to a sample’s build.xml file,

right-click it, and choose an Ant target to run.

For more information regarding these tasks, refer to the application server documentation at http://docs.sun.com.

Documento similar