Add and Remove targets from a Deploy-able system resource
Add and Remove targets from a Deploy-able system resource


Add and Remove targets from a Deploy-able system resource:

  • Any deploy-able weblogic system resource (JDBC Data Source, JMS Connection Factory, JMS Servers, JDBC Multi Pools, Web deployment, etc) implement the ‘DeploymentMBean’ interface
  • A deploy-able Systme resource is any MBean that may be deployed on one or more targets, such as a JMS Front-end or back-end or a JDBC connection pool.
  • Any deploy-able resource (MBean) has targets, which specify which servers the deployment should be deployed / pinned on.
  • All these deploy-able resources (MBean) leverage ‘addTarget’ and ‘removeTarget’ methods , which they inherit from the ‘DeploymentMBean’ interface.
    • addTarget(target)
  • This method adds a target to specify additional servers / clusters on which the deployable Mbean can be deployed here, target - is the reference variable of type: TargetMBean, [a server MBean is acceptable], see example below
    • removeTarget(target)
  • This method removes the value of the addTarget attribute
  • here, target - is the reference variable of type: TargetMBean, [a server MBean is acceptable], see example below

In this example we will use a JDBC Data Source to demonstrate this

Prerequisites

  • WebLogic Domain with an admin server and a managed server named ‘MS1’
  • Create a JDBC Datasource named ‘DS1’, and deploy it ONLY on ‘Admin Server’
  • Make sure that both the servers are running and DS1 is also running

Demonstration for adding a target to a Data Source:

  • open a command window (CMD)
  • set the environment by running the ‘setdomainenv.cmd’ from the ‘domain\bin’ dir
  • execute ‘java weblogic.WLST’
  • connect to the Admin Server using ‘connect’ command
## don't hesitate to add a comment to this post incase you have any queries or sugessions
edit()
startEdit()
cd('/JDBCSystemResources/DS1')
jdbcDS1=cmo
cd("/Servers/MS1")
target=cmo  
jdbcDS1.addTarget(target)
save()
activate()
  • You should be able to see the new target in the Admin Console (Service > JDBC > DataSources > DS1 > Targets Tab)

Demonstration for removing a target to a Data Source:

  • open a command window (CMD)
  • set the environment by running the ‘setdomainenv.cmd’ from the ‘domain\bin’ dir
  • execute ‘java weblogic.WLST’
  • connect to the Admin Server using ‘connect’ command
## don't hesitate to add a comment to this post incase you have any queries or sugessions

edit()
startEdit()
cd('/JDBCSystemResources/DS1')
jdbcDS1=cmo
cd("/Servers/MS1")
target=cmo  
jdbcDS1.removeTarget(target)
save()
activate()
  • You should be able to see the new target in the Admin Console (Service > JDBC > DataSources > DS1 > Targets Tab)

Cheers :)

Unni

comments here

June 2, 2010
387 words


Categories
Tags
example hugox blog

Connect. Socialize.

Sponsors