use of org.eclipse.jst.server.tomcat.core.internal.TomcatConfiguration in project liferay-ide by liferay.
the class LiferayTomcatServer method getPortalHomeUrl.
@Override
public URL getPortalHomeUrl() {
try {
TomcatConfiguration config = getTomcatConfiguration();
if (config == null)
return null;
// $NON-NLS-1$
String url = "http://" + getServer().getHost();
int port = config.getMainPort().getPort();
// $NON-NLS-1$
port = ServerUtil.getMonitoredPort(getServer(), port, "web");
if (port != 80)
// $NON-NLS-1$
url += ":" + port;
return new URL(url);
} catch (Exception ex) {
return null;
}
}
use of org.eclipse.jst.server.tomcat.core.internal.TomcatConfiguration in project webtools.servertools by eclipse.
the class ContextPublisherDelegate method execute.
public IStatus execute(int kind, IProgressMonitor monitor, IAdaptable info) throws CoreException {
// this publisher only runs when there is a UI
if (info == null)
return Status.OK_STATUS;
final Shell shell = (Shell) info.getAdapter(Shell.class);
if (shell == null)
return Status.OK_STATUS;
IServer server = (IServer) getTaskModel().getObject(TaskModel.TASK_SERVER);
TomcatServer tomcatServer = (TomcatServer) server.loadAdapter(TomcatServer.class, monitor);
final TomcatConfiguration configuration = tomcatServer.getTomcatConfiguration();
final boolean[] save = new boolean[1];
List modules = (List) getTaskModel().getObject(TaskModel.TASK_MODULES);
int size = modules.size();
for (int i = 0; i < size; i++) {
IModule[] module = (IModule[]) modules.get(i);
final IModule m = module[module.length - 1];
IWebModule webModule = (IWebModule) m.loadAdapter(IWebModule.class, monitor);
final WebModule webModule2 = configuration.getWebModule(m);
if (webModule != null && webModule2 != null) {
String contextRoot = webModule.getContextRoot();
if (contextRoot != null && !contextRoot.startsWith("/") && contextRoot.length() > 0)
contextRoot = "/" + contextRoot;
if (!contextRoot.equals(webModule2.getPath()) && shouldPrompt(m, contextRoot)) {
final String context = contextRoot;
shell.getDisplay().syncExec(new Runnable() {
public void run() {
if (MessageDialog.openQuestion(shell, Messages.wizardTitle, NLS.bind(Messages.contextCleanup, m.getName()))) {
int index = configuration.getWebModules().indexOf(webModule2);
configuration.modifyWebModule(index, webModule2.getDocumentBase(), context, webModule2.isReloadable());
save[0] = true;
}
}
});
markProject(m, contextRoot);
}
}
}
if (save[0])
tomcatServer.saveConfiguration(monitor);
return Status.OK_STATUS;
}
use of org.eclipse.jst.server.tomcat.core.internal.TomcatConfiguration in project mdw-designer by CenturyLinkCloud.
the class TomcatServer method importRuntimeConfiguration.
@Override
public void importRuntimeConfiguration(IRuntime runtime, IProgressMonitor monitor) throws CoreException {
// initialize state
synchronized (versionLock) {
configuration = null;
currentVersion = 0;
loadedVersion = 0;
}
if (runtime == null) {
return;
}
IPath path = runtime.getLocation().append("conf");
IFolder folder = getServer().getServerConfiguration();
TomcatConfiguration tcConfig = new Tomcat70Configuration(folder);
try {
tcConfig.importFromPath(path, isTestEnvironment(), monitor);
} catch (CoreException ce) {
throw ce;
}
// update version
synchronized (versionLock) {
// configuration
if (configuration == null) {
configuration = tcConfig;
}
}
}
use of org.eclipse.jst.server.tomcat.core.internal.TomcatConfiguration in project mdw-designer by CenturyLinkCloud.
the class TomcatServer method getTomcatConfiguration.
@Override
public TomcatConfiguration getTomcatConfiguration() throws CoreException {
int current;
TomcatConfiguration tcConfig;
// grab current state
synchronized (versionLock) {
current = currentVersion;
tcConfig = configuration;
}
// configuration needs loading
if (tcConfig == null || loadedVersion != current) {
IFolder folder = getServer().getServerConfiguration();
if (folder == null || !folder.exists()) {
String path = null;
if (folder != null) {
path = folder.getFullPath().toOSString();
IProject project = folder.getProject();
if (project != null && project.exists() && !project.isOpen())
throw new CoreException(new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorConfigurationProjectClosed, path, project.getName()), null));
}
throw new CoreException(new Status(IStatus.ERROR, TomcatPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorNoConfiguration, path), null));
}
// not yet loaded
if (tcConfig == null)
tcConfig = new Tomcat70Configuration(folder);
try {
((Tomcat70Configuration) tcConfig).load(folder, null);
// update loaded version
synchronized (versionLock) {
// if newer version not already loaded, update version
if (configuration == null || loadedVersion < current) {
configuration = tcConfig;
loadedVersion = current;
}
}
} catch (CoreException ce) {
// Ignore
throw ce;
}
}
return tcConfig;
}
Aggregations