use of org.apache.catalina.Host in project tomcat by apache.
the class StandardContextSF method store.
/**
* Store a Context as Separate file as configFile value from context exists.
* filename can be relative to catalina.base.
*
* @see org.apache.catalina.storeconfig.IStoreFactory#store(java.io.PrintWriter,
* int, java.lang.Object)
*/
@Override
public void store(PrintWriter aWriter, int indent, Object aContext) throws Exception {
if (aContext instanceof StandardContext) {
StoreDescription desc = getRegistry().findDescription(aContext.getClass());
if (desc.isStoreSeparate()) {
URL configFile = ((StandardContext) aContext).getConfigFile();
if (configFile != null) {
if (desc.isExternalAllowed()) {
if (desc.isBackup())
storeWithBackup((StandardContext) aContext);
else
storeContextSeparate(aWriter, indent, (StandardContext) aContext);
return;
}
} else if (desc.isExternalOnly()) {
// Set a configFile so that the configuration is actually saved
Context context = ((StandardContext) aContext);
Host host = (Host) context.getParent();
File configBase = host.getConfigBaseFile();
ContextName cn = new ContextName(context.getName(), false);
String baseName = cn.getBaseName();
File xml = new File(configBase, baseName + ".xml");
context.setConfigFile(xml.toURI().toURL());
if (desc.isBackup())
storeWithBackup((StandardContext) aContext);
else
storeContextSeparate(aWriter, indent, (StandardContext) aContext);
return;
}
}
}
super.store(aWriter, indent, aContext);
}
use of org.apache.catalina.Host in project ofbiz-framework by apache.
the class CatalinaContainer method prepareHost.
private Host prepareHost(Tomcat tomcat, List<String> virtualHosts) {
Host host;
if (UtilValidate.isEmpty(virtualHosts)) {
host = tomcat.getHost();
} else {
host = prepareVirtualHost(tomcat, virtualHosts);
}
host.setAppBase(System.getProperty("ofbiz.home") + "/framework/catalina/hosts");
host.setDeployOnStartup(false);
host.setBackgroundProcessorDelay(5);
host.setAutoDeploy(false);
((StandardHost) host).setWorkDir(new File(System.getProperty(Globals.CATALINA_HOME_PROP), "work" + File.separator + host.getName()).getAbsolutePath());
return host;
}
use of org.apache.catalina.Host in project tomcat70 by apache.
the class MBeanFactory method getParentContainerFromParent.
/**
* Get Parent ContainerBase to add its child component
* from parent's ObjectName
*/
private ContainerBase getParentContainerFromParent(ObjectName pname) throws Exception {
String type = pname.getKeyProperty("type");
String j2eeType = pname.getKeyProperty("j2eeType");
Service service = getService(pname);
StandardEngine engine = (StandardEngine) service.getContainer();
if ((j2eeType != null) && (j2eeType.equals("WebModule"))) {
String name = pname.getKeyProperty("name");
name = name.substring(2);
int i = name.indexOf('/');
String hostName = name.substring(0, i);
String path = name.substring(i);
Host host = (Host) engine.findChild(hostName);
String pathStr = getPathStr(path);
StandardContext context = (StandardContext) host.findChild(pathStr);
return context;
} else if (type != null) {
if (type.equals("Engine")) {
return engine;
} else if (type.equals("Host")) {
String hostName = pname.getKeyProperty("host");
StandardHost host = (StandardHost) engine.findChild(hostName);
return host;
}
}
return null;
}
use of org.apache.catalina.Host in project tomcat70 by apache.
the class MBeanUtils method createObjectName.
/**
* Create an <code>ObjectName</code> for this
* <code>Loader</code> object.
*
* @param domain Domain in which this name is to be created
* @param loader The Loader to be named
*
* @exception MalformedObjectNameException if a name cannot be created
*/
static ObjectName createObjectName(String domain, Loader loader) throws MalformedObjectNameException {
ObjectName name = null;
Container container = loader.getContainer();
if (container instanceof Engine) {
name = new ObjectName(domain + ":type=Loader");
} else if (container instanceof Host) {
name = new ObjectName(domain + ":type=Loader,host=" + container.getName());
} else if (container instanceof Context) {
Context context = ((Context) container);
ContextName cn = new ContextName(context.getName(), false);
Container host = context.getParent();
name = new ObjectName(domain + ":type=Loader,context=" + cn.getDisplayName() + ",host=" + host.getName());
}
return (name);
}
use of org.apache.catalina.Host in project tomcat70 by apache.
the class MBeanUtils method createObjectName.
/**
* Create an <code>ObjectName</code> for this
* <code>Context</code> object.
*
* @param domain Domain in which this name is to be created
* @param context The Context to be named
*
* @exception MalformedObjectNameException if a name cannot be created
* @deprecated Unused. Will be removed in Tomcat 8.0.x
*/
@Deprecated
static ObjectName createObjectName(String domain, Context context) throws MalformedObjectNameException {
ObjectName name = null;
Host host = (Host) context.getParent();
ContextName cn = new ContextName(context.getName(), false);
name = new ObjectName(domain + ":j2eeType=WebModule,name=//" + host.getName() + cn.getDisplayName() + ",J2EEApplication=none,J2EEServer=none");
return (name);
}
Aggregations