use of org.eclipse.wst.server.core.IServer in project jbosstools-openshift by jbosstools.
the class OpenShiftLaunchController method getHotCodeReplaceListener.
protected IJavaHotCodeReplaceListener getHotCodeReplaceListener(final IServer server, final ILaunch launch) {
return new ClassCollectingHCRListener(server, launch) {
protected void prePublish(IJavaDebugTarget target, IModule[] modules) {
try {
getLaunch().terminate();
} catch (DebugException de) {
OpenShiftCoreActivator.pluginLog().logError(toCoreException("Unable to terminate debug session", de));
}
}
@Override
protected void postPublish(IJavaDebugTarget target, IModule[] modules) {
IServer server = getServer();
waitModulesStarted(modules);
executeJMXGarbageCollection(server, modules);
sleep(3000);
String portAttr = launch.getAttribute(LAUNCH_DEBUG_PORT_PROP);
int port = DebugContext.NO_DEBUG_PORT;
try {
port = Integer.parseInt(portAttr);
} catch (NumberFormatException nfe) {
// TODO
}
try {
ILaunch newLaunch = attachRemoteDebugger(server, port, new NullProgressMonitor());
if (newLaunch != null) {
overrideHotcodeReplace(server, newLaunch);
}
setLaunch(newLaunch);
} catch (CoreException ce) {
OpenShiftCoreActivator.pluginLog().logError(toCoreException("Unable to restart debug session", ce));
}
}
};
}
use of org.eclipse.wst.server.core.IServer in project jbosstools-openshift by jbosstools.
the class CDK32LaunchControllerTest method mockServer.
private IServer mockServer() {
IServer server = mock(IServer.class);
when(server.getAttribute(CDKServer.PROP_PASS_CREDENTIALS, false)).thenReturn(Boolean.TRUE);
when(server.getAttribute(CDKServer.PROP_USER_ENV_VAR, CDKConstants.CDK_ENV_SUB_USERNAME)).thenReturn(CDKConstants.CDK_ENV_SUB_USERNAME);
when(server.getAttribute(CDK3Server.PROP_HYPERVISOR, CDK3Server.getHypervisors()[0])).thenReturn(CDK3Server.VIRTUALBOX);
when(server.getAttribute(CDK32Server.PROFILE_ID, (String) null)).thenReturn(CDK32Server.MINISHIFT_DEFAULT_PROFILE);
when(server.getAttribute(CDK3Server.MINISHIFT_FILE, (String) null)).thenReturn("/home/user/apps/minishift");
when(server.getName()).thenReturn(NAME);
CDKServer cdk = mock(CDKServer.class);
when(server.loadAdapter(eq(CDKServer.class), any(IProgressMonitor.class))).thenReturn(cdk);
when(cdk.passCredentials()).thenReturn(Boolean.TRUE);
when(cdk.getUserEnvironmentKey()).thenReturn(CDKConstants.CDK_ENV_SUB_USERNAME);
IServerType mockType = mock(IServerType.class);
when(server.getServerType()).thenReturn(mockType);
when(mockType.getId()).thenReturn(CDK32Server.CDK_V32_SERVER_TYPE);
return server;
}
use of org.eclipse.wst.server.core.IServer in project jbosstools-openshift by jbosstools.
the class CDK32LaunchControllerTest method testInitializeAndOverrides.
@Test
public void testInitializeAndOverrides() throws Exception {
ILaunchConfigurationWorkingCopy wc = mock(ILaunchConfigurationWorkingCopy.class);
when(wc.getAttribute(any(String.class), any(String.class))).thenAnswer(AdditionalAnswers.returnsSecondArg());
String userName = "Drumpf";
IServer server = mockServer();
when(wc.getName()).thenReturn(NAME);
ArgumentCaptor<String> keyCaptor = ArgumentCaptor.forClass(String.class);
ArgumentCaptor<String> valCaptor = ArgumentCaptor.forClass(String.class);
CDKServer cdkServer = (CDKServer) server.loadAdapter(CDKServer.class, new NullProgressMonitor());
CDK3TestLaunchController controller = new CDK3TestLaunchController(server, cdkServer);
controller.initialize(wc, userName, server);
verify(wc, Mockito.times(1)).setAttribute(keyCaptor.capture(), valCaptor.capture());
List<String> allVals = valCaptor.getAllValues();
assertTrue(allVals.get(0).replace("\\", "/").endsWith(".metadata/.plugins/org.jboss.ide.eclipse.as.core"));
ArgumentCaptor<String> keyCaptor2 = ArgumentCaptor.forClass(String.class);
ArgumentCaptor<String> valCaptor2 = ArgumentCaptor.forClass(String.class);
controller.performOverrides(wc);
verify(wc, Mockito.times(4)).setAttribute(keyCaptor2.capture(), valCaptor2.capture());
allVals = valCaptor2.getAllValues();
assertTrue(allVals.get(0).replace("\\", "/").endsWith(".metadata/.plugins/org.jboss.ide.eclipse.as.core"));
assertTrue(allVals.get(1).replace("\\", "/").endsWith(".metadata/.plugins/org.jboss.ide.eclipse.as.core"));
assertTrue(allVals.get(2).endsWith("/home/user/apps/minishift"));
assertTrue(allVals.get(3).endsWith("--profile minishift start --vm-driver=virtualbox"));
}
use of org.eclipse.wst.server.core.IServer in project mdw-designer by CenturyLinkCloud.
the class FuseConfigurator method doDeploy.
@SuppressWarnings("restriction")
public void doDeploy(Shell shell) {
org.eclipse.wst.server.core.internal.Server matchingServer = null;
for (IServer server : ServerCore.getServers()) {
if (server.getRuntime() != null && server.getRuntime().getRuntimeType() != null && server.getRuntime().getRuntimeType().getId().startsWith("com.centurylink.server.runtime.jbossfuse")) {
org.eclipse.wst.server.core.internal.Server smixServer = (org.eclipse.wst.server.core.internal.Server) server;
if (smixServer.getAllModules().size() > 0) {
String wfProjectName = smixServer.getAllModules().get(0)[0].getName();
WorkflowProject serverWfp = WorkflowProjectManager.getInstance().getWorkflowProject(wfProjectName);
if (serverWfp != null && serverWfp.equals(getServerSettings().getProject()))
matchingServer = smixServer;
}
}
}
if (matchingServer != null) {
matchingServer.publish(IServer.PUBLISH_INCREMENTAL, new NullProgressMonitor());
} else {
MessageDialog.openError(shell, "Server Deploy", "Could not find a Fues server with a module matching " + getServerSettings().getProject());
}
}
use of org.eclipse.wst.server.core.IServer in project mdw-designer by CenturyLinkCloud.
the class ServerConsole method getServerSettings.
private ServerSettings getServerSettings(String serverName) {
IServer server = getServer(serverName);
if (server == null)
return null;
ServiceMixServerBehavior serverBehave = null;
if (server.getServerType().getId().startsWith(ServiceMixServer.ID_PREFIX))
serverBehave = (ServiceMixServerBehavior) server.loadAdapter(ServiceMixServerBehavior.class, null);
else if (server.getServerType().getId().startsWith(FuseServer.ID_PREFIX))
serverBehave = (FuseServerBehavior) server.loadAdapter(FuseServerBehavior.class, null);
if (serverBehave == null)
return null;
return serverBehave.getServerSettings();
}
Aggregations