The steps involved in multi datasource confiuration are as follows:
1. Configure individual datasource
2. Configure a new multidatasource
3. Add the datasources created in steip 1
Keeping more flavor (Object-Orientation) to your script we will create a Class in WLST this time. Are you ready??? I know you guys very intelligents and know all WLST tricks how they works and all!! Lets dive into the process of configuration.
-->
#==========================================
# File name: ConfigMDS.py
# Please change the code (line 38) as per your environment and needs
# Author : Inteligent WLA :)
#=============================================
class MDS:
def __init__(self, nam):
self.nam = nam
def configMDS(self):
n=self.nam
try:
cd('/')
cmo.createJDBCSystemResource(n)
cd('/JDBCSystemResources/'+n+'/JDBCResource/'+n)
cmo.setName(n)
cd('JDBCDataSourceParams/'+n)
set('JNDINames',jarray.array([String(n)], String))
cmo.setAlgorithmType('Failover')
dslist=raw_input('Please enter comma separating Datasources for MDS:')
cmo.setDataSourceList(dslist)
cd('/JDBCSystemResources/'+n)
targetType=raw_input('Target to (C)luster or (S)erver: ')
if targetType in ('C','c') :
clstrNam=raw_input('Cluster Name: ')
set('Targets',jarray.array([ObjectName('com.bea:Name='+clstrNam+',Type=Cluster')], ObjectName))
else:
servr=raw_input('Server Name: ')
set('Targets',jarray.array([ObjectName('com.bea:Name='+servr+',Type=Server')], ObjectName))
print 'Succesfully configured MultiDataSource...'
activation()
except BeanAlreadyExistsException:
print 'Error: '+n+' BeanAlreadyExists...'
cancelEdit('y')
exit()
#===== main program===============
if __name__== "main":
connect('wlusr','paswd','t3://AdminUrl:AdminPort')
edit()
startEdit()
mdsName = raw_input("Please enter MultiDataSource name: ")
# create object, call configMDS
MDS(mdsName).configMDS()
print('Exiting...')
exit()
Here you can templatise more by creating the a properties file where you need to store Multidatasoruce name, JNDIName, WebLogic Admin user, Password, AdminURL, the datasource names you wish to add to the multidatasource.
Use the same steps as followed in the Generic Data Source Creation.
# http://unni-at-work.blogspot.com/2009/03/multi-data-source-using-wlst.html
# http://edocs.bea.com/wls/docs100/wlsmbeanref/mbeans/JDBCDataSourceParamsBean.html#AlgorithmType