This blog briefly explains the use of customization files, how to create a customization file using the Service Bus Console, includes the WLST script to execute this task, and provides a brief conclusion.
Customization Files
Customization files are XML files that contain the configuration of Service Bus resources and projects. Examples of such configurations are Service URIs, JCA settings, Retry Settings, and so on. Customization files provide a convenient way to apply environment-specific configuration during deployment. You can both apply, as well as create and extract the runtime configuration of Service Bus resources and projects into customization files using the Service Bus Console.Creating customization file using the Service Bus Console |
Read more about customization files in the Oracle Fusion Middleware Administrator's Guide for Oracle Service Bus.
WLST Script
Based on the following resources a WLST script can be created to export an OSB project including its customization file from a runtime environment:The WLST script is as follows:
from java.io import FileOutputStream
from java.util import Collections
from com.bea.wli.config import Ref
from com.bea.wli.config.mbeans import ConfigMBean
from com.bea.wli.sb.util import EnvValueTypes
import sys
#==================================================
# Utility function to export project and cust file
#==================================================
def exportProject():
try:
if projectName == "None":
print "No project specified, exiting deployment"
exit(exitcode=-1)
if customizationFile == "None":
print "No customization file specified, exiting"
exit(exitcode=-1)
ALSBConfigurationMBean = findService("ALSBConfiguration", "com.bea.wli.sb.management.configuration.ALSBConfigurationMBean")
print "ALSBConfigurationMBean found"
configMBean = JMX.newMBeanProxy(mbs, ObjectName.getInstance("com.bea:Name=Config.XBus Kernel,Type=com.bea.wli.config.mbeans.ConfigMBean"), ConfigMBean)
print "ConfigMBean found"
# Get reference to OSB project
ref = Ref.makeProjectRef(projectName);
collection = Collections.singleton(ref)
# Export OSB project JAR
print "Export JAR for OSB project:", projectName
theBytes = ALSBConfigurationMBean.exportProjects(collection, passphrase)
aFile = File(exportJar)
out = FileOutputStream(aFile)
out.write(theBytes)
out.close()
print "Project " + projectName + " exported"
# Export OSB customization file
print "Export customization file for:", projectName
theBytes = configMBean.createCustomizationFile(collection, EnvValueTypes.ENV_VALUE_TYPES);
out = FileOutputStream(customizationFile);
out.write(theBytes);
out.close();
print "Cust file for " + projectName + " exported"
except:
raise
try:
adminUser = sys.argv[1]
adminPassword = sys.argv[2]
adminUrl = sys.argv[3]
projectName = sys.argv[4]
exportJar = sys.argv[5]
customizationFile = sys.argv[6]
passphrase = "your-passphrase"
connect(adminUser, adminPassword, adminUrl)
domainRuntime()
exportProject()
except:
print "Unexpected error: ", sys.exc_info()[0]
dumpStack()
raise