Nuiton-utils-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- 3157 discussions
Author: bleny
Date: 2013-03-13 14:39:11 +0100 (Wed, 13 Mar 2013)
New Revision: 2529
Url: http://nuiton.org/projects/nuiton-utils/repository/revisions/2529
Log:
add .idea to svn:ignore
Modified:
trunk/
Property changes on: trunk
___________________________________________________________________
Modified: svn:ignore
- target
velocity.log
maven.log
.eclipse
.classpath
*.iml
*.ipr
*.iws
.settings
.project
testdir
+ target
velocity.log
maven.log
.eclipse
.classpath
*.iml
*.ipr
*.iws
.settings
.project
testdir
.idea
1
0
r2528 - trunk/nuiton-updater/src/main/java/org/nuiton/util/updater
by tchemit@users.nuiton.org 12 Mar '13
by tchemit@users.nuiton.org 12 Mar '13
12 Mar '13
Author: tchemit
Date: 2013-03-13 00:03:34 +0100 (Wed, 13 Mar 2013)
New Revision: 2528
Url: http://nuiton.org/projects/nuiton-utils/repository/revisions/2528
Log:
fixes #2547: Add a progression model when downloading the update
fixes #2590: Improve download api
Added:
trunk/nuiton-updater/src/main/java/org/nuiton/util/updater/DownloadMonitor.java
trunk/nuiton-updater/src/main/java/org/nuiton/util/updater/UpdateInvalidArchiveLayoutException.java
trunk/nuiton-updater/src/main/java/org/nuiton/util/updater/UpdateNotFoundException.java
Modified:
trunk/nuiton-updater/src/main/java/org/nuiton/util/updater/ApplicationInfo.java
trunk/nuiton-updater/src/main/java/org/nuiton/util/updater/ApplicationUpdater.java
Modified: trunk/nuiton-updater/src/main/java/org/nuiton/util/updater/ApplicationInfo.java
===================================================================
--- trunk/nuiton-updater/src/main/java/org/nuiton/util/updater/ApplicationInfo.java 2013-03-12 16:07:04 UTC (rev 2527)
+++ trunk/nuiton-updater/src/main/java/org/nuiton/util/updater/ApplicationInfo.java 2013-03-12 23:03:34 UTC (rev 2528)
@@ -25,6 +25,7 @@
*/
import java.io.File;
+import java.io.Serializable;
/**
* TODO
@@ -33,8 +34,10 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 2.7
*/
-public class ApplicationInfo {
+public class ApplicationInfo implements Serializable {
+ private static final long serialVersionUID = 1L;
+
public String name;
public String oldVersion;
Modified: trunk/nuiton-updater/src/main/java/org/nuiton/util/updater/ApplicationUpdater.java
===================================================================
--- trunk/nuiton-updater/src/main/java/org/nuiton/util/updater/ApplicationUpdater.java 2013-03-12 16:07:04 UTC (rev 2527)
+++ trunk/nuiton-updater/src/main/java/org/nuiton/util/updater/ApplicationUpdater.java 2013-03-12 23:03:34 UTC (rev 2528)
@@ -25,6 +25,7 @@
*/
import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -35,14 +36,15 @@
import org.apache.commons.vfs2.FileSystemOptions;
import org.apache.commons.vfs2.VFS;
import org.apache.commons.vfs2.provider.http.HttpFileSystemConfigBuilder;
+import org.nuiton.util.VersionUtil;
import org.nuiton.util.config.ApplicationConfig;
import org.nuiton.util.config.ArgumentsParserException;
-import org.nuiton.util.VersionUtil;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
+import java.io.OutputStream;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
@@ -134,18 +136,20 @@
final static private String SEPARATOR_KEY = ".";
- public static final String HTTP_PROXY = "http_proxy";
+ public static final String HTTP_PROXY = "http_proxy";
- public static final String URL_KEY = "url";
+ public static final String URL_KEY = "url";
- public static final String AUTHENTICATION_KEY = "auth";
+ public static final String AUTHENTICATION_KEY = "auth";
- public static final String VERSION_KEY = "version";
+ public static final String VERSION_KEY = "version";
- public static final String VERSION_FILE = "version.appup";
+ public static final String VERSION_FILE = "version.appup";
protected ApplicationConfig config;
+ protected DownloadMonitor downloadMonitor;
+
/** Utilise le fichier de configuration par defaut: ApplicationUpdater.properties */
public ApplicationUpdater() {
this(null);
@@ -170,6 +174,9 @@
this.config = config;
}
+ public void setDownloadMonitor(DownloadMonitor downloadMonitor) {
+ this.downloadMonitor = downloadMonitor;
+ }
/**
* @param url url where properties file is downloadable. This properties
@@ -184,7 +191,7 @@
File destDir,
boolean async,
ApplicationUpdaterCallback callback) {
- Updater up = new Updater(config, url, currentDir, destDir, callback);
+ Updater up = new Updater(config, url, currentDir, destDir, downloadMonitor, callback);
if (async) {
Thread thread = new Thread(up, ApplicationUpdater.class.getSimpleName());
thread.start();
@@ -193,6 +200,11 @@
}
}
+ public static void createVersionFile(File dir, String version) throws IOException {
+ File versionFile = new File(dir, VERSION_FILE);
+ FileUtils.writeStringToFile(versionFile, version);
+ }
+
/**
* La classe ou le travail est reellement fait, peut-etre appeler dans
* un thread si necessaire.
@@ -209,15 +221,19 @@
protected ApplicationUpdaterCallback callback;
+ protected DownloadMonitor downloadMonitor;
+
public Updater(ApplicationConfig config,
String vfsPropertiesUrl,
File currentDir,
File destDir,
+ DownloadMonitor downloadMonitor,
ApplicationUpdaterCallback callback) {
this.config = config;
this.vfsPropertiesUrl = vfsPropertiesUrl;
this.currentDir = currentDir;
this.destDir = destDir;
+ this.downloadMonitor = downloadMonitor;
this.callback = callback;
}
@@ -228,6 +244,7 @@
* <p/>
* Si callback existe envoi les messages necessaire
*/
+ @Override
public void run() {
try {
FileSystemOptions vfsConfig = getVFSConfig(config);
@@ -282,7 +299,6 @@
log.debug("Can't clean directory", doNothing);
}
-
log.warn(String.format(
"Can't update application '%s' with url '%s'",
app, info.url));
@@ -311,10 +327,11 @@
* nommera au final "monApp/Readme.txt"
*
* @param vfsConfig le proxy a utiliser pour la connexion a l'url
- * @param info information sur l'application a mettre a jour
+ * @param info information sur l'application a mettre a jour
* @throws Exception
*/
- protected void doUpdate(FileSystemOptions vfsConfig, ApplicationInfo info) throws Exception {
+ protected void doUpdate(FileSystemOptions vfsConfig,
+ ApplicationInfo info) throws Exception {
if (info.destDir != null) {
File dest = new File(info.destDir, info.name);
String url = toVfsURL(info.url);
@@ -325,11 +342,22 @@
if (callback != null) {
callback.startUpdate(info);
}
- deepCopy(vfsConfig, url, dest.getAbsolutePath());
+ // le type de l'archive contenant la mise à jour
+ String archiveType = url.substring(0, url.indexOf(':'));
+
+ // recuperation de l'archive en locale (dans /tmp)
+ File archive = downloadUpdate(vfsConfig, info, url.substring(archiveType.length() + 1));
+
+ // extraction depuis l'archive téléchargée de l'unique répertoire vers la destination
+ explodeUpdate(vfsConfig,
+ info,
+ archiveType,
+ archive,
+ dest);
+
// ajout du fichier de version
- File versionFile = new File(dest, VERSION_FILE);
- FileUtils.writeStringToFile(versionFile, info.newVersion);
+ createVersionFile(dest, info.newVersion);
log.info(String.format(
"Application '%s' is uptodate with version '%s' in '%s'",
info.name, info.newVersion, info.destDir));
@@ -339,6 +367,94 @@
}
/**
+ * Télécharge une archive dans un fichier temporaraire.
+ * <p/>
+ * Si l'archive a plus d'un repertoire root, une exception est levee
+ *
+ * @param info
+ * @param srcPath source path de la forme vfs2 ex:"zip:http://www.nuiton.org/attachments/download/830/nuiton-utils-2.6.5-deps.…"
+ * @throws FileSystemException
+ */
+ protected File downloadUpdate(FileSystemOptions vfsConfig,
+ ApplicationInfo info,
+ String srcPath) throws IOException {
+ File result = new File(FileUtils.getTempDirectory(), srcPath);
+
+ FileSystemManager fsManager = VFS.getManager();
+ FileObject source = fsManager.resolveFile(srcPath, vfsConfig);
+
+ if (!source.exists()) {
+ throw new UpdateNotFoundException(info);
+ }
+ FileObject target = fsManager.toFileObject(result);
+ InputStream input = source.getContent().getInputStream();
+ try {
+ OutputStream output = target.getContent().getOutputStream();
+ try {
+ long inputSize = source.getContent().getSize();
+ if (downloadMonitor != null) {
+ downloadMonitor.setSize(inputSize);
+ }
+ long count = 0;
+ int n;
+ byte[] buffer = new byte[1024];
+ while (-1 != (n = input.read(buffer))) {
+ output.write(buffer, 0, n);
+ count += n;
+ if (downloadMonitor != null) {
+ downloadMonitor.setCurrent(count);
+ }
+ }
+ output.close();
+ } finally {
+
+ IOUtils.closeQuietly(output);
+ }
+ input.close();
+ } finally {
+ IOUtils.closeQuietly(input);
+ }
+ return result;
+ }
+
+ /**
+ * Recopie le contenu du répertoire de l'archive dans le
+ * répertoire {@code target}.
+ * <p/>
+ * Si le répertoire cible existe déjà, il sera alors vidé.
+ * <p/>
+ * Si l'archive ne contient pas exactement un répertoire alors une exception est levée
+ *
+ * @param archiveType le type de l'archive
+ * @param source l'archive à décompresser
+ * @param target le répertoire cible
+ * @throws FileSystemException
+ * @throws UpdateInvalidArchiveLayoutException
+ * si l'archive n'a pas le bon format
+ */
+ protected void explodeUpdate(FileSystemOptions vfsConfig,
+ ApplicationInfo info,
+ String archiveType,
+ File source,
+ File target) throws FileSystemException, UpdateInvalidArchiveLayoutException {
+
+ FileSystemManager fsManager = VFS.getManager();
+ FileObject sourceObject = fsManager.resolveFile(archiveType + ":" + source.getAbsolutePath(), vfsConfig);
+
+ FileObject[] children = sourceObject.getChildren();
+ if (children.length != 1) {
+ throw new UpdateInvalidArchiveLayoutException(info, source);
+ }
+ // clean target
+ FileObject targetObject = fsManager.toFileObject(target);
+ targetObject.delete(new AllFileSelector());
+
+ //copy to it the archive only directory
+ FileObject child = children[0];
+ targetObject.copyFrom(child, new AllFileSelector());
+ }
+
+ /**
* Recupere le contenu du repertoire de l'archive pour le mettre dans targetPath
* si targetPath existait deja, il est supprime au prealable.
* <p/>
@@ -347,7 +463,9 @@
* @param srcPath source path de la forme vfs2 ex:"zip:http://www.nuiton.org/attachments/download/830/nuiton-utils-2.6.5-deps.…"
* @param targetPath le path destination
* @throws FileSystemException
+ * @deprecated since 2.6.11, no more used
*/
+ @Deprecated
protected void deepCopy(FileSystemOptions vfsConfig,
String srcPath,
String targetPath) throws FileSystemException {
Added: trunk/nuiton-updater/src/main/java/org/nuiton/util/updater/DownloadMonitor.java
===================================================================
--- trunk/nuiton-updater/src/main/java/org/nuiton/util/updater/DownloadMonitor.java (rev 0)
+++ trunk/nuiton-updater/src/main/java/org/nuiton/util/updater/DownloadMonitor.java 2013-03-12 23:03:34 UTC (rev 2528)
@@ -0,0 +1,38 @@
+package org.nuiton.util.updater;
+
+/*
+ * #%L
+ * Nuiton Utils :: Nuiton Updater
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2013 CodeLutin, Tony Chemit
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+/**
+ * Pour monitorer la progression d'un téléchargement.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.6.11
+ */
+public interface DownloadMonitor {
+
+ void setSize(long size);
+
+ void setCurrent(long current);
+}
Property changes on: trunk/nuiton-updater/src/main/java/org/nuiton/util/updater/DownloadMonitor.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-updater/src/main/java/org/nuiton/util/updater/UpdateInvalidArchiveLayoutException.java
===================================================================
--- trunk/nuiton-updater/src/main/java/org/nuiton/util/updater/UpdateInvalidArchiveLayoutException.java (rev 0)
+++ trunk/nuiton-updater/src/main/java/org/nuiton/util/updater/UpdateInvalidArchiveLayoutException.java 2013-03-12 23:03:34 UTC (rev 2528)
@@ -0,0 +1,56 @@
+package org.nuiton.util.updater;
+
+/*
+ * #%L
+ * Nuiton Utils :: Nuiton Updater
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2013 CodeLutin, Tony Chemit
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+import java.io.File;
+
+/**
+ * Exception leve lorsque l'archive d'une mise à jour ne respecte pas le bon
+ * format (à savoir contenir un uniquement répertoire).
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.6.11
+ */
+public class UpdateInvalidArchiveLayoutException extends Exception {
+
+ private static final long serialVersionUID = 1L;
+
+
+ protected final ApplicationInfo info;
+ protected final File archiveFile;
+
+ public UpdateInvalidArchiveLayoutException(ApplicationInfo info, File archiveFile) {
+ this.info= info;
+ this.archiveFile = archiveFile;
+ }
+
+ public ApplicationInfo getInfo() {
+ return info;
+ }
+
+ public File getArchiveFile() {
+ return archiveFile;
+ }
+}
Property changes on: trunk/nuiton-updater/src/main/java/org/nuiton/util/updater/UpdateInvalidArchiveLayoutException.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-updater/src/main/java/org/nuiton/util/updater/UpdateNotFoundException.java
===================================================================
--- trunk/nuiton-updater/src/main/java/org/nuiton/util/updater/UpdateNotFoundException.java (rev 0)
+++ trunk/nuiton-updater/src/main/java/org/nuiton/util/updater/UpdateNotFoundException.java 2013-03-12 23:03:34 UTC (rev 2528)
@@ -0,0 +1,48 @@
+package org.nuiton.util.updater;
+
+/*
+ * #%L
+ * Nuiton Utils :: Nuiton Updater
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2013 CodeLutin, Tony Chemit
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+import java.io.IOException;
+
+/**
+ * When an update is not found.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.6.11
+ */
+public class UpdateNotFoundException extends IOException {
+
+ private static final long serialVersionUID = 1L;
+
+ protected ApplicationInfo info;
+
+ public UpdateNotFoundException(ApplicationInfo info) {
+ this.info = info;
+ }
+
+ public ApplicationInfo getInfo() {
+ return info;
+ }
+}
Property changes on: trunk/nuiton-updater/src/main/java/org/nuiton/util/updater/UpdateNotFoundException.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
1
0
r2527 - in trunk/nuiton-utils: . src/main/java/org/nuiton/util/beans src/test/java/org/nuiton/util/beans
by tchemit@users.nuiton.org 12 Mar '13
by tchemit@users.nuiton.org 12 Mar '13
12 Mar '13
Author: tchemit
Date: 2013-03-12 17:07:04 +0100 (Tue, 12 Mar 2013)
New Revision: 2527
Url: http://nuiton.org/projects/nuiton-utils/repository/revisions/2527
Log:
fixes #2587: [BeanUtil] Add method to filter descriptors
Modified:
trunk/nuiton-utils/pom.xml
trunk/nuiton-utils/src/main/java/org/nuiton/util/beans/BeanUtil.java
trunk/nuiton-utils/src/test/java/org/nuiton/util/beans/BeanUtilTest.java
Modified: trunk/nuiton-utils/pom.xml
===================================================================
--- trunk/nuiton-utils/pom.xml 2013-03-12 10:28:51 UTC (rev 2526)
+++ trunk/nuiton-utils/pom.xml 2013-03-12 16:07:04 UTC (rev 2527)
@@ -85,6 +85,11 @@
</dependency>
<dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ </dependency>
+
+ <dependency>
<groupId>org.nuiton.i18n</groupId>
<artifactId>nuiton-i18n</artifactId>
</dependency>
Modified: trunk/nuiton-utils/src/main/java/org/nuiton/util/beans/BeanUtil.java
===================================================================
--- trunk/nuiton-utils/src/main/java/org/nuiton/util/beans/BeanUtil.java 2013-03-12 10:28:51 UTC (rev 2526)
+++ trunk/nuiton-utils/src/main/java/org/nuiton/util/beans/BeanUtil.java 2013-03-12 16:07:04 UTC (rev 2527)
@@ -24,6 +24,10 @@
*/
package org.nuiton.util.beans;
+import com.google.common.base.Predicate;
+import com.google.common.base.Predicates;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
import org.apache.commons.beanutils.MethodUtils;
import org.apache.commons.beanutils.PropertyUtils;
@@ -31,6 +35,7 @@
import java.beans.PropertyDescriptor;
import java.lang.reflect.InvocationTargetException;
import java.util.HashSet;
+import java.util.Map;
import java.util.Set;
/**
@@ -52,6 +57,40 @@
}
/**
+ * Is a property is readable ?
+ *
+ * @since 2.5.11
+ */
+ public static final Predicate<PropertyDescriptor> IS_READ_DESCRIPTOR = new Predicate<PropertyDescriptor>() {
+ @Override
+ public boolean apply(PropertyDescriptor input) {
+ return input.getReadMethod() != null;
+ }
+ };
+
+ /**
+ * Is a property is writable ?
+ *
+ * @since 2.5.11
+ */
+ public static final Predicate<PropertyDescriptor> IS_WRITE_DESCRIPTOR = new Predicate<PropertyDescriptor>() {
+ @Override
+ public boolean apply(PropertyDescriptor input) {
+ return input.getReadMethod() != null;
+ }
+ };
+
+ /**
+ * Is a property is readable and writable ?
+ *
+ * @since 2.5.11
+ */
+ public static final Predicate<PropertyDescriptor> IS_READ_AND_WRITE_DESCRIPTOR = Predicates.and(
+ IS_READ_DESCRIPTOR,
+ IS_WRITE_DESCRIPTOR
+ );
+
+ /**
* Test if the given type is JavaBean compiliant, says that it has two
* public methods :
* <ul>
@@ -189,7 +228,7 @@
result = false;
} else {
- String rest = propertyName.substring(dotIndex+1);
+ String rest = propertyName.substring(dotIndex + 1);
result = isNestedReadableProperty(nestedType, rest);
}
@@ -245,6 +284,72 @@
return result;
}
+ /**
+ * Scan the given type and obtain {@link PropertyDescriptor}
+ * given the (optional) predicate (except the {@code class} property of
+ * any java object).
+ * <p/>
+ * <strong>Note:</strong> If no predicate is given, then all descriptors
+ * are returned.
+ *
+ * @param beanType the bean type to scan
+ * @param predicate the optional predicate to keep descriptor
+ * @return set of all matching descriptors
+ * @since 2.6.11
+ */
+ public static Set<PropertyDescriptor> getDescriptors(Class<?> beanType,
+ Predicate<PropertyDescriptor> predicate) {
+
+ if (predicate == null) {
+ predicate = Predicates.alwaysTrue();
+ }
+
+ Set<Class<?>> exploredTypes = Sets.newHashSet();
+ Map<String, PropertyDescriptor> result = Maps.newTreeMap();
+
+ getDescriptors(beanType, predicate, result, exploredTypes);
+
+ // the special getClass will never be a JavaBean property...
+ result.remove("class");
+
+ return Sets.newHashSet(result.values());
+ }
+
+ protected static void getDescriptors(Class<?> beanType,
+ Predicate<PropertyDescriptor> predicate,
+ Map<String, PropertyDescriptor> result,
+ Set<Class<?>> exploredTypes) {
+
+ if (exploredTypes.contains(beanType)) {
+
+ // already explored
+ return;
+ }
+ exploredTypes.add(beanType);
+
+ PropertyDescriptor[] descriptors =
+ PropertyUtils.getPropertyDescriptors(beanType);
+
+ for (PropertyDescriptor descriptor : descriptors) {
+ String name = descriptor.getName();
+ if (!result.containsKey(name) && predicate.apply(descriptor)) {
+ result.put(name, descriptor);
+ }
+ }
+
+ if (beanType.getSuperclass() != null) {
+
+ // get properties fro super-class
+ getDescriptors(beanType.getSuperclass(), predicate, result, exploredTypes);
+ }
+ Class<?>[] interfaces = beanType.getInterfaces();
+ for (Class<?> anInterface : interfaces) {
+
+ // get properties fro super-class
+ getDescriptors(anInterface, predicate, result, exploredTypes);
+ }
+ }
+
protected static void getReadableProperties(Class<?> beanType,
Set<String> result,
Set<Class<?>> exploredTypes) {
Modified: trunk/nuiton-utils/src/test/java/org/nuiton/util/beans/BeanUtilTest.java
===================================================================
--- trunk/nuiton-utils/src/test/java/org/nuiton/util/beans/BeanUtilTest.java 2013-03-12 10:28:51 UTC (rev 2526)
+++ trunk/nuiton-utils/src/test/java/org/nuiton/util/beans/BeanUtilTest.java 2013-03-12 16:07:04 UTC (rev 2527)
@@ -24,10 +24,15 @@
*/
package org.nuiton.util.beans;
+import com.google.common.base.Function;
+import com.google.common.base.Predicate;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Maps;
import org.junit.Assert;
import org.junit.Test;
import java.beans.PropertyChangeListener;
+import java.beans.PropertyDescriptor;
import java.beans.beancontext.BeanContextSupport;
import java.lang.reflect.InvocationTargetException;
import java.util.Set;
@@ -86,6 +91,66 @@
}
@Test
+ public void getDescriptors() {
+
+ assertFoundDescriptors(BeanA.class,
+ BeanUtil.IS_READ_DESCRIPTOR,
+ BeanA.PROPERTY_A,
+ BeanA.PROPERTY_B,
+ BeanA.PROPERTY_C,
+ BeanA.PROPERTY_D,
+ BeanA.PROPERTY_E,
+ BeanA.PROPERTY_F);
+
+ assertFoundDescriptors(BeanB.class,
+ BeanUtil.IS_READ_DESCRIPTOR,
+ BeanA.PROPERTY_A,
+ BeanA.PROPERTY_B,
+ BeanA.PROPERTY_C,
+ BeanA.PROPERTY_D,
+ BeanA.PROPERTY_E,
+ BeanA.PROPERTY_F,
+ BeanB.PROPERTY_BB,
+ BeanB.PROPERTY_A2,
+ BeanB.PROPERTY_B2,
+ BeanB.PROPERTY_C2,
+ BeanB.PROPERTY_D2,
+ BeanB.PROPERTY_E2,
+ BeanB.PROPERTY_F2
+ );
+
+ assertFoundDescriptors(getClass(), BeanUtil.IS_READ_DESCRIPTOR);
+
+ assertFoundDescriptors(BeanA.class,
+ BeanUtil.IS_WRITE_DESCRIPTOR,
+ BeanA.PROPERTY_A,
+ BeanA.PROPERTY_B,
+ BeanA.PROPERTY_C,
+ BeanA.PROPERTY_D,
+ BeanA.PROPERTY_E,
+ BeanA.PROPERTY_F);
+
+ assertFoundDescriptors(BeanB.class,
+ BeanUtil.IS_WRITE_DESCRIPTOR,
+ BeanA.PROPERTY_A,
+ BeanA.PROPERTY_B,
+ BeanA.PROPERTY_C,
+ BeanA.PROPERTY_D,
+ BeanA.PROPERTY_E,
+ BeanA.PROPERTY_F,
+ BeanB.PROPERTY_BB,
+ BeanB.PROPERTY_A2,
+ BeanB.PROPERTY_B2,
+ BeanB.PROPERTY_C2,
+ BeanB.PROPERTY_D2,
+ BeanB.PROPERTY_E2,
+ BeanB.PROPERTY_F2
+ );
+
+ assertFoundDescriptors(getClass(), BeanUtil.IS_WRITE_DESCRIPTOR);
+ }
+
+ @Test
public void getWriteableProperties() {
assertFoundWriteableProperties(BeanA.class,
@@ -233,4 +298,22 @@
Assert.assertTrue("Did not found nested property " + expectedproperty, actual);
}
}
+
+ protected void assertFoundDescriptors(Class<?> type,
+ Predicate<PropertyDescriptor> predicate,
+ String... expectedproperties) {
+ Set<PropertyDescriptor> actual = BeanUtil.getDescriptors(type, predicate);
+ Assert.assertEquals(expectedproperties.length, actual.size());
+
+ ImmutableMap<String, PropertyDescriptor> map = Maps.uniqueIndex(actual, new Function<PropertyDescriptor, String>() {
+ @Override
+ public String apply(PropertyDescriptor input) {
+ return input.getName();
+ }
+ });
+ for (String expectedproperty : expectedproperties) {
+ Assert.assertTrue("Did not found property " + expectedproperty,
+ map.containsKey(expectedproperty));
+ }
+ }
}
1
0
12 Mar '13
Author: echatellier
Date: 2013-03-12 11:28:51 +0100 (Tue, 12 Mar 2013)
New Revision: 2526
Url: http://nuiton.org/projects/nuiton-utils/repository/revisions/2526
Log:
fix svn:ignore
Modified:
trunk/nuiton-utils-maven-report-plugin/
Property changes on: trunk/nuiton-utils-maven-report-plugin
___________________________________________________________________
Modified: svn:ignore
- target
*.ipr
*.iws
*.iml
.idea
+ target
*.ipr
*.iws
*.iml
.idea
.classpath
.project
.settings
1
0
Author: tchemit
Date: 2013-03-11 12:32:41 +0100 (Mon, 11 Mar 2013)
New Revision: 2525
Url: http://nuiton.org/projects/nuiton-utils/repository/revisions/2525
Log:
fixes #2582: Updates mavenpom to 3.4.8
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2013-03-05 11:02:29 UTC (rev 2524)
+++ trunk/pom.xml 2013-03-11 11:32:41 UTC (rev 2525)
@@ -27,7 +27,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>mavenpom4redmineAndCentral</artifactId>
- <version>3.4.7</version>
+ <version>3.4.8</version>
</parent>
<artifactId>nuiton-utils-parent</artifactId>
1
0
r2524 - in trunk: . nuiton-config nuiton-csv nuiton-updater nuiton-utils nuiton-utils-maven-report-plugin nuiton-validator
by maven-release@users.nuiton.org 05 Mar '13
by maven-release@users.nuiton.org 05 Mar '13
05 Mar '13
Author: maven-release
Date: 2013-03-05 12:02:29 +0100 (Tue, 05 Mar 2013)
New Revision: 2524
Url: http://nuiton.org/projects/nuiton-utils/repository/revisions/2524
Log:
[maven-release-plugin] prepare for next development iteration
Modified:
trunk/nuiton-config/pom.xml
trunk/nuiton-csv/pom.xml
trunk/nuiton-updater/pom.xml
trunk/nuiton-utils-maven-report-plugin/pom.xml
trunk/nuiton-utils/pom.xml
trunk/nuiton-validator/pom.xml
trunk/pom.xml
Modified: trunk/nuiton-config/pom.xml
===================================================================
--- trunk/nuiton-config/pom.xml 2013-03-05 11:02:27 UTC (rev 2523)
+++ trunk/nuiton-config/pom.xml 2013-03-05 11:02:29 UTC (rev 2524)
@@ -27,7 +27,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>nuiton-utils-parent</artifactId>
- <version>2.6.10</version>
+ <version>2.6.11-SNAPSHOT</version>
</parent>
<artifactId>nuiton-config</artifactId>
Modified: trunk/nuiton-csv/pom.xml
===================================================================
--- trunk/nuiton-csv/pom.xml 2013-03-05 11:02:27 UTC (rev 2523)
+++ trunk/nuiton-csv/pom.xml 2013-03-05 11:02:29 UTC (rev 2524)
@@ -31,7 +31,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>nuiton-utils-parent</artifactId>
- <version>2.6.10</version>
+ <version>2.6.11-SNAPSHOT</version>
</parent>
<artifactId>nuiton-csv</artifactId>
Modified: trunk/nuiton-updater/pom.xml
===================================================================
--- trunk/nuiton-updater/pom.xml 2013-03-05 11:02:27 UTC (rev 2523)
+++ trunk/nuiton-updater/pom.xml 2013-03-05 11:02:29 UTC (rev 2524)
@@ -31,7 +31,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>nuiton-utils-parent</artifactId>
- <version>2.6.10</version>
+ <version>2.6.11-SNAPSHOT</version>
</parent>
<artifactId>nuiton-updater</artifactId>
Modified: trunk/nuiton-utils/pom.xml
===================================================================
--- trunk/nuiton-utils/pom.xml 2013-03-05 11:02:27 UTC (rev 2523)
+++ trunk/nuiton-utils/pom.xml 2013-03-05 11:02:29 UTC (rev 2524)
@@ -31,7 +31,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>nuiton-utils-parent</artifactId>
- <version>2.6.10</version>
+ <version>2.6.11-SNAPSHOT</version>
</parent>
<artifactId>nuiton-utils</artifactId>
Modified: trunk/nuiton-utils-maven-report-plugin/pom.xml
===================================================================
--- trunk/nuiton-utils-maven-report-plugin/pom.xml 2013-03-05 11:02:27 UTC (rev 2523)
+++ trunk/nuiton-utils-maven-report-plugin/pom.xml 2013-03-05 11:02:29 UTC (rev 2524)
@@ -31,7 +31,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>nuiton-utils-parent</artifactId>
- <version>2.6.10</version>
+ <version>2.6.11-SNAPSHOT</version>
</parent>
<artifactId>nuiton-utils-maven-report-plugin</artifactId>
Modified: trunk/nuiton-validator/pom.xml
===================================================================
--- trunk/nuiton-validator/pom.xml 2013-03-05 11:02:27 UTC (rev 2523)
+++ trunk/nuiton-validator/pom.xml 2013-03-05 11:02:29 UTC (rev 2524)
@@ -31,7 +31,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>nuiton-utils-parent</artifactId>
- <version>2.6.10</version>
+ <version>2.6.11-SNAPSHOT</version>
</parent>
<artifactId>nuiton-validator</artifactId>
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2013-03-05 11:02:27 UTC (rev 2523)
+++ trunk/pom.xml 2013-03-05 11:02:29 UTC (rev 2524)
@@ -31,7 +31,7 @@
</parent>
<artifactId>nuiton-utils-parent</artifactId>
- <version>2.6.10</version>
+ <version>2.6.11-SNAPSHOT</version>
<modules>
<module>nuiton-utils</module>
@@ -333,12 +333,12 @@
<scm>
<connection>
- scm:svn:http://svn.nuiton.org/svn/nuiton-utils/tags/nuiton-utils-2.6.10
+ scm:svn:http://svn.nuiton.org/svn/nuiton-utils/trunk
</connection>
<developerConnection>
- scm:svn:http://svn.nuiton.org/svn/nuiton-utils/tags/nuiton-utils-2.6.10
+ scm:svn:http://svn.nuiton.org/svn/nuiton-utils/trunk
</developerConnection>
- <url>http://nuiton.org/projects/nuiton-utils/repository/show/tags/nuiton-utils-2…</url>
+ <url>http://nuiton.org/projects/nuiton-utils/repository/show/trunk</url>
</scm>
<distributionManagement>
1
0
Author: maven-release
Date: 2013-03-05 12:02:27 +0100 (Tue, 05 Mar 2013)
New Revision: 2523
Url: http://nuiton.org/projects/nuiton-utils/repository/revisions/2523
Log:
[maven-release-plugin] copy for tag nuiton-utils-2.6.10
Added:
tags/nuiton-utils-2.6.10/
Property changes on: tags/nuiton-utils-2.6.10
___________________________________________________________________
Added: svn:ignore
+ target
velocity.log
maven.log
.eclipse
.classpath
*.iml
*.ipr
*.iws
.settings
.project
testdir
Added: svn:mergeinfo
+
1
0
r2522 - in trunk: . nuiton-config nuiton-csv nuiton-updater nuiton-utils nuiton-utils-maven-report-plugin nuiton-validator
by maven-release@users.nuiton.org 05 Mar '13
by maven-release@users.nuiton.org 05 Mar '13
05 Mar '13
Author: maven-release
Date: 2013-03-05 12:02:24 +0100 (Tue, 05 Mar 2013)
New Revision: 2522
Url: http://nuiton.org/projects/nuiton-utils/repository/revisions/2522
Log:
[maven-release-plugin] prepare release nuiton-utils-2.6.10
Modified:
trunk/nuiton-config/pom.xml
trunk/nuiton-csv/pom.xml
trunk/nuiton-updater/pom.xml
trunk/nuiton-utils-maven-report-plugin/pom.xml
trunk/nuiton-utils/pom.xml
trunk/nuiton-validator/pom.xml
trunk/pom.xml
Modified: trunk/nuiton-config/pom.xml
===================================================================
--- trunk/nuiton-config/pom.xml 2013-03-03 15:20:18 UTC (rev 2521)
+++ trunk/nuiton-config/pom.xml 2013-03-05 11:02:24 UTC (rev 2522)
@@ -27,7 +27,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>nuiton-utils-parent</artifactId>
- <version>2.6.10-SNAPSHOT</version>
+ <version>2.6.10</version>
</parent>
<artifactId>nuiton-config</artifactId>
Modified: trunk/nuiton-csv/pom.xml
===================================================================
--- trunk/nuiton-csv/pom.xml 2013-03-03 15:20:18 UTC (rev 2521)
+++ trunk/nuiton-csv/pom.xml 2013-03-05 11:02:24 UTC (rev 2522)
@@ -31,7 +31,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>nuiton-utils-parent</artifactId>
- <version>2.6.10-SNAPSHOT</version>
+ <version>2.6.10</version>
</parent>
<artifactId>nuiton-csv</artifactId>
Modified: trunk/nuiton-updater/pom.xml
===================================================================
--- trunk/nuiton-updater/pom.xml 2013-03-03 15:20:18 UTC (rev 2521)
+++ trunk/nuiton-updater/pom.xml 2013-03-05 11:02:24 UTC (rev 2522)
@@ -31,7 +31,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>nuiton-utils-parent</artifactId>
- <version>2.6.10-SNAPSHOT</version>
+ <version>2.6.10</version>
</parent>
<artifactId>nuiton-updater</artifactId>
Modified: trunk/nuiton-utils/pom.xml
===================================================================
--- trunk/nuiton-utils/pom.xml 2013-03-03 15:20:18 UTC (rev 2521)
+++ trunk/nuiton-utils/pom.xml 2013-03-05 11:02:24 UTC (rev 2522)
@@ -31,7 +31,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>nuiton-utils-parent</artifactId>
- <version>2.6.10-SNAPSHOT</version>
+ <version>2.6.10</version>
</parent>
<artifactId>nuiton-utils</artifactId>
Modified: trunk/nuiton-utils-maven-report-plugin/pom.xml
===================================================================
--- trunk/nuiton-utils-maven-report-plugin/pom.xml 2013-03-03 15:20:18 UTC (rev 2521)
+++ trunk/nuiton-utils-maven-report-plugin/pom.xml 2013-03-05 11:02:24 UTC (rev 2522)
@@ -31,7 +31,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>nuiton-utils-parent</artifactId>
- <version>2.6.10-SNAPSHOT</version>
+ <version>2.6.10</version>
</parent>
<artifactId>nuiton-utils-maven-report-plugin</artifactId>
Modified: trunk/nuiton-validator/pom.xml
===================================================================
--- trunk/nuiton-validator/pom.xml 2013-03-03 15:20:18 UTC (rev 2521)
+++ trunk/nuiton-validator/pom.xml 2013-03-05 11:02:24 UTC (rev 2522)
@@ -31,7 +31,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>nuiton-utils-parent</artifactId>
- <version>2.6.10-SNAPSHOT</version>
+ <version>2.6.10</version>
</parent>
<artifactId>nuiton-validator</artifactId>
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2013-03-03 15:20:18 UTC (rev 2521)
+++ trunk/pom.xml 2013-03-05 11:02:24 UTC (rev 2522)
@@ -31,7 +31,7 @@
</parent>
<artifactId>nuiton-utils-parent</artifactId>
- <version>2.6.10-SNAPSHOT</version>
+ <version>2.6.10</version>
<modules>
<module>nuiton-utils</module>
@@ -333,12 +333,12 @@
<scm>
<connection>
- scm:svn:http://svn.nuiton.org/svn/nuiton-utils/trunk
+ scm:svn:http://svn.nuiton.org/svn/nuiton-utils/tags/nuiton-utils-2.6.10
</connection>
<developerConnection>
- scm:svn:http://svn.nuiton.org/svn/nuiton-utils/trunk
+ scm:svn:http://svn.nuiton.org/svn/nuiton-utils/tags/nuiton-utils-2.6.10
</developerConnection>
- <url>http://nuiton.org/projects/nuiton-utils/repository/show/trunk</url>
+ <url>http://nuiton.org/projects/nuiton-utils/repository/show/tags/nuiton-utils-2…</url>
</scm>
<distributionManagement>
1
0
03 Mar '13
Author: tchemit
Date: 2013-03-03 16:20:18 +0100 (Sun, 03 Mar 2013)
New Revision: 2521
Url: http://nuiton.org/projects/nuiton-utils/repository/revisions/2521
Log:
fixes #2554: Deprecates old applicationConfig reports
refs #2555: Write new report adapated to new config module
refs #2506: Introduce nuiton-config module (move upper level ActionDef to ConfigActionDef and OptionDef to ConfigOptionDef)
add missing stuff on some classes
Added:
trunk/nuiton-config/src/main/java/org/nuiton/util/config/ConfigActionDef.java
trunk/nuiton-config/src/main/java/org/nuiton/util/config/ConfigOptionDef.java
trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/config/
trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/config/AbstractApplicationConfigReport.java
trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/config/AggregateApplicationConfigReport.java
trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/config/ApplicationConfigReport.java
trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/config/ApplicationConfigReportRenderer.java
Modified:
trunk/nuiton-config/src/main/java/org/nuiton/util/config/ApplicationConfig.java
trunk/nuiton-config/src/main/java/org/nuiton/util/config/ApplicationConfigHelper.java
trunk/nuiton-config/src/main/java/org/nuiton/util/config/ApplicationConfigProvider.java
trunk/nuiton-utils-maven-report-plugin/pom.xml
trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/plugin/report/AbstractApplicationConfigReport.java
trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/plugin/report/AggregateApplicationConfigReport.java
trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/plugin/report/ApplicationConfigReport.java
trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/plugin/report/ApplicationConfigReportRenderer.java
trunk/nuiton-utils/src/main/java/org/nuiton/util/AliasMap.java
trunk/nuiton-utils/src/main/java/org/nuiton/util/SemVer.java
trunk/nuiton-utils/src/test/java/org/nuiton/util/AliasMapTest.java
trunk/nuiton-utils/src/test/java/org/nuiton/util/SemVerTest.java
Modified: trunk/nuiton-config/src/main/java/org/nuiton/util/config/ApplicationConfig.java
===================================================================
--- trunk/nuiton-config/src/main/java/org/nuiton/util/config/ApplicationConfig.java 2013-02-26 15:30:54 UTC (rev 2520)
+++ trunk/nuiton-config/src/main/java/org/nuiton/util/config/ApplicationConfig.java 2013-03-03 15:20:18 UTC (rev 2521)
@@ -51,7 +51,6 @@
import java.io.OutputStreamWriter;
import java.io.PrintStream;
import java.io.Reader;
-import java.io.Serializable;
import java.io.Writer;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
@@ -126,8 +125,8 @@
* </pre>
* <p/>
* <ul>
- * <li>MyAppConfigOption doit étendre {@link OptionDef} et décrir la configuration de l'application.
- * <li>MyAppConfigAction doit étendre {@link ActionDef} et décrir la liste des options
+ * <li>MyAppConfigOption doit étendre {@link ConfigOptionDef} et décrir la configuration de l'application.
+ * <li>MyAppConfigAction doit étendre {@link ConfigActionDef} et décrir la liste des options
* et de leur alias disponible pour l'application.
* </ul>
* <p/>
@@ -531,7 +530,7 @@
* @deprecated since 2.4.8, prefer use {@link #ApplicationConfig(Properties, String)}
*/
@Deprecated
- public <O extends OptionDef, A extends ActionDef> ApplicationConfig(
+ public <O extends ConfigOptionDef, A extends ConfigActionDef> ApplicationConfig(
Class<O> optionClass, Class<A> actionClass,
Properties defaults, String configFilename) {
this(defaults, configFilename);
@@ -586,14 +585,14 @@
}
/**
- * Load default options of enum pass in param (enum must extend {@link OptionDef})
+ * Load default options of enum pass in param (enum must extend {@link ConfigOptionDef})
*
* @param optionClass to load
- * @param <O> type of enum extend {@link OptionDef}
- * @deprecated since 2.4.8, prefer use now {@link #loadDefaultOptions(OptionDef[])}
+ * @param <O> type of enum extend {@link ConfigOptionDef}
+ * @deprecated since 2.4.8, prefer use now {@link #loadDefaultOptions(ConfigOptionDef[])}
*/
@Deprecated
- public <O extends OptionDef> void loadDefaultOptions(Class<O> optionClass) {
+ public <O extends ConfigOptionDef> void loadDefaultOptions(Class<O> optionClass) {
loadDefaultOptions(optionClass.getEnumConstants());
}
@@ -602,13 +601,13 @@
* Load default given options.
*
* @param options options to load
- * @param <O> type of enum extend {@link OptionDef}
+ * @param <O> type of enum extend {@link ConfigOptionDef}
* @since 2.4.8
*/
- public <O extends OptionDef> void loadDefaultOptions(O[] options) {
+ public <O extends ConfigOptionDef> void loadDefaultOptions(O[] options) {
// load default option (included configuration file name : important)
- for (OptionDef o : options) {
+ for (ConfigOptionDef o : options) {
if (o.getDefaultValue() != null) {
setDefaultOption(o.getKey(), o.getDefaultValue());
}
@@ -616,14 +615,14 @@
}
/**
- * Load actions of enum pass in param (enum must extend {@link ActionDef})
+ * Load actions of enum pass in param (enum must extend {@link ConfigActionDef})
*
* @param actionClass to load
- * @param <A> type of enum extend {@link ActionDef}
- * @deprecated since 2.4.8, prefer use now {@link #loadActions(ActionDef[])}
+ * @param <A> type of enum extend {@link ConfigActionDef}
+ * @deprecated since 2.4.8, prefer use now {@link #loadActions(ConfigActionDef[])}
*/
@Deprecated
- public <A extends ActionDef> void loadActions(Class<A> actionClass) {
+ public <A extends ConfigActionDef> void loadActions(Class<A> actionClass) {
loadActions(actionClass.getEnumConstants());
}
@@ -632,10 +631,10 @@
* Load given actions.
*
* @param actions actions to load
- * @param <A> type of enum extend {@link ActionDef}
+ * @param <A> type of enum extend {@link ConfigActionDef}
* @since 2.4.8
*/
- public <A extends ActionDef> void loadActions(A[] actions) {
+ public <A extends ConfigActionDef> void loadActions(A[] actions) {
// load actions
for (A a : actions) {
@@ -1168,7 +1167,7 @@
* @param key la clef de l'option à tester
* @return {@code true} si 'loption existe, {@code false} sinon.
*/
- public boolean hasOption(OptionDef key) {
+ public boolean hasOption(ConfigOptionDef key) {
boolean result = hasOption(key.getKey());
return result;
}
@@ -1398,7 +1397,7 @@
* @param key the definition of the option
* @return the value for the given option
*/
- public Object getOption(OptionDef key) {
+ public Object getOption(ConfigOptionDef key) {
Object result = getOption(key.getType(), key.getKey());
return result;
}
@@ -2421,192 +2420,6 @@
}
/**
- * Le contrat de marquage des options, on utilise cette interface pour
- * caracteriser une option de configuration.
- * <p/>
- * <pre>
- * public enum MyConfigOption implements OptionDef {
- *
- * APP_CONFIG_FILE(
- * ApplicationConfig.CONFIG_FILE_NAME,
- * "Main configuration app file",
- * "myApp-config.properties",
- * String.class, true, true),
- *
- * APP_NAME(
- * ApplicationConfig.CONFIG_FILE_NAME,
- * Application name,
- * "MyApp",
- * String.class, true, true);
- *
- * public String key;
- * public String description;
- * public String defaultValue;
- * public Class<?> type;
- * public boolean isTransient;
- * public boolean isFinal;
- *
- * private WikittyConfigOption(String key, String description,
- * String defaultValue, Class<?> type, boolean isTransient, boolean isFinal) {
- * this.key = key;
- * this.description = description;
- * this.defaultValue = defaultValue;
- * this.type = type;
- * this.isTransient = isTransient;
- * this.isFinal = isFinal;
- * }
- *
- * @Override
- * public boolean isFinal() {
- * return isFinal;
- * }
- *
- * @Override
- * public boolean isTransient() {
- * return isTransient;
- * }
- *
- * @Override
- * public String getDefaultValue() {
- * return defaultValue;
- * }
- *
- * @Override
- * public String getDescription() {
- * return description;
- * }
- *
- * @Override
- * public String getKey() {
- * return key;
- * }
- *
- * @Override
- * public Class<?> getType() {
- * return type;
- * }
- *
- * @Override
- * public void setDefaultValue(String defaultValue) {
- * this.defaultValue = defaultValue;
- * }
- *
- * @Override
- * public void setTransient(boolean isTransient) {
- * this.isTransient = isTransient;
- * }
- *
- * @Override
- * public void setFinal(boolean isFinal) {
- * this.isFinal = isFinal;
- * }
- * }
- * </pre>
- *
- * @since 1.0.0-rc-9
- */
- public interface OptionDef extends Serializable {
-
- /** @return la clef identifiant l'option */
- String getKey();
-
- /** @return le type de l'option */
- Class<?> getType();
-
- /** @return la clef i18n de description de l'option */
- String getDescription();
-
- /**
- * @return la valeur par defaut de l'option sous forme de chaine de
- * caracteres
- */
- String getDefaultValue();
-
- /**
- * @return <code>true</code> si l'option ne peut etre sauvegardee sur
- * disque (utile par exemple pour les mots de passe, ...)
- */
- boolean isTransient();
-
- /**
- * @return <code>true</code> si l'option n'est pas modifiable (utilise
- * par exemple pour la version de l'application, ...)
- */
- boolean isFinal();
-
- /**
- * Changes the default value of the option.
- *
- * @param defaultValue the new default value of the option
- */
- void setDefaultValue(String defaultValue);
-
- /**
- * Changes the transient state of the option.
- *
- * @param isTransient the new value of the transient state
- */
- void setTransient(boolean isTransient);
-
- /**
- * Changes the final state of the option.
- *
- * @param isFinal the new transient state value
- */
- void setFinal(boolean isFinal);
- }
-
- /**
- * Le contrat de marquage des action, on utilise cette interface pour
- * caracteriser une action.
- * <p/>
- * Ex :
- * <p/>
- * <pre>
- * public enum MyAppConfigAction implements ActionDef {
- * HELP(MyAppHelpAction.class.getName() + "#show", "-h", "--help");
- * public String action;
- * public String[] aliases;
- *
- * private WikittyConfigAction(String action, String... aliases) {
- * this.action = action;
- * this.aliases = aliases;
- * }
- *
- * @Override
- * public String getAction() {
- * return action;
- * }
- *
- * @Override
- * public String[] getAliases() {
- * return aliases;
- * }
- *
- * }
- * </pre>
- *
- * @author sletellier
- * @since 1.5.2
- */
- public interface ActionDef extends Serializable {
-
- /**
- * Must return fully qualified method path : package.Class#method
- *
- * @return action to run
- */
- String getAction();
-
- /**
- * Return all alias used to execute action.
- *
- * @return aliases used to execute action
- */
- String[] getAliases();
- }
-
- /**
* Defines a runtime action to be launched via the {@link #doAction()}
* method.
*
Modified: trunk/nuiton-config/src/main/java/org/nuiton/util/config/ApplicationConfigHelper.java
===================================================================
--- trunk/nuiton-config/src/main/java/org/nuiton/util/config/ApplicationConfigHelper.java 2013-02-26 15:30:54 UTC (rev 2520)
+++ trunk/nuiton-config/src/main/java/org/nuiton/util/config/ApplicationConfigHelper.java 2013-03-03 15:20:18 UTC (rev 2521)
@@ -131,7 +131,7 @@
provider.getName());
}
if (log.isInfoEnabled()) {
- for (ApplicationConfig.OptionDef optionDef : provider.getOptions()) {
+ for (ConfigOptionDef optionDef : provider.getOptions()) {
log.info(" " + optionDef.getKey() +
" (" + optionDef.getDefaultValue() + ')');
}
@@ -145,13 +145,13 @@
*
* @param providers providers to inspect
* @return the set of all options that are transient
- * @see ApplicationConfig.OptionDef#isTransient()
+ * @see ConfigOptionDef#isTransient()
* @since 2.6.7
*/
- public static Set<ApplicationConfig.OptionDef> getTransientOptions(Set<ApplicationConfigProvider> providers) {
- Set<ApplicationConfig.OptionDef> result = new HashSet<ApplicationConfig.OptionDef>();
+ public static Set<ConfigOptionDef> getTransientOptions(Set<ApplicationConfigProvider> providers) {
+ Set<ConfigOptionDef> result = new HashSet<ConfigOptionDef>();
for (ApplicationConfigProvider provider : providers) {
- for (ApplicationConfig.OptionDef def : provider.getOptions()) {
+ for (ConfigOptionDef def : provider.getOptions()) {
if (def.isTransient()) {
result.add(def);
}
@@ -166,13 +166,13 @@
*
* @param providers providers to inspect
* @return the set of all options that are final
- * @see ApplicationConfig.OptionDef#isFinal()
+ * @see ConfigOptionDef#isFinal()
* @since 2.6.7
*/
- public static Set<ApplicationConfig.OptionDef> getFinalOptions(Set<ApplicationConfigProvider> providers) {
- Set<ApplicationConfig.OptionDef> result = new HashSet<ApplicationConfig.OptionDef>();
+ public static Set<ConfigOptionDef> getFinalOptions(Set<ApplicationConfigProvider> providers) {
+ Set<ConfigOptionDef> result = new HashSet<ConfigOptionDef>();
for (ApplicationConfigProvider provider : providers) {
- for (ApplicationConfig.OptionDef def : provider.getOptions()) {
+ for (ConfigOptionDef def : provider.getOptions()) {
if (def.isFinal()) {
result.add(def);
}
@@ -189,16 +189,16 @@
*
* @param providers providers to inspect
* @return the set of options key not to store in the config file
- * @see ApplicationConfig.OptionDef#isFinal()
- * @see ApplicationConfig.OptionDef#isTransient()
+ * @see ConfigOptionDef#isFinal()
+ * @see ConfigOptionDef#isTransient()
* @since 2.6.7
*/
public static Set<String> getTransientOrFinalOptionKey(Set<ApplicationConfigProvider> providers) {
Set<String> result = new HashSet<String>();
- for (ApplicationConfig.OptionDef def : getTransientOptions(providers)) {
+ for (ConfigOptionDef def : getTransientOptions(providers)) {
result.add(def.getKey());
}
- for (ApplicationConfig.OptionDef def : getFinalOptions(providers)) {
+ for (ConfigOptionDef def : getFinalOptions(providers)) {
result.add(def.getKey());
}
return result;
Modified: trunk/nuiton-config/src/main/java/org/nuiton/util/config/ApplicationConfigProvider.java
===================================================================
--- trunk/nuiton-config/src/main/java/org/nuiton/util/config/ApplicationConfigProvider.java 2013-02-26 15:30:54 UTC (rev 2520)
+++ trunk/nuiton-config/src/main/java/org/nuiton/util/config/ApplicationConfigProvider.java 2013-03-03 15:20:18 UTC (rev 2521)
@@ -65,15 +65,15 @@
* Returns all options offered by the configuration.
*
* @return all options offered by the configuration
- * @see ApplicationConfig.OptionDef
+ * @see ConfigOptionDef
*/
- ApplicationConfig.OptionDef[] getOptions();
+ ConfigOptionDef[] getOptions();
/**
* Returns all actions offered by the configuration.
*
* @return all actions offered by the configuration.
- * @see ApplicationConfig.ActionDef
+ * @see ConfigActionDef
*/
- ApplicationConfig.ActionDef[] getActions();
+ ConfigActionDef[] getActions();
}
Added: trunk/nuiton-config/src/main/java/org/nuiton/util/config/ConfigActionDef.java
===================================================================
--- trunk/nuiton-config/src/main/java/org/nuiton/util/config/ConfigActionDef.java (rev 0)
+++ trunk/nuiton-config/src/main/java/org/nuiton/util/config/ConfigActionDef.java 2013-03-03 15:20:18 UTC (rev 2521)
@@ -0,0 +1,78 @@
+package org.nuiton.util.config;
+
+/*
+ * #%L
+ * Nuiton Utils :: Nuiton Config
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 - 2013 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+import java.io.Serializable;
+
+/**
+ * Le contrat de marquage des actions, on utilise cette interface pour
+ * caracteriser une action.
+ * <p/>
+ * Ex :
+ * <p/>
+ * <pre>
+ * public enum MyAppConfigAction implements ConfigActionDef {
+ * HELP(MyAppHelpAction.class.getName() + "#show", "-h", "--help");
+ * public String action;
+ * public String[] aliases;
+ *
+ * private WikittyConfigAction(String action, String... aliases) {
+ * this.action = action;
+ * this.aliases = aliases;
+ * }
+ *
+ * @Override
+ * public String getAction() {
+ * return action;
+ * }
+ *
+ * @Override
+ * public String[] getAliases() {
+ * return aliases;
+ * }
+ *
+ * }
+ * </pre>
+ *
+ * @author sletellier
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.6.10
+ */
+public interface ConfigActionDef extends Serializable {
+
+ /**
+ * Must return fully qualified method path : package.Class#method
+ *
+ * @return action to run
+ */
+ String getAction();
+
+ /**
+ * Return all alias used to execute action.
+ *
+ * @return aliases used to execute action
+ */
+ String[] getAliases();
+}
Property changes on: trunk/nuiton-config/src/main/java/org/nuiton/util/config/ConfigActionDef.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/nuiton-config/src/main/java/org/nuiton/util/config/ConfigOptionDef.java
===================================================================
--- trunk/nuiton-config/src/main/java/org/nuiton/util/config/ConfigOptionDef.java (rev 0)
+++ trunk/nuiton-config/src/main/java/org/nuiton/util/config/ConfigOptionDef.java 2013-03-03 15:20:18 UTC (rev 2521)
@@ -0,0 +1,163 @@
+package org.nuiton.util.config;
+
+/*
+ * #%L
+ * Nuiton Utils :: Nuiton Config
+ * $Id$
+ * $HeadURL:$
+ * %%
+ * Copyright (C) 2011 - 2013 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+import java.io.Serializable;
+
+/**
+ * Le contrat de marquage des options, on utilise cette interface pour
+ * caracteriser une option de configuration.
+ * <p/>
+ * <pre>
+ * public enum MyConfigOption implements ConfigOptionDef {
+ *
+ * APP_CONFIG_FILE(
+ * ApplicationConfig.CONFIG_FILE_NAME,
+ * "Main configuration app file",
+ * "myApp-config.properties",
+ * String.class, true, true),
+ *
+ * APP_NAME(
+ * ApplicationConfig.CONFIG_FILE_NAME,
+ * Application name,
+ * "MyApp",
+ * String.class, true, true);
+ *
+ * public String key;
+ * public String description;
+ * public String defaultValue;
+ * public Class<?> type;
+ * public boolean isTransient;
+ * public boolean isFinal;
+ *
+ * private WikittyConfigOption(String key, String description,
+ * String defaultValue, Class<?> type, boolean isTransient, boolean isFinal) {
+ * this.key = key;
+ * this.description = description;
+ * this.defaultValue = defaultValue;
+ * this.type = type;
+ * this.isTransient = isTransient;
+ * this.isFinal = isFinal;
+ * }
+ *
+ * @Override
+ * public boolean isFinal() {
+ * return isFinal;
+ * }
+ *
+ * @Override
+ * public boolean isTransient() {
+ * return isTransient;
+ * }
+ *
+ * @Override
+ * public String getDefaultValue() {
+ * return defaultValue;
+ * }
+ *
+ * @Override
+ * public String getDescription() {
+ * return description;
+ * }
+ *
+ * @Override
+ * public String getKey() {
+ * return key;
+ * }
+ *
+ * @Override
+ * public Class<?> getType() {
+ * return type;
+ * }
+ *
+ * @Override
+ * public void setDefaultValue(String defaultValue) {
+ * this.defaultValue = defaultValue;
+ * }
+ *
+ * @Override
+ * public void setTransient(boolean isTransient) {
+ * this.isTransient = isTransient;
+ * }
+ *
+ * @Override
+ * public void setFinal(boolean isFinal) {
+ * this.isFinal = isFinal;
+ * }
+ * }
+ * </pre>
+ *
+ * @since 1.0.0-rc-9
+ */
+public interface ConfigOptionDef extends Serializable {
+
+ /** @return la clef identifiant l'option */
+ String getKey();
+
+ /** @return le type de l'option */
+ Class<?> getType();
+
+ /** @return la clef i18n de description de l'option */
+ String getDescription();
+
+ /**
+ * @return la valeur par defaut de l'option sous forme de chaine de
+ * caracteres
+ */
+ String getDefaultValue();
+
+ /**
+ * @return <code>true</code> si l'option ne peut etre sauvegardee sur
+ * disque (utile par exemple pour les mots de passe, ...)
+ */
+ boolean isTransient();
+
+ /**
+ * @return <code>true</code> si l'option n'est pas modifiable (utilise
+ * par exemple pour la version de l'application, ...)
+ */
+ boolean isFinal();
+
+ /**
+ * Changes the default value of the option.
+ *
+ * @param defaultValue the new default value of the option
+ */
+ void setDefaultValue(String defaultValue);
+
+ /**
+ * Changes the transient state of the option.
+ *
+ * @param isTransient the new value of the transient state
+ */
+ void setTransient(boolean isTransient);
+
+ /**
+ * Changes the final state of the option.
+ *
+ * @param isFinal the new transient state value
+ */
+ void setFinal(boolean isFinal);
+}
Property changes on: trunk/nuiton-config/src/main/java/org/nuiton/util/config/ConfigOptionDef.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Property changes on: trunk/nuiton-utils/src/main/java/org/nuiton/util/AliasMap.java
___________________________________________________________________
Added: svn:eol-style
+ native
Property changes on: trunk/nuiton-utils/src/main/java/org/nuiton/util/SemVer.java
___________________________________________________________________
Added: svn:eol-style
+ native
Property changes on: trunk/nuiton-utils/src/test/java/org/nuiton/util/AliasMapTest.java
___________________________________________________________________
Added: svn:eol-style
+ native
Property changes on: trunk/nuiton-utils/src/test/java/org/nuiton/util/SemVerTest.java
___________________________________________________________________
Added: svn:eol-style
+ native
Modified: trunk/nuiton-utils-maven-report-plugin/pom.xml
===================================================================
--- trunk/nuiton-utils-maven-report-plugin/pom.xml 2013-02-26 15:30:54 UTC (rev 2520)
+++ trunk/nuiton-utils-maven-report-plugin/pom.xml 2013-03-03 15:20:18 UTC (rev 2521)
@@ -46,6 +46,12 @@
</dependency>
<dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>nuiton-config</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId>
</dependency>
Copied: trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/config/AbstractApplicationConfigReport.java (from rev 2512, trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/plugin/report/AbstractApplicationConfigReport.java)
===================================================================
--- trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/config/AbstractApplicationConfigReport.java (rev 0)
+++ trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/config/AbstractApplicationConfigReport.java 2013-03-03 15:20:18 UTC (rev 2521)
@@ -0,0 +1,314 @@
+package org.nuiton.util.config;
+
+/*
+ * #%L
+ * Nuiton Utils :: Maven Report Plugin
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+import org.apache.maven.doxia.siterenderer.Renderer;
+import org.apache.maven.plugins.annotations.Component;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.reporting.AbstractMavenReport;
+import org.apache.maven.reporting.MavenReportException;
+import org.codehaus.plexus.i18n.I18N;
+import org.codehaus.plexus.util.StringUtils;
+import org.nuiton.i18n.I18n;
+import org.nuiton.i18n.init.ClassPathI18nInitializer;
+import org.nuiton.i18n.init.DefaultI18nInitializer;
+import org.nuiton.i18n.init.I18nInitializer;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Locale;
+import java.util.Set;
+
+/**
+ * Abstract application config report used by normal and aggregate report.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.6.10
+ */
+public abstract class AbstractApplicationConfigReport extends AbstractMavenReport {
+
+ /**
+ * Report output directory. Note that this parameter is only relevant if the goal is run from the command line or
+ * from the default build lifecycle. If the goal is run indirectly as part of a site generation, the output
+ * directory configured in the Maven Site Plugin is used instead.
+ *
+ * @since 2.6.10
+ */
+ @Parameter(property = "config.outputDirectory",
+ defaultValue = "${project.reporting.outputDirectory}",
+ required = true)
+ protected File outputDirectory;
+
+ /**
+ * Report output encoding. Note that this parameter is only relevant if the goal is run from the command line or
+ * from the default build lifecycle. If the goal is run indirectly as part of a site generation, the output
+ * encoding configured in the Maven Site Plugin is used instead.
+ *
+ * @since 2.6.10
+ */
+ @Parameter(property = "config.outputEncoding",
+ defaultValue = "${project.reporting.outputEncoding}",
+ required = true)
+ protected String outputEncoding;
+
+ /**
+ * Optional i18n bundle name as used by the nuiton I18n system to init his
+ * files.
+ * <p/>
+ * If not given, will look at all i18n files in all over class-path (which
+ * could be costy if many dependencies), otherwise will init I18n system
+ * usinga {@link DefaultI18nInitializer} with this bundle name.
+ *
+ * @since 2.6.10
+ */
+ @Parameter(property = "config.i18nBundleName")
+ protected String i18nBundleName;
+
+ /**
+ * List of application config to include in report (separated by comma).
+ * <p/>
+ * <strong>Note:</strong> If not filled then will use all config
+ * found in class-path.
+ *
+ * @since 2.6.10
+ */
+ @Parameter(property = "config.include")
+ protected String include;
+
+ /**
+ * List of application config to exclude from report (separated by comma).
+ * <p/>
+ * <strong>Note:</strong> If not filled no config will be exclude.
+ *
+ * @since 2.6.10
+ */
+ @Parameter(property = "config.exclude")
+ protected String exclude;
+
+ /**
+ * Flag to activate verbose mode.
+ * <p/>
+ * <b>Note:</b> Verbose mode is always on if you starts a debug maven instance
+ * (says via {@code -X}).
+ *
+ * @since 2.6.10
+ */
+ @Parameter(property = "config.verbose", defaultValue = "${maven.verbose}")
+ protected boolean verbose;
+
+ /**
+ * Flag to render option in detail (add a section for each option).
+ *
+ * @since 2.6.10
+ */
+ @Parameter(property = "config.showOptionDetail", defaultValue = "true")
+ protected boolean showOptionDetail;
+
+ /**
+ * Skip to generate the report.
+ *
+ * @since 2.6.10
+ */
+ @Parameter(property = "config.skip")
+ protected boolean skip;
+
+ /**
+ * The Maven Project.
+ *
+ * @since 2.6.10
+ */
+ @Component
+ protected MavenProject project;
+
+
+ /**
+ * Doxia Site Renderer component.
+ *
+ * @since 2.6.10
+ */
+ @Component
+ protected Renderer siteRenderer;
+
+ /**
+ * Internationalization component.
+ *
+ * @since 2.6.10
+ */
+ @Component
+ protected I18N i18n;
+
+ /**
+ * Class loader with all compile dependencies of the module in class-path
+ * (used to init i18n) and obtain config provider over compile class-path.
+ *
+ * @since 2.6.10
+ */
+ protected ClassLoader newClassLoader;
+
+ /**
+ * Set of ApplicationconfigProvider detected from configuration.
+ *
+ * @since 2.6.10
+ */
+ protected Set<ApplicationConfigProvider> configProviders;
+
+ @Override
+ public String getOutputName() {
+ return "application-config-report";
+ }
+
+ public String getDescription(Locale locale) {
+ return i18n.getString(getOutputName(), locale, "report.description");
+ }
+
+ public String getName(Locale locale) {
+ return i18n.getString(getOutputName(), locale, "report.title");
+ }
+
+ @Override
+ public String getCategoryName() {
+ return CATEGORY_PROJECT_REPORTS;
+ }
+
+ @Override
+ public boolean canGenerateReport() {
+ return !skip;
+ }
+
+ @Override
+ protected Renderer getSiteRenderer() {
+ return siteRenderer;
+ }
+
+ @Override
+ protected String getOutputDirectory() {
+ return outputDirectory.getAbsolutePath();
+ }
+
+ @Override
+ protected MavenProject getProject() {
+ return project;
+ }
+
+ protected abstract ClassLoader createClassLoader() throws MavenReportException;
+
+ @Override
+ protected void executeReport(Locale locale) throws MavenReportException {
+
+ if (newClassLoader == null) {
+
+ // not init
+ init(locale);
+ } else {
+
+ // just change init language
+ I18n.setDefaultLocale(locale);
+ }
+ ApplicationConfigReportRenderer renderer =
+ new ApplicationConfigReportRenderer(getSink(),
+ i18n,
+ locale,
+ getOutputName(),
+ configProviders,
+ showOptionDetail);
+ renderer.render();
+ }
+
+ protected void init(Locale locale) throws MavenReportException {
+ if (getLog().isDebugEnabled()) {
+
+ // debug mode set verbose flag to true
+ verbose = true;
+ }
+
+ if (newClassLoader == null) {
+
+ newClassLoader = createClassLoader();
+ }
+
+ // get i18n initializer
+ I18nInitializer initializer;
+ if (StringUtils.isNotEmpty(i18nBundleName)) {
+ initializer = new DefaultI18nInitializer(i18nBundleName,
+ newClassLoader);
+ } else {
+ initializer = new ClassPathI18nInitializer(newClassLoader);
+ }
+ // init i18n
+ I18n.init(initializer, locale);
+
+ if (configProviders == null) {
+
+ Set<String> includes = null;
+ if (StringUtils.isNotEmpty(include)) {
+ includes = new HashSet<String>(Arrays.asList(include.split("\\s*,\\s*")));
+ if (verbose) {
+ getLog().info("config - includes : " + includes);
+ }
+ }
+
+ Set<String> excludes = null;
+ if (StringUtils.isNotEmpty(exclude)) {
+ excludes = new HashSet<String>(Arrays.asList(exclude.split("\\s*,\\s*")));
+ if (verbose) {
+ getLog().info("config - excludes : " + excludes);
+ }
+ }
+
+ configProviders = ApplicationConfigHelper.getProviders(
+ newClassLoader,
+ includes,
+ excludes,
+ verbose
+ );
+ }
+ }
+
+ protected ClassLoader createClassLoader(Set<String> paths) {
+
+ Set<URL> urls = new HashSet<URL>();
+
+ for (String fileName : paths) {
+ File pathElem = new File(fileName);
+ try {
+ URL url = pathElem.toURI().toURL();
+ urls.add(url);
+ getLog().debug("Added classpathElement URL " + url);
+ } catch (MalformedURLException e) {
+ throw new RuntimeException(
+ "Error in adding the classpath " + pathElem, e);
+ }
+ }
+
+ return new URLClassLoader(
+ urls.toArray(new URL[urls.size()]),
+ Thread.currentThread().getContextClassLoader());
+ }
+}
Copied: trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/config/AggregateApplicationConfigReport.java (from rev 2512, trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/plugin/report/AggregateApplicationConfigReport.java)
===================================================================
--- trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/config/AggregateApplicationConfigReport.java (rev 0)
+++ trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/config/AggregateApplicationConfigReport.java 2013-03-03 15:20:18 UTC (rev 2521)
@@ -0,0 +1,78 @@
+package org.nuiton.util.config;
+
+/*
+ * #%L
+ * Nuiton Utils :: Maven Report Plugin
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+import org.apache.maven.artifact.DependencyResolutionRequiredException;
+import org.apache.maven.plugins.annotations.Execute;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.plugins.annotations.ResolutionScope;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.reporting.MavenReportException;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * Generates a report for declarated application config via the
+ * {@link ApplicationConfigProvider} mecanism on a aggregate mojo.
+ * <p/>
+ * For each configuration, you can find all his options and actions.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.6.10
+ */
+@Mojo(name = "aggregate-config-report", aggregator = true,
+ requiresProject = true, requiresReports = true,
+ requiresDependencyResolution = ResolutionScope.RUNTIME)
+@Execute(phase = LifecyclePhase.COMPILE)
+public class AggregateApplicationConfigReport extends AbstractApplicationConfigReport {
+
+ /**
+ * The projects in the reactor.
+ *
+ * @since 2.6.10
+ */
+ @Parameter(property = "reactorProjects", readonly = true, required = true)
+ protected List<?> reactorProjects;
+
+ @Override
+ protected ClassLoader createClassLoader() throws MavenReportException {
+ Set<String> paths = new HashSet<String>();
+
+ for (Object o : reactorProjects) {
+ MavenProject p = (MavenProject) o;
+ try {
+ List runtimeClasspathElements = p.getRuntimeClasspathElements();
+ paths.addAll(runtimeClasspathElements);
+ } catch (DependencyResolutionRequiredException e) {
+ throw new MavenReportException("Could not obtain dependencies for project " + p);
+ }
+ }
+ return createClassLoader(paths);
+ }
+}
Copied: trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/config/ApplicationConfigReport.java (from rev 2512, trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/plugin/report/ApplicationConfigReport.java)
===================================================================
--- trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/config/ApplicationConfigReport.java (rev 0)
+++ trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/config/ApplicationConfigReport.java 2013-03-03 15:20:18 UTC (rev 2521)
@@ -0,0 +1,62 @@
+package org.nuiton.util.config;
+
+/*
+ * #%L
+ * Nuiton Utils :: Maven Report Plugin
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.plugins.annotations.ResolutionScope;
+
+import java.util.HashSet;
+import java.util.List;
+
+/**
+ * Generates a report for declarated application config via the
+ * {@link ApplicationConfigProvider} mecanism.
+ * <p/>
+ * For each configuration, you can find all his options and actions.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.6.10
+ */
+@Mojo(name = "config-report",
+ requiresProject = true, requiresReports = true,
+ requiresDependencyResolution = ResolutionScope.RUNTIME)
+public class ApplicationConfigReport extends AbstractApplicationConfigReport {
+
+ /**
+ * List of all class-path elements.
+ *
+ * @since 2.6.10
+ */
+ @Parameter(property = "project.runtimeClasspathElements",
+ required = true, readonly = true)
+ protected List<String> runtimeClasspathElements;
+
+ @Override
+ protected ClassLoader createClassLoader() {
+ return createClassLoader(new HashSet<String>(runtimeClasspathElements));
+ }
+
+}
Copied: trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/config/ApplicationConfigReportRenderer.java (from rev 2512, trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/plugin/report/ApplicationConfigReportRenderer.java)
===================================================================
--- trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/config/ApplicationConfigReportRenderer.java (rev 0)
+++ trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/config/ApplicationConfigReportRenderer.java 2013-03-03 15:20:18 UTC (rev 2521)
@@ -0,0 +1,513 @@
+package org.nuiton.util.config;
+
+/*
+ * #%L
+ * Nuiton Utils :: Maven Report Plugin
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 - 2013 CodeLutin
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.maven.doxia.sink.Sink;
+import org.apache.maven.doxia.sink.SinkEventAttributeSet;
+import org.apache.maven.reporting.AbstractMavenReportRenderer;
+import org.codehaus.plexus.i18n.I18N;
+import org.codehaus.plexus.util.StringUtils;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Set;
+
+import static org.nuiton.i18n.I18n.l_;
+
+/**
+ * Render the {@link ApplicationConfigReport} report.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 2.6.10
+ */
+public class ApplicationConfigReportRenderer extends AbstractMavenReportRenderer {
+
+ /**
+ * Internationalization component.
+ *
+ * @since 2.6.10
+ */
+ protected final I18N i18n;
+
+ /**
+ * The locale we are rendering for.
+ *
+ * @since 2.6.10
+ */
+ protected final Locale locale;
+
+ /**
+ * The name of the bundle containing our I18n resources.
+ *
+ * @since 2.6.10
+ */
+ protected final String bundleName;
+
+ /**
+ * Set of config providers to generate.
+ *
+ * @since 2.6.10
+ */
+ protected final Set<ApplicationConfigProvider> configProviders;
+
+
+ /**
+ * To show option in detail.
+ *
+ * @since 2.6.10
+ */
+ protected final boolean optionWithDetail;
+
+ public ApplicationConfigReportRenderer(Sink sink,
+ I18N i18n,
+ Locale locale,
+ String bundleName,
+ Set<ApplicationConfigProvider> configProviders,
+ boolean optionWithDetail) {
+ super(sink);
+ this.i18n = i18n;
+ this.locale = locale;
+ this.bundleName = bundleName;
+ this.sink = sink;
+ this.configProviders = configProviders;
+ this.optionWithDetail = optionWithDetail;
+ }
+
+ @Override
+ public String getTitle() {
+ return getText("report.title");
+ }
+
+ @Override
+ public void renderBody() {
+
+ sink.section1();
+ sink.sectionTitle1();
+ sink.text(getText("report.overview.title"));
+ sink.sectionTitle1_();
+ sink.lineBreak();
+ sink.paragraph();
+ sink.text(getText("report.overview.text"));
+ sink.paragraph_();
+
+ sink.paragraph();
+ sink.link("http://maven-site.nuiton.org/nuiton-utils/nuiton-utils/ApplicationConfig.ht…");
+ sink.text(getText("report.overview.more.information"));
+ sink.link_();
+ sink.paragraph_();
+ sink.lineBreak();
+
+ renderProviderSummaryTable();
+
+ sink.section1_();
+
+ if (CollectionUtils.isNotEmpty(configProviders)) {
+
+ sink.section1();
+ sink.sectionTitle1();
+ sink.text(getText("report.detail.title"));
+ sink.sectionTitle1_();
+ sink.lineBreak();
+ sink.paragraph();
+ sink.text(getText("report.detail.text"));
+ sink.paragraph_();
+
+ for (ApplicationConfigProvider configProvider : configProviders) {
+
+ renderConfigProviderDetail(configProvider);
+ }
+
+ sink.section1_();
+ }
+ }
+
+ protected void renderProviderSummaryTable() {
+
+ if (CollectionUtils.isEmpty(configProviders)) {
+
+ sink.text(getText("report.detail.text.noConfig"));
+
+ } else {
+ sink.table();
+
+ sink.tableRow();
+ sinkHeaderCellText(getText("report.config.name"));
+ sinkHeaderCellText(getText("report.config.description"));
+ sinkHeaderCellText(getText("report.config.nbOptions"));
+ sinkHeaderCellText(getText("report.config.nbActions"));
+ sink.tableRow_();
+
+ for (ApplicationConfigProvider configProvider : configProviders) {
+
+ sink.tableRow();
+ sinkCellLink(configProvider.getName(), "./application-config-report.html#detail_" + configProvider.getName());
+ sinkCellText(configProvider.getDescription(locale));
+ sinkCellText(configProvider.getOptions().length + "");
+ sinkCellText(configProvider.getActions().length + "");
+ sink.tableRow_();
+ }
+ sink.table_();
+ }
+ }
+
+ protected void renderConfigProviderDetail(ApplicationConfigProvider configProvider) {
+
+ sink.section2();
+ sink.sectionTitle2();
+ sink.anchor("detail_" + configProvider.getName());
+ sink.text(getText("report.detail.configuration.title") + " " +
+ configProvider.getName());
+ sink.anchor_();
+ sink.sectionTitle2_();
+
+ sink.lineBreak();
+ sink.paragraph();
+ sink.text(getText("report.config.name") + " : ");
+ sink.bold();
+ sink.text(configProvider.getName());
+ sink.bold_();
+ sink.paragraph_();
+
+ sink.lineBreak();
+ sink.paragraph();
+ sink.text(getText("report.config.description") + " : ");
+ sink.bold();
+ sink.text(configProvider.getDescription(locale));
+ sink.bold_();
+ sink.paragraph_();
+
+ sink.section3();
+ sink.sectionTitle3();
+ sink.anchor("detail_options_" + configProvider.getName());
+
+ sink.text(getText("report.detail.options.title"));
+ sink.anchor_();
+ sink.sectionTitle3_();
+ sink.lineBreak();
+
+ Collection<ConfigOptionDef> options =
+ getOptions(configProvider);
+
+ renderOptionDefsTable(configProvider, options);
+
+ if (optionWithDetail) {
+
+ for (ConfigOptionDef option : options) {
+
+ renderProviderOptionDetail(configProvider, option);
+ }
+ }
+
+ sink.section3_();
+
+ sink.section3();
+ sink.sectionTitle3();
+ sink.text(getText("report.detail.actions.title"));
+ sink.sectionTitle3_();
+ sink.lineBreak();
+
+ renderActionDefsTable(configProvider.getActions());
+
+ sink.section3_();
+
+ sink.section2_();
+ }
+
+ protected void renderOptionDefsTable(ApplicationConfigProvider configProvider,
+ Collection<ConfigOptionDef> options) {
+
+ if (options.isEmpty()) {
+
+ sink.paragraph();
+ sink.bold();
+ sink.text(getText("report.detail.options.noOptions"));
+ sink.bold_();
+ sink.paragraph_();
+
+ } else {
+
+ sink.table();
+ sink.tableRow();
+
+ sinkHeaderCellText(getText("report.config.option.key"));
+ sinkHeaderCellText(getText("report.config.option.description"));
+ if (!optionWithDetail) {
+ sinkHeaderCellText(getText("report.config.option.type"));
+ }
+ sinkHeaderCellText(getText("report.config.option.defaultValue"));
+
+ if (!optionWithDetail) {
+ sinkHeaderCellText(getText("report.config.option.final"));
+ sinkHeaderCellText(getText("report.config.option.transient"));
+ }
+ sink.tableRow_();
+
+ for (ConfigOptionDef option : options) {
+
+ sink.tableRow();
+ if (optionWithDetail) {
+ sinkCellLink(
+ option.getKey(),
+ "./application-config-report.html#detail_" +
+ configProvider.getName() + "_" + option.getKey());
+ } else {
+ sinkCellText(option.getKey());
+ }
+ sinkCellText(l_(locale, option.getDescription()));
+ if (!optionWithDetail) {
+ sinkCellText(option.getType().getName());
+ }
+ sinkCellVerbatimText(getDefaultValue(option));
+ if (!optionWithDetail) {
+ sinkCellText(getText(!option.isFinal()));
+ sinkCellText(getText(!option.isTransient()));
+ }
+ sink.tableRow_();
+ }
+
+ sink.table_();
+
+ }
+ }
+
+ protected void renderActionDefsTable(ConfigActionDef... actions) {
+
+ if (actions.length == 0) {
+
+ sink.paragraph();
+ sink.bold();
+ sink.text(getText("report.detail.actions.noActions"));
+ sink.bold_();
+ sink.paragraph_();
+
+ } else {
+
+ sink.table();
+
+ sink.tableRow();
+ sinkHeaderCellText(getText("report.config.action.action"));
+ sinkHeaderCellText(getText("report.config.action.aliases"));
+ sink.tableRow_();
+
+ for (ConfigActionDef action : actions) {
+ sink.tableRow();
+ sinkCellText(action.getAction());
+ sinkCellText(l_(locale, Arrays.toString(action.getAliases())));
+ sink.tableRow_();
+ }
+
+ sink.table_();
+ }
+ }
+
+ protected void renderProviderOptionDetail(ApplicationConfigProvider configProvider,
+ ConfigOptionDef option) {
+
+ final String cellWidth = "80%";
+ final String headerWidth = "20%";
+
+ sink.section4();
+ sink.sectionTitle4();
+ sink.anchor("detail_" + configProvider.getName() + "_" + option.getKey());
+ sink.text(getText("report.config.option.detail") + " '" + option.getKey()
+ + "'");
+ sink.sectionTitle4_();
+ sink.lineBreak();
+
+ sink.table();
+ sink.tableRows(new int[]{Sink.JUSTIFY_RIGHT, Sink.JUSTIFY_LEFT}, false);
+
+ sink.tableRow();
+ sinkHeaderCellText(headerWidth, getText("report.config.option.key"));
+ sink.tableCell(cellWidth);
+ sink.nonBreakingSpace();
+ sink.bold();
+ sink.text(option.getKey());
+ sink.bold_();
+ sink.tableCell_();
+ sink.tableRow_();
+
+ sink.tableRow();
+ sinkHeaderCellText(headerWidth, getText("report.config.option.description"));
+ sink.tableCell(cellWidth);
+ sink.nonBreakingSpace();
+ sink.text(l_(locale, option.getDescription()));
+ sink.tableCell_();
+ sink.tableRow_();
+
+ sink.tableRow();
+ sinkHeaderCellText(headerWidth, getText("report.config.option.defaultValue"));
+ sink.tableCell(cellWidth);
+ sink.nonBreakingSpace();
+ sink.bold();
+ sink.text(getDefaultValue(option));
+ sink.bold_();
+ sink.tableCell_();
+ sink.tableRow_();
+
+ sink.tableRow();
+ sinkHeaderCellText(headerWidth, getText("report.config.option.type"));
+ sink.tableCell(cellWidth);
+ sink.nonBreakingSpace();
+ sink.text(option.getType().getName());
+ sink.tableCell_();
+ sink.tableRow_();
+
+ sink.tableRow();
+ sinkHeaderCellText(headerWidth, getText("report.config.option.final"));
+ sink.tableCell(cellWidth);
+ sink.nonBreakingSpace();
+ sink.text(getText(!option.isFinal()));
+ sink.tableCell_();
+ sink.tableRow_();
+
+ sink.tableRow();
+ sinkHeaderCellText(headerWidth, getText("report.config.option.transient"));
+ sink.tableCell(cellWidth);
+ sink.nonBreakingSpace();
+ sink.text(getText(!option.isTransient()));
+ sink.tableCell_();
+ sink.tableRow_();
+
+ sink.table_();
+
+ sink.paragraph();
+ sink.link("./application-config-report.html#detail_options_" + configProvider.getName());
+ sink.text(getText("report.back.options.table"));
+ sink.link_();
+ sink.paragraph_();
+
+ sink.section4_();
+
+ }
+
+ protected String getText(boolean key) {
+ return getText("report." + String.valueOf(key));
+ }
+
+ /**
+ * Gets the localized message for this report.
+ *
+ * @param key the message key.
+ * @return the message.
+ */
+ protected String getText(String key) {
+ return i18n.getString(bundleName, locale, key);
+ }
+
+ protected String getDefaultValue(ConfigOptionDef option) {
+ String defaultValue = option.getDefaultValue();
+ if (StringUtils.isBlank(defaultValue)) {
+ defaultValue = getText("report.noDefaultValue");
+ }
+ return defaultValue;
+ }
+
+ protected void renderWarningIcon() {
+ sink.figure();
+ sink.figureGraphics("images/icon_warning_sml.gif");
+ sink.figure_();
+ }
+
+ protected void renderErrorIcon() {
+ sink.figure();
+ sink.figureGraphics("images/icon_error_sml.gif");
+ sink.figure_();
+ }
+
+ protected void renderSuccessIcon() {
+ sink.figure();
+ sink.figureGraphics("images/icon_success_sml.gif");
+ sink.figure_();
+ }
+
+ protected void renderInfoIcon() {
+ sink.figure();
+ sink.figureGraphics("images/icon_info_sml.gif");
+ sink.figure_();
+ }
+
+ protected void sinkHeaderCellText(String text) {
+ sink.tableHeaderCell();
+ sink.text(text);
+ sink.tableHeaderCell_();
+ }
+
+ protected void sinkHeaderCellText(String width, String text) {
+ sink.tableHeaderCell(width);
+ sink.text(text);
+ sink.tableHeaderCell_();
+ }
+
+ protected void sinkCellText(String width, String text) {
+ sink.tableCell(width);
+ sink.text(text);
+ sink.tableCell_();
+ }
+
+ protected void sinkCellText(String text) {
+ sink.tableCell();
+ sink.text(text);
+ sink.tableCell_();
+ }
+
+ protected void sinkCellVerbatimText(String text) {
+ sink.tableCell();
+ sink.verbatim(SinkEventAttributeSet.MONOSPACED);
+ sink.text(text);
+ sink.verbatim_();
+ sink.tableCell_();
+ }
+
+ protected void sinkCellLink(String text, String url) {
+ sink.tableCell();
+ sink.link(url);
+ sink.text(text);
+ sink.link_();
+ sink.tableCell_();
+ }
+
+ protected Collection<ConfigOptionDef> getOptions(
+ ApplicationConfigProvider configProvider) {
+ List<ConfigOptionDef> result =
+ new ArrayList<ConfigOptionDef>(
+ Arrays.asList(configProvider.getOptions()));
+ Collections.sort(result, new Comparator<ConfigOptionDef>() {
+ @Override
+ public int compare(ConfigOptionDef o1,
+ ConfigOptionDef o2) {
+ return o1.getKey().compareTo(o2.getKey());
+ }
+ });
+ return result;
+ }
+
+}
Modified: trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/plugin/report/AbstractApplicationConfigReport.java
===================================================================
--- trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/plugin/report/AbstractApplicationConfigReport.java 2013-02-26 15:30:54 UTC (rev 2520)
+++ trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/plugin/report/AbstractApplicationConfigReport.java 2013-03-03 15:20:18 UTC (rev 2521)
@@ -52,7 +52,9 @@
*
* @author tchemit <chemit(a)codelutin.com>
* @since 2.4.9
+ * @deprecated since 2.6.10, use now {@link org.nuiton.util.config.AbstractApplicationConfigReport}
*/
+@Deprecated
public abstract class AbstractApplicationConfigReport extends AbstractMavenReport {
/**
Modified: trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/plugin/report/AggregateApplicationConfigReport.java
===================================================================
--- trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/plugin/report/AggregateApplicationConfigReport.java 2013-02-26 15:30:54 UTC (rev 2520)
+++ trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/plugin/report/AggregateApplicationConfigReport.java 2013-03-03 15:20:18 UTC (rev 2521)
@@ -45,11 +45,13 @@
*
* @author tchemit <chemit(a)codelutin.com>
* @since 2.4.9
+ * @deprecated since 2.6.10, use now {@link org.nuiton.util.config.AggregateApplicationConfigReport}
*/
@Mojo(name = "aggregate-application-config-report", aggregator = true,
requiresProject = true, requiresReports = true,
requiresDependencyResolution = ResolutionScope.RUNTIME)
@Execute(phase = LifecyclePhase.COMPILE)
+@Deprecated
public class AggregateApplicationConfigReport extends AbstractApplicationConfigReport {
/**
Modified: trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/plugin/report/ApplicationConfigReport.java
===================================================================
--- trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/plugin/report/ApplicationConfigReport.java 2013-02-26 15:30:54 UTC (rev 2520)
+++ trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/plugin/report/ApplicationConfigReport.java 2013-03-03 15:20:18 UTC (rev 2521)
@@ -40,10 +40,12 @@
*
* @author tchemit <chemit(a)codelutin.com>
* @since 2.4.8
+ * @deprecated since 2.6.10, use now {@link org.nuiton.util.config.ApplicationConfigReport}
*/
@Mojo(name = "application-config-report",
requiresProject = true, requiresReports = true,
requiresDependencyResolution = ResolutionScope.RUNTIME)
+@Deprecated
public class ApplicationConfigReport extends AbstractApplicationConfigReport {
/**
Modified: trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/plugin/report/ApplicationConfigReportRenderer.java
===================================================================
--- trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/plugin/report/ApplicationConfigReportRenderer.java 2013-02-26 15:30:54 UTC (rev 2520)
+++ trunk/nuiton-utils-maven-report-plugin/src/main/java/org/nuiton/util/plugin/report/ApplicationConfigReportRenderer.java 2013-03-03 15:20:18 UTC (rev 2521)
@@ -49,7 +49,9 @@
*
* @author tchemit <chemit(a)codelutin.com>
* @since 2.4.8
+ * @deprecated since 2.6.10, use now {@link org.nuiton.util.config.ApplicationConfigReportRenderer}
*/
+@Deprecated
public class ApplicationConfigReportRenderer extends AbstractMavenReportRenderer {
/**
1
0
Author: athimel
Date: 2013-02-26 16:30:54 +0100 (Tue, 26 Feb 2013)
New Revision: 2520
Url: http://nuiton.org/projects/nuiton-utils/repository/revisions/2520
Log:
Fix spelling and conjugation in nuiton-config's index documentation
Modified:
trunk/nuiton-config/src/site/apt/index.apt
Modified: trunk/nuiton-config/src/site/apt/index.apt
===================================================================
--- trunk/nuiton-config/src/site/apt/index.apt 2013-02-26 14:48:17 UTC (rev 2519)
+++ trunk/nuiton-config/src/site/apt/index.apt 2013-02-26 15:30:54 UTC (rev 2520)
@@ -30,23 +30,23 @@
Présentation
- La classe ApplicationConfig a pour but de gérer les options et action
- disponible au sein d'une application. Elle gère aussi bien :
+ La classe ApplicationConfig a pour but de gérer les options et actions
+ disponibles au sein d'une application. Elle gère aussi bien :
- * la lecture de fichier de configuration
+ * la lecture de fichier de configuration ;
- * le parsage de la ligne de commande
+ * le parsage de la ligne de commande ;
- * l'execution des actions
+ * l'execution des actions ;
- * la sauvegarde de la configuration
+ * la sauvegarde de la configuration.
Lecture/écriture
* Lecture des fichiers de configuration
- La lecture des fichiers de configuration est effectuées lors de l'appel
+ La lecture des fichiers de configuration est effectuée lors de l'appel
à la methode <<<parse(String...)>>> en utilisant la valeur de
<<<getConfigFileName()>>> pour trouver les fichiers à lire.
@@ -54,27 +54,27 @@
La sauvegarde des options se fait via une des trois methodes disponibles :
- * <<<save>>> : sauvegarde dans un fichier specifique
+ * <<<save>>> : sauvegarde dans un fichier specifique ;
- * <<<saveForSystem>>> : sauvegarde les donnees dans /etc
+ * <<<saveForSystem>>> : sauvegarde les donnees dans /etc ;
- * <<<saveForUser>>> : sauvegarde les donnees dans $HOME
+ * <<<saveForUser>>> : sauvegarde les donnees dans $HOME.
[]
Seules les options qui ont été modifiées par l'application (par la methode
- <<<setOption()>>> seront sauvegardée. Les variable d'envirronement, les
- arguments de la ligne de commandes(etc...) ne seront pas sauvegardées.
+ <<<setOption()>>>) seront sauvegardées. Les variables d'environnement, les
+ arguments de la ligne de commandes(etc...) ne seront pas sauvegardés.
* Configuration multi instance
- Il est possible d'associé un nom de contexte a une configuration via la
+ Il est possible d'associer un nom de contexte à une configuration via la
methode <<<setAppName("azerty")>>>. Ainsi, les fichiers seront cherchés
- dans le dossier définit par l'option <<<azerty.config.path>>> si elle existe
- (sinon, dans le dossier par defaut) et le nom du fichier cherché defini
+ dans le dossier défini par l'option <<<azerty.config.path>>> si elle existe
+ (sinon, dans le dossier par défaut) et le nom du fichier cherché defini
par l'option <<<azerty.config.file>>>.
- Cett option est utilise par exemple pour installer plusieurs instance
+ Cette option est utilisée par exemple pour installer plusieurs instances
d'application dans un serveur web et que chaque instance aille
chercher ses fichiers de configuration à son propre endroit.
@@ -82,30 +82,29 @@
* Les options de configuration
- L'ordre de prise en compte des options suivant les différentes sources est
- le suivant :
+ L'ordre de prise en compte des options est le suivant :
- * Option renseignées par programmation
+ * Option renseignée par programmation ;
- * Ligne de commandes
+ * Ligne de commande ;
- * Propriétés systèmes (System.getProperties())
+ * Propriétés système (System.getProperties()) ;
- * Propriétés d'envirronement (System.getenv())
+ * Propriétés d'environnement (System.getenv()) ;
- * Fichier du dossier courant ( ./ + nom du fichier)
+ * Fichier du dossier courant ( ./ + nom du fichier) ;
- * Fichier de configuration globale ( /etc/ + nom du fichier)
+ * Fichier de configuration globale ( /etc/ + nom du fichier) ;
- * Fichier dans le classpath ( / + nom du fichier)
+ * Fichier dans le classpath ( / + nom du fichier) ;
- * Valeur par défaut (renseignés à l'init)
+ * Valeur par défaut (renseignée à l'init).
[]
- Cela signifie par exemple que si une option à une valeur par défaut, est renseignée
- dans le fichier /etc et sur la ligne de commande, la valeur presente sur la
- ligne de commande sera prise en compte.
+ Cela signifie par exemple que si une option a une valeur par défaut et qu'elle
+ est renseignée dans le fichier /etc et sur la ligne de commande, c'est la
+ valeur présente sur la ligne de commande qui sera prise en compte.
* Les actions
@@ -117,25 +116,25 @@
Une action est donc définie par le chemin complet de la methode qui traitera
l'action. Si la methode est statique, elle sera appelée directement. Dans le
- cas contraire, la classe contenant la methode sera instancié à partir
- d'un constructeur prenant en parametre seulement la configuration, ou, s'il
- n'est pas disponible, le constructeur par defaut. La methode sera ensuite
- appelée sur cette instance. Les divers instances sont conservés pour effectué
- plusieurs actions.
+ cas contraire, la classe contenant la méthode sera instanciée à partir
+ d'un constructeur prenant en paramètre seulement la configuration, ou, s'il
+ n'est pas disponible, le constructeur par défaut. La méthode sera ensuite
+ appelée sur cette instance. Les diverses instances sont conservées pour
+ effectuer plusieurs actions.
- Les arguments de la methode sont utilisé lors de l'appel. On sont convertit
- dans le bon type. Si la méthode avec des arguments de taille variante (...)
- tous les arguments jusqu'a la prochaine option ou à la fin de la ligne
- seront utilisé.
+ Les arguments de la méthode utilisés lors de l'appel sont convertis
+ dans le bon type. Si la méthode a des arguments de taille variante (...)
+ tous les arguments jusqu'à la prochaine option ou à la fin de la ligne
+ seront utilisés.
- Si vous avez des parametres optionnels, le seul moyen est d'utiliser des
- arguments variant.
+ Si vous avez des paramètres optionnels, le seul moyen est d'utiliser des
+ arguments variants.
- Par exemple, la ligne de commande précédente appelera la methode
+ Par exemple, la ligne de commande précédente appelera la methode :
+-------------------------------------------
public class Test {
- public goLogin(String login, String password, boolean dryRun) {
+ public doLogin(String login, String password, boolean dryRun) {
[...]
}
}
@@ -144,10 +143,10 @@
Les actions ne sont pas executées, mais seulement parsées. Cela signifie
qu'elles seront executées seulement lorsque l'application appelera la méthode
<<<doAction(int)>>>.
- Par defaut, toutes les actions sont de niveau 0 et sont executées dans leur
+ Par défaut, toutes les actions sont de niveau 0 et sont executées dans leur
ordre d'apparition sur la ligne de commande.
- Il est possible de differencier les differentes action en utilisant l'annotation
- <<<@Step>>>
+ Il est possible de différencier les différentes actions en utilisant
+ l'annotation <<<@Step>>>
+-------------------------------------------
doAction(0);
@@ -156,13 +155,13 @@
+-------------------------------------------
Dans cet exemple, les actions 0 et 1 ne sont pas effectuées au même moment.
- C'est très utile par exemple pour executer certaines actions avant le démarrage
- de l'UI par exemple, et d'autre après...
+ C'est très utile par exemple pour éxecuter certaines actions avant le démarrage
+ de l'UI par exemple, et d'autres après...
-* Les arguments non parsées
+* Les arguments non parsés
- La configuration 'consome' les arguments de la ligne de commande qu'elle a
- réussie a traiter. Pour recuperer les autres arguments propres à l'application
+ La configuration 'consomme' les arguments de la ligne de commande qu'elle a
+ réussie à traiter. Pour recupérer les autres arguments propres à l'application
il est possible de les obtenir grace à la méthode <<<getUnparsed()>>>.
Si l'on souhaite forcer la fin du parsing de la ligne de commande il est
possible de mettre <<<-->>>.
@@ -173,7 +172,7 @@
monApplication "mon arg" --option k1 v1 -- --option k2 v2 -- autre
+-------------------------------------------
- Renvera la liste suivante via <<<getUnparsed()>>> :
+ Renverra la liste suivante via <<<getUnparsed()>>> :
+-------------------------------------------
"mon arg", "--option", "k2", "v2", "--", "autre"
@@ -190,7 +189,13 @@
addAlias("-i", "--mon.package.MaClass#MaMethode", "import");
+-------------------------------------------
- Lors du parsing de la ligne de commande, tous les alias sont remplacé par
+ Dans le premier exemple on simplifie une option de flags l'option -v n'attend
+ donc plus d'argument. Dans le second exemple on simplifie une option qui
+ attend encore un argment de type File. Enfin dans le troisieme exemple
+ on simplifie la syntaxe d'une action et on force le premier argument de
+ l'action à être "import".
+
+ Lors du parsing de la ligne de commande, tous les alias sont remplacés par
leur correspondance. Il est donc possible d'utiliser ce mecanisme pour
autre chose :
@@ -198,49 +203,43 @@
addAlias("cl", "Code Lutin");
+-------------------------------------------
- Dans le premier exemple on simplifie une option de flags l'option -v n'attend
- donc plus d'argument. Dans le second exemple on simplifie une option qui
- attend encore un argment de type File. Enfin dans le troisieme exemple
- on simplifie la syntaxe d'une action et on force le premier argument de
- l'action a etre "import".
-
* Conversion de type
- Pour convertir les types des options et arguments de methodes,
+ Pour convertir les types des options et arguments de méthodes,
{{{http://commons.apache.org/beanutils/}commons-beanutils}} est utilisé.
Les types actuellement supporté sont :
- * <<<java.lang.String>>>
+ * <<<java.lang.String>>> ;
- * <<<java.io.File>>>
+ * <<<java.io.File>>> ;
- * <<<java.net.URL>>>
+ * <<<java.net.URL>>> ;
- * <<<java.lang.Class>>>
+ * <<<java.lang.Class>>> ;
- * <<<java.sql.Date>>>
+ * <<<java.sql.Date>>> ;
- * <<<java.sql.Time>>>
+ * <<<java.sql.Time>>> ;
- * <<<java.sql.Timestamp>>>
+ * <<<java.sql.Timestamp>>> ;
* Les tableaux d'un type primitif ou {@link String}. Chaque élément doit
être séparé par une virgule.
[]
- Pour utiliser d'autre type, il suffit de le enregistrer dans beanutils via
- la mézthode <<<ConvertUtils.register(Converter, Class)>>>
+ Pour utiliser d'autres types, il suffit de les enregistrer dans beanutils via
+ la méthode <<<ConvertUtils.register(Converter, Class)>>>
* Les substitutions de variable
- La configuration de variable supporte la substitution par d'autre variable
- via la synthaxe <<<$\{xxx\}>>> où <<<xxx>>> est une autre variable de
- la configuration
+ La configuration de variable supporte la substitution par d'autres variables
+ via la syntaxe <<<$\{xxx\}>>> où <<<xxx>>> est une autre variable de
+ la configuration.
- Par exemple (fichier de configuration):
+ Par exemple (fichier de configuration) :
+-------------------------------------------
application.name = Mon Appli
@@ -249,13 +248,13 @@
+-------------------------------------------
L'appel de l'option <<<application.info>>> via la methode <<<getOption()>>>
- retournera une chaine de la forme:
+ retournera une chaîne de la forme :
+-------------------------------------------
Mon Appli 1.2.3 (1.6.0_18)
+-------------------------------------------
- À noter que les substitutions ne sont remplacée qu'a leur lecture, la sauvegarde
+ À noter que les substitutions ne sont remplacées qu'a leur lecture, la sauvegarde
de l'option <<<application.info>>> se fera sans remplacement.
Mise en oeuvre
@@ -265,13 +264,13 @@
Voici l'ensemble des tâches à effectuer pour définir une configuration
d'application :
- * Creation d'une sous classes d'<<<ApplicationConfig>>>
+ * Creation d'une sous classe d'<<<ApplicationConfig>>> ;
- * Ajout des options par défaut
+ * Ajout des options par défaut ;
- * Creation des classes et méthodes d'actions
+ * Création des classes et méthodes d'actions ;
- * Déclaration des alias des options et actions
+ * Déclaration des alias des options et actions.
[]
@@ -280,33 +279,33 @@
+-------------------------------------------
public class MyConfig extends ApplicationConfig {
- public final static int AFTER_LOGIN = 1;
+ public static final int AFTER_LOGIN = 1;
public MyConfig () {
- // options par defaut
- setDefaultOption("user", "anonymous");
- setDefaultOption("password", "");
- // ajout des alias
- addAlias("-u", "--user");
- addAlias("-p", "--password");
- addActionAlias("--login", MyConfig.class.getName + "#" + doLogin");
+ // options par défaut
+ setDefaultOption("user", "anonymous");
+ setDefaultOption("password", "");
+ // ajout des alias
+ addAlias("-u", "--user");
+ addAlias("-p", "--password");
+ addActionAlias("--login", MyConfig.class.getName + "#" + "doLogin");
}
public void setUser(String user) {
- setOption("user", user);
+ setOption("user", user);
}
public void setUser(String user) {
- setOption("user", user);
+ setOption("user", user);
}
public void doLogin(String user, String password) {
- [...]
+ [...]
}
@Step(AFTER_LOGIN)
public void doSomething() {
- [...]
+ [...]
}
}
+-------------------------------------------
@@ -314,7 +313,7 @@
* Usage
La configuration doit principalement être initilalisée grâce à la méthode
- <<<parse(String[])>>> avant d'être utilisé.
+ <<<parse(String[])>>> avant d'être utilisée.
+-------------------------------------------
public static void main(String[] args) {
@@ -365,11 +364,11 @@
+-------------------------------------------
Puis ajouter le fichier <META-INF/services/org.nuiton.util.ApplicationConfigProvider>
- dans les resources du projet :
+ dans les resources du projet :
+-------------------------------------------
org.chorem.pollen.PollenApplicationConfigProvider
+-------------------------------------------
- Cela permet ensuite par exemple de générer un rapport contenant toutes les
- options disnible dans l'application.
+ Cela permet ensuite, par exemple, de générer un rapport contenant toutes les
+ options disponibles dans l'application.
1
0