# Application View Control Interface

This topic defines the base interface for all Application View controls.

    package com.bea.wlai.control;

    import com.bea.control.XMLControl;

    /**
     * ApplicationView Control base interface
     */
    public interface ApplicationViewControl
        extends XMLControl
    {
        // -------------------------
        // Local transaction methods
        // -------------------------

        public void beginLocalTransaction()
            throws Exception;

        public void commitLocalTransaction()
            throws Exception;

        public void rollbackLocalTransaction()
            throws Exception;

        // -------------------------
        // Async methods
        // -------------------------

        public boolean isAsyncRequestActive();

        public String getActiveAsyncRequestID();

        public interface Callback

    }

The methods of this interface may be invoked by any web service or business process with an Application View control instance.

The local transaction methods are not used in a container that controls transactions, such as the process container for WebLogic Integration or the web service container for WebLogic Workshop. This is because the WebLogic Server Transaction Manager (TM) automatically enlists any local resource (a maximum of one) into the active XA transaction. Thus, using application views and adapters that support only local transactions appears the same as using application views and adapters that support XA transactions.

You can have only one local-only resource in the transaction. The business process designer must ensure that only one local resource gets enlisted anywhere within a given set of explicit transaction tags (or the implicit outer transaction tags if none are given explicitly). If a second local-only resource is required, you must separate the first and second resources across transaction tags in the process definition language.

For containers that do not control the outer XA transaction (for example, a WebLogic Portal page group), you can use the local transaction methods. However, you can also start an XA transaction using the javax.transaction.UserTransaction interface, and allow the WebLogic Server Transaction Manager to automatically enlist the local resource.

public void beginLocalTransaction() throws Exception

Begin a local transaction on this control. This will begin a local transaction on the underlying ApplicationView instance. All work done by this control instance between this call and a call to commitLocalTransaction() or rollbackLocalTransaction() will be committed or rolled back, respectively, as a unit.

If the underlying adapter used by the application view for this control does not support local transactions, an exception is thrown.

public void commitLocalTransaction() throws Exception

Commit the active local transaction for this control. All work done since the last call to beginLocalTransaction() will be committed into the EIS's permanent state.

If the underlying adapter used by the application view for this control does not support local transactions, an exception is thrown.

public void rollbackLocalTransaction() throws Exception

Rollback the active local transaction for this control. All work done since the last call to beginLocalTransaction() will be discarded.

If the underlying adapter used by the application view for this control does not support local transactions, an exception is thrown.

public boolean isAsyncRequestActive()

Tests to determine whether the control instance is currently processing an async request.

public String getActiveAsyncRequestID()

Return the ID of the active asynchronous request being processed by this control instance, or null if no async request is active.

public interface Callback

The callback interface defines the generic events that can be delivered to any web service or business process hosting this control interface.

Note: Any asynchronous service for the JCX is represented as a callback on the JCX. This allows the extension of the base control for callbacks. Asynchronous response callbacks use the XML type to represent the response document.

### Sample Sub-Classed Application View Control

The following code shows an example of a sub-classed control. This code is automatically created by the control wizard.

    package FunctionDemo;

    import weblogic.jws.*;
    import com.bea.wlai.control.ApplicationViewControl;
    import com.bea.xml.XmlObject;
    /**
     * This ApplicationView provides some simple services to
     * create/get/update customers in the sample CUSTOMER_TABLE table.
     * It also defines an event
     * indicating a customer record has been updated.
     * @jc:av-identity name="FunctionDemo.CustomerMgmt"
     * app="sampleApp"
     */
    public interface CustomerMgmtAppView extends
     com.bea.control.ControlExtension, ApplicationViewControl
    {

        /**
         * Get a customer record given first and last name.
         * @jc:av-service name="GetCustomer" async="false"
         */
    public wlai.functionDemo.
    customerMgmtGetCustomerResponse.RowsDocument
    GetCustomer(wlai.functionDemo.customerMgmtGetCustomerRequest.
    InputDocument request)
            throws Exception;

        /**
         * Update the customer's email address.
         * @jc:av-service name="UpdateCustomer" async="false"
         */

    public wlai.functionDemo.customerMgmtUpdateCustomerResponse.
    RowsAffectedDocument UpdateCustomer(wlai.functionDemo.
    customerMgmtUpdateCustomerRequest.InputDocument request)
            throws Exception;

        /**
         * Select all customers in the customer table.
         * @jc:av-service name="GetAllCustomers" async="true"
         */
        public void GetAllCustomers()
            throws Exception;

        /**
         * Create a new customer given first and last name,
         * and date of birth.
         * @jc:av-service name="CreateCustomer" async="false"
         */
    public wlai.functionDemo.
    customerMgmtCreateCustomerResponse.RowsAffectedDocument
    CreateCustomer(wlai.functionDemo.
    customerMgmtCreateCustomerRequest.InputDocument request)
            throws Exception;

        public interface Callback extends
     ApplicationViewControl.Callback

        {

            /**
             * Async response callback method for
             * GetAllCustomers service.
             */
    public void onGetAllCustomersResponse(wlai.functionDemo.
    customerMgmtGetAllCustomersResponse.RowsDocument response);

            /**
             * Callback to handle errors with async service requests.
             * Note that only one async request can be in flight
             * for a given control instance at any given time.
             *
             * @param errorMsg
             * The error message text for the failed async request.
             */
            public void onAsyncServiceError(String errorMsg);
        }
    }