Upload
maarten-smeets
View
295
Download
2
Embed Size (px)
Citation preview
Introduction
• About AMIS– Located in the Netherlands– Oracle Award winning partner
• Maarten Smeets– Senior Oracle Integration Consultant– Experience with Oracle SOA Suite since 2007– Well certified (SOA, BPM, Java, SQL,
PL/SQL among others)– Author of 100+ blog articles (http://javaoraclesoa.blogspot.com)– Working @ AMIS since 2014
@MaartenSmeetsNL
https://nl.linkedin.com/in/smeetsm
Agenda
• Introduction
• Using Java within WLST
• Using WLST as Jython module
• A look into the future
• Summary
Agenda
• Introduction
• Using Java within WLST
• Using WLST as Jython module
• A look into the future
• Summary
IntroductionWebLogic Scripting Tool
http://www.oracle.com/technetwork/middleware/weblogic/overview/weblogic-server-12-1-3-datasheet-2227036.pdf
IntroductionBased on popular languages
• WLST is based on Jython. Jython is an implementation of the Python language for the Java platform
Python ranks as 5th most popular programming
languageJava ranks as most popular programming language
TIOBE index 2015
IntroductionMbean trees
• domainConfig– configuration hierarchy of the entire domain; represents the configuration MBeans in
RuntimeMBeanServer– read only
• serverConfig– configuration hierarchy (configuration MBeans) of the server your are connected to– read only
• domainRuntime– hierarchy of runtime MBeans for the entire domain– read only
• serverRuntime– hierarchy of runtime MBeans for the server you are connected to– read only
• edit– writable domain configuration with pending changes; represents the configuration MBeans in the
EditMBeanServer• jndi
– read-only JNDI tree for the server you are connected to• custom
– list of custom MBeans– can be hierarchical/grouped if MBeans use namespaces appropriately
http://www.slideshare.net/jambay/weblogic-scripting-tool-overview
IntroductionWLST Configuration
http://stackoverflow.com/questions/18105396/wlst-command-to-update-jdbc-datasource-url
IntroductionWLST Management
http://wlstbyexamples.blogspot.nl/2009/10/dynamic-domain-creation-with-wlst.html#.VmGRnnYvdD8
IntroductionWLST Monitoring
http://wlstbyexamples.blogspot.nl/2010/02/server-state-using-wlst.html#.VmGYinYvdD8
Agenda
• Introduction
• Using Java within WLST
• Using WLST as Jython module
• A look into the future
• Summary
Using Java within WLSTWhy?
• Extend WLST with Java API’s– Unleash the power of Java API’s on your WLST scripts!
• Rewrite Java as WLST– WLST can easily be executed by operations on an application server
Using Java with WLSTCreating instances
Java WLST
Hashtable jndiProps = new Hashtable(); jndiProps = Hashtable()
Types are determined by inference
Using Java with WLSTMethods
Java WLST
private String getDNToUndeploy(CompositeData[] compositeData) throws Exception
def getDNToUndeploy(compositeData):
Python has no true private methodsExceptions are determined by inference
Using Java with WLSTArrays
Java WLST
int[] intArray = { 1, 2, 3}; from jarray import array intArray = array ([1, 2, 3],’i’)
Java primitives arrays can be created in Jython with the jarray module
Using Java with WLSTExample: Java
http://javaoraclesoa.blogspot.co.uk/2015/05/unleash-power-of-java-apis-on-your-wlst.html
Agenda
• Introduction
• Using Java with WLST
• Using WLST as Jython module
• A look into the future
• Summary
Using WLST as Jython moduleWhy?
• WLST uses Jython 2.2.1 (2007)
• Current version of Jython is 2.7 (2015)
• Jython 2.7 has many nice things, for example;– Package management: pip install logging– XML API’s: ElementTree– Easy multithreading: multiprocessing– Easy argument parsing: argparse
Using WLST as Jython moduleArgument parsing in WLST
import getopturl = Noneuser = Nonepassword = None
opts, args = getopt.getopt(sys.argv[1:], "e:u:p:")for opt, arg in opts: print opt, arg if opt in "-e": env = arg if opt in "-p": password = arg if opt in "-u": user = arg
print "URL: "+urlprint "Username: "+usernameprint "Password: "+password
import sys;print "URL: "+sys.argv[1]print "Username: "+sys.argv[2]print "Password: "+sys.argv[3]
Manual argument checking and processing!
Using WLST as Jython moduleArgument parsing in Jython 2.7
import argparseparser = argparse.ArgumentParser()parser.add_argument("username", type=string, help="username")parser.add_argument("password", type=string, help="password")parser.add_argument("url", type=string, help="url")args = parser.parse_args()
print "URL: "+args.urlprint "Username: "+args.usernameprint "Password: "+args.password
Type checkingOptional/required argumentsHelp generationMinimal coding
Using WLST as Jython moduleModule installation
WLST (Jython 2.2.1) Jython 2.7Find and download aJython 2.2.1 compatible module
Copy the module to WL_HOME/common/wlst/modules
pip install <module name>
Using WLST as Jython moduleHow?
• You need the classpath
• You need the Jython module path
• You need a WLST Jython module
Using WLST as Jython moduleHow?
• You need the classpath
• You need the Jython module path
• You need a WLST Jython module
Using WLST as Jython moduleClasspath
• Start wlst.sh / wlst.cmd– import os– print os.environ[‘CLASSPATH’]
• Add the wlfullclient.jar and <WLS_HOME>/oracle_common/modules/*
• Done
Using WLST as Jython moduleHow?
• You need the classpath
• You need the Jython module path
• You need a WLST Jython module
Using WLST as Jython moduleHow?
• You need the classpath
• You need the Jython module path
• You need a WLST Jython module
Using WLST as Jython module
• Start wlst.sh or wlst.cmd– writeIniFile("wl.py")
• Replace ‘origPrompt = sys.ps1’ with ‘origPrompt = ">>>“’
• Done
Using WLST as Jython module
• Create a startjython.sh script to set the CLASSPATH and JYTHONPATH
• Ready to roll!
import wl wl.connect("weblogic","Welcome01", "t3://localhost:7101") mbServers= wl.getMBean("Servers") servers= mbServers.getServers() for server in servers : print( "Server Name: " + server.getName() ) print( "Done." )
Agenda
• Introduction
• Using Java with WLST
• Using WLST as Jython module
• A look into the future
• Summary
A look into the futureNew WLST features in 12c
• WLST 12c introduces Jline integration – use up and down arrows to browse command history
• WebLogic Server 12c provides a Maven plugin to allow execution of WLST scripts in for example Continuous Delivery pipelines– https://docs.oracle.com/cd/E24329_01/web.1211/e24368/maven.htm#WLPRG700
• SOA Suite 12.2.1 instance patching only supported with WLST (not Ant or Maven)
• WLST 12.2.1 offline mode does not support partitions (yet?) . WLST 12.2.1 online does support partitions (multitenancy)
A look into the futureHowever…
• wlfullclient.jar is deprecated since 12.2.1 (related to multitenancy?)– http://docs.oracle.com/middleware/1221/wls/NOTES/whatsnew.htm#NOTES155
• RESTful Management Services replacing WLST in the cloud?– http://docs.oracle.com/middleware/1221/wls/NOTES/whatsnew.htm#NOTES353
• WLST has not seen a new Jython version since 11g
Agenda
• Introduction
• Using Java with WLST
• Using WLST as Jython module
• A look into the future
• Summary
Summary
• WebLogic Scripting Tool is based on popular programming languages
• WebLogic Scripting Tool has many uses
• WebLogic Scripting Tool is very flexible– can be extended with Java API’s– can be used as Jython module
• WebLogic Server is changing because of Oracle Cloud requirements
Questions
@MaartenSmeetsNL
https://nl.linkedin.com/in/smeetsm Download the presentation at http://bit.ly/1jH5ywP