Methods Summary |
---|
public static java.lang.String | checkContextRootUniqueness(com.sun.enterprise.config.ConfigContext ctx, java.lang.String appId, java.lang.String targetName, java.lang.String virtualServerList)Check the uniqueness of application's context-roots
among applications deployed to the given server instance's virtual servers
ConfigBean appBean = ApplicationHelper.findApplication(ctx, appId);
if(appBean==null)
{
throw new ConfigException(_strMgr.getString("applicationElementIsNotFoundForName", appId));
}
//get context roots for testing element
String[] ctxRoots = getAppContextRoots(appBean);
if(ctxRoots==null || ctxRoots.length<=0)
return null;
//create target by name
final Target target = TargetBuilder.INSTANCE.createTarget(
new TargetType[]{TargetType.CLUSTER, TargetType.SERVER, TargetType.DAS}, targetName, ctx);
//get apprefs for target
ApplicationRef[] refs = null;
if (target.getType() == TargetType.CLUSTER ||
target.getType() == TargetType.STANDALONE_CLUSTER)
{
refs = ClusterHelper.getApplicationReferences(ctx, targetName);
}
else
{
refs = ServerHelper.getApplicationReferences(ctx, targetName);
}
if(refs==null)
return null;
for(int i=0; i<refs.length; i++)
{
if(isVSListsIntersected(refs[i].getVirtualServers(), virtualServerList))
{
ConfigBean appBeanToCompare = ApplicationHelper.findApplication(ctx, refs[i].getRef());
if(appBeanToCompare==null)
{
throw new ConfigException(_strMgr.getString("applicationElementIsNotFoundForName", refs[i].getRef()));
}
if(((Object)appBeanToCompare)!=((Object)appBean))
{
String commonElement = (String)getFirstCommonElement(getAppContextRoots(appBeanToCompare), ctxRoots);
if(commonElement!=null)
return commonElement;
}
}
}
return null;
|
public static java.lang.String[] | getAppContextRoots(com.sun.enterprise.config.ConfigBean appBean)Get application context roots of standalone web-module or j2ee application
if (appBean instanceof WebModule)
{
return new String[]{((WebModule)appBean).getContextRoot()};
}
if (appBean instanceof J2eeApplication)
{
Object roots = appBean.getTransientProperty(CONTEXT_ROOTS_PROPERTY_NAME);
if(roots==null)
{
String appName = ((J2eeApplication)appBean).getName();
//call deployment helper
roots = DeploymentServiceUtils.getContextRootsForEmbeddedWebApp(appName);
appBean.setTransientProperty(CONTEXT_ROOTS_PROPERTY_NAME, roots);
}
else
{
if(!(roots instanceof String[]))
{
throw new ConfigException(_strMgr.getString("configRootsPropertyIsNotStringArray",
((J2eeApplication)appBean).getName()));
}
}
return (String[])roots;
}
return null;
|
public static java.lang.String[] | getAppContextRoots(com.sun.enterprise.config.ConfigContext ctx, java.lang.String appName)Get application context roots of standalone web-module or j2ee application
ConfigBean appBean = ApplicationHelper.findApplication(ctx, appName);
if(appBean==null)
{
throw new ConfigException(_strMgr.getString("applicationElementIsNotFoundForName", appName));
}
return getAppContextRoots(appBean);
|
private com.sun.enterprise.config.ConfigContext | getConfigContext()
return _configContext;
|
private static java.lang.Object | getFirstCommonElement(java.lang.Object[] arr1, java.lang.Object[] arr2)returns null if arrays have equal elements
if(arr1!=null && arr2!=null && arr1.length!=0 && arr2.length!=0)
{
for(int i=0; i<arr1.length; i++)
{
for(int j=0; j<arr2.length; j++)
{
if( ((String)arr1[i]).startsWith("/") ) {
arr1[i] = ((String)arr1[i]).substring(1);
}
if( ((String)arr2[j]).startsWith("/") ) {
arr2[j] = ((String)arr2[j]).substring(1);
}
if(arr1[i].equals(arr2[j])) {
return arr1[i];
}
}
}
}
return null;
|
private static boolean | isVSListsIntersected(java.lang.String vsList1, java.lang.String vsList2)returns true if any of lists are empty or not intersected
vsList1 is from existing application-ref and vsList2 is from the
the application being deployed
if (vsList1==null || vsList1.length()==0 ) {
return true;
}
if (vsList2 == null || vsList2.length()==0 ) {
String[] arr = vsList1.split(",");
if (arr.length == 1 && arr[0].equals(
com.sun.enterprise.web.VirtualServer.ADMIN_VS)) {
return false;
}
return true;
}
String[] arr1 = vsList1.split(",");
String[] arr2 = vsList2.split(",");
if(arr1.length==0 || arr2.length==0)
return true;
return (getFirstCommonElement(arr1, arr2)!=null);
|
public static void | resetAppContextRoots(com.sun.enterprise.config.ConfigBean appBean, boolean bForceToSetActualValue)Resets config bean context-roots transient property value
(ingnored if not j2ee-application)
if (appBean instanceof J2eeApplication)
{
appBean.setTransientProperty(CONTEXT_ROOTS_PROPERTY_NAME, null);
if(bForceToSetActualValue)
getAppContextRoots(appBean); //forces to read descriptor xml
}
|
public static void | resetAppContextRoots(com.sun.enterprise.config.ConfigContext ctx, java.lang.String appName, boolean bForceToSetActualValue)Resets config bean context-roots transient property value
(ingnored/no exception if not j2ee-application)
ConfigBean appBean = ApplicationHelper.findApplication(ctx, appName);
if(appBean==null)
{
throw new ConfigException(_strMgr.getString("applicationElementIsNotFoundForName", appName));
}
resetAppContextRoots(appBean, bForceToSetActualValue);
|