fathom.utils.Util类的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(10.0k)|赞(0)|评价(0)|浏览(212)

本文整理了Java中fathom.utils.Util类的一些代码示例,展示了Util类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util类的具体详情如下:
包路径:fathom.utils.Util
类名称:Util

Util介绍

暂无

代码示例

代码示例来源:origin: com.gitblit.fathom/fathom-security

  1. protected void logCacheSettings(Logger log) {
  2. Util.logSetting(log, "caching", accountCache != null);
  3. Util.logSetting(log, "cacheTtl (mins)", cacheTtl);
  4. Util.logSetting(log, "cacheMax (accounts)", cacheMax);
  5. }

代码示例来源:origin: gitblit/fathom

  1. public static String toString(Method method) {
  2. return toString(method.getDeclaringClass(), method.getName());
  3. }

代码示例来源:origin: com.gitblit.fathom/fathom-security

  1. public DomainPermission(String actions, String targets) {
  2. this.domain = getDomain(getClass());
  3. this.actions = Util.splitToSet(actions, SUBPART_DIVIDER_TOKEN);
  4. this.targets = Util.splitToSet(targets, SUBPART_DIVIDER_TOKEN);
  5. encodeParts(this.domain, actions, targets);
  6. }

代码示例来源:origin: com.gitblit.fathom/fathom-rest-security

  1. String contentType = Util.getPreSubstring(context.getRequest().getHeader("Content-Type").toLowerCase(), ';');
  2. if (!guardedTypes.contains(contentType)) {
  3. log.debug("Ignoring '{}' request for {} '{}'", contentType, context.getRequestMethod(),

代码示例来源:origin: gitblit/fathom

  1. /**
  2. * Returns {@code true} if the resource at the specified path exists, {@code false} otherwise. This
  3. * method supports scheme prefixes on the path as defined in {@link #getInputStreamForPath(String)}.
  4. *
  5. * @param resourcePath the path of the resource to check.
  6. * @return {@code true} if the resource at the specified path exists, {@code false} otherwise.
  7. * @since 0.9
  8. */
  9. public static boolean resourceExists(String resourcePath) {
  10. InputStream stream = null;
  11. boolean exists = false;
  12. try {
  13. stream = getInputStreamForPath(resourcePath);
  14. exists = true;
  15. } catch (IOException e) {
  16. stream = null;
  17. } finally {
  18. if (stream != null) {
  19. try {
  20. stream.close();
  21. } catch (IOException ignored) {
  22. }
  23. }
  24. }
  25. return exists;
  26. }

代码示例来源:origin: gitblit/fathom

  1. String contentType = Util.getPreSubstring(context.getRequest().getHeader("Content-Type").toLowerCase(), ';');
  2. if (!guardedTypes.contains(contentType)) {
  3. log.debug("Ignoring '{}' request for {} '{}'", contentType, context.getRequestMethod(),

代码示例来源:origin: gitblit/fathom

  1. protected void logCacheSettings(Logger log) {
  2. Util.logSetting(log, "caching", accountCache != null);
  3. Util.logSetting(log, "cacheTtl (mins)", cacheTtl);
  4. Util.logSetting(log, "cacheMax (accounts)", cacheMax);
  5. }

代码示例来源:origin: com.gitblit.fathom/fathom-xmlrpc

  1. Object invokeMethod(Method method, List<Object> methodParameters) throws Exception {
  2. Object[] argValues = null;
  3. if (methodParameters != null) {
  4. argValues = new Object[methodParameters.size()];
  5. for (int i = 0; i < methodParameters.size(); i++) {
  6. argValues[i] = methodParameters.get(i);
  7. }
  8. }
  9. try {
  10. method.setAccessible(true);
  11. return method.invoke(invokeTarget, argValues);
  12. } catch (IllegalAccessException | IllegalArgumentException e) {
  13. throw e;
  14. } catch (InvocationTargetException e) {
  15. Throwable t = e.getTargetException();
  16. log.error("Failed to execute {}", Util.toString(method), t);
  17. throw new FathomException(t.getMessage());
  18. }
  19. }

代码示例来源:origin: gitblit/fathom

  1. public DomainPermission(String actions, String targets) {
  2. this.domain = getDomain(getClass());
  3. this.actions = Util.splitToSet(actions, SUBPART_DIVIDER_TOKEN);
  4. this.targets = Util.splitToSet(targets, SUBPART_DIVIDER_TOKEN);
  5. encodeParts(this.domain, actions, targets);
  6. }

代码示例来源:origin: com.gitblit.fathom/fathom-security-ldap

  1. @Override
  2. public void start() {
  3. log.debug("Realm '{}' configuration:", getRealmName());
  4. Util.logSetting(log, "url", ldapUrl);
  5. Util.logSetting(log, "username", ldapUsername);
  6. Util.logSetting(log, "password", ldapPassword);
  7. Util.logSetting(log, "bindPattern", ldapBindPattern);
  8. Util.logSetting(log, "accountBase", accountBase);
  9. Util.logSetting(log, "accountPattern", accountPattern);
  10. Util.logSetting(log, "nameMapping", nameMapping);
  11. Util.logSetting(log, "emailMapping", emailMapping);
  12. Util.logSetting(log, "groupBase", groupBase);
  13. Util.logSetting(log, "groupMemberPattern", groupMemberPattern);
  14. Util.logSetting(log, "adminGroups", adminGroups);
  15. super.logCacheSettings(log);
  16. }

代码示例来源:origin: gitblit/fathom

  1. public static Class<?> getParameterGenericType(Method method, Parameter parameter) {
  2. Type parameterType = parameter.getParameterizedType();
  3. if (!ParameterizedType.class.isAssignableFrom(parameterType.getClass())) {
  4. throw new FathomException("Please specify a generic parameter type for '{}' of '{}'",
  5. parameter.getType().getName(), Util.toString(method));
  6. }
  7. ParameterizedType parameterizedType = (ParameterizedType) parameterType;
  8. try {
  9. Class<?> genericClass = (Class<?>) parameterizedType.getActualTypeArguments()[0];
  10. return genericClass;
  11. } catch (ClassCastException e) {
  12. throw new FathomException("Please specify a generic parameter type for '{}' of '{}'",
  13. parameter.getType().getName(), Util.toString(method));
  14. }
  15. }

代码示例来源:origin: com.gitblit.fathom/fathom-security

  1. protected void setParts(String wildcardString, boolean caseSensitive) {
  2. if (wildcardString == null || wildcardString.trim().length() == 0) {
  3. throw new IllegalArgumentException("Wildcard string cannot be null or empty. Make sure permission strings are properly formatted.");
  4. }
  5. wildcardString = wildcardString.trim();
  6. List<String> parts = Arrays.asList(wildcardString.split(PART_DIVIDER_TOKEN));
  7. this.parts = new ArrayList<>();
  8. for (String part : parts) {
  9. Set<String> subparts = Util.splitToSet(part, SUBPART_DIVIDER_TOKEN);
  10. if (!caseSensitive) {
  11. subparts = lowercase(subparts);
  12. }
  13. if (subparts.isEmpty()) {
  14. throw new IllegalArgumentException("Wildcard string cannot contain parts with only dividers. Make sure permission strings are properly formatted.");
  15. }
  16. this.parts.add(subparts);
  17. }
  18. if (this.parts.isEmpty()) {
  19. throw new IllegalArgumentException("Wildcard string cannot contain only dividers. Make sure permission strings are properly formatted.");
  20. }
  21. }

代码示例来源:origin: gitblit/fathom

  1. @Override
  2. public void start() {
  3. log.debug("Realm '{}' configuration:", getRealmName());
  4. Util.logSetting(log, "url", ldapUrl);
  5. Util.logSetting(log, "username", ldapUsername);
  6. Util.logSetting(log, "password", ldapPassword);
  7. Util.logSetting(log, "bindPattern", ldapBindPattern);
  8. Util.logSetting(log, "accountBase", accountBase);
  9. Util.logSetting(log, "accountPattern", accountPattern);
  10. Util.logSetting(log, "nameMapping", nameMapping);
  11. Util.logSetting(log, "emailMapping", emailMapping);
  12. Util.logSetting(log, "groupBase", groupBase);
  13. Util.logSetting(log, "groupMemberPattern", groupMemberPattern);
  14. Util.logSetting(log, "adminGroups", adminGroups);
  15. super.logCacheSettings(log);
  16. }

代码示例来源:origin: gitblit/fathom

  1. /**
  2. * Validates that the declared content-types can actually be generated by Fathom.
  3. *
  4. * @param fathomContentTypes
  5. */
  6. protected void validateProduces(Collection<String> fathomContentTypes) {
  7. Set<String> ignoreProduces = new TreeSet<>();
  8. ignoreProduces.add(Produces.TEXT);
  9. ignoreProduces.add(Produces.HTML);
  10. ignoreProduces.add(Produces.XHTML);
  11. for (String produces : declaredProduces) {
  12. if (ignoreProduces.contains(produces)) {
  13. continue;
  14. }
  15. if (!fathomContentTypes.contains(produces)) {
  16. throw new FatalException("{} declares @{}(\"{}\") but there is no registered ContentTypeEngine for that type!",
  17. Util.toString(method), Produces.class.getSimpleName(), produces);
  18. }
  19. }
  20. }

代码示例来源:origin: gitblit/fathom

  1. protected void setParts(String wildcardString, boolean caseSensitive) {
  2. if (wildcardString == null || wildcardString.trim().length() == 0) {
  3. throw new IllegalArgumentException("Wildcard string cannot be null or empty. Make sure permission strings are properly formatted.");
  4. }
  5. wildcardString = wildcardString.trim();
  6. List<String> parts = Arrays.asList(wildcardString.split(PART_DIVIDER_TOKEN));
  7. this.parts = new ArrayList<>();
  8. for (String part : parts) {
  9. Set<String> subparts = Util.splitToSet(part, SUBPART_DIVIDER_TOKEN);
  10. if (!caseSensitive) {
  11. subparts = lowercase(subparts);
  12. }
  13. if (subparts.isEmpty()) {
  14. throw new IllegalArgumentException("Wildcard string cannot contain parts with only dividers. Make sure permission strings are properly formatted.");
  15. }
  16. this.parts.add(subparts);
  17. }
  18. if (this.parts.isEmpty()) {
  19. throw new IllegalArgumentException("Wildcard string cannot contain only dividers. Make sure permission strings are properly formatted.");
  20. }
  21. }

代码示例来源:origin: gitblit/fathom

  1. public static void logSetting(Logger log, Enum<?> name, Object value) {
  2. logSetting(log, name.toString(), value);
  3. }

代码示例来源:origin: com.gitblit.fathom/fathom-rest

  1. /**
  2. * Validates that the declared content-types can actually be generated by Fathom.
  3. *
  4. * @param fathomContentTypes
  5. */
  6. protected void validateProduces(Collection<String> fathomContentTypes) {
  7. Set<String> ignoreProduces = new TreeSet<>();
  8. ignoreProduces.add(Produces.TEXT);
  9. ignoreProduces.add(Produces.HTML);
  10. ignoreProduces.add(Produces.XHTML);
  11. for (String produces : declaredProduces) {
  12. if (ignoreProduces.contains(produces)) {
  13. continue;
  14. }
  15. if (!fathomContentTypes.contains(produces)) {
  16. throw new FatalException("{} declares @{}(\"{}\") but there is no registered ContentTypeEngine for that type!",
  17. Util.toString(method), Produces.class.getSimpleName(), produces);
  18. }
  19. }
  20. }

代码示例来源:origin: com.gitblit.fathom/fathom-security

  1. public DomainPermission(String actions) {
  2. domain = getDomain(getClass());
  3. this.actions = Util.splitToSet(actions, SUBPART_DIVIDER_TOKEN);
  4. encodeParts(domain, actions, null);
  5. }

代码示例来源:origin: com.gitblit.fathom/fathom-security-htpasswd

  1. @Override
  2. public void start() {
  3. log.debug("Realm '{}' configuration:", getRealmName());
  4. Util.logSetting(log, "file", file);
  5. Util.logSetting(log, "allowClearPasswords", isAllowClearTextPasswords);
  6. }

代码示例来源:origin: gitblit/fathom

  1. Object invokeMethod(Method method, List<Object> methodParameters) throws Exception {
  2. Object[] argValues = null;
  3. if (methodParameters != null) {
  4. argValues = new Object[methodParameters.size()];
  5. for (int i = 0; i < methodParameters.size(); i++) {
  6. argValues[i] = methodParameters.get(i);
  7. }
  8. }
  9. try {
  10. method.setAccessible(true);
  11. return method.invoke(invokeTarget, argValues);
  12. } catch (IllegalAccessException | IllegalArgumentException e) {
  13. throw e;
  14. } catch (InvocationTargetException e) {
  15. Throwable t = e.getTargetException();
  16. log.error("Failed to execute {}", Util.toString(method), t);
  17. throw new FathomException(t.getMessage());
  18. }
  19. }

相关文章