Exports public methods annotated by {@link XRMethod} declared on a clazz.

@param server
object instance exposing XML-RPC methods
@param clazz
to export methods from
@return this instance for call chaining.
19486
public ObjectEndpoint export(Object server, Class<?> clazz) {
		// If clazz isn't specified than export all methods on a object
		if (clazz == null) {
			clazz = (Class<?>) server.getClass();
		}

		for (Method m : clazz.getMethods()) {
			// Ignore all java.lang.Object methods
			if (Object.class.equals(m.getDeclaringClass())) {
				continue;
			}
			MethodEndpoint method = new MethodEndpoint(m, server, null, faultMapper, typeConverter);
			String name = method.getMethodName();
			if (prefix != null) {
				name = prefix + "." + name;
			}
			if (methods.containsKey(name)) {
				throw new IllegalArgumentException("methods " + m + " and " + methods.get(name) + " are exported as "
						+ name);
			}
			methods.put(name, method);
		}

		return this;
	}
30703
@Override
    public <T> T unwrap(Class<T> clazz) {
      return ServerHttpExchange.class.isAssignableFrom(clazz) ? clazz.cast(http) : null;
    }
246209
private static Map<String, Method> gatherAllDeclaredMethods(Class clazz) {
        Map<String, Method> methods = new HashMap<String, Method>();
        gatherAllDeclaredMethods(methods, clazz);
        return methods;
    }
485175
private static List<Method> getAnnotatedMethods(Class<?> clazz){
		List<Method> methods = new ArrayList<Method>();
		
		for(Method method:getAllMethods(clazz))
			if(!isNull(method.getAnnotation(JMapConversion.class)))
				methods.add(method);
		
		return methods;
	}
209382
public static <T> T convertToObject(Class<T> clazz, String xml) {
		return convertToObject(clazz, new StringReader(xml));
	}
1279800
private static String getClassMethod(Class clazz, Method method) {
		StringBuilder builder = new StringBuilder();
		builder.append(clazz.getName()).append(".").append(method.getName());
		builder.append("(");
		if (method.getParameterCount() > 0) {
			for (int i = 0; i < method.getParameterCount(); i++) {
				Parameter param = method.getParameters()[i];
				builder.append(param.getType().getSimpleName()).append(" ").append(param.getName());

				if (i + 1 < method.getParameterCount()) {
					builder.append(", ");
				}
			}
		}
		builder.append(")");
		return builder.toString();
	}
93373
protected File exportParametersToXml() throws Exception {
        PluginConfigXmlDocument configDocument = PluginConfigXmlDocument.newInstance("liberty-plugin-config");

        List<Profile> profiles = project.getActiveProfiles();
        configDocument.createActiveBuildProfilesElement("activeBuildProfiles", profiles);

        configDocument.createElement("installDirectory", installDirectory);
        configDocument.createElement("serverDirectory", serverDirectory);
        configDocument.createElement("userDirectory", userDirectory);
        configDocument.createElement("serverOutputDirectory", new File(outputDirectory, serverName));
        configDocument.createElement("serverName", serverName);
        configDocument.createElement("configDirectory", configDirectory);

        if (getFileFromConfigDirectory("server.xml", configFile) != null) {
            configDocument.createElement("configFile", getFileFromConfigDirectory("server.xml", configFile));
        }
        if (bootstrapProperties != null && getFileFromConfigDirectory("bootstrap.properties") == null) {
            configDocument.createElement("bootstrapProperties", bootstrapProperties);
        } else {
            configDocument.createElement("bootstrapPropertiesFile",
                    getFileFromConfigDirectory("bootstrap.properties", bootstrapPropertiesFile));
        }
        if (jvmOptions != null && getFileFromConfigDirectory("jvm.options") == null) {
            configDocument.createElement("jvmOptions", jvmOptions);
        } else {
            configDocument.createElement("jvmOptionsFile", getFileFromConfigDirectory("jvm.options", jvmOptionsFile));
        }
        if (getFileFromConfigDirectory("server.env", serverEnv) != null) {
            configDocument.createElement("serverEnv", getFileFromConfigDirectory("server.env", serverEnv));
        }

        configDocument.createElement("appsDirectory", getAppsDirectory());
        configDocument.createElement("looseApplication", looseApplication);
        configDocument.createElement("stripVersion", stripVersion);
        configDocument.createElement("installAppPackages", getInstallAppPackages());
        configDocument.createElement("applicationFilename", getApplicationFilename());
        configDocument.createElement("assemblyArtifact", assemblyArtifact);
        configDocument.createElement("assemblyArchive", assemblyArchive);
        configDocument.createElement("assemblyInstallDirectory", assemblyInstallDirectory);
        configDocument.createElement("refresh", refresh);
        configDocument.createElement("install", install);

        configDocument.createElement("installAppsConfigDropins",
                ApplicationXmlDocument.getApplicationXmlFile(serverDirectory));
        configDocument.createElement("projectType", project.getPackaging());
        if (project.getParent() != null && !project.getParent().getModules().isEmpty()) {
            configDocument.createElement("aggregatorParentId", project.getParent().getArtifactId());
            configDocument.createElement("aggregatorParentBasedir", project.getParent().getBasedir());
        }

        // returns all current project compile dependencies, including
        // transitive dependencies
        // if Mojo required dependencyScope is set to COMPILE
        Set<Artifact> artifacts = project.getArtifacts();
        for (Artifact artifact : artifacts) {
            if ("compile".equals(artifact.getScope()) || "runtime".equals(artifact.getScope())) {
                configDocument.createElement("projectCompileDependency",
                        artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + artifact.getVersion());
            }
        }

        // include warSourceDirectory for liberty-assembly project with source
        configDocument.createElement("warSourceDirectory", getLibertyAssemblyWarSourceDirectory(project));

        // write XML document to file
        File f = new File(project.getBuild().getDirectory() + File.separator + PLUGIN_CONFIG_XML);
        configDocument.writeXMLDocument(f);
        return f;
    }
1230887
public static Method getPublicMethod(Class<?> clazz, String methodName, Class<?>[] argTypes) {
        assertObjectNotNull("clazz", clazz);
        assertStringNotNullAndNotTrimmedEmpty("methodName", methodName);
        return findMethod(clazz, methodName, argTypes, VisibilityType.PUBLIC, false);
    }
722932
private static Map<String, Method> getAllMethod(Class<?> clazz, Map<String, Method> methods) {
        if (clazz == null || clazz == Object.class) {
            return methods;
        }

        Arrays.stream(clazz.getDeclaredMethods()).forEach(method -> {
            String key = String.format("%s:%s", method.getName(),
                ByteCodeUtils.getMethodDesc(method));
            Method m = methods.get(key);
            if (m == null || (m.getDeclaringClass().isInterface()
                              && !method.getDeclaringClass().isInterface())) {
                methods.put(key, method);
            }
        });

        Arrays.stream(clazz.getInterfaces()).forEach(c -> getAllMethod(c, methods));

        return getAllMethod(clazz.getSuperclass(), methods);
    }
898693
private static List<Method> getMethodsWithAnnotation(Class<?> clazz, Class<? extends Annotation> annotation, Logger log) {
    List<Method> annotatedMethods = new ArrayList<Method>();
    Method classMethods[] = clazz.getDeclaredMethods();
    for(Method classMethod : classMethods) {
      if(classMethod.isAnnotationPresent(annotation) && classMethod.getParameterTypes().length == 0) {
        if(!containsMethod(classMethod, annotatedMethods)) {
          annotatedMethods.add(classMethod);
        }
      }
    }
    Collections.sort(annotatedMethods, new Comparator<Method> () {

      @Override
      public int compare(Method method1, Method method2) {
        return method1.getName().compareTo(method2.getName());
      }
    });
    return annotatedMethods;
  }
219577
public static XMethod createXMethod(JavaClass javaClass, Method method) {
        if (method == null) {
            throw new NullPointerException("method must not be null");
        }
        XMethod xmethod = createXMethod(javaClass.getClassName(), method);
        assert xmethod.isResolved();
        return xmethod;
    }
1174667
public static Map<String, Method> getClassWriteMethods(Class<?> clazz) {
		Map<String, Method> writeMethods = classWriteMethods.get(clazz);
		if (writeMethods == null) {
			cacheReadWriteMethodsAndBoxField(clazz);
			return classWriteMethods.get(clazz);
		} else
			return writeMethods;
	}
238542
public static Method getMethodByName(Class<?> clazz, String name)
  {
    final List<Method> methods = JReflectionUtils.getAllMethods(new ArrayList<Method>(), clazz);

    for (Method method : methods)
    {
      if (method.getName().equals(name))
      {
        return method;
      }
    }
    return null;
  }
357211
public IRExpression callMethod( Class cls, String strMethod, Class[] paramTypes, IRExpression root, List<IRExpression> args )
  {
    return callMethod( IRMethodFactory.createIRMethod( cls, strMethod, paramTypes ), root, args );
  }
319769
private static Set<Method> collectMethods(Class clazz)
    {
        if (clazz == null) return Collections.emptySet();

        Set<Method> s = new HashSet<Method>();

        s.addAll(Arrays.asList(clazz.getDeclaredMethods()));
        s.addAll(collectMethods(clazz.getSuperclass()));

        return s;
    }
784718
@SuppressWarnings("unchecked")
	public static <T> T convertToObject(Class<T> clazz, Reader reader) {
		try {
			/**
			 * XXE 漏洞
			 * https://www.owasp.org/index.php/XML_External_Entity_(XXE)_Prevention_Cheat_Sheet#JAXB_Unmarshaller
			 */
			SAXParserFactory spf = SAXParserFactory.newInstance();
			spf.setFeature("http://xml.org/sax/features/external-general-entities", false);
			spf.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
			spf.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);

			if (!JAXB_CONTEXT_MAP.containsKey(clazz)) {
				JAXB_CONTEXT_MAP.put(clazz, JAXBContext.newInstance(clazz));
			}

			Source xmlSource = new SAXSource(spf.newSAXParser().getXMLReader(), new InputSource(reader));
			Unmarshaller unmarshaller = JAXB_CONTEXT_MAP.get(clazz).createUnmarshaller();
			return (T) unmarshaller.unmarshal(xmlSource);
		} catch (Exception e) {
			logger.error("", e);
		}
		return null;
	}
791108
private FieldSpec generateRxMappingMethod(ObjectMappableAnnotatedClass clazz) {

    String objectVarName = "item";
    String cursorVarName = "cursor";

    TypeName elementType = ClassName.get(clazz.getElement().asType());

    // new Func1<Cursor, ListsItem>()

    CodeBlock.Builder initBlockBuilder = CodeBlock.builder()
        .add("new $L<$L, $L>() {\n", Func1.class.getSimpleName(), Cursor.class.getSimpleName(),
            elementType)
        .indent()
        .add("@Override public $L call($L cursor) {\n", elementType, Cursor.class.getSimpleName())
        .indent();

    // assign the columns indexes
    generateColumnIndexCode(initBlockBuilder, clazz.getColumnAnnotatedElements(), cursorVarName);

    // Instantiate element
    initBlockBuilder.addStatement("$T $L = new $T()", elementType, objectVarName, elementType);

    // read cursor into element variable
    for (ColumnAnnotateable e : clazz.getColumnAnnotatedElements()) {
      String indexVaName = e.getColumnName() + "Index";
      initBlockBuilder.beginControlFlow("if ($L >= 0)", indexVaName);
      e.generateAssignStatement(initBlockBuilder, objectVarName, cursorVarName, indexVaName);
      initBlockBuilder.endControlFlow();
    }

    initBlockBuilder.addStatement("return $L", objectVarName)
        .unindent()
        .add("}\n") // end call () method
        .unindent()
        .add("}") // end anonymous class
        .build();

    ParameterizedTypeName fieldType =
        ParameterizedTypeName.get(ClassName.get(Func1.class), ClassName.get(Cursor.class),
            elementType);

    return FieldSpec.builder(fieldType, "MAPPER", Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL)
        .initializer(initBlockBuilder.build())
        .build();
  }