use of org.kie.dmn.model.v1_1.Context in project webtools.servertools by eclipse.
the class TomcatVersionHelper method loadSeparateContextFiles.
private static void loadSeparateContextFiles(File contextDir, Factory factory, Map<File, Context> projectContexts) {
File[] contextFiles = contextDir.listFiles(new FilenameFilter() {
public boolean accept(File dir, String name) {
return name.toLowerCase().endsWith(".xml");
}
});
for (int j = 0; j < contextFiles.length; j++) {
File ctx = contextFiles[j];
Context context = loadContextFile(ctx);
if (context != null) {
// TODO Handle non-project contexts when their removal can be addressed
String memento = context.getSource();
if (memento != null) {
projectContexts.put(ctx, context);
}
}
}
}
use of org.kie.dmn.model.v1_1.Context in project webtools.servertools by eclipse.
the class TomcatVersionHelper method getCatalinaServerInstance.
/**
* Gets a ServerInstance for the specified server.xml, Service name,
* and Host name. Returns null if server.xml does not exist
* or an error occurs.
*
* @param serverXml path to previously published server.xml
* @param serviceName name of Service to be used by this instance or null
* @param hostName name of Host to be used by this instance or null
* @return ServerInstance for specified server.xml using specified
* Service and Host names. null if server.xml does not exist.
* @throws FileNotFoundException should not occur since existence is tested
* @throws IOException if there is an error reading server.xml
* @throws SAXException if there is a syntax error in server.xml
*/
public static ServerInstance getCatalinaServerInstance(IPath serverXml, String serviceName, String hostName) throws FileNotFoundException, IOException, SAXException {
ServerInstance serverInstance = null;
Factory factory = new Factory();
factory.setPackageName("org.eclipse.jst.server.tomcat.core.internal.xml.server40");
File serverFile = serverXml.toFile();
if (serverFile.exists()) {
Server server = (Server) factory.loadDocument(new FileInputStream(serverFile));
serverInstance = new ServerInstance(server, serviceName, hostName);
IPath contextPath = serverInstance.getContextXmlDirectory(serverXml.removeLastSegments(1));
File contextDir = contextPath.toFile();
if (contextDir.exists()) {
Map<File, Context> projectContexts = new HashMap<File, Context>();
loadSeparateContextFiles(contextPath.toFile(), factory, projectContexts);
// add any separately saved contexts
Host host = serverInstance.getHost();
Collection contexts = projectContexts.values();
Iterator iter = contexts.iterator();
while (iter.hasNext()) {
Context context = (Context) iter.next();
host.importNode(context.getElementNode(), true);
}
// TODO Add handling for non-project contexts when there removal can be addressed
}
}
return serverInstance;
}
use of org.kie.dmn.model.v1_1.Context in project webtools.servertools by eclipse.
the class Tomcat50Configuration method modifyWebModule.
/**
* Change a web module.
* @param index int
* @param docBase java.lang.String
* @param path java.lang.String
* @param reloadable boolean
*/
public void modifyWebModule(int index, String docBase, String path, boolean reloadable) {
try {
Context context = serverInstance.getContext(index);
if (context != null) {
context.setPath(path);
context.setDocBase(docBase);
context.setReloadable(reloadable ? "true" : "false");
isServerDirty = true;
WebModule module = new WebModule(path, docBase, null, reloadable);
firePropertyChangeEvent(MODIFY_WEB_MODULE_PROPERTY, new Integer(index), module);
}
} catch (Exception e) {
Trace.trace(Trace.SEVERE, "Error modifying web module " + index, e);
}
}
use of org.kie.dmn.model.v1_1.Context in project webtools.servertools by eclipse.
the class Tomcat55Configuration method modifyWebModule.
/**
* Change a web module.
* @param index int
* @param docBase java.lang.String
* @param path java.lang.String
* @param reloadable boolean
*/
public void modifyWebModule(int index, String docBase, String path, boolean reloadable) {
try {
Context context = serverInstance.getContext(index);
if (context != null) {
context.setPath(path);
context.setDocBase(docBase);
context.setReloadable(reloadable ? "true" : "false");
isServerDirty = true;
WebModule module = new WebModule(path, docBase, null, reloadable);
firePropertyChangeEvent(MODIFY_WEB_MODULE_PROPERTY, new Integer(index), module);
}
} catch (Exception e) {
Trace.trace(Trace.SEVERE, "Error modifying web module " + index, e);
}
}
use of org.kie.dmn.model.v1_1.Context in project webtools.servertools by eclipse.
the class Tomcat55Configuration method addWebModule.
/**
* @see ITomcatConfigurationWorkingCopy#addWebModule(int, ITomcatWebModule)
*/
public void addWebModule(int index, ITomcatWebModule module) {
try {
Context context = serverInstance.createContext(index);
if (context != null) {
context.setDocBase(module.getDocumentBase());
context.setPath(module.getPath());
context.setReloadable(module.isReloadable() ? "true" : "false");
if (module.getMemento() != null && module.getMemento().length() > 0)
context.setSource(module.getMemento());
isServerDirty = true;
firePropertyChangeEvent(ADD_WEB_MODULE_PROPERTY, null, module);
}
} catch (Exception e) {
Trace.trace(Trace.SEVERE, "Error adding web module " + module.getPath(), e);
}
}
Aggregations