Created
June 13, 2012 01:48
-
-
Save jsanda/2921298 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function findResourceType(plugin, resourceTypeName) { | |
var criteria = ResourceTypeCriteria(); | |
criteria.strict = true; | |
criteria.addFilterPluginName(plugin); | |
criteria.addFilterName(resourceTypeName); | |
var types = ResourceTypeManager.findResourceTypesByCriteria(criteria); | |
if (types.size() > 0) { | |
return types.get(0); | |
} | |
return null; | |
} | |
function findPlatform(hostname) { | |
var criteria = new ResourceCriteria(); | |
criteria.addFilterResourceCategories([ResourceCategory.PLATFORM]); | |
criteria.addFilterResourceKey(hostname); | |
var resources = ResourceManager.findResourcesByCriteria(criteria); | |
if (resources.size() > 0) { | |
return resources.get(0); | |
} | |
return null; | |
} | |
function createTomcatConnectionProps(path) { | |
var config = new Configuration(); | |
config.put(new PropertySimple('catalinaBase', path)); | |
config.put(new PropertySimple('installationPath', path)); | |
config.put(new PropertySimple('connectorAddress', | |
'service:jmx:rmi:///jndi/rmi://localhost:9876/jxrmi')); | |
config.put(new PropertySimple('type', | |
'org.mc4j.ems.connection.support.metadata.Tomcat55ConnectionTypeDescriptor')); | |
return config; | |
} | |
function manuallyAddTomcat(hostname, path) { | |
var platform = findPlatform(hostname); | |
var type = findResourceType('Tomcat', 'Tomcat Server'); | |
var pluginConfig = createTomcatConnectionProps(path); | |
return DiscoveryBoss.manuallyAddResource(type.id, platform.id, | |
pluginConfig); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment