示例#1
0
  protected Result processDeployment(Project project, String path, Type type) {
    Result result;

    // The server must be running
    if (serverController.hasServer() && serverController.getServer().isRunning()) {
      final PackagingFacet packagingFacet = project.getFacet(PackagingFacet.class);

      // Can't deploy what doesn't exist
      if (!packagingFacet.getFinalArtifact().exists())
        throw new DeploymentFailureException(
            messages.getMessage("deployment.not.found", path, type));
      final File content;
      if (path == null) {
        content = new File(packagingFacet.getFinalArtifact().getFullyQualifiedName());
      } else if (path.startsWith("/")) {
        content = new File(path);
      } else {
        // TODO this might not work for EAR deployments
        content =
            new File(packagingFacet.getFinalArtifact().getParent().getFullyQualifiedName(), path);
      }
      try {
        final ModelControllerClient client = serverController.getClient();
        final Deployment deployment =
            StandaloneDeployment.create(client, content, null, type, null, null);
        deployment.execute();
        result = Results.success(messages.getMessage("deployment.successful", type));
      } catch (Exception e) {
        if (e.getCause() != null) {
          result =
              Results.fail(e.getLocalizedMessage() + ": " + e.getCause().getLocalizedMessage());
        } else {
          result = Results.fail(e.getLocalizedMessage());
        }
      }
    } else {
      result =
          Results.fail(
              messages.getMessage(
                  "server.not.running", configuration.getHostname(), configuration.getPort()));
    }

    return result;
  }
示例#2
0
  @Override
  public Result start(UIContext context) {
    Result result = null;
    if ((serverController.hasServer() && serverController.getServer().isRunning())
        || false) // getState().isRunningState())
    {
      result = Results.fail(messages.getMessage("server.already.running"));
    } else {
      try {

        if (!serverController.hasServer()) createServer(context);

        Server<ModelControllerClient> server = serverController.getServer();

        // Start the server
        server.start();
        server.checkServerState();

        if (server.isRunning()) {
          result =
              Results.success(
                  messages.getMessage("server.start.success", configuration.getVersion()));
        } else {
          result =
              Results.fail(messages.getMessage("server.start.failed", configuration.getVersion()));
        }
      } catch (Exception e) {
        result =
            Results.fail(
                messages.getMessage(
                    "server.start.failed.exception",
                    configuration.getVersion(),
                    e.getLocalizedMessage()));
      }
      if (result instanceof Failed) {
        // closeConsoleOutput();
      }
    }
    return result;
  }