return platformResourceType;
}
private ResourceType parseServerDescriptor(ServerDescriptor serverDescriptor, ResourceType parentServerType)
throws InvalidPluginDescriptorException {
ResourceType serverResourceType;
String sourcePlugin = serverDescriptor.getSourcePlugin();
String sourceServer = serverDescriptor.getSourceType();
sourcePlugin = (sourcePlugin == null) ? "" : sourcePlugin.trim();
sourceServer = (sourceServer == null) ? "" : sourceServer.trim();
if ((sourcePlugin.length() == 0) && (sourceServer.length() == 0)) {
// not using Embedded extension model
serverResourceType = new ResourceType(serverDescriptor.getName(), pluginDescriptor.getName(),
ResourceCategory.SERVER, parentServerType);
serverResourceType.setDescription(serverDescriptor.getDescription());
serverResourceType.setSubCategory(serverDescriptor.getSubCategory());
serverResourceType.setCreationDataType(convertCreationDataType(serverDescriptor.getCreationDataType()));
serverResourceType
.setCreateDeletePolicy(convertCreateDeletePolicy(serverDescriptor.getCreateDeletePolicy()));
serverResourceType.setSingleton(serverDescriptor.isSingleton());
parseResourceDescriptor(serverDescriptor, serverResourceType, null, null, null);
LOG.debug("Parsed server Resource type: " + serverResourceType);
} else if ((sourcePlugin.length() > 0) && (sourceServer.length() > 0)) {
// using Embedded extension model - the defined type is actually a copy of another plugin's server type
LOG.debug("Parsing embedded server type {" + pluginDescriptor.getName() + "}"
+ serverDescriptor.getName() + ", which extends server type {" + sourcePlugin + "}" + sourceServer + "...");
Map<String, ServerDescriptor> pluginServerDescriptors = getPluginServerDescriptors(sourcePlugin);
ServerDescriptor sourceServerDescriptor = pluginServerDescriptors.get(sourceServer);
if (sourceServerDescriptor == null) {
LOG.warn("There is no server type named [" + sourceServer + "] from a plugin named [" + sourcePlugin
+ "]. This is probably because that plugin is missing. Resource Type [{"
+ pluginDescriptor.getName() + "}" + serverDescriptor.getName() + "] will be ignored.");
return null;
}
serverResourceType = new ResourceType(serverDescriptor.getName(), pluginDescriptor.getName(),
ResourceCategory.SERVER, parentServerType);
// Let the plugin writer override these, or if not, parseResourceDescriptor() will pick up the source type's
// values.
serverResourceType.setDescription(serverDescriptor.getDescription());
serverResourceType.setSubCategory(serverDescriptor.getSubCategory());
serverResourceType.setCreationDataType(convertCreationDataType(serverDescriptor.getCreationDataType()));
serverResourceType
.setCreateDeletePolicy(convertCreateDeletePolicy(serverDescriptor.getCreateDeletePolicy()));
serverResourceType.setSingleton(serverDescriptor.isSingleton());
String discoveryClass;
String componentClass;
if (serverDescriptor.getDiscovery() != null) {
discoveryClass = getFullyQualifiedComponentClassName(pluginDescriptor.getPackage(), serverDescriptor
.getDiscovery());
} else {
discoveryClass = getFullyQualifiedComponentClassName(getPluginPackage(sourcePlugin),
sourceServerDescriptor.getDiscovery());
}
if (serverDescriptor.getClazz() != null) {
componentClass = getFullyQualifiedComponentClassName(pluginDescriptor.getPackage(), serverDescriptor
.getClazz());
} else {
componentClass = getFullyQualifiedComponentClassName(getPluginPackage(sourcePlugin),
sourceServerDescriptor.getClazz());
}
parseResourceDescriptor(sourceServerDescriptor, serverResourceType, discoveryClass, componentClass,
sourcePlugin);
// The above incorporates children from the source descriptor. The following incorporates
// children from this descriptor
// Look for child server types
for (ServerDescriptor childServerDescriptor : serverDescriptor.getServers()) {
parseServerDescriptor(childServerDescriptor, serverResourceType);
}
// Look for child service types
for (ServiceDescriptor childServiceDescriptor : serverDescriptor.getServices()) {
parseServiceDescriptor(childServiceDescriptor, serverResourceType, null);
}
} else {
// this should never happen - the XML parser should have failed to even get this far
throw new InvalidPluginDescriptorException("Both sourcePlugin and sourceType must be defined: "
+ serverDescriptor.getName());
}
serverResourceType.setSupportsManualAdd(serverDescriptor.isSupportsManualAdd());
serverResourceType.setSupportsMissingAvailabilityType(serverDescriptor.isSupportsMissingAvailabilityType());
// now see if we are using the Injection extension model
// if so, we need to inject the new resource type as a child to the parent plugin's types
RunsInsideType runsInside = serverDescriptor.getRunsInside();
if (runsInside != null) {
List<ParentResourceType> parentTypesDescriptor = runsInside.getParentResourceType();
for (ParentResourceType parentTypeDescriptor : parentTypesDescriptor) {
String parentTypeName = parentTypeDescriptor.getName();
String parentTypePlugin = parentTypeDescriptor.getPlugin();
ResourceType parentTypeToInjectInto = getResourceTypeFromPlugin(parentTypeName, parentTypePlugin);
if (parentTypeToInjectInto != null) {
// inject our new server resource type as a child type to the parent plugin's type
parentTypeToInjectInto.addChildResourceType(serverResourceType);
} else {
// The parent plugin owning the resource that this resource can run inside of does not exist.
// We will ignore this runs-inside declaration, thus allowing optional plugins to be missing.
LOG.warn("There is no resource type named [" + parentTypeName + "] from a plugin named ["
+ parentTypePlugin + "]. This is probably because that plugin is missing. Resource Type [{"