Пример #1
0
  private void initSetter() {
    setter = ReflectionUtils.getSetter(fieldName, object.getClass());

    if (setter == null) {
      return;
    }

    setterParamType = setter.getParameterTypes()[0];

    try {
      setterTypeConverter = lookup.lookupConverterForType(setterParamType);
    } catch (ComponentConfigurationException e) {
      // ignore, handle later
    }
  }
Пример #2
0
  /**
   * This method will run client gen on the given WSDL.
   *
   * @throws MojoExecutionException Thrown if we fail to obtain the WSDL.
   */
  public void execute() throws MojoExecutionException {
    super.execute();

    if (getLog().isInfoEnabled()) {
      getLog().info("Weblogic client gen beginning ");
    }
    if (getLog().isInfoEnabled()) {
      getLog().info(" Detailed client gen settings information " + this.toString());
    }

    try {
      final ClientGenTask clientGen = new ClientGenTask();
      // Set the classpath
      final Project project = new Project();
      project.setName("clientgen");
      final Path path =
          new Path(
              project,
              WeblogicMojoUtilities.getDependencies(
                  this.getArtifacts(), this.getPluginArtifacts()));
      clientGen.setProject(project);
      clientGen.setClasspath(path);

      // in WebLogic 10.3 some methods were renamed (e.g. "setDestDir()") or removed (e.g.
      // "setOverwrite()")
      // so we have to use reflection here
      //            clientGen.setOverwrite( true );
      Method method = ReflectionUtils.getSetter("overwrite", clientGen.getClass());
      if (method != null) {
        method.invoke(clientGen, new Object[] {Boolean.TRUE});
      }
      //            clientGen.setDestdir( new File( this.outputDir ) );
      method = ReflectionUtils.getSetter("destdir", clientGen.getClass());
      if (method != null) {
        method.invoke(clientGen, new Object[] {new File(this.outputDir)});
      }
      //            clientGen.setDestDir( new File( this.outputDir ) );
      method = ReflectionUtils.getSetter("destDir", clientGen.getClass());
      if (method != null) {
        method.invoke(clientGen, new Object[] {new File(this.outputDir)});
      }

      clientGen.setVerbose(this.verbose);
      clientGen.setPackageName(this.packageName);
      clientGen.setIncludeGlobalTypes(this.useServerTypes);
      clientGen.setJaxRPCWrappedArrayStyle(this.jaxRPCWrappedArrayStyle);
      String wsdlUri;
      if (this.warFileName != null) {
        if (getLog().isInfoEnabled()) {
          getLog()
              .info(
                  " calculating wsdl URI from warFileName "
                      + this.warFileName
                      + " with wsdl "
                      + this.inputWSDL);
        }
        wsdlUri =
            "jar:file:"
                + WeblogicMojoUtilities.getWarFileName(this.getArtifacts(), this.warFileName)
                + "!"
                + this.inputWSDL;
        new File(this.inputWSDL).toURI().toString();
        if (getLog().isInfoEnabled()) {
          getLog().info(" using " + wsdlUri + " for clientgen.");
        }
      } else if (this.inputWSDL.startsWith("http")) {
        if (getLog().isInfoEnabled()) {
          getLog().info(" using " + this.inputWSDL + " for clientgen.");
        }
        wsdlUri = this.inputWSDL;
      } else {
        wsdlUri = new File(this.inputWSDL).toURI().toString();
        if (getLog().isInfoEnabled()) {
          getLog().info(" using " + wsdlUri + " for clientgen.");
        }
      }
      clientGen.setWsdl(wsdlUri);
      // set the service name if it is specified
      if (this.serviceName != null) {
        if (getLog().isInfoEnabled()) {
          getLog().info(" generating client for service '" + this.serviceName + "'.");
        }
        clientGen.setServiceName(this.serviceName);
      }
      clientGen.execute();
    } catch (Exception ex) {
      getLog().error("Exception encountered during client gen", ex);
      throw new MojoExecutionException("Exception encountered during listapps", ex);
    } finally {
      WeblogicMojoUtilities.unsetWeblogicProtocolHandler();
    }

    if (getLog().isInfoEnabled()) {
      getLog().info("Weblogic client gen successful ");
    }
  }