public void waitModuleStarted(IServer server, IModule[] module, IProgressMonitor monitor) {
    if (module.length == 0 || module[0] == null) return;

    try {
      String deploymentName = getDeploymentName(server, module[0]);
      boolean waitedOnce = false;

      while (!monitor.isCanceled()) {
        boolean done = isRootModuleStarted(server, module[0], deploymentName, monitor);
        if (done) {
          return;
        }
        if (!waitedOnce) {
          String info = "Module {0} on {1} not yet fully deployed. Waiting..."; // $NON-NLS-1$
          IStatus s =
              new Status(
                  IStatus.INFO,
                  JBossServerCorePlugin.PLUGIN_ID,
                  NLS.bind(info, module[0].getName(), server.getName()),
                  null);
          ServerLogger.getDefault().log(server, s);
        }
        waitedOnce = true;
        try {
          Thread.sleep(2000);
        } catch (InterruptedException ie) {
          // Ignore, intentional
        }
      }

      String warning =
          "Module {0} on {1} still not ready to be shown in browser. Aborting delay."; //$NON-NLS-1$
      IStatus s =
          new Status(
              IStatus.WARNING,
              JBossServerCorePlugin.PLUGIN_ID,
              NLS.bind(warning, module[0].getName(), server.getName()),
              null);
      ServerLogger.getDefault().log(server, s);
    } catch (Exception e) {
      String er = "Error occurred while waiting for {0} to start on server {1}"; // $NON-NLS-1$
      IStatus s =
          new Status(
              IStatus.WARNING,
              JBossServerCorePlugin.PLUGIN_ID,
              NLS.bind(er, module[0].getName(), server.getName()),
              e);
      ServerLogger.getDefault().log(server, s);
    }
  }
 private void startProxy(final IServer startedServer) {
   // re-start exiting proxy id already exist
   if (proxyServers.containsKey(startedServer)) {
     final LiveReloadProxyServer proxyServer = proxyServers.get(startedServer);
     try {
       proxyServer.start();
     } catch (Exception e) {
       Logger.error(
           "Failed to start LiveReload Proxy on port "
               + proxyServer.getConnectors()[0].getPort()
               + " for server "
               + startedServer.getName(),
           e);
     }
   }
   // create a new proxy
   else {
     final int targetPort = WSTUtils.getWebPort(startedServer);
     if (targetPort != -1) {
       try {
         // now, let's init and start the embedded jetty proxy server
         // from the
         // server attributes
         final boolean allowRemoteConnections = isRemoteConnectionsAllowed();
         final boolean enableScriptInjection = isScriptInjectionEnabled();
         final String proxyHost = getProxyHost();
         final int proxyPort = getProxyPort(startedServer);
         final LiveReloadProxyServer proxyServer =
             new LiveReloadProxyServer(
                 proxyHost,
                 proxyPort,
                 startedServer.getHost(),
                 targetPort,
                 websocketPort,
                 allowRemoteConnections,
                 enableScriptInjection);
         proxyServers.put(startedServer, proxyServer);
         final JettyServerRunner proxyRunner = JettyServerRunner.start(proxyServer);
         proxyRunners.put(startedServer, proxyRunner);
       } catch (Exception e) {
         Logger.error(
             "Failed to create or start LiveReload proxy for server " + startedServer.getName(),
             e);
       }
     }
   }
 }
Ejemplo n.º 3
0
 /**
  * @param server that associates to a {@link CloudFoundryServer}
  * @return non-null {@link CloudFoundryServer}
  * @throws CoreException if server is not a {@link CloudFoundryServer} or error occurred while
  *     resolving Cloud server
  */
 public static CloudFoundryServer getCloudServer(IServer server) throws CoreException {
   CloudFoundryServer cfServer = (CloudFoundryServer) server.getAdapter(CloudFoundryServer.class);
   if (cfServer == null) {
     throw CloudErrorUtil.toCoreException(
         NLS.bind(
             Messages.CloudServerUtil_NOT_CLOUD_SERVER_ERROR, server.getName(), server.getId()));
   }
   return cfServer;
 }
 protected Control createContents(Composite parent) {
   Control c = super.createContents(parent);
   setMessage(
       NLS.bind(Messages.DeploymentScannerDialogWarning, server.getName()),
       IMessageProvider.WARNING);
   setTitle(Messages.DeploymentScannerDialogTitle);
   getShell().setText(Messages.DeploymentScannerDialogTitle);
   getShell().setSize(500, 400);
   return c;
 }
  protected void validateServerStructure(IServer server) throws CoreException {
    IControllableServerBehavior jbsBehavior =
        JBossServerBehaviorUtils.getControllableBehavior(server);

    Trace.trace(Trace.STRING_FINEST, "Verifying server structure"); // $NON-NLS-1$
    JBossExtendedProperties props =
        ExtendedServerPropertiesAdapterFactory.getJBossExtendedProperties(server);
    IStatus status = props.verifyServerStructure();
    if (!status.isOK()) {
      ((ControllableServerBehavior) jbsBehavior).setServerStopped();
      throw new CoreException(status);
    }

    Trace.trace(
        Trace.STRING_FINEST, "Verifying jdk is available if server requires jdk"); // $NON-NLS-1$
    boolean requiresJDK = props.requiresJDK();
    if (requiresJDK) {
      IRuntime rt = server.getRuntime();
      IJBossServerRuntime rt2 = RuntimeUtils.getJBossServerRuntime(rt);
      IVMInstall vm = rt2.getVM();

      if (!JavaUtils.isJDK(vm)) {
        // JBIDE-14568 do not BLOCK launch, but log error
        Trace.trace(
            Trace.STRING_FINEST,
            "The VM to launch server '"
                + //$NON-NLS-1$
                server.getName()
                + "' does not appear to be a JDK: "
                + vm.getInstallLocation().getAbsolutePath()); // $NON-NLS-1$
        IStatus stat =
            new Status(
                IStatus.ERROR,
                JBossServerCorePlugin.PLUGIN_ID,
                NLS.bind(
                    Messages.launch_requiresJDK,
                    server.getName(),
                    vm.getInstallLocation().getAbsolutePath()));
        logStatus(server, stat);
      }
    }
  }
Ejemplo n.º 6
0
  // TODO fire gwt sdm start/stop event
  private void addServerUrlsToDevModeView(ILaunch launch) {
    IServer server = getServerFromLaunchConfig(launch);
    if (server == null) {
      logMessage("posiblyLaunchGwtSuperDevModeCodeServer: No WTP server found.");
      return;
    }

    IModule[] modules = server.getModules();
    if (modules == null || modules.length == 0) {
      return;
    }

    IModule rootMod = modules[0];
    if (rootMod == null) {
      return;
    }

    // First clear the previous urls, before adding new ones
    launchUrls.clear();

    String host = server.getHost();
    ServerPort[] ports = null;
    try {
      ports = server.getServerPorts(new NullProgressMonitor());
    } catch (Exception e1) {
    }

    // Add server urls to DevModeViewer
    if (ports != null) {
      for (ServerPort port : ports) {
        String baseUrl = String.format(LOCAL_URL, host, port.getPort());
        String path = getPath(server, rootMod);
        String fullUrl = baseUrl + path;
        launchUrls.add(fullUrl);
      }
    }

    // TODO extract, consider a plugin that does this, that adds the appengine dashboard url
    // TODO or possibly do a extension query
    // Add App Engine url to DevModeView
    // See OpenLocalAdminConsoleHandler
    if (server.getName().contains("Google")) {
      GaeServer gaeServer = GaeServer.getGaeServer(server);
      String gaeHost = server.getHost();
      ServerPort gaePort = gaeServer.getMainPort();
      String gaeUrl = String.format("http://%s:%s/_ah/admin", gaeHost, gaePort.getPort());
      launchUrls.add(gaeUrl);
    }
  }
 public int getModuleState(IServer server, IModule[] module, IProgressMonitor monitor) {
   try {
     return getRootModuleState(server, module[0], getDeploymentName(server, module[0]), monitor);
   } catch (Exception e) {
     String er = "Error occurred while checking module state for {0} on server {1}"; // $NON-NLS-1$
     IStatus s =
         new Status(
             IStatus.WARNING,
             JBossServerCorePlugin.PLUGIN_ID,
             NLS.bind(er, module[0].getName(), server.getName()),
             e);
     ServerLogger.getDefault().log(server, s);
     return IServer.STATE_UNKNOWN;
   }
 }
Ejemplo n.º 8
0
  private final String getCacheKey(
      final IServer server, final Image serverTypeImg, final Image serverStatusImg) {

    StringBuffer key = new StringBuffer();
    if (server != null) {
      key.append(server.getName());
    }
    if (serverTypeImg != null) {
      key.append(serverTypeImg.toString());
    }
    if (serverStatusImg != null) {
      key.append(serverStatusImg.toString());
    }
    return key.toString();
  }
 /**
  * Starts the {@link LiveReloadServer} which is responsable for the embedded web/websocket/proxy
  * server configuration and lifecycle
  *
  * @param serverBehaviour
  * @throws CoreException
  * @throws TimeoutException
  * @throws InterruptedException
  */
 public void startServer() throws CoreException {
   try {
     // set the server status to "Starting"
     setServerStarting();
     // now, let's init and start the embedded jetty server from the
     // server attributes
     final IServer server = getServer();
     // retrieve the websocket port, use the default value if it was missing
     websocketPort =
         server.getAttribute(
             LiveReloadLaunchConfiguration.WEBSOCKET_PORT,
             LiveReloadLaunchConfiguration.DEFAULT_WEBSOCKET_PORT);
     // fix the new default behaviour: proxy is now always enabled
     if (!isProxyEnabled()) {
       setProxyEnabled(true);
     }
     final boolean allowRemoteConnections = isRemoteConnectionsAllowed();
     final boolean enableScriptInjection = isScriptInjectionEnabled();
     this.liveReloadServer =
         new LiveReloadServer(
             server.getName(),
             server.getHost(),
             websocketPort,
             true,
             allowRemoteConnections,
             enableScriptInjection);
     this.liveReloadServerRunnable = JettyServerRunner.start(liveReloadServer);
     if (!this.liveReloadServerRunnable.isSuccessfullyStarted()) {
       setServerStopped();
     } else {
       // listen to file changes in the workspace
       addWorkspaceResourceChangeListener();
       // listen to server lifecycles
       addServerLifeCycleListener();
       // set the server status to "Started"
       setServerStarted();
     }
   } catch (TimeoutException e) {
     setServerStopped();
     throw new CoreException(
         new Status(IStatus.ERROR, JBossLiveReloadCoreActivator.PLUGIN_ID, e.getMessage(), e));
   }
 }
Ejemplo n.º 10
0
  public String getText(Object element) {
    if (element instanceof ModuleServer) {
      ModuleServer ms = (ModuleServer) element;
      if (ms.module == null) return "";
      return ms.getModuleDisplayName();
    }

    if (element instanceof IServer) {
      IServer server = (IServer) element;
      return notNull(server.getName());
    }

    if (element == ServerContentProvider.INITIALIZING) return Messages.viewInitializing;

    if (element instanceof IWorkspaceRoot) {
      return Platform.getResourceString(ServerUIPlugin.getInstance().getBundle(), "%viewServers");
    }

    return "";
  }
Ejemplo n.º 11
0
 @Override
 public String getKey(IServer value) {
   return value.getName();
 }