跳到导航
BEA Dev2Dev Oracle and BEA
首页 资源中心 dev2dev学堂 在线技术论坛 User Group CodeShare
dev2dev 首页 > 资源中心 > 专家Blog > 专家Blog文章
有用的weblogic.Admin

时间:2005-12-01
作者:Hussein Badakhchani
浏览次数:
本文关键字:LSTweblogic.Admin
文章工具
推荐给朋友 推荐给朋友
打印文章 打印文章

  作为一名现场技术顾问,通常客户在现场服务器上安装WLST后,我就开始工作了。但是在WLS 9之前的版本中没有WLST,所以我有时只好使用weblogic.Admin以及VI和Bash。

  这里要说的是我用来从WLS转储EJB数据的一个Bash脚本。您根本不需要Bash,它只是一个较长的命令行的包装器。

#!/bin/bash

# ejbdump.sh
#
# author: Hussein Badakhchani
# date: 29 September 2005
# description: This scrip uses the weblogic.Admin tool to dump all data \
#              relating to a EJBMBeans
# processname: ejbdump
# info: Make sure your WebLogic environment is set up correctly. \
#       Run setEnv.sh before using ejbdump

prog=ejbdump

if [ ! $# == 4 ]; then
  echo
  echo "Usage: $0 url username password command_file"
  echo
  echo "e.g. ejbdump myhost:7001 myuser mypassword commands.txt"
  exit
fi


url=$1
username=$2
password=$3
command_file=$4

# Check for the existence of the command file.
if [ ! -f "$command_file" ]
then
  echo
  echo "Command file: $command_file not found!"
  echo "Please proivde the correct path to this file and ensure you have the \
correct privledges associated with it."
  exit $E_NOTFOUND
fi

java -cp $CLASSPATH weblogic.Admin -adminurl $url -username $username \
-password $password BATCHUPDATE -batchFile $command_file \
-continueOnError -batchCmdVerbose
该脚本运行weblogic.Admin类,它在$command_file中执行大量的命令,这里是:commands.txt。
get -pretty -type EJBCacheRuntime
get -pretty -type EJBComponentRuntime
get -pretty -type EJBLockingRuntime
get -pretty -type EJBPoolRuntime
get -pretty -type EJBRuntime
get -pretty -type EJBTransactionRuntime
get -pretty -type EntityCacheCumulativeRuntime
get -pretty -type EntityCacheCurrentStateRuntime
get -pretty -type EntityCacheRuntime
get -pretty -type EntityEJBRuntime

  -type参数全都是MBean,我从WLS 8.1 API javadocs获得这些。注意,要在名称中去掉“MBean”,才是正确的参数名。

  使用命令行运行上面的脚本:

[husseinb@lap1 bea]$ ./ejbdump lap3:7001 weblogic weblogic commands.txt
当然也可以将参数硬编码到脚本中。当在WLS附带的示例域中运行时,输出如下:
Executing command: get -pretty -type EntityCacheRuntime

No MBeans found

Error executing command in batch file commands.txt at line number: 9

Executing command: get -pretty -type EntityEJBRuntime

---------------------------
MBeanName: "examples:ApplicationRuntime=examplesServer__appsdir_ejb20_basic_containerManaged_ear,
EJBComponentRuntime=examplesServer__appsdir_ejb20_basic_containerManaged_ear_ejb20_basic_containerManaged.jar,
Location=examplesServer,
Name=examplesServer__appsdir_ejb20_basic_containerManaged_ear_ejb20_basic_containerManaged.jar_containerManaged,
ServerRuntime=examplesServer,Type=EntityEJBRuntime"
        CacheRuntime: examplesServer__appsdir_ejb20_basic_containerManaged_ear_ejb20_basic_containerManaged.jar_containerManaged
        CachingDisabled: true
        EJBName: containerManaged
        LockingRuntime:
        Name: examplesServer__appsdir_ejb20_basic_containerManaged_ear_ejb20_basic_containerManaged.jar_containerManaged
        ObjectName: examplesServer__appsdir_ejb20_basic_containerManaged_ear_ejb20_basic_containerManaged.jar_containerManaged

        Parent: examplesServer__appsdir_ejb20_basic_containerManaged_ear_ejb20_basic_containerManaged.jar
        PoolRuntime: examplesServer__appsdir_ejb20_basic_containerManaged_ear_ejb20_basic_containerManaged.jar_containerManaged
        Registered: false
        Resources:
        TransactionRuntime: examplesServer__appsdir_ejb20_basic_containerManaged_ear_ejb20_basic_containerManaged.jar_containerManaged
        Type: EntityEJBRuntime
---------------------------
MBeanName:"examples:ApplicationRuntime=examplesServer__appsdir_ejb20_basic_beanManaged_ear,
EJBComponentRuntime=examplesServer__appsdir_ejb20_basic_beanManaged_ear_ejb20_basic_beanManaged.jar,
Location=examplesServer,
Name=examplesServer__appsdir_ejb20_basic_beanManaged_ear_ejb20_basic_beanManaged.jar_beanManaged,
ServerRuntime=examplesServer,Type=EntityEJBRuntime"
        CacheRuntime: examplesServer__appsdir_ejb20_basic_beanManaged_ear_ejb20_basic_beanManaged.jar_beanManaged
        CachingDisabled: true
        EJBName: beanManaged
        LockingRuntime:
        Name: examplesServer__appsdir_ejb20_basic_beanManaged_ear_ejb20_basic_beanManaged.jar_beanManaged
        ObjectName: examplesServer__appsdir_ejb20_basic_beanManaged_ear_ejb20_basic_beanManaged.jar_beanManaged
        Parent: examplesServer__appsdir_ejb20_basic_beanManaged_ear_ejb20_basic_beanManaged.jar
        PoolRuntime: examplesServer__appsdir_ejb20_basic_beanManaged_ear_ejb20_basic_beanManaged.jar_beanManaged
        Registered: false
        Resources:
        TransactionRuntime: examplesServer__appsdir_ejb20_basic_beanManaged_ear_ejb20_basic_beanManaged.jar_beanManaged
        Type: EntityEJBRuntime

---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
Batch Command Results:
Total Commands Executed: 10
Commands Successful: 6
Commands Failed: 4

  输出非常罗嗦,如果您要研究特定的bean,可以使用它的名称(从上一个脚本的输出中获得)来指示weblogic.Admin,例如:

java -cp $CLASSPATH weblogic.Admin -url lap3:7001 -username weblogic \
-password weblogic GET -pretty -mbean \
examples:ApplicationRuntime=examplesServer__appsdir_ejb20_basic_containerManaged_ear,
EJBComponentRuntime=examplesServer__appsdir_ejb20_basic_containerManaged_ear_ejb20_basic_containerManaged.jar,
Location=examplesServer,
Name=examplesServer__appsdir_ejb20_basic_containerManaged_ear_ejb20_basic_containerManaged.jar_containerManaged,
ServerRuntime=examplesServer,Type=EJBTransactionRuntime

  最后,我要说明一下,虽然BEA的WLS 7和8.1版没有附带WLST联机版,但是它们仍然支持它。

原文出处: http://dev2dev.bea.com/blog/hoos/archive/2005/09/what_no_wlst_1.html

dot dot dot

dot
  作者其它文章
您对本文的评价
您对这篇文章的看法如何?
太棒了!5分 不错啊 4分 一般般 3分 有待提高 2分 不好 1分