ApplicationReferenceHelperpublic class ApplicationReferenceHelper extends Object implements com.sun.enterprise.admin.util.IAdminConstants
Fields Summary |
---|
private static final com.sun.enterprise.util.i18n.StringManager | _strMgr | private com.sun.enterprise.config.ConfigContext | _configContext | private static final com.sun.enterprise.admin.target.TargetType[] | targetTypes |
Methods Summary |
---|
private void | addApplicationReferenceToCluster(com.sun.enterprise.config.serverbeans.Cluster cluster, boolean enabled, java.lang.String virtualServers, java.lang.String referenceName)Add an application reference to the cluster.
NOTE: Much of this functionality is duplicated in ResourcesMBeanHelper. As
such be aware that bugs fixed here should be fixed there as well.
ApplicationRef ref = cluster.getApplicationRefByRef(referenceName);
if (ref != null) {
//Application ref already exists in cluster
throw new ConfigException(_strMgr.getString("clusterApplicationRefAlreadyExists",
referenceName, cluster.getName()));
}
ref = new ApplicationRef();
ref.setEnabled(enabled);
ref.setRef(referenceName);
ref.setVirtualServers(virtualServers);
cluster.addApplicationRef(ref, BaseConfigMBean.OVERWRITE);
| private void | addApplicationReferenceToClusteredServers(com.sun.enterprise.config.serverbeans.Cluster cluster, com.sun.enterprise.config.serverbeans.Server[] servers, boolean enabled, java.lang.String virtualServers, java.lang.String referenceName)Add an application reference to the server instances in the cluster.
NOTE: Much of this functionality is duplicated in ResourcesMBeanHelper. As
such be aware that bugs fixed here should be fixed there as well.
for (int i = 0; i < servers.length; i++) {
final ApplicationRef ref = servers[i].getApplicationRefByRef(referenceName);
if (ref != null) {
//This indicates that the cluster is in an inconsistent state. Some of the
//instances in the cluster have the ref and some do not.
throw new ConfigException(_strMgr.getString("clusterApplicationRefInconsistency",
referenceName, cluster.getName(), servers[i].getName()));
}
addApplicationReferenceToServer(servers[i], enabled, virtualServers,
referenceName);
}
| private void | addApplicationReferenceToServer(com.sun.enterprise.config.serverbeans.Server server, boolean enabled, java.lang.String virtualServers, java.lang.String referenceName)Add an application reference to a single server instance.
NOTE: Much of this functionality is duplicated in ResourcesMBeanHelper. As
such be aware that bugs fixed here should be fixed there as well.
ApplicationRef ref = server.getApplicationRefByRef(referenceName);
if (ref != null) {
//Resource ref already exists in server
throw new ConfigException(_strMgr.getString("serverApplicationRefAlreadyExists",
referenceName, server.getName()));
}
ref = new ApplicationRef();
ref.setEnabled(enabled);
ref.setRef(referenceName);
ref.setVirtualServers(virtualServers);
server.addApplicationRef(ref, BaseConfigMBean.OVERWRITE);
| public void | createApplicationReference(com.sun.enterprise.admin.target.TargetType[] validTypes, java.lang.String targetName, boolean enabled, java.lang.String virtualServers, java.lang.String referenceName)Create an application reference in the specified target (cluster
unclustered server).
NOTE: Much of this functionality is duplicated in ResourcesMBeanHelper. As
such be aware that bugs fixed here should be fixed there as well.
final ConfigContext configContext = getConfigContext();
//Validate that there is indeed a resource with the specified name.
final String type = getApplicationType(referenceName);
final Target target = TargetBuilder.INSTANCE.createTarget(
validTypes, targetName, configContext);
if (target.getType() == TargetType.CLUSTER) {
final Cluster cluster = ClusterHelper.getClusterByName(configContext, target.getName());
addApplicationReferenceToCluster(cluster, enabled, virtualServers, referenceName);
final Server[] servers = ServerHelper.getServersInCluster(configContext, target.getName());
addApplicationReferenceToClusteredServers(cluster, servers, enabled,
virtualServers, referenceName);
} else if (target.getType() == TargetType.SERVER ||
target.getType() == TargetType.DAS) {
final Server server = ServerHelper.getServerByName(configContext, target.getName());
addApplicationReferenceToServer(server, enabled, virtualServers, referenceName);
} else {
throw new ConfigException(_strMgr.getString("invalidClusterOrServerTarget",
target.getName()));
}
| public void | deleteApplicationReference(com.sun.enterprise.admin.target.TargetType[] validTypes, java.lang.String targetName, java.lang.String referenceName)Delete application reference from the given target (cluster or unclustered
server instance).
NOTE: Much of this functionality is duplicated in ResourcesMBeanHelper. As
such be aware that bugs fixed here should be fixed there as well.
final ConfigContext configContext = getConfigContext();
//Validate that there is indeed a resource with the specified name.
final String type = getApplicationType(referenceName);
final Target target = TargetBuilder.INSTANCE.createTarget(
validTypes, targetName, configContext);
if (target.getType() == TargetType.SERVER ||
target.getType() == TargetType.DAS) {
final Server server = ServerHelper.getServerByName(configContext, targetName);
deleteApplicationReferenceFromServer(server, referenceName);
} else if (target.getType() == TargetType.CLUSTER) {
final Cluster cluster = ClusterHelper.getClusterByName(configContext, targetName);
deleteApplicationReferenceFromCluster(cluster, referenceName);
final Server[] servers = ServerHelper.getServersInCluster(configContext, targetName);
deleteApplicationReferenceFromClusteredServers(cluster, servers, referenceName);
} else {
throw new ConfigException(_strMgr.getString("invalidClusterOrServerTarget",
targetName));
}
| private void | deleteApplicationReferenceFromCluster(com.sun.enterprise.config.serverbeans.Cluster cluster, java.lang.String referenceName)Delete an application reference from the cluster.
NOTE: Much of this functionality is duplicated in ResourcesMBeanHelper. As
such be aware that bugs fixed here should be fixed there as well.
final ApplicationRef ref = cluster.getApplicationRefByRef(referenceName);
if (ref == null) {
//Application ref already exists in cluster
throw new ConfigException(_strMgr.getString("clusterApplicationRefDoesNotExist",
cluster.getName(), referenceName));
}
cluster.removeApplicationRef(ref, BaseConfigMBean.OVERWRITE);
| private void | deleteApplicationReferenceFromClusteredServers(com.sun.enterprise.config.serverbeans.Cluster cluster, com.sun.enterprise.config.serverbeans.Server[] servers, java.lang.String referenceName)Delete the application references from all servers that are part of a cluster.
NOTE: Much of this functionality is duplicated in ResourcesMBeanHelper. As
such be aware that bugs fixed here should be fixed there as well.
for (int i = 0; i < servers.length; i++) {
final ApplicationRef ref = servers[i].getApplicationRefByRef(referenceName);
if (ref == null) {
//This indicates that the cluster is in an inconsistent state. Some of the
//instances in the cluster have the ref and some do not.
throw new ConfigException(_strMgr.getString("clusterApplicationRefInconsistency",
referenceName, cluster.getName(), servers[i].getName()));
}
deleteApplicationReferenceFromServer(servers[i], referenceName);
}
| private void | deleteApplicationReferenceFromServer(com.sun.enterprise.config.serverbeans.Server server, java.lang.String referenceName)Delete application reference from a single server instance.
NOTE: Much of this functionality is duplicated in ResourcesMBeanHelper. As
such be aware that bugs fixed here should be fixed there as well.
final ApplicationRef ref = server.getApplicationRefByRef(referenceName);
if (ref == null) {
//Application ref already exists in server
throw new ConfigException(_strMgr.getString("serverApplicationRefDoesNotExist",
server.getName(), referenceName));
}
server.removeApplicationRef(ref, BaseConfigMBean.OVERWRITE);
| public static com.sun.enterprise.config.serverbeans.ApplicationRef | findCurrentAppRef(DeploymentContext deploymentCtx, java.lang.String targetName, java.lang.String appName)Locates the app ref for the specified application on the given target.
ApplicationRef appRef = null;
final ConfigContext configContext = deploymentCtx.getConfigContext();
final Target target = TargetBuilder.INSTANCE.createTarget(
targetTypes, targetName, configContext);
if (target.getType() == TargetType.CLUSTER ||
target.getType() == TargetType.STANDALONE_CLUSTER)
{
Cluster cluster = ClusterHelper.getClusterByName(
configContext, target.getName());
if (cluster != null) {
appRef = cluster.getApplicationRefByRef(appName);
}
}
else
{
Server server = ServerHelper.getServerByName(
configContext, target.getName());
if (server != null) {
appRef = server.getApplicationRefByRef(appName);
}
}
return appRef;
| protected java.lang.String | getApplicationType(java.lang.String appName)Given the application name, return its type.
NOTE: Much of this functionality is duplicated in ResourcesMBeanHelper. As
such be aware that bugs fixed here should be fixed there as well.
final ConfigContext configContext = getConfigContext();
final Domain domain = ConfigAPIHelper.getDomainConfigBean(configContext);
final Applications applications = domain.getApplications();
if (applications.getAppclientModuleByName(appName) != null) {
return ServerTags.APPCLIENT_MODULE;
} else if (applications.getConnectorModuleByName(appName) != null) {
return ServerTags.CONNECTOR_MODULE;
} else if (applications.getEjbModuleByName(appName) != null) {
return ServerTags.EJB_MODULE;
} else if (applications.getJ2eeApplicationByName(appName) != null) {
return ServerTags.J2EE_APPLICATION;
} else if (applications.getLifecycleModuleByName(appName) != null) {
return ServerTags.LIFECYCLE_MODULE;
} else if (applications.getWebModuleByName(appName) != null) {
return ServerTags.WEB_MODULE;
} else {
throw new ConfigException(_strMgr.getString("applicationDoesNotExist",
appName));
}
| private com.sun.enterprise.config.ConfigContext | getConfigContext()
return _configContext;
|
|