![]() ![]() ![]() ![]() ![]() ![]() |
This chapter documents the best practices, design considerations, and packaging to develop transports for Oracle Service Bus Workshop for WebLogic design time. The Transport SDK interface provides a bridge between transport protocols and the Oracle Service Bus run time.
Tip: | Before you begin this chapter, review Design Considerations. |
This chapter includes the following sections:
Oracle Service Bus transports were originally designed to be deployed on Oracle Service Bus servers and configured through the Oracle Service Bus console. With design environments like Workshop for WebLogic, some modifications to the SDK and the existing transports are necessary.
This document describes the additional steps to ensure Oracle Service Bus transports design time can be used on platforms outside the Oracle Service Bus console.
The sample socket transport was ported to Workshop for WebLogic and can be considered a best practice for Workshop for WebLogic integration. The sample socket resources are located at ALSB_HOME/samples/servicebus/sample-transport/. The Java source files are in the /src subdirectory. The sample also contains a build script that automatically packages the sample socket transport for both Workshop for WebLogic integration and Oracle Service Bus console deployment. For information on building and deploying the sample socket transport, see Sample Socket Transport Provider.
When you develop a transport, you should distinguish the runtime aspects from the configuration aspects. The runtime aspects include proxy or business service deployment and service run-time invocation. The configuration aspects include proxy or service configuration and validation.
The runtime aspects do not need to change since they are always exercised in the context of a running Oracle Service Bus server. However, the configuration aspects are dependent on the design environment.
Developers should consider three different modes:
Transports running in Workshop for WebLogic must support offline mode and, optionally, offline mode with a remote server.
This section contains the following topics:
When you deploy a transport in offline mode, the configuration framework creates a single session for all the resource configurations. This session is never activated. Since proxy or business services can only be deployed on a running Oracle Service Bus server, there is no need to activate the session. However, it is still important to detect conflicts and configuration errors and the validation methods are still exercised.
Following is a list of the minimum set of classes and methods defined by the Transport SDK that must be implemented in offline mode. The exceptions were removed from the methods signature for better readability.
Note: | You do not need to completely re-implement your transport for offline mode. In most cases your transport will only need a few changes to existing methods to support both online and offline modes. |
public interface TransportProvider
classString getId();
void validateEndPointConfiguration(TransportValidationContext context);
SchemaType getEndPointConfigurationSchemaType();
SchemaType getRequestMetaDataSchemaType();
SchemaType getRequestHeadersSchemaType();
SchemaType getResponseMetaDataSchemaType();
SchemaType getResponseHeadersSchemaType();
TransportProviderConfiguration getProviderConfiguration();
TransportUIBinding getUIBinding(TransportUIContext context);
void shutdown();
Collection<NonQualifiedEnvValue> getEnvValues(Ref ref,
EndPointConfiguration epConfig);
void setEnvValues(Ref ref, EndPointConfiguration epConfig,
Collection<NonQualifiedEnvValue> envValues);
Collection<Ref> getExternalReferences(EndPointConfiguration epConfig);
void setExternalReferences(Map<Ref, Ref> mapRefs, EndPointConfiguration
epConfig);
Map<String, String> getBusinessServicePropertiesForProxy(Ref ref);
XmlObject getProviderSpecificConfiguration(Ref ref, Map<String, String>
props);
public interface TransportProviderFactory
classThis interface registers transports in offline mode. See Deploying a Transport Provider for more details.
public interface TransportUIBinding
classYou should implement all the methods in this interface and define the user interface used to configure a proxy or business service.
public class TransportManagerHelper
class
This class is typically used by TransportProvider
developers. However, some of the methods that are not valid in offline mode will throw exceptions, which are described below. Other methods are meant only for runtime or deployment, such as public isAdmin()
.
Two methods are also available when working in offline mode with remote server:
public Set<String> getDispatchPolicies(JMXConnector connector);
methodpublic DomainRuntimeServiceMBean getDomainRuntimeServiceMBean(JMXConnector connector);
methodSee Working Offline with a Remote Server for more information.
Do not invoke the following two methods in offline mode:
isAdmin
method throws exceptions (public static boolean isAdmin();
). This method throws a java.lang.IllegalStateException
message.clusterExists()
method always returns false (public static boolean clusterExists();
). This method always returns false.When you work offline, none of WebLogic Server services running on the server are available. Do not use these services inside the methods described in Offline Methods.
Following are examples of restrictions for working offline:
Because some of the services are not available, it is necessary to evaluate how the transport user interface is affected. In general, the user interface should be more flexible to let users manually configure values instead of trying to retrieve values from the server environment.
Workshop for WebLogic design time does not currently support deployment to an Oracle Service Bus cluster. Therefore, the user interface must be populated as if there is no cluster. If necessary, the user can use a customization file to update the configuration and force a deployment to an Oracle Service Bus cluster.
For example, some transports retrieve the list of available WorkManager items by using the TransportManagerHelper and letting the user pick one through a drop-down list. However, in offline mode, the MBeans are not available so the drop-down list cannot be populated. The transport provider has two choices:
When you work offline, a remote server might be available. For instance, when you configure a service on Workshop for WebLogic, the user can associate a remote Oracle Service Bus server to the current project. The transport provider can take advantage of the remote server by accessing the WebLogic Server MBeans and retrieving information. This mode is similar to working online; however, some restrictions still apply since the code is not running on the server and only the MBeans are available.
When you work offline, the following statements apply:
To access the MBeans, the framework provides an instance of JMXConnector when it requests the TransportUI object, or when it asks the provider to validate a configuration. The JMXConnector is available in the TransportUIContext or the TransportValidationContext:
JMXConnector connector = (JMXConnector)uiContext.get(TransportValidationContext.JMXCONNECTOR);
For more information, see the sample transport in Reference.
If the connector is not present, a remote server is not available. This connector object can then be used to access the MBeans. Helper methods have been added to the TransportManagerHelper to retrieve the list of WorkManager and WebLogic Server domain MBean.
Note: | This behavior is generalized for both online and offline modes. The public static Set<String> getDispatchPolicies() method defined in the TransactionManagerHelper will be deprecated and must be replaced by the same method with JMXConnector as a parameter. If you do not replace it, the following error appears: com.bea.wli.sb.transports.TransportException . |
In online mode, transports must be packaged as EAR files and deployed on an Oracle Service Bus server. When the EAR is loaded at startup, the transport registers a callback on a startup event and registers an instance of the TransportProvider to the TransportManager.
In offline mode, a new mechanism registers transports. The SDK introduces a new interface called com.bea.wli.sb.transports
.TransportProviderFactory
. A transport developer must implement this interface and must make the default constructor public. The interface is provided in Reference, as well as a sample implementation.
If the TransportProvideFactory is instantiated, you can assume the transport needs to work in offline mode (with or without a remote server).
Note: | You can set a boolean operator in the TransportProviderFactory when the constructor is invoked to determine if the transport is running in offline mode. This information can also be passed in the TransportUIContext and the TransportValidationContext. Your Engineering Department can assist you in making this decision. |
In offline mode, you can use transports in different design environments. The Workshop for WebLogic environment defines specific packaging, which is described in the next section. In general, transports simply need to be available to external design time environments as a self-contained JAR file. A self-contained JAR file has the JAR file include the transport config.xml file, the header, metadata schemas, XBeans classes, TransportProviderFactory implementation, and the compiled transport classes.
Packaging your custom transport as a Workshop for WebLogic plug-in, in conjunction with your transport user interface implementation, lets service developers select and configure your transport in the development environment.
Figure 4-1 shows the service creation wizard with a drop-down field populated with available transports.
Figure 4-2 shows the service editor—after a service has been created—with a configuration page for the selected transport.
Note: | Your implementation of the TransportUIBinding interface determines the user interface for selecting and configuring your transport, both in Workshop for WebLogic and in the Oracle Service Bus console. |
Oracle Service Bus provides Eclipse-based plug-ins to Workshop for WebLogic. The core Oracle Service Bus plug-in, com.bea.alsb.core, defines an extension point (com.bea.alsb.core.transports) that is used to register Oracle Service Bus transports in the Workshop for WebLogic environment as plug-ins.
Your transport plug-in must provide the following resources:
You can package your transport plug-in either as a JAR file or in an exploded directory. Packaging as a JAR makes the transport more portable. Packaging as an exploded directory lets you reference resources in other Oracle Service Bus plug-ins. For example, if you want to merge your transport help with the Oracle Service Bus transport topics in the Workshop for WebLogic help system, you must package your transport plug-in in an exploded directory, as described in Providing Custom Transport Help in Workshop for WebLogic.
Whether you package your plug-in in a JAR or an exploded directory, you must package your transport implementation in a JAR file.
Use the following guidance for packaging your transport as a plug-in:
Bundle-Version
to the Bundle-SymbolicName
from the MANIFEST.MF file. For example, the sample socket transport JAR is named Socket_Transport_3.0.0.0.jar.For reference on transport plug-in packaging:
This section contains the following topics:
Dispatch Policies are used by most transports and allow services throttling. This code distinguishes the three modes described in Services Runtime and Services Configuration:
The connection to the remote server is retrieved from the context, as shown in Listing 4-1.
/**
* Builds the dispatch policies in the ui object.
*
* @param curDispatchPolicy
* @return TransportEditField containing existing dispatch policies.
*/
public TransportEditField getDispatchPolicyEditField(StringcurDispatch
Policy) {
TransportUIFactory.TransportUIObject uiObject = null;
Set<String> wmSet = null;
if (SocketTransportProviderFactory.isOffline()) { // if on
Eclipse try to get the MBeans from the UIContext
JMXConnector connector = (JMXConnector)uiContext.get
(TransportValidationContext.JMXCONNECTOR);
if (connector != null) {
try {
wmSet = TransportManagerHelper.getDispatchPolicies
(connector);
} catch (Exception ex) {
wmSet = null; //continue
}
}
} else { // if running on the server use the helper to get the
policies
try {
wmSet = TransportManagerHelper.getDispatchPolicies();
} catch (TransportException e) {
SocketTransportUtil.logger
.error(SocketTransportMessagesLogger.
noDispatchPolicies(), e);
}
}
if (wmSet == null) // if JMXConnector not available or impossible
to connect provide a simple edit field
{
uiObject = TransportUIFactory.createTextBox
(curDispatchPolicy);
} else // create a drop down list
{
// adding default work manager to the list.
wmSet.add(DEFAULT_WORK_MANAGER);
String[] values = wmSet.toArray(new String[wmSet.size()]);
uiObject = TransportUIFactory.createSelectObject(
values,
values,
curDispatchPolicy,
TransportUIFactory.SelectObject.DISPLAY_LIST,
false);
}
return TransportUIFactory.createEditField(DISPATCH_POLICY,
TextMessages.getMessage(TextMessages.DISPATCH_POLICY,
locale),
TextMessages.getMessage(TextMessages.DISPATCH_POLICY_INFO,
locale), uiObject);
}
TransportProviderFactory, Listing 4-2, lets you provide development-time functionality in Workshop for WebLogic.
package com.bea.wli.sb.transports;
import com.bea.wli.sb.transports.TransportException;
import com.bea.wli.sb.transports.TransportManager;
/**
* This interface is the extension point to plug custom ALSB transports in
Eclipse.
* The implementation must declare the default class constructor.
*/
public interface TransportProviderFactory {
/**
* Registers a new provider with the transport manager. Typically
* called by the ALSB core eclipse plugin.
* @param tm the transport manager to which to register
*/
public void registerProvider(TransportManager tm) throws
TransportException;
/**
* @return a unique string that identifies this provider, like "http"
* This method must return the same ID than provider.getId()
*/
String getId();
}
The code sample in Listing 4-3 shows how the Socket Transport implements this interface
package com.bea.alsb.transports.sock;
import com.bea.wli.sb.transports.TransportManager;
import com.bea.wli.sb.transports.TransportException;
import com.bea.wli.sb.transports.TransportProviderFactory;
public class SocketTransportProviderFactory implements
TransportProviderFactory {
public static boolean isOffline() {
return isOffline;
}
private static boolean isOffline = false;
public void registerProvider(TransportManager tm) throws
TransportException {
isOffline = true;
SocketTransportProvider instance =
SocketTransportProvider.getInstance();
tm.registerProvider(instance, null);
}
public String getId() {
return SocketTransportProvider.ID;
}
}
Listing 4-4 is extracted from the extension point schema that defines the transport
element and transport-provider
attribute for adding a transport as a Workshop for WebLogic plug-in, shown in plugin.xml.
<element name="transport">
<complexType>
<attribute name="transport-provider" type="string" use="required">
<annotation>
<documentation>
</documentation>
<appInfo>
<meta.attribute kind="java" basedOn="
com.bea.wli.sb.transports.Transport
ProviderFactory"/>
</appInfo>
</annotation>
</attribute>
</complexType>
</element>
Listing 4-5 shows the transport extension for the sample socket transport plugin.xml file. The file is located at ALSB_HOME/samples/servicebus/sample-transport/eclipse/.
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.2"?>
<plugin>
<extension
id="socket"
name="Socket Transport"
point="com.bea.alsb.core.transports">
<transport transport-provider="com.bea.alsb.transports
.sock.SocketTransportProviderFactory"/>
</extension>
</plugin>
Note: | Transport providers typically are not required to manage the life cycle inside Workshop for WebLogic, so there is no need to extend the org.eclipse.core.runtime.Plugin class like a regular plug-in. |
If you are providing help for your custom transport in Workshop for WebLogic, you will also have help entries in plugin.xml. For more information, see Creating Help for Custom Transports.
Listing 4-6 shows the sample socket transport MANIFEST.MF file. The file is located at ALSB_HOME/samples/servicebus/sample-transport/eclipse/META-INF/.
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Socket Transport Plug-in
Bundle-SymbolicName: Socket_Transport;singleton:=true
Bundle-Version: 3.0.0.0
Bundle-Localization: plugin
Bundle-ClassPath: .,
lib/sock_transport.jar
Require-Bundle: com.bea.alsb.core
Listing 4-7 shows the target to package the sample socket transport for Workshop for WebLogic. The file is located at ALSB_HOME/samples/servicebus/sample-transport/.
<target name="create_plugin">
<mkdir dir="${build.dir.transports.sock.eclipse}/plugin"/>
<copy todir="${build.dir.transports.sock.eclipse}/plugin"
overwrite="true">
<fileset dir="${src.dir.transports.sock.eclipse}"/>
</copy>
<mkdir dir="${build.dir.transports.sock.eclipse}/plugin/lib"/>
<copy file="${sock.transport.jar}"
todir="${build.dir.transports.sock.eclipse}/plugin/lib"
overwrite="true"/>
<zip destfile="${sock.transport.eclipse.jar}" basedir="${build.dir.
transports.sock.eclipse}/plugin"/>
</target>
The build-jar
target also builds the sample socket transport plug-in, along with the deployable transport EAR.
For more information on building the sample socket transport, see Sample Socket Transport Provider.
Listing 4-8 shows the TransportManagerHelper methods.
public static Set<String> getDispatchPolicies(JMXConnector connector)
throws TransportException;
public static DomainRuntimeServiceMBean
getDomainRuntimeService(JMXConnector connector)
throws TransportException;
![]() ![]() ![]() |