![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Resources within a domain use Java Management Extensions (JMX) Managed Beans (MBeans) to expose their management functions. An MBean is a concrete Java class that is developed per JMX specifications. It can provide getter and setter operations for each management attribute within a managed resource along with additional management operations that the resource makes available.
The AquaLogic Service Bus DeploymentMBean
enables programmatic import and export of AquaLogic Service Bus configurations, as well as modification of environment-specific configuration information. Using the DeploymentMBean
interface, you can create Java programs and WLST scripts to automate promotion of AquaLogic Service Bus configurations from development environments through testing, staging, and finally to production environments.
The following sections describe how to use the DeploymentMBean
to perform these deployment activities from within a WLST script:
For reference material on the DeploymentMBean
interface and Java usage examples, see the com.bea.wli.management package in the Javadoc for AquaLogic Service Bus Classes.
AquaLogic Service Bus configurations are created using the AquaLogic Service Bus Console, and are stored through export in .jar
files. Once a configuration .jar
file has been exported, you can promote the configuration by importing it into a different AquaLogic Service Bus domain and changing the environment-specific values in the configuration to match those of the new environment.
The methods in the DeploymentMBean
interface directly parallel interactive features provided in the AquaLogic Service Bus Console, and require execution in the same order as their GUI counterparts. The following table lists the required steps and the methods available in the DeploymentMBean
interface to perform them.
The following example shows how to use the DeploymentMBean
to perform these activities from within a WLST script.
Note: | The following JAR files must be on the classpath: sb-public.jar and sb-internal.jar . |
import wlstModule
from java.io import File
from java.util import List
from com.bea.wli.config import Ref
from com.bea.wli.config import TypeIds
def connectToServer():
connect("weblogic", "weblogic", "t3://localhost:7001")
domainRuntime()
# imports a configuration jar file
def importConfig(jarfilename):
infile = File(jarfilename)
infile = infile.getAbsoluteFile() # enables server to find the file
# find the deployment mbean
mbean = findService("Deployment", "com.bea.wli.management.DeploymentMBean")
# all changes to Service Bus configuration must be done in a session
session = mbean.openImportSession()
# import the whole jar file into the session.
mbean.importIntoSession(session, infile)
# typically you will change certain values that are environment dependent
# here we are changing "localhost:7001" to "productionserver:7001"
mbean.findAndReplaceEnvValues(session, TypeIds.URI_ENV_VALUE_TYPE,
"localhost:7001", "productionserver:7001")
# finally commit the session. The changes will be submitted to the
# core state and the session will be destroyed
mbean.commitImportSession(session)
# exports all resources in
def exportConfig(jarfilename, projectname, exportDependencies):
outfile = File(jarfilename)
outfile = outfile.getAbsoluteFile() # enables server to find the file
# find the deployment mbean
mbean = findService("Deployment", "com.bea.wli.management.DeploymentMBean")
# export all resources in the given project. If exportDependencies
# is true, any other resources that these resources depend on will
# also be exported. If false, only the resources in the given project
# will be exported.
mbean.export(outfile, [projectname], [], exportDependencies)
# call the defined functions here.
try:
# connect to running server
connectToServer()
# import configuration
importConfig(sys.argv[1])
# export all resources in the default project and their dependencies
exportConfig("temp.jar", "default", true)
except:
print "Unexpected error: ", sys.exc_info()[0]
dumpStack()
raise
In this example, the full contents of one configuration file are imported. One or more service endpoints had been set to localhost:7001
in the environment from which the configuration had been exported. This example uses findAndReplaceEnvValues()
to set each service endpoint having the value of localhost:7001
to productionserver:7001
. The change affects any matching endpoints in both proxy service and business service configurations. The updated configuration is committed, and then exported into another configuration file.
For reference material on the DeploymentMBean
interface, see the com.bea.wli.management package in the Javadoc for AquaLogic Service Bus Classes.
For more information on creating WLST scripts, see WebLogic Scripting Tool.
The findAndReplaceEnvValues()
method enables you to update the value of the following artifacts to the appropriate environment-specific value:
When using the findAndReplaceEnvValues()
method, you indicate the type of artifact you want to update with the envValueType
parameter. As shown in Listing A-1, you use TypeIds.URI_ENV_VALUE_TYPE
as the envValueType
parameter value for search and replacement of service endpoint URIs. To update directory elements (such as error or archive directories), you use TypeIds.FILE_PATH_ENV_VALUE_TYPE
as the envValueType
parameter value for search and replacement of fully qualified directory paths.
The following code excerpt shows an example of updating directory values.
...
mbean.findAndReplaceEnvValues(session, TypeIds.FILE_PATH_ENV_VALUE_TYPE,
"c:/myArchiveDirectory", "d:/production/ArchiveDirectory")
...
You must update your security configuration and all other environment-specific settings interactively using the AquaLogic Service Bus Console. For information on configuring security, see Securing Inbound and Outbound Messages in the BEA AquaLogic Service Bus Console Online Help. For information on configuring other environment-specific settings, see Step 4. Deploy an AquaLogic Service Bus Configuration.
![]() ![]() ![]() |