hallo,
Pada blog kali ini saya akan menulis bagaimana menggunakan WLST command di java dengan studi kasus menambahkan group di user LDAP.
Langsung mulai saja WLST adalah :
The WebLogic Scripting Tool (WLST) is a command-line scripting interface that system administrators and operators use to monitor and manage WebLogic Server instances and domains. The WLST scripting environment is based on the Java scripting interpreter, Jython. In addition to WebLogic scripting functions, you can use common features of interpreted languages, including local variables, conditional variables, and flow control statements. WebLogic Server developers and administrators can extend the WebLogic scripting language to suit their environmental needs by following the Jython language syntax. See http://www.jython.org.Nah langsung saja pertama - tama saya membuat class dengan nama WLSTUtil.
- WLSTIntepreter berfungsi untuk wrapper Jython interpreter. Sehingga java client dapat menjalankan WLST
- execute commend berfungsi untuk mengeksekusi syntax jython.
package wlst; import org.python.util.InteractiveInterpreter; import weblogic.management.scripting.utils.WLSTInterpreter; public class WLSTUtil { private InteractiveInterpreter interpreter; private String weblogicUser="weblogic"; private String weblogicPassword="welcome1"; private String weblogicURL="192.168.1.159:7001"; public WLSTUtil() { super(); interpreter = new WLSTInterpreter(); } public void disConnect() { StringBuffer buffer = new StringBuffer(); buffer.append("disconnect(force='true')\n"); this.interpreter.exec(buffer.toString()); } public void connect() { StringBuffer buffer = new StringBuffer(); buffer.append("connect('" + this.weblogicUser + "','" + this.weblogicPassword + "','" + this.weblogicURL + "')"); this.interpreter.exec(buffer.toString()); } public void execute_command (String cmd) { StringBuffer buffer = new StringBuffer(); System.out.println ("* Execute WLST command : " + cmd ); buffer.append(cmd); interpreter.exec(buffer.toString()); System.out.println ("* Executed"); } }Dengan class diats kita sudah bisa terhubung dengan WLST, Saya akan memberikan contoh menambahkan menambah group ke user tertentu.
public void addUserToGroup(String username) { WLSTUtil wlstUtil; wlstUtil = new WLSTUtil(); wlstUtil.connect(); wlstUtil.execute_command("serverConfig()"); wlstUtil.execute_command("print 'Lookup DefaultAuthenticator' "); wlstUtil.execute_command("cmoDefaultAuthenticator=cmo.getSecurityConfiguration().getDefaultRealm().lookupAuthenticationProvider('DefaultAuthenticator')"); wlstUtil.execute_command("cmoDefaultAuthenticator.addMemberToGroup('" + this.groupName + "','" + username + "')"); wlstUtil.disConnect(); } public static void main(String[] args) { ServiceSetGroup serviceSetGroup = new ServiceSetGroup(); serviceSetGroup.addUserToGroup("andre"); }Diatas merupkan contoh scipting jython yang di panggil menggunakan java client. Selain itu jg kalian bisa create, configure dan manage weblogic domain menggukan WLST.
Demikian blog dari saya, semoga bermanfaat :)
sumber :
http://docs.oracle.com/cd/E21764_01/web.1111/e13715/using_wlst.htm#autoId0
No comments:
Post a Comment