Skip to content

Instantly share code, notes, and snippets.

@fbricon
Created March 16, 2016 19:48
Show Gist options
  • Save fbricon/d96354b617d2042da045 to your computer and use it in GitHub Desktop.
Save fbricon/d96354b617d2042da045 to your computer and use it in GitHub Desktop.
package org.jboss.tools.openshift.core.server.behavior;
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.IServerAttributes;
import org.jboss.ide.eclipse.as.wtp.core.server.behavior.ISubsystemController;
import org.jboss.ide.eclipse.as.wtp.core.util.ServerModelUtilities;
import org.jboss.tools.as.core.internal.modules.ModuleDeploymentPrefsUtil;
import org.jboss.tools.as.core.server.controllable.subsystems.internal.ModuleDeployPathController;
import org.jboss.tools.openshift.core.server.OpenShiftServerUtils;
public class OpenShiftEapDeployPathController extends ModuleDeployPathController implements ISubsystemController, IOpenShiftModuleFinder {
interface IOpenShiftModuleFinder {
IModule getProjectModule(IServer server);
}
public OpenShiftEapDeployPathController() {
super();
}
@Override
protected ModuleDeploymentPrefsUtil createModuleDeploymentPrefsUtil() {
return new OpenShiftModuleDeploymentPrefsUtil(this);
}
public IModule getProjectModule(IServer server) {
return OpenShiftServerUtils.findProjectModule(OpenShiftServerUtils.getDeployProject(server));
}
public static class OpenShiftModuleDeploymentPrefsUtil extends ModuleDeploymentPrefsUtil {
OpenShiftModuleDeploymentPrefsUtil(IOpenShiftModuleFinder moduleFinder) {
this.moduleFinder = moduleFinder;
}
// We must override the presumed name given to the module upon publish if it is our magic project
protected String getOutputNameFromSettings(IServerAttributes server, IModule module) {
String ret = super.getOutputNameFromSettings(server, module);
if( ret == null && module.equals(moduleFinder.getProjectModule(server))) {
String suffix = ServerModelUtilities.getDefaultSuffixForModule(module);
ret = "ROOT" + suffix;
}
return ret;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment