Example #1
0
  /**
   * Create a file that contains the base class of all worker thread classes. This method will
   * trigger the class generation and add all required Java imports to the source file.
   *
   * @throws Exception Error during code generation
   */
  private void createBaseWorkerThreadFile() throws Exception {
    JSourceFile jsf =
        this.workspace
            .getJava()
            .getJSourceFile(this.threadWorkerPackageName, WORKER_THREAD_CLASS_NAME);

    // Add base worker thread class
    jsf.add(this.createBaseWorkerThreadClass());

    // Add required imports
    this.addRequiredImport(jsf, "org.atmosphere.websocket.WebSocket");
    this.addRequiredImport(
        jsf, this.serviceProviderPackageName + "." + this.serviceProviderClassName);
    this.addRequiredImport(jsf, this.packageName + "." + this.interfaceName);
  }
Example #2
0
  /**
   * Create a file that contains a single worker thread class. All child worker classes are
   * generated on a per-operation basis for each and every RPC method defined in the WSDL document.
   *
   * <p>This method will trigger the class generation and add all required Java imports to the
   * source file.
   *
   * @param operation FOperation object from WSDL parser
   * @throws Exception Error during code generation
   */
  private void createWorkerThreadFile(final FOperation operation) throws Exception {
    String rpcMethodName = WorkerThreadGenerator.firstLetterCapital(operation.getOperationName());
    JSourceFile jsf =
        this.workspace
            .getJava()
            .getJSourceFile(this.threadWorkerPackageName, rpcMethodName + "Worker");

    // Add child worker thread class
    jsf.add(this.createWorkerThreadClass(operation));

    // Add required imports
    this.addRequiredImport(jsf, "org.slf4j.Logger");
    this.addRequiredImport(jsf, "org.slf4j.LoggerFactory");
    this.addRequiredImport(jsf, "org.atmosphere.websocket.WebSocket");

    this.addRequiredImport(
        jsf, this.serviceProviderPackageName + "." + this.serviceProviderClassName);
    this.addRequiredImport(jsf, this.packageName + "." + this.interfaceName);
    this.addRequiredImport(
        jsf, this.packageName + "." + JSONMarshallerGenerator.MARSHALLER_CLASS_NAME);

    // Import server only if required
    if (null != operation.getOutputMessage()) {
      this.addRequiredImport(jsf, this.packageName + "." + this.interfaceName);
    }

    // Operation has input message
    if (null != operation.getInputMessage()) {
      this.addRequiredImport(
          jsf, this.serviceProviderPackageName + "." + this.getInputMessageName(operation));
    }

    // Operation has output message
    if (null != operation.getOutputMessage()) {
      this.addRequiredImport(
          jsf, this.serviceProviderPackageName + "." + this.getOutputMessageName(operation));
    }
  }