我已經能夠使用下面的Jython腳本成功配置資源環境條目。我使用本地應用程序服務器bin目錄中的ws_admin程序調用Jython腳本。使用ant&jython的WebSphere配置
我在一個團隊工作,螞蟻是我們構建過程中的首選技術。
我已經瀏覽了Web上有關使用ant配置WebSphere的文檔,到目前爲止,它看起來像我主要能夠從螞蟻調用ws_admin這樣的程序。
是否可以使用ant直接配置資源環境條目而不是使用Jython或Jacl腳本?如果沒有,我該如何設置ant任務來減少設置資源環境條目所需的Jython數量?
這是我設置資源環境條目的當前Jython腳本。最終尋找各種方法來減少我們對Jython的依賴......
# Set up Variables used within this script
objServerAttrs = AdminControl.completeObjectName('WebSphere:type=Server,*')
node = AdminControl.getAttribute(objServerAttrs, 'nodeName')
server = AdminControl.getAttribute(objServerAttrs, 'name')
provider = "Test_ConfigurationProvider"
providerFactory = "com.DG_ConfigurationFactory"
providerClass = "com.DG_Configuration"
# Function for creating resource custom properties
def createResourceCustomProperty(envEntry, propName, propValue):
propSet = AdminConfig.showAttribute(envEntry, 'propertySet')
if propSet == None:
propSet = AdminConfig.create('J2EEResourcePropertySet',envEntry,[])
name = ['name', propName]
value = ['value', propValue]
propAttrs = [name, value]
AdminConfig.create('J2EEResourceProperty', propSet, propAttrs)
return
# Create the resource environment provider
AdminResources.createResourceEnvProvider(node, server, provider)
AdminResources.createResourceEnvProviderRef(node,server,provider, providerFactory, providerClass)
# Create the resource environment entries
## Context Configuration
envEntry = AdminResources.createResourceEnvEntries(node,server,provider, "Context Configuration", "test-config/context")
createResourceCustomProperty(envEntry, "deployment.environment", "IDE")
createResourceCustomProperty(envEntry, "server.context", "com.context.DG_WebSphereServerContext")
createResourceCustomProperty(envEntry, "user.context", "com.context.DG_WebSphereUserContext")
createResourceCustomProperty(envEntry, "log.directory", "C:/Development/WebSphere/Logs")
createResourceCustomProperty (envEntry, "file.directory", "C:/Development/WebSphere/AppFiles")
## Mail Configuration
envEntry = AdminResources.createResourceEnvEntries(node,server,provider, "Mail Configuration", "test-config/mail")
createResourceCustomProperty(envEntry, "enabled", "false")
createResourceCustomProperty(envEntry, "mailSessionJndiName", "mail/MailSession")
## User Repository Configuration
envEntry = AdminResources.createResourceEnvEntries(node, server, provider, "User Repository Configuration", "test-config/userRepository")
createResourceCustomProperty(envEntry, "ldap.provider.url", "ldap://test.com:389/cn=users,dc=com")
createResourceCustomProperty (envEntry, "ldap.security.principal", "cn=was_user,cn=users,dc=com")
# Save changes to the configuration
AdminConfig.save()
非常好的信息 - 謝謝。 – 2013-03-20 14:45:30