Packaging and Deploying a Singleton Service Within an Application Deploying a Singleton Service as a Standalone Service in WebLogic Server Configuring Singleton Service Migration

8-26 Using Clusters for Oracle WebLogic Server – When a newly deployed application is started – During server start – During the activation stage of service migration ■ public void deactivate This method is called during server shutdown and during the deactivation stage of singleton service migration. This method should release any resources obtained through the activate method. Additionally, it should stop any services that should only be available from one member of a cluster.

8.8.3 Deploying a Singleton Service and Configuring the Migration Behavior

Depending on how you used the SingletonService interface to define a singleton service, you must perform the following steps to deploy it: ■ Package and deploy the singleton service within an application. ~ or ~ ■ Deploy the singleton service as a standalone service within WebLogic Server. ■ Optionally, configure the migration behavior of the singleton service. The following sections outline these procedures in detail.

8.8.3.1 Packaging and Deploying a Singleton Service Within an Application

Singleton services that are packaged within an application should have their classes implement the SingletonService interface, and placed within a JAR file, in APP-INFlib or APP-INFclasses, or within an EAR-level lib directory. For standalone singleton services, their classes should be made available in the WebLogic Server system classpath. Also, add the following entry to the weblogic-application.xml descriptor file. weblogic-application ... singleton-service class-namemypackage.MySingletonServiceImplclass-name nameAppscoped_Singleton_Servicename singleton-service ... weblogic-application Deployment of an application-scoped singleton service will happen automatically as part of the application deployment. The candidate servers for the singleton service will be the cluster members where the application is deployed.

8.8.3.2 Deploying a Singleton Service as a Standalone Service in WebLogic Server

After you have created a singleton service class using the SingletonService interface, you must define it as a singleton service within WebLogic Server. This singleton service object contains the following information: ■ The path to the class to load as the singleton service. Note: The class-name and name elements are required. Service Migration 8-27 ■ The preferred server and other candidate servers for the singleton service. The following excerpt from the cluster element of config.xml shows how a singleton service is defined: singleton-service nameSingletonTestServiceNamename user-preferred-servermyManaged1user-preferred-server class-namemycompany.myprogram.subpackage.SingletonTestServiceImplclass-name clustermyClustercluster singleton-service

8.8.3.3 Configuring Singleton Service Migration

A singleton service is automatically configured to be an exactly-once service, which indicates that if at least one Managed Server in the candidate list is running, then the service will be active somewhere in the cluster. You can modify certain singleton service migration parameters using the following methods: ■ WebLogic Server Administration Console—allows you to create and configure singleton services. See Configure a singleton service in Oracle WebLogic Server Administration Console Help. ■ WebLogic Scripting Tool WLST—allows you to configure automatic service migration using the MigratableTarget Management Bean. See WLST Command and Variable Reference in WebLogic Scripting Tool Command Reference. 8-28 Using Clusters for Oracle WebLogic Server 9 Cluster Architectures 9-1 9 Cluster Architectures This following sections describe alternative architectures for a WebLogic Server cluster: ■ Section 9.1, Architectural and Cluster Terminology ■ Section 9.2, Recommended Basic Architecture ■ Section 9.3, Recommended Multi-Tier Architecture ■ Section 9.4, Recommended Proxy Architectures ■ Section 9.5, Security Options for Cluster Architectures

9.1 Architectural and Cluster Terminology

This section defines terms used in this document.

9.1.1 Architecture

In this context the architecture refers to how the tiers of an application are deployed to one or more clusters.

9.1.2 Web Application Tiers

A Web application is divided into several tiers that correspond to the logical services the application provides. Because not all Web applications are alike, your application may not utilize all of the tiers described below. Also keep in mind that the tiers represent logical divisions of an applications services, and not necessarily physical divisions between hardware or software components. In some cases, a single machine running a single WebLogic Server instance can provide all of the tiers described below. ■ Web Tier The Web tier provides static content for example, simple HTML pages to clients of a Web application. The Web tier is generally the first point of contact between external clients and the Web application. A simple Web application may have a Web tier that consists of one or more machines running Apache, Netscape Enterprise Server, or Microsoft Internet Information Server. ■ Presentation Tier The presentation tier provides dynamic content for example, servlets or Java Server Pages to clients of a Web application. A cluster of WebLogic Server instances that hosts servlets andor JSPs comprises the presentation tier of a Web application. If the cluster also serves static HTML pages for your application, it encompasses both the Web tier and the presentation tier.