Search in sources :

Example 86 with IServer

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));
            }
        }
    };
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ClassCollectingHCRListener(org.jboss.ide.eclipse.as.core.util.ClassCollectingHCRListener) IServer(org.eclipse.wst.server.core.IServer) IJavaDebugTarget(org.eclipse.jdt.debug.core.IJavaDebugTarget) CoreException(org.eclipse.core.runtime.CoreException) OpenShiftServerUtils.toCoreException(org.jboss.tools.openshift.core.server.OpenShiftServerUtils.toCoreException) ILaunch(org.eclipse.debug.core.ILaunch) DebugException(org.eclipse.debug.core.DebugException)

Example 87 with IServer

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;
}
Also used : IServer(org.eclipse.wst.server.core.IServer) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IServerType(org.eclipse.wst.server.core.IServerType) CDKServer(org.jboss.tools.openshift.cdk.server.core.internal.adapter.CDKServer)

Example 88 with IServer

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"));
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IServer(org.eclipse.wst.server.core.IServer) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) CDKServer(org.jboss.tools.openshift.cdk.server.core.internal.adapter.CDKServer) Test(org.junit.Test)

Example 89 with IServer

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());
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IServer(org.eclipse.wst.server.core.IServer) IServer(org.eclipse.wst.server.core.IServer) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject)

Example 90 with IServer

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();
}
Also used : IServer(org.eclipse.wst.server.core.IServer)

Aggregations

IServer (org.eclipse.wst.server.core.IServer)183 CoreException (org.eclipse.core.runtime.CoreException)39 IModule (org.eclipse.wst.server.core.IModule)32 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)30 Test (org.junit.Test)30 IProject (org.eclipse.core.resources.IProject)25 IStatus (org.eclipse.core.runtime.IStatus)25 IServerWorkingCopy (org.eclipse.wst.server.core.IServerWorkingCopy)23 ArrayList (java.util.ArrayList)20 File (java.io.File)17 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)13 Status (org.eclipse.core.runtime.Status)12 Iterator (java.util.Iterator)11 IPath (org.eclipse.core.runtime.IPath)11 IServerType (org.eclipse.wst.server.core.IServerType)11 CDKServer (org.jboss.tools.openshift.cdk.server.core.internal.adapter.CDKServer)11 IOException (java.io.IOException)10 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)10 Server (org.eclipse.wst.server.core.internal.Server)10 IFolder (org.eclipse.core.resources.IFolder)8