reference = ref;
break;
}
}
WebXml webXml = new WebXml();
webXml.addContextParam(DispatcherConfiguration.BUNDLE_NAME, siteBundle.getSymbolicName());
webXml.addContextParam(DispatcherConfiguration.BUNDLE_ENTRY, Site.BUNDLE_PATH);
// Webapp context root
String webappRoot = null;
if (reference != null && reference.getProperty(DispatcherConfiguration.WEBAPP_CONTEXT_ROOT) != null)
webappRoot = (String) reference.getProperty(DispatcherConfiguration.WEBAPP_CONTEXT_ROOT);
else if (System.getProperty(DispatcherConfiguration.WEBAPP_CONTEXT_ROOT) != null)
webappRoot = System.getProperty(DispatcherConfiguration.WEBAPP_CONTEXT_ROOT);
if (webappRoot == null)
webappRoot = DEFAULT_WEBAPP_CONTEXT_ROOT;
if (!webappRoot.startsWith("/"))
webappRoot = "/" + webappRoot;
webXml.addContextParam(DispatcherConfiguration.WEBAPP_CONTEXT_ROOT, webappRoot);
// Bundle name
webXml.addContextParam(DispatcherConfiguration.BUNDLE_NAME, siteBundle.getSymbolicName().toLowerCase());
// Bundle context root uri
String sitesRoot = null;
if (reference != null && reference.getProperty(DispatcherConfiguration.BUNDLE_CONTEXT_ROOT_URI) != null)
sitesRoot = (String) reference.getProperty(DispatcherConfiguration.BUNDLE_CONTEXT_ROOT_URI);
else if (System.getProperty(DispatcherConfiguration.BUNDLE_CONTEXT_ROOT_URI) != null)
sitesRoot = System.getProperty(DispatcherConfiguration.BUNDLE_CONTEXT_ROOT_URI);
if (sitesRoot == null)
sitesRoot = DEFAULT_BUNDLE_CONTEXT_ROOT_URI;
if (!sitesRoot.startsWith("/"))
sitesRoot = "/" + sitesRoot;
webXml.addContextParam(DispatcherConfiguration.BUNDLE_CONTEXT_ROOT_URI, sitesRoot);
// Bundle context root
sitesRoot = UrlUtils.concat(webappRoot, sitesRoot);
webXml.addContextParam(DispatcherConfiguration.BUNDLE_CONTEXT_ROOT, sitesRoot);
// Bundle uri
webXml.addContextParam(DispatcherConfiguration.BUNDLE_URI, site.getIdentifier());
// Bundle root
String bundleRoot = UrlUtils.concat(sitesRoot, site.getIdentifier());
webXml.addContextParam(DispatcherConfiguration.BUNDLE_ROOT, bundleRoot);
// Bundle entry
String bundleEntry = null;
if (reference != null && reference.getProperty(DispatcherConfiguration.BUNDLE_ENTRY) != null)
bundleEntry = (String) reference.getProperty(DispatcherConfiguration.BUNDLE_ENTRY);
else if (System.getProperty(DispatcherConfiguration.BUNDLE_ENTRY) != null)
bundleEntry = System.getProperty(DispatcherConfiguration.BUNDLE_ENTRY);
if (bundleEntry == null)
bundleEntry = Site.BUNDLE_PATH;
if (!bundleEntry.startsWith("/"))
bundleEntry = "/" + bundleEntry;
webXml.addContextParam(DispatcherConfiguration.BUNDLE_ENTRY, bundleEntry);
return webXml;
}