protected Target getTarget(String targetName) throws MBeanException
{
try
{
Target target = TargetBuilder.INSTANCE.createTarget(VALID_CREATE_DELETE_TYPES, targetName,
getConfigContext());
if (target.getType() == TargetType.SERVER ||
target.getType() == TargetType.DAS) {
//If we are operating on a server, ensure that the server is the only entity
//referencing its config
String configName = ServerHelper.getConfigForServer(getConfigContext(),
target.getName()).getName();
if (!ConfigAPIHelper.isConfigurationReferencedByServerOnly(getConfigContext(),
configName, target.getName())) {
throw new ConfigException(localStrings.getString(
"configurationHasMultipleRefs", target.getName(), configName,
ConfigAPIHelper.getConfigurationReferenceesAsString(
getConfigContext(), configName)));
}
} else if (target.getType() == TargetType.CLUSTER) {
//If we are operating on a cluster, ensure that the cluster is the only entity
//referencing its config
String configName = ClusterHelper.getConfigForCluster(getConfigContext(),
target.getName()).getName();
if (!ConfigAPIHelper.isConfigurationReferencedByClusterOnly(getConfigContext(),
configName, target.getName())) {
throw new ConfigException(localStrings.getString(
"configurationHasMultipleRefs", target.getName(), configName,
ConfigAPIHelper.getConfigurationReferenceesAsString(
getConfigContext(), configName)));
}
}
return target;