use of org.eclipse.jst.server.tomcat.core.internal.xml.server40.Server in project webtools.servertools by eclipse.
the class Tomcat80Configuration method getWebModules.
/**
* Return a list of the web modules in this server.
* @return java.util.List
*/
public List getWebModules() {
List<WebModule> list = new ArrayList<WebModule>();
try {
Context[] contexts = serverInstance.getContexts();
if (contexts != null) {
for (int i = 0; i < contexts.length; i++) {
Context context = contexts[i];
String reload = context.getReloadable();
if (reload == null)
reload = "false";
WebModule module = new WebModule(context.getPath(), context.getDocBase(), context.getSource(), reload.equalsIgnoreCase("true") ? true : false);
list.add(module);
}
}
} catch (Exception e) {
Trace.trace(Trace.SEVERE, "Error getting project refs", e);
}
return list;
}
use of org.eclipse.jst.server.tomcat.core.internal.xml.server40.Server in project webtools.servertools by eclipse.
the class Tomcat90Configuration method load.
/**
* @see TomcatConfiguration#load(IPath, IProgressMonitor)
*/
public void load(IPath path, IProgressMonitor monitor) throws CoreException {
try {
monitor = ProgressUtil.getMonitorFor(monitor);
monitor.beginTask(Messages.loadingTask, 7);
// check for catalina.policy to verify that this is a v9.0 config
InputStream in = new FileInputStream(path.append("catalina.policy").toFile());
in.read();
in.close();
monitor.worked(1);
serverFactory = new Factory();
serverFactory.setPackageName("org.eclipse.jst.server.tomcat.core.internal.xml.server40");
server = (Server) serverFactory.loadDocument(new FileInputStream(path.append("server.xml").toFile()));
serverInstance = new ServerInstance(server, null, null);
monitor.worked(1);
webAppDocument = new WebAppDocument(path.append("web.xml"));
monitor.worked(1);
File file = path.append("context.xml").toFile();
if (file.exists())
contextDocument = XMLUtil.getDocumentBuilder().parse(new InputSource(new FileInputStream(file)));
monitor.worked(1);
tomcatUsersDocument = XMLUtil.getDocumentBuilder().parse(new InputSource(new FileInputStream(path.append("tomcat-users.xml").toFile())));
monitor.worked(1);
// load policy file
policyFile = TomcatVersionHelper.getFileContents(new FileInputStream(path.append("catalina.policy").toFile()));
monitor.worked(1);
// load properties file
file = path.append("catalina.properties").toFile();
if (file.exists())
propertiesFile = TomcatVersionHelper.getFileContents(new FileInputStream(file));
else
propertiesFile = null;
monitor.worked(1);
if (monitor.isCanceled())
return;
monitor.done();
} catch (Exception e) {
Trace.trace(Trace.WARNING, "Could not load Tomcat v9.0 configuration from " + path.toOSString() + ": " + e.getMessage());
throw new CoreException(new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorCouldNotLoadConfiguration, path.toOSString()), e));
}
}
use of org.eclipse.jst.server.tomcat.core.internal.xml.server40.Server in project webtools.servertools by eclipse.
the class XmlTestCase method testServerInstance1.
/**
* Test behavior of ServerInstance
*/
public void testServerInstance1() {
Server server = getXml40Server("serverxml.test1");
assertNotNull(server);
ServerInstance si = new ServerInstance(server, "nonexistent_service", null);
assertNull(si.getService());
assertEquals("Service \"nonexistent_service\" was not found.", si.getStatus().getMessage());
si = new ServerInstance(server, null, null);
assertNotNull(si.getService());
assertEquals("Service", si.getService().getName());
si = new ServerInstance(server, "Service", null);
assertNotNull(si.getService());
assertNull(si.getEngine());
assertEquals("Engine element not found under Service \"Service\".", si.getStatus().getMessage());
}
use of org.eclipse.jst.server.tomcat.core.internal.xml.server40.Server in project webtools.servertools by eclipse.
the class XmlTestCase method getXml40Server.
private Server getXml40Server(String testId) {
Factory factory = new Factory();
factory.setPackageName("org.eclipse.jst.server.tomcat.core.internal.xml.server40");
try {
return (Server) factory.loadDocument(getXmlInputStream(testId));
} catch (Exception e) {
fail("Exception occurred loading " + testId + " XML: " + e.getMessage());
return null;
}
}
use of org.eclipse.jst.server.tomcat.core.internal.xml.server40.Server in project webtools.servertools by eclipse.
the class XmlTestCase method getXml32Server.
private org.eclipse.jst.server.tomcat.core.internal.xml.server32.Server getXml32Server(String testId) {
Factory factory = new Factory();
factory.setPackageName("org.eclipse.jst.server.tomcat.core.internal.xml.server32");
try {
return (org.eclipse.jst.server.tomcat.core.internal.xml.server32.Server) factory.loadDocument(getXmlInputStream(testId));
} catch (Exception e) {
fail("Exception occurred loading " + testId + " XML: " + e.getMessage());
return null;
}
}
Aggregations