JavaDocs and use of isEmpty()
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/0d70b3c3 Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/0d70b3c3 Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/0d70b3c3 Branch: refs/heads/master Commit: 0d70b3c3081704d9556eb7b10775c038a67fe869 Parents: 298cdee Author: Hayri Cicek <ha...@kodnito.com> Authored: Fri Dec 7 21:52:37 2018 +0100 Committer: Hayri Cicek <ha...@kodnito.com> Committed: Fri Dec 7 21:52:37 2018 +0100 ---------------------------------------------------------------------- .../org/apache/openejb/loader/ClassPath.java | 10 + .../apache/openejb/loader/ClassPathFactory.java | 6 + .../apache/openejb/loader/ContextClassPath.java | 4 +- .../org/apache/openejb/loader/FileUtils.java | 22 +-- .../org/apache/openejb/loader/JarLocation.java | 32 +++- .../java/org/apache/openejb/loader/Loader.java | 5 + .../openejb/loader/LoaderRuntimeException.java | 10 + .../apache/openejb/loader/OpenEJBInstance.java | 13 ++ .../java/org/apache/openejb/loader/Options.java | 185 ++++++++++++++++++- 9 files changed, 270 insertions(+), 17 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tomee/blob/0d70b3c3/container/openejb-loader/src/main/java/org/apache/openejb/loader/ClassPath.java ---------------------------------------------------------------------- diff --git a/container/openejb-loader/src/main/java/org/apache/openejb/loader/ClassPath.java b/container/openejb-loader/src/main/java/org/apache/openejb/loader/ClassPath.java index 6cdb335..3baef29 100644 --- a/container/openejb-loader/src/main/java/org/apache/openejb/loader/ClassPath.java +++ b/container/openejb-loader/src/main/java/org/apache/openejb/loader/ClassPath.java @@ -23,7 +23,17 @@ public interface ClassPath { ClassLoader getClassLoader(); + /** + * + * @param dir File + * @throws Exception + */ void addJarsToPath(File dir) throws Exception; + /** + * + * @param dir URL + * @throws Exception + */ void addJarToPath(URL dir) throws Exception; } http://git-wip-us.apache.org/repos/asf/tomee/blob/0d70b3c3/container/openejb-loader/src/main/java/org/apache/openejb/loader/ClassPathFactory.java ---------------------------------------------------------------------- diff --git a/container/openejb-loader/src/main/java/org/apache/openejb/loader/ClassPathFactory.java b/container/openejb-loader/src/main/java/org/apache/openejb/loader/ClassPathFactory.java index 6eb20bb..4201bab 100644 --- a/container/openejb-loader/src/main/java/org/apache/openejb/loader/ClassPathFactory.java +++ b/container/openejb-loader/src/main/java/org/apache/openejb/loader/ClassPathFactory.java @@ -21,6 +21,12 @@ import java.net.URLClassLoader; import static java.lang.ClassLoader.getSystemClassLoader; public class ClassPathFactory { + + /** + * + * @param name String + * @return ClassPath + */ @SuppressWarnings("checkstyle:needbraces") public static ClassPath createClassPath(final String name) { if (name.equalsIgnoreCase("tomcat")) return new TomcatClassPath(); http://git-wip-us.apache.org/repos/asf/tomee/blob/0d70b3c3/container/openejb-loader/src/main/java/org/apache/openejb/loader/ContextClassPath.java ---------------------------------------------------------------------- diff --git a/container/openejb-loader/src/main/java/org/apache/openejb/loader/ContextClassPath.java b/container/openejb-loader/src/main/java/org/apache/openejb/loader/ContextClassPath.java index 68cfdae..fe92b6f 100644 --- a/container/openejb-loader/src/main/java/org/apache/openejb/loader/ContextClassPath.java +++ b/container/openejb-loader/src/main/java/org/apache/openejb/loader/ContextClassPath.java @@ -37,7 +37,7 @@ public class ContextClassPath extends BasicURLClassPath { /** * - * @param dir + * @param dir File * @throws Exception */ @Override @@ -51,7 +51,7 @@ public class ContextClassPath extends BasicURLClassPath { /** * - * @param jar + * @param jar URL * @throws Exception */ @Override http://git-wip-us.apache.org/repos/asf/tomee/blob/0d70b3c3/container/openejb-loader/src/main/java/org/apache/openejb/loader/FileUtils.java ---------------------------------------------------------------------- diff --git a/container/openejb-loader/src/main/java/org/apache/openejb/loader/FileUtils.java b/container/openejb-loader/src/main/java/org/apache/openejb/loader/FileUtils.java index e710136..6a5ea98 100644 --- a/container/openejb-loader/src/main/java/org/apache/openejb/loader/FileUtils.java +++ b/container/openejb-loader/src/main/java/org/apache/openejb/loader/FileUtils.java @@ -34,9 +34,9 @@ public class FileUtils { /** * - * @param homeDir - * @param defaultDir - * @param env + * @param homeDir String + * @param defaultDir String + * @param env Hashtable */ @SuppressWarnings("UseOfObsoleteCollectionType") public FileUtils(final String homeDir, final String defaultDir, final Hashtable env) { @@ -67,7 +67,7 @@ public class FileUtils { /** * - * @param path + * @param path String * @return File * @throws IOException */ @@ -86,8 +86,8 @@ public class FileUtils { /** * - * @param path - * @param create + * @param path String + * @param create boolean * @return File * @throws IOException */ @@ -121,7 +121,7 @@ public class FileUtils { /** * - * @param dir + * @param dir File */ public void setDirectory(final File dir) { this.home = dir; @@ -129,7 +129,7 @@ public class FileUtils { /** * - * @param path + * @param path String * @return File * @throws IOException */ @@ -139,8 +139,8 @@ public class FileUtils { /** * - * @param path - * @param validate + * @param path String + * @param validate boolean * @return File * @throws IOException */ @@ -162,7 +162,7 @@ public class FileUtils { /** * - * @param pathPrefix + * @param pathPrefix String * @return File * @throws IOException */ http://git-wip-us.apache.org/repos/asf/tomee/blob/0d70b3c3/container/openejb-loader/src/main/java/org/apache/openejb/loader/JarLocation.java ---------------------------------------------------------------------- diff --git a/container/openejb-loader/src/main/java/org/apache/openejb/loader/JarLocation.java b/container/openejb-loader/src/main/java/org/apache/openejb/loader/JarLocation.java index 4294e3a..7e6509f 100644 --- a/container/openejb-loader/src/main/java/org/apache/openejb/loader/JarLocation.java +++ b/container/openejb-loader/src/main/java/org/apache/openejb/loader/JarLocation.java @@ -26,14 +26,29 @@ import java.net.URL; */ public class JarLocation { + /** + * + * @return File + */ public static File get() { return jarLocation(JarLocation.class); } + /** + * + * @param resourceName String + * @return File + */ public static File jarFromResource(final String resourceName) { return jarFromResource(Thread.currentThread().getContextClassLoader(), resourceName); } + /** + * + * @param loader ClassLoader + * @param resourceName String + * @return File + */ public static File jarFromResource(final ClassLoader loader, final String resourceName) { try { URL url = loader.getResource(resourceName); @@ -68,6 +83,11 @@ public class JarLocation { } } + /** + * + * @param clazz Class + * @return File + */ public static File jarLocation(final Class clazz) { try { final String classFileName = clazz.getName().replace(".", "/") + ".class"; @@ -80,13 +100,23 @@ public class JarLocation { } } + /** + * + * @param classFileName String + * @param url URL + * @return File + */ public static File toFile(final String classFileName, final URL url) { String path = url.getFile(); path = path.substring(0, path.length() - classFileName.length()); return new File(decode(path)); } - + /** + * + * @param fileName String + * @return String + */ public static String decode(final String fileName) { if (fileName.indexOf('%') == -1) { return fileName; http://git-wip-us.apache.org/repos/asf/tomee/blob/0d70b3c3/container/openejb-loader/src/main/java/org/apache/openejb/loader/Loader.java ---------------------------------------------------------------------- diff --git a/container/openejb-loader/src/main/java/org/apache/openejb/loader/Loader.java b/container/openejb-loader/src/main/java/org/apache/openejb/loader/Loader.java index 2ebadbb..635f30b 100644 --- a/container/openejb-loader/src/main/java/org/apache/openejb/loader/Loader.java +++ b/container/openejb-loader/src/main/java/org/apache/openejb/loader/Loader.java @@ -20,6 +20,11 @@ import java.util.Properties; public interface Loader { + /** + * + * @param properties Properties + * @throws Exception + */ void init(Properties properties) throws Exception; } http://git-wip-us.apache.org/repos/asf/tomee/blob/0d70b3c3/container/openejb-loader/src/main/java/org/apache/openejb/loader/LoaderRuntimeException.java ---------------------------------------------------------------------- diff --git a/container/openejb-loader/src/main/java/org/apache/openejb/loader/LoaderRuntimeException.java b/container/openejb-loader/src/main/java/org/apache/openejb/loader/LoaderRuntimeException.java index e894074..b9fc239 100644 --- a/container/openejb-loader/src/main/java/org/apache/openejb/loader/LoaderRuntimeException.java +++ b/container/openejb-loader/src/main/java/org/apache/openejb/loader/LoaderRuntimeException.java @@ -17,10 +17,20 @@ package org.apache.openejb.loader; public class LoaderRuntimeException extends RuntimeException { + + /** + * + * @param str String + * @param e Throwable + */ public LoaderRuntimeException(final String str, final Throwable e) { super(str, e); } + /** + * + * @param e Exception + */ public LoaderRuntimeException(final Exception e) { super(e); } http://git-wip-us.apache.org/repos/asf/tomee/blob/0d70b3c3/container/openejb-loader/src/main/java/org/apache/openejb/loader/OpenEJBInstance.java ---------------------------------------------------------------------- diff --git a/container/openejb-loader/src/main/java/org/apache/openejb/loader/OpenEJBInstance.java b/container/openejb-loader/src/main/java/org/apache/openejb/loader/OpenEJBInstance.java index c1dc806..43ab11c 100644 --- a/container/openejb-loader/src/main/java/org/apache/openejb/loader/OpenEJBInstance.java +++ b/container/openejb-loader/src/main/java/org/apache/openejb/loader/OpenEJBInstance.java @@ -25,12 +25,21 @@ public class OpenEJBInstance { private final Method init; private final Method isInitialized; + /** + * + * @throws Exception + */ public OpenEJBInstance() throws Exception { final Class<?> openejb = loadOpenEJBClass(); this.init = openejb.getMethod("init", Properties.class); this.isInitialized = openejb.getMethod("isInitialized"); } + /** + * + * @param props Properties + * @throws Exception + */ public void init(final Properties props) throws Exception { try { init.invoke(null, props); @@ -44,6 +53,10 @@ public class OpenEJBInstance { } } + /** + * + * @return boolean + */ public boolean isInitialized() { try { return (Boolean) isInitialized.invoke(null); http://git-wip-us.apache.org/repos/asf/tomee/blob/0d70b3c3/container/openejb-loader/src/main/java/org/apache/openejb/loader/Options.java ---------------------------------------------------------------------- diff --git a/container/openejb-loader/src/main/java/org/apache/openejb/loader/Options.java b/container/openejb-loader/src/main/java/org/apache/openejb/loader/Options.java index d6e2482..c0fcf19 100644 --- a/container/openejb-loader/src/main/java/org/apache/openejb/loader/Options.java +++ b/container/openejb-loader/src/main/java/org/apache/openejb/loader/Options.java @@ -73,37 +73,76 @@ public class Options { private final Options parent; private final TomEEPropertyAdapter properties; + /** + * + * @param properties Properties + */ public Options(final Properties properties) { this(properties, new NullOptions()); } + /** + * + * @param properties Properties + * @param parent Options + */ public Options(final Properties properties, final Options parent) { this.parent = parent; this.properties = new TomEEPropertyAdapter(properties); } + /** + * + * @return Properties + */ public Properties getProperties() { return properties.delegate; } + /** + * + * @param logger Log + */ public void setLogger(final Log logger) { parent.setLogger(logger); } + /** + * + * @return Log + */ public Log getLogger() { return parent.getLogger(); } + /** + * + * @param property String + * @return boolean + */ public boolean has(final String property) { return properties.containsKey(property) || parent.has(property); } + /** + * + * @param property String + * @param defaultValue String + * @return String + */ public String get(final String property, final String defaultValue) { final String value = properties.getProperty(property); return value != null ? log(property, value) : parent.get(property, defaultValue); } + /** + * + * @param <T> + * @param property String + * @param defaultValue T + * @return + */ @SuppressWarnings("unchecked") public <T> T get(final String property, final T defaultValue) { if (defaultValue == null) { @@ -128,6 +167,12 @@ public class Options { } } + /** + * + * @param property String + * @param defaultValue int + * @return int + */ public int get(final String property, final int defaultValue) { final String value = properties.getProperty(property); @@ -143,6 +188,12 @@ public class Options { } } + /** + * + * @param property String + * @param defaultValue long + * @return long + */ public long get(final String property, final long defaultValue) { final String value = properties.getProperty(property); @@ -158,6 +209,12 @@ public class Options { } } + /** + * + * @param property String + * @param defaultValue boolean + * @return boolean + */ public boolean get(final String property, final boolean defaultValue) { final String value = properties.getProperty(property); @@ -173,6 +230,12 @@ public class Options { } } + /** + * + * @param property String + * @param defaultValue + * @return + */ public Class<?> get(final String property, final Class<?> defaultValue) { final String className = properties.getProperty(property); @@ -189,6 +252,13 @@ public class Options { } } + /** + * + * @param <T> + * @param property String + * @param defaultValue + * @return + */ public <T extends Enum<T>> T get(final String property, final T defaultValue) { final String value = properties.getProperty(property); @@ -210,11 +280,25 @@ public class Options { } } + /** + * + * @param <T> + * @param property String + * @param defaultValue T... + * @return + */ public <T extends Enum<T>> Set<T> getAll(final String property, final T... defaultValue) { final EnumSet<T> defaults = EnumSet.copyOf(Arrays.asList(defaultValue)); return getAll(property, defaults); } + /** + * + * @param <T> + * @param property String + * @param defaultValue + * @return + */ public <T extends Enum<T>> Set<T> getAll(final String property, final Set<T> defaultValue) { final Class<T> enumType; try { @@ -227,6 +311,13 @@ public class Options { return getAll(property, defaultValue, enumType); } + /** + * + * @param <T> + * @param property String + * @param enumType + * @return + */ public <T extends Enum<T>> Set<T> getAll(final String property, final Class<T> enumType) { return getAll(property, Collections.EMPTY_SET, enumType); } @@ -310,6 +401,13 @@ public class Options { return value; } + /** + * + * @param <T> + * @param property String + * @param value + * @return + */ public <T extends Enum<T>> Set<T> logAll(final String property, final Set<T> value) { if (!getLogger().isInfoEnabled()) { return value; @@ -320,7 +418,12 @@ public class Options { return value; } - + /** + * + * @param <T> + * @param items + * @return + */ protected static <T extends Enum<T>> String[] lowercase(final T... items) { final String[] values = new String[items.length]; for (int i = 0; i < items.length; i++) { @@ -329,6 +432,12 @@ public class Options { return values; } + /** + * + * @param <T> + * @param items + * @return + */ protected static <T extends Enum<T>> String[] lowercase(final Collection<T> items) { final String[] values = new String[items.size()]; int i = 0; @@ -338,16 +447,32 @@ public class Options { return values; } + /** + * + * @param <V> + * @param v + * @return + */ protected static <V extends Enum<V>> String possibleValues(final V v) { final Class<? extends Enum> enumType = v.getClass(); return possibleValues(enumType); } + /** + * + * @param enumType + * @return + */ protected static String possibleValues(final Class<? extends Enum> enumType) { return join(", ", lowercase(enumType.getEnumConstants())); } - + /** + * + * @param delimiter String + * @param collection Object... + * @return String + */ public static String join(final String delimiter, final Object... collection) { final StringBuilder sb = new StringBuilder(); for (final Object obj : collection) { @@ -422,7 +547,7 @@ public class Options { final String defaultValues; - if (defaults.size() == 0) { + if (defaults.isEmpty()) { defaultValues = "NONE"; } else if (defaults.size() == enumType.getEnumConstants().length) { defaultValues = "ALL"; @@ -469,10 +594,19 @@ public class Options { public static final int OPENEJB_PREFIX_LENGHT = "openejb.".length(); private final Properties delegate; + /** + * + * @param properties Properties + */ public TomEEPropertyAdapter(final Properties properties) { this.delegate = properties; } + /** + * + * @param key String + * @return String + */ public String getProperty(final String key) { String value = delegate.getProperty(key); @@ -483,6 +617,11 @@ public class Options { return value; } + /** + * + * @param key String + * @return boolean + */ public boolean containsKey(final String key) { return delegate.containsKey(key) || delegate.containsKey(getTomeeKey(key)); @@ -514,41 +653,81 @@ public class Options { } public static class NullLog implements Log { + + /** + * + * @return boolean + */ @Override public boolean isDebugEnabled() { return false; } + /** + * + * @return boolean + */ @Override public boolean isInfoEnabled() { return false; } + /** + * + * @return boolean + */ @Override public boolean isWarningEnabled() { return false; } + /** + * + * @param message String + * @param t Throwable + */ @Override public void warning(final String message, final Throwable t) { } + /** + * + * @param message String + */ @Override public void warning(final String message) { } + /** + * + * @param message String + * @param t Throwable + */ @Override public void debug(final String message, final Throwable t) { } + /** + * + * @param message String + */ @Override public void debug(final String message) { } + /** + * + * @param message String + * @param t Throwable + */ @Override public void info(final String message, final Throwable t) { } + /** + * + * @param message String + */ @Override public void info(final String message) { }