# Setting Service Broker Properties

The Service Broker control adds the capability of dynamically binding some properties of the control. Dynamic binding of properties can be achieved the following ways:

- Using selectors
- Using the setProperties() API
- Using setter methods for individual properties, such as setEndPoint(). These setter methods are inherited from the Web Service control interface.

    package com.bea.control;

    public interface ServiceBrokerControl extends ServiceControl {

        void setProperties(ServiceBrokerControlProperties props)
            throws Exception;
    }

To retrieve the current properties settings, use the getProperties() method. Note that this method does not return security-related settings such as username/password, keyAlias/keyPassword, and keyStoreLocation/keyStorePassword.

Starting with the method with the highest precedence, the hierarchy of property settings is:

1. properties dynamically bound using the jc:selector tag and the DynamicProperties.xml file
2. properties set using the setProperties() method or other setter methods inherited from the Service control (setConversationID, setEndPoint, setOutputHeaders, setPassword, and setUsername)
3. properties set using static annotations

The ServiceBrokerControlProperties type is an XML Beans class that is generated out of the corresponding schema element defined in DynamicProperties.xsd. The DynamicProperties.xsd file is located in the system folder of New Process Applications or in the system folder of the Schemas project.

Note: The ServiceBrokerControlProperties document's "password" field and associated setPassword() method should contain the intended password alias, not the actual password.

The setProperties() method uses this XML Beans class to set properties on a control instance. A selector on a Service Broker control method returns an XML document that conforms to the ServiceBrokerControlProperties element. The following sample shows how to programmatically set the endpoint property for the control. You add the bold code lines to the code generated when the control is created, overriding properties set using dynamic binding and static annotations:

    import com.bea.wli.control.dynamicProperties.
    ServiceBrokerControlPropertiesDocument;

    import com.bea.wli.control.dynamicProperties.
    ServiceBrokerControlPropertiesDocument.ServiceBrokerControlProperties;

        ServiceBrokerControlPropertiesDocument props= null;
        ServiceBrokerControlProperties sprops = null;

        public void sBC8InvokeSetProperties() throws Exception

        {

            props = ServiceBrokerControlPropertiesDocument.Factory.newInstance();
            sprops = props.addNewServiceBrokerControlProperties();

            sprops.setEndpoint("http://localhost:7001/BVTAppWeb/ServiceBrokerControl
            /SBC8DynPropHierarchyChild_2.jpd");

You construct the ServiceBrokerControlPropertiesDocument instance in the above section of code through a Data Transformation method or through XML Bean APIs. For more information on Data Transformations, see Guide to Data Transformation, and for more information on XML Beans, see "Getting Started with XML Beans" in Handling XML with XML Beans.

The following code provides a sample of a ServiceBrokerControlPropertiesDocument instance:

    this.sbcp = ServiceBrokerControlPropertiesDocument.Factory.newInstance();

    this.sbcp.addNewServiceBrokerControlProperties();

    this.sbcp.getServiceBrokerControlProperties().setEndpoint("http://localhost:7001/");

Some control properties can be specified dynamically or in annotations (statically) on the JCX file. For example, the Service Broker control allows you to specify the http-url of the target service in the jc:location annotation at the top of the JCX, or dynamically using the endpoint element in DynamicProperties.xml. In all such cases, a dynamically bound value for the property takes precedence over the static annotation.

If the domain is active, it is recommended that you use the WebLogic Integration Administration Console to perform dynamic binding. For more information on binding lookup values to dynamic properties using the WebLogic Integration Administration Console, see "Adding or Changing Dynamic Control Selectors" in Process Configuration in Managing WebLogic Integration Solutions, which is available at the following URL:

http://e-docs.bea.com/wli/docs81/manage/processconfig.html#1039959

Dynamic properties can also be specified by calling setProperties on the control, or by calling one of the setter methods, such as ServiceBrokerControl.setEndPoint(). Properties specified in this way take precedence over properties bound by selectors or annotations.

Properties applied using selectors remained bound until one of the following conditions occurs:

- A method marked finish on the JCX is invoked
- A start method is invoked again
- The property is programmatically set by calling setProperties or a setter method

ServiceControl.reset() is overwritten by the Service Broker control to reset all dynamically set properties (in addition to all conversational states). Programmatically specified properties remain bound until reset() is invoked.

You can also use the ControlContext interface for access to a control's properties at run time and for handling control events. Property values set by a developer who is using the control are stored as annotations on the control's declaration in a JWS, JSP, or JPD file, or as annotations on its interface, callback, or method declarations in a JCX file.

Related Topics

Overview: Service Broker Control

Using Dynamic Binding

ServiceBrokerControl Interface