# Define environment-specific variables
#--------------------------------------------

# Need values for prod

eesvcAdminServerName = ''
eesvcAdminServerPORT       
eesvcUsername = ''
eesvcPassword = ''

esrAdminServerName = ''
esrAdminServerPORT       
esrUsername = ''
esrPassword = ''

esrT3URL = 't3://' + esrAdminServerName + ':' + esrAdminServerPort
eesvcT3URL = 't3://' + eesvcAdminServerName + ':' + eesvcAdminServerPort

#--------------------------------------------

connect(eesvcUsername, eesvcPassword, eesvcT3URL)
edit() 
startEdit()

cd('/')
cmo.createJMSServer('EE-JMS')

cd('/Deployments/EE-JMS')
cmo.setPersistentStore(getMBean('/FileStores/WseeFileStore'))
set('Targets',jarray.array([ObjectName('com.bea:Name=AdminServer,Type=Server')], ObjectName))

cd('/')
cmo.createJMSSystemResource('MSDS-Module')

cd('/SystemResources/MSDS-Module')
set('Targets',jarray.array([ObjectName('com.bea:Name=AdminServer,Type=Server')], ObjectName))

cd('/JMSSystemResources/MSDS-Module/JMSResource/MSDS-Module')
cmo.createConnectionFactory('MSDS-ConnectionFactory')

cd('/JMSSystemResources/MSDS-Module/JMSResource/MSDS-Module/ConnectionFactories/MSDS-ConnectionFactory')
cmo.setJNDIName('jms/MSDS-ConnectionFactory')

cd('/JMSSystemResources/MSDS-Module/JMSResource/MSDS-Module/ConnectionFactories/MSDS-ConnectionFactory/SecurityParams/MSDS-ConnectionFactory')
cmo.setAttachJMSXUserId(false)

cd('/JMSSystemResources/MSDS-Module/JMSResource/MSDS-Module/ConnectionFactories/MSDS-ConnectionFactory')
cmo.setDefaultTargetingEnabled(true)

cd('/SystemResources/MSDS-Module')
cmo.createSubDeployment('MSDS-QueueSubdeployment')

cd('/JMSSystemResources/MSDS-Module/JMSResource/MSDS-Module')
cmo.createQueue('MSDS-RequestQueue')

cd('/JMSSystemResources/MSDS-Module/JMSResource/MSDS-Module/Queues/MSDS-RequestQueue')
cmo.setJNDIName('jms/MSDS-InboundQueue')
cmo.setSubDeploymentName('MSDS-QueueSubdeployment')

cd('/SystemResources/MSDS-Module/SubDeployments/MSDS-QueueSubdeployment')
set('Targets',jarray.array([ObjectName('com.bea:Name=EE-JMS,Type=JMSServer')], ObjectName))

cd('/JMSSystemResources/MSDS-Module/JMSResource/MSDS-Module')
cmo.createQueue('MSDS-ResponseQueue')

cd('/JMSSystemResources/MSDS-Module/JMSResource/MSDS-Module/Queues/MSDS-ResponseQueue')
cmo.setJNDIName('jms/MSDS-OutboundQueue')
cmo.setSubDeploymentName('MSDS-QueueSubdeployment')

cd('/SystemResources/MSDS-Module/SubDeployments/MSDS-QueueSubdeployment')
set('Targets',jarray.array([ObjectName('com.bea:Name=EE-JMS,Type=JMSServer')], ObjectName))

cd('/')
cmo.createJMSBridgeDestination('MSDS-RequestBridgeSource')

cd('/JMSBridgeDestinations/MSDS-RequestBridgeSource')
cmo.setClasspath('')
cmo.setConnectionURL(esrT3URL)
cmo.setAdapterJNDIName('eis.jms.WLSConnectionFactoryJNDINoTX')
cmo.setConnectionFactoryJNDIName('jms/MSDS-ConnectionFactory')
cmo.setDestinationJNDIName('jms.OutboundMSDSQueue')

cd('/')
cmo.createJMSBridgeDestination('MSDS-RequestBridgeDestination')

cd('/JMSBridgeDestinations/MSDS-RequestBridgeDestination')
cmo.setClasspath('')
cmo.setConnectionURL(eesvcT3URL)
cmo.setAdapterJNDIName('eis.jms.WLSConnectionFactoryJNDINoTX')
cmo.setConnectionFactoryJNDIName('jms/MSDS-ConnectionFactory')
cmo.setDestinationJNDIName('jms/MSDS-InboundQueue')

cd('/')
cmo.createMessagingBridge('MSDS-RequestBridge')

cd('/Deployments/MSDS-RequestBridge')
set('Targets',jarray.array([ObjectName('com.bea:Name=AdminServer,Type=Server')], ObjectName))
cmo.setSourceDestination(getMBean('/JMSBridgeDestinations/MSDS-RequestBridgeSource'))
cmo.setTargetDestination(getMBean('/JMSBridgeDestinations/MSDS-RequestBridgeDestination'))
cmo.setStarted(true)
cmo.setSelector('')
cmo.setQualityOfService('Duplicate-okay')

cd('/')
cmo.createJMSBridgeDestination('MSDS-ResponseBridgeSource')

cd('/JMSBridgeDestinations/MSDS-ResponseBridgeSource')
cmo.setClasspath('')
cmo.setConnectionURL(eesvcT3URL)
cmo.setAdapterJNDIName('eis.jms.WLSConnectionFactoryJNDINoTX')
cmo.setConnectionFactoryJNDIName('jms/MSDS-ConnectionFactory')
cmo.setDestinationJNDIName('jms/MSDS-OutboundQueue')

cd('/')
cmo.createJMSBridgeDestination('MSDS-ResponseBridgeDestination')

cd('/JMSBridgeDestinations/MSDS-ResponseBridgeDestination')
cmo.setClasspath('')
cmo.setConnectionURL(esrT3URL)
cmo.setAdapterJNDIName('eis.jms.WLSConnectionFactoryJNDINoTX')
cmo.setConnectionFactoryJNDIName('jms/MSDS-ConnectionFactory')
cmo.setDestinationJNDIName('jms.InboundMSDSQueue')

cd('/')
cmo.createMessagingBridge('MSDS-ResponseBridge')

cd('/Deployments/MSDS-ResponseBridge')
set('Targets',jarray.array([ObjectName('com.bea:Name=AdminServer,Type=Server')], ObjectName))
cmo.setSourceDestination(getMBean('/JMSBridgeDestinations/MSDS-ResponseBridgeSource'))
cmo.setTargetDestination(getMBean('/JMSBridgeDestinations/MSDS-ResponseBridgeDestination'))
cmo.setStarted(true)
cmo.setSelector('')
cmo.setQualityOfService('Duplicate-okay')

activate()
disconnect()