diff -Nru plexus-containers-1.0~beta3.0.7/debian/changelog plexus-containers-1.7.1/debian/changelog --- plexus-containers-1.0~beta3.0.7/debian/changelog 2017-07-24 12:54:38.000000000 +0000 +++ plexus-containers-1.7.1/debian/changelog 2017-11-07 12:32:00.000000000 +0000 @@ -1,95 +1,175 @@ -plexus-containers (1.0~beta3.0.7-9) unstable; urgency=medium +plexus-containers (1.7.1-7) unstable; urgency=medium * Team upload. - * Build with maven-debian-helper instead of maven-ant-helper - * Moved the package to Git + * Renamed the libplexus-container-default1.5-java package to + libplexus-container-default-java (but keep a transitional package) + * Removed libplexus-containers1.5-java (no longer used) + * Relocate the version 1.5.5 of the plexus-component-metadata plugin + to the current version instead of patching the pom + + -- Emmanuel Bourg Tue, 07 Nov 2017 13:32:00 +0100 + +plexus-containers (1.7.1-6) unstable; urgency=medium + + * Team upload. + * Renamed the package to plexus-containers + * Install the Maven artifacts for plexus-component-annotations and + plexus-container-default with the 'debian' generic version and relocate + the version 1.5.5 + * Install versionless jars in /usr/share/java but keep compatibility links + * Depend on libplexus-classworlds-java (>= 2.5.2) + instead of libplexus-classworlds2-java + * Removed the unused Maven rule for plexus-component-javadoc + * Standards-Version updated to 4.1.1 + + -- Emmanuel Bourg Tue, 07 Nov 2017 11:22:49 +0100 + +plexus-containers1.5 (1.7.1-5) unstable; urgency=medium + + * Team upload. + * Depend on libxbean-reflect-java instead of libxbean-java + * Standards-Version updated to 4.1.0 + * Documented the upstream bug for 03-reproducible-metadata.patch + + -- Emmanuel Bourg Mon, 18 Sep 2017 13:07:31 +0200 + +plexus-containers1.5 (1.7.1-4) unstable; urgency=medium + + * Team upload. + * Depend on libmaven3-core-java instead of libmaven2-core-java + + -- Emmanuel Bourg Sun, 30 Jul 2017 01:17:10 +0200 + +plexus-containers1.5 (1.7.1-3) unstable; urgency=medium + + * Team upload. + * Fixed the compatibility with qdox 2.0~M5 + + -- Emmanuel Bourg Fri, 30 Jun 2017 22:34:09 +0200 + +plexus-containers1.5 (1.7.1-2) unstable; urgency=medium + + * Team upload. + * Added a symlink for plexus-component-annotations-1.5-1.6.jar + in /usr/share/java to work around a gradle issue (see #865499) * Standards-Version updated to 4.0.0 - * Switch to debhelper level 10 - * Updated the Homepage field - * Track and download the releases from GitHub - * Converted debian/copyright to the Copyright Format 1.0 - -- Emmanuel Bourg Mon, 24 Jul 2017 14:54:38 +0200 + -- Emmanuel Bourg Fri, 23 Jun 2017 09:57:14 +0200 -plexus-containers (1.0~beta3.0.7-8) unstable; urgency=medium +plexus-containers1.5 (1.7.1-1) unstable; urgency=medium * Team upload. - * No longer build plexus-component-javadoc (never used) - * Set the locale when generating the javadoc to make the build reproducible - * Standards-Version updated to 3.9.7 (no changes) - * Switch to debhelper level 9 + * Upload to unstable - -- Emmanuel Bourg Fri, 12 Feb 2016 10:03:38 +0100 + -- Emmanuel Bourg Mon, 19 Jun 2017 15:34:19 +0200 -plexus-containers (1.0~beta3.0.7-7) unstable; urgency=low +plexus-containers1.5 (1.7.1-1~exp2) experimental; urgency=medium * Team upload. - * Replaced Google Collections by Guava in the pom installed - in /usr/share/maven-repo (Closes: #724149) + * Ensure that libplexus-component-metadata-java pulls the same version + of libplexus-container-default1.5-java + + -- Emmanuel Bourg Mon, 22 May 2017 17:19:22 +0200 + +plexus-containers1.5 (1.7.1-1~exp1) experimental; urgency=medium + + * New upstream release + - Refreshed the patches + - Depend on libjdom2-java instead of libjdom1-java + * Updated the URL of the project homepage + * Switch to debhelper level 10 - -- Emmanuel Bourg Mon, 23 Sep 2013 13:00:53 +0200 + -- Emmanuel Bourg Thu, 18 May 2017 14:48:04 +0200 -plexus-containers (1.0~beta3.0.7-6) unstable; urgency=low +plexus-containers1.5 (1.6-3) unstable; urgency=medium * Team upload. - * Replaced the dependency on Google Collections by Guava - * Use canonical URLs for the Vcs-* fields - * debian/rules: Improved the clean target to allow rebuilds + * Depend on libasm-java (>= 5.0) instead of libasm4-java + * Standards-Version updated to 3.9.8 + * Use a secure Vcs-Git URL + + -- Emmanuel Bourg Tue, 27 Sep 2016 23:55:07 +0200 + +plexus-containers1.5 (1.6-2) unstable; urgency=medium - -- Emmanuel Bourg Wed, 11 Sep 2013 19:13:31 +0200 + * Team upload. + * Build with maven-debian-helper + * Sort the components in the components.xml files generated by the metadata + plugin. This should improve the reproducibility of the packages affected + by the random_order_in_plexus_comonents_xml issue. + * Moved the artifact to distinct packages to optimize the dependencies + * No longer build plexus-component-javadoc (never used) + * Removed the unused -doc package + * Depend on libqdox2-java instead of libqdox-java + * Updated Standards-Version to 3.9.7 (no changes) + * Updated the URL of the project homepage + + -- Emmanuel Bourg Fri, 12 Feb 2016 18:38:36 +0100 -plexus-containers (1.0~beta3.0.7-5) unstable; urgency=low +plexus-containers1.5 (1.6-1) unstable; urgency=medium * Team upload. - * Fix FTBFS with libgoogle-collections >= 1.0, - closes: #625972, #628328, #628294 - * Bump to Standards-Version 3.9.2: no changes needed. - * Bump Debhelper compat level to 7. + * New upstream release + - Removed 01-classworlds-compatibility.patch (fixed upstream) + - Depend on asm4 instead of asm3 (Closes: #800862) + - Build depend on junit4 instead of junit + - Reverted the update to qdox 2 (not yet in Debian) + * Improved the reproducibility: + - Set the locale and disable the timestamps when generating the javadoc + * debian/watch: Track the release tags on GitHub + * Updated Standards-Version to 3.9.6 (no changes) - -- Damien Raude-Morvan Tue, 31 May 2011 02:41:40 +0200 + -- Emmanuel Bourg Thu, 19 Nov 2015 19:27:19 +0100 -plexus-containers (1.0~beta3.0.7-4) unstable; urgency=low +plexus-containers1.5 (1.5.5-6) unstable; urgency=low - * Downgrade Build-Depends: default-jdk. - * Update Standards-Version: 3.8.4. - * Switch to source format 3.0. + * Team upload. + * Added a patch to fix the source incompatibility with plexus-classworlds 2.5 + (Closes: #728171) + * Updated Standards-Version to 3.9.5 (no changes) + * Build depend on debhelper >= 9 - -- Torsten Werner Wed, 05 May 2010 07:28:43 +0200 + -- Emmanuel Bourg Tue, 29 Oct 2013 11:10:33 +0100 -plexus-containers (1.0~beta3.0.7-3) unstable; urgency=low +plexus-containers1.5 (1.5.5-5) unstable; urgency=low - * Add versioned Conflicts: libplexus-container-default-java. (Closes: - #542055) + * Team upload. + * Replaced the dependency on Google Collections by Guava + * Use canonical URLs for the Vcs-* fields + * debian/rules: Improved the clean target to allow rebuilds + * debian/copyright: Updated the Format URI to 1.0 - -- Torsten Werner Mon, 17 Aug 2009 20:14:42 +0200 + -- Emmanuel Bourg Mon, 17 Jun 2013 13:38:11 +0200 -plexus-containers (1.0~beta3.0.7-2) unstable; urgency=low +plexus-containers1.5 (1.5.5-4) unstable; urgency=low + * Team upload. * Upload to unstable. + * Update gbp.conf to point to master branch. - -- Torsten Werner Sun, 09 Aug 2009 23:38:52 +0200 + -- tony mancill Sun, 02 Jun 2013 10:50:42 -0700 -plexus-containers (1.0~beta3.0.7-1) experimental; urgency=low +plexus-containers1.5 (1.5.5-3) experimental; urgency=low - * New upstream version, add myself to Uploaders. - * Change section to java, bump Standards-Version to 3.8.1 - * Add the Maven POM to the package, - * Add a Build-Depends-Indep dependency on maven-repo-helper - * Use mh_installpom and mh_installjar to install the POM and the jar to the - Maven repository - * Fix Lintian warning: Add ${misc:Depend} to libplexus-containers-java-doc - * Remove Depends on Java runtimes as it is a library + * Team upload. + * Drop dependency on libmaven-plugin-tools-java to break cycle + (Closes: #702363). + * Updated standards version to 3.9.4 - -- Ludovic Claude Tue, 24 Mar 2009 00:33:14 +0000 + -- Thomas Koch Tue, 05 Mar 2013 19:18:57 +0100 -plexus-containers (1.0~beta2-2) unstable; urgency=low +plexus-containers1.5 (1.5.5-2) unstable; urgency=low - * Add missing Depends. + * d/maven.rules: Force version to 1.5.5. + * d/control: Remove Ludovic and Torsten from Uploaders: I've added them by + cut-paste from old package, without their approval + (feel free to re-add yourself if you want). + * d/orig-tar.sh: Remove svn tarball handling. - -- Torsten Werner Fri, 26 Dec 2008 00:55:46 +0100 + -- Damien Raude-Morvan Sun, 22 Jan 2012 14:50:45 +0100 -plexus-containers (1.0~beta2-1) unstable; urgency=low +plexus-containers1.5 (1.5.5-1) unstable; urgency=low - * Initial release. (Closes: #507272) + * New upstream release (needed for Maven 3) (Closes: #649783). - -- Torsten Werner Fri, 05 Dec 2008 10:10:34 +0100 + -- Damien Raude-Morvan Mon, 28 Nov 2011 22:55:21 +0100 diff -Nru plexus-containers-1.0~beta3.0.7/debian/clean plexus-containers-1.7.1/debian/clean --- plexus-containers-1.0~beta3.0.7/debian/clean 2017-07-24 11:28:14.000000000 +0000 +++ plexus-containers-1.7.1/debian/clean 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -plexus-component-metadata/pom.xml diff -Nru plexus-containers-1.0~beta3.0.7/debian/control plexus-containers-1.7.1/debian/control --- plexus-containers-1.0~beta3.0.7/debian/control 2017-07-24 12:23:12.000000000 +0000 +++ plexus-containers-1.7.1/debian/control 2017-11-07 12:13:51.000000000 +0000 @@ -2,73 +2,86 @@ Section: java Priority: optional Maintainer: Debian Java Maintainers -Uploaders: - Torsten Werner , - Ludovic Claude +Uploaders: Damien Raude-Morvan Build-Depends: debhelper (>= 10), default-jdk, - junit, + junit4, + libasm-java (>= 5.0), + libcommons-cli-java, libguava-java, - libmaven-javadoc-plugin-java, - libplexus-classworlds-java, - libplexus-utils-java, - libxbean-java, - maven-debian-helper (>= 2.2) -Standards-Version: 4.0.0 + libjdom2-java, + libmaven3-core-java, + libplexus-classworlds-java (>= 2.5.2), + libplexus-cli-java, + libplexus-utils2-java, + libqdox2-java, + libxbean-reflect-java, + maven-debian-helper +Standards-Version: 4.1.1 Vcs-Git: https://anonscm.debian.org/git/pkg-java/plexus-containers.git Vcs-Browser: https://anonscm.debian.org/cgit/pkg-java/plexus-containers.git -Homepage: https://codehaus-plexus.github.io/plexus-containers/ +Homepage: https://github.com/codehaus-plexus/plexus-containers -Package: libplexus-containers-java +Package: libplexus-container-default-java Architecture: all -Depends: ${misc:Depends}, ${maven:Depends} -Suggests: ${maven:OptionalDepends} -Conflicts: libplexus-container-default-java (<= 1.0-alpha-9-stable-1-2) -Description: utilities for the Plexus framework +Depends: + libguava-java, + libplexus-classworlds-java (>= 2.5.2), + libplexus-utils2-java, + libxbean-reflect-java, + ${misc:Depends} +Breaks: libplexus-containers1.5-java (<< 1.6-2~), libplexus-containers-java, libplexus-container-default1.5-java (<< 1.7.1-7~) +Replaces: libplexus-containers1.5-java (<< 1.6-2~), libplexus-containers-java, libplexus-container-default1.5-java (<< 1.7.1-7~) +Description: Plexus Inversion-of-control Container The Plexus project provides a full software stack for creating and executing software projects. Based on the Plexus container, the applications can utilise component-oriented programming to build modular, reusable components that can easily be assembled and reused. . - While Plexus is similar to other inversion-of-control (IoC) or dependency - injection frameworks such as the Spring Framework, it is a full-fledged - container that supports many more features such as: - . - * Component lifecycles - * Component instantiation strategies - * Nested containers - * Component configuration - * Auto-wiring - * Component dependencies, and - * Various dependency injection techniques including constructor injection, - setter injection, and private field injection. + This package contains the plexus-container-default module. + +Package: libplexus-container-default1.5-java +Architecture: all +Section: oldlibs +Depends: ${misc:Depends}, libplexus-container-default-java (>= 1.7.1-7~) +Description: Plexus Inversion-of-control Container (transitional package) + The Plexus project provides a full software stack for creating and executing + software projects. Based on the Plexus container, the applications can + utilise component-oriented programming to build modular, reusable components + that can easily be assembled and reused. . - This package replaces the old packages libplexus-containers-default-java. + This is a transitional package, please use libplexus-container-default-java + instead. -Package: libplexus-containers-java-doc +Package: libplexus-component-annotations-java Architecture: all -Section: doc Depends: ${misc:Depends} -Suggests: libplexus-containers-java -Description: API Documentation for plexus-container-default +Breaks: libplexus-containers1.5-java (<< 1.6-2~), libplexus-containers-java +Replaces: libplexus-containers1.5-java (<< 1.6-2~), libplexus-containers-java +Description: Plexus Component Annotations + Plexus Component Java 5 annotations, to describe Plexus components + properties in java sources with standard annotations instead of javadoc + annotations. + +Package: libplexus-component-metadata-java +Architecture: all +Depends: + libasm-java (>= 5.0), + libcommons-cli-java, + libjdom2-java, + libmaven3-core-java, + libplexus-cli-java, + libplexus-component-annotations-java (= ${source:Version}), + libplexus-container-default-java (= ${source:Version}), + libqdox2-java, + ${misc:Depends} +Breaks: libplexus-containers1.5-java (<< 1.6-2~) +Replaces: libplexus-containers1.5-java (<< 1.6-2~) +Description: Component Metadata Maven plugin for Plexus The Plexus project provides a full software stack for creating and executing software projects. Based on the Plexus container, the applications can utilise component-oriented programming to build modular, reusable components that can easily be assembled and reused. . - While Plexus is similar to other inversion-of-control (IoC) or dependency - injection frameworks such as the Spring Framework, it is a full-fledged - container that supports many more features such as: - . - * Component lifecycles - * Component instantiation strategies - * Nested containers - * Component configuration - * Auto-wiring - * Component dependencies, and - * Various dependency injection techniques including constructor injection, - setter injection, and private field injection. - . - This package contains the API documentation for plexus-containers. It - replaces the old packages libplexus-containers-default-java-doc. + This package provides the Maven plugin generating the component metadata. diff -Nru plexus-containers-1.0~beta3.0.7/debian/copyright plexus-containers-1.7.1/debian/copyright --- plexus-containers-1.0~beta3.0.7/debian/copyright 2017-07-24 12:54:10.000000000 +0000 +++ plexus-containers-1.7.1/debian/copyright 2017-11-07 08:41:28.000000000 +0000 @@ -6,8 +6,17 @@ Copyright: 2001-2008, Codehaus Foundation License: Apache-2.0 -Files: plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/* - plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/* +Files: + plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/* + plexus-component-metadata/src/test/java/org/codehaus/plexus/metadata/merge/* + plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/* + plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/gleaner/ComponentGleanerException.java + plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/gleaner/QDoxComponentGleaner.java + plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/DefaultComponentDescriptorWriter.java + plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/DefaultMetadataGenerator.java + plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/ComponentDescriptorWriteException.java + plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/ComponentDescriptorWriter.java + plexus-component-metadata/src/main/java/org/codehaus/plexus/maven/plugin/* Copyright: 2001-2008, Codehaus Foundation License: MIT Permission is hereby granted, free of charge, to any person obtaining a copy of @@ -29,12 +38,10 @@ SOFTWARE. Files: debian/* -Copyright: 2008-2009, Torsten Werner - 2009, Ludovic Claude +Copyright: 2010, Torsten Werner 2011, Damien Raude-Morvan - 2013-2017, Emmanuel Bourg License: Apache-2.0 License: Apache-2.0 On Debian GNU/Linux system you can find the complete text of the - Apache-2.0 license in '/usr/share/common-licenses/Apache-2.0'. + Apache-2.0 license in '/usr/share/common-licenses/Apache-2.0' diff -Nru plexus-containers-1.0~beta3.0.7/debian/gbp.conf plexus-containers-1.7.1/debian/gbp.conf --- plexus-containers-1.0~beta3.0.7/debian/gbp.conf 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/debian/gbp.conf 2017-11-07 08:41:28.000000000 +0000 @@ -0,0 +1,2 @@ +[DEFAULT] +debian-branch = master diff -Nru plexus-containers-1.0~beta3.0.7/debian/libplexus-component-annotations-java.links plexus-containers-1.7.1/debian/libplexus-component-annotations-java.links --- plexus-containers-1.0~beta3.0.7/debian/libplexus-component-annotations-java.links 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/debian/libplexus-component-annotations-java.links 2017-11-07 09:59:59.000000000 +0000 @@ -0,0 +1 @@ +/usr/share/java/plexus-component-annotations.jar /usr/share/java/plexus-component-annotations-1.5.jar diff -Nru plexus-containers-1.0~beta3.0.7/debian/libplexus-container-default-java.links plexus-containers-1.7.1/debian/libplexus-container-default-java.links --- plexus-containers-1.0~beta3.0.7/debian/libplexus-container-default-java.links 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/debian/libplexus-container-default-java.links 2017-11-07 10:01:37.000000000 +0000 @@ -0,0 +1 @@ +/usr/share/java/plexus-container-default.jar /usr/share/java/plexus-container-default-1.5.jar diff -Nru plexus-containers-1.0~beta3.0.7/debian/libplexus-container-default-java.poms plexus-containers-1.7.1/debian/libplexus-container-default-java.poms --- plexus-containers-1.0~beta3.0.7/debian/libplexus-container-default-java.poms 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/debian/libplexus-container-default-java.poms 2017-11-07 12:19:11.000000000 +0000 @@ -0,0 +1,32 @@ +# List of POM files for the package +# Format of this file is: +# [option]* +# where option can be: +# --ignore: ignore this POM and its artifact if any +# --ignore-pom: don't install the POM. To use on POM files that are created +# temporarily for certain artifacts such as Javadoc jars. [mh_install, mh_installpoms] +# --no-parent: remove the tag from the POM +# --package=: an alternative package to use when installing this POM +# and its artifact +# --has-package-version: to indicate that the original version of the POM is the same as the upstream part +# of the version for the package. +# --keep-elements=: a list of XML elements to keep in the POM +# during a clean operation with mh_cleanpom or mh_installpom +# --artifact=: path to the build artifact associated with this POM, +# it will be installed when using the command mh_install. [mh_install] +# --java-lib: install the jar into /usr/share/java to comply with Debian +# packaging guidelines +# --usj-name=: name to use when installing the library in /usr/share/java +# --usj-version=: version to use when installing the library in /usr/share/java +# --no-usj-versionless: don't install the versionless link in /usr/share/java +# --dest-jar=: the destination for the real jar. +# It will be installed with mh_install. [mh_install] +# --classifier=: Optional, the classifier for the jar. Empty by default. +# --site-xml=: Optional, the location for site.xml if it needs to be installed. +# Empty by default. [mh_install] +# +pom.xml --no-parent --has-package-version --package=libplexus-container-default-java +plexus-component-annotations/pom.xml --no-parent --has-package-version --package=libplexus-component-annotations-java --relocate=org.codehaus.plexus:plexus-component-annotations:1.5.5 +plexus-component-metadata/pom.xml --has-package-version --package=libplexus-component-metadata-java --relocate=org.codehaus.plexus:plexus-component-metadata:1.5.5 +plexus-component-javadoc/pom.xml --ignore +plexus-container-default/pom.xml --has-package-version --package=libplexus-container-default-java --relocate=org.codehaus.plexus:plexus-container-default:1.5.5 diff -Nru plexus-containers-1.0~beta3.0.7/debian/libplexus-containers-java-doc.doc-base plexus-containers-1.7.1/debian/libplexus-containers-java-doc.doc-base --- plexus-containers-1.0~beta3.0.7/debian/libplexus-containers-java-doc.doc-base 2016-02-27 22:59:35.000000000 +0000 +++ plexus-containers-1.7.1/debian/libplexus-containers-java-doc.doc-base 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -Document: libplexus-containers-java -Title: API Javadoc for plexus-containers -Author: plexus-containers developers -Abstract: This is the API Javadoc provided by the plexus-containers library. -Section: Programming - -Format: HTML -Index: /usr/share/doc/libplexus-containers-java/api/index.html -Files: /usr/share/doc/libplexus-containers-java/api/* diff -Nru plexus-containers-1.0~beta3.0.7/debian/libplexus-containers-java-doc.install plexus-containers-1.7.1/debian/libplexus-containers-java-doc.install --- plexus-containers-1.0~beta3.0.7/debian/libplexus-containers-java-doc.install 2017-07-24 12:22:01.000000000 +0000 +++ plexus-containers-1.7.1/debian/libplexus-containers-java-doc.install 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -target/site/apidocs/* /usr/share/doc/libplexus-containers-java/api/ diff -Nru plexus-containers-1.0~beta3.0.7/debian/libplexus-containers-java.poms plexus-containers-1.7.1/debian/libplexus-containers-java.poms --- plexus-containers-1.0~beta3.0.7/debian/libplexus-containers-java.poms 2017-07-24 12:13:41.000000000 +0000 +++ plexus-containers-1.7.1/debian/libplexus-containers-java.poms 1970-01-01 00:00:00.000000000 +0000 @@ -1,5 +0,0 @@ -pom.xml --no-parent -plexus-container-default/pom.xml -plexus-component-javadoc/pom.xml --ignore -plexus-component-annotations/pom.xml -plexus-component-metadata/pom.xml --ignore diff -Nru plexus-containers-1.0~beta3.0.7/debian/maven.ignoreRules plexus-containers-1.7.1/debian/maven.ignoreRules --- plexus-containers-1.0~beta3.0.7/debian/maven.ignoreRules 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/debian/maven.ignoreRules 2017-11-07 08:41:28.000000000 +0000 @@ -0,0 +1,5 @@ + +org.apache.maven.plugins maven-assembly-plugin * * * * +org.apache.maven.plugins maven-deploy-plugin * * * * +org.apache.maven.plugins maven-release-plugin * * * * +org.apache.maven.plugins maven-site-plugin * * * * diff -Nru plexus-containers-1.0~beta3.0.7/debian/maven.properties plexus-containers-1.7.1/debian/maven.properties --- plexus-containers-1.0~beta3.0.7/debian/maven.properties 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/debian/maven.properties 2017-11-07 08:41:28.000000000 +0000 @@ -0,0 +1,5 @@ +# Include here properties to pass to Maven during the build. +# For example: +# maven.test.skip=true + +maven.test.skip=true diff -Nru plexus-containers-1.0~beta3.0.7/debian/maven.rules plexus-containers-1.7.1/debian/maven.rules --- plexus-containers-1.0~beta3.0.7/debian/maven.rules 2016-02-27 22:59:35.000000000 +0000 +++ plexus-containers-1.7.1/debian/maven.rules 2017-11-07 12:19:23.000000000 +0000 @@ -1,4 +1,27 @@ -s/com.google.code.google-collections/com.google.guava/ s/google-collect/guava/ jar s/.*/debian/ -s/jdom/org.jdom/ jdom jar s/1\..*/debian/ -junit junit jar s/3\..*/3.x/ +# Maven rules - transform Maven dependencies and plugins +# Format of this file is: +# [group] [artifact] [type] [version] [classifier] [scope] +# where each element can be either +# - the exact string, for example org.apache for the group, or 3.1 +# for the version. In this case, the element is simply matched +# and left as it is +# - * (the star character, alone). In this case, anything will +# match and be left as it is. For example, using * on the +# position of the artifact field will match any artifact id +# - a regular expression of the form s/match/replace/ +# in this case, elements that match are transformed using +# the regex rule. +# All elements much match before a rule can be applied +# Example rule: match jar with groupid= junit, artifactid= junit +# and version starting with 3., replacing the version with 3.x +# junit junit jar s/3\\..*/3.x/ +s/jdom/org.jdom/ jdom jar s/.*/debian/ * * +junit junit jar s/.*/4.x/ * * +com.thoughtworks.qdox qdox * s/.*/2.x/ * * +s/com.google.collections/com.google.guava/ s/google-collections/guava/ * s/.*/debian/ * * + +org.codehaus.plexus plexus-utils jar s/.*/2.x/ * * + +org.apache.maven s/maven-project/maven-core/ * s/.*/3.x/ * * +org.apache.maven maven-* * s/.*/3.x/ * * diff -Nru plexus-containers-1.0~beta3.0.7/debian/patches/03-reproducible-metadata.patch plexus-containers-1.7.1/debian/patches/03-reproducible-metadata.patch --- plexus-containers-1.0~beta3.0.7/debian/patches/03-reproducible-metadata.patch 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/debian/patches/03-reproducible-metadata.patch 2017-11-07 08:41:28.000000000 +0000 @@ -0,0 +1,18 @@ +Description: Sort the components to make the metadata reproducible +Author: Emmanuel Bourg +Bug: https://github.com/codehaus-plexus/plexus-containers/pull/7 +--- a/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/DefaultMetadataGenerator.java ++++ b/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/DefaultMetadataGenerator.java +@@ -101,6 +101,12 @@ + } + } + ++ Collections.sort(descriptors, new java.util.Comparator() { ++ public int compare(ComponentDescriptor d1, ComponentDescriptor d2) { ++ return d1.getHumanReadableKey().compareTo(d2.getHumanReadableKey()); ++ } ++ }); ++ + List componentDescriptors = new ArrayList(); + + // diff -Nru plexus-containers-1.0~beta3.0.7/debian/patches/05-qdox-compatibility.patch plexus-containers-1.7.1/debian/patches/05-qdox-compatibility.patch --- plexus-containers-1.0~beta3.0.7/debian/patches/05-qdox-compatibility.patch 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/debian/patches/05-qdox-compatibility.patch 2017-11-07 08:41:28.000000000 +0000 @@ -0,0 +1,14 @@ +Description: Fixes the compatibility with the version of Qdox in Debian +Author: Emmanuel Bourg +Forwarded: no +--- a/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/gleaner/QDoxComponentGleaner.java ++++ b/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/gleaner/QDoxComponentGleaner.java +@@ -244,7 +244,7 @@ + // Remove any Plexus specific interfaces from the calculation + // ---------------------------------------------------------------------- + +- List interfaces = new ArrayList( javaClass.getImplementedInterfaces() ); ++ List interfaces = new ArrayList( javaClass.getInterfaces() ); + + for ( Iterator it = interfaces.iterator(); it.hasNext(); ) + { diff -Nru plexus-containers-1.0~beta3.0.7/debian/patches/google_collections_10.diff plexus-containers-1.7.1/debian/patches/google_collections_10.diff --- plexus-containers-1.0~beta3.0.7/debian/patches/google_collections_10.diff 2016-02-27 22:59:35.000000000 +0000 +++ plexus-containers-1.7.1/debian/patches/google_collections_10.diff 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -Description: Fix FTBFS with libgoogle-collections >= 1.0 -Author: Damien Raude-Morvan -Last-Update: 2011-05-31 -Forwarded: no ---- a/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/DefaultComponentRepository.java -+++ b/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/DefaultComponentRepository.java -@@ -82,7 +82,7 @@ - } - - // Get all valid component descriptors -- Multimap> roleHintIndex = Multimaps.newLinkedHashMultimap(); -+ Multimap> roleHintIndex = com.google.common.collect.LinkedHashMultimap.create(); - for ( ClassRealm realm : realms ) - { - SortedMap>> roleIndex = index.get( realm ); -@@ -189,7 +189,7 @@ - Multimap> roleHintIndex = roleIndex.get( role ); - if ( roleHintIndex == null ) - { -- roleHintIndex = Multimaps.newLinkedHashMultimap(); -+ roleHintIndex = com.google.common.collect.LinkedHashMultimap.create(); - roleIndex.put( role, roleHintIndex ); - } - roleHintIndex.put( componentDescriptor.getRoleHint(), componentDescriptor ); diff -Nru plexus-containers-1.0~beta3.0.7/debian/patches/series plexus-containers-1.7.1/debian/patches/series --- plexus-containers-1.0~beta3.0.7/debian/patches/series 2017-07-24 12:19:31.000000000 +0000 +++ plexus-containers-1.7.1/debian/patches/series 2017-11-07 12:20:40.000000000 +0000 @@ -1 +1,2 @@ -google_collections_10.diff +03-reproducible-metadata.patch +05-qdox-compatibility.patch diff -Nru plexus-containers-1.0~beta3.0.7/debian/rules plexus-containers-1.7.1/debian/rules --- plexus-containers-1.0~beta3.0.7/debian/rules 2017-07-24 11:29:15.000000000 +0000 +++ plexus-containers-1.7.1/debian/rules 2017-11-07 08:41:28.000000000 +0000 @@ -3,13 +3,5 @@ %: dh $@ -override_dh_auto_configure: - mkdir -p plexus-component-metadata - touch plexus-component-metadata/pom.xml - dh_auto_configure - -override_dh_auto_build: - dh_auto_build - get-orig-source: - uscan --download-current-version --force-download --rename + uscan --download-curent-version --force-download --rename diff -Nru plexus-containers-1.0~beta3.0.7/debian/watch plexus-containers-1.7.1/debian/watch --- plexus-containers-1.0~beta3.0.7/debian/watch 2017-07-24 12:27:49.000000000 +0000 +++ plexus-containers-1.7.1/debian/watch 2017-11-07 08:41:28.000000000 +0000 @@ -1,3 +1,2 @@ version=3 -opts=mode=git,repack,compression=xz,uversionmangle=s/-(alpha|beta)-/~$1/ \ -https://github.com/codehaus-plexus/plexus-containers refs/tags/plexus-containers-(1\.0-.*) debian debian/orig-tar.sh +https://github.com/codehaus-plexus/plexus-containers/tags .*/plexus-containers-([\d\.]+).tar.gz diff -Nru plexus-containers-1.0~beta3.0.7/.gitignore plexus-containers-1.7.1/.gitignore --- plexus-containers-1.0~beta3.0.7/.gitignore 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/.gitignore 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,7 @@ +target/ +.project +.classpath +.settings/ +bin +*.iml +.idea diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-annotations/pom.xml plexus-containers-1.7.1/plexus-component-annotations/pom.xml --- plexus-containers-1.0~beta3.0.7/plexus-component-annotations/pom.xml 2009-05-13 15:28:46.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-annotations/pom.xml 2016-08-31 19:01:49.000000000 +0000 @@ -1,13 +1,20 @@ - - + + 4.0.0 + org.codehaus.plexus plexus-containers - 1.0-beta-3.0.7 + 1.7.1 + plexus-component-annotations + Plexus :: Component Annotations + + Plexus Component "Java 5" Annotations, to describe plexus components properties in java sources with + standard annotations instead of javadoc annotations. + diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-annotations/src/main/java/org/codehaus/plexus/component/annotations/Component.java plexus-containers-1.7.1/plexus-component-annotations/src/main/java/org/codehaus/plexus/component/annotations/Component.java --- plexus-containers-1.0~beta3.0.7/plexus-component-annotations/src/main/java/org/codehaus/plexus/component/annotations/Component.java 2007-10-01 04:15:36.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-annotations/src/main/java/org/codehaus/plexus/component/annotations/Component.java 2016-08-31 19:01:49.000000000 +0000 @@ -26,7 +26,8 @@ /** * Marks a class as a Plexus component. * - * @version $Id: Component.java 6920 2007-10-01 04:15:36Z user57 $ + * @since 1.0-alpha-33 + * @version $Id$ */ @Documented @Retention(RUNTIME) @@ -47,7 +48,7 @@ String lifecycleHandler() default ""; String instantiationStrategy() default ""; - + String factory() default ""; String type() default ""; diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-annotations/src/main/java/org/codehaus/plexus/component/annotations/Configuration.java plexus-containers-1.7.1/plexus-component-annotations/src/main/java/org/codehaus/plexus/component/annotations/Configuration.java --- plexus-containers-1.0~beta3.0.7/plexus-component-annotations/src/main/java/org/codehaus/plexus/component/annotations/Configuration.java 2007-09-30 18:40:35.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-annotations/src/main/java/org/codehaus/plexus/component/annotations/Configuration.java 2016-08-31 19:01:49.000000000 +0000 @@ -24,9 +24,10 @@ import java.lang.annotation.Target; /** - * Marks a field as a configuration element with a default falue. + * Marks a field as a configuration element with a default value. * - * @version $Id: Configuration.java 6916 2007-09-30 18:40:35Z user57 $ + * @since 1.0-alpha-33 + * @version $Id$ */ @Documented @Retention(RUNTIME) @@ -35,6 +36,6 @@ public @interface Configuration { String name() default ""; - + String value(); } diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-annotations/src/main/java/org/codehaus/plexus/component/annotations/Requirement.java plexus-containers-1.7.1/plexus-component-annotations/src/main/java/org/codehaus/plexus/component/annotations/Requirement.java --- plexus-containers-1.0~beta3.0.7/plexus-component-annotations/src/main/java/org/codehaus/plexus/component/annotations/Requirement.java 2007-09-30 18:40:35.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-annotations/src/main/java/org/codehaus/plexus/component/annotations/Requirement.java 2016-08-31 19:01:49.000000000 +0000 @@ -27,7 +27,8 @@ /** * Configures a requirement. * - * @version $Id: Requirement.java 6916 2007-09-30 18:40:35Z user57 $ + * @since 1.0-alpha-33 + * @version $Id$ */ @Documented @Retention(RUNTIME) @@ -42,6 +43,9 @@ // // HACK: This is here to support component requirement lists, which can take a list of hints // - + String[] hints() default {}; + + boolean optional() default false; + } diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-annotations/src/site/apt/index.apt plexus-containers-1.7.1/plexus-component-annotations/src/site/apt/index.apt --- plexus-containers-1.0~beta3.0.7/plexus-component-annotations/src/site/apt/index.apt 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-annotations/src/site/apt/index.apt 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,23 @@ + ----- + Overview + ----- + Hervé Boutemy + ----- + 2011-10-02 + ----- + +About Plexus :: Component Annotations + + Plexus Component "Java 5" Annotations, to describe plexus components properties in java sources with standard annotations instead of javadoc annotations. + + 3 "Java 5" annotations are provided to replace javadoc annotations: + +*-----------------------------+----------------------+ +| <> | <> | +*-----------------------------+----------------------+ +| <<<@plexus.component>>> | {{{./apidocs/org/codehaus/plexus/component/annotations/Component.html}<<<@Component>>>}} | +*-----------------------------+----------------------+ +| <<<@plexus.requirement>>> | {{{./apidocs/org/codehaus/plexus/component/annotations/Requirement.html}<<<@Requirement>>>}} | +*-----------------------------+----------------------+ +| <<<@plexus.configuration>>> | {{{./apidocs/org/codehaus/plexus/component/annotations/Configuration.html}<<<@Configuration>>>}} | +*-----------------------------+----------------------+ diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-annotations/src/site/site.xml plexus-containers-1.7.1/plexus-component-annotations/src/site/site.xml --- plexus-containers-1.0~beta3.0.7/plexus-component-annotations/src/site/site.xml 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-annotations/src/site/site.xml 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-javadoc/pom.xml plexus-containers-1.7.1/plexus-component-javadoc/pom.xml --- plexus-containers-1.0~beta3.0.7/plexus-component-javadoc/pom.xml 2009-05-13 15:28:46.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-javadoc/pom.xml 2016-08-31 19:01:49.000000000 +0000 @@ -1,29 +1,27 @@ - + 4.0.0 + org.codehaus.plexus plexus-containers - 1.0-beta-3.0.7 + 1.7.1 + plexus-component-javadoc + Plexus :: Javadoc Taglets + + Plexus Javadoc Taglets to generate additional documentation for plexus components' javadoc from plexus javadoc annotations. + 2007 - - - - maven-javadoc-plugin - - - maven-jxr-plugin - - - + default-tools.jar + (,9) java.vendor Sun Microsystems Inc. @@ -40,7 +38,27 @@ - integration-tests + J7-default-tools.jar + + (,9) + + java.vendor + Oracle Corporation + + + + + com.sun + tools + 1.4.2 + system + ${java.home}/../lib/tools.jar + + + + + + run-its maven.test.skip @@ -50,8 +68,9 @@ + org.apache.maven.plugins maven-invoker-plugin - 1.3 + 2.0.0 true ${project.build.directory}/it diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-javadoc/src/it/basic/pom.xml plexus-containers-1.7.1/plexus-component-javadoc/src/it/basic/pom.xml --- plexus-containers-1.0~beta3.0.7/plexus-component-javadoc/src/it/basic/pom.xml 2008-11-25 09:22:35.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-javadoc/src/it/basic/pom.xml 2016-08-31 19:01:49.000000000 +0000 @@ -16,7 +16,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 2.3 + 2.10.4 ${basedir}/target/site/apidocs true diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-javadoc/src/main/java/org/codehaus/plexus/javadoc/AbstractPlexusTaglet.java plexus-containers-1.7.1/plexus-component-javadoc/src/main/java/org/codehaus/plexus/javadoc/AbstractPlexusTaglet.java --- plexus-containers-1.0~beta3.0.7/plexus-component-javadoc/src/main/java/org/codehaus/plexus/javadoc/AbstractPlexusTaglet.java 2008-04-11 18:12:21.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-javadoc/src/main/java/org/codehaus/plexus/javadoc/AbstractPlexusTaglet.java 2016-08-31 19:01:49.000000000 +0000 @@ -36,7 +36,7 @@ * http://plexus.codehaus.org/guides/developer-guide/appendices/javadoc-tags-reference.html * * @author Vincent Siveton - * @version $Id: AbstractPlexusTaglet.java 7277 2008-04-11 18:12:21Z bentmann $ + * @version $Id$ */ public abstract class AbstractPlexusTaglet implements Taglet @@ -79,12 +79,10 @@ } boolean hasParameters = false; - for ( int i = 0; i < tags.length; i++ ) - { - String tagText = tags[i].text(); - MutableAttributeSet att = getAttributes( tagText ); - if ( att != null ) - { + for (Tag tag : tags) { + String tagText = tag.text(); + MutableAttributeSet att = getAttributes(tagText); + if (att != null) { hasParameters = att.getAttributeCount() > 0; } } diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-javadoc/src/main/java/org/codehaus/plexus/javadoc/PlexusComponentTaglet.java plexus-containers-1.7.1/plexus-component-javadoc/src/main/java/org/codehaus/plexus/javadoc/PlexusComponentTaglet.java --- plexus-containers-1.0~beta3.0.7/plexus-component-javadoc/src/main/java/org/codehaus/plexus/javadoc/PlexusComponentTaglet.java 2008-04-11 18:12:21.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-javadoc/src/main/java/org/codehaus/plexus/javadoc/PlexusComponentTaglet.java 2016-08-31 19:01:49.000000000 +0000 @@ -58,7 +58,7 @@ * http://plexus.codehaus.org/guides/developer-guide/appendices/javadoc-tags-reference.html * * @author Vincent Siveton - * @version $Id: PlexusComponentTaglet.java 7277 2008-04-11 18:12:21Z bentmann $ + * @version $Id$ */ public class PlexusComponentTaglet extends AbstractPlexusTaglet diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-javadoc/src/main/java/org/codehaus/plexus/javadoc/PlexusConfigurationTaglet.java plexus-containers-1.7.1/plexus-component-javadoc/src/main/java/org/codehaus/plexus/javadoc/PlexusConfigurationTaglet.java --- plexus-containers-1.0~beta3.0.7/plexus-component-javadoc/src/main/java/org/codehaus/plexus/javadoc/PlexusConfigurationTaglet.java 2008-04-11 18:12:21.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-javadoc/src/main/java/org/codehaus/plexus/javadoc/PlexusConfigurationTaglet.java 2016-08-31 19:01:49.000000000 +0000 @@ -46,7 +46,7 @@ * http://plexus.codehaus.org/guides/developer-guide/appendices/javadoc-tags-reference.html * * @author Vincent Siveton - * @version $Id: PlexusConfigurationTaglet.java 7277 2008-04-11 18:12:21Z bentmann $ + * @version $Id$ */ public class PlexusConfigurationTaglet extends AbstractPlexusTaglet diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-javadoc/src/main/java/org/codehaus/plexus/javadoc/PlexusRequirementTaglet.java plexus-containers-1.7.1/plexus-component-javadoc/src/main/java/org/codehaus/plexus/javadoc/PlexusRequirementTaglet.java --- plexus-containers-1.0~beta3.0.7/plexus-component-javadoc/src/main/java/org/codehaus/plexus/javadoc/PlexusRequirementTaglet.java 2008-04-11 18:12:21.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-javadoc/src/main/java/org/codehaus/plexus/javadoc/PlexusRequirementTaglet.java 2016-08-31 19:01:49.000000000 +0000 @@ -58,7 +58,7 @@ * http://plexus.codehaus.org/guides/developer-guide/appendices/javadoc-tags-reference.html * * @author Vincent Siveton - * @version $Id: PlexusRequirementTaglet.java 7277 2008-04-11 18:12:21Z bentmann $ + * @version $Id$ */ public class PlexusRequirementTaglet extends AbstractPlexusTaglet diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-javadoc/src/site/site.xml plexus-containers-1.7.1/plexus-component-javadoc/src/site/site.xml --- plexus-containers-1.0~beta3.0.7/plexus-component-javadoc/src/site/site.xml 2008-04-11 18:12:21.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-javadoc/src/site/site.xml 2016-08-31 19:01:49.000000000 +0000 @@ -1,26 +1,12 @@ - - - Plexus - http://plexus.codehaus.org/ - /images/plexus-logo.png - - - - - org.codehaus.plexus - plexus-stylus-skin - 1.0-SNAPSHOT - + - - - - - + diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/pom.xml plexus-containers-1.7.1/plexus-component-metadata/pom.xml --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/pom.xml 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/pom.xml 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,132 @@ + + + + 4.0.0 + + + org.codehaus.plexus + plexus-containers + 1.7.1 + + + plexus-component-metadata + maven-plugin + + Plexus :: Component Metadata + A Maven plugin to generate Plexus descriptors from source tags and class annotations. + + + + org.codehaus.plexus + plexus-container-default + + + org.codehaus.plexus + plexus-component-annotations + + + org.codehaus.plexus + plexus-utils + + + com.thoughtworks.qdox + qdox + + + org.jdom + jdom2 + + + org.apache.maven + maven-plugin-api + + + org.apache.maven + maven-model + + + org.apache.maven + maven-project + + + org.codehaus.plexus + plexus-cli + 1.6 + + + commons-cli + commons-cli + 1.2 + + + org.ow2.asm + asm-all + 5.1 + + + + org.apache.maven.plugin-tools + maven-plugin-annotations + 3.4 + provided + + + + + + + + org.apache.maven.plugins + maven-plugin-plugin + 3.5 + + + + + + + + + org.apache.maven.plugins + maven-plugin-plugin + + + + + + + run-its + + + + org.apache.maven.plugins + maven-invoker-plugin + 2.0.0 + + true + src/it + ${project.build.directory}/it + setup + validate + ${project.build.directory}/local-repo + src/it/settings.xml + + clean + process-classes + + + + + integration-test + + install + run + + + + + + + + + diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/README.txt plexus-containers-1.7.1/plexus-component-metadata/README.txt --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/README.txt 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/README.txt 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,4 @@ +The org.codehaus.plexus.component.repository.cdc package contains some classes copied from the container +before it started using the "default" role hints. + +This can be removed once all supported maven versions are using a container newer than 1.0-alpha-19. diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/it/annotation-processing-test/pom.xml plexus-containers-1.7.1/plexus-component-metadata/src/it/annotation-processing-test/pom.xml --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/it/annotation-processing-test/pom.xml 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/it/annotation-processing-test/pom.xml 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,51 @@ + + 4.0.0 + org.codehaus.plexus + annotation-processing-test + jar + 1.0-SNAPSHOT + annotation-processing-test + http://maven.apache.org + + @project.version@ + + + + junit + junit + 3.8.1 + test + + + org.codehaus.plexus + plexus-component-annotations + ${plexusVersion} + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + 1.6 + 1.6 + + + + org.codehaus.plexus + plexus-component-metadata + ${plexusVersion} + + + + generate-metadata + + + + + + + diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/it/annotation-processing-test/src/main/java/org/codehaus/plexus/AbstractPlexusComponent.java plexus-containers-1.7.1/plexus-component-metadata/src/it/annotation-processing-test/src/main/java/org/codehaus/plexus/AbstractPlexusComponent.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/it/annotation-processing-test/src/main/java/org/codehaus/plexus/AbstractPlexusComponent.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/it/annotation-processing-test/src/main/java/org/codehaus/plexus/AbstractPlexusComponent.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,10 @@ +package org.codehaus.plexus; + +import org.codehaus.plexus.component.annotations.Requirement; + +public abstract class AbstractPlexusComponent + implements PlexusComponent +{ + @Requirement + protected Executor executor; +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/it/annotation-processing-test/src/main/java/org/codehaus/plexus/Executor.java plexus-containers-1.7.1/plexus-component-metadata/src/it/annotation-processing-test/src/main/java/org/codehaus/plexus/Executor.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/it/annotation-processing-test/src/main/java/org/codehaus/plexus/Executor.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/it/annotation-processing-test/src/main/java/org/codehaus/plexus/Executor.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,6 @@ +package org.codehaus.plexus; + +public interface Executor +{ + String execute(); +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/it/annotation-processing-test/src/main/java/org/codehaus/plexus/FastExecutor.java plexus-containers-1.7.1/plexus-component-metadata/src/it/annotation-processing-test/src/main/java/org/codehaus/plexus/FastExecutor.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/it/annotation-processing-test/src/main/java/org/codehaus/plexus/FastExecutor.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/it/annotation-processing-test/src/main/java/org/codehaus/plexus/FastExecutor.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,13 @@ +package org.codehaus.plexus; + +import org.codehaus.plexus.component.annotations.Component; + +@Component(role = Executor.class, hint = "fast") +public class FastExecutor + implements Executor +{ + public String execute() + { + return "fast"; + } +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/it/annotation-processing-test/src/main/java/org/codehaus/plexus/PlexusComponent.java plexus-containers-1.7.1/plexus-component-metadata/src/it/annotation-processing-test/src/main/java/org/codehaus/plexus/PlexusComponent.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/it/annotation-processing-test/src/main/java/org/codehaus/plexus/PlexusComponent.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/it/annotation-processing-test/src/main/java/org/codehaus/plexus/PlexusComponent.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,6 @@ +package org.codehaus.plexus; + +public interface PlexusComponent +{ + String execute(); +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/it/annotation-processing-test/src/main/java/org/codehaus/plexus/SlowExecutor.java plexus-containers-1.7.1/plexus-component-metadata/src/it/annotation-processing-test/src/main/java/org/codehaus/plexus/SlowExecutor.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/it/annotation-processing-test/src/main/java/org/codehaus/plexus/SlowExecutor.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/it/annotation-processing-test/src/main/java/org/codehaus/plexus/SlowExecutor.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,13 @@ +package org.codehaus.plexus; + +import org.codehaus.plexus.component.annotations.Component; + +@Component(role=Executor.class,hint="slow") +public class SlowExecutor + implements Executor +{ + public String execute() + { + return "slow"; + } +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/it/annotation-processing-test/src/main/java/org/codehaus/plexus/SubclassPlexusComponent.java plexus-containers-1.7.1/plexus-component-metadata/src/it/annotation-processing-test/src/main/java/org/codehaus/plexus/SubclassPlexusComponent.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/it/annotation-processing-test/src/main/java/org/codehaus/plexus/SubclassPlexusComponent.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/it/annotation-processing-test/src/main/java/org/codehaus/plexus/SubclassPlexusComponent.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,13 @@ +package org.codehaus.plexus; + +import org.codehaus.plexus.component.annotations.Component; + +@Component(role = Component.class) +public class SubclassPlexusComponent + extends AbstractPlexusComponent +{ + public String execute() + { + return executor.execute(); + } +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/it/annotation-processing-test/src/test/java/org/codehaus/plexus/AppTest.java plexus-containers-1.7.1/plexus-component-metadata/src/it/annotation-processing-test/src/test/java/org/codehaus/plexus/AppTest.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/it/annotation-processing-test/src/test/java/org/codehaus/plexus/AppTest.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/it/annotation-processing-test/src/test/java/org/codehaus/plexus/AppTest.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,38 @@ +package org.codehaus.plexus; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +/** + * Unit test for simple App. + */ +public class AppTest + extends TestCase +{ + /** + * Create the test case + * + * @param testName name of the test case + */ + public AppTest( String testName ) + { + super( testName ); + } + + /** + * @return the suite of tests being tested + */ + public static Test suite() + { + return new TestSuite( AppTest.class ); + } + + /** + * Rigourous Test :-) + */ + public void testApp() + { + assertTrue( true ); + } +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/it/descriptor-1/pom.xml plexus-containers-1.7.1/plexus-component-metadata/src/it/descriptor-1/pom.xml --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/it/descriptor-1/pom.xml 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/it/descriptor-1/pom.xml 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,63 @@ + + + + + + + + 4.0.0 + + org.codehaus.plexus.it.plexus-cdc-anno + descriptor-1 + testing + + + + org.codehaus.plexus + plexus-component-annotations + @project.version@ + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.6 + 1.6 + + + + + org.codehaus.plexus + plexus-component-metadata + @project.version@ + + + + generate-metadata + + + + + + + + + diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/it/descriptor-1/src/main/java/testing/ChildComponent.java plexus-containers-1.7.1/plexus-component-metadata/src/it/descriptor-1/src/main/java/testing/ChildComponent.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/it/descriptor-1/src/main/java/testing/ChildComponent.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/it/descriptor-1/src/main/java/testing/ChildComponent.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2007 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package testing; + +import org.codehaus.plexus.component.annotations.*; + +/** + * ??? + * + * @version $Id$ + */ +@Component(role=ChildComponent.class) +public class ChildComponent +{ +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/it/descriptor-1/src/main/java/testing/MyComponent.java plexus-containers-1.7.1/plexus-component-metadata/src/it/descriptor-1/src/main/java/testing/MyComponent.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/it/descriptor-1/src/main/java/testing/MyComponent.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/it/descriptor-1/src/main/java/testing/MyComponent.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2007 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package testing; + +import org.codehaus.plexus.component.annotations.*; + +/** + * ??? + * + * @version $Id$ + */ +@Component(role=MyComponent.class, hint="foo") +public class MyComponent +{ + @Requirement + private ChildComponent child; + + + @Configuration("bar") + private String foo; +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/it/descriptor-1/validate.groovy plexus-containers-1.7.1/plexus-component-metadata/src/it/descriptor-1/validate.groovy --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/it/descriptor-1/validate.groovy 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/it/descriptor-1/validate.groovy 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2006-2007 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// +// $Id$ +// + +def file = new File(basedir, 'target/classes/META-INF/plexus/components.xml') +assert file.exists() + +def componentSet = new XmlParser().parse(file) + +assert componentSet.components.component.size() == 2 + +return true; diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/it/settings.xml plexus-containers-1.7.1/plexus-component-metadata/src/it/settings.xml --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/it/settings.xml 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/it/settings.xml 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,35 @@ + + + + + it-repo + + true + + + + local.central + @localRepositoryUrl@ + + true + + + true + + + + + + local.central + @localRepositoryUrl@ + + true + + + true + + + + + + diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/component/repository/ComponentDescriptor.java plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/component/repository/ComponentDescriptor.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/component/repository/ComponentDescriptor.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/component/repository/ComponentDescriptor.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,702 @@ +package org.codehaus.plexus.component.repository; + +/* + * Copyright 2001-2006 Codehaus Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import org.codehaus.plexus.PlexusConstants; +import org.codehaus.plexus.classworlds.realm.ClassRealm; +import org.codehaus.plexus.configuration.PlexusConfiguration; + +import java.util.ArrayList; +import java.util.List; +import java.util.Arrays; +import java.util.Collections; + +/** + * Component instantiation description. + * + * @author Jason van Zyl + * @author bob mcwhirter + * @author Michal Maczka + * @version $Id: ComponentDescriptor.java 8155 2009-04-26 01:22:53Z jvanzyl $ + */ +public class ComponentDescriptor +{ + private String alias = null; + + private String role = null; + + private Class roleClass; + + private String roleHint = PlexusConstants.PLEXUS_DEFAULT_HINT; + + private String implementation; + + private Class implementationClass; + + private String version; + + private String componentType; + + private PlexusConfiguration configuration; + + private String instantiationStrategy; + + private String lifecycleHandler; + + private String componentProfile; + + private final List requirements = new ArrayList(); + + private String componentFactory; + + private String componentComposer; + + private String componentConfigurator; + + private String description; + + private ClassRealm realm; + + // ---------------------------------------------------------------------- + // These two fields allow for the specification of an isolated class realm + // and dependencies that might be specified in a component configuration + // setup by a user i.e. this is here to allow isolation for components + // that are not picked up by the discovery mechanism. + // ---------------------------------------------------------------------- + + private boolean isolatedRealm; + + // ---------------------------------------------------------------------- + + private ComponentSetDescriptor componentSetDescriptor; + + private String source; + + // ---------------------------------------------------------------------- + // Instance methods + // ---------------------------------------------------------------------- + + public ComponentDescriptor() + { + } + + public ComponentDescriptor( Class implementationClass, ClassRealm realm ) + { + this.implementationClass = implementationClass; + this.implementation = implementationClass.getName(); + this.realm = realm; + } + + /** + * The location this information came from (descriptor file URI). + */ + public void setSource( String source ) + { + this.source = source; + } + + /** + * The location this information came from (descriptor file URI). + */ + public String getSource() + { + return source; + } + + /** + * Returns a human-friendly key, suitable for display. + * + * @return a human-friendly key + */ + public String getHumanReadableKey() + { + StringBuilder key = new StringBuilder(); + + key.append( "role: '" ).append( role ).append( "'" ); + + key.append( ", implementation: '" ).append( implementation ).append( "'" ); + + if ( roleHint != null ) + { + key.append( ", role hint: '" ).append( roleHint ).append( "'" ); + } + + if ( alias != null ) + { + key.append( ", alias: '" ).append( alias ).append( "'" ); + } + + return key.toString(); + } + + /** + * Returns an alias for this component. An alias as an alternate name other than the normal key. + * + * @return an alias for this component + */ + public String getAlias() + { + return alias; + } + + /** + * Sets the alias for this component. + * + * @param alias alternate name to set + */ + public void setAlias( String alias ) + { + this.alias = alias; + } + + /** + * Returns the role of this component. + * + * @return the role of this component + */ + public String getRole() + { + return role; + } + + public Class getRoleClass() + { + attemptRoleLoad(); + + if (roleClass == null) { + return (Class) Object.class; + } + return (Class)roleClass; + } + + private void attemptRoleLoad() + { + if ( roleClass == null && role != null && realm != null ) + { + try + { + roleClass = (Class) realm.loadClass( role ); + Thread.currentThread(); + } + catch ( Throwable ignored ) + { + Thread.currentThread(); + } + } + } + + + /** + * Sets the role of this component. + * + * @param role this component's role + */ + public void setRole( String role ) + { + this.role = role; + + // reload role class + roleClass = null; + attemptRoleLoad(); + } + + public void setRoleClass( Class roleClass ) + { + this.roleClass = roleClass; + + if (roleClass == null) { + role = null; + } else { + role = roleClass.getName(); + } + } + + /** + * Returns the role-hint of this component. + * + * @return the role-hint of this component + */ + public String getRoleHint() + { + return roleHint; + } + + /** + * Sets the role-hint of this component. Pasing null will set the hint to the default value. + * + * @param roleHint this component's role-hint + */ + public void setRoleHint( String roleHint ) + { + if ( ( roleHint == null ) || roleHint.trim().equals( "" ) ) + { + this.roleHint = PlexusConstants.PLEXUS_DEFAULT_HINT; + } + else + { + this.roleHint = roleHint; + } + } + + /** + * Returns the implementation of this componet. Implementation is a string denoting a FQCN in normal Java + * components, or some other name or file for other component factory implementations. + * + * @return the implementation of this componet's role. + */ + public String getImplementation() + { + return implementation; + } + + /** + * Sets the implementation of this componet. + * + * @param implementation string denoting a FQCN in normal Java components, or some other name or file for other + * component factory implementations + */ + public void setImplementation( String implementation ) + { + this.implementation = implementation; + + // reload implementation class + implementationClass = null; + attemptImplementationLoad(); + } + + /** + * Returns the implementation class of this componet, or null if the implementation class can not be loaded. + * + * @return the implementation of this componet's role. + */ + public Class getImplementationClass() + { + attemptImplementationLoad(); + + if (implementationClass == null) { + return (Class) Object.class; + } + return implementationClass; + } + + private void attemptImplementationLoad() + { + if ( implementationClass == null && implementation != null && realm != null ) + { + try + { + implementationClass = (Class) realm.loadClass( implementation ); + Thread.currentThread(); + } + catch ( Throwable ignored ) + { + Thread.currentThread(); + } + } + } + + public void setImplementationClass( Class implementationClass ) + { + this.implementationClass = implementationClass; + if (implementationClass == null) { + implementation = null; + } else { + implementation = implementationClass.getName(); + } + } + + /** + * Returns a specific point in a components's project timeline. i.e. version 1, or 2.1.4 + * + * @return a specific point in a components's project timeline + */ + public String getVersion() + { + return version; + } + + /** + * Sets the point in a components's project development timeline + * + * @param version the components's version + */ + public void setVersion( String version ) + { + this.version = version; + } + + /** + * Returns the type of this component. + * + * @return the type of this component + */ + public String getComponentType() + { + return componentType; + } + + /** + * Sets this component's type. + * + * @param componentType the type to set + */ + public void setComponentType( String componentType ) + { + this.componentType = componentType; + } + + /** + * Returns the type of instantiation strategy for this component. + * + * @return the type of instantiation strategy for this component + */ + public String getInstantiationStrategy() + { + return instantiationStrategy; + } + + /** + * Returns configuration values defined for this component. + * + * @return configuration values defined for this component + */ + public PlexusConfiguration getConfiguration() + { + return configuration; + } + + /** + * Sets the configuration hierarchy for this component. + * + * @param configuration the configuration hierarchy to set + */ + public void setConfiguration( PlexusConfiguration configuration ) + { + this.configuration = configuration; + } + + /** + * Returns true if this component has a configuration. + * + * @return true if this component has a configuration + */ + public boolean hasConfiguration() + { + return configuration != null; + } + + /** + * Returns the lifecycle-handler for this component. + * + * @return the lifecycle-handler for this component + */ + public String getLifecycleHandler() + { + return lifecycleHandler; + } + + /** + * Sets the lifecycle-handler for this component. For example, "basic", "passive", "bootstrap". + * + * @param lifecycleHandler the lifecycle handler string to set + */ + public void setLifecycleHandler( String lifecycleHandler ) + { + this.lifecycleHandler = lifecycleHandler; + } + + public String getComponentProfile() + { + return componentProfile; + } + + public void setComponentProfile( String componentProfile ) + { + this.componentProfile = componentProfile; + } + + /** + * Add a project requirement to this component. + * + * @param requirement the requirement to add + */ + public void addRequirement( ComponentRequirement requirement ) + { + this.requirements.add( requirement ); + } + + /** + * Add a project requirement to this component. + * + * @param requirement the requirement to add + */ + public void addRequirement( ComponentRequirement... requirement ) + { + this.requirements.addAll( Arrays.asList( requirement )); + } + + /** + * Adds a list of requirements to this component. + * + * @param requirements the requirements to add + */ + public void addRequirements( List requirements ) + { + this.requirements.addAll( requirements ); + } + + /** + * Remove a project requirement from this component. + * + * @param requirement the requirement to remove + */ + public void removeRequirement( ComponentRequirement... requirement ) + { + this.requirements.removeAll( Arrays.asList( requirement )); + } + + /** + * Removes a list of requirements from this component. + * + * @param requirements the requirements to remove + */ + public void removeRequirements( List requirements ) + { + this.requirements.removeAll( requirements ); + } + + /** + * Returns all project requirements of this component. + * + * @return all project requirements of this component + */ + public List getRequirements() + { + return Collections.unmodifiableList( requirements ); + } + + /** + * Returns an id of the factory used to create this component. + * + * @return an id of the factory used to create this component + */ + public String getComponentFactory() + { + return componentFactory; + } + + /** + * Sets the id of the factory to use to create this component. For example, "jruby" will use a JRuby factory. + * + * @param componentFactory + */ + public void setComponentFactory( String componentFactory ) + { + this.componentFactory = componentFactory; + } + + /** + * Returns the ID of the type of composer this component will use. For example, "setter" or "field" for the + * different types of dependency injection. + * + * @return the ID of the type of composer this component will use + */ + public String getComponentComposer() + { + return componentComposer; + } + + /** + * Sets a representation of the composer this component uses. + * + * @param componentComposer string representation of the composer to use + */ + public void setComponentComposer( String componentComposer ) + { + this.componentComposer = componentComposer; + } + + /** + * Return a human-readable description of this component. + * + * @return a human-readable description of this component + */ + public String getDescription() + { + return description; + } + + /** + * Sets a description of this component for users to read. + * + * @param description a human-readable description of this component + */ + public void setDescription( String description ) + { + this.description = description; + } + + /** + * Sets the instantiation-strategy for this component. For example, "container". + * + * @param instantiationStrategy + */ + public void setInstantiationStrategy( String instantiationStrategy ) + { + this.instantiationStrategy = instantiationStrategy; + } + + // ---------------------------------------------------------------------- + // + // ---------------------------------------------------------------------- + + /** + * Returns true if this may be in an isolated classrealm. + * + * @return true if this may be in an isolated classrealm + */ + public boolean isIsolatedRealm() + { + return isolatedRealm; + } + + /** + * Sets the component set descriptor of components and dependencies for this component. + * + * @param componentSetDescriptor the component set descriptor of components and dependencies + */ + public void setComponentSetDescriptor( ComponentSetDescriptor componentSetDescriptor ) + { + this.componentSetDescriptor = componentSetDescriptor; + } + + /** + * Returns the component set descriptor. + * + * @return the component set descriptor + */ + public ComponentSetDescriptor getComponentSetDescriptor() + { + return componentSetDescriptor; + } + + /** + * Sets that this component may be in an isolated classrealm. + * + * @param isolatedRealm true if this component may be in an isolated classrealm + */ + public void setIsolatedRealm( boolean isolatedRealm ) + { + this.isolatedRealm = isolatedRealm; + } + + /** + * Returns the type of component configurator for this project. For example "basic" for normal, or "map-oriented" + * for map oriented components. + * + * @return the type of component configurator for this project + */ + public String getComponentConfigurator() + { + return componentConfigurator; + } + + /** + * Sets the type of component configurator for this project. + * + * @param componentConfigurator + */ + public void setComponentConfigurator( String componentConfigurator ) + { + this.componentConfigurator = componentConfigurator; + } + + /** + * The ClassRealm that this component lives under. + * + * @return ClassRealm that this component lives under + */ + public ClassRealm getRealm() + { + return realm; + } + + /** + * Set the ClassRealm that this component lives under. + * + * @param realm the ClassRealm that this component lives under + */ + public void setRealm( ClassRealm realm ) + { + this.realm = realm; + + // reload implementation class + implementationClass = null; + attemptImplementationLoad(); + + // reload role class + roleClass = null; + attemptRoleLoad(); + } + + // Component identity established here! + public boolean equals( Object other ) + { + if ( !( other instanceof ComponentDescriptor ) ) + { + return false; + } + else + { + ComponentDescriptor otherDescriptor = (ComponentDescriptor) other; + + boolean isEqual = true; + + String role = getRole(); + String otherRole = otherDescriptor.getRole(); + + isEqual = isEqual && ( ( role.equals( otherRole ) ) || role.equals( otherRole ) ); + + String roleHint = getRoleHint(); + String otherRoleHint = otherDescriptor.getRoleHint(); + + isEqual = isEqual && ( ( roleHint.equals( otherRoleHint ) ) || roleHint.equals( otherRoleHint ) ); + + return isEqual; + } + } + + public String toString() + { + return getClass().getName() + " [role: '" + getRole() + "', hint: '" + getRoleHint() + "', realm: " + + ( realm == null ? "NULL" : "'" + realm + "'" ) + "]"; + } + + public int hashCode() + { + int result = getRole().hashCode() + 1; + + String hint = getRoleHint(); + + if ( hint != null ) + { + result += hint.hashCode(); + } + + return result; + } +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/component/repository/ComponentRequirement.java plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/component/repository/ComponentRequirement.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/component/repository/ComponentRequirement.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/component/repository/ComponentRequirement.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,187 @@ +package org.codehaus.plexus.component.repository; + +/* + * Copyright 2001-2006 Codehaus Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * This represents a component this is required by another component. + * + * @author Michal Maczka + * @version $Id: ComponentRequirement.java 8525 2009-11-06 15:23:51Z bentmann $ + */ +public class ComponentRequirement +{ + private String role; + + private String roleHint = ""; + + private String fieldName; + + private String fieldMappingType; + + private boolean optional; + + /** + * Returns the field name that this component requirement will inject. + * @return the field name that this component requirement will inject + */ + public String getFieldName() + { + return fieldName; + } + + /** + * Sets the name of the field that will be populated by the required + * component. + * @param fieldName the name of the field to be populated + */ + public void setFieldName( String fieldName ) + { + this.fieldName = fieldName; + } + + /** + * Returns the role of the required component. + * @return the role of the required component + */ + public String getRole() + { + return role; + } + + /** + * Sets the role of the require component. + * @param role the required component's role + */ + public void setRole( String role ) + { + this.role = role; + } + + /** + * Returns the role-hint of the required component. + * @return the role-hint of the required component + */ + public String getRoleHint() + { + return roleHint; + } + + /** + * Sets the role-hint of the require component. + * Passing null or an empty string will match any available implementation. + * @param roleHint the required component's role-hint + */ + public void setRoleHint( String roleHint ) + { + this.roleHint = ( roleHint != null ) ? roleHint : ""; + } + + /** + * Returns the type of the field this component requirement will inject. + * @return the type of the field this component requirement will inject + */ + public String getFieldMappingType() + { + return fieldMappingType; + } + + /** + * Sets the type of the field that will be populated by the required + * component. + * @param fieldType the type of the field to be populated + */ + public void setFieldMappingType( String fieldType ) + { + this.fieldMappingType = fieldType; + } + + /** + * Whether this component requirement is optional and needs not be satisfied + * + * @return {@code true} if the requested component may be missing, {@code false} if the component is mandatory. + * @since 1.3.0 + */ + public boolean isOptional() + { + return optional; + } + + /** + * Controls whether a failure to satisfy this requirement can be tolerated by host component or whether construction + * of the host component should also fail. + * + * @param optional {@code true} if the requested component may be missing, {@code false} if the component is + * mandatory. + * @since 1.3.0 + */ + public void setOptional( boolean optional ) + { + this.optional = optional; + } + + public String toString() + { + return "ComponentRequirement{" + + "role='" + getRole() + "'" + ", " + + "roleHint='" + getRoleHint() + "', " + + "fieldName='" + getFieldName() + "'" + + "}"; + } + + /** + * Returns a human-friendly key, suitable for display. + * @return a human-friendly key + */ + public String getHumanReadableKey() + { + StringBuilder key = new StringBuilder(); + + key.append( "role: '").append( getRole() ).append( "'" ); + + if ( getRoleHint() != null ) + { + key.append( ", role-hint: '" ).append( getRoleHint() ).append( "'. " ); + } + + if ( getFieldName() != null ) + { + key.append( ", field name: '" ).append( getFieldName() ).append( "' " ); + } + + return key.toString(); + } + + public boolean equals( Object other ) + { + if ( other instanceof ComponentRequirement ) + { + String myId = role + ":" + roleHint; + + ComponentRequirement req = (ComponentRequirement) other; + String otherId = req.role + ":" + req.roleHint; + + return myId.equals( otherId ); + } + + return false; + } + + public int hashCode() + { + return ( role + ":" + roleHint ).hashCode(); + } +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/component/repository/ComponentRequirementList.java plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/component/repository/ComponentRequirementList.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/component/repository/ComponentRequirementList.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/component/repository/ComponentRequirementList.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,43 @@ +package org.codehaus.plexus.component.repository; + +import java.util.List; + +/** + * Created by IntelliJ IDEA. + * + * @author Andrew Williams + * @version $Id: ComponentRequirementList.java 7828 2008-11-14 22:07:56Z dain $ + * @since 1.0 + */ +public class ComponentRequirementList + extends ComponentRequirement +{ + private List roleHints; + + public List getRoleHints() + { + return roleHints; + } + + public void setRoleHints(List roleHints) + { + this.roleHints = roleHints; + } + + public String getRoleHint() + { + StringBuilder buffer = new StringBuilder(); + for ( String hint : roleHints ) + { + if (buffer.length() > 0) + { + buffer.append(","); + } + + buffer.append(hint); + + } + + return buffer.toString(); + } +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/component/repository/ComponentSetDescriptor.java plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/component/repository/ComponentSetDescriptor.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/component/repository/ComponentSetDescriptor.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/component/repository/ComponentSetDescriptor.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,164 @@ +package org.codehaus.plexus.component.repository; + +/* + * Copyright 2001-2006 Codehaus Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import java.util.ArrayList; +import java.util.List; + +/** + * Contains a set of ComponentDescriptors and the set's dependencies. + * + * @author Jason van Zyl + * @author Trygve Laugstøl + * @version $Id: ComponentSetDescriptor.java 7828 2008-11-14 22:07:56Z dain $ + */ +public class ComponentSetDescriptor +{ + // This field is not currently used in Maven, or Plexus + private String id; + + /** The source location of this component source descriptor */ + private String source; + + /** Flag to indicate whether this component should be loaded in a realm/classloader of its own. */ + private boolean isolatedRealm; + + /** The component descriptors that can be found within this component set descriptor. */ + private final List> components = new ArrayList>(); + + /** The dependencies that are required by the set of components found in this component set descriptor. */ + private final List dependencies = new ArrayList(); + + /** + * Returns a list of components in this set. + * @return a list of components + */ + public List> getComponents() + { + return components; + } + + /** + * Add a new ComponentDescriptor to this set. + * @param cd the ComponentDescriptor to add + */ + public void addComponentDescriptor( ComponentDescriptor cd ) + { + components.add( cd ); + } + + /** + * Sets a List of components as this set's contents. + * @param components the List of components to set + */ + public void setComponents( List> components ) + { + this.components.clear(); + this.components.addAll(components); + } + + /** + * Returns a List of dependencies of this set of components. + * @return a List of dependencies of this set of components + */ + public List getDependencies() + { + return dependencies; + } + + /** + * Add a depenency to this set's contents. + * @param cd the ComponentDependency to add + */ + public void addDependency( ComponentDependency cd ) + { + dependencies.add( cd ); + } + + /** + * Sets a List of dependencies as this set's component dependencies. + * @param dependencies the List of components to set + */ + public void setDependencies( List dependencies ) + { + this.dependencies.clear(); + this.dependencies.addAll(dependencies); + } + + /** + * Sets that this set of components may be in an isolated classrealm. + * @param isolatedRealm true if this set of components may be in an + * isolated classrealm + */ + public void setIsolatedRealm( boolean isolatedRealm ) + { + this.isolatedRealm = isolatedRealm; + } + + /** + * Returns true if this set may be in an isolated classrealm. + * @return true if this set may be in an isolated classrealm + */ + public boolean isIsolatedRealm() + { + return isolatedRealm; + } + + /** + * Returns the identifier of this set. + * @return the identifier of this set + */ + public String getId() + { + return id; + } + + /** + * Sets the identifier of this set. + * @param id the identifier to set + */ + public void setId( String id ) + { + this.id = id; + } + + public String toString() + { + StringBuilder sb = new StringBuilder(); + + sb.append( "Component Descriptor: " ); + + for ( ComponentDescriptor cd : components ) + { + sb.append( cd.getHumanReadableKey() ).append( "\n" ); + } + + sb.append( "---" ); + + return sb.toString(); + } + + public String getSource() + { + return source; + } + + public void setSource( String source ) + { + this.source = source; + } +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/component/repository/README.txt plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/component/repository/README.txt --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/component/repository/README.txt 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/component/repository/README.txt 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,3 @@ +This package contains some classes copied from the container before it started using the "default" role hints. + +This can be removed once all supported maven versions are using a container newer than 1.0-alpha-19. \ No newline at end of file diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/maven/plugin/AbstractDescriptorMojo.java plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/maven/plugin/AbstractDescriptorMojo.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/maven/plugin/AbstractDescriptorMojo.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/maven/plugin/AbstractDescriptorMojo.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,74 @@ +package org.codehaus.plexus.maven.plugin; + +import java.util.List; + +/* + * The MIT License + * + * Copyright (c) 2004-2006, The Codehaus + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugins.annotations.Component; +import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.project.MavenProject; +import org.apache.maven.project.MavenProjectHelper; +import org.codehaus.plexus.metadata.MetadataGenerator; + +/** + * Base class for Plexus Metadata mojos. + * + * @author Jason van Zyl + */ +public abstract class AbstractDescriptorMojo + extends AbstractMojo +{ + + /** + * Current project + */ + @Parameter( defaultValue = "${project}", required = true, readonly = true ) + protected MavenProject mavenProject; + + /** + * The file encoding of the source files. + * + * @parameter default-value="${project.build.sourceEncoding}" + */ + @Parameter( defaultValue = "${project.build.sourceEncoding}" ) + protected String sourceEncoding; + + /** + * The extractors to use. By default all available extractors will be used. + *

+ * Known extractors: + *

    + *
  • source
  • + *
  • class
  • + *
+ *

+ */ + @Parameter + protected List extractors; + + @Component + protected MavenProjectHelper mavenProjectHelper; + + @Component + protected MetadataGenerator metadataGenerator; +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/maven/plugin/PlexusDescriptorMojo.java plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/maven/plugin/PlexusDescriptorMojo.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/maven/plugin/PlexusDescriptorMojo.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/maven/plugin/PlexusDescriptorMojo.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,86 @@ +package org.codehaus.plexus.maven.plugin; + +/* + * Copyright (c) 2004-2005, Codehaus.org + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +import java.io.File; + +import org.apache.maven.plugin.MojoExecutionException; +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.codehaus.plexus.metadata.MetadataGenerationRequest; + +/** + * Generates a Plexus components.xml component descriptor file from source (javadoc) or + * class annotations. + * + * @author Jason van Zyl + * @author Trygve Laugstøl + * @version $Id$ + */ +@Mojo( name = "generate-metadata", defaultPhase = LifecyclePhase.PROCESS_CLASSES, requiresDependencyResolution = ResolutionScope.COMPILE ) +public class PlexusDescriptorMojo + extends AbstractDescriptorMojo +{ + /** + * The output location for the generated descriptor. + */ + @Parameter( defaultValue = "${project.build.outputDirectory}/META-INF/plexus/components.xml", required = true ) + protected File generatedMetadata; + + /** + * The location of manually crafted component descriptors. The contents of the descriptor files in this directory is + * merged with the information extracted from the project's sources/classes. + */ + @Parameter( defaultValue = "${basedir}/src/main/resources/META-INF/plexus", required = true ) + protected File staticMetadataDirectory; + + /** + * The output location for the intermediary descriptor. This descriptors contains only the information extracted + * from the project's sources/classes. + */ + @Parameter( defaultValue = "${project.build.directory}/components.xml", required = true ) + protected File intermediaryMetadata; + + public void execute() + throws MojoExecutionException + { + MetadataGenerationRequest request = new MetadataGenerationRequest(); + + try + { + request.classpath = mavenProject.getCompileClasspathElements(); + request.classesDirectory = new File( mavenProject.getBuild().getOutputDirectory() ); + request.sourceDirectories = mavenProject.getCompileSourceRoots(); + request.sourceEncoding = sourceEncoding; + request.componentDescriptorDirectory = staticMetadataDirectory; + request.intermediaryFile = intermediaryMetadata; + request.outputFile = generatedMetadata; + request.extractors = extractors; + + metadataGenerator.generateDescriptor( request ); + } + catch ( Exception e ) + { + throw new MojoExecutionException( "Error generating metadata: ", e ); + } + } +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/maven/plugin/PlexusMergeMojo.java plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/maven/plugin/PlexusMergeMojo.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/maven/plugin/PlexusMergeMojo.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/maven/plugin/PlexusMergeMojo.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,86 @@ +package org.codehaus.plexus.maven.plugin; + +/* + * Copyright (c) 2004-2006, Codehaus.org + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugins.annotations.Component; +import org.apache.maven.plugins.annotations.LifecyclePhase; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; +import org.codehaus.plexus.metadata.merge.Merger; + +/** + * Merges a set of Plexus descriptors into one descriptor file. + * + * @author Jason van Zyl + * @author Trygve Laugstøl + * @version $Id$ + */ +@Mojo( name = "merge-metadata", defaultPhase = LifecyclePhase.PROCESS_CLASSES ) +public class PlexusMergeMojo + extends AbstractMojo +{ + /** + * The destination for the merged descriptor. + */ + @Parameter( defaultValue = "${project.build.outputDirectory}/META-INF/plexus/components.xml", required = true ) + private File output; + + /** + * The paths of the input descriptors to merge. + */ + @Parameter + private File[] descriptors; + + @Component( hint = "componentsXml" ) + private Merger merger; + + public void execute() + throws MojoExecutionException + { + List files = new ArrayList(); + + if ( descriptors != null ) + { + files.addAll( Arrays.asList( descriptors ) ); + } + + if ( files.isEmpty() ) + { + return; + } + + try + { + merger.mergeDescriptors( output, files ); + } + catch ( IOException e ) + { + throw new MojoExecutionException( "Error while executing component descritor creator.", e ); + } + } +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/maven/plugin/PlexusTestDescriptorMojo.java plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/maven/plugin/PlexusTestDescriptorMojo.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/maven/plugin/PlexusTestDescriptorMojo.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/maven/plugin/PlexusTestDescriptorMojo.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,86 @@ +package org.codehaus.plexus.maven.plugin; + +/* + * Copyright (c) 2004-2005, Codehaus.org + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +import java.io.File; + +import org.apache.maven.plugin.MojoExecutionException; +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.codehaus.plexus.metadata.MetadataGenerationRequest; + +/** + * Generates a Plexus components.xml component descriptor file from test source (javadoc) + * or test class annotations. + * + * @author Jason van Zyl + * @author Trygve Laugstøl + * @version $Id$ + */ +@Mojo( name = "generate-test-metadata", defaultPhase = LifecyclePhase.PROCESS_TEST_CLASSES, requiresDependencyResolution = ResolutionScope.TEST ) +public class PlexusTestDescriptorMojo + extends AbstractDescriptorMojo +{ + /** + * The output location for the generated descriptor. + */ + @Parameter( defaultValue = "${project.build.testOutputDirectory}/META-INF/plexus/components.xml", required = true ) + protected File testGeneratedMetadata; + + /** + * The location of manually crafted component descriptors. The contents of the descriptor files in this directory is + * merged with the information extracted from the project's sources/classes. + */ + @Parameter( defaultValue = "${basedir}/src/test/resources/META-INF/plexus", required = true ) + protected File testStaticMetadataDirectory; + + /** + * The output location for the intermediary descriptor. This descriptors contains only the information extracted + * from the project's sources/classes. + */ + @Parameter( defaultValue = "${project.build.directory}/test-components.xml", required = true ) + protected File testIntermediaryMetadata; + + public void execute() + throws MojoExecutionException + { + MetadataGenerationRequest request = new MetadataGenerationRequest(); + + try + { + request.classpath = mavenProject.getTestClasspathElements(); + request.classesDirectory = new File( mavenProject.getBuild().getTestOutputDirectory() ); + request.sourceDirectories = mavenProject.getTestCompileSourceRoots(); + request.sourceEncoding = sourceEncoding; + request.componentDescriptorDirectory = testStaticMetadataDirectory; + request.intermediaryFile = testIntermediaryMetadata; + request.outputFile = testGeneratedMetadata; + request.extractors = extractors; + + metadataGenerator.generateDescriptor( request ); + } + catch ( Exception e ) + { + throw new MojoExecutionException( "Error generating test metadata: ", e ); + } + } +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/ann/AnnClass.java plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/ann/AnnClass.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/ann/AnnClass.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/ann/AnnClass.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,134 @@ +/* + * Copyright (C) 2008 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.codehaus.plexus.metadata.ann; + +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Set; + +import org.objectweb.asm.Type; + +/** + * @author Eugene Kuleshov + */ +public class AnnClass { + + private int access; + private String name; + private String superName; + private String[] interfaces; + + private Map anns = new LinkedHashMap(); + private Map fields = new LinkedHashMap(); + private Map methods = new LinkedHashMap(); + private ClassLoader cl; + + // setters + + public AnnClass(ClassLoader cl) { + this.cl = cl; + } + + public void setName(String name) { + this.name = name; + } + + public void setAccess(int access) { + this.access = access; + } + + public void setSuperName(String superName) { + this.superName = superName; + } + + public void setInterfaces(String[] interfaces) { + this.interfaces = interfaces; + } + + public void addAnn(Ann ann) { + anns.put(ann.getDesc(), ann); + } + + public void addField(AnnField field) { + fields.put(field.getName(), field); + } + + public void addMethod(AnnMethod method) { + methods.put(method.getName() + method.getDesc(), method); + } + + // getters + + public ClassLoader getClassLoader() { + return cl; + } + + public int getAccess() { + return access; + } + + public String getName() { + return name; + } + + public String getSuperName() { + return superName; + } + + public String[] getInterfaces() { + return interfaces; + } + + public Map getAnns() { + return anns; + } + + public Map getFields() { + return fields; + } + + public Map getMethods() { + return methods; + } + + public Set getFieldNames() { + return fields.keySet(); + } + + public Set getMethodKeys() { + return methods.keySet(); + } + + // conversion to java.lang.Annotation + + public T getAnnotation(Class c) { + Ann ann = anns.get(Type.getDescriptor(c)); + return ann == null ? null : ann.getAnnotation(c, cl); + } + + public T getFieldAnnotation(String fieldName, Class c) { + AnnField field = fields.get(fieldName); + return field==null ? null : field.getAnnotation(c); + } + + public T getMethodAnnotation(String methodKey, Class c) { + AnnMethod method = methods.get(methodKey); + return method==null ? null : method.getAnnotation(c); + } + +} + diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/ann/AnnEnum.java plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/ann/AnnEnum.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/ann/AnnEnum.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/ann/AnnEnum.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2008 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.codehaus.plexus.metadata.ann; + +import org.objectweb.asm.Type; + +/** + * @author Eugene Kuleshov + */ +public class AnnEnum { + + private final String desc; + private final String value; + + public AnnEnum(String desc, String value) { + this.desc = desc; + this.value = value; + } + + public String getDesc() { + return desc; + } + + public String getValue() { + return value; + } + + public String getType() { + return Type.getType(desc).getClassName(); + } + + public int hashCode() { + return 31 * (31 + desc.hashCode()) + value.hashCode(); + } + + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + AnnEnum other = (AnnEnum) obj; + if (desc == null) { + if (other.desc != null) { + return false; + } + } else if (!desc.equals(other.desc)) { + return false; + } + if (value == null) { + if (other.value != null) { + return false; + } + } else if (!value.equals(other.value)) { + return false; + } + return true; + } + +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/ann/AnnField.java plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/ann/AnnField.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/ann/AnnField.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/ann/AnnField.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,72 @@ +/* + * Copyright (C) 2008 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.codehaus.plexus.metadata.ann; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.objectweb.asm.Type; + +/** + * @author Eugene Kuleshov + */ +public class AnnField { + + private final AnnClass owner; + private final int access; + private final String name; + private final String desc; + private Map anns = new LinkedHashMap(); + + public AnnField(AnnClass owner, int access, String name, String desc) { + this.owner = owner; + this.access = access; + this.desc = desc; + this.name = name; + } + + public int getAccess() { + return access; + } + + public String getName() { + return name; + } + + public String getDesc() { + return desc; + } + + public Map getAnns() { + return anns; + } + + public String getType() { + return Type.getType(desc).getClassName(); + } + + public void addAnn(Ann ann) { + anns.put(ann.getDesc(), ann); + } + + public T getAnnotation(Class c) { + Ann ann = anns.get(Type.getDescriptor(c)); + return ann == null ? null : ann.getAnnotation(c, owner.getClassLoader()); + } + +} + diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/ann/AnnInvocationHandler.java plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/ann/AnnInvocationHandler.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/ann/AnnInvocationHandler.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/ann/AnnInvocationHandler.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2008 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.codehaus.plexus.metadata.ann; + +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; +import java.net.URL; +import java.net.URLClassLoader; +import java.util.Arrays; +import java.util.Map; + +import org.objectweb.asm.Type; + +/** + * @author Eugene Kuleshov + */ +public class AnnInvocationHandler implements InvocationHandler { + private final Ann ann; + private final ClassLoader cl; + private final Class c; + + public AnnInvocationHandler(Ann ann, ClassLoader cl, Class c) { + this.ann = ann; + this.cl = cl; + this.c = c; + } + + public Object invoke(Object proxy, Method m, Object[] args) throws Throwable { + String name = m.getName(); + + if("toString".equals(name)) { + StringBuilder sb = new StringBuilder(ann.getType()); + sb.append("["); + String sep = ""; + for(Map.Entry e : ann.getParams().entrySet()) { + // TODO conversion for class, array, enum, and annotation types + sb.append(sep).append(e.getKey()).append("=").append(e.getValue()); + sep = "; "; + } + sb.append("]"); + return sb.toString(); + } + + Object value = ann.getParams().get(name); + if(value!=null) { + if(value instanceof Type) { + String className = ((Type) value).getClassName(); + try { + return Class.forName(className, false, cl); + } catch(ClassNotFoundException ex) { + if(cl instanceof URLClassLoader) { + URL[] urls = ((URLClassLoader) cl).getURLs(); + throw new RuntimeException("Unable to load class " + className + " from " + Arrays.toString(urls), ex); + } + throw new RuntimeException("Unable to load class " + className + " from " + cl, ex); + } + } + // TODO conversion for class, array, enum, and annotation types + return value; + } else { + Method am = c.getDeclaredMethod(m.getName(), m.getParameterTypes()); + return am.getDefaultValue(); + } + } + +} + diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/ann/Ann.java plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/ann/Ann.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/ann/Ann.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/ann/Ann.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2008 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.codehaus.plexus.metadata.ann; + +import java.lang.reflect.Proxy; +import java.util.LinkedHashMap; +import java.util.Map; + +import org.objectweb.asm.Type; + +/** + * @author Eugene Kuleshov + */ +public class Ann { + + private String desc; + private Map params = new LinkedHashMap(); + + public Ann(String desc) { + this.desc = desc; + } + + public void addParam(String name, Object value) { + params.put(name, value); + } + + public String getDesc() { + return desc; + } + + public String getType() { + return Type.getType(desc).getClassName(); + } + + public Map getParams() { + return params; + } + + @SuppressWarnings("unchecked") + public T getAnnotation(Class c, ClassLoader cl) { + return (T) Proxy.newProxyInstance(Ann.class.getClassLoader(), new Class[] { c }, // + new AnnInvocationHandler(this, cl, c)); + } + +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/ann/AnnMethod.java plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/ann/AnnMethod.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/ann/AnnMethod.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/ann/AnnMethod.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,92 @@ +/* + * Copyright (C) 2008 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.codehaus.plexus.metadata.ann; + +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; + +import org.objectweb.asm.Type; + +/** + * @author Eugene Kuleshov + */ +public class AnnMethod { + + private final AnnClass owner; + private final int access; + private final String name; + private final String desc; + private Map anns = new LinkedHashMap(); + private Map> paramAnns = new HashMap>(); + + public AnnMethod(AnnClass owner, int access, String name, String desc) { + this.owner = owner; + this.access = access; + this.name = name; + this.desc = desc; + } + + public int getAccess() { + return access; + } + + public String getName() { + return name; + } + + public String getDesc() { + return desc; + } + + public Map getAnns() { + return anns; + } + + public Map> getParamAnns() { + return paramAnns; + } + + public void addAnn(Ann ann) { + anns.put(ann.getDesc(), ann); + } + + public void addParamAnn(int parameter, Ann ann) { + Map anns = paramAnns.get(parameter); + if(anns==null) { + anns = new LinkedHashMap(); + paramAnns.put(parameter, anns); + } + anns.put(ann.getDesc(), ann); + } + + public T getAnnotation(Class c) { + Ann ann = anns.get(Type.getDescriptor(c)); + return ann == null ? null : ann.getAnnotation(c, owner.getClassLoader()); + } + + public T getParameterAnnotation(int parameter, Class c) { + Map anns = paramAnns.get(parameter); + if (anns == null) { + return null; + } + Ann ann = anns.get(Type.getDescriptor(c)); + return ann == null ? null : ann.getAnnotation(c, owner.getClassLoader()); + } + +} + diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/ann/AnnReader.java plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/ann/AnnReader.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/ann/AnnReader.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/ann/AnnReader.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,150 @@ +/* + * Copyright (C) 2008 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.codehaus.plexus.metadata.ann; + +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; + +import org.objectweb.asm.AnnotationVisitor; +import org.objectweb.asm.ClassReader; +import org.objectweb.asm.ClassVisitor; +import org.objectweb.asm.FieldVisitor; +import org.objectweb.asm.MethodVisitor; +import org.objectweb.asm.Opcodes; + +/** + * @author Eugene Kuleshov + */ +public class AnnReader extends ClassVisitor { + + private final AnnClass annClass; + + private AnnReader(AnnClass annClass) { + super(Opcodes.ASM5); + this.annClass = annClass; + } + + public static AnnClass read(InputStream is, ClassLoader cl) throws IOException { + AnnClass annClass = new AnnClass(cl); + AnnReader cv = new AnnReader(annClass); + ClassReader r = new ClassReader(is); + r.accept(cv, ClassReader.SKIP_FRAMES | ClassReader.SKIP_CODE); + return annClass; + } + + public void visit(int version, int access, String name, String signature, + String superName, String[] interfaces) { + annClass.setName(name); + annClass.setAccess(access); + annClass.setSuperName(superName); + annClass.setInterfaces(interfaces); + } + + public AnnotationVisitor visitAnnotation(final String desc, boolean visible) { + Ann ann = new Ann(desc); + annClass.addAnn(ann); + return new AnnAnnReader(ann); + } + + public FieldVisitor visitField(int access, final String name, final String desc, String signature, Object value) { + final AnnField field = new AnnField(annClass, access, name, desc); + annClass.addField(field); + return new FieldVisitor(Opcodes.ASM5) { + + public AnnotationVisitor visitAnnotation(String desc, boolean visible) { + Ann ann = new Ann(desc); + field.addAnn(ann); + return new AnnAnnReader(ann); + } + }; + } + + public MethodVisitor visitMethod(int access, final String mname, final String mdesc, + String signature, String[] exceptions) { + final AnnMethod method = new AnnMethod(annClass, access, mname, mdesc); + annClass.addMethod(method); + + return new MethodVisitor(Opcodes.ASM5) { + + public AnnotationVisitor visitAnnotation(String desc, boolean visible) { + Ann ann = new Ann(desc); + method.addAnn(ann); + return new AnnAnnReader(ann); + } + + public AnnotationVisitor visitParameterAnnotation(int parameter, String desc, boolean visible) { + Ann ann = new Ann(desc); + method.addParamAnn(parameter, ann); + return new AnnAnnReader(ann); + } + }; + } + + static class AnnAnnReader extends AnnotationVisitor { + private Ann ann; + + public AnnAnnReader(Ann ann) { + super(Opcodes.ASM5); + this.ann = ann; + } + + public void visit(String name, Object value) { + ann.addParam(name, value); + } + + public void visitEnum(String name, String desc, String value) { + ann.addParam(name, new AnnEnum(desc, value)); + } + + public AnnotationVisitor visitAnnotation(String name, String desc) { + Ann ann = new Ann(desc); + this.ann.addParam(name, ann); + return new AnnAnnReader(ann); + } + + public AnnotationVisitor visitArray(String name) { + return new AnnAnnArrayReader(ann, name); + } + } + + static class AnnAnnArrayReader extends AnnotationVisitor { + + private Ann ann; + + private String name; + + // TODO good enough for now, but does not cover general case + private ArrayList array = new ArrayList(); + + public AnnAnnArrayReader(Ann ann, String name) { + super(Opcodes.ASM5); + this.ann = ann; + this.name = name; + } + + public void visit(String name, Object value) { + if(value instanceof String) { + array.add((String) value); + } + } + + public void visitEnd() { + ann.addParam(name, array.toArray(new String[array.size()])); + } + } +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/ClassComponentDescriptorExtractor.java plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/ClassComponentDescriptorExtractor.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/ClassComponentDescriptorExtractor.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/ClassComponentDescriptorExtractor.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,165 @@ +/* + * Copyright (C) 2007 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ + +package org.codehaus.plexus.metadata; + +import java.io.File; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLClassLoader; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +import org.apache.maven.plugin.MojoExecutionException; +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.component.repository.ComponentDescriptor; +import org.codehaus.plexus.metadata.gleaner.AnnotationComponentGleaner; +import org.codehaus.plexus.metadata.gleaner.ClassComponentGleaner; +import org.codehaus.plexus.util.DirectoryScanner; + +/** + * Extracts {@link ComponentDescriptor} from class files. + * + * @version $Id$ + */ +@Component( role = ComponentDescriptorExtractor.class, hint = "class" ) +public class ClassComponentDescriptorExtractor + extends ComponentDescriptorExtractorSupport +{ + private ClassComponentGleaner gleaner; + + public ClassComponentDescriptorExtractor( final ClassComponentGleaner gleaner ) + { + this.gleaner = gleaner; + } + + public ClassComponentDescriptorExtractor() + { + this.gleaner = new AnnotationComponentGleaner(); + } + + public List> extract( MetadataGenerationRequest configuration, final ComponentDescriptor[] roleDefaults ) + throws Exception + { + // We don't have a reasonable default to use, so just puke up + if ( gleaner == null ) + { + throw new IllegalStateException( "Gleaner is not bound" ); + } + + if ( !configuration.classesDirectory.exists() ) + { + return Collections.emptyList(); + } + + if ( configuration.useContextClassLoader ) + { + return extract( configuration.classesDirectory, Thread.currentThread().getContextClassLoader(), getDefaultsByRole( roleDefaults ) ); + } + else + { + ClassLoader prev = Thread.currentThread().getContextClassLoader(); + ClassLoader cl = createClassLoader( configuration.classpath ); + + Thread.currentThread().setContextClassLoader( cl ); + + try + { + return extract( configuration.classesDirectory, cl, getDefaultsByRole( roleDefaults ) ); + } + finally + { + Thread.currentThread().setContextClassLoader( prev ); + } + } + } + + private ClassLoader createClassLoader( final List elements ) + throws Exception + { + List list = new ArrayList(); + + // Add the projects dependencies + for ( String filename : elements ) + { + try + { + list.add( new File( filename ).toURI().toURL() ); + } + catch ( MalformedURLException e ) + { + throw new MojoExecutionException( "Invalid classpath entry: " + filename, e ); + } + } + + URL[] urls = list.toArray( new URL[list.size()] ); + + //getLogger().debug( "Classpath:" ); + for (URL url : urls) { + //getLogger().debug( " " + urls[i] ); + } + + return new URLClassLoader( urls, null ); + } + + private List> extract( File classesDir, ClassLoader cl, Map> defaultsByRole ) + throws Exception + { + assert classesDir != null; + assert cl != null; + assert defaultsByRole != null; + + List> descriptors = new ArrayList>(); + + DirectoryScanner scanner = new DirectoryScanner(); + scanner.setBasedir( classesDir ); + scanner.addDefaultExcludes(); + scanner.setIncludes( new String[] { "**/*.class" } ); + // exclude special classes like module-info.class + scanner.setExcludes( new String[] { "**/*-*.class" } ); + + //getLogger().debug( "Scanning for classes in: " + classesDir ); + + scanner.scan(); + + String[] includes = scanner.getIncludedFiles(); + + for ( String include : includes ) + { + String className = include.substring( 0, include.lastIndexOf( ".class" ) ).replace( '\\', '.' ).replace( '/', '.' ); + + try + { + // Class type = cl.loadClass( className ); + + ComponentDescriptor descriptor = gleaner.glean( className, cl ); + + if ( descriptor != null ) + { + applyDefaults( descriptor, defaultsByRole ); + + descriptors.add( descriptor ); + } + } + catch ( VerifyError e ) + { + // getLogger().error( "Failed to load class: " + className + "; cause: " + e ); + } + } + + return descriptors; + } +} \ No newline at end of file diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/ComponentDescriptorExtractor.java plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/ComponentDescriptorExtractor.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/ComponentDescriptorExtractor.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/ComponentDescriptorExtractor.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2007 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ + +package org.codehaus.plexus.metadata; + +import java.util.List; + +import org.codehaus.plexus.component.repository.ComponentDescriptor; + +/** + * An abstraction to allow pluggable {@link ComponentDescriptor} extraction to be dropped. + * + * @version $Id$ + */ +public interface ComponentDescriptorExtractor +{ + String ROLE = ComponentDescriptorExtractor.class.getName(); + + List> extract( MetadataGenerationRequest configuration, ComponentDescriptor[] roleDefaults ) + throws Exception; +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/ComponentDescriptorExtractorSupport.java plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/ComponentDescriptorExtractorSupport.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/ComponentDescriptorExtractorSupport.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/ComponentDescriptorExtractorSupport.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2007 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ + +package org.codehaus.plexus.metadata; + +import java.util.HashMap; +import java.util.Map; + +import org.codehaus.plexus.component.repository.ComponentDescriptor; + +/** + * Support for {@link ComponentDescriptorExtractor} implementations. + * + * @version $Id$ + */ +public abstract class ComponentDescriptorExtractorSupport + implements ComponentDescriptorExtractor +{ + protected Map> getDefaultsByRole( final ComponentDescriptor[] roleDefaults ) + { + Map> defaultsByRole = new HashMap>(); + + if ( roleDefaults != null ) + { + for (ComponentDescriptor roleDefault : roleDefaults) { + String role = roleDefault.getRole(); + + if (role == null) { + throw new IllegalArgumentException("Invalid role defaults; found null role in: " + roleDefault); + } + + defaultsByRole.put(role, roleDefault); + } + } + + return defaultsByRole; + } + + protected void applyDefaults( ComponentDescriptor descriptor, Map> defaultsByRole ) + { + assert descriptor != null; + assert defaultsByRole != null; + + if ( defaultsByRole.containsKey( descriptor.getRole() ) ) + { + ComponentDescriptor defaults = defaultsByRole.get( descriptor.getRole() ); + + if ( descriptor.getInstantiationStrategy() == null ) + { + descriptor.setInstantiationStrategy( defaults.getInstantiationStrategy() ); + } + } + } +} \ No newline at end of file diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/ComponentDescriptorWriteException.java plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/ComponentDescriptorWriteException.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/ComponentDescriptorWriteException.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/ComponentDescriptorWriteException.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,48 @@ +package org.codehaus.plexus.metadata; + +/* + * The MIT License + * + * Copyright (c) 2004, The Codehaus + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/** + * @author Trygve Laugstøl + * @version $Id$ + */ +public class ComponentDescriptorWriteException + extends Exception +{ + public ComponentDescriptorWriteException( String message ) + { + super( message ); + } + + public ComponentDescriptorWriteException( String message, Throwable cause ) + { + super( message, cause ); + } + + public ComponentDescriptorWriteException( Throwable cause ) + { + super( cause ); + } +} \ No newline at end of file diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/ComponentDescriptorWriter.java plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/ComponentDescriptorWriter.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/ComponentDescriptorWriter.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/ComponentDescriptorWriter.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,39 @@ +/* + * The MIT License + * + * Copyright (c) 2007, The Codehaus + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package org.codehaus.plexus.metadata; + +import java.io.IOException; +import java.io.Writer; + +import org.codehaus.plexus.component.repository.ComponentSetDescriptor; + +/** + * @author Kenney Westerhof + */ +public interface ComponentDescriptorWriter +{ + void writeDescriptorSet( Writer writer, ComponentSetDescriptor componentSetDescriptor, boolean containerDescriptor ) + throws ComponentDescriptorWriteException, IOException; +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/DefaultComponentDescriptorWriter.java plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/DefaultComponentDescriptorWriter.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/DefaultComponentDescriptorWriter.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/DefaultComponentDescriptorWriter.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,303 @@ +/* + * The MIT License + * + * Copyright (c) 2007, The Codehaus + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package org.codehaus.plexus.metadata; + +import java.io.IOException; +import java.io.Writer; +import java.util.List; + +import org.codehaus.plexus.component.repository.ComponentDependency; +import org.codehaus.plexus.component.repository.ComponentDescriptor; +import org.codehaus.plexus.component.repository.ComponentRequirement; +import org.codehaus.plexus.component.repository.ComponentRequirementList; +import org.codehaus.plexus.component.repository.ComponentSetDescriptor; +import org.codehaus.plexus.configuration.PlexusConfiguration; +import org.codehaus.plexus.configuration.PlexusConfigurationException; +import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter; +import org.codehaus.plexus.util.xml.XMLWriter; + +/** + * Serializes a {@link ComponentSetDescriptor}. + * + * @author Kenney Westerhof + * @author Jason van Zyl + * @author Trygve Laugstøl + */ +public class DefaultComponentDescriptorWriter + implements ComponentDescriptorWriter +{ + private static final String LS = System.getProperty( "line.separator" ); + + public void writeDescriptorSet( Writer writer, ComponentSetDescriptor componentSetDescriptor, boolean containerDescriptor ) + throws ComponentDescriptorWriteException, IOException + { + try + { + XMLWriter w = new PrettyPrintXMLWriter( writer ); + + w.startElement( containerDescriptor ? "plexus" : "component-set" ); + + writeComponents( w, componentSetDescriptor.getComponents() ); + + writeDependencies( w, componentSetDescriptor.getDependencies() ); + + w.endElement(); + + writer.write( LS ); + + // Flush, but don't close the writer... we are not its owner + writer.flush(); + } + catch ( PlexusConfigurationException e ) + { + throw new ComponentDescriptorWriteException( "Internal error while writing out the configuration", e ); + } + + } + + private void writeComponents( XMLWriter w, List> componentDescriptors ) + throws ComponentDescriptorWriteException, PlexusConfigurationException + { + if ( componentDescriptors == null ) + { + return; + } + + w.startElement( "components" ); + + for ( ComponentDescriptor cd : componentDescriptors ) + { + w.startElement( "component" ); + + element( w, "role", cd.getRole() ); + + element( w, "role-hint", cd.getRoleHint() ); + + element( w, "implementation", cd.getImplementation() ); + + element( w, "version", cd.getVersion() ); + + element( w, "component-type", cd.getComponentType() ); + + element( w, "instantiation-strategy", cd.getInstantiationStrategy() ); + + element( w, "lifecycle-handler", cd.getLifecycleHandler() ); + + element( w, "component-profile", cd.getComponentProfile() ); + + element( w, "component-composer", cd.getComponentComposer() ); + + element( w, "component-configurator", cd.getComponentConfigurator() ); + + element( w, "component-factory", cd.getComponentFactory() ); + + element( w, "description", cd.getDescription() ); + + element( w, "alias", cd.getAlias() ); + + element( w, "isolated-realm", Boolean.toString( cd.isIsolatedRealm() ) ); + + writeRequirements( w, cd.getRequirements() ); + + writeConfiguration( w, cd.getConfiguration() ); + + w.endElement(); + } + + w.endElement(); + } + + public void writeDependencies( XMLWriter w, List deps ) + { + if ( deps == null || deps.size() == 0 ) + { + return; + } + + w.startElement( "dependencies" ); + + for ( ComponentDependency dep : deps ) + { + writeDependencyElement( dep, w ); + } + + w.endElement(); + } + + private void writeDependencyElement( ComponentDependency dependency, XMLWriter w ) + { + w.startElement( "dependency" ); + + String groupId = dependency.getGroupId(); + + element( w, "groupId", groupId ); + + String artifactId = dependency.getArtifactId(); + + element( w, "artifactId", artifactId ); + + String type = dependency.getType(); + + if ( type != null ) + { + element( w, "type", type ); + } + + String version = dependency.getVersion(); + + element( w, "version", version ); + + w.endElement(); + } + + private void writeRequirements( XMLWriter w, List requirements ) + { + if ( requirements == null || requirements.size() == 0 ) + { + return; + } + + w.startElement( "requirements" ); + + for ( ComponentRequirement cr : requirements ) + { + w.startElement( "requirement" ); + + element( w, "role", cr.getRole() ); + + if ( cr instanceof ComponentRequirementList ) + { + List hints = ( (ComponentRequirementList) cr ).getRoleHints(); + + if ( hints != null ) + { + w.startElement( "role-hints" ); + + for ( String roleHint : hints ) + { + w.startElement( "role-hint" ); + + w.writeText( roleHint ); + + w.endElement(); + } + + w.endElement(); + } + } + else + { + // ensure there's no written, which causes ComponentLookupException + element( w, "role-hint", "".equals( cr.getRoleHint() ) ? null : cr.getRoleHint() ); + } + + element( w, "field-name", cr.getFieldName() ); + + element( w, "optional", cr.isOptional() ? Boolean.TRUE.toString() : null ); + + w.endElement(); + } + + w.endElement(); + } + + private void writeConfiguration( XMLWriter w, PlexusConfiguration configuration ) + throws ComponentDescriptorWriteException, PlexusConfigurationException + { + if ( configuration == null || configuration.getChildCount() == 0 ) + { + return; + } + + if ( !configuration.getName().equals( "configuration" ) ) + { + throw new ComponentDescriptorWriteException( "The root node of the configuration must be 'configuration'."); + } + + writePlexusConfiguration( w, configuration ); + } + + private void writePlexusConfiguration( XMLWriter xmlWriter, PlexusConfiguration c ) + throws PlexusConfigurationException + { + if ( c.getAttributeNames().length == 0 && c.getChildCount() == 0 && c.getValue() == null ) + { + return; + } + + xmlWriter.startElement( c.getName() ); + + // ---------------------------------------------------------------------- + // Write the attributes + // ---------------------------------------------------------------------- + + String[] attributeNames = c.getAttributeNames(); + + for ( String attributeName : attributeNames ) + { + xmlWriter.addAttribute( attributeName, c.getAttribute( attributeName ) ); + } + + // ---------------------------------------------------------------------- + // Write the children + // ---------------------------------------------------------------------- + + PlexusConfiguration[] children = c.getChildren(); + + if ( children.length > 0 ) + { + for ( PlexusConfiguration aChildren : children ) + { + writePlexusConfiguration( xmlWriter, aChildren ); + } + } + else + { + String value = c.getValue(); + + if ( value != null ) + { + xmlWriter.writeText( value ); + } + } + + xmlWriter.endElement(); + } + + private void element( XMLWriter w, String name, String value ) + { + if ( value == null ) + { + return; + } + + w.startElement( name ); + + w.writeText( value ); + + w.endElement(); + } + +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/DefaultMetadataGenerator.java plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/DefaultMetadataGenerator.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/DefaultMetadataGenerator.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/DefaultMetadataGenerator.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,178 @@ +package org.codehaus.plexus.metadata; + +/* + * The MIT License + * + * Copyright (c) 2004-2006, The Codehaus + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileOutputStream; +import java.io.OutputStreamWriter; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.component.annotations.Requirement; +import org.codehaus.plexus.component.repository.ComponentDependency; +import org.codehaus.plexus.component.repository.ComponentDescriptor; +import org.codehaus.plexus.component.repository.ComponentSetDescriptor; +import org.codehaus.plexus.logging.AbstractLogEnabled; +import org.codehaus.plexus.metadata.gleaner.AnnotationComponentGleaner; +import org.codehaus.plexus.metadata.merge.Merger; +import org.codehaus.plexus.util.FileUtils; +import org.codehaus.plexus.util.IOUtil; + +/** + * @author Jason van Zyl + */ +@Component(role = MetadataGenerator.class) +public class DefaultMetadataGenerator + extends AbstractLogEnabled + implements MetadataGenerator +{ + @Requirement + private Merger merger; + + private ComponentDescriptor[] roleDefaults; + + @Requirement + private Map extractorMap; + + // should be a component + private ComponentDescriptorWriter writer = new DefaultComponentDescriptorWriter(); + + public void generateDescriptor( MetadataGenerationRequest request ) + throws Exception + { + assert request.outputFile != null; + + List extractorHints = request.extractors; + + final Collection extractors; + if ( extractorHints == null || extractorHints.size() == 0 ) + { + extractors = extractorMap.values(); + } + else + { + extractors = new ArrayList( extractorHints.size() ); + + for ( String hint : extractorHints ) + { + extractors.add( extractorMap.get( hint ) ); + } + } + + List> descriptors = new ArrayList>(); + + for ( ComponentDescriptorExtractor extractor : extractors ) + { + try + { + List> list = extractor.extract( request, roleDefaults ); + if ( list != null && !list.isEmpty() ) + { + descriptors.addAll( list ); + } + } + catch ( Exception e ) + { + throw new Exception( "Failed to extract descriptors", e ); + } + } + + List componentDescriptors = new ArrayList(); + + // + // If we found descriptors, write out the discovered descriptors + // + if ( descriptors.size() > 0 ) + { + getLogger().info( "Discovered " + descriptors.size() + " component descriptors(s)" ); + + ComponentSetDescriptor set = new ComponentSetDescriptor(); + set.setComponents( descriptors ); + set.setDependencies( Collections. emptyList() ); + + if ( request.componentDescriptorDirectory == null ) + { + writeDescriptor( set, request.outputFile ); + } + else + { + if ( request.intermediaryFile == null ) + { + request.intermediaryFile = File.createTempFile( "plexus-metadata", "xml" ); + request.intermediaryFile.deleteOnExit(); + } + writeDescriptor( set, request.intermediaryFile ); + componentDescriptors.add( request.intermediaryFile ); + } + } + + + // + // Deal with merging + // + if ( request.componentDescriptorDirectory != null && request.componentDescriptorDirectory.isDirectory() ) + { + File[] files = request.componentDescriptorDirectory.listFiles(); + + for ( File file : files ) + { + if ( file.getName().endsWith( ".xml" ) && !file.getName().equals( "plexus.xml" ) ) + { + componentDescriptors.add( file ); + } + } + } + + if ( componentDescriptors.size() > 0 ) + { + merger.mergeDescriptors( request.outputFile, componentDescriptors ); + } + } + + private void writeDescriptor( ComponentSetDescriptor desc, File outputFile ) + throws Exception + { + assert desc != null; + assert outputFile != null; + + FileUtils.forceMkdir( outputFile.getParentFile() ); + + BufferedWriter output = new BufferedWriter( new OutputStreamWriter( new FileOutputStream( outputFile ), "UTF-8" ) ); + + try + { + writer.writeDescriptorSet( output, desc, false ); + output.flush(); + } + finally + { + IOUtil.close( output ); + } + + getLogger().debug( "Wrote: " + outputFile ); + } +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/gleaner/AnnotationComponentGleaner.java plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/gleaner/AnnotationComponentGleaner.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/gleaner/AnnotationComponentGleaner.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/gleaner/AnnotationComponentGleaner.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,281 @@ +/* + * Copyright (C) 2007 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.codehaus.plexus.metadata.gleaner; + +import java.io.IOException; +import java.io.InputStream; +import java.lang.reflect.Modifier; +import java.net.URL; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Enumeration; +import java.util.List; + +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.component.annotations.Configuration; +import org.codehaus.plexus.component.annotations.Requirement; +import org.codehaus.plexus.component.repository.ComponentDescriptor; +import org.codehaus.plexus.component.repository.ComponentRequirement; +import org.codehaus.plexus.component.repository.ComponentRequirementList; +import org.codehaus.plexus.configuration.PlexusConfiguration; +import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration; +import org.codehaus.plexus.metadata.ann.AnnClass; +import org.codehaus.plexus.metadata.ann.AnnField; +import org.codehaus.plexus.metadata.ann.AnnReader; +import org.codehaus.plexus.util.IOUtil; + +/** + * A class component gleaner which inspects each type for org.codehaus.plexus.component.annotations.* annotations + * and when found translates them into a {@link ComponentDescriptor}. + * + * @version $Id$ + */ +public class AnnotationComponentGleaner + extends ComponentGleanerSupport + implements ClassComponentGleaner +{ + private static final String OBJECT_SLASHED_NAME = Object.class.getName().replace('.', '/'); + + public ComponentDescriptor glean(String className, ClassLoader cl) throws ComponentGleanerException + { + assert className != null; + assert cl != null; + + AnnClass annClass = readClass(className.replace('.', '/'), cl); + + // Skip abstract classes + if (Modifier.isAbstract(annClass.getAccess())) { + return null; + } + + + Component anno = annClass.getAnnotation(Component.class); + + if (anno == null) { + return null; + } + + ComponentDescriptor component = new ComponentDescriptor(); + + component.setRole(anno.role().getName()); + + component.setRoleHint(filterEmptyAsNull(anno.hint())); + + component.setImplementation(className); + + component.setVersion(filterEmptyAsNull(anno.version())); + + component.setComponentType(filterEmptyAsNull(anno.type())); + + component.setInstantiationStrategy(filterEmptyAsNull(anno.instantiationStrategy())); + + component.setLifecycleHandler(filterEmptyAsNull(anno.lifecycleHandler())); + + component.setComponentProfile(filterEmptyAsNull(anno.profile())); + + component.setComponentComposer(filterEmptyAsNull(anno.composer())); + + component.setComponentConfigurator(filterEmptyAsNull(anno.configurator())); + + component.setComponentFactory(filterEmptyAsNull(anno.factory())); + + component.setDescription(filterEmptyAsNull(anno.description())); + + component.setAlias(filterEmptyAsNull(anno.alias())); + + component.setIsolatedRealm(anno.isolatedRealm()); + + for (AnnClass c : getClasses(annClass, cl)) { + for (AnnField field : c.getFields().values()) { + ComponentRequirement requirement = findRequirement(field, c, cl); + + if (requirement != null) { + component.addRequirement(requirement); + } + + PlexusConfiguration config = findConfiguration(field, c, cl); + + if (config != null) { + addChildConfiguration(component, config); + } + } + + // + // TODO: Inspect methods? + // + } + + return component; + } + + private AnnClass readClass(String className, ClassLoader cl) throws ComponentGleanerException + { + InputStream is = null; + + try + { + // only read annotation from project classes (not jars) + Enumeration en = cl.getResources( className + ".class" ); + while ( en.hasMoreElements() ) { + URL url = en.nextElement(); + if( url.toString().startsWith( "file:" ) ) + { + is = url.openStream(); + return AnnReader.read( is, cl ); + } + } + throw new ComponentGleanerException("Can't find class " + className); + } + catch (IOException ex) + { + throw new ComponentGleanerException("Can't read class " + className, ex); + } + finally + { + IOUtil.close(is); + } + } + + private AnnClass readClass2(String className, ClassLoader cl) throws ComponentGleanerException + { + InputStream is = null; + try + { + is = cl.getResourceAsStream(className + ".class"); + return AnnReader.read(is, cl); + } + catch (IOException ex) + { + throw new ComponentGleanerException("Can't read class " + className, ex); + } + finally + { + IOUtil.close(is); + } + } + + /** + * Returns a list of all of the classes which the given type inherits from. + */ + private List getClasses(AnnClass annClass, ClassLoader cl) throws ComponentGleanerException { + assert annClass != null; + + List classes = new ArrayList(); + + while(annClass!=null) { + classes.add(annClass); + String superName = annClass.getSuperName(); + if(superName!=null && !superName.equals(OBJECT_SLASHED_NAME)) { + annClass = readClass2(superName, cl); + } else { + break; + } + + // + // TODO: See if we need to include interfaces here too? + // + } + + return classes; + } + + private ComponentRequirement findRequirement(final AnnField field, AnnClass annClass, ClassLoader cl) + throws ComponentGleanerException + { + assert field != null; + + Requirement anno = field.getAnnotation(Requirement.class); + + if (anno == null) { + return null; + } + + String fieldType = field.getType(); + + // TODO implement type resolution without loading classes + Class type; + try { + type = Class.forName(fieldType, false, cl); + } catch (ClassNotFoundException ex) { + // TODO Auto-generated catch block + throw new ComponentGleanerException("Can't load class " + fieldType); + } + + ComponentRequirement requirement; + + if (isRequirementListType(type)) { + requirement = new ComponentRequirementList(); + + String[] hints = anno.hints(); + + if (hints != null && hints.length > 0) { + ((ComponentRequirementList)requirement).setRoleHints(Arrays.asList(hints)); + } + + // + // TODO: See if we can glean any type details out of any generic information from the map or collection + // + } + else { + requirement = new ComponentRequirement(); + + requirement.setRoleHint(filterEmptyAsNull(anno.hint())); + } + + // TODO need to read default annotation values + // if (anno.role()==null || anno.role().isAssignableFrom(Object.class)) { + if (anno.role().isAssignableFrom(Object.class)) { + requirement.setRole(type.getName()); + } + else { + requirement.setRole(anno.role().getName()); + } + + requirement.setFieldName(field.getName()); + + requirement.setFieldMappingType(type.getName()); + + requirement.setOptional( anno.optional() ); + + return requirement; + } + + private PlexusConfiguration findConfiguration(AnnField field, AnnClass c, ClassLoader cl) { + assert field != null; + + Configuration anno = field.getAnnotation(Configuration.class); + + if (anno == null) { + return null; + } + + String name = filterEmptyAsNull(anno.name()); + if (name == null) { + name = field.getName(); + } + name = deHump(name); + + XmlPlexusConfiguration config = new XmlPlexusConfiguration(name); + + String value = filterEmptyAsNull(anno.value()); + if (value != null) { + config.setValue(value); + } + + return config; + } +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/gleaner/ClassComponentGleaner.java plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/gleaner/ClassComponentGleaner.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/gleaner/ClassComponentGleaner.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/gleaner/ClassComponentGleaner.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,33 @@ +package org.codehaus.plexus.metadata.gleaner; + +/* + * Copyright (C) 2007 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import org.codehaus.plexus.component.repository.ComponentDescriptor; + +/** + * Interface for component gleaners which glean off of compiled classes.. + * + * @version $Id$ + */ +public interface ClassComponentGleaner +{ + String ROLE = ClassComponentGleaner.class.getName(); + + ComponentDescriptor glean(String className, ClassLoader cl) + throws ComponentGleanerException; + +} \ No newline at end of file diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/gleaner/ComponentGleanerException.java plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/gleaner/ComponentGleanerException.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/gleaner/ComponentGleanerException.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/gleaner/ComponentGleanerException.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,48 @@ +package org.codehaus.plexus.metadata.gleaner; + +/* + * The MIT License + * + * Copyright (c) 2004, The Codehaus + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/** + * @author Trygve Laugstøl + * @version $Id$ + */ +public class ComponentGleanerException + extends Exception +{ + public ComponentGleanerException( String message ) + { + super( message ); + } + + public ComponentGleanerException( String message, Throwable cause ) + { + super( message, cause ); + } + + public ComponentGleanerException( Throwable cause ) + { + super( cause ); + } +} \ No newline at end of file diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/gleaner/ComponentGleanerSupport.java plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/gleaner/ComponentGleanerSupport.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/gleaner/ComponentGleanerSupport.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/gleaner/ComponentGleanerSupport.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2007 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.codehaus.plexus.metadata.gleaner; + +import java.util.Collection; +import java.util.Map; + +import org.codehaus.plexus.component.repository.ComponentDescriptor; +import org.codehaus.plexus.configuration.PlexusConfiguration; +import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration; + +/** + * Support for component gleaner implementations. + * + * @version $Id$ + */ +public abstract class ComponentGleanerSupport +{ + private static final String EMPTY_STRING = ""; + + protected String filterEmptyAsNull(final String value) { + if (value == null) { + return null; + } else if (EMPTY_STRING.equals(value.trim())) { + return null; + } else { + return value; + } + } + + protected boolean isRequirementListType(final Class type) { + // assert type != null; + + return Collection.class.isAssignableFrom(type) || Map.class.isAssignableFrom(type); + } + + protected void addChildConfiguration(final ComponentDescriptor component, final PlexusConfiguration config) { + // assert component != null; + // assert config != null; + + if (!component.hasConfiguration()) { + component.setConfiguration(new XmlPlexusConfiguration("configuration")); + } + + component.getConfiguration().addChild(config); + } + + protected String deHump(final String string) { + // assert string != null; + + StringBuilder buff = new StringBuilder(); + + for (int i = 0; i < string.length(); i++) { + if (i != 0 && Character.isUpperCase(string.charAt(i))) { + buff.append('-'); + } + + buff.append(string.charAt(i)); + } + + return buff.toString().trim().toLowerCase(); + } +} \ No newline at end of file diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/gleaner/QDoxComponentGleaner.java plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/gleaner/QDoxComponentGleaner.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/gleaner/QDoxComponentGleaner.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/gleaner/QDoxComponentGleaner.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,521 @@ +package org.codehaus.plexus.metadata.gleaner; + +/* + * The MIT License + * + * Copyright (c) 2004, The Codehaus + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +import java.util.*; + +import org.codehaus.plexus.component.repository.ComponentDescriptor; +import org.codehaus.plexus.component.repository.ComponentRequirement; +import org.codehaus.plexus.component.repository.ComponentRequirementList; +import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration; +import org.codehaus.plexus.logging.LogEnabled; +import org.codehaus.plexus.personality.plexus.lifecycle.phase.*; +import org.codehaus.plexus.util.StringUtils; + +import com.thoughtworks.qdox.JavaProjectBuilder; +import com.thoughtworks.qdox.model.DocletTag; +import com.thoughtworks.qdox.model.JavaClass; +import com.thoughtworks.qdox.model.JavaField; + +/** + * A source component gleaner which uses QDox to discover Javadoc annotations. + * + * @author Trygve Laugstøl + * @version $Id$ + */ +public class QDoxComponentGleaner + extends ComponentGleanerSupport + implements SourceComponentGleaner +{ + public static final String PLEXUS_COMPONENT_TAG = "plexus.component"; + + public static final String PLEXUS_REQUIREMENT_TAG = "plexus.requirement"; + + public static final String PLEXUS_CONFIGURATION_TAG = "plexus.configuration"; + + public static final String PLEXUS_VERSION_PARAMETER = "version"; + + public static final String PLEXUS_ROLE_PARAMETER = "role"; + + public static final String PLEXUS_ROLE_HINT_PARAMETER = "role-hint"; + + public static final String PLEXUS_ROLE_HINT_LIST_PARAMETER = "role-hints"; + + public static final String PLEXUS_ALIAS_PARAMETER = "alias"; + + public static final String PLEXUS_DEFAULT_VALUE_PARAMETER = "default-value"; + + public static final String PLEXUS_LIFECYCLE_HANDLER_PARAMETER = "lifecycle-handler"; + + public static final String PLEXUS_INSTANTIATION_STARTEGY_PARAMETER = "instantiation-strategy"; + + public static final String PLEXUS_OPTIONAL_PARAMETER = "optional"; + + public static final String PLEXUS_DEFAULT_HINT = "default"; + + // ---------------------------------------------------------------------- + // ComponentGleaner Implementation + // ---------------------------------------------------------------------- + + public ComponentDescriptor glean( JavaProjectBuilder classCache, JavaClass javaClass ) + throws ComponentGleanerException + { + DocletTag tag = javaClass.getTagByName( PLEXUS_COMPONENT_TAG ); + + if ( tag == null ) + { + return null; + } + + Map parameters = tag.getNamedParameterMap(); + + // ---------------------------------------------------------------------- + // + // ---------------------------------------------------------------------- + + String fqn = javaClass.getFullyQualifiedName(); + + //log.debug( "Creating descriptor for component: {}", fqn ); + + ComponentDescriptor componentDescriptor = new ComponentDescriptor(); + + componentDescriptor.setImplementation( fqn ); + + // ---------------------------------------------------------------------- + // Role + // ---------------------------------------------------------------------- + + String role = getParameter( parameters, PLEXUS_ROLE_PARAMETER ); + + if ( role == null ) + { + role = findRole( javaClass ); + + if ( role == null ) + { + /* + log.warn( "Could not figure out a role for the component '" + fqn + "'. " + + "Please specify a role with a parameter '" + PLEXUS_ROLE_PARAMETER + "' " + "on the @" + + PLEXUS_COMPONENT_TAG + " tag." ); + */ + + return null; + } + } + + componentDescriptor.setRole( role ); + + // ---------------------------------------------------------------------- + // Role hint + // ---------------------------------------------------------------------- + + String roleHint = getParameter( parameters, PLEXUS_ROLE_HINT_PARAMETER ); + + if ( roleHint != null ) + { + // getLogger().debug( " Role hint: " + roleHint ); + } + + componentDescriptor.setRoleHint( roleHint ); + + // ---------------------------------------------------------------------- + // Version + // ---------------------------------------------------------------------- + + String version = getParameter( parameters, PLEXUS_VERSION_PARAMETER ); + + componentDescriptor.setVersion( version ); + + // ---------------------------------------------------------------------- + // Lifecycle handler + // ---------------------------------------------------------------------- + + String lifecycleHandler = getParameter( parameters, PLEXUS_LIFECYCLE_HANDLER_PARAMETER ); + + componentDescriptor.setLifecycleHandler( lifecycleHandler ); + + // ---------------------------------------------------------------------- + // Lifecycle handler + // ---------------------------------------------------------------------- + + String instatiationStrategy = getParameter( parameters, PLEXUS_INSTANTIATION_STARTEGY_PARAMETER ); + + componentDescriptor.setInstantiationStrategy( instatiationStrategy ); + + // ---------------------------------------------------------------------- + // Alias + // ---------------------------------------------------------------------- + + componentDescriptor.setAlias( getParameter( parameters, PLEXUS_ALIAS_PARAMETER ) ); + + // ---------------------------------------------------------------------- + // + // ---------------------------------------------------------------------- + + findExtraParameters( PLEXUS_COMPONENT_TAG, parameters ); + + // ---------------------------------------------------------------------- + // Requirements + // ---------------------------------------------------------------------- + + findRequirements( classCache, componentDescriptor, javaClass ); + + // ---------------------------------------------------------------------- + // Description + // ---------------------------------------------------------------------- + + String comment = javaClass.getComment(); + + if ( comment != null ) + { + int i = comment.indexOf( '.' ); + + if ( i > 0 ) + { + comment = comment.substring( 0, i + 1 ); // include the dot + } + } + + componentDescriptor.setDescription( comment ); + + // ---------------------------------------------------------------------- + // Configuration + // ---------------------------------------------------------------------- + + XmlPlexusConfiguration configuration = new XmlPlexusConfiguration( "configuration" ); + + findConfiguration( configuration, javaClass ); + + componentDescriptor.setConfiguration( configuration ); + + return componentDescriptor; + } + + // ---------------------------------------------------------------------- + // + // ---------------------------------------------------------------------- + + private final static List IGNORED_INTERFACES = Collections.unmodifiableList( Arrays.asList( new String[]{ + LogEnabled.class.getName(), + Initializable.class.getName(), + Configurable.class.getName(), + Contextualizable.class.getName(), + Disposable.class.getName(), + Startable.class.getName(), + } ) ); + + private static String getPackage( JavaClass javaClass ) + { + if ( javaClass.getPackage() != null ) + { + return javaClass.getPackage().getName(); + } + else + { + return ""; + } + } + + private String findRole( JavaClass javaClass ) + { + // ---------------------------------------------------------------------- + // Remove any Plexus specific interfaces from the calculation + // ---------------------------------------------------------------------- + + List interfaces = new ArrayList( javaClass.getImplementedInterfaces() ); + + for ( Iterator it = interfaces.iterator(); it.hasNext(); ) + { + JavaClass ifc = it.next(); + + if ( IGNORED_INTERFACES.contains( ifc.getFullyQualifiedName() ) ) + { + it.remove(); + } + } + + // ---------------------------------------------------------------------- + // For each implemented interface, check to see if it's a candiate + // interface + // ---------------------------------------------------------------------- + + String role = null; + + String className = javaClass.getName(); + + for (JavaClass ifc : interfaces) { + String fqn = ifc.getFullyQualifiedName(); + + String pkg = getPackage(ifc); + + if (pkg == null) { + int index = fqn.lastIndexOf('.'); + + if (index == -1) { + // ----------------------------------------------------------------------- + // This is a special case which will happen in two cases: + // 1) The component is in the default/root package + // 2) The interface is in another build, typically in an -api package + // while the code beeing gleaned in in the -impl build. + // + // Since it's most likely in another package than in the default package + // prepend the gleaned class' package + // ----------------------------------------------------------------------- + + pkg = getPackage(javaClass); + + fqn = pkg + "." + fqn; + } else { + pkg = fqn.substring(0, index); + } + } + + if (fqn == null) { + fqn = ifc.getName(); + } + + String name = fqn.substring(pkg.length() + 1); + + if (className.endsWith(name)) { + if (role != null) { + /* + log.warn( "Found several possible roles for component " + "'" + + javaClass.getFullyQualifiedName() + "', " + "will use '" + role + "', found: " + ifc.getName() + "." ); + */ + } + + role = fqn; + } + } + + if ( role == null ) + { + JavaClass superClass = javaClass.getSuperJavaClass(); + + if ( superClass != null ) + { + role = findRole( superClass ); + } + } + + return role; + } + + private void findRequirements( JavaProjectBuilder classCache, ComponentDescriptor componentDescriptor, + JavaClass javaClass ) + { + List fields = javaClass.getFields(); + + // ---------------------------------------------------------------------- + // Search the super class for requirements + // ---------------------------------------------------------------------- + + if ( javaClass.getSuperJavaClass() != null ) + { + findRequirements( classCache, componentDescriptor, javaClass.getSuperJavaClass() ); + } + + // ---------------------------------------------------------------------- + // Search the current class for requirements + // ---------------------------------------------------------------------- + + for (JavaField field : fields) { + DocletTag tag = field.getTagByName(PLEXUS_REQUIREMENT_TAG); + + if (tag == null) { + continue; + } + + Map parameters = new HashMap(tag.getNamedParameterMap()); + + // ---------------------------------------------------------------------- + // Role + // ---------------------------------------------------------------------- + + String requirementClass = field.getType().getFullyQualifiedName(); + + boolean isMap = requirementClass.equals(Map.class.getName()) || + requirementClass.equals(Collection.class.getName()); + + try { + isMap = isMap || Collection.class.isAssignableFrom(Class.forName(requirementClass)); + } catch (ClassNotFoundException e) { + // ignore the assignable Collection test, though this should never happen + } + + boolean isList = requirementClass.equals(List.class.getName()); + + ComponentRequirement cr; + + String hint = getParameter(parameters, PLEXUS_ROLE_HINT_PARAMETER); + + if (isMap || isList) { + cr = new ComponentRequirementList(); + + String hintList = getParameter(parameters, PLEXUS_ROLE_HINT_LIST_PARAMETER); + + if (hintList != null) { + String[] hintArr = hintList.split(","); + + ((ComponentRequirementList) cr).setRoleHints(Arrays.asList(hintArr)); + } + } else { + cr = new ComponentRequirement(); + + cr.setRoleHint(hint); + } + + String role = getParameter(parameters, PLEXUS_ROLE_PARAMETER); + + if (role == null) { + cr.setRole(requirementClass); + } else { + cr.setRole(role); + } + + String optional = getParameter(parameters, PLEXUS_OPTIONAL_PARAMETER); + + cr.setOptional(Boolean.parseBoolean(optional)); + + cr.setFieldName(field.getName()); + + if (isMap || isList) { + if (hint != null) { + /* + log.warn( "Field: '" + field.getName() + "': A role hint cannot be specified if the " + + "field is a java.util.Map or a java.util.List" ); + */ + + continue; + } + + if (role == null) { + /* + log.warn( "Field: '" + field.getName() + "': A java.util.Map or java.util.List " + + "requirement has to specify a '" + PLEXUS_ROLE_PARAMETER + "' parameter on " + "the @" + + PLEXUS_REQUIREMENT_TAG + " tag so Plexus can know which components to " + + "put in the map or list." ); + */ + + continue; + } + + JavaClass roleClass = classCache.getClassByName(role); + + if (role.indexOf('.') == -1 && StringUtils.isEmpty(getPackage(roleClass))) { + role = getPackage(javaClass) + "." + roleClass.getName(); + } + + cr.setRole(role); + + findExtraParameters(PLEXUS_REQUIREMENT_TAG, parameters); + } + + // ---------------------------------------------------------------------- + // + // ---------------------------------------------------------------------- + + componentDescriptor.addRequirement(cr); + } + } + + private void findConfiguration( XmlPlexusConfiguration configuration, JavaClass javaClass ) + throws ComponentGleanerException + { + List fields = javaClass.getFields(); + + // ---------------------------------------------------------------------- + // Search the super class for configurable fields. + // ---------------------------------------------------------------------- + + if ( javaClass.getSuperJavaClass() != null ) + { + findConfiguration( configuration, javaClass.getSuperJavaClass() ); + } + + // ---------------------------------------------------------------------- + // Search the current class for configurable fields. + // ---------------------------------------------------------------------- + + for (JavaField field : fields) { + DocletTag tag = field.getTagByName(PLEXUS_CONFIGURATION_TAG); + + if (tag == null) { + continue; + } + + Map parameters = new HashMap(tag.getNamedParameterMap()); + + /* don't use the getParameter helper as we like empty strings */ + String defaultValue = parameters.remove(PLEXUS_DEFAULT_VALUE_PARAMETER); + + if (defaultValue == null) { + /* + log.warn( "Component: " + javaClass.getName() + ", field name: '" + field.getName() + "': " + + "Currently configurable fields will not be written to the descriptor " + + "without a default value." );*/ + + continue; + } + + String name = deHump(field.getName()); + + XmlPlexusConfiguration c; + + c = new XmlPlexusConfiguration(name); + + c.setValue(defaultValue); + + //log.debug( " Configuration: {}={}", name, defaultValue ); + + configuration.addChild(c); + + findExtraParameters(PLEXUS_CONFIGURATION_TAG, parameters); + } + } + + // ---------------------------------------------------------------------- + // + // ---------------------------------------------------------------------- + + private void findExtraParameters( String tagName, Map parameters ) + { + for (String s : parameters.keySet()) { + //log.warn( "Extra parameter on the '" + tagName + "' tag: '" + s + "'." ); + } + } + + private String getParameter( Map parameters, String parameter ) + { + String value = parameters.remove( parameter ); + + if ( StringUtils.isEmpty( value ) ) + { + return null; + } + + return value; + } +} \ No newline at end of file diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/gleaner/SourceComponentGleaner.java plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/gleaner/SourceComponentGleaner.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/gleaner/SourceComponentGleaner.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/gleaner/SourceComponentGleaner.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,35 @@ +package org.codehaus.plexus.metadata.gleaner; + +/* + * Copyright (C) 2007 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import org.codehaus.plexus.component.repository.ComponentDescriptor; + +import com.thoughtworks.qdox.JavaProjectBuilder; +import com.thoughtworks.qdox.model.JavaClass; + +/** + * Interface for component gleaners which glean off of source code. + * + * @version $Id$ + */ +public interface SourceComponentGleaner +{ + String ROLE = SourceComponentGleaner.class.getName(); + + ComponentDescriptor glean( JavaProjectBuilder classCache, JavaClass javaClass ) + throws ComponentGleanerException; +} \ No newline at end of file diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/AbstractMerger.java plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/AbstractMerger.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/AbstractMerger.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/AbstractMerger.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,118 @@ +package org.codehaus.plexus.metadata.merge; + +/* + * The MIT License + * + * Copyright (c) 2006, The Codehaus + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and + * associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStreamWriter; +import java.io.Writer; +import java.util.List; + +import org.codehaus.plexus.util.IOUtil; +import org.jdom2.Document; +import org.jdom2.JDOMException; +import org.jdom2.input.SAXBuilder; +import org.jdom2.input.sax.XMLReaderJDOMFactory; +import org.jdom2.input.sax.XMLReaderSAX2Factory; +import org.jdom2.output.XMLOutputter; +import org.xml.sax.XMLReader; + +/** + * Base class for common mergers. + * + * @author Brett Porter + */ +public abstract class AbstractMerger + implements Merger +{ + /** + * @see org.codehaus.plexus.metadata.merge.Merger#writeMergedDocument(org.jdom2.Document, + * java.io.File) + */ + public void writeMergedDocument( Document mergedDocument, File file ) + throws IOException + { + if ( !file.getParentFile().exists() ) + { + file.getParentFile().mkdirs(); + } + + XMLOutputter out = new XMLOutputter(); + Writer fw = null; + try + { + fw = new OutputStreamWriter( new FileOutputStream( file ), "UTF-8" ); + out.output( mergedDocument, fw ); + } + finally + { + IOUtil.close( fw ); + } + } + + public void mergeDescriptors( File outputDescriptor, List descriptors ) + throws IOException + { + SAXBuilder builder = new SAXBuilder( new XMLReaderSAX2Factory( false, Driver.class.getName() ) ); + + Document finalDoc = null; + + for ( File f : descriptors ) + { + try + { + Document doc = builder.build( f ); + + if ( finalDoc != null ) + { + // Last specified has dominance + finalDoc = merge( doc, finalDoc ); + } + else + { + finalDoc = doc; + } + } + catch ( JDOMException e ) + { + throw new IOException( "Invalid input descriptor for merge: " + f + " --> " + e.getMessage() ); + } + catch ( MergeException e ) + { + throw new IOException( "Error merging descriptor: " + f + " --> " + e.getMessage() ); + } + } + + if ( finalDoc != null ) + { + try + { + writeMergedDocument( finalDoc, outputDescriptor ); + } + catch ( IOException e ) + { + throw new IOException( "Error writing merged descriptor: " + outputDescriptor ); + } + } + } +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/ComponentsXmlMerger.java plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/ComponentsXmlMerger.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/ComponentsXmlMerger.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/ComponentsXmlMerger.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,56 @@ +package org.codehaus.plexus.metadata.merge; + +/* + * The MIT License + * + * Copyright (c) 2006, The Codehaus + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.metadata.merge.support.ComponentSetElement; +import org.jdom2.Document; + +/** + * @author Rahul Thakur + * @version $Id$ + */ +@Component(role=Merger.class,hint="componentsXml") +public class ComponentsXmlMerger + extends AbstractMerger +{ + /** + * @see Merger#merge(Document, Document) + */ + public Document merge( Document dDocument, Document rDocument ) + throws MergeException + { + // TODO: Ideally we don't want to manipulate the original + // dominant document but use its copy for merge. + //Document mDoc = (Document) dDocument.clone(); // doesn't merge properly + Document mDoc = dDocument; + ComponentSetElement dCSE = new ComponentSetElement( mDoc.getRootElement() ); + ComponentSetElement rCSE = new ComponentSetElement( rDocument.getRootElement() ); + dCSE.merge( rCSE ); + // the contents are merged into the dominant document DOM. + return mDoc; + } + +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/Driver.java plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/Driver.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/Driver.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/Driver.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,462 @@ +/* -*- c-basic-offset: 4; indent-tabs-mode: nil; -*- //------100-columns-wide------>|*/ +// for license please see accompanying LICENSE.txt file (available also at http://www.xmlpull.org/) + +package org.codehaus.plexus.metadata.merge; + +import java.io.InputStream; +import java.io.IOException; +import java.io.Reader; + +// not J2ME classes -- remove if you want to run in MIDP devices +import java.net.URL; +import java.net.MalformedURLException; + + +// not J2ME classes +import java.io.FileInputStream; +import java.io.FileNotFoundException; + +import org.codehaus.plexus.util.xml.pull.XmlPullParser; +import org.codehaus.plexus.util.xml.pull.XmlPullParserException; +import org.xml.sax.Attributes; +import org.xml.sax.DTDHandler; +import org.xml.sax.ContentHandler; +import org.xml.sax.EntityResolver; +import org.xml.sax.ErrorHandler; +import org.xml.sax.InputSource; +import org.xml.sax.Locator; +import org.xml.sax.SAXException; +import org.xml.sax.SAXParseException; +import org.xml.sax.SAXNotRecognizedException; +import org.xml.sax.SAXNotSupportedException; +import org.xml.sax.XMLReader; +import org.xml.sax.helpers.DefaultHandler; + +/** + * SAX2 Driver that pulls events from XmlPullParser + * and comverts them into SAX2 callbacks. + * + * @author Aleksander Slominski + */ + +public class Driver implements Locator, XMLReader, Attributes +{ + + protected static final String DECLARATION_HANDLER_PROPERTY = + "http://xml.org/sax/properties/declaration-handler"; + + protected static final String LEXICAL_HANDLER_PROPERTY = + "http://xml.org/sax/properties/lexical-handler"; + + protected static final String NAMESPACES_FEATURE = + "http://xml.org/sax/features/namespaces"; + + protected static final String NAMESPACE_PREFIXES_FEATURE = + "http://xml.org/sax/features/namespace-prefixes"; + + protected static final String VALIDATION_FEATURE = + "http://xml.org/sax/features/validation"; + + protected static final String APACHE_SCHEMA_VALIDATION_FEATURE = + "http://apache.org/xml/features/validation/schema"; + + protected static final String APACHE_DYNAMIC_VALIDATION_FEATURE = + "http://apache.org/xml/features/validation/dynamic"; + + protected ContentHandler contentHandler = new DefaultHandler(); + protected ErrorHandler errorHandler = new DefaultHandler();; + + protected String systemId; + + protected XmlPullParser pp; + + public Driver() throws XmlPullParserException + { + pp = new MXParser(); + + try + { + setFeature( NAMESPACES_FEATURE, true ); + setFeature( NAMESPACE_PREFIXES_FEATURE, true ); + + } + catch ( Exception e ) + { + e.printStackTrace(); + } + } + + // -- Attributes interface + + public int getLength() { return pp.getAttributeCount(); } + public String getURI(int index) { return pp.getAttributeNamespace(index); } + public String getLocalName(int index) { return pp.getAttributeName(index); } + public String getQName(int index) { + final String prefix = pp.getAttributePrefix(index); + if(prefix != null) { + return prefix+':'+pp.getAttributeName(index); + } else { + return pp.getAttributeName(index); + } + } + public String getType(int index) { return pp.getAttributeType(index); } + public String getValue(int index) { return pp.getAttributeValue(index); } + + public int getIndex(String uri, String localName) { + for (int i = 0; i < pp.getAttributeCount(); i++) + { + if(pp.getAttributeNamespace(i).equals(uri) + && pp.getAttributeName(i).equals(localName)) + { + return i; + } + + } + return -1; + } + + public int getIndex(String qName) { + for (int i = 0; i < pp.getAttributeCount(); i++) + { + if(pp.getAttributeName(i).equals(qName)) + { + return i; + } + + } + return -1; + } + + public String getType(String uri, String localName) { + for (int i = 0; i < pp.getAttributeCount(); i++) + { + if(pp.getAttributeNamespace(i).equals(uri) + && pp.getAttributeName(i).equals(localName)) + { + return pp.getAttributeType(i); + } + + } + return null; + } + public String getType(String qName) { + for (int i = 0; i < pp.getAttributeCount(); i++) + { + if(pp.getAttributeName(i).equals(qName)) + { + return pp.getAttributeType(i); + } + + } + return null; + } + public String getValue(String uri, String localName) { + return pp.getAttributeValue(uri, localName); + } + public String getValue(String qName) { + return pp.getAttributeValue(null, qName); + } + + // -- Locator interface + + public String getPublicId() { return null; } + public String getSystemId() { return systemId; } + public int getLineNumber() { return pp.getLineNumber(); } + public int getColumnNumber() { return pp.getColumnNumber(); } + + // --- XMLReader interface + + //"http://xml.org/sax/features/namespaces", + //true + + public boolean getFeature(String name) + throws SAXNotRecognizedException, SAXNotSupportedException + { + if(NAMESPACES_FEATURE.equals(name)) { + return pp.getFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES); + } else if(NAMESPACE_PREFIXES_FEATURE.equals(name)) { + return pp.getFeature(XmlPullParser.FEATURE_REPORT_NAMESPACE_ATTRIBUTES); + } else if(VALIDATION_FEATURE.equals(name)) { + return pp.getFeature(XmlPullParser.FEATURE_VALIDATION); + // } else if(APACHE_SCHEMA_VALIDATION_FEATURE.equals(name)) { + // return false; //TODO + // } else if(APACHE_DYNAMIC_VALIDATION_FEATURE.equals(name)) { + // return false; //TODO + } else { + return pp.getFeature(name); + //throw new SAXNotRecognizedException("unrecognized feature "+name); + } + } + + public void setFeature (String name, boolean value) + throws SAXNotRecognizedException, SAXNotSupportedException + { + try { + if(NAMESPACES_FEATURE.equals(name)) { + pp.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, value); + } else if(NAMESPACE_PREFIXES_FEATURE.equals(name)) { + if(pp.getFeature(XmlPullParser.FEATURE_REPORT_NAMESPACE_ATTRIBUTES) != value) { + pp.setFeature(XmlPullParser.FEATURE_REPORT_NAMESPACE_ATTRIBUTES, value); + } + } else if(VALIDATION_FEATURE.equals(name)) { + pp.setFeature(XmlPullParser.FEATURE_VALIDATION, value); + } else { + pp.setFeature(name, value); + //throw new SAXNotRecognizedException("unrecognized feature "+name); + } + } catch(XmlPullParserException ex) { + throw new SAXNotSupportedException("problem with setting feature "+name+": "+ex); + } + } + + public Object getProperty (String name) + throws SAXNotRecognizedException, SAXNotSupportedException + { + if(DECLARATION_HANDLER_PROPERTY.equals(name)) { + return null; + } else if(LEXICAL_HANDLER_PROPERTY.equals(name)) { + return null; + } else { + return pp.getProperty(name); + //throw new SAXNotRecognizedException("not recognized get property "+name); + } + } + + public void setProperty (String name, Object value) + throws SAXNotRecognizedException, SAXNotSupportedException + { + // + if(DECLARATION_HANDLER_PROPERTY.equals(name)) { + throw new SAXNotSupportedException("not supported setting property "+name);//+" to "+value); + } else if(LEXICAL_HANDLER_PROPERTY.equals(name)) { + throw new SAXNotSupportedException("not supported setting property "+name);//+" to "+value); + } else { + try { + pp.setProperty(name, value); + } catch(XmlPullParserException ex) { + throw new SAXNotSupportedException("not supported set property "+name+": "+ ex); + } + //throw new SAXNotRecognizedException("not recognized set property "+name); + } + } + + public void setEntityResolver (EntityResolver resolver) {} + + public EntityResolver getEntityResolver () { return null; } + + public void setDTDHandler (DTDHandler handler) {} + + public DTDHandler getDTDHandler () { return null; } + + public void setContentHandler (ContentHandler handler) + { + this.contentHandler = handler; + } + + public ContentHandler getContentHandler() { return contentHandler; } + + public void setErrorHandler(ErrorHandler handler) { + this.errorHandler = handler; + } + + public ErrorHandler getErrorHandler() { return errorHandler; } + + public void parse(InputSource source) throws SAXException, IOException + { + + systemId = source.getSystemId(); + contentHandler.setDocumentLocator(this); + + final Reader reader = source.getCharacterStream(); + try { + if (reader == null) { + InputStream stream = source.getByteStream(); + final String encoding = source.getEncoding(); + + if (stream == null) { + systemId = source.getSystemId(); + if(systemId == null) { + SAXParseException saxException = new SAXParseException( + "null source systemId" , this); + errorHandler.fatalError(saxException); + return; + } + // NOTE: replace with Connection to run in J2ME environment + try { + final URL url = new URL(systemId); + stream = url.openStream(); + } catch (MalformedURLException nue) { + try { + stream = new FileInputStream(systemId); + } catch (FileNotFoundException fnfe) { + final SAXParseException saxException = new SAXParseException( + "could not open file with systemId "+systemId, this, fnfe); + errorHandler.fatalError(saxException); + return; + } + } + } + pp.setInput(stream, encoding); + } else { + pp.setInput(reader); + } + } catch (XmlPullParserException ex) { + final SAXParseException saxException = new SAXParseException( + "parsing initialization error: "+ex, this, ex); + //if(DEBUG) ex.printStackTrace(); + errorHandler.fatalError(saxException); + return; + } + + // start parsing - move to first start tag + try { + contentHandler.startDocument(); + // get first event + pp.next(); + // it should be start tag... + if(pp.getEventType() != XmlPullParser.START_TAG) { + final SAXParseException saxException = new SAXParseException( + "expected start tag not"+pp.getPositionDescription(), this); + //throw saxException; + errorHandler.fatalError(saxException); + return; + } + } catch (XmlPullParserException ex) { + final SAXParseException saxException = new SAXParseException( + "parsing initialization error: "+ex, this, ex); + //ex.printStackTrace(); + errorHandler.fatalError(saxException); + return; + } + + // now real parsing can start! + + parseSubTree(pp); + + // and finished ... + + contentHandler.endDocument(); + } + + public void parse(String systemId) throws SAXException, IOException { + parse(new InputSource(systemId)); + } + + + public void parseSubTree(XmlPullParser pp) throws SAXException, IOException { + this.pp = pp; + final boolean namespaceAware = pp.getFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES); + try { + if(pp.getEventType() != XmlPullParser.START_TAG) { + throw new SAXException( + "start tag must be read before skiping subtree"+pp.getPositionDescription()); + } + final int[] holderForStartAndLength = new int[2]; + final StringBuilder rawName = new StringBuilder(16); + String prefix = null; + String name = null; + int level = pp.getDepth() - 1; + int type = XmlPullParser.START_TAG; + + LOOP: + do { + switch(type) { + case XmlPullParser.START_TAG: + if(namespaceAware) { + final int depth = pp.getDepth() - 1; + final int countPrev = + (level > depth) ? pp.getNamespaceCount(depth) : 0; + //int countPrev = pp.getNamespaceCount(pp.getDepth() - 1); + final int count = pp.getNamespaceCount(depth + 1); + for (int i = countPrev; i < count; i++) + { + contentHandler.startPrefixMapping( + pp.getNamespacePrefix(i), + pp.getNamespaceUri(i) + ); + } + name = pp.getName(); + prefix = pp.getPrefix(); + if(prefix != null) { + rawName.setLength(0); + rawName.append(prefix); + rawName.append(':'); + rawName.append(name); + } + startElement(pp.getNamespace(), + name, + prefix != null ? name : rawName.toString()); + } else { + startElement(pp.getNamespace(), + pp.getName(), + pp.getName()); + } + //++level; + + break; + case XmlPullParser.TEXT: + final char[] chars = pp.getTextCharacters(holderForStartAndLength); + contentHandler.characters(chars, + holderForStartAndLength[0], //start + holderForStartAndLength[1] //len + ); + break; + case XmlPullParser.END_TAG: + //--level; + if(namespaceAware) { + name = pp.getName(); + prefix = pp.getPrefix(); + if(prefix != null) { + rawName.setLength(0); + rawName.append(prefix); + rawName.append(':'); + rawName.append(name); + } + contentHandler.endElement(pp.getNamespace(), + name, + prefix != null ? name : rawName.toString() + ); + // when entering show prefixes for all levels!!!! + final int depth = pp.getDepth(); + final int countPrev = + (level > depth) ? pp.getNamespaceCount(pp.getDepth()) : 0; + int count = pp.getNamespaceCount(pp.getDepth() - 1); + // undeclare them in reverse order + for (int i = count - 1; i >= countPrev; i--) + { + contentHandler.endPrefixMapping( + pp.getNamespacePrefix(i) + ); + } + } else { + contentHandler.endElement(pp.getNamespace(), + pp.getName(), + pp.getName() + ); + + } + break; + case XmlPullParser.END_DOCUMENT: + break LOOP; + } + type = pp.next(); + } while(pp.getDepth() > level); + } catch (XmlPullParserException ex) { + final SAXParseException saxException = new SAXParseException("parsing error: "+ex, this, ex); + ex.printStackTrace(); + errorHandler.fatalError(saxException); + } + } + + /** + * Calls {@link ContentHandler.startElement(String, String, String, Attributes) startElement} + * on the ContentHandler with this driver object as the + * {@link Attributes} implementation. In default implementation + * {@link Attributes} object is valid only during this method call and may not + * be stored. Sub-classes can overwrite this method to cache attributes. + */ + protected void startElement(String namespace, String localName, String qName) throws SAXException { + contentHandler.startElement(namespace, localName, qName, this); + } + +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/MergeException.java plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/MergeException.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/MergeException.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/MergeException.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,43 @@ +package org.codehaus.plexus.metadata.merge; + +/* + * The MIT License + * + * Copyright (c) 2006, The Codehaus + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/** + * @author Rahul Thakur + * @version $Id$ + */ +public class MergeException + extends Exception +{ + public MergeException( String message, Throwable cause ) + { + super( message, cause ); + } + + public MergeException( String message ) + { + super( message ); + } +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/Merger.java plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/Merger.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/Merger.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/Merger.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,65 @@ +package org.codehaus.plexus.metadata.merge; + +/* + * The MIT License + * + * Copyright (c) 2006, The Codehaus + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +import java.io.File; +import java.io.IOException; +import java.util.List; + +import org.jdom2.Document; + +/** + * @author Rahul Thakur + * @version $Id$ + */ +public interface Merger +{ + String ROLE = Merger.class.getName(); + + /** + * Merge with the recessive document. + * + * @param dDocument the dominant document. + * @param rDocument the recessive document. + * @return the merged {@link Document} instance. + * + * @throws MergeException if there was an error in merge. + */ + Document merge( Document dDocument, Document rDocument ) + throws MergeException; + + /** + * Allows writing out a merged JDom Document to the specified file. + * + * @param mergedDocument the merged {@link Document} instance. + * @param file File to write the merged contents to. + * @throws IOException if there was an error while writing merged contents to the specified file. + */ + void writeMergedDocument( Document mergedDocument, File file ) + throws IOException; + + void mergeDescriptors( File outputDescriptor, List descriptors ) + throws IOException; +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/MergeStrategy.java plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/MergeStrategy.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/MergeStrategy.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/MergeStrategy.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,44 @@ +package org.codehaus.plexus.metadata.merge; + +/* + * The MIT License + * + * Copyright (c) 2006, The Codehaus + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +import org.codehaus.plexus.metadata.merge.support.Mergeable; + +/** + * @author Rahul Thakur + * @version $Id$ + */ +public interface MergeStrategy +{ + /** + * Merges a dominant {@link Mergeable} instance with a recessive one. + * + * @param dElt Dominant {@link Mergeable} instance. + * @param rElt Recessive {@link Mergeable} instance. + * @throws MergeException TODO + */ + void apply( Mergeable dElt, Mergeable rElt ) + throws MergeException; +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/MXParser.java plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/MXParser.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/MXParser.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/MXParser.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,3288 @@ +/* -*- c-basic-offset: 4; indent-tabs-mode: nil; -*- //------100-columns-wide------>|*/ +/* + * Copyright (c) 2003 Extreme! Lab, Indiana University. All rights reserved. + * + * This software is open source. See the bottom of this file for the licence. + * + * $Id$ + */ + +package org.codehaus.plexus.metadata.merge; + +import java.io.EOFException; +import java.io.IOException; +import java.io.Reader; +import java.io.UnsupportedEncodingException; + +import org.codehaus.plexus.util.ReaderFactory; +import org.codehaus.plexus.util.xml.pull.XmlPullParser; +import org.codehaus.plexus.util.xml.pull.XmlPullParserException; + +//import java.util.Hashtable; + +//TODO best handling of interning issues +// have isAllNewStringInterned ??? + +//TODO handling surrogate pairs: http://www.unicode.org/unicode/faq/utf_bom.html#6 + +//TODO review code for use of bufAbsoluteStart when keeping pos between next()/fillBuf() + +/** + * Absolutely minimal implementation of XMLPULL V1 API. Encoding handling done with XmlReader + * + * @see org.codehaus.plexus.util.xml.XmlReader + * @author Aleksander Slominski + */ + +public class MXParser + implements XmlPullParser +{ + //NOTE: no interning of those strings --> by Java leng spec they MUST be already interned + protected final static String XML_URI = "http://www.w3.org/XML/1998/namespace"; + protected final static String XMLNS_URI = "http://www.w3.org/2000/xmlns/"; + protected final static String FEATURE_XML_ROUNDTRIP= + //"http://xmlpull.org/v1/doc/features.html#xml-roundtrip"; + "http://xmlpull.org/v1/doc/features.html#xml-roundtrip"; + protected final static String FEATURE_NAMES_INTERNED = + "http://xmlpull.org/v1/doc/features.html#names-interned"; + protected final static String PROPERTY_XMLDECL_VERSION = + "http://xmlpull.org/v1/doc/properties.html#xmldecl-version"; + protected final static String PROPERTY_XMLDECL_STANDALONE = + "http://xmlpull.org/v1/doc/properties.html#xmldecl-standalone"; + protected final static String PROPERTY_XMLDECL_CONTENT = + "http://xmlpull.org/v1/doc/properties.html#xmldecl-content"; + protected final static String PROPERTY_LOCATION = + "http://xmlpull.org/v1/doc/properties.html#location"; + + + protected final static String REPORT_NAMESPACE_PREFIXES = + "http://xmlpull.org/v1/doc/features.html#report-namespace-prefixes"; + /** + * Implementation notice: + * the is instance variable that controls if newString() is interning. + *

NOTE: newStringIntern always returns interned strings + * and newString MAY return interned String depending on this variable. + *

NOTE: by default in this minimal implementation it is false! + */ + protected boolean allStringsInterned; + + protected boolean usePC; + protected boolean seenStartTag; + protected boolean seenEndTag; + protected boolean pastEndTag; + protected boolean seenAmpersand; + protected boolean seenMarkup; + protected boolean seenDocdecl; + + // transient variable set during each call to next/Token() + protected boolean tokenize; + protected String text; + protected String entityRefName; + + protected String xmlDeclVersion; + protected Boolean xmlDeclStandalone; + protected String xmlDeclContent; + + // NOTE: features are not resetable and typically defaults to false ... + protected boolean processNamespaces; + protected boolean roundtripSupported; + + // global parser state + protected String location; + protected int lineNumber; + protected int columnNumber; + protected boolean seenRoot; + protected boolean reachedEnd; + protected int eventType; + protected boolean emptyElementTag; + // element stack + protected int depth; + protected char[] elRawName[]; + protected int elRawNameEnd[]; + protected int elRawNameLine[]; + + protected String elName[]; + protected String elPrefix[]; + protected String elUri[]; + //protected String elValue[]; + protected int elNamespaceCount[]; + + // input buffer management + protected static final int READ_CHUNK_SIZE = 8*1024; //max data chars in one read() call + protected Reader reader; + protected String inputEncoding; + + + protected int bufLoadFactor = 95; // 99% + //protected int bufHardLimit; // only matters when expanding + + protected char buf[] = new char[READ_CHUNK_SIZE]; + protected int bufSoftLimit = ( bufLoadFactor * buf.length ) /100; + protected boolean preventBufferCompaction; + + protected int bufAbsoluteStart; // this is buf + protected int bufStart; + protected int bufEnd; + protected int pos; + protected int posStart; + protected int posEnd; + + protected char pc[] = new char[READ_CHUNK_SIZE]; + protected int pcStart; + protected int pcEnd; + + protected void resetStringCache() { + //System.out.println("resetStringCache() minimum called"); + } + + protected String newString(char[] cbuf, int off, int len) { + return new String(cbuf, off, len); + } + + protected String newStringIntern(char[] cbuf, int off, int len) { + return (new String(cbuf, off, len)).intern(); + } + + private static final boolean TRACE_SIZING = false; + + + /** + * Make sure that we have enough space to keep element stack if passed size. + * It will always create one additional slot then current depth + */ + protected void ensureElementsCapacity() { + final int elStackSize = elName != null ? elName.length : 0; + if( (depth + 1) >= elStackSize) { + // we add at least one extra slot ... + final int newSize = (depth >= 7 ? 2 * depth : 8) + 2; // = lucky 7 + 1 //25 + if(TRACE_SIZING) { + System.err.println("TRACE_SIZING elStackSize "+elStackSize+" ==> "+newSize); + } + final boolean needsCopying = elStackSize > 0; + String[] arr = null; + // resue arr local variable slot + arr = new String[newSize]; + if(needsCopying) System.arraycopy(elName, 0, arr, 0, elStackSize); + elName = arr; + arr = new String[newSize]; + if(needsCopying) System.arraycopy(elPrefix, 0, arr, 0, elStackSize); + elPrefix = arr; + arr = new String[newSize]; + if(needsCopying) System.arraycopy(elUri, 0, arr, 0, elStackSize); + elUri = arr; + + int[] iarr = new int[newSize]; + if(needsCopying) { + System.arraycopy(elNamespaceCount, 0, iarr, 0, elStackSize); + } else { + // special initialization + iarr[0] = 0; + } + elNamespaceCount = iarr; + + //TODO: avoid using element raw name ... + iarr = new int[newSize]; + if(needsCopying) { + System.arraycopy(elRawNameEnd, 0, iarr, 0, elStackSize); + } + elRawNameEnd = iarr; + + iarr = new int[newSize]; + if(needsCopying) { + System.arraycopy(elRawNameLine, 0, iarr, 0, elStackSize); + } + elRawNameLine = iarr; + + final char[][] carr = new char[newSize][]; + if(needsCopying) { + System.arraycopy(elRawName, 0, carr, 0, elStackSize); + } + elRawName = carr; + // arr = new String[newSize]; + // if(needsCopying) System.arraycopy(elLocalName, 0, arr, 0, elStackSize); + // elLocalName = arr; + // arr = new String[newSize]; + // if(needsCopying) System.arraycopy(elDefaultNs, 0, arr, 0, elStackSize); + // elDefaultNs = arr; + // int[] iarr = new int[newSize]; + // if(needsCopying) System.arraycopy(elNsStackPos, 0, iarr, 0, elStackSize); + // for (int i = elStackSize; i < iarr.length; i++) + // { + // iarr[i] = (i > 0) ? -1 : 0; + // } + // elNsStackPos = iarr; + //assert depth < elName.length; + } + } + + + + // attribute stack + protected int attributeCount; + protected String attributeName[]; + protected int attributeNameHash[]; + //protected int attributeNameStart[]; + //protected int attributeNameEnd[]; + protected String attributePrefix[]; + protected String attributeUri[]; + protected String attributeValue[]; + //protected int attributeValueStart[]; + //protected int attributeValueEnd[]; + + + /** + * Make sure that in attributes temporary array is enough space. + */ + protected void ensureAttributesCapacity(int size) { + final int attrPosSize = attributeName != null ? attributeName.length : 0; + if(size >= attrPosSize) { + final int newSize = size > 7 ? 2 * size : 8; // = lucky 7 + 1 //25 + if(TRACE_SIZING) { + System.err.println("TRACE_SIZING attrPosSize "+attrPosSize+" ==> "+newSize); + } + final boolean needsCopying = attrPosSize > 0; + String[] arr = null; + + arr = new String[newSize]; + if(needsCopying) System.arraycopy(attributeName, 0, arr, 0, attrPosSize); + attributeName = arr; + + arr = new String[newSize]; + if(needsCopying) System.arraycopy(attributePrefix, 0, arr, 0, attrPosSize); + attributePrefix = arr; + + arr = new String[newSize]; + if(needsCopying) System.arraycopy(attributeUri, 0, arr, 0, attrPosSize); + attributeUri = arr; + + arr = new String[newSize]; + if(needsCopying) System.arraycopy(attributeValue, 0, arr, 0, attrPosSize); + attributeValue = arr; + + if( ! allStringsInterned ) { + final int[] iarr = new int[newSize]; + if(needsCopying) System.arraycopy(attributeNameHash, 0, iarr, 0, attrPosSize); + attributeNameHash = iarr; + } + + arr = null; + // //assert attrUri.length > size + } + } + + // namespace stack + protected int namespaceEnd; + protected String namespacePrefix[]; + protected int namespacePrefixHash[]; + protected String namespaceUri[]; + + protected void ensureNamespacesCapacity(int size) { + final int namespaceSize = namespacePrefix != null ? namespacePrefix.length : 0; + if(size >= namespaceSize) { + final int newSize = size > 7 ? 2 * size : 8; // = lucky 7 + 1 //25 + if(TRACE_SIZING) { + System.err.println("TRACE_SIZING namespaceSize "+namespaceSize+" ==> "+newSize); + } + final String[] newNamespacePrefix = new String[newSize]; + final String[] newNamespaceUri = new String[newSize]; + if(namespacePrefix != null) { + System.arraycopy( + namespacePrefix, 0, newNamespacePrefix, 0, namespaceEnd); + System.arraycopy( + namespaceUri, 0, newNamespaceUri, 0, namespaceEnd); + } + namespacePrefix = newNamespacePrefix; + namespaceUri = newNamespaceUri; + + + if( ! allStringsInterned ) { + final int[] newNamespacePrefixHash = new int[newSize]; + if(namespacePrefixHash != null) { + System.arraycopy( + namespacePrefixHash, 0, newNamespacePrefixHash, 0, namespaceEnd); + } + namespacePrefixHash = newNamespacePrefixHash; + } + //prefixesSize = newSize; + // //assert nsPrefixes.length > size && nsPrefixes.length == newSize + } + } + + /** + * simplistic implementation of hash function that has constant + * time to compute - so it also means diminishing hash quality for long strings + * but for XML parsing it should be good enough ... + */ + protected static final int fastHash( char ch[], int off, int len ) { + if(len == 0) return 0; + //assert len >0 + int hash = ch[off]; // hash at beginning + //try { + hash = (hash << 7) + ch[ off + len - 1 ]; // hash at the end + //} catch(ArrayIndexOutOfBoundsException aie) { + // aie.printStackTrace(); //should never happen ... + // throw new RuntimeException("this is violation of pre-condition"); + //} + if(len > 16) hash = (hash << 7) + ch[ off + (len / 4)]; // 1/4 from beginning + if(len > 8) hash = (hash << 7) + ch[ off + (len / 2)]; // 1/2 of string size ... + // notice that hash is at most done 3 times <<7 so shifted by 21 bits 8 bit value + // so max result == 29 bits so it is quite just below 31 bits for long (2^32) ... + //assert hash >= 0; + return hash; + } + + // entity replacement stack + protected int entityEnd; + + protected String entityName[]; + protected char[] entityNameBuf[]; + protected String entityReplacement[]; + protected char[] entityReplacementBuf[]; + + protected int entityNameHash[]; + + protected void ensureEntityCapacity() { + final int entitySize = entityReplacementBuf != null ? entityReplacementBuf.length : 0; + if(entityEnd >= entitySize) { + final int newSize = entityEnd > 7 ? 2 * entityEnd : 8; // = lucky 7 + 1 //25 + if(TRACE_SIZING) { + System.err.println("TRACE_SIZING entitySize "+entitySize+" ==> "+newSize); + } + final String[] newEntityName = new String[newSize]; + final char[] newEntityNameBuf[] = new char[newSize][]; + final String[] newEntityReplacement = new String[newSize]; + final char[] newEntityReplacementBuf[] = new char[newSize][]; + if(entityName != null) { + System.arraycopy(entityName, 0, newEntityName, 0, entityEnd); + System.arraycopy(entityNameBuf, 0, newEntityNameBuf, 0, entityEnd); + System.arraycopy(entityReplacement, 0, newEntityReplacement, 0, entityEnd); + System.arraycopy(entityReplacementBuf, 0, newEntityReplacementBuf, 0, entityEnd); + } + entityName = newEntityName; + entityNameBuf = newEntityNameBuf; + entityReplacement = newEntityReplacement; + entityReplacementBuf = newEntityReplacementBuf; + + if( ! allStringsInterned ) { + final int[] newEntityNameHash = new int[newSize]; + if(entityNameHash != null) { + System.arraycopy(entityNameHash, 0, newEntityNameHash, 0, entityEnd); + } + entityNameHash = newEntityNameHash; + } + } + } + + protected void reset() + { + location = null; + lineNumber = 1; + columnNumber = 0; + seenRoot = false; + reachedEnd = false; + eventType = START_DOCUMENT; + emptyElementTag = false; + + depth = 0; + + attributeCount = 0; + + namespaceEnd = 0; + + entityEnd = 0; + + reader = null; + inputEncoding = null; + + preventBufferCompaction = false; + bufAbsoluteStart = 0; + bufEnd = bufStart = 0; + pos = posStart = posEnd = 0; + + pcEnd = pcStart = 0; + + usePC = false; + + seenStartTag = false; + seenEndTag = false; + pastEndTag = false; + seenAmpersand = false; + seenMarkup = false; + seenDocdecl = false; + + xmlDeclVersion = null; + xmlDeclStandalone = null; + xmlDeclContent = null; + + resetStringCache(); + } + + public MXParser() { + } + + + /** + * Method setFeature + * + * @param name a String + * @param state a boolean + * + * @throws XmlPullParserException + * + */ + public void setFeature(String name, + boolean state) throws XmlPullParserException + { + if(name == null) throw new IllegalArgumentException("feature name should not be null"); + if(FEATURE_PROCESS_NAMESPACES.equals(name)) { + if(eventType != START_DOCUMENT) throw new XmlPullParserException( + "namespace processing feature can only be changed before parsing", this, null); + processNamespaces = state; + // } else if(FEATURE_REPORT_NAMESPACE_ATTRIBUTES.equals(name)) { + // if(type != START_DOCUMENT) throw new XmlPullParserException( + // "namespace reporting feature can only be changed before parsing", this, null); + // reportNsAttribs = state; + } else if(FEATURE_NAMES_INTERNED.equals(name)) { + if(state != false) { + throw new XmlPullParserException( + "interning names in this implementation is not supported"); + } + } else if(FEATURE_PROCESS_DOCDECL.equals(name)) { + if(state != false) { + throw new XmlPullParserException( + "processing DOCDECL is not supported"); + } + //} else if(REPORT_DOCDECL.equals(name)) { + // paramNotifyDoctype = state; + } else if(FEATURE_XML_ROUNDTRIP.equals(name)) { + //if(state == false) { + // throw new XmlPullParserException( + // "roundtrip feature can not be switched off"); + //} + roundtripSupported = state; + } else if (FEATURE_VALIDATION.equals( name ) && !state) { + // noop, is already the default. JDom wants to set it anyway + } else { + throw new XmlPullParserException("unsupporte feature "+name); + } + } + + /** Unknown properties are always returned as false */ + public boolean getFeature(String name) + { + if(name == null) throw new IllegalArgumentException("feature name should not be nulll"); + if(FEATURE_PROCESS_NAMESPACES.equals(name)) { + return processNamespaces; + // } else if(FEATURE_REPORT_NAMESPACE_ATTRIBUTES.equals(name)) { + // return reportNsAttribs; + } else if(FEATURE_NAMES_INTERNED.equals(name)) { + return false; + } else if(FEATURE_PROCESS_DOCDECL.equals(name)) { + return false; + //} else if(REPORT_DOCDECL.equals(name)) { + // return paramNotifyDoctype; + } else if(FEATURE_XML_ROUNDTRIP.equals(name)) { + //return true; + return roundtripSupported; + } + else if( REPORT_NAMESPACE_PREFIXES.equals( name ) ) { + return processNamespaces; + } + + return false; + } + + public void setProperty(String name, + Object value) + throws XmlPullParserException + { + if(PROPERTY_LOCATION.equals(name)) { + location = (String) value; + } else { + throw new XmlPullParserException("unsupported property: '"+name+"'"); + } + } + + + public Object getProperty(String name) + { + if(name == null) throw new IllegalArgumentException("property name should not be nulll"); + if(PROPERTY_XMLDECL_VERSION.equals(name)) { + return xmlDeclVersion; + } else if(PROPERTY_XMLDECL_STANDALONE.equals(name)) { + return xmlDeclStandalone; + } else if(PROPERTY_XMLDECL_CONTENT.equals(name)) { + return xmlDeclContent; + } else if(PROPERTY_LOCATION.equals(name)) { + return location; + } + return null; + } + + + public void setInput(Reader in) throws XmlPullParserException + { + reset(); + reader = in; + } + + + public void setInput(java.io.InputStream inputStream, String inputEncoding) + throws XmlPullParserException + { + if(inputStream == null) { + throw new IllegalArgumentException("input stream can not be null"); + } + Reader reader; + try { + if(inputEncoding != null) { + reader = ReaderFactory.newReader(inputStream, inputEncoding); + } else { + reader = ReaderFactory.newXmlReader(inputStream); + } + } catch (UnsupportedEncodingException une) { + throw new XmlPullParserException( + "could not create reader for encoding "+inputEncoding+" : "+une, this, une); + } + catch ( IOException e ) + { + throw new XmlPullParserException( + "could not create reader : "+e, this, e); + } + setInput(reader); + //must be here as reset() was called in setInput() and has set this.inputEncoding to null ... + this.inputEncoding = inputEncoding; + } + + public String getInputEncoding() { + return inputEncoding; + } + + public void defineEntityReplacementText(String entityName, + String replacementText) + throws XmlPullParserException + { + // throw new XmlPullParserException("not allowed"); + + //protected char[] entityReplacement[]; + ensureEntityCapacity(); + + // this is to make sure that if interning works we will take advantage of it ... + this.entityName[entityEnd] = newString(entityName.toCharArray(), 0, entityName.length()); + entityNameBuf[entityEnd] = entityName.toCharArray(); + + entityReplacement[entityEnd] = replacementText; + entityReplacementBuf[entityEnd] = replacementText.toCharArray(); + if(!allStringsInterned) { + entityNameHash[ entityEnd ] = + fastHash(entityNameBuf[entityEnd], 0, entityNameBuf[entityEnd].length); + } + ++entityEnd; + //TODO disallow < or & in entity replacement text (or ]]>???) + // TOOD keepEntityNormalizedForAttributeValue cached as well ... + } + + public int getNamespaceCount(int depth) + throws XmlPullParserException + { + if(processNamespaces == false || depth == 0) { + return 0; + } + //int maxDepth = eventType == END_TAG ? this.depth + 1 : this.depth; + //if(depth < 0 || depth > maxDepth) throw new IllegalArgumentException( + if(depth < 0 || depth > this.depth) throw new IllegalArgumentException( + "napespace count mayt be for depth 0.."+this.depth+" not "+depth); + return elNamespaceCount[ depth ]; + } + + public String getNamespacePrefix(int pos) + throws XmlPullParserException + { + + //int end = eventType == END_TAG ? elNamespaceCount[ depth + 1 ] : namespaceEnd; + //if(pos < end) { + if(pos < namespaceEnd) { + return namespacePrefix[ pos ]; + } else { + throw new XmlPullParserException( + "position "+pos+" exceeded number of available namespaces "+namespaceEnd); + } + } + + public String getNamespaceUri(int pos) throws XmlPullParserException + { + //int end = eventType == END_TAG ? elNamespaceCount[ depth + 1 ] : namespaceEnd; + //if(pos < end) { + if(pos < namespaceEnd) { + return namespaceUri[ pos ]; + } else { + throw new XmlPullParserException( + "position "+pos+" exceedded number of available namespaces "+namespaceEnd); + } + } + + public String getNamespace( String prefix ) + //throws XmlPullParserException + { + //int count = namespaceCount[ depth ]; + if(prefix != null) { + for( int i = namespaceEnd -1; i >= 0; i--) { + if( prefix.equals( namespacePrefix[ i ] ) ) { + return namespaceUri[ i ]; + } + } + if("xml".equals( prefix )) { + return XML_URI; + } else if("xmlns".equals( prefix )) { + return XMLNS_URI; + } + } else { + for( int i = namespaceEnd -1; i >= 0; i--) { + if( namespacePrefix[ i ] == null) { //"") { //null ) { //TODO check FIXME Alek + return namespaceUri[ i ]; + } + } + + } + return null; + } + + + public int getDepth() + { + return depth; + } + + + private static int findFragment(int bufMinPos, char[] b, int start, int end) { + //System.err.println("bufStart="+bufStart+" b="+printable(new String(b, start, end - start))+" start="+start+" end="+end); + if(start < bufMinPos) { + start = bufMinPos; + if(start > end) start = end; + return start; + } + if(end - start > 65) { + start = end - 10; // try to find good location + } + int i = start + 1; + while(--i > bufMinPos) { + if((end - i) > 65) break; + final char c = b[i]; + if(c == '<' && (start - i) > 10) break; + } + return i; + } + + + /** + * Return string describing current position of parsers as + * text 'STATE [seen %s...] @line:column'. + */ + public String getPositionDescription () + { + String fragment = null; + if(posStart <= pos) { + final int start = findFragment(0, buf, posStart, pos); + //System.err.println("start="+start); + if(start < pos) { + fragment = new String(buf, start, pos - start); + } + if(bufAbsoluteStart > 0 || start > 0) fragment = "..." + fragment; + } + // return " at line "+tokenizerPosRow + // +" and column "+(tokenizerPosCol-1) + // +(fragment != null ? " seen "+printable(fragment)+"..." : ""); + return " "+TYPES[ eventType ] + + (fragment != null ? " seen "+printable(fragment)+"..." : "") + +" "+(location != null ? location : "") + +"@"+getLineNumber()+":"+getColumnNumber(); + } + + public int getLineNumber() + { + return lineNumber; + } + + public int getColumnNumber() + { + return columnNumber; + } + + + public boolean isWhitespace() throws XmlPullParserException + { + if(eventType == TEXT || eventType == CDSECT) { + if(usePC) { + for (int i = pcStart; i = 0; i--) { + // if( prefix.equals( namespacePrefix[ i ] ) ) { + // return namespaceUri[ i ]; + // } + // } + // } else { + // for( int i = namespaceEnd -1; i >= 0; i--) { + // if( namespacePrefix[ i ] == null ) { + // return namespaceUri[ i ]; + // } + // } + // + // } + // return ""; + } + + public String getName() + { + if(eventType == START_TAG) { + //return elName[ depth - 1 ] ; + return elName[ depth ] ; + } else if(eventType == END_TAG) { + return elName[ depth ] ; + } else if(eventType == ENTITY_REF) { + if(entityRefName == null) { + entityRefName = newString(buf, posStart, posEnd - posStart); + } + return entityRefName; + } else { + return null; + } + } + + public String getPrefix() + { + if(eventType == START_TAG) { + //return elPrefix[ depth - 1 ] ; + return elPrefix[ depth ] ; + } else if(eventType == END_TAG) { + return elPrefix[ depth ] ; + } + return null; + // if(eventType != START_TAG && eventType != END_TAG) return null; + // int maxDepth = eventType == END_TAG ? depth : depth - 1; + // return elPrefix[ maxDepth ]; + } + + + public boolean isEmptyElementTag() throws XmlPullParserException + { + if(eventType != START_TAG) throw new XmlPullParserException( + "parser must be on START_TAG to check for empty element", this, null); + return emptyElementTag; + } + + public int getAttributeCount() + { + if(eventType != START_TAG) return -1; + return attributeCount; + } + + public String getAttributeNamespace(int index) + { + if(eventType != START_TAG) throw new IndexOutOfBoundsException( + "only START_TAG can have attributes"); + if(processNamespaces == false) return NO_NAMESPACE; + if(index < 0 || index >= attributeCount) throw new IndexOutOfBoundsException( + "attribute position must be 0.."+(attributeCount-1)+" and not "+index); + return attributeUri[ index ]; + } + + public String getAttributeName(int index) + { + if(eventType != START_TAG) throw new IndexOutOfBoundsException( + "only START_TAG can have attributes"); + if(index < 0 || index >= attributeCount) throw new IndexOutOfBoundsException( + "attribute position must be 0.."+(attributeCount-1)+" and not "+index); + return attributeName[ index ]; + } + + public String getAttributePrefix(int index) + { + if(eventType != START_TAG) throw new IndexOutOfBoundsException( + "only START_TAG can have attributes"); + if(processNamespaces == false) return null; + if(index < 0 || index >= attributeCount) throw new IndexOutOfBoundsException( + "attribute position must be 0.."+(attributeCount-1)+" and not "+index); + return attributePrefix[ index ]; + } + + public String getAttributeType(int index) { + if(eventType != START_TAG) throw new IndexOutOfBoundsException( + "only START_TAG can have attributes"); + if(index < 0 || index >= attributeCount) throw new IndexOutOfBoundsException( + "attribute position must be 0.."+(attributeCount-1)+" and not "+index); + return "CDATA"; + } + + public boolean isAttributeDefault(int index) { + if(eventType != START_TAG) throw new IndexOutOfBoundsException( + "only START_TAG can have attributes"); + if(index < 0 || index >= attributeCount) throw new IndexOutOfBoundsException( + "attribute position must be 0.."+(attributeCount-1)+" and not "+index); + return false; + } + + public String getAttributeValue(int index) + { + if(eventType != START_TAG) throw new IndexOutOfBoundsException( + "only START_TAG can have attributes"); + if(index < 0 || index >= attributeCount) throw new IndexOutOfBoundsException( + "attribute position must be 0.."+(attributeCount-1)+" and not "+index); + return attributeValue[ index ]; + } + + public String getAttributeValue(String namespace, + String name) + { + if(eventType != START_TAG) throw new IndexOutOfBoundsException( + "only START_TAG can have attributes"+getPositionDescription()); + if(name == null) { + throw new IllegalArgumentException("attribute name can not be null"); + } + // TODO make check if namespace is interned!!! etc. for names!!! + if(processNamespaces) { + if(namespace == null) { + namespace = ""; + } + + for(int i = 0; i < attributeCount; ++i) { + if((namespace == attributeUri[ i ] || + namespace.equals(attributeUri[ i ]) ) + //(namespace != null && namespace.equals(attributeUri[ i ])) + // taking advantage of String.intern() + && name.equals(attributeName[ i ]) ) + { + return attributeValue[i]; + } + } + } else { + if(namespace != null && namespace.length() == 0) { + namespace = null; + } + if(namespace != null) throw new IllegalArgumentException( + "when namespaces processing is disabled attribute namespace must be null"); + for(int i = 0; i < attributeCount; ++i) { + if(name.equals(attributeName[i])) + { + return attributeValue[i]; + } + } + } + return null; + } + + + public int getEventType() + throws XmlPullParserException + { + return eventType; + } + + public void require(int type, String namespace, String name) + throws XmlPullParserException, IOException + { + if(processNamespaces == false && namespace != null) { + throw new XmlPullParserException( + "processing namespaces must be enabled on parser (or factory)"+ + " to have possible namespaces delcared on elements" + +(" (postion:"+ getPositionDescription())+")"); + } + if (type != getEventType() + || (namespace != null && !namespace.equals (getNamespace())) + || (name != null && !name.equals (getName ())) ) + { + throw new XmlPullParserException ( + "expected event "+TYPES[ type ] + +(name != null ? " with name '"+name+"'" : "") + +(namespace != null && name != null ? " and" : "") + +(namespace != null ? " with namespace '"+namespace+"'" : "") + +" but got" + +(type != getEventType() ? " "+TYPES[ getEventType() ] : "") + +(name != null && getName() != null && !name.equals (getName ()) + ? " name '"+getName()+"'" : "") + +(namespace != null && name != null + && getName() != null && !name.equals (getName ()) + && getNamespace() != null && !namespace.equals (getNamespace()) + ? " and" : "") + +(namespace != null && getNamespace() != null && !namespace.equals (getNamespace()) + ? " namespace '"+getNamespace()+"'" : "") + +(" (postion:"+ getPositionDescription())+")"); + } + } + + + /** + * Skip sub tree that is currently porser positioned on. + *
NOTE: parser must be on START_TAG and when funtion returns + * parser will be positioned on corresponding END_TAG + */ + public void skipSubTree() + throws XmlPullParserException, IOException + { + require(START_TAG, null, null); + int level = 1; + while(level > 0) { + int eventType = next(); + if(eventType == END_TAG) { + --level; + } else if(eventType == START_TAG) { + ++level; + } + } + } + + // public String readText() throws XmlPullParserException, IOException + // { + // if (getEventType() != TEXT) return ""; + // String result = getText(); + // next(); + // return result; + // } + + public String nextText() throws XmlPullParserException, IOException + { + // String result = null; + // boolean onStartTag = false; + // if(eventType == START_TAG) { + // onStartTag = true; + // next(); + // } + // if(eventType == TEXT) { + // result = getText(); + // next(); + // } else if(onStartTag && eventType == END_TAG) { + // result = ""; + // } else { + // throw new XmlPullParserException( + // "parser must be on START_TAG or TEXT to read text", this, null); + // } + // if(eventType != END_TAG) { + // throw new XmlPullParserException( + // "event TEXT it must be immediately followed by END_TAG", this, null); + // } + // return result; + if(getEventType() != START_TAG) { + throw new XmlPullParserException( + "parser must be on START_TAG to read next text", this, null); + } + int eventType = next(); + if(eventType == TEXT) { + final String result = getText(); + eventType = next(); + if(eventType != END_TAG) { + throw new XmlPullParserException( + "TEXT must be immediately followed by END_TAG and not " + +TYPES[ getEventType() ], this, null); + } + return result; + } else if(eventType == END_TAG) { + return ""; + } else { + throw new XmlPullParserException( + "parser must be on START_TAG or TEXT to read text", this, null); + } + } + + public int nextTag() throws XmlPullParserException, IOException + { + next(); + if(eventType == TEXT && isWhitespace()) { // skip whitespace + next(); + } + if (eventType != START_TAG && eventType != END_TAG) { + throw new XmlPullParserException("expected START_TAG or END_TAG not " + +TYPES[ getEventType() ], this, null); + } + return eventType; + } + + public int next() + throws XmlPullParserException, IOException + { + tokenize = false; + return nextImpl(); + } + + public int nextToken() + throws XmlPullParserException, IOException + { + tokenize = true; + return nextImpl(); + } + + + protected int nextImpl() + throws XmlPullParserException, IOException + { + text = null; + pcEnd = pcStart = 0; + usePC = false; + bufStart = posEnd; + if(pastEndTag) { + pastEndTag = false; + --depth; + namespaceEnd = elNamespaceCount[ depth ]; // less namespaces available + } + if(emptyElementTag) { + emptyElementTag = false; + pastEndTag = true; + return eventType = END_TAG; + } + + // [1] document ::= prolog element Misc* + if(depth > 0) { + + if(seenStartTag) { + seenStartTag = false; + return eventType = parseStartTag(); + } + if(seenEndTag) { + seenEndTag = false; + return eventType = parseEndTag(); + } + + // ASSUMPTION: we are _on_ first character of content or markup!!!! + // [43] content ::= CharData? ((element | Reference | CDSect | PI | Comment) CharData?)* + char ch; + if(seenMarkup) { // we have read ahead ... + seenMarkup = false; + ch = '<'; + } else if(seenAmpersand) { + seenAmpersand = false; + ch = '&'; + } else { + ch = more(); + } + posStart = pos - 1; // VERY IMPORTANT: this is correct start of event!!! + + // when true there is some potential event TEXT to return - keep gathering + boolean hadCharData = false; + + // when true TEXT data is not continuous (like ) and requires PC merging + boolean needsMerging = false; + + MAIN_LOOP: + while(true) { + // work on MARKUP + if(ch == '<') { + if(hadCharData) { + //posEnd = pos - 1; + if(tokenize) { + seenMarkup = true; + return eventType = TEXT; + } + } + ch = more(); + if(ch == '/') { + if(!tokenize && hadCharData) { + seenEndTag = true; + //posEnd = pos - 2; + return eventType = TEXT; + } + return eventType = parseEndTag(); + } else if(ch == '!') { + ch = more(); + if(ch == '-') { + // note: if(tokenize == false) posStart/End is NOT changed!!!! + parseComment(); + if(tokenize) return eventType = COMMENT; + if( !usePC && hadCharData ) { + needsMerging = true; + } else { + posStart = pos; //completely ignore comment + } + } else if(ch == '[') { + //posEnd = pos - 3; + // must remember previous posStart/End as it merges with content of CDATA + //int oldStart = posStart + bufAbsoluteStart; + //int oldEnd = posEnd + bufAbsoluteStart; + parseCDSect(hadCharData); + if(tokenize) return eventType = CDSECT; + final int cdStart = posStart; + final int cdEnd = posEnd; + final int cdLen = cdEnd - cdStart; + + + if(cdLen > 0) { // was there anything inside CDATA section? + hadCharData = true; + if(!usePC) { + needsMerging = true; + } + } + + // posStart = oldStart; + // posEnd = oldEnd; + // if(cdLen > 0) { // was there anything inside CDATA section? + // if(hadCharData) { + // // do merging if there was anything in CDSect!!!! + // // if(!usePC) { + // // // posEnd is correct already!!! + // // if(posEnd > posStart) { + // // joinPC(); + // // } else { + // // usePC = true; + // // pcStart = pcEnd = 0; + // // } + // // } + // // if(pcEnd + cdLen >= pc.length) ensurePC(pcEnd + cdLen); + // // // copy [cdStart..cdEnd) into PC + // // System.arraycopy(buf, cdStart, pc, pcEnd, cdLen); + // // pcEnd += cdLen; + // if(!usePC) { + // needsMerging = true; + // posStart = cdStart; + // posEnd = cdEnd; + // } + // } else { + // if(!usePC) { + // needsMerging = true; + // posStart = cdStart; + // posEnd = cdEnd; + // hadCharData = true; + // } + // } + // //hadCharData = true; + // } else { + // if( !usePC && hadCharData ) { + // needsMerging = true; + // } + // } + } else { + throw new XmlPullParserException( + "unexpected character in markup "+printable(ch), this, null); + } + } else if(ch == '?') { + parsePI(); + if(tokenize) return eventType = PROCESSING_INSTRUCTION; + if( !usePC && hadCharData ) { + needsMerging = true; + } else { + posStart = pos; //completely ignore PI + } + + } else if( isNameStartChar(ch) ) { + if(!tokenize && hadCharData) { + seenStartTag = true; + //posEnd = pos - 2; + return eventType = TEXT; + } + return eventType = parseStartTag(); + } else { + throw new XmlPullParserException( + "unexpected character in markup "+printable(ch), this, null); + } + // do content comapctation if it makes sense!!!! + + } else if(ch == '&') { + // work on ENTITTY + //posEnd = pos - 1; + if(tokenize && hadCharData) { + seenAmpersand = true; + return eventType = TEXT; + } + final int oldStart = posStart + bufAbsoluteStart; + final int oldEnd = posEnd + bufAbsoluteStart; + final char[] resolvedEntity = parseEntityRef(); + if(tokenize) return eventType = ENTITY_REF; + // check if replacement text can be resolved !!! + if(resolvedEntity == null) { + if(entityRefName == null) { + entityRefName = newString(buf, posStart, posEnd - posStart); + } + throw new XmlPullParserException( + "could not resolve entity named '"+printable(entityRefName)+"'", + this, null); + } + //int entStart = posStart; + //int entEnd = posEnd; + posStart = oldStart - bufAbsoluteStart; + posEnd = oldEnd - bufAbsoluteStart; + if(!usePC) { + if(hadCharData) { + joinPC(); // posEnd is already set correctly!!! + needsMerging = false; + } else { + usePC = true; + pcStart = pcEnd = 0; + } + } + //assert usePC == true; + // write into PC replacement text - do merge for replacement text!!!! + for (char aResolvedEntity : resolvedEntity) { + if (pcEnd >= pc.length) ensurePC(pcEnd); + pc[pcEnd++] = aResolvedEntity; + + } + hadCharData = true; + //assert needsMerging == false; + } else { + + if(needsMerging) { + //assert usePC == false; + joinPC(); // posEnd is already set correctly!!! + //posStart = pos - 1; + needsMerging = false; + } + + + //no MARKUP not ENTITIES so work on character data ... + + + + // [14] CharData ::= [^<&]* - ([^<&]* ']]>' [^<&]*) + + + hadCharData = true; + + boolean normalizedCR = false; + final boolean normalizeInput = tokenize == false || roundtripSupported == false; + // use loop locality here!!!! + boolean seenBracket = false; + boolean seenBracketBracket = false; + do { + + // check that ]]> does not show in + if(ch == ']') { + if(seenBracket) { + seenBracketBracket = true; + } else { + seenBracket = true; + } + } else if(seenBracketBracket && ch == '>') { + throw new XmlPullParserException( + "characters ]]> are not allowed in content", this, null); + } else { + if(seenBracket) { + seenBracketBracket = seenBracket = false; + } + // assert seenTwoBrackets == seenBracket == false; + } + if(normalizeInput) { + // deal with normalization issues ... + if(ch == '\r') { + normalizedCR = true; + posEnd = pos -1; + // posEnd is already set + if(!usePC) { + if(posEnd > posStart) { + joinPC(); + } else { + usePC = true; + pcStart = pcEnd = 0; + } + } + //assert usePC == true; + if(pcEnd >= pc.length) ensurePC(pcEnd); + pc[pcEnd++] = '\n'; + } else if(ch == '\n') { + // if(!usePC) { joinPC(); } else { if(pcEnd >= pc.length) ensurePC(); } + if(!normalizedCR && usePC) { + if(pcEnd >= pc.length) ensurePC(pcEnd); + pc[pcEnd++] = '\n'; + } + normalizedCR = false; + } else { + if(usePC) { + if(pcEnd >= pc.length) ensurePC(pcEnd); + pc[pcEnd++] = ch; + } + normalizedCR = false; + } + } + + ch = more(); + } while(ch != '<' && ch != '&'); + posEnd = pos - 1; + continue MAIN_LOOP; // skip ch = more() from below - we are already ahead ... + } + ch = more(); + } // endless while(true) + } else { + if(seenRoot) { + return parseEpilog(); + } else { + return parseProlog(); + } + } + } + + + protected int parseProlog() + throws XmlPullParserException, IOException + { + // [2] prolog: ::= XMLDecl? Misc* (doctypedecl Misc*)? and look for [39] element + + char ch; + if(seenMarkup) { + ch = buf[ pos - 1 ]; + } else { + ch = more(); + } + + if(eventType == START_DOCUMENT) { + // bootstrap parsing with getting first character input! + // deal with BOM + // detect BOM and crop it (Unicode int Order Mark) + if(ch == '\uFFFE') { + throw new XmlPullParserException( + "first character in input was UNICODE noncharacter (0xFFFE)"+ + "- input requires int swapping", this, null); + } + if(ch == '\uFEFF') { + // skipping UNICODE int Order Mark (so called BOM) + ch = more(); + } + } + seenMarkup = false; + boolean gotS = false; + posStart = pos - 1; + final boolean normalizeIgnorableWS = tokenize == true && roundtripSupported == false; + boolean normalizedCR = false; + while(true) { + // deal with Misc + // [27] Misc ::= Comment | PI | S + // deal with docdecl --> mark it! + // else parseStartTag seen <[^/] + if(ch == '<') { + if(gotS && tokenize) { + posEnd = pos - 1; + seenMarkup = true; + return eventType = IGNORABLE_WHITESPACE; + } + ch = more(); + if(ch == '?') { + // check if it is 'xml' + // deal with XMLDecl + boolean isXMLDecl = parsePI(); + if(tokenize) { + if (isXMLDecl) { + return eventType = START_DOCUMENT; + } + return eventType = PROCESSING_INSTRUCTION; + } + } else if(ch == '!') { + ch = more(); + if(ch == 'D') { + if(seenDocdecl) { + throw new XmlPullParserException( + "only one docdecl allowed in XML document", this, null); + } + seenDocdecl = true; + parseDocdecl(); + if(tokenize) return eventType = DOCDECL; + } else if(ch == '-') { + parseComment(); + if(tokenize) return eventType = COMMENT; + } else { + throw new XmlPullParserException( + "unexpected markup posStart) { + joinPC(); + } else { + usePC = true; + pcStart = pcEnd = 0; + } + } + //assert usePC == true; + if(pcEnd >= pc.length) ensurePC(pcEnd); + pc[pcEnd++] = '\n'; + } else if(ch == '\n') { + if(!normalizedCR && usePC) { + if(pcEnd >= pc.length) ensurePC(pcEnd); + pc[pcEnd++] = '\n'; + } + normalizedCR = false; + } else { + if(usePC) { + if(pcEnd >= pc.length) ensurePC(pcEnd); + pc[pcEnd++] = ch; + } + normalizedCR = false; + } + } + } else { + throw new XmlPullParserException( + "only whitespace content allowed before start tag and not "+printable(ch), + this, null); + } + ch = more(); + } + } + + protected int parseEpilog() + throws XmlPullParserException, IOException + { + if(eventType == END_DOCUMENT) { + throw new XmlPullParserException("already reached end of XML input", this, null); + } + if(reachedEnd) { + return eventType = END_DOCUMENT; + } + boolean gotS = false; + final boolean normalizeIgnorableWS = tokenize == true && roundtripSupported == false; + boolean normalizedCR = false; + try { + // epilog: Misc* + char ch; + if(seenMarkup) { + ch = buf[ pos - 1 ]; + } else { + ch = more(); + } + seenMarkup = false; + posStart = pos - 1; + if(!reachedEnd) { + while(true) { + // deal with Misc + // [27] Misc ::= Comment | PI | S + if(ch == '<') { + if(gotS && tokenize) { + posEnd = pos - 1; + seenMarkup = true; + return eventType = IGNORABLE_WHITESPACE; + } + ch = more(); + if(reachedEnd) { + break; + } + if(ch == '?') { + // check if it is 'xml' + // deal with XMLDecl + parsePI(); + if(tokenize) return eventType = PROCESSING_INSTRUCTION; + + } else if(ch == '!') { + ch = more(); + if(reachedEnd) { + break; + } + if(ch == 'D') { + parseDocdecl(); //FIXME + if(tokenize) return eventType = DOCDECL; + } else if(ch == '-') { + parseComment(); + if(tokenize) return eventType = COMMENT; + } else { + throw new XmlPullParserException( + "unexpected markup posStart) { + joinPC(); + } else { + usePC = true; + pcStart = pcEnd = 0; + } + } + //assert usePC == true; + if(pcEnd >= pc.length) ensurePC(pcEnd); + pc[pcEnd++] = '\n'; + } else if(ch == '\n') { + if(!normalizedCR && usePC) { + if(pcEnd >= pc.length) ensurePC(pcEnd); + pc[pcEnd++] = '\n'; + } + normalizedCR = false; + } else { + if(usePC) { + if(pcEnd >= pc.length) ensurePC(pcEnd); + pc[pcEnd++] = ch; + } + normalizedCR = false; + } + } + } else { + throw new XmlPullParserException( + "in epilog non whitespace content is not allowed but got "+printable(ch), + this, null); + } + ch = more(); + if(reachedEnd) { + break; + } + + } + } + + // throw Exception("unexpected content in epilog + // catch EOFException return END_DOCUMENT + //try { + } catch(EOFException ex) { + reachedEnd = true; + } + if(reachedEnd) { + if(tokenize && gotS) { + posEnd = pos; // well - this is LAST available character pos + return eventType = IGNORABLE_WHITESPACE; + } + return eventType = END_DOCUMENT; + } else { + throw new XmlPullParserException("internal error in parseEpilog"); + } + } + + + public int parseEndTag() throws XmlPullParserException, IOException { + //ASSUMPTION ch is past "' + char ch = more(); + if(!isNameStartChar(ch)) { + throw new XmlPullParserException( + "expected name start and not "+printable(ch), this, null); + } + posStart = pos - 3; + final int nameStart = pos - 1 + bufAbsoluteStart; + do { + ch = more(); + } while(isNameChar(ch)); + + // now we go one level down -- do checks + //--depth; //FIXME + + // check that end tag name is the same as start tag + //String name = new String(buf, nameStart - bufAbsoluteStart, + // (pos - 1) - (nameStart - bufAbsoluteStart)); + //int last = pos - 1; + int off = nameStart - bufAbsoluteStart; + //final int len = last - off; + final int len = (pos - 1) - off; + final char[] cbuf = elRawName[depth]; + if(elRawNameEnd[depth] != len) { + // construct strings for exception + final String startname = new String(cbuf, 0, elRawNameEnd[depth]); + final String endname = new String(buf, off, len); + throw new XmlPullParserException( + "end tag name must match start tag name <"+startname+">" + +" from line "+elRawNameLine[depth], this, null); + } + for (int i = 0; i < len; i++) + { + if(buf[off++] != cbuf[i]) { + // construct strings for exception + final String startname = new String(cbuf, 0, len); + final String endname = new String(buf, off - i - 1, len); + throw new XmlPullParserException( + "end tag name must be the same as start tag <"+startname+">" + +" from line "+elRawNameLine[depth], this, null); + } + } + + while(isS(ch)) { ch = more(); } // skip additional white spaces + if(ch != '>') { + throw new XmlPullParserException( + "expected > to finsh end tag not "+printable(ch) + +" from line "+elRawNameLine[depth], this, null); + } + + + //namespaceEnd = elNamespaceCount[ depth ]; //FIXME + + posEnd = pos; + pastEndTag = true; + return eventType = END_TAG; + } + + public int parseStartTag() throws XmlPullParserException, IOException { + //ASSUMPTION ch is past ' + // [44] EmptyElemTag ::= '<' Name (S Attribute)* S? '/>' + ++depth; //FIXME + + posStart = pos - 2; + + emptyElementTag = false; + attributeCount = 0; + // retrieve name + final int nameStart = pos - 1 + bufAbsoluteStart; + int colonPos = -1; + char ch = buf[ pos - 1]; + if(ch == ':' && processNamespaces) throw new XmlPullParserException( + "when namespaces processing enabled colon can not be at element name start", + this, null); + while(true) { + ch = more(); + if(!isNameChar(ch)) break; + if(ch == ':' && processNamespaces) { + if(colonPos != -1) throw new XmlPullParserException( + "only one colon is allowed in name of element when namespaces are enabled", + this, null); + colonPos = pos - 1 + bufAbsoluteStart; + } + } + + // retrieve name + ensureElementsCapacity(); + + + //TODO check for efficient interning and then use elRawNameInterned!!!! + + int elLen = (pos - 1) - (nameStart - bufAbsoluteStart); + if(elRawName[ depth ] == null || elRawName[ depth ].length < elLen) { + elRawName[ depth ] = new char[ 2 * elLen ]; + } + System.arraycopy(buf, nameStart - bufAbsoluteStart, elRawName[ depth ], 0, elLen); + elRawNameEnd[ depth ] = elLen; + elRawNameLine[ depth ] = lineNumber; + + String name = null; + + // work on prefixes and namespace URI + String prefix = null; + if(processNamespaces) { + if(colonPos != -1) { + prefix = elPrefix[ depth ] = newString(buf, nameStart - bufAbsoluteStart, + colonPos - nameStart); + name = elName[ depth ] = newString(buf, colonPos + 1 - bufAbsoluteStart, + //(pos -1) - (colonPos + 1)); + pos - 2 - (colonPos - bufAbsoluteStart)); + } else { + prefix = elPrefix[ depth ] = null; + name = elName[ depth ] = newString(buf, nameStart - bufAbsoluteStart, elLen); + } + } else { + + name = elName[ depth ] = newString(buf, nameStart - bufAbsoluteStart, elLen); + + } + + + while(true) { + + while(isS(ch)) { ch = more(); } // skip additional white spaces + + if(ch == '>') { + break; + } else if(ch == '/') { + if(emptyElementTag) throw new XmlPullParserException( + "repeated / in tag declaration", this, null); + emptyElementTag = true; + ch = more(); + if(ch != '>') throw new XmlPullParserException( + "expected > to end empty tag not "+printable(ch), this, null); + break; + } else if(isNameStartChar(ch)) { + ch = parseAttribute(); + ch = more(); + continue; + } else { + throw new XmlPullParserException( + "start tag unexpected character "+printable(ch), this, null); + } + //ch = more(); // skip space + } + + // now when namespaces were declared we can resolve them + if(processNamespaces) { + String uri = getNamespace(prefix); + if(uri == null) { + if(prefix == null) { // no prefix and no uri => use default namespace + uri = NO_NAMESPACE; + } else { + throw new XmlPullParserException( + "could not determine namespace bound to element prefix "+prefix, + this, null); + } + + } + elUri[ depth ] = uri; + + + //String uri = getNamespace(prefix); + //if(uri == null && prefix == null) { // no prefix and no uri => use default namespace + // uri = ""; + //} + // resolve attribute namespaces + for (int i = 0; i < attributeCount; i++) + { + final String attrPrefix = attributePrefix[ i ]; + if(attrPrefix != null) { + final String attrUri = getNamespace(attrPrefix); + if(attrUri == null) { + throw new XmlPullParserException( + "could not determine namespace bound to attribute prefix "+attrPrefix, + this, null); + + } + attributeUri[ i ] = attrUri; + } else { + attributeUri[ i ] = NO_NAMESPACE; + } + } + + //TODO + //[ WFC: Unique Att Spec ] + // check namespaced attribute uniqueness contraint!!! + + for (int i = 1; i < attributeCount; i++) + { + for (int j = 0; j < i; j++) + { + if( attributeUri[j] == attributeUri[i] + && (allStringsInterned && attributeName[j].equals(attributeName[i]) + || (!allStringsInterned + && attributeNameHash[ j ] == attributeNameHash[ i ] + && attributeName[j].equals(attributeName[i])) ) + + ) { + // prepare data for nice error messgae? + String attr1 = attributeName[j]; + if(attributeUri[j] != null) attr1 = attributeUri[j]+":"+attr1; + String attr2 = attributeName[i]; + if(attributeUri[i] != null) attr2 = attributeUri[i]+":"+attr2; + throw new XmlPullParserException( + "duplicated attributes "+attr1+" and "+attr2, this, null); + } + } + } + + + } else { // ! processNamespaces + + //[ WFC: Unique Att Spec ] + // check raw attribute uniqueness contraint!!! + for (int i = 1; i < attributeCount; i++) + { + for (int j = 0; j < i; j++) + { + if((allStringsInterned && attributeName[j].equals(attributeName[i]) + || (!allStringsInterned + && attributeNameHash[ j ] == attributeNameHash[ i ] + && attributeName[j].equals(attributeName[i])) ) + + ) { + // prepare data for nice error messgae? + final String attr1 = attributeName[j]; + final String attr2 = attributeName[i]; + throw new XmlPullParserException( + "duplicated attributes "+attr1+" and "+attr2, this, null); + } + } + } + } + + elNamespaceCount[ depth ] = namespaceEnd; + posEnd = pos; + return eventType = START_TAG; + } + + protected char parseAttribute() throws XmlPullParserException, IOException + { + // parse attribute + // [41] Attribute ::= Name Eq AttValue + // [WFC: No External Entity References] + // [WFC: No < in Attribute Values] + final int prevPosStart = posStart + bufAbsoluteStart; + final int nameStart = pos - 1 + bufAbsoluteStart; + int colonPos = -1; + char ch = buf[ pos - 1 ]; + if(ch == ':' && processNamespaces) throw new XmlPullParserException( + "when namespaces processing enabled colon can not be at attribute name start", + this, null); + + + boolean startsWithXmlns = processNamespaces && ch == 'x'; + int xmlnsPos = 0; + + ch = more(); + while(isNameChar(ch)) { + if(processNamespaces) { + if(startsWithXmlns && xmlnsPos < 5) { + ++xmlnsPos; + if(xmlnsPos == 1) { if(ch != 'm') startsWithXmlns = false; } + else if(xmlnsPos == 2) { if(ch != 'l') startsWithXmlns = false; } + else if(xmlnsPos == 3) { if(ch != 'n') startsWithXmlns = false; } + else if(xmlnsPos == 4) { if(ch != 's') startsWithXmlns = false; } + else if(xmlnsPos == 5) { + if(ch != ':') throw new XmlPullParserException( + "after xmlns in attribute name must be colon" + +"when namespaces are enabled", this, null); + //colonPos = pos - 1 + bufAbsoluteStart; + } + } + if(ch == ':') { + if(colonPos != -1) throw new XmlPullParserException( + "only one colon is allowed in attribute name" + +" when namespaces are enabled", this, null); + colonPos = pos - 1 + bufAbsoluteStart; + } + } + ch = more(); + } + + ensureAttributesCapacity(attributeCount); + + // --- start processing attributes + String name = null; + String prefix = null; + // work on prefixes and namespace URI + if(processNamespaces) { + if(xmlnsPos < 4) startsWithXmlns = false; + if(startsWithXmlns) { + if(colonPos != -1) { + //prefix = attributePrefix[ attributeCount ] = null; + final int nameLen = pos - 2 - (colonPos - bufAbsoluteStart); + if(nameLen == 0) { + throw new XmlPullParserException( + "namespace prefix is required after xmlns: " + +" when namespaces are enabled", this, null); + } + name = //attributeName[ attributeCount ] = + newString(buf, colonPos - bufAbsoluteStart + 1, nameLen); + //pos - 1 - (colonPos + 1 - bufAbsoluteStart) + } + } else { + if(colonPos != -1) { + int prefixLen = colonPos - nameStart; + prefix = attributePrefix[ attributeCount ] = + newString(buf, nameStart - bufAbsoluteStart,prefixLen); + //colonPos - (nameStart - bufAbsoluteStart)); + int nameLen = pos - 2 - (colonPos - bufAbsoluteStart); + name = attributeName[ attributeCount ] = + newString(buf, colonPos - bufAbsoluteStart + 1, nameLen); + //pos - 1 - (colonPos + 1 - bufAbsoluteStart)); + + //name.substring(0, colonPos-nameStart); + } else { + prefix = attributePrefix[ attributeCount ] = null; + name = attributeName[ attributeCount ] = + newString(buf, nameStart - bufAbsoluteStart, + pos - 1 - (nameStart - bufAbsoluteStart)); + } + if(!allStringsInterned) { + attributeNameHash[ attributeCount ] = name.hashCode(); + } + } + + } else { + // retrieve name + name = attributeName[ attributeCount ] = + newString(buf, nameStart - bufAbsoluteStart, + pos - 1 - (nameStart - bufAbsoluteStart)); + ////assert name != null; + if(!allStringsInterned) { + attributeNameHash[ attributeCount ] = name.hashCode(); + } + } + + // [25] Eq ::= S? '=' S? + while(isS(ch)) { ch = more(); } // skip additional spaces + if(ch != '=') throw new XmlPullParserException( + "expected = after attribute name", this, null); + ch = more(); + while(isS(ch)) { ch = more(); } // skip additional spaces + + // [10] AttValue ::= '"' ([^<&"] | Reference)* '"' + // | "'" ([^<&'] | Reference)* "'" + final char delimit = ch; + if(delimit != '"' && delimit != '\'') throw new XmlPullParserException( + "attribute value must start with quotation or apostrophe not " + +printable(delimit), this, null); + // parse until delimit or < and resolve Reference + //[67] Reference ::= EntityRef | CharRef + //int valueStart = pos + bufAbsoluteStart; + + + boolean normalizedCR = false; + usePC = false; + pcStart = pcEnd; + posStart = pos; + + while(true) { + ch = more(); + if(ch == delimit) { + break; + } if(ch == '<') { + throw new XmlPullParserException( + "markup not allowed inside attribute value - illegal < ", this, null); + } if(ch == '&') { + // extractEntityRef + posEnd = pos - 1; + if(!usePC) { + final boolean hadCharData = posEnd > posStart; + if(hadCharData) { + // posEnd is already set correctly!!! + joinPC(); + } else { + usePC = true; + pcStart = pcEnd = 0; + } + } + //assert usePC == true; + + final char[] resolvedEntity = parseEntityRef(); + // check if replacement text can be resolved !!! + if(resolvedEntity == null) { + if(entityRefName == null) { + entityRefName = newString(buf, posStart, posEnd - posStart); + } + throw new XmlPullParserException( + "could not resolve entity named '"+printable(entityRefName)+"'", + this, null); + } + // write into PC replacement text - do merge for replacement text!!!! + for (char aResolvedEntity : resolvedEntity) { + if (pcEnd >= pc.length) ensurePC(pcEnd); + pc[pcEnd++] = aResolvedEntity; + } + } else if(ch == '\t' || ch == '\n' || ch == '\r') { + // do attribute value normalization + // as described in http://www.w3.org/TR/REC-xml#AVNormalize + // TODO add test for it form spec ... + // handle EOL normalization ... + if(!usePC) { + posEnd = pos - 1; + if(posEnd > posStart) { + joinPC(); + } else { + usePC = true; + pcEnd = pcStart = 0; + } + } + //assert usePC == true; + if(pcEnd >= pc.length) ensurePC(pcEnd); + if(ch != '\n' || !normalizedCR) { + pc[pcEnd++] = ' '; //'\n'; + } + + } else { + if(usePC) { + if(pcEnd >= pc.length) ensurePC(pcEnd); + pc[pcEnd++] = ch; + } + } + normalizedCR = ch == '\r'; + } + + + if(processNamespaces && startsWithXmlns) { + String ns = null; + if(!usePC) { + ns = newStringIntern(buf, posStart, pos - 1 - posStart); + } else { + ns = newStringIntern(pc, pcStart, pcEnd - pcStart); + } + ensureNamespacesCapacity(namespaceEnd); + int prefixHash = -1; + if(colonPos != -1) { + if(ns.length() == 0) { + throw new XmlPullParserException( + "non-default namespace can not be declared to be empty string", this, null); + } + // declare new namespace + namespacePrefix[ namespaceEnd ] = name; + if(!allStringsInterned) { + prefixHash = namespacePrefixHash[ namespaceEnd ] = name.hashCode(); + } + } else { + // declare new default namespace... + namespacePrefix[ namespaceEnd ] = null; //""; //null; //TODO check FIXME Alek + if(!allStringsInterned) { + prefixHash = namespacePrefixHash[ namespaceEnd ] = -1; + } + } + namespaceUri[ namespaceEnd ] = ns; + + // detect duplicate namespace declarations!!! + final int startNs = elNamespaceCount[ depth - 1 ]; + for (int i = namespaceEnd - 1; i >= startNs; --i) + { + if(((allStringsInterned || name == null) && namespacePrefix[ i ] == name) + || (!allStringsInterned && name != null && + namespacePrefixHash[ i ] == prefixHash + && name.equals(namespacePrefix[ i ]) + )) + { + final String s = name == null ? "default" : "'"+name+"'"; + throw new XmlPullParserException( + "duplicated namespace declaration for "+s+" prefix", this, null); + } + } + + ++namespaceEnd; + + } else { + if(!usePC) { + attributeValue[ attributeCount ] = + new String(buf, posStart, pos - 1 - posStart); + } else { + attributeValue[ attributeCount ] = + new String(pc, pcStart, pcEnd - pcStart); + } + ++attributeCount; + } + posStart = prevPosStart - bufAbsoluteStart; + return ch; + } + + protected char[] charRefOneCharBuf = new char[1]; + + protected char[] parseEntityRef() + throws XmlPullParserException, IOException + { + // entity reference http://www.w3.org/TR/2000/REC-xml-20001006#NT-Reference + // [67] Reference ::= EntityRef | CharRef + + // ASSUMPTION just after & + entityRefName = null; + posStart = pos; + char ch = more(); + if(ch == '#') { + // parse character reference + char charRef = 0; + ch = more(); + if(ch == 'x') { + //encoded in hex + while(true) { + ch = more(); + if(ch >= '0' && ch <= '9') { + charRef = (char)(charRef * 16 + (ch - '0')); + } else if(ch >= 'a' && ch <= 'f') { + charRef = (char)(charRef * 16 + (ch - ('a' - 10))); + } else if(ch >= 'A' && ch <= 'F') { + charRef = (char)(charRef * 16 + (ch - ('A' - 10))); + } else if(ch == ';') { + break; + } else { + throw new XmlPullParserException( + "character reference (with hex value) may not contain " + +printable(ch), this, null); + } + } + } else { + // encoded in decimal + while(true) { + if(ch >= '0' && ch <= '9') { + charRef = (char)(charRef * 10 + (ch - '0')); + } else if(ch == ';') { + break; + } else { + throw new XmlPullParserException( + "character reference (with decimal value) may not contain " + +printable(ch), this, null); + } + ch = more(); + } + } + posEnd = pos - 1; + charRefOneCharBuf[0] = charRef; + if(tokenize) { + text = newString(charRefOneCharBuf, 0, 1); + } + return charRefOneCharBuf; + } else { + // [68] EntityRef ::= '&' Name ';' + // scan anem until ; + if(!isNameStartChar(ch)) { + throw new XmlPullParserException( + "entity reference names can not start with character '" + +printable(ch)+"'", this, null); + } + while(true) { + ch = more(); + if(ch == ';') { + break; + } + if(!isNameChar(ch)) { + throw new XmlPullParserException( + "entity reference name can not contain character " + +printable(ch)+"'", this, null); + } + } + posEnd = pos - 1; + // determine what name maps to + final int len = posEnd - posStart; + if(len == 2 && buf[posStart] == 'l' && buf[posStart+1] == 't') { + if(tokenize) { + text = "<"; + } + charRefOneCharBuf[0] = '<'; + return charRefOneCharBuf; + //if(paramPC || isParserTokenizing) { + // if(pcEnd >= pc.length) ensurePC(); + // pc[pcEnd++] = '<'; + //} + } else if(len == 3 && buf[posStart] == 'a' + && buf[posStart+1] == 'm' && buf[posStart+2] == 'p') { + if(tokenize) { + text = "&"; + } + charRefOneCharBuf[0] = '&'; + return charRefOneCharBuf; + } else if(len == 2 && buf[posStart] == 'g' && buf[posStart+1] == 't') { + if(tokenize) { + text = ">"; + } + charRefOneCharBuf[0] = '>'; + return charRefOneCharBuf; + } else if(len == 4 && buf[posStart] == 'a' && buf[posStart+1] == 'p' + && buf[posStart+2] == 'o' && buf[posStart+3] == 's') + { + if(tokenize) { + text = "'"; + } + charRefOneCharBuf[0] = '\''; + return charRefOneCharBuf; + } else if(len == 4 && buf[posStart] == 'q' && buf[posStart+1] == 'u' + && buf[posStart+2] == 'o' && buf[posStart+3] == 't') + { + if(tokenize) { + text = "\""; + } + charRefOneCharBuf[0] = '"'; + return charRefOneCharBuf; + } else { + final char[] result = lookuEntityReplacement(len); + if(result != null) { + return result; + } + } + if(tokenize) text = null; + return null; + } + } + + protected char[] lookuEntityReplacement(int entitNameLen) + throws XmlPullParserException, IOException + + { + if(!allStringsInterned) { + final int hash = fastHash(buf, posStart, posEnd - posStart); + LOOP: + for (int i = entityEnd - 1; i >= 0; --i) + { + if(hash == entityNameHash[ i ] && entitNameLen == entityNameBuf[ i ].length) { + final char[] entityBuf = entityNameBuf[ i ]; + for (int j = 0; j < entitNameLen; j++) + { + if(buf[posStart + j] != entityBuf[j]) continue LOOP; + } + if(tokenize) text = entityReplacement[ i ]; + return entityReplacementBuf[ i ]; + } + } + } else { + entityRefName = newString(buf, posStart, posEnd - posStart); + for (int i = entityEnd - 1; i >= 0; --i) + { + // take advantage that interning for newStirng is enforced + if(entityRefName == entityName[ i ]) { + if(tokenize) text = entityReplacement[ i ]; + return entityReplacementBuf[ i ]; + } + } + } + return null; + } + + + protected void parseComment() + throws XmlPullParserException, IOException + { + // implements XML 1.0 Section 2.5 Comments + + //ASSUMPTION: seen + ch = more(); + if(seenDashDash && ch != '>') { + throw new XmlPullParserException( + "in comment after two dashes (--) next character must be >" + +" not "+printable(ch), this, null); + } + if(ch == '-') { + if(!seenDash) { + seenDash = true; + } else { + seenDashDash = true; + seenDash = false; + } + } else if(ch == '>') { + if(seenDashDash) { + break; // found end sequence!!!! + } else { + seenDashDash = false; + } + seenDash = false; + } else { + seenDash = false; + } + if(normalizeIgnorableWS) { + if(ch == '\r') { + normalizedCR = true; + //posEnd = pos -1; + //joinPC(); + // posEnd is alreadys set + if(!usePC) { + posEnd = pos -1; + if(posEnd > posStart) { + joinPC(); + } else { + usePC = true; + pcStart = pcEnd = 0; + } + } + //assert usePC == true; + if(pcEnd >= pc.length) ensurePC(pcEnd); + pc[pcEnd++] = '\n'; + } else if(ch == '\n') { + if(!normalizedCR && usePC) { + if(pcEnd >= pc.length) ensurePC(pcEnd); + pc[pcEnd++] = '\n'; + } + normalizedCR = false; + } else { + if(usePC) { + if(pcEnd >= pc.length) ensurePC(pcEnd); + pc[pcEnd++] = ch; + } + normalizedCR = false; + } + } + } + + } catch(EOFException ex) { + // detect EOF and create meaningful error ... + throw new XmlPullParserException( + "comment started on line "+curLine+" and column "+curColumn+" was not closed", + this, ex); + } + if(tokenize) { + posEnd = pos - 3; + if(usePC) { + pcEnd -= 2; + } + } + } + + protected boolean parsePI() + throws XmlPullParserException, IOException + { + // implements XML 1.0 Section 2.6 Processing Instructions + + // [16] PI ::= '' Char*)))? '?>' + // [17] PITarget ::= Name - (('X' | 'x') ('M' | 'm') ('L' | 'l')) + //ASSUMPTION: seen + //ch = more(); + + if(ch == '?') { + seenQ = true; + } else if(ch == '>') { + if(seenQ) { + break; // found end sequence!!!! + } + seenQ = false; + } else { + if(piTargetEnd == -1 && isS(ch)) { + piTargetEnd = pos - 1 + bufAbsoluteStart; + + // [17] PITarget ::= Name - (('X' | 'x') ('M' | 'm') ('L' | 'l')) + if((piTargetEnd - piTargetStart) == 3) { + if((buf[piTargetStart] == 'x' || buf[piTargetStart] == 'X') + && (buf[piTargetStart+1] == 'm' || buf[piTargetStart+1] == 'M') + && (buf[piTargetStart+2] == 'l' || buf[piTargetStart+2] == 'L') + ) + { + if(piTargetStart > 3) { // posStart) { + joinPC(); + } else { + usePC = true; + pcStart = pcEnd = 0; + } + } + //assert usePC == true; + if(pcEnd >= pc.length) ensurePC(pcEnd); + pc[pcEnd++] = '\n'; + } else if(ch == '\n') { + if(!normalizedCR && usePC) { + if(pcEnd >= pc.length) ensurePC(pcEnd); + pc[pcEnd++] = '\n'; + } + normalizedCR = false; + } else { + if(usePC) { + if(pcEnd >= pc.length) ensurePC(pcEnd); + pc[pcEnd++] = ch; + } + normalizedCR = false; + } + } + ch = more(); + } + } catch(EOFException ex) { + // detect EOF and create meaningful error ... + throw new XmlPullParserException( + "processing instruction started on line "+curLine+" and column "+curColumn + +" was not closed", + this, ex); + } + if(piTargetEnd == -1) { + piTargetEnd = pos - 2 + bufAbsoluteStart; + //throw new XmlPullParserException( + // "processing instruction must have PITarget name", this, null); + } + piTargetStart -= bufAbsoluteStart; + piTargetEnd -= bufAbsoluteStart; + if(tokenize) { + posEnd = pos - 2; + if(normalizeIgnorableWS) { + --pcEnd; + } + } + return true; + } + + // protected final static char[] VERSION = {'v','e','r','s','i','o','n'}; + // protected final static char[] NCODING = {'n','c','o','d','i','n','g'}; + // protected final static char[] TANDALONE = {'t','a','n','d','a','l','o','n','e'}; + // protected final static char[] YES = {'y','e','s'}; + // protected final static char[] NO = {'n','o'}; + + protected final static char[] VERSION = "version".toCharArray(); + protected final static char[] NCODING = "ncoding".toCharArray(); + protected final static char[] TANDALONE = "tandalone".toCharArray(); + protected final static char[] YES = "yes".toCharArray(); + protected final static char[] NO = "no".toCharArray(); + + + + protected void parseXmlDecl(char ch) + throws XmlPullParserException, IOException + { + // [23] XMLDecl ::= '' + + // first make sure that relative positions will stay OK + preventBufferCompaction = true; + bufStart = 0; // necessary to keep pos unchanged during expansion! + + // --- parse VersionInfo + + // [24] VersionInfo ::= S 'version' Eq ("'" VersionNum "'" | '"' VersionNum '"') + // parse is positioned just on first S past 'z') && (ch < 'A' || ch > 'Z') && (ch < '0' || ch > '9') + && ch != '_' && ch != '.' && ch != ':' && ch != '-') + { + throw new XmlPullParserException( + " 'z') && (ch < 'A' || ch > 'Z')) + { + throw new XmlPullParserException( + " 'z') && (ch < 'A' || ch > 'Z') && (ch < '0' || ch > '9') + && ch != '.' && ch != '_' && ch != '-') + { + throw new XmlPullParserException( + " as last part of ') { + throw new XmlPullParserException( + "expected ?> as last part of ' + int bracketLevel = 0; + final boolean normalizeIgnorableWS = tokenize == true && roundtripSupported == false; + boolean normalizedCR = false; + while(true) { + ch = more(); + if(ch == '[') ++bracketLevel; + if(ch == ']') --bracketLevel; + if(ch == '>' && bracketLevel == 0) break; + if(normalizeIgnorableWS) { + if(ch == '\r') { + normalizedCR = true; + //posEnd = pos -1; + //joinPC(); + // posEnd is alreadys set + if(!usePC) { + posEnd = pos -1; + if(posEnd > posStart) { + joinPC(); + } else { + usePC = true; + pcStart = pcEnd = 0; + } + } + //assert usePC == true; + if(pcEnd >= pc.length) ensurePC(pcEnd); + pc[pcEnd++] = '\n'; + } else if(ch == '\n') { + if(!normalizedCR && usePC) { + if(pcEnd >= pc.length) ensurePC(pcEnd); + pc[pcEnd++] = '\n'; + } + normalizedCR = false; + } else { + if(usePC) { + if(pcEnd >= pc.length) ensurePC(pcEnd); + pc[pcEnd++] = ch; + } + normalizedCR = false; + } + } + + } + posEnd = pos - 1; + } + + protected void parseCDSect(boolean hadCharData) + throws XmlPullParserException, IOException + { + // implements XML 1.0 Section 2.7 CDATA Sections + + // [18] CDSect ::= CDStart CData CDEnd + // [19] CDStart ::= '' Char*)) + // [21] CDEnd ::= ']]>' + + //ASSUMPTION: seen posStart) { + joinPC(); + } else { + usePC = true; + pcStart = pcEnd = 0; + } + } + } + } + boolean seenBracket = false; + boolean seenBracketBracket = false; + boolean normalizedCR = false; + while(true) { + // scan until it hits "]]>" + ch = more(); + if(ch == ']') { + if(!seenBracket) { + seenBracket = true; + } else { + seenBracketBracket = true; + //seenBracket = false; + } + } else if(ch == '>') { + if(seenBracket && seenBracketBracket) { + break; // found end sequence!!!! + } else { + seenBracketBracket = false; + } + seenBracket = false; + } else { + if(seenBracket) { + seenBracket = false; + } + } + if(normalizeInput) { + // deal with normalization issues ... + if(ch == '\r') { + normalizedCR = true; + posStart = cdStart - bufAbsoluteStart; + posEnd = pos - 1; // posEnd is alreadys set + if(!usePC) { + if(posEnd > posStart) { + joinPC(); + } else { + usePC = true; + pcStart = pcEnd = 0; + } + } + //assert usePC == true; + if(pcEnd >= pc.length) ensurePC(pcEnd); + pc[pcEnd++] = '\n'; + } else if(ch == '\n') { + if(!normalizedCR && usePC) { + if(pcEnd >= pc.length) ensurePC(pcEnd); + pc[pcEnd++] = '\n'; + } + normalizedCR = false; + } else { + if(usePC) { + if(pcEnd >= pc.length) ensurePC(pcEnd); + pc[pcEnd++] = ch; + } + normalizedCR = false; + } + } + } + } catch(EOFException ex) { + // detect EOF and create meaningful error ... + throw new XmlPullParserException( + "CDATA section started on line "+curLine+" and column "+curColumn+" was not closed", + this, ex); + } + if(normalizeInput) { + if(usePC) { + pcEnd = pcEnd - 2; + } + } + posStart = cdStart - bufAbsoluteStart; + posEnd = pos - 3; + } + + protected void fillBuf() throws IOException, XmlPullParserException { + if(reader == null) throw new XmlPullParserException( + "reader must be set before parsing is started"); + + // see if we are in compaction area + if(bufEnd > bufSoftLimit) { + + // expand buffer it makes sense!!!! + boolean compact = bufStart > bufSoftLimit; + boolean expand = false; + if(preventBufferCompaction) { + compact = false; + expand = true; + } else if(!compact) { + //freeSpace + if(bufStart < buf.length / 2) { + // less then half buffer available forcompactin --> expand instead!!! + expand = true; + } else { + // at least half of buffer can be reclaimed --> worthwhile effort!!! + compact = true; + } + } + + // if buffer almost full then compact it + if(compact) { + //TODO: look on trashing + // //assert bufStart > 0 + System.arraycopy(buf, bufStart, buf, 0, bufEnd - bufStart); + if(TRACE_SIZING) System.out.println( + "TRACE_SIZING fillBuf() compacting "+bufStart + +" bufEnd="+bufEnd + +" pos="+pos+" posStart="+posStart+" posEnd="+posEnd + +" buf first 100 chars:"+new String(buf, bufStart, + bufEnd - bufStart < 100 ? bufEnd - bufStart : 100 )); + + } else if(expand) { + final int newSize = 2 * buf.length; + final char newBuf[] = new char[ newSize ]; + if(TRACE_SIZING) System.out.println("TRACE_SIZING fillBuf() "+buf.length+" => "+newSize); + System.arraycopy(buf, bufStart, newBuf, 0, bufEnd - bufStart); + buf = newBuf; + if(bufLoadFactor > 0) { + bufSoftLimit = ( bufLoadFactor * buf.length ) /100; + } + + } else { + throw new XmlPullParserException("internal error in fillBuffer()"); + } + bufEnd -= bufStart; + pos -= bufStart; + posStart -= bufStart; + posEnd -= bufStart; + bufAbsoluteStart += bufStart; + bufStart = 0; + if(TRACE_SIZING) System.out.println( + "TRACE_SIZING fillBuf() after bufEnd="+bufEnd + +" pos="+pos+" posStart="+posStart+" posEnd="+posEnd + +" buf first 100 chars:"+new String(buf, 0, bufEnd < 100 ? bufEnd : 100)); + } + // at least one charcter must be read or error + final int len = buf.length - bufEnd > READ_CHUNK_SIZE ? READ_CHUNK_SIZE : buf.length - bufEnd; + final int ret = reader.read(buf, bufEnd, len); + if(ret > 0) { + bufEnd += ret; + if(TRACE_SIZING) System.out.println( + "TRACE_SIZING fillBuf() after filling in buffer" + +" buf first 100 chars:"+new String(buf, 0, bufEnd < 100 ? bufEnd : 100)); + + return; + } + if(ret == -1) { + if(bufAbsoluteStart == 0 && pos == 0) { + throw new EOFException("input contained no data"); + } else { + if(seenRoot && depth == 0) { // inside parsing epilog!!! + reachedEnd = true; + return; + } else { + StringBuilder expectedTagStack = new StringBuilder(); + if(depth > 0) { + //final char[] cbuf = elRawName[depth]; + //final String startname = new String(cbuf, 0, elRawNameEnd[depth]); + expectedTagStack.append(" - expected end tag"); + if(depth > 1) { + expectedTagStack.append("s"); //more than one end tag + } + expectedTagStack.append(" "); + for (int i = depth; i > 0; i--) + { + String tagName = new String(elRawName[i], 0, elRawNameEnd[i]); + expectedTagStack.append("'); + } + expectedTagStack.append(" to close"); + for (int i = depth; i > 0; i--) + { + if(i != depth) { + expectedTagStack.append(" and"); //more than one end tag + } + String tagName = new String(elRawName[i], 0, elRawNameEnd[i]); + expectedTagStack.append(" start tag <").append(tagName).append(">"); + expectedTagStack.append(" from line ").append(elRawNameLine[i]); + } + expectedTagStack.append(", parser stopped on"); + } + throw new EOFException("no more data available" + +expectedTagStack.toString()+getPositionDescription()); + } + } + } else { + throw new IOException("error reading input, returned "+ret); + } + } + + protected char more() throws IOException, XmlPullParserException { + if(pos >= bufEnd) { + fillBuf(); + // this return value should be ignonored as it is used in epilog parsing ... + if(reachedEnd) return (char)-1; + } + final char ch = buf[pos++]; + //line/columnNumber + if(ch == '\n') { ++lineNumber; columnNumber = 1; } + else { ++columnNumber; } + //System.out.print(ch); + return ch; + } + + // /** + // * This function returns position of parser in XML input stream + // * (how many characters were processed. + // *

NOTE: this logical position and not byte offset as encodings + // * such as UTF8 may use more than one byte to encode one character. + // */ + // public int getCurrentInputPosition() { + // return pos + bufAbsoluteStart; + // } + + protected void ensurePC(int end) { + //assert end >= pc.length; + final int newSize = end > READ_CHUNK_SIZE ? 2 * end : 2 * READ_CHUNK_SIZE; + final char[] newPC = new char[ newSize ]; + if(TRACE_SIZING) System.out.println("TRACE_SIZING ensurePC() "+pc.length+" ==> "+newSize+" end="+end); + System.arraycopy(pc, 0, newPC, 0, pcEnd); + pc = newPC; + //assert end < pc.length; + } + + protected void joinPC() { + //assert usePC == false; + //assert posEnd > posStart; + final int len = posEnd - posStart; + final int newEnd = pcEnd + len + 1; + if(newEnd >= pc.length) ensurePC(newEnd); // add 1 for extra space for one char + //assert newEnd < pc.length; + System.arraycopy(buf, posStart, pc, pcEnd, len); + pcEnd += len; + usePC = true; + + } + + protected char requireInput(char ch, char[] input) + throws XmlPullParserException, IOException + { + for (char anInput : input) { + if (ch != anInput) { + throw new XmlPullParserException( + "expected " + printable(anInput) + " in " + new String(input) + + " and not " + printable(ch), this, null); + } + ch = more(); + } + return ch; + } + + protected char requireNextS() + throws XmlPullParserException, IOException + { + final char ch = more(); + if(!isS(ch)) { + throw new XmlPullParserException( + "white space is required and not "+printable(ch), this, null); + } + return skipS(ch); + } + + protected char skipS(char ch) + throws XmlPullParserException, IOException + { + while(isS(ch)) { ch = more(); } // skip additional spaces + return ch; + } + + // nameStart / name lookup tables based on XML 1.1 http://www.w3.org/TR/2001/WD-xml11-20011213/ + protected static final int LOOKUP_MAX = 0x400; + protected static final char LOOKUP_MAX_CHAR = (char)LOOKUP_MAX; + // protected static int lookupNameStartChar[] = new int[ LOOKUP_MAX_CHAR / 32 ]; + // protected static int lookupNameChar[] = new int[ LOOKUP_MAX_CHAR / 32 ]; + protected static boolean lookupNameStartChar[] = new boolean[ LOOKUP_MAX ]; + protected static boolean lookupNameChar[] = new boolean[ LOOKUP_MAX ]; + + private static final void setName(char ch) + //{ lookupNameChar[ (int)ch / 32 ] |= (1 << (ch % 32)); } + { lookupNameChar[ ch ] = true; } + private static final void setNameStart(char ch) + //{ lookupNameStartChar[ (int)ch / 32 ] |= (1 << (ch % 32)); setName(ch); } + { lookupNameStartChar[ ch ] = true; setName(ch); } + + static { + setNameStart(':'); + for (char ch = 'A'; ch <= 'Z'; ++ch) setNameStart(ch); + setNameStart('_'); + for (char ch = 'a'; ch <= 'z'; ++ch) setNameStart(ch); + for (char ch = '\u00c0'; ch <= '\u02FF'; ++ch) setNameStart(ch); + for (char ch = '\u0370'; ch <= '\u037d'; ++ch) setNameStart(ch); + for (char ch = '\u037f'; ch < '\u0400'; ++ch) setNameStart(ch); + + setName('-'); + setName('.'); + for (char ch = '0'; ch <= '9'; ++ch) setName(ch); + setName('\u00b7'); + for (char ch = '\u0300'; ch <= '\u036f'; ++ch) setName(ch); + } + + //private final static boolean isNameStartChar(char ch) { + protected boolean isNameStartChar(char ch) { + return (ch < LOOKUP_MAX_CHAR && lookupNameStartChar[ ch ]) + || (ch >= LOOKUP_MAX_CHAR && ch <= '\u2027') + || (ch >= '\u202A' && ch <= '\u218F') + || (ch >= '\u2800' && ch <= '\uFFEF') + ; + + // if(ch < LOOKUP_MAX_CHAR) return lookupNameStartChar[ ch ]; + // else return ch <= '\u2027' + // || (ch >= '\u202A' && ch <= '\u218F') + // || (ch >= '\u2800' && ch <= '\uFFEF') + // ; + //return false; + // return (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || ch == ':' + // || (ch >= '0' && ch <= '9'); + // if(ch < LOOKUP_MAX_CHAR) return (lookupNameStartChar[ (int)ch / 32 ] & (1 << (ch % 32))) != 0; + // if(ch <= '\u2027') return true; + // //[#x202A-#x218F] + // if(ch < '\u202A') return false; + // if(ch <= '\u218F') return true; + // // added pairts [#x2800-#xD7FF] | [#xE000-#xFDCF] | [#xFDE0-#xFFEF] | [#x10000-#x10FFFF] + // if(ch < '\u2800') return false; + // if(ch <= '\uFFEF') return true; + // return false; + + + // else return (supportXml11 && ( (ch < '\u2027') || (ch > '\u2029' && ch < '\u2200') ... + } + + //private final static boolean isNameChar(char ch) { + protected boolean isNameChar(char ch) { + //return isNameStartChar(ch); + + // if(ch < LOOKUP_MAX_CHAR) return (lookupNameChar[ (int)ch / 32 ] & (1 << (ch % 32))) != 0; + + return (ch < LOOKUP_MAX_CHAR && lookupNameChar[ ch ]) + || (ch >= LOOKUP_MAX_CHAR && ch <= '\u2027') + || (ch >= '\u202A' && ch <= '\u218F') + || (ch >= '\u2800' && ch <= '\uFFEF') + ; + //return false; + // return (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || ch == ':' + // || (ch >= '0' && ch <= '9'); + // if(ch < LOOKUP_MAX_CHAR) return (lookupNameStartChar[ (int)ch / 32 ] & (1 << (ch % 32))) != 0; + + //else return + // else if(ch <= '\u2027') return true; + // //[#x202A-#x218F] + // else if(ch < '\u202A') return false; + // else if(ch <= '\u218F') return true; + // // added pairts [#x2800-#xD7FF] | [#xE000-#xFDCF] | [#xFDE0-#xFFEF] | [#x10000-#x10FFFF] + // else if(ch < '\u2800') return false; + // else if(ch <= '\uFFEF') return true; + //else return false; + } + + protected boolean isS(char ch) { + return (ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t'); + // || (supportXml11 && (ch == '\u0085' || ch == '\u2028'); + } + + //protected boolean isChar(char ch) { return (ch < '\uD800' || ch > '\uDFFF') + // ch != '\u0000' ch < '\uFFFE' + + + //protected char printable(char ch) { return ch; } + protected String printable(char ch) { + if(ch == '\n') { + return "\\n"; + } else if(ch == '\r') { + return "\\r"; + } else if(ch == '\t') { + return "\\t"; + } else if(ch == '\'') { + return "\\'"; + } if(ch > 127 || ch < 32) { + return "\\u"+Integer.toHexString((int)ch); + } + return ""+ch; + } + + protected String printable(String s) { + if(s == null) return null; + final int sLen = s.length(); + StringBuilder buf = new StringBuilder(sLen + 10); + for(int i = 0; i < sLen; ++i) { + buf.append(printable(s.charAt(i))); + } + s = buf.toString(); + return s; + } +} + + +/* + * Indiana University Extreme! Lab Software License, Version 1.2 + * + * Copyright (C) 2003 The Trustees of Indiana University. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * 1) All redistributions of source code must retain the above + * copyright notice, the list of authors in the original source + * code, this list of conditions and the disclaimer listed in this + * license; + * + * 2) All redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the disclaimer + * listed in this license in the documentation and/or other + * materials provided with the distribution; + * + * 3) Any documentation included with all redistributions must include + * the following acknowledgement: + * + * "This product includes software developed by the Indiana + * University Extreme! Lab. For further information please visit + * http://www.extreme.indiana.edu/" + * + * Alternatively, this acknowledgment may appear in the software + * itself, and wherever such third-party acknowledgments normally + * appear. + * + * 4) The name "Indiana University" or "Indiana University + * Extreme! Lab" shall not be used to endorse or promote + * products derived from this software without prior written + * permission from Indiana University. For written permission, + * please contact http://www.extreme.indiana.edu/. + * + * 5) Products derived from this software may not use "Indiana + * University" name nor may "Indiana University" appear in their name, + * without prior written permission of the Indiana University. + * + * Indiana University provides no reassurances that the source code + * provided does not infringe the patent or any other intellectual + * property rights of any other entity. Indiana University disclaims any + * liability to any recipient for claims brought by any other entity + * based on infringement of intellectual property rights or otherwise. + * + * LICENSEE UNDERSTANDS THAT SOFTWARE IS PROVIDED "AS IS" FOR WHICH + * NO WARRANTIES AS TO CAPABILITIES OR ACCURACY ARE MADE. INDIANA + * UNIVERSITY GIVES NO WARRANTIES AND MAKES NO REPRESENTATION THAT + * SOFTWARE IS FREE OF INFRINGEMENT OF THIRD PARTY PATENT, COPYRIGHT, OR + * OTHER PROPRIETARY RIGHTS. INDIANA UNIVERSITY MAKES NO WARRANTIES THAT + * SOFTWARE IS FREE FROM "BUGS", "VIRUSES", "TROJAN HORSES", "TRAP + * DOORS", "WORMS", OR OTHER HARMFUL CODE. LICENSEE ASSUMES THE ENTIRE + * RISK AS TO THE PERFORMANCE OF SOFTWARE AND/OR ASSOCIATED MATERIALS, + * AND TO THE PERFORMANCE AND VALIDITY OF INFORMATION GENERATED USING + * SOFTWARE. + */ + + + + + + diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/PlexusXmlMerger.java plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/PlexusXmlMerger.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/PlexusXmlMerger.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/PlexusXmlMerger.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,57 @@ +package org.codehaus.plexus.metadata.merge; + +/* + * The MIT License + * + * Copyright (c) 2006, The Codehaus + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.metadata.merge.support.PlexusRootElement; +import org.jdom2.Document; + +/** + * Plexus XML merger. This is a superset of the components xml merger so can be used in its place if necessary. + * + * @author Rahul Thakur + * @version $Id$ + */ +@Component(role=Merger.class,hint="plexusXml") +public class PlexusXmlMerger + extends AbstractMerger +{ + /** + * @see org.codehaus.plexus.metadata.merge.Merger#merge(org.jdom.Document, org.jdom.Document) + */ + public Document merge( Document dDocument, Document rDocument ) + throws MergeException + { + // TODO: Ideally we don't want to manipulate the original + // dominant document but use its copy for merge. + //Document mDoc = (Document) dDocument.clone(); // doesn't merge properly + Document mDoc = dDocument; + PlexusRootElement dCSE = new PlexusRootElement( mDoc.getRootElement() ); + PlexusRootElement rCSE = new PlexusRootElement( rDocument.getRootElement() ); + dCSE.merge( rCSE ); + // the contents are merged into the dominant document DOM. + return mDoc; + } +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/support/AbstractMergeableElement.java plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/support/AbstractMergeableElement.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/support/AbstractMergeableElement.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/support/AbstractMergeableElement.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,190 @@ +package org.codehaus.plexus.metadata.merge.support; + +/* + * The MIT License + * + * Copyright (c) 2006, The Codehaus + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.codehaus.plexus.metadata.merge.MergeException; +import org.codehaus.plexus.metadata.merge.MergeStrategy; +import org.jdom2.Content; +import org.jdom2.Element; + +/** + * @author Rahul Thakur + * @version $Id$ + */ +public abstract class AbstractMergeableElement + extends AbstractMergeableSupport +{ + public AbstractMergeableElement( Element element ) + { + super( element ); + } + + /** + * Detects if there was a conflict, that is the specified element was + * present in both dominant and recessive element-sets. + *

+ * This delegates to + * {@link #isRecessiveElementInConflict(AbstractMergeableElement,List)}. + * + * @param re Recessive element. + * @param eltName Element name to test for. + * @return true if there was a conflict of element. + * @deprecated use {@link #isRecessiveElementInConflict(AbstractMergeableElement,List)} instead. + */ + protected boolean isRecessiveElementInConflict( AbstractMergeableElement re, String eltName ) + { + // return (null != getChild (eltName) && null != re.getChild (eltName)); + List l = new ArrayList(); + l.add( eltName ); + return isRecessiveElementInConflict( re, l ); + } + + /** + * Detects if there was a conflict, that is the specified element was + * present in both dominant and recessive element-sets. + *

+ * Use this to determine conflicts when the Dominant and Recessive element + * sets are keyed with Composite keys.
+ * For instance: <component> is keyed on + * <role> and <role-hint>. + * + * @param re + * @param eltNameList List of elements that will be checked for values in both dominant and recessive sets. + * @return + */ + protected boolean isRecessiveElementInConflict( AbstractMergeableElement re, List eltNameList ) + { + // give opportunity to subclasses to provide any custom Composite keys + // for conflict checks. + eltNameList = getElementNamesForConflictResolution( eltNameList ); + + if ( null == eltNameList || eltNameList.size() == 0 ) + { + return false; + } + + // assuming the elements will conflict. + for (Object anEltNameList : eltNameList) { + String eltName = (String) anEltNameList; + String dEltValue = getChildTextTrim(eltName); + String rEltValue = re.getChildTextTrim(eltName); + if (null == dEltValue || null == rEltValue || !dEltValue.equals(rEltValue)) { + return false; + } + } + return true; + } + + /** + * Determines if the Element to be merged is to be sourced from Recessive + * Element set. + * + * @param re Recessive element. + * @param eltName Element name to test for. + * @return + */ + protected boolean mergeableElementComesFromRecessive( AbstractMergeableElement re, String eltName ) + { + return null == getChildText( eltName ) && null != re.getChildText( eltName ); + } + + /** + * Simply delegate to + * + * @see Mergeable#merge(Mergeable,org.codehaus.plexus.metadata.merge.MergeStrategy) + */ + public void merge( Mergeable me, MergeStrategy strategy ) + throws MergeException + { + // TODO set up a unit test for this! + strategy.apply( this, me ); + } + + public void merge( Mergeable me ) + throws MergeException + { + if ( !isExpectedElementType( me ) ) + { + // if (getLogger().isErrorEnabled) + // getLogger().error ("Cannot Merge dissimilar elements. (Expected : '" + getClass ().getName () + "', found '" + me.getClass ().getName () + "')"); + throw new MergeException( "Cannot Merge dissimilar elements. " + "(Expected : '" + getClass().getName() + + "', found '" + me.getClass().getName() + "')" ); + } + // recessive Component Element. + AbstractMergeableElement rce = (AbstractMergeableElement) me; + + Set allowedTags = new HashSet(); + + for ( int i = 0; i < getAllowedTags().length; i++ ) + { + String tagName = getAllowedTags()[i].getTagName(); + + allowedTags.add( tagName ); + + List defaultConflictChecklist = new ArrayList(); + defaultConflictChecklist.add( tagName ); + + if ( !isRecessiveElementInConflict( rce, defaultConflictChecklist ) && + mergeableElementComesFromRecessive( rce, tagName ) ) + { + this.addContent( (Element) rce.getChild( tagName ).clone() ); + // else dominant wins in anycase! + } + else + if ( getAllowedTags()[i].isMergeable() && isRecessiveElementInConflict( rce, defaultConflictChecklist ) ) + { + // this allows for merging multiple/list of elements. + try + { + getAllowedTags()[i].createMergeable( this.getChild( tagName ) ) + .merge( getAllowedTags()[i].createMergeable( rce.getChild( tagName ) ), + getDefaultMergeStrategy() ); + } + catch ( Exception e ) + { + // TODO log to error + throw new MergeException( + "Unable to create Mergeable instance for tag " + "'" + getAllowedTags()[i] + "'.", e ); + } + } + } + + for (Object o : me.getElement().getChildren()) { + Element child = (Element) o; + + if (!allowedTags.contains(child.getName())) { + // not yet merged, copy over + element.addContent((Content) child.clone()); + } + } + + } + +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/support/AbstractMergeableElementList.java plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/support/AbstractMergeableElementList.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/support/AbstractMergeableElementList.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/support/AbstractMergeableElementList.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,212 @@ +package org.codehaus.plexus.metadata.merge.support; + +/* + * The MIT License + * + * Copyright (c) 2006, The Codehaus + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.codehaus.plexus.metadata.merge.MergeException; +import org.jdom2.Element; + +/** + * Base class that allows for handling merging two element lists. + *

+ * TODO Refactor and make this extend {@link AbstractMergeableElement} which is what + * this actually is, but with added bits for merging child element lists. + * + * @author Rahul Thakur + * @version $Id$ + */ +public abstract class AbstractMergeableElementList + extends AbstractMergeableElement +{ + public AbstractMergeableElementList( Element element ) + { + super( element ); + } + + /** + * Parses <component> elements and builds a map keyed basd on the list of composite keys specified. + * + * @param tagName Name of the tag that appears multiple times + * @param compositeKeyList List of element/tag names to be used as composite keys to register recurring + * {@link Mergeable} instances. + * @return Map of {@link Mergeable} instances keyed on the composite key obtained from + * {@link #getElementNamesForConflictResolution(java.util.List)} + * @throws Exception if there was an error parsing and registering {@link Mergeable} instances + */ + protected Map parseRecurringMergeables( String tagName, List compositeKeyList, Mergeable parentElement ) + throws Exception + { + Map mergeables = new LinkedHashMap(); + List list = this.getChildren( tagName ); + for (Object aList : list) { + Element ce = (Element) aList; + + // use the composite key specified by the passed in list + String compositeKey = ""; + for (Object aCompositeKeyList : compositeKeyList) { + String key = (String) aCompositeKeyList; + if (null != ce.getChildText(key)) { + compositeKey = compositeKey + ce.getChildText(key); + } + } + + // create a Mergeable instance and store it in the map. + DescriptorTag tag = lookupTagInstanceByName(tagName, parentElement.getAllowedTags()); + Mergeable mergeable = tag.createMergeable(ce); + // register the Mergeable instance based on composite key + mergeables.put(compositeKey, mergeable); + } + return mergeables; + } + + /** + * Looks up and returns an {@link DescriptorTag} instance for the + * specified tag name. + * + * @param name key to look up the {@link DescriptorTag} instance on. + * @return {@link DescriptorTag} instance whose name matches the name specified. + * Returns null if no match is found. + */ + private DescriptorTag lookupTagInstanceByName( String name, DescriptorTag[] values ) + { + DescriptorTag value = null; + + for ( int i = 0; i < values.length && value == null; i++ ) + { + if ( values[i].getTagName().equals( name ) ) + { + value = values[i]; + } + } + // not found! + return value; + } + + public void merge( Mergeable me ) + throws MergeException + { + try + { + Map dRequirementsMap = parseRecurringMergeables( getTagNameForRecurringMergeable(), + getElementNamesForConflictResolution( new ArrayList() ), me ); + Map rRequirementsMap = ( (AbstractMergeableElementList) me ) + .parseRecurringMergeables( getTagNameForRecurringMergeable(), + getElementNamesForConflictResolution( new ArrayList() ), me ); + merge( getElement(), dRequirementsMap, rRequirementsMap ); + } + catch ( Exception e ) + { + // TODO: log to error + // TODO: better error message + throw new MergeException( "Unable to merge Mergeable lists for element '" + getName() + "'.", e ); + } + + } + + /** + * Identifies the conflicting elements in the dominant and recessive + * {@link Map} instance and merges as required. + * + * @param parent {@link Element} that is parent for the children in the dominant Map instance. Merged content is + * added to this element. + * @param dMap Dominant Map keyed by the composite key obtained from + * {@link #getElementNamesForConflictResolution(List)} + * @param rMap Recessive Map keyed by the composite key obtained from + * {@link #getElementNamesForConflictResolution(List)} + * @throws Exception if there was an error merging both the maps. + */ + protected void merge( Element parent, Map dMap, Map rMap ) + throws Exception + { + Set dKeySet = dMap.keySet(); + Set rKeySet = rMap.keySet(); + // check if there are any entities to merge + if ( !isMergeRequired( dKeySet, rKeySet ) ) + { + return; + } + + // iterate over components and process them + for (Object aDKeySet : dKeySet) { + String dKey = (String) aDKeySet; + if (rMap.containsKey(dKey)) { + // conflict ! merge this component + Mergeable dMeregeable = (Mergeable) dMap.get(dKey); + Mergeable rMergeable = (Mergeable) rMap.get(dKey); + + dMeregeable.merge(rMergeable); + + // and remove from the recessive list to mark it as merged. + rMap.remove(dKey); + } + } + + // check if any unmerged components are left in the recessive map. + if ( rMap.keySet().size() > 0 ) + { + // add them to results + for (Object aRKeySet : rKeySet) { + String rKey = (String) aRKeySet; + // add to parent + parent.addContent((Element) ((Mergeable) rMap.get(rKey)).getElement().clone()); + } + } + } + + /** + * Determines if a merge operation is required for the two sets (dominant and recessive) specified. + * + * @param dKeySet the dominant set of elements. + * @param rKeySet the recessive set of elements. + * @return true if a merge operation was required. + */ + private boolean isMergeRequired( Set dKeySet, Set rKeySet ) + { + return ( dKeySet.size() > 0 || rKeySet.size() > 0 ); + } + + /** + * Allows the sub classes to provided a tag name that they expect to recurr + * within them. + *

+ * For instance:
+ *

    + *
  • <components> expects <component> to recurr within + * itself.
  • + *
  • <requirements> expects <requirement> to recurr within + * itself.
  • + *
+ * + * @return tag name of the {@link Mergeable} element that occurs multiple times. + */ + protected abstract String getTagNameForRecurringMergeable(); + + protected abstract List getElementNamesForConflictResolution( List defaultList ); +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/support/AbstractMergeableSupport.java plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/support/AbstractMergeableSupport.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/support/AbstractMergeableSupport.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/support/AbstractMergeableSupport.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,673 @@ +package org.codehaus.plexus.metadata.merge.support; + +/* + * The MIT License + * + * Copyright (c) 2006, The Codehaus + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +import java.util.Collection; +import java.util.Iterator; +import java.util.List; + +import org.codehaus.plexus.metadata.merge.MergeException; +import org.codehaus.plexus.metadata.merge.MergeStrategy; +import org.jdom2.Attribute; +import org.jdom2.Content; +import org.jdom2.Document; +import org.jdom2.Element; +import org.jdom2.Namespace; +import org.jdom2.Parent; +import org.jdom2.filter.Filter; + +/** + * @author Rahul Thakur + * @version $Id$ + */ +public abstract class AbstractMergeableSupport + implements Mergeable +{ + /** + * Wrapped JDOM element. + */ + protected Element element; + + /** + * The default merging strategy used. + */ + private static final MergeStrategy DEFAULT_MERGE_STRATEGY = MergeStrategies.DEEP; + + public AbstractMergeableSupport( Element element ) + { + this.element = element; + } + + public abstract void merge( Mergeable me ) + throws MergeException; + + /** + * Determines if the passed in {@link Mergeable} was of same type as this + * class. + * + * @param me {@link Mergeable} instance to test. + * @return true if the passed in Mergeable can be merged with + * the current Mergeable. + */ + protected abstract boolean isExpectedElementType( Mergeable me ); + + // ---------------------------------------------------------------------- + // Methods delegated on wrapped JDOM element. + // ---------------------------------------------------------------------- + + public Element addContent( Collection collection ) + { + return element.addContent( collection ); + } + + public Element addContent( Content child ) + { + return element.addContent( child ); + } + + public Element addContent( int index, Collection c ) + { + return element.addContent( index, c ); + } + + public Element addContent( int index, Content child ) + { + return element.addContent( index, child ); + } + + public Element addContent( String str ) + { + return element.addContent( str ); + } + + public void addNamespaceDeclaration( Namespace additional ) + { + element.addNamespaceDeclaration( additional ); + } + + public Object clone() + { + return element.clone(); + } + + public List cloneContent() + { + return element.cloneContent(); + } + + public Content detach() + { + return element.detach(); + } + + public boolean equals( Object obj ) + { + return element.equals( obj ); + } + + public List getAdditionalNamespaces() + { + return element.getAdditionalNamespaces(); + } + + public Attribute getAttribute( String name, Namespace ns ) + { + return element.getAttribute( name, ns ); + } + + public Attribute getAttribute( String name ) + { + return element.getAttribute( name ); + } + + public List getAttributes() + { + return element.getAttributes(); + } + + /** + * @see org.jdom.Element#getAttributeValue(java.lang.String,org.jdom.Namespace,java.lang.String) + */ + public String getAttributeValue( String name, Namespace ns, String def ) + { + return element.getAttributeValue( name, ns, def ); + } + + /** + * @see org.jdom.Element#getAttributeValue(java.lang.String,org.jdom.Namespace) + */ + public String getAttributeValue( String name, Namespace ns ) + { + return element.getAttributeValue( name, ns ); + } + + /** + * @see org.jdom.Element#getAttributeValue(java.lang.String,java.lang.String) + */ + public String getAttributeValue( String name, String def ) + { + return element.getAttributeValue( name, def ); + } + + /** + * @see org.jdom.Element#getAttributeValue(java.lang.String) + */ + public String getAttributeValue( String name ) + { + return element.getAttributeValue( name ); + } + + /** + * @return + * @see org.jdom.Element#getChild(java.lang.String,org.jdom.Namespace) + */ + public Element getChild( String name, Namespace ns ) + { + return element.getChild( name, ns ); + } + + /** + * @see org.jdom.Element#getChild(java.lang.String) + */ + public Element getChild( String name ) + { + return element.getChild( name ); + } + + /** + * @see org.jdom.Element#getChildren() + */ + public List getChildren() + { + return element.getChildren(); + } + + /** + * @see org.jdom.Element#getChildren(java.lang.String,org.jdom.Namespace) + */ + public List getChildren( String name, Namespace ns ) + { + return element.getChildren( name, ns ); + } + + /** + * @see org.jdom.Element#getChildren(java.lang.String) + */ + public List getChildren( String name ) + { + return element.getChildren( name ); + } + + /** + * @see org.jdom.Element#getChildText(java.lang.String,org.jdom.Namespace) + */ + public String getChildText( String name, Namespace ns ) + { + return element.getChildText( name, ns ); + } + + /** + * @see org.jdom.Element#getChildText(java.lang.String) + */ + public String getChildText( String name ) + { + return element.getChildText( name ); + } + + /** + * @see org.jdom.Element#getChildTextNormalize(java.lang.String,org.jdom.Namespace) + */ + public String getChildTextNormalize( String name, Namespace ns ) + { + return element.getChildTextNormalize( name, ns ); + } + + /** + * @see org.jdom.Element#getChildTextNormalize(java.lang.String) + */ + public String getChildTextNormalize( String name ) + { + return element.getChildTextNormalize( name ); + } + + /** + * @see org.jdom.Element#getChildTextTrim(java.lang.String,org.jdom.Namespace) + */ + public String getChildTextTrim( String name, Namespace ns ) + { + return element.getChildTextTrim( name, ns ); + } + + /** + * @see org.jdom.Element#getChildTextTrim(java.lang.String) + */ + public String getChildTextTrim( String name ) + { + return element.getChildTextTrim( name ); + } + + /** + * @see org.jdom.Element#getContent() + */ + public List getContent() + { + return element.getContent(); + } + + /** + * @see org.jdom.Element#getContent(org.jdom.filter.Filter) + */ + public List getContent( Filter filter ) + { + return element.getContent( filter ); + } + + /** + * @see org.jdom.Element#getContent(int) + */ + public Content getContent( int index ) + { + return element.getContent( index ); + } + + /** + * @return + * @see org.jdom.Element#getContentSize() + */ + public int getContentSize() + { + return element.getContentSize(); + } + + /** + * @see org.jdom.Element#getDescendants() + */ + public Iterator getDescendants() + { + return element.getDescendants(); + } + + /** + * @see org.jdom.Element#getDescendants(org.jdom.filter.Filter) + */ + public Iterator getDescendants( Filter filter ) + { + return element.getDescendants( filter ); + } + + /** + * @see org.jdom.Content#getDocument() + */ + public Document getDocument() + { + return element.getDocument(); + } + + /** + * @see org.jdom.Element#getName() + */ + public String getName() + { + return element.getName(); + } + + /** + * @see org.jdom.Element#getNamespace() + */ + public Namespace getNamespace() + { + return element.getNamespace(); + } + + /** + * @see org.jdom.Element#getNamespace(java.lang.String) + */ + public Namespace getNamespace( String prefix ) + { + return element.getNamespace( prefix ); + } + + /** + * @see org.jdom.Element#getNamespacePrefix() + */ + public String getNamespacePrefix() + { + return element.getNamespacePrefix(); + } + + /** + * @see org.jdom.Element#getNamespaceURI() + */ + public String getNamespaceURI() + { + return element.getNamespaceURI(); + } + + /** + * @see org.jdom.Content#getParent() + */ + public Parent getParent() + { + return element.getParent(); + } + + /** + * @see org.jdom.Content#getParentElement() + */ + public Element getParentElement() + { + return element.getParentElement(); + } + + /** + * @see org.jdom.Element#getQualifiedName() + */ + public String getQualifiedName() + { + return element.getQualifiedName(); + } + + /** + * @see org.jdom.Element#getText() + */ + public String getText() + { + return element.getText(); + } + + /** + * @see org.jdom.Element#getTextNormalize() + */ + public String getTextNormalize() + { + return element.getTextNormalize(); + } + + /** + * @see org.jdom.Element#getTextTrim() + */ + public String getTextTrim() + { + return element.getTextTrim(); + } + + /** + * @see org.jdom.Element#getValue() + */ + public String getValue() + { + return element.getValue(); + } + + /** + * @see java.lang.Object#hashCode() + */ + public int hashCode() + { + return element.hashCode(); + } + + /** + * @see org.jdom.Element#indexOf(org.jdom.Content) + */ + public int indexOf( Content child ) + { + return element.indexOf( child ); + } + + /** + * @see org.jdom.Element#isAncestor(org.jdom.Element) + */ + public boolean isAncestor( Element element ) + { + return element.isAncestor( element ); + } + + /** + * @see org.jdom.Element#isRootElement() + */ + public boolean isRootElement() + { + return element.isRootElement(); + } + + /** + * @see org.jdom.Element#removeAttribute(org.jdom.Attribute) + */ + public boolean removeAttribute( Attribute attribute ) + { + return element.removeAttribute( attribute ); + } + + /** + * @see org.jdom.Element#removeAttribute(java.lang.String,org.jdom.Namespace) + */ + public boolean removeAttribute( String name, Namespace ns ) + { + return element.removeAttribute( name, ns ); + } + + /** + * @see org.jdom.Element#removeAttribute(java.lang.String) + */ + public boolean removeAttribute( String name ) + { + return element.removeAttribute( name ); + } + + /** + * @see org.jdom.Element#removeChild(java.lang.String,org.jdom.Namespace) + */ + public boolean removeChild( String name, Namespace ns ) + { + return element.removeChild( name, ns ); + } + + /** + * @see org.jdom.Element#removeChild(java.lang.String) + */ + public boolean removeChild( String name ) + { + return element.removeChild( name ); + } + + /** + * @see org.jdom.Element#removeChildren(java.lang.String,org.jdom.Namespace) + */ + public boolean removeChildren( String name, Namespace ns ) + { + return element.removeChildren( name, ns ); + } + + /** + * @see org.jdom.Element#removeChildren(java.lang.String) + */ + public boolean removeChildren( String name ) + { + return element.removeChildren( name ); + } + + /** + * @see org.jdom.Element#removeContent() + */ + public List removeContent() + { + return element.removeContent(); + } + + /** + * @see org.jdom.Element#removeContent(org.jdom.Content) + */ + public boolean removeContent( Content child ) + { + return element.removeContent( child ); + } + + /** + * @see org.jdom.Element#removeContent(org.jdom.filter.Filter) + */ + public List removeContent( Filter filter ) + { + return element.removeContent( filter ); + } + + /** + * @see org.jdom.Element#removeContent(int) + */ + public Content removeContent( int index ) + { + return element.removeContent( index ); + } + + /** + * @see org.jdom.Element#removeNamespaceDeclaration(org.jdom.Namespace) + */ + public void removeNamespaceDeclaration( Namespace additionalNamespace ) + { + element.removeNamespaceDeclaration( additionalNamespace ); + } + + /** + * @see org.jdom.Element#setAttribute(org.jdom.Attribute) + */ + public Element setAttribute( Attribute attribute ) + { + return element.setAttribute( attribute ); + } + + /** + * @see org.jdom.Element#setAttribute(java.lang.String,java.lang.String,org.jdom.Namespace) + */ + public Element setAttribute( String name, String value, Namespace ns ) + { + return element.setAttribute( name, value, ns ); + } + + /** + * @see org.jdom.Element#setAttribute(java.lang.String,java.lang.String) + */ + public Element setAttribute( String name, String value ) + { + return element.setAttribute( name, value ); + } + + /** + * @see org.jdom.Element#setAttributes(java.util.List) + */ + public Element setAttributes( List newAttributes ) + { + return element.setAttributes( newAttributes ); + } + + /** + * @see org.jdom.Element#setContent(java.util.Collection) + */ + public Element setContent( Collection newContent ) + { + return element.setContent( newContent ); + } + + /** + * @see org.jdom.Element#setContent(org.jdom.Content) + */ + public Element setContent( Content child ) + { + return element.setContent( child ); + } + + /** + * @see org.jdom.Element#setContent(int,java.util.Collection) + */ + public Parent setContent( int index, Collection collection ) + { + return element.setContent( index, collection ); + } + + /** + * @see org.jdom.Element#setContent(int,org.jdom.Content) + */ + public Element setContent( int index, Content child ) + { + return element.setContent( index, child ); + } + + /** + * @see org.jdom.Element#setName(java.lang.String) + */ + public Element setName( String name ) + { + return element.setName( name ); + } + + /** + * @see org.jdom.Element#setNamespace(org.jdom.Namespace) + */ + public Element setNamespace( Namespace namespace ) + { + return element.setNamespace( namespace ); + } + + /** + * @see org.jdom.Element#setText(java.lang.String) + */ + public Element setText( String text ) + { + return element.setText( text ); + } + + /** + * @see org.jdom.Element#toString() + */ + public String toString() + { + return element.toString(); + } + + /** + * Returns the wrapped up JDom {@link Element} instance. + */ + public Element getElement() + { + return this.element; + } + + /** + * Sub classes should override if they wish to provide a different + * combination of composite keys for determining conflicts. + */ + protected List getElementNamesForConflictResolution( List defaultList ) + { + return defaultList; + } + + /** + * Returns the default {@link MergeStrategy} instance. + */ + protected MergeStrategy getDefaultMergeStrategy() + { + return DEFAULT_MERGE_STRATEGY; + } + +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/support/ComponentElement.java plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/support/ComponentElement.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/support/ComponentElement.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/support/ComponentElement.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,85 @@ +package org.codehaus.plexus.metadata.merge.support; + +/* + * The MIT License + * + * Copyright (c) 2006, The Codehaus + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +import org.jdom2.Element; + +/** + * @author Rahul Thakur + * @version $Id$ + */ +public class ComponentElement + extends AbstractMergeableElement +{ + /** + * Allowed elements/tags that we can expect under this element. + */ + private final DescriptorTag[] allowedTags = { + ROLE, + ROLE_HINT, + OPTIONAL, + IMPLEMENTATION, + FIELD_NAME, + LIFECYCLE_HANDLER, + DESCRIPTION, + ISOLATION_REALM, + CONFIGURATION, + RequirementsElement.TAG }; + + static final DescriptorTag TAG = new DescriptorTag( "component", true, ComponentElement.class ); + + static final DescriptorTag ROLE = new DescriptorTag( "role" ); + + static final DescriptorTag ROLE_HINT = new DescriptorTag( "role-hint" ); + + static final DescriptorTag OPTIONAL = new DescriptorTag( "optional" ); + + static final DescriptorTag ISOLATION_REALM = new DescriptorTag( "isolated-realm" ); + + private static final DescriptorTag DESCRIPTION = new DescriptorTag( "description" ); + + private static final DescriptorTag CONFIGURATION = new DescriptorTag( "configuration" ); + + static final DescriptorTag FIELD_NAME = new DescriptorTag( "field-name" ); + + private static final DescriptorTag IMPLEMENTATION = new DescriptorTag( "implementation" ); + + private static final DescriptorTag LIFECYCLE_HANDLER = new DescriptorTag( "lifecycle-handler", false, null ); + + public ComponentElement( Element element ) + { + super( element ); + } + + protected boolean isExpectedElementType( Mergeable me ) + { + return me instanceof ComponentElement; + } + + public DescriptorTag[] getAllowedTags() + { + return allowedTags; + } +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/support/ComponentsElement.java plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/support/ComponentsElement.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/support/ComponentsElement.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/support/ComponentsElement.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,80 @@ +package org.codehaus.plexus.metadata.merge.support; + +/* + * The MIT License + * + * Copyright (c) 2006, The Codehaus + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +import java.util.ArrayList; +import java.util.List; + +import org.jdom2.Element; + +/** + * @author Rahul Thakur + * @version $Id$ + */ +public class ComponentsElement + extends AbstractMergeableElementList +{ + static final DescriptorTag TAG = new DescriptorTag( "components", true, ComponentsElement.class ); + + private List conflictVerificationkeys = new ArrayList(); + + public ComponentsElement( Element element ) + { + super( element ); + + conflictVerificationkeys.add( ComponentElement.ROLE.getTagName() ); + conflictVerificationkeys.add( ComponentElement.ROLE_HINT.getTagName() ); + } + + public DescriptorTag[] getAllowedTags() + { + return new DescriptorTag[]{ComponentElement.TAG}; + } + + protected boolean isExpectedElementType( Mergeable me ) + { + return ( me instanceof ComponentsElement ); + } + + protected List getElementNamesForConflictChecks( List defaultList ) + { + // Allow to return custom keys for conflict checks/resolution. + return this.conflictVerificationkeys; + } + + protected String getTagNameForRecurringMergeable() + { + return ComponentElement.TAG.getTagName(); + } + + protected List getElementNamesForConflictResolution( List defaultList ) + { + // TODO: how is this different from getElementNamesForConflictChecks? + List l = new ArrayList(); + l.add( ComponentElement.ROLE.getTagName() ); + l.add( ComponentElement.ROLE_HINT.getTagName() ); + return l; + } +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/support/ComponentSetElement.java plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/support/ComponentSetElement.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/support/ComponentSetElement.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/support/ComponentSetElement.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,50 @@ +package org.codehaus.plexus.metadata.merge.support; + +/* + * The MIT License + * + * Copyright (c) 2006, The Codehaus + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +import org.jdom2.Element; + +/** + * @author Rahul Thakur + * @version $Id$ + */ +public class ComponentSetElement + extends AbstractMergeableElement +{ + public ComponentSetElement( Element element ) + { + super( element ); + } + + public DescriptorTag[] getAllowedTags() + { + return new DescriptorTag[]{ComponentsElement.TAG}; + } + + protected boolean isExpectedElementType( Mergeable me ) + { + return me instanceof ComponentSetElement; + } +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/support/ConfigurationElement.java plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/support/ConfigurationElement.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/support/ConfigurationElement.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/support/ConfigurationElement.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,53 @@ +package org.codehaus.plexus.metadata.merge.support; + +/* + * The MIT License + * + * Copyright (c) 2006, The Codehaus + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +import org.jdom2.Element; + +/** + * TODO Implement merge for this. + * + * @author Rahul Thakur + * @version $Id$ + */ +public class ConfigurationElement + extends AbstractMergeableElement +{ + public ConfigurationElement( Element element ) + { + super( element ); + } + + protected boolean isExpectedElementType( Mergeable me ) + { + return me instanceof ConfigurationElement; + } + + public DescriptorTag[] getAllowedTags() + { + // TODO Implement! + return new DescriptorTag[0]; + } +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/support/DescriptorTag.java plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/support/DescriptorTag.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/support/DescriptorTag.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/support/DescriptorTag.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,168 @@ +package org.codehaus.plexus.metadata.merge.support; + +/* + * ======================================================================== + * + * Copyright 2003 The Apache Software Foundation. Code from this file + * was originally imported from the Jakarta Cactus project. + * + * Copyright 2004-2006 Vincent Massol. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ======================================================================== + */ + +import java.lang.reflect.Constructor; + +import org.jdom2.Element; + +/** + * Represents the various top-level tags in a deployment descriptor as a typesafe enumeration. + * + * @version $Id$ + */ +public class DescriptorTag +{ + /** + * The tag name. + */ + private String tagName; + + /** + * Whether multiple occurrences of the tag in the descriptor are allowed. + */ + private boolean multipleAllowed; + + /** + * Class that wraps this tag and provides for merging same tags. + */ + private Class mergeableClass; + + /** + * Constructor. + * + * @param tagName The tag name of the element + */ + public DescriptorTag( String tagName ) + { + this( tagName, false, null ); + } + + /** + * Constructor. + * + * @param tagName The tag name of the element + * @param isMultipleAllowed Whether the element may occur multiple times in the descriptor + * @deprecated Use {@link #DescriptorTag(String,boolean,Class)} instead + */ + public DescriptorTag( String tagName, boolean isMultipleAllowed ) + { + this( tagName, isMultipleAllowed, null ); + } + + /** + * Constructor. + * + * @param tagName The tag name of the element + * @param isMultipleAllowed Whether the element may occur multiple times in the descriptor + * @param mergeableClass Concrete implementation of {@link Mergeable} that is bound this tag. + */ + public DescriptorTag( String tagName, boolean isMultipleAllowed, Class mergeableClass ) + { + this.tagName = tagName; + this.multipleAllowed = isMultipleAllowed; + this.mergeableClass = mergeableClass; + } + + public boolean equals( Object other ) + { + boolean eq = false; + if ( other instanceof DescriptorTag ) + { + DescriptorTag tag = (DescriptorTag) other; + if ( tag.getTagName().equals( this.tagName ) ) + { + eq = true; + } + } + return eq; + } + + public int hashCode() + { + return this.getTagName().hashCode(); + } + + public String getTagName() + { + return this.tagName; + } + + /** + * Returns whether the tag may occur multiple times in the descriptor. + * + * @return Whether multiple occurrences are allowed + */ + public boolean isMultipleAllowed() + { + return this.multipleAllowed; + } + + /** + * Determines if a particular Tag is mergeable or not. + *

+ * Basically means if we have a {@link Mergeable} class registered for a tag instance. + * + * @return true if this tag is mergeable. + */ + public boolean isMergeable() + { + return null != this.mergeableClass; + } + + public String toString() + { + return getTagName(); + } + + /** + * Creates an {@link Mergeable} instance from the registered class for this + * tag instance. + * + * @return instance of {@link Mergeable}. + * @throws Exception if there was an error creating an instance. + */ + public Mergeable createMergeable( Element element ) + throws Exception + { + Constructor cons = this.mergeableClass.getConstructor( new Class[] { Element.class } ); + // XXX Is there a better way to determine this? + if ( this.mergeableClass.getSuperclass().equals( AbstractMergeableElementList.class ) ) + { + return (AbstractMergeableElementList) cons.newInstance( new Object[] { element } ); + } + else if ( this.mergeableClass.getSuperclass().equals( AbstractMergeableElement.class ) ) + { + return (AbstractMergeableElement) cons.newInstance( new Object[] { element } ); + } + else + { + // TODO set up Logger + // if (getLogger ().isErrorEnabled ()) + // getLogger.error ( "Could not create Mergeable instance for specified class '" + this.mergeableClass + "'" ); + throw new Exception( "Could not create Mergeable instance for specified class " + "'" + this.mergeableClass + + "'" ); + } + } +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/support/Mergeable.java plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/support/Mergeable.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/support/Mergeable.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/support/Mergeable.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,74 @@ +package org.codehaus.plexus.metadata.merge.support; + +/* + * The MIT License + * + * Copyright (c) 2006, The Codehaus + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +import org.codehaus.plexus.metadata.merge.MergeException; +import org.codehaus.plexus.metadata.merge.MergeStrategy; +import org.jdom2.Element; + +/** + * Interface that marks an implementing entity as mergeable.

+ * Not all the elements/tags are expected to implement this interface.
+ * It should be implemented by elements/tags that need to have a certain control on how elements of the same type are merged with them. + * + * @author Rahul Thakur + * @version $Id$ + */ +public interface Mergeable +{ + /** + * Merges an element of same type. + * + * @param me Another entity that is mergeable. + * @throws MergeException if there was an error merging the mergeables. + */ + void merge( Mergeable me ) + throws MergeException; + + /** + * Applies the passed in {@link MergeStrategy} to merge two {@link Mergeable} instance.

+ * + * @param me Recessive {@link Mergeable} instance. + * @param strategy {@link MergeStrategy} to apply for merging. + * @throws MergeException if there was an error while merging. + */ + void merge( Mergeable me, MergeStrategy strategy ) + throws MergeException; + + /** + * Returns the wrapped up JDom {@link Element} instance that was used to create this Mergeable. + * + * @return the wrapped up JDom {@link Element} instance. + */ + Element getElement(); + + /** + * Returns an array of tags/elements that are allowed under the current + * element. + * + * @return the allowedTags + */ + DescriptorTag[] getAllowedTags(); +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/support/MergeStrategies.java plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/support/MergeStrategies.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/support/MergeStrategies.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/support/MergeStrategies.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,82 @@ +package org.codehaus.plexus.metadata.merge.support; + +/* + * The MIT License + * + * Copyright (c) 2006, The Codehaus + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +import java.util.Collections; +import java.util.List; + +import org.codehaus.plexus.metadata.merge.MergeException; +import org.codehaus.plexus.metadata.merge.MergeStrategy; + +/** + * Collection of available Merge Strategies.

+ * TODO: Revisit and factor {@link Mergeable#merge(Mergeable)} to use a {@link MergeStrategy}. + * + * @author Rahul Thakur + * @version $Id$ + */ +public class MergeStrategies +{ + /** + * {@link MergeStrategy} implementation wherein the elements are merged + * down to the deepest available {@link Mergeable} instance in the DOM tree. + */ + public static final MergeStrategy DEEP = new MergeStrategy() + { + public void apply( Mergeable dElt, Mergeable rElt ) + throws MergeException + { + dElt.merge( rElt ); + } + }; + + /** + * {@link MergeStrategy} implementation wherein only the element on + * which the merge operation is called is 'merged'. The merge does not + * traverse the DOM tree any further. + */ + public static final MergeStrategy SHALLOW = new MergeStrategy() + { + /** + * @throws MergeException + * @see org.codehaus.plexus.metadata.merge.MergeStrategy#apply(Mergeable,Mergeable) + */ + public void apply( Mergeable dElt, Mergeable rElt ) + throws MergeException + { + AbstractMergeableElement dame = (AbstractMergeableElement) dElt; + AbstractMergeableElement rame = (AbstractMergeableElement) rElt; + + // check if the dominant was in conflict with recessive. + List elementNames = dame.getElementNamesForConflictResolution( Collections.EMPTY_LIST ); + + if ( !dame.isRecessiveElementInConflict( rame, elementNames ) ) + { + // no conflict, simply add recessive to dominant's parent + dame.getElement().addContent( rame.getElement() ); + } + } + }; +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/support/PlexusRootElement.java plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/support/PlexusRootElement.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/support/PlexusRootElement.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/support/PlexusRootElement.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,51 @@ +package org.codehaus.plexus.metadata.merge.support; + +/* + * The MIT License + * + * Copyright (c) 2006, The Codehaus + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +import org.jdom2.Element; + +/** + * @author Rahul Thakur + * @version $Id$ + */ +public class PlexusRootElement + extends AbstractMergeableElement +{ + public PlexusRootElement( Element element ) + { + super( element ); + } + + public DescriptorTag[] getAllowedTags() + { + // TODO: add the managers, etc + return new DescriptorTag[]{ComponentsElement.TAG}; + } + + protected boolean isExpectedElementType( Mergeable me ) + { + return me instanceof PlexusRootElement; + } +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/support/PlexusXmlTag.java plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/support/PlexusXmlTag.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/support/PlexusXmlTag.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/support/PlexusXmlTag.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,62 @@ +package org.codehaus.plexus.metadata.merge.support; + +/** + * All allowable tags in components.xml and their bindings to + * {@link org.codehaus.plexus.metadata.merge.support.Mergeable} counterparts (if required). + *

+ * This implementation may change.
+ * TODO Might be an idea factor and set up the list of allowed tags here itself. + * + * @author Rahul Thakur + * @version $Id$ + */ +public class PlexusXmlTag + extends DescriptorTag +{ + public static final PlexusXmlTag COMPONENT_SET = new PlexusXmlTag( "component-set", + false, ComponentSetElement.class ); + + public static final PlexusXmlTag COMPONENTS = new PlexusXmlTag( "components", + true, ComponentsElement.class ); + + public static final PlexusXmlTag COMPONENT = new PlexusXmlTag( "component", true, ComponentElement.class ); + + public static final PlexusXmlTag ROLE = new PlexusXmlTag( "role" ); + + public static final PlexusXmlTag ROLE_HINT = new PlexusXmlTag( "role-hint" ); + + public static final PlexusXmlTag FIELD_NAME = new PlexusXmlTag( "field-name" ); + + public static final PlexusXmlTag IMPLEMENTATION = new PlexusXmlTag( "implementation" ); + + public static final PlexusXmlTag LIFECYCLE_HANDLER = new PlexusXmlTag( "lifecycle-handler", false, null ); + + public static final PlexusXmlTag REQUIREMENTS = + new PlexusXmlTag( "requirements", true, RequirementsElement.class ); + + public static final PlexusXmlTag CONFIGURATION = + new PlexusXmlTag( "configuration", true, ConfigurationElement.class ); + + public static final PlexusXmlTag REQUIREMENT = + new PlexusXmlTag( "requirement", true, RequirementElement.class ); + + /** + * @param tagName + * @param isMultipleAllowed + * @param mergeableClass Class that wraps this tag (as JDom element) and provides for merging same tags. + */ + private PlexusXmlTag( String tagName, boolean isMultipleAllowed, Class mergeableClass ) + { + super( tagName, isMultipleAllowed, mergeableClass ); + } + + /** + * By default we don't allow multiples of same tag names. + * + * @param tagName + */ + private PlexusXmlTag( String tagName ) + { + super( tagName, false, null ); + } +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/support/RequirementElement.java plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/support/RequirementElement.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/support/RequirementElement.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/support/RequirementElement.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,60 @@ +package org.codehaus.plexus.metadata.merge.support; + +/* + * The MIT License + * + * Copyright (c) 2006, The Codehaus + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +import org.codehaus.plexus.metadata.merge.MergeException; +import org.jdom2.Element; + +/** + * @author Rahul Thakur + * @version $Id$ + */ +public class RequirementElement + extends AbstractMergeableElement +{ + static final DescriptorTag TAG = new DescriptorTag( "requirement", true, RequirementElement.class ); + + public RequirementElement( Element element ) + { + super( element ); + } + + public DescriptorTag[] getAllowedTags() + { + return new DescriptorTag[] { ComponentElement.ROLE, ComponentElement.ROLE_HINT, ComponentElement.FIELD_NAME, + ComponentElement.OPTIONAL }; + } + + public void merge( Mergeable me ) + throws MergeException + { + super.merge( me ); + } + + protected boolean isExpectedElementType( Mergeable me ) + { + return me instanceof RequirementElement; + } +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/support/RequirementsElement.java plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/support/RequirementsElement.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/support/RequirementsElement.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/merge/support/RequirementsElement.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,71 @@ +package org.codehaus.plexus.metadata.merge.support; + +/* + * The MIT License + * + * Copyright (c) 2006, The Codehaus + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +import java.util.ArrayList; +import java.util.List; + +import org.jdom2.Element; + +/** + * @author Rahul Thakur + * @version $Id$ + */ +public class RequirementsElement + extends AbstractMergeableElementList +{ + public static final DescriptorTag TAG = new DescriptorTag( "requirements", true, RequirementsElement.class ); + + public RequirementsElement( Element element ) + { + super( element ); + } + + protected boolean isExpectedElementType( Mergeable me ) + { + return me instanceof RequirementsElement; + } + + public DescriptorTag[] getAllowedTags() + { + return new DescriptorTag[]{RequirementElement.TAG}; + } + + protected List getElementNamesForConflictResolution( List defaultList ) + { + // we return the keys that we know we want to lookup to identify and + // resolve conflicts. + List l = new ArrayList(); + l.add( ComponentElement.ROLE.getTagName() ); + // TODO: add this back, but a test will fail (based on a role with no hint, which shouldn't be legal) +// l.add( ComponentElement.ROLE_HINT.getTagName() ); + return l; + } + + protected String getTagNameForRecurringMergeable() + { + return RequirementElement.TAG.getTagName(); + } +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/MetadataGenerationRequest.java plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/MetadataGenerationRequest.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/MetadataGenerationRequest.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/MetadataGenerationRequest.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,36 @@ +package org.codehaus.plexus.metadata; + +import java.io.File; +import java.util.List; + +public class MetadataGenerationRequest +{ + /** Source to examine for Javadoc annotions which are used to generate component metadata. */ + public List sourceDirectories; //todo: these should be files + + /** The character encoding of the source files, may be {@code null} or empty to use platform's default encoding. */ + public String sourceEncoding; + + /** Classes to examine for annotations which are used to generate component metadata. */ + public File classesDirectory; + + /** Supporting classpath required by class-based annotation processing. */ + public List classpath; //todo: these should be files + + /** Flag to indicate using the context classloader for the supporting classpath required by annotation-based processing. */ + public boolean useContextClassLoader; + + /** Directory where existing component descriptors live. */ + public File componentDescriptorDirectory; + + /** Existing component descriptors that need to be merged. */ + public List componentDescriptors; + + /** Where existing component descriptors are merged. */ + public File intermediaryFile; + + /** Output file for the final component descriptor. */ + public File outputFile; + + public List extractors; +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/MetadataGenerator.java plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/MetadataGenerator.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/MetadataGenerator.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/MetadataGenerator.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,8 @@ +package org.codehaus.plexus.metadata; + +public interface MetadataGenerator +{ + void generateDescriptor( MetadataGenerationRequest configuration ) + throws Exception; + +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/PlexusMetadataGeneratorCli.java plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/PlexusMetadataGeneratorCli.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/PlexusMetadataGeneratorCli.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/PlexusMetadataGeneratorCli.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,62 @@ +package org.codehaus.plexus.metadata; + +import java.io.File; +import java.util.Arrays; +import java.util.Collections; + +import org.apache.commons.cli.CommandLine; +import org.apache.commons.cli.OptionBuilder; +import org.apache.commons.cli.Options; +import org.codehaus.plexus.PlexusContainer; +import org.codehaus.plexus.tools.cli.AbstractCli; + +public class PlexusMetadataGeneratorCli + extends AbstractCli +{ + public static final char SOURCE_DIRECTORY = 's'; + public static final char SOURCE_ENCODING = 'e'; + public static final char CLASSES_DIRECTORY = 'c'; + public static final char OUTPUT_FILE = 'o'; + public static final char DESCRIPTORS_DIRECTORY = 'm'; + + public static void main( String[] args ) + throws Exception + { + new PlexusMetadataGeneratorCli().execute( args ); + } + + @Override + public String getPomPropertiesPath() + { + return "META-INF/maven/org.codehaus.plexus/plexus-metadata-generator/pom.properties"; + } + + @Override + @SuppressWarnings("static-access") + public Options buildCliOptions( Options options ) + { + options.addOption( OptionBuilder.withLongOpt( "source" ).hasArg().withDescription( "Source directory." ).create( SOURCE_DIRECTORY ) ); + options.addOption( OptionBuilder.withLongOpt( "encoding" ).hasArg().withDescription( "Source file encoding." ).create( SOURCE_ENCODING ) ); + options.addOption( OptionBuilder.withLongOpt( "classes" ).hasArg().withDescription( "Classes directory." ).create( CLASSES_DIRECTORY ) ); + options.addOption( OptionBuilder.withLongOpt( "output" ).hasArg().withDescription( "Output directory." ).create( OUTPUT_FILE ) ); + options.addOption( OptionBuilder.withLongOpt( "descriptors" ).hasArg().withDescription( "Descriptors directory." ).create( DESCRIPTORS_DIRECTORY ) ); + return options; + } + + public void invokePlexusComponent( CommandLine cli, PlexusContainer plexus ) + throws Exception + { + MetadataGenerator metadataGenerator = plexus.lookup( MetadataGenerator.class ); + + MetadataGenerationRequest request = new MetadataGenerationRequest(); + request.classesDirectory = new File( cli.getOptionValue( CLASSES_DIRECTORY ) ); + request.classpath = Collections.emptyList(); + request.sourceDirectories = Arrays.asList( new String[]{ new File( cli.getOptionValue( SOURCE_DIRECTORY ) ).getAbsolutePath() } ); + request.sourceEncoding = cli.getOptionValue( SOURCE_ENCODING ); + request.useContextClassLoader = true; + request.outputFile = new File( cli.getOptionValue( OUTPUT_FILE ) ); + request.componentDescriptorDirectory = new File( cli.getOptionValue( DESCRIPTORS_DIRECTORY ) ); + + metadataGenerator.generateDescriptor( request ); + } +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/SourceComponentDescriptorExtractor.java plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/SourceComponentDescriptorExtractor.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/SourceComponentDescriptorExtractor.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/main/java/org/codehaus/plexus/metadata/SourceComponentDescriptorExtractor.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,101 @@ +/* + * Copyright (C) 2007 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ + +package org.codehaus.plexus.metadata; + +import java.io.File; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Map; + +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.component.repository.ComponentDescriptor; +import org.codehaus.plexus.metadata.gleaner.QDoxComponentGleaner; +import org.codehaus.plexus.metadata.gleaner.SourceComponentGleaner; +import org.codehaus.plexus.util.StringUtils; + +import com.thoughtworks.qdox.JavaProjectBuilder; +import com.thoughtworks.qdox.model.JavaClass; + +/** + * Extracts {@link ComponentDescriptor} from source files. + * + * @version $Rev$ $Date$ + */ +@Component( role = ComponentDescriptorExtractor.class, hint = "source" ) +public class SourceComponentDescriptorExtractor + extends ComponentDescriptorExtractorSupport +{ + private SourceComponentGleaner gleaner; + + public SourceComponentDescriptorExtractor() + { + } + + public SourceComponentDescriptorExtractor( final SourceComponentGleaner gleaner ) + { + this.gleaner = gleaner; + } + + public List> extract( MetadataGenerationRequest configuration, final ComponentDescriptor[] roleDefaults ) + throws Exception + { + if ( gleaner == null ) + { + gleaner = new QDoxComponentGleaner(); + } + + return extract( configuration.sourceDirectories, configuration.sourceEncoding, getDefaultsByRole( roleDefaults ) ); + } + + private List> extract( final List sourceDirectories, final String sourceEncoding, final Map> defaultsByRole ) + throws Exception + { + assert sourceDirectories != null; + assert defaultsByRole != null; + + List> descriptors = new ArrayList>(); + + // Scan the sources + JavaProjectBuilder builder = new JavaProjectBuilder(); + + if ( StringUtils.isNotEmpty( sourceEncoding ) ) + { + builder.setEncoding( sourceEncoding ); + } + + for ( String sourceDirectory : sourceDirectories ) + { + File dir = new File( sourceDirectory ); + + builder.addSourceTree( dir ); + } + + Collection classes = builder.getClasses(); + + // For each class we find, try to glean off a descriptor + for (JavaClass aClass : classes) { + ComponentDescriptor descriptor = gleaner.glean(builder, aClass); + + if (descriptor != null) { + applyDefaults(descriptor, defaultsByRole); + + descriptors.add(descriptor); + } + } + + return descriptors; + } +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/resources/META-INF/plexus/components.xml plexus-containers-1.7.1/plexus-component-metadata/src/main/resources/META-INF/plexus/components.xml --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/main/resources/META-INF/plexus/components.xml 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/main/resources/META-INF/plexus/components.xml 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,60 @@ + + + + + + + org.codehaus.plexus.metadata.gleaner.SourceComponentGleaner + qdox + org.codehaus.plexus.metadata.gleaner.QDoxComponentGleaner + + + org.codehaus.plexus.metadata.ComponentDescriptorCreator + org.codehaus.plexus.metadata.DefaultComponentDescriptorCreator + + + org.codehaus.plexus.metadata.ComponentDescriptorExtractor + class + org.codehaus.plexus.metadata.ClassComponentDescriptorExtractor + + + org.codehaus.plexus.metadata.ComponentDescriptorExtractor + source + org.codehaus.plexus.metadata.SourceComponentDescriptorExtractor + + + org.codehaus.plexus.metadata.ComponentDescriptorWriter + org.codehaus.plexus.metadata.DefaultComponentDescriptorWriter + + + org.codehaus.plexus.metadata.merge.Merger + componentsXml + org.codehaus.plexus.metadata.merge.ComponentsXmlMerger + + + + org.codehaus.plexus.metadata.merge.Merger + plexusXml + org.codehaus.plexus.metadata.merge.PlexusXmlMerger + + + org.codehaus.plexus.metadata.gleaner.ClassComponentGleaner + annotation + org.codehaus.plexus.metadata.gleaner.AnnotationComponentGleaner + + + org.codehaus.plexus.metadata.MetadataGenerator + org.codehaus.plexus.metadata.DefaultMetadataGenerator + + + org.codehaus.plexus.metadata.merge.Merger + componentsXml + + + org.codehaus.plexus.metadata.ComponentDescriptorExtractor + extractorMap + + + + + \ No newline at end of file diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/site/site.xml plexus-containers-1.7.1/plexus-component-metadata/src/site/site.xml --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/site/site.xml 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/site/site.xml 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,12 @@ + + + + +

+ + + + + diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/test/java/org/codehaus/plexus/metadata/DefaultComponentDescriptorWriterTest.java plexus-containers-1.7.1/plexus-component-metadata/src/test/java/org/codehaus/plexus/metadata/DefaultComponentDescriptorWriterTest.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/test/java/org/codehaus/plexus/metadata/DefaultComponentDescriptorWriterTest.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/test/java/org/codehaus/plexus/metadata/DefaultComponentDescriptorWriterTest.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,99 @@ +/* + * Copyright (C) 2007 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.codehaus.plexus.metadata; + +import java.io.StringWriter; +import java.util.List; + +import org.codehaus.plexus.PlexusTestCase; +import org.codehaus.plexus.classworlds.ClassWorld; +import org.codehaus.plexus.classworlds.realm.ClassRealm; +import org.codehaus.plexus.component.repository.ComponentSetDescriptor; +import org.codehaus.plexus.component.repository.ComponentDescriptor; +import org.codehaus.plexus.component.repository.io.PlexusTools; +import org.codehaus.plexus.configuration.PlexusConfiguration; + +/** + * Test for the {@link DefaultComponentDescriptorWriter} class. + * + * @version $Rev$ $Date$ + */ +public class DefaultComponentDescriptorWriterTest + extends PlexusTestCase +{ + private DefaultComponentDescriptorWriter descriptorWriter; + + // @Override + protected void setUp() throws Exception { + super.setUp(); + + descriptorWriter = (DefaultComponentDescriptorWriter) lookup(ComponentDescriptorWriter.class); + assertNotNull(descriptorWriter); + } + + // @Override + protected void tearDown() throws Exception { + descriptorWriter = null; + + super.tearDown(); + } + + public void testBasic() throws Exception { + ComponentSetDescriptor set = new ComponentSetDescriptor(); + + ComponentDescriptor component = new ComponentDescriptor(); + component.setImplementation("java.lang.String"); + component.setRole("foo"); + component.setRoleHint("bar"); + component.setComponentFactory("baz"); + + set.addComponentDescriptor(component); + + StringWriter writer = new StringWriter(); + descriptorWriter.writeDescriptorSet(writer, set, false); + writer.flush(); + writer.close(); + + String xml = writer.toString(); + + assertTrue(xml.length() != 0); + + PlexusConfiguration config = PlexusTools.buildConfiguration(xml); + assertNotNull(config); + + ClassWorld classWorld = new ClassWorld( "test", Thread.currentThread().getContextClassLoader() ); + ClassRealm realm = classWorld.getRealm( "test" ); + org.codehaus.plexus.component.repository.ComponentSetDescriptor set2 = PlexusTools.buildComponentSet(config, realm); + assertNotNull(set2); + + List components = set2.getComponents(); + assertNotNull(components); + assertEquals(1, components.size()); + + org.codehaus.plexus.component.repository.ComponentDescriptor component2 = + (org.codehaus.plexus.component.repository.ComponentDescriptor) components.get(0); + assertNotNull(component2); + + assertEquals(component.getRole(), component2.getRole()); + assertEquals(component.getRoleHint(), component2.getRoleHint()); + assertEquals(component.getComponentFactory(), component2.getComponentFactory()); + + // + // TODO: Verify requirements and configuration too... but I'm too lazy for that right now + // + } +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/test/java/org/codehaus/plexus/metadata/gleaner/AbstractClass.java plexus-containers-1.7.1/plexus-component-metadata/src/test/java/org/codehaus/plexus/metadata/gleaner/AbstractClass.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/test/java/org/codehaus/plexus/metadata/gleaner/AbstractClass.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/test/java/org/codehaus/plexus/metadata/gleaner/AbstractClass.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2007 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.codehaus.plexus.metadata.gleaner; + +/** + * ??? + * + * @version $Id$ + */ +public abstract class AbstractClass +{ +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/test/java/org/codehaus/plexus/metadata/gleaner/AbstractWithAnnoClass.java plexus-containers-1.7.1/plexus-component-metadata/src/test/java/org/codehaus/plexus/metadata/gleaner/AbstractWithAnnoClass.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/test/java/org/codehaus/plexus/metadata/gleaner/AbstractWithAnnoClass.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/test/java/org/codehaus/plexus/metadata/gleaner/AbstractWithAnnoClass.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2007 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.codehaus.plexus.metadata.gleaner; + +/** + * ??? + * + * @plexus.component role="foo" + * + * @version $Id$ + */ +public abstract class AbstractWithAnnoClass +{ +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/test/java/org/codehaus/plexus/metadata/gleaner/ann/AnnotatedComponentDependency.java plexus-containers-1.7.1/plexus-component-metadata/src/test/java/org/codehaus/plexus/metadata/gleaner/ann/AnnotatedComponentDependency.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/test/java/org/codehaus/plexus/metadata/gleaner/ann/AnnotatedComponentDependency.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/test/java/org/codehaus/plexus/metadata/gleaner/ann/AnnotatedComponentDependency.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2007 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.codehaus.plexus.metadata.gleaner.ann; + +/** + * @author Eugene Kuleshov + */ +public class AnnotatedComponentDependency { + +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/test/java/org/codehaus/plexus/metadata/gleaner/ann/AnnotatedComponent.java plexus-containers-1.7.1/plexus-component-metadata/src/test/java/org/codehaus/plexus/metadata/gleaner/ann/AnnotatedComponent.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/test/java/org/codehaus/plexus/metadata/gleaner/ann/AnnotatedComponent.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/test/java/org/codehaus/plexus/metadata/gleaner/ann/AnnotatedComponent.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2007 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.codehaus.plexus.metadata.gleaner.ann; + +import java.util.List; + +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.component.annotations.Configuration; +import org.codehaus.plexus.component.annotations.Requirement; + +/** + * @author Eugene Kuleshov + */ +@Component(type="foo", role=AnnotatedComponentRole.class) +public class AnnotatedComponent implements AnnotatedComponentRole { + + @Requirement(hint="default") + @Configuration(name="param", value="value") + AnnotatedComponentDependency dependency; + + @Requirement(role=AnnotatedComponentDependency.class, hints={"release", "latest", "snapshot"}) + List dependency2; + +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/test/java/org/codehaus/plexus/metadata/gleaner/ann/AnnotatedComponentRole.java plexus-containers-1.7.1/plexus-component-metadata/src/test/java/org/codehaus/plexus/metadata/gleaner/ann/AnnotatedComponentRole.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/test/java/org/codehaus/plexus/metadata/gleaner/ann/AnnotatedComponentRole.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/test/java/org/codehaus/plexus/metadata/gleaner/ann/AnnotatedComponentRole.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2007 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.codehaus.plexus.metadata.gleaner.ann; + +public interface AnnotatedComponentRole { + +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/test/java/org/codehaus/plexus/metadata/gleaner/AnnotationComponentGleanerTest.java plexus-containers-1.7.1/plexus-component-metadata/src/test/java/org/codehaus/plexus/metadata/gleaner/AnnotationComponentGleanerTest.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/test/java/org/codehaus/plexus/metadata/gleaner/AnnotationComponentGleanerTest.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/test/java/org/codehaus/plexus/metadata/gleaner/AnnotationComponentGleanerTest.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2007 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.codehaus.plexus.metadata.gleaner; + +import java.util.List; + +import org.codehaus.plexus.component.repository.ComponentDescriptor; +import org.codehaus.plexus.component.repository.ComponentRequirement; +import org.codehaus.plexus.configuration.PlexusConfiguration; +import org.codehaus.plexus.metadata.gleaner.ann.AnnotatedComponent; +import org.codehaus.plexus.metadata.gleaner.ann.AnnotatedComponentRole; + +import junit.framework.TestCase; + +/** + * @author Eugene Kuleshov + */ +public class AnnotationComponentGleanerTest extends TestCase { + + public void testGlean() throws Exception { + AnnotationComponentGleaner gleaner = new AnnotationComponentGleaner(); + Class c = AnnotatedComponent.class; + ComponentDescriptor descriptor = gleaner.glean(c.getName(), c.getClassLoader()); + + assertEquals("foo", descriptor.getComponentType()); + assertEquals(AnnotatedComponentRole.class.getName(), descriptor.getRole()); + + List requirements = descriptor.getRequirements(); + assertEquals(requirements.toString(), 2, requirements.size()); + + ComponentRequirement requirement = requirements.get(0); + assertEquals("dependency", requirement.getFieldName()); + assertEquals("default", requirement.getRoleHint()); + + ComponentRequirement requirement2 = requirements.get(1); + assertEquals("dependency2", requirement2.getFieldName()); + assertEquals("release,latest,snapshot", requirement2.getRoleHint()); + + PlexusConfiguration configuration = descriptor.getConfiguration(); + assertEquals(1, configuration.getChildCount()); + PlexusConfiguration child = configuration.getChild(0); + assertEquals("param", child.getName()); + assertEquals("value", child.getValue()); + } + +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/test/java/org/codehaus/plexus/metadata/gleaner/ChildComponent.java plexus-containers-1.7.1/plexus-component-metadata/src/test/java/org/codehaus/plexus/metadata/gleaner/ChildComponent.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/test/java/org/codehaus/plexus/metadata/gleaner/ChildComponent.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/test/java/org/codehaus/plexus/metadata/gleaner/ChildComponent.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2007 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.codehaus.plexus.metadata.gleaner; + +/** + * ??? + * + * @plexus.component role="org.codehaus.plexus.metadata.gleaner.ChildComponent" + * + * @version $Id$ + */ +public class ChildComponent +{ +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/test/java/org/codehaus/plexus/metadata/gleaner/MyComponent.java plexus-containers-1.7.1/plexus-component-metadata/src/test/java/org/codehaus/plexus/metadata/gleaner/MyComponent.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/test/java/org/codehaus/plexus/metadata/gleaner/MyComponent.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/test/java/org/codehaus/plexus/metadata/gleaner/MyComponent.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2007 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.codehaus.plexus.metadata.gleaner; + +/** + * ??? + * + * @plexus.component role="org.codehaus.plexus.metadata.gleaner.MyComponent" role-hint="foo" + * + * @version $Rev: 7691 $ $Date$ + */ +public class MyComponent +{ + /** + * @plexus.requirement + */ + private ChildComponent child; + + /** + * @plexus.configuration default-value="bar" + */ + private String foo; +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/test/java/org/codehaus/plexus/metadata/gleaner/NoAnnotationsClass.java plexus-containers-1.7.1/plexus-component-metadata/src/test/java/org/codehaus/plexus/metadata/gleaner/NoAnnotationsClass.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/test/java/org/codehaus/plexus/metadata/gleaner/NoAnnotationsClass.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/test/java/org/codehaus/plexus/metadata/gleaner/NoAnnotationsClass.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2007 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.codehaus.plexus.metadata.gleaner; + +/** + * ??? + * + * @version $Id$ + */ +public class NoAnnotationsClass +{ +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/test/java/org/codehaus/plexus/metadata/gleaner/NoAnnotationsIntf.java plexus-containers-1.7.1/plexus-component-metadata/src/test/java/org/codehaus/plexus/metadata/gleaner/NoAnnotationsIntf.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/test/java/org/codehaus/plexus/metadata/gleaner/NoAnnotationsIntf.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/test/java/org/codehaus/plexus/metadata/gleaner/NoAnnotationsIntf.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2007 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.codehaus.plexus.metadata.gleaner; + +/** + * ??? + * + * @version $Id$ + */ +public interface NoAnnotationsIntf +{ +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/test/java/org/codehaus/plexus/metadata/gleaner/QDoxComponentGleanerTest.java plexus-containers-1.7.1/plexus-component-metadata/src/test/java/org/codehaus/plexus/metadata/gleaner/QDoxComponentGleanerTest.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/test/java/org/codehaus/plexus/metadata/gleaner/QDoxComponentGleanerTest.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/test/java/org/codehaus/plexus/metadata/gleaner/QDoxComponentGleanerTest.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,161 @@ +/* + * Copyright (C) 2007 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ + +package org.codehaus.plexus.metadata.gleaner; + +import java.io.File; +import java.io.IOException; +import java.util.List; + +import org.codehaus.plexus.PlexusTestCase; +import org.codehaus.plexus.component.repository.ComponentDescriptor; +import org.codehaus.plexus.component.repository.ComponentRequirement; +import org.codehaus.plexus.configuration.PlexusConfiguration; + +import com.thoughtworks.qdox.JavaProjectBuilder; +import com.thoughtworks.qdox.model.JavaClass; +import com.thoughtworks.qdox.model.JavaSource; + +/** + * Tests for the {@link QDoxComponentGleaner} class. + * + * @version $Rev$ $Date$ + */ +public class QDoxComponentGleanerTest + extends PlexusTestCase +{ + private QDoxComponentGleaner gleaner; + + private JavaProjectBuilder builder; + + // @Override + protected void setUp() + throws Exception + { + super.setUp(); + + gleaner = new QDoxComponentGleaner(); + builder = new JavaProjectBuilder(); + } + + // @Override + protected void tearDown() + throws Exception + { + gleaner = null; + builder = null; + + super.tearDown(); + } + + private JavaSource addSource( final String name ) + throws IOException + { + File url = new File( getBasedir(), "src/test/java/" + getClass().getPackage().getName().replace( '.', '/' ) + "/" + name ); + assertTrue( url.exists() ); + return builder.addSource( url ); + } + + + private JavaClass loadJavaClass( final String name ) + throws IOException + { + JavaSource source = addSource( name ); + assertNotNull( source ); + + List classes = source.getClasses(); + assertNotNull( classes ); + assertEquals( 1, classes.size() ); + + assertNotNull( classes.get(0) ); + + return classes.get(0); + } + + private ComponentDescriptor glean( final String name, final String[] supporting ) + throws Exception + { + if ( supporting != null ) + { + for ( String aSupporting : supporting ) + { + addSource( aSupporting ); + } + } + + return gleaner.glean( builder, loadJavaClass( name ) ); + } + + private ComponentDescriptor glean( final String name ) + throws Exception + { + return glean( name, null ); + } + + public void testNoAnnotationsClass() + throws Exception + { + ComponentDescriptor component = glean( "NoAnnotationsClass.java" ); + assertNull( component ); + } + + public void testAbstractClass() + throws Exception + { + ComponentDescriptor component = glean( "AbstractClass.java" ); + assertNull( component ); + } + + /* + public void testAbstractWithAnnoClass() throws Exception { + ComponentDescriptor component = glean("AbstractWithAnnoClass.java"); + assertNull(component); + } + */ + + public void testNoAnnotationsIntf() + throws Exception + { + ComponentDescriptor component = glean( "NoAnnotationsIntf.java" ); + assertNull( component ); + } + + public void testMyComponent() + throws Exception + { + addSource( "ChildComponent.java" ); + ComponentDescriptor component = glean( "MyComponent.java" ); + assertNotNull( component ); + + assertEquals( MyComponent.class.getName(), component.getRole() ); + assertEquals( "foo", component.getRoleHint() ); + + List requirements = component.getRequirements(); + assertNotNull( requirements ); + assertEquals( 1, requirements.size() ); + + ComponentRequirement requirement = requirements.get( 0 ); + assertNotNull( requirement ); + assertEquals( ChildComponent.class.getName(), requirement.getRole() ); + + PlexusConfiguration config = component.getConfiguration(); + assertNotNull( config ); + assertEquals( 1, config.getChildCount() ); + + PlexusConfiguration child = config.getChild( 0 ); + assertNotNull( child ); + assertEquals( "foo", child.getName() ); + assertEquals( "bar", child.getValue() ); + } +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/test/java/org/codehaus/plexus/metadata/merge/ComponentsXmlMergerTest.java plexus-containers-1.7.1/plexus-component-metadata/src/test/java/org/codehaus/plexus/metadata/merge/ComponentsXmlMergerTest.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/test/java/org/codehaus/plexus/metadata/merge/ComponentsXmlMergerTest.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/test/java/org/codehaus/plexus/metadata/merge/ComponentsXmlMergerTest.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,272 @@ +package org.codehaus.plexus.metadata.merge; + +/* + * The MIT License + * + * Copyright (c) 2006, The Codehaus + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +import java.io.File; +import java.util.List; + +import org.codehaus.plexus.PlexusTestCase; +import org.codehaus.plexus.metadata.merge.support.AbstractMergeableElement; +import org.codehaus.plexus.metadata.merge.support.AbstractMergeableElementList; +import org.codehaus.plexus.metadata.merge.support.ComponentElement; +import org.codehaus.plexus.metadata.merge.support.ComponentsElement; +import org.codehaus.plexus.metadata.merge.support.RequirementsElement; +import org.codehaus.plexus.util.FileUtils; +import org.jdom2.Document; +import org.jdom2.Element; +import org.jdom2.input.SAXBuilder; + +/** + * Tests for {@link ComponentsXmlMerger}. + * + * @author Rahul Thakur + * @version $Id$ + */ +public class ComponentsXmlMergerTest + extends PlexusTestCase +{ + public void testBasic() + throws Exception + { + ComponentsXmlMerger merger = (ComponentsXmlMerger) lookup( Merger.class, "componentsXml" ); + assertNotNull( merger ); + } + + public void testComponentsXmlFileMerge() + throws Exception + { + File dominantXml = getTestFile( "src/test/resources/org/codehaus/plexus/metadata/merge/dominant.xml" ); + File recessiveXml = getTestFile( "src/test/resources/org/codehaus/plexus/metadata/merge/recessive.xml" ); + Document dDoc = new SAXBuilder().build( dominantXml ); + Document rDoc = new SAXBuilder().build( recessiveXml ); + // ComponentsXmlMerger merger = new ComponentsXmlMerger (dDoc); + Merger merger = lookup( Merger.class, "componentsXml" ); + assertNotNull( merger ); + merger.merge( dDoc, rDoc ); + + File merged_xml = getTestFile( "target/merged.xml" ); + if ( merged_xml.exists() ) + { + FileUtils.forceDelete( merged_xml ); + } + merger.writeMergedDocument( dDoc, merged_xml ); + assertTrue( merged_xml.exists() ); + // read merged xml and verify it was merged as expected + Document mDoc = new SAXBuilder().build( merged_xml ); + Element mRootElt = mDoc.getRootElement(); + assertTrue( mRootElt.getName().equals( "component-set" ) ); + assertEquals( 1, mRootElt.getChildren( "components" ).size() ); + List componentEltList = mRootElt.getChild( "components" ).getChildren( "component" ); + assertEquals( 2, componentEltList.size() ); + Element cElt = (Element) componentEltList.get( 0 ); + + assertEquals( "org.codehaus.plexus.metadata.component.IComponent", cElt.getChildTextTrim( "role" ) ); + assertEquals( "org.codehaus.plexus.metadata.component.DominantComponent", cElt.getChildTextTrim( "implementation" ) ); + + assertEquals( "Should only have 1 description element.", 1, cElt.getChildren( "description" ).size() ); + assertEquals( "Description for Dominant component", cElt.getChildTextTrim( "description" ) ); + + assertEquals( "Should only have 1 configuration element.", 1, cElt.getChildren( "configuration" ).size() ); + // assert Merged configuration properties + Element configurationElt = cElt.getChild( "configuration" ); + assertNotNull( configurationElt ); + assertEquals( 1, configurationElt.getChildren( "prop1" ).size() ); + assertEquals( "Dominant Property1 value", configurationElt.getChildTextTrim( "prop1" ) ); + assertEquals( 1, configurationElt.getChildren( "prop2" ).size() ); + assertEquals( 0, configurationElt.getChildren( "prop3" ).size() ); + + // now for the second component + cElt = (Element) componentEltList.get( 1 ); + assertEquals( "org.codehaus.plexus.metadata.component.INonConflictingComponent", cElt.getChildTextTrim( "role" ) ); + assertEquals( "org.codehaus.plexus.metadata.component.RecessiveComponent", cElt.getChildTextTrim( "implementation" ) ); + + assertEquals( 1, mRootElt.getChildren( "lifecycle-handler-manager" ).size() ); + assertEquals( "org.codehaus.plexus.lifecycle.DefaultLifecycleHandlerManager", mRootElt + .getChild( "lifecycle-handler-manager" ).getAttributeValue( "implementation" ) ); + } + + public void testInvalidMergeableElements() + throws Exception + { + // dominant Component Element + AbstractMergeableElement dCE = new ComponentElement( new Element( "component" ) ); + Element roleElt = new Element( "role" ); + roleElt.setText( "org.codehaus.plexus.ISampleRole" ); + dCE.addContent( roleElt ); + + AbstractMergeableElementList reqElt = new RequirementsElement( new Element( "requirement" ) ); + // attempt and invalid merge + try + { + dCE.merge( reqElt ); + fail( "Expected MergeException!" ); + } + catch ( MergeException e ) + { + // do nothing. + } + } + + /** + * Tests if <component> elements from two sets are being merged properly. + * + * @throws Exception if there was an unexpected error. + */ + public void testComponentsMerge() + throws Exception + { + // dominant Components Element + AbstractMergeableElement dParent = new ComponentsElement( new Element( "components" ) ); + Element dCE = new Element( "component" ); + dParent.addContent( dCE ); + Element roleElt = new Element( "role" ); + roleElt.setText( "org.codehaus.plexus.ISampleRole" ); + dCE.addContent( roleElt ); + Element roleHintElt = new Element( "role-hint" ); + roleHintElt.setText( "sample-role-hint" ); + dCE.addContent( roleHintElt ); + Element implElt = new Element( "implementation" ); + implElt.setText( "org.codehaus.plexus.DominantImplementation" ); + dCE.addContent( implElt ); + Element requirementsElt = new Element( "requirements" ); + Element reqElt = new Element( "requirement" ); + Element reqRoleElt = new Element( "role" ); + reqRoleElt.setText( "org.codehaus.plexus.IRequiredRole" ); + reqElt.addContent( reqRoleElt ); + requirementsElt.addContent( reqElt ); + dCE.addContent( requirementsElt ); + + // recessive Component Element + AbstractMergeableElement rParent = new ComponentsElement( new Element( "components" ) ); + Element rCE = new Element( "component" ); + rParent.addContent( rCE ); + roleElt = new Element( "role" ); + roleElt.setText( "org.codehaus.plexus.ISampleRole" ); + rCE.addContent( roleElt ); + roleHintElt = new Element( "role-hint" ); + roleHintElt.setText( "sample-role-hint" ); + rCE.addContent( roleHintElt ); + implElt = new Element( "implementation" ); + implElt.setText( "org.codehaus.plexus.RecessiveImplementation" ); + rCE.addContent( implElt ); + Element lifecycleHandlerElt = new Element( "lifecycle-handler" ); + rCE.addContent( lifecycleHandlerElt ); + lifecycleHandlerElt.setText( "plexus-configurable" ); + requirementsElt = new Element( "requirements" ); + reqElt = new Element( "requirement" ); + reqRoleElt = new Element( "role" ); + reqRoleElt.setText( "org.codehaus.plexus.IRequiredRole" ); + reqElt.addContent( reqRoleElt ); + requirementsElt.addContent( reqElt ); + Element reqRoleHintElt = new Element( "role-hint" ); + reqRoleHintElt.setText( "recessive-required-role-hint" ); + reqElt.addContent( reqRoleHintElt ); + rCE.addContent( requirementsElt ); + + // attempt to merge + dParent.merge( rParent ); + assertEquals( 1, dParent.getChildren( "component" ).size() ); + assertEquals( "org.codehaus.plexus.DominantImplementation", dParent.getChild( "component" ) + .getChildText( "implementation" ) ); + assertEquals( 1, dParent.getChild( "component" ).getChild( "requirements" ).getChildren( "requirement" ).size() ); + } + + /** + * This is deprecated as we dont' want to drill to merging + * nested elements within a component.

+ * Keeping this around for testing MergeStrategy implmentation. + * + * @throws Exception + */ + public void testDeepComponentsMerge() + throws Exception + { + // FIXME: Review this after MergeStrategies are in place. + if ( true ) + { + return; + } + + // dominant Component Element + AbstractMergeableElement dCE = new ComponentElement( new Element( "component" ) ); + Element roleElt = new Element( "role" ); + roleElt.setText( "org.codehaus.plexus.ISampleRole" ); + dCE.addContent( roleElt ); + Element roleHintElt; + // roleHintElt = new Element ("role-hint"); + // roleHintElt.setText ("sample-hint"); + // dCE.addContent (roleHintElt); + Element implElt = new Element( "implementation" ); + implElt.setText( "org.codehaus.plexus.DominantImplementation" ); + dCE.addContent( implElt ); + Element requirementsElt = new Element( "requirements" ); + Element reqElt = new Element( "requirement" ); + Element reqRoleElt = new Element( "role" ); + reqRoleElt.setText( "org.codehaus.plexus.IRequiredRole" ); + reqElt.addContent( reqRoleElt ); + requirementsElt.addContent( reqElt ); + dCE.addContent( requirementsElt ); + + // recessive Component Element + AbstractMergeableElement rCE = new ComponentElement( new Element( "component" ) ); + roleElt = new Element( "role" ); + roleElt.setText( "org.codehaus.plexus.ISampleRole" ); + rCE.addContent( roleElt ); + roleHintElt = new Element( "role-hint" ); + roleHintElt.setText( "recessive-hint" ); + rCE.addContent( roleHintElt ); + implElt = new Element( "implementation" ); + implElt.setText( "org.codehaus.plexus.RecessiveImplementation" ); + rCE.addContent( implElt ); + Element lifecycleHandlerElt = new Element( "lifecycle-handler" ); + rCE.addContent( lifecycleHandlerElt ); + lifecycleHandlerElt.setText( "plexus-configurable" ); + requirementsElt = new Element( "requirements" ); + reqElt = new Element( "requirement" ); + reqRoleElt = new Element( "role" ); + reqRoleElt.setText( "org.codehaus.plexus.IRequiredRole" ); + reqElt.addContent( reqRoleElt ); + requirementsElt.addContent( reqElt ); + Element reqRoleHintElt = new Element( "role-hint" ); + reqRoleHintElt.setText( "recessive-required-role-hint" ); + reqElt.addContent( reqRoleHintElt ); + rCE.addContent( requirementsElt ); + + // attempt to merge + dCE.merge( rCE ); + + // verify the merge + assertTrue( null != dCE.getChild( "role" ) ); + assertEquals( "org.codehaus.plexus.ISampleRole", dCE.getChildText( "role" ) ); + assertTrue( null != dCE.getChild( "role-hint" ) ); + assertEquals( "recessive-hint", dCE.getChildText( "role-hint" ) ); + assertTrue( null != dCE.getChild( "lifecycle-handler" ) ); + assertEquals( "plexus-configurable", dCE.getChildText( "lifecycle-handler" ) ); + assertTrue( null != dCE.getChild( "requirements" ) ); + assertEquals( 1, dCE.getChild( "requirements" ).getChildren( "requirement" ).size() ); + assertEquals( "recessive-required-role-hint", ( (Element) dCE.getChild( "requirements" ) + .getChildren( "requirement" ).get( 0 ) ).getChildText( "role-hint" ) ); + } +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/test/resources/org/codehaus/plexus/metadata/merge/dominant.xml plexus-containers-1.7.1/plexus-component-metadata/src/test/resources/org/codehaus/plexus/metadata/merge/dominant.xml --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/test/resources/org/codehaus/plexus/metadata/merge/dominant.xml 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/test/resources/org/codehaus/plexus/metadata/merge/dominant.xml 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,18 @@ + + + + org.codehaus.plexus.metadata.component.IComponent + org.codehaus.plexus.metadata.component.DominantComponent + Description for Dominant component + + Dominant Property1 value + Dominant Property2 value + + + + org.codehaus.plexus.metadata.component.IComponentA + + + + + \ No newline at end of file diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/test/resources/org/codehaus/plexus/metadata/merge/recessive.xml plexus-containers-1.7.1/plexus-component-metadata/src/test/resources/org/codehaus/plexus/metadata/merge/recessive.xml --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/test/resources/org/codehaus/plexus/metadata/merge/recessive.xml 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/test/resources/org/codehaus/plexus/metadata/merge/recessive.xml 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,51 @@ + + + + org.codehaus.plexus.metadata.component.IComponent + org.codehaus.plexus.metadata.component.RecessiveComponent + Description for conflicting recessive component + + Recessive Property1 value + Property3 value + + + + org.codehaus.plexus.metadata.component.IComponentA + recessiveField + + + + + + + org.codehaus.plexus.metadata.component.INonConflictingComponent + org.codehaus.plexus.metadata.component.RecessiveComponent + Description for non-conflicting recessive component + + Non conflicting Property1 value + Non conflicting Property2 value + + + + org.codehaus.plexus.metadata.component.IComponentA + + + + + + + webapp + + + webapp + Webapp + + + + + + + + + + diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/test/resources/projects/project-01/pom.xml plexus-containers-1.7.1/plexus-component-metadata/src/test/resources/projects/project-01/pom.xml --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/test/resources/projects/project-01/pom.xml 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/test/resources/projects/project-01/pom.xml 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,27 @@ + + + 4.0.0 + plexus-maven-test + plexus-maven-plugin-test + 0.1 + Plexus Maven Plugin Test + + + + org.codehaus.plexus + plexus-maven-plugin + + true + + + + + descriptor + + + + + + + diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/test/resources/projects/project-01/src/main/java/org/codehaus/plexus/component/HelloImpl.java plexus-containers-1.7.1/plexus-component-metadata/src/test/resources/projects/project-01/src/main/java/org/codehaus/plexus/component/HelloImpl.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/test/resources/projects/project-01/src/main/java/org/codehaus/plexus/component/HelloImpl.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/test/resources/projects/project-01/src/main/java/org/codehaus/plexus/component/HelloImpl.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,21 @@ +package org.codehaus.plexus.component; + +/** + * @plexus.component + */ +public class HelloImpl + implements Hello +{ + + /** + * @plexus.configuration expression="${expression}" default-value="Hello World!" + * @required + */ + private String message; + + public void sayHello() + { + System.out.print( message ); + } + +} \ No newline at end of file diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/test/resources/projects/project-01/src/main/java/org/codehaus/plexus/component/Hello.java plexus-containers-1.7.1/plexus-component-metadata/src/test/resources/projects/project-01/src/main/java/org/codehaus/plexus/component/Hello.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/test/resources/projects/project-01/src/main/java/org/codehaus/plexus/component/Hello.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/test/resources/projects/project-01/src/main/java/org/codehaus/plexus/component/Hello.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,9 @@ +package org.codehaus.plexus.component; + +public interface Hello +{ + + final static String ROLE = Hello.class.getName(); + + void sayHello(); +} \ No newline at end of file diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/test/sources/Component.java plexus-containers-1.7.1/plexus-component-metadata/src/test/sources/Component.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/test/sources/Component.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/test/sources/Component.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,7 @@ +/** + * @plexus.component + */ +public class Component +{ +} + diff -Nru plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/test/sources/Empty.java plexus-containers-1.7.1/plexus-component-metadata/src/test/sources/Empty.java --- plexus-containers-1.0~beta3.0.7/plexus-component-metadata/src/test/sources/Empty.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-component-metadata/src/test/sources/Empty.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,2 @@ +/* No class in here */ + diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/pom.xml plexus-containers-1.7.1/plexus-container-default/pom.xml --- plexus-containers-1.0~beta3.0.7/plexus-container-default/pom.xml 2009-05-13 15:28:46.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/pom.xml 2016-08-31 19:01:49.000000000 +0000 @@ -1,26 +1,19 @@ - + 4.0.0 + org.codehaus.plexus plexus-containers - 1.0-beta-3.0.7 + 1.7.1 + plexus-container-default + Plexus :: Default Container - - - - maven-surefire-plugin - - once - - **/Test*.java - **/Abstract*.java - - - - - + + The Plexus IoC container API and its default implementation. + + org.codehaus.plexus @@ -35,8 +28,61 @@ xbean-reflect - com.google.code.google-collections - google-collect + com.google.collections + google-collections + + + junit + junit + + + + + maven-surefire-plugin + + once + + **/Test*.java + **/Abstract*.java + + + + + org.codehaus.modello + modello-maven-plugin + 1.1 + + + src/main/mdo/components.mdo + src/main/mdo/plexus.mdo + + 1.3.0 + + + + xsd-site + pre-site + + xsd + + + ${basedir}/target/generated-site/resources/xsd + + + + descriptor-site + pre-site + + xdoc + + + 1.0.0 + + + + + + diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/ClassRealmUtil.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/ClassRealmUtil.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/ClassRealmUtil.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/ClassRealmUtil.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,83 @@ +package org.codehaus.plexus; + +/* + * Copyright 2001-2009 Codehaus Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import java.util.Collection; +import java.util.Iterator; +import java.util.LinkedHashSet; +import java.util.LinkedList; +import java.util.Queue; +import java.util.Set; + +import org.codehaus.plexus.classworlds.ClassWorld; +import org.codehaus.plexus.classworlds.realm.ClassRealm; + +public class ClassRealmUtil +{ + + public static Set getContextRealms( ClassWorld world ) + { + Set realms = new LinkedHashSet(); + + for ( ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); classLoader != null; classLoader = + classLoader.getParent() ) + { + if ( classLoader instanceof ClassRealm ) + { + realms.add( (ClassRealm) classLoader ); + + Queue queue = new LinkedList(); + queue.add( (ClassRealm) classLoader ); + + while ( !queue.isEmpty() ) + { + ClassRealm realm = queue.remove(); + + Collection importRealms = realm.getImportRealms(); + for ( ClassRealm importRealm : importRealms ) + { + if ( realms.add( importRealm ) ) + { + queue.add( importRealm ); + } + } + + ClassRealm parentRealm = realm.getParentRealm(); + if ( parentRealm != null && realms.add( parentRealm ) ) + { + queue.add( parentRealm ); + } + } + } + } + + if ( world != null ) + { + for ( Iterator it = realms.iterator(); it.hasNext(); ) + { + ClassRealm realm = it.next(); + if ( realm.getWorld() != world ) + { + it.remove(); + } + } + } + + return realms; + } + +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/builder/XBeanComponentBuilder.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/builder/XBeanComponentBuilder.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/builder/XBeanComponentBuilder.java 2009-01-21 01:34:55.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/builder/XBeanComponentBuilder.java 2016-08-31 19:01:49.000000000 +0000 @@ -149,17 +149,19 @@ ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(realm); try { - ObjectRecipe recipe = createObjectRecipe(descriptor, realm); + ObjectRecipe recipe; T instance; ComponentFactory componentFactory = container.getComponentFactoryManager().findComponentFactory(descriptor.getComponentFactory()); if (JavaComponentFactory.class.equals(componentFactory.getClass())) { // xbean-reflect will create object and do injection + recipe = createObjectRecipe( null, descriptor, realm ); instance = (T) recipe.create(); } else { // todo figure out how to easily let xbean use the factory to construct the component // use object factory to construct component and then inject into that object instance = (T) componentFactory.newInstance(descriptor, realm, container); + recipe = createObjectRecipe( instance, descriptor, realm ); recipe.setProperties( instance ); } @@ -172,17 +174,40 @@ return instance; } catch (Exception e) { throw new ComponentLifecycleException("Error constructing component " + descriptor.getHumanReadableKey(), e); + } catch (LinkageError e) { + throw new ComponentLifecycleException("Error constructing component " + descriptor.getHumanReadableKey(), e); } finally { Thread.currentThread().setContextClassLoader(oldClassLoader); } } - public ObjectRecipe createObjectRecipe(ComponentDescriptor descriptor, ClassRealm realm) throws ComponentInstantiationException, PlexusConfigurationException { + public ObjectRecipe createObjectRecipe(T instance, ComponentDescriptor descriptor, ClassRealm realm) throws ComponentInstantiationException, PlexusConfigurationException { String factoryMethod = null; String[] constructorArgNames = null; Class[] constructorArgTypes = null; - ObjectRecipe recipe = new ObjectRecipe(descriptor.getImplementationClass(), + Class implClass = ( instance != null ) ? instance.getClass() : descriptor.getImplementationClass(); + + if ( implClass == null || implClass == Object.class ) + { + // if the descriptor could not load the class, it's time to report this up to the caller now + try + { + realm.loadClass( descriptor.getImplementation() ); + } + catch ( ClassNotFoundException e ) + { + throw new ComponentInstantiationException( "Could not load implementation class for component " + + descriptor.getHumanReadableKey() + " from class realm " + realm, e ); + } + catch ( LinkageError e ) + { + throw new ComponentInstantiationException( "Could not load implementation class for component " + + descriptor.getHumanReadableKey() + " from class realm " + realm, e ); + } + } + + ObjectRecipe recipe = new ObjectRecipe( implClass, factoryMethod, constructorArgNames, constructorArgTypes); @@ -190,7 +215,7 @@ recipe.allow(Option.PRIVATE_PROPERTIES); // MapOrientedComponents don't get normal injection - if (!MapOrientedComponent.class.isAssignableFrom(descriptor.getImplementationClass())) { + if (!MapOrientedComponent.class.isAssignableFrom( implClass )) { for (ComponentRequirement requirement : descriptor.getRequirements() ) { String name = requirement.getFieldName(); RequirementRecipe requirementRecipe = new RequirementRecipe(descriptor, requirement, getContainer(), name == null); @@ -219,10 +244,13 @@ for (PlexusConfiguration child : configuration.getChildren()) { String name = child.getName(); name = fromXML(name); - if (child.getChildCount() == 0) { - recipe.setProperty(name, child.getValue()); - } else { - recipe.setProperty(name, new PlexusConfigurationRecipe(child)); + if ( StringUtils.isNotEmpty( child.getValue( null ) ) ) + { + recipe.setProperty( name, child.getValue() ); + } + else + { + recipe.setProperty( name, new PlexusConfigurationRecipe( child ) ); } } } @@ -377,6 +405,11 @@ return assignment; } catch (ComponentLookupException e) { + if ( requirement.isOptional() ) + { + return null; + } + throw new ConstructionException("Composition failed of field " + requirement.getFieldName() + " " + "in object of type " + componentDescriptor.getImplementation() + " because the requirement " + requirement + " was missing)", e); diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/collections/AbstractComponentCollection.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/collections/AbstractComponentCollection.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/collections/AbstractComponentCollection.java 2008-11-14 22:07:56.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/collections/AbstractComponentCollection.java 2016-08-31 19:01:49.000000000 +0000 @@ -1,13 +1,15 @@ package org.codehaus.plexus.component.collections; import org.codehaus.plexus.MutablePlexusContainer; -import org.codehaus.plexus.classworlds.realm.ClassRealm; import org.codehaus.plexus.classworlds.ClassWorld; +import org.codehaus.plexus.classworlds.realm.ClassRealm; import org.codehaus.plexus.component.repository.ComponentDescriptor; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.logging.Logger; +import java.util.Collection; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; @@ -57,18 +59,17 @@ /** Used to log errors in the component lookup process. */ protected Logger logger; - private List realms; - - private int lastRealmCount = -1; + private ClassLoader tccl; + private Collection realms; private Map> componentDescriptorMap; - private ClassWorld world; + private final ClassWorld world; - public AbstractComponentCollection( MutablePlexusContainer container, - Class componentType, - String role, - List roleHints, - String hostComponent ) + public AbstractComponentCollection( final MutablePlexusContainer container, + final Class componentType, + final String role, + final List roleHints, + final String hostComponent ) { this.container = container; @@ -87,16 +88,18 @@ private boolean realmsHaveChanged() { - return ( realms == null ) || ( world.getRealms().size() != lastRealmCount ); + return ( tccl != Thread.currentThread().getContextClassLoader() ) || + ( realms == null ) || ( !realms.equals( world.getRealms() ) ); } - protected Map> getComponentDescriptorMap() + protected synchronized Map> getComponentDescriptorMap() { checkUpdate(); return componentDescriptorMap; } + @SuppressWarnings( "unchecked" ) protected boolean checkUpdate() { if ( componentDescriptorMap != null && !realmsHaveChanged() ) @@ -104,8 +107,20 @@ return false; } - Map> newComponentDescriptors = new HashMap>(); + tccl = Thread.currentThread().getContextClassLoader(); + Collection fromWorld = world.getRealms(); + if ( fromWorld == null || fromWorld.isEmpty() ) + { + realms = null; + } + else + { + realms = new HashSet( fromWorld ); + } + Map> componentMap = container.getComponentDescriptorMap( componentType, role ); + Map> newComponentDescriptors = + new HashMap>( componentMap.size() * 2 ); if ( roleHints != null && !roleHints.isEmpty() ) { @@ -123,7 +138,7 @@ newComponentDescriptors.putAll( componentMap ); } - if ( componentDescriptorMap == null || newComponentDescriptors.size() != componentDescriptorMap.size() ) + if ( componentDescriptorMap == null || !newComponentDescriptors.equals( componentDescriptorMap ) ) { componentDescriptorMap = newComponentDescriptors; @@ -133,30 +148,34 @@ return false; } - protected T lookup( String role, String roleHint ) + protected T lookup( ComponentDescriptor componentDescriptor ) { + T component = null; + try { - return container.lookup( componentType, role, roleHint ); + if ( componentDescriptor != null ) + { + component = container.lookup( componentDescriptor ); + } } catch ( ComponentLookupException e ) { - logger.debug( "Failed to lookup a member of active collection with role: " + role - + " and role-hint: " + roleHint, e ); - - return null; + logger.debug( "Failed to lookup a member of active collection with role: " + role + " and role-hint: " + + componentDescriptor.getRoleHint(), e ); } + + return component; } - public void clear() + public synchronized void clear() { releaseAllCallback(); - componentDescriptorMap.clear(); componentDescriptorMap = null; + tccl = null; realms = null; - lastRealmCount = -1; } protected abstract void releaseAllCallback(); diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/collections/ComponentList.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/collections/ComponentList.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/collections/ComponentList.java 2008-11-14 22:07:56.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/collections/ComponentList.java 2016-08-31 19:01:49.000000000 +0000 @@ -67,19 +67,14 @@ return getList().toArray(); } - public Object[] toArray( Object[] ts ) + public X[] toArray( X[] ts ) { return getList().toArray( ts ); } - public boolean add( T object ) + public synchronized boolean add( T object ) { - if ( components == null ) - { - components = new ArrayList(); - } - - components.add( object ); + getList().add( object ); /* * PLX-352 This is strictly to support the hack in the Ant Run plugin that tries to poke in a custom converter. @@ -114,12 +109,12 @@ + hostComponent + " and managed by the container." ); } - public boolean removeAll( Collection collection ) + public synchronized boolean removeAll( Collection collection ) { return getList().removeAll( collection ); } - public boolean retainAll( Collection collection ) + public synchronized boolean retainAll( Collection collection ) { return getList().retainAll( collection ); } @@ -192,7 +187,7 @@ return getList().subList( fromIndex, toIndex ); } - private List getList() + private synchronized List getList() { // NOTE: If we cache the component map, we have a problem with releasing any of the // components in this map...we need to be able to release them all. @@ -207,7 +202,10 @@ // we must follow the order in roleHints for ( String roleHint : roleHints ) { - T component = lookup( role, roleHint ); + ComponentDescriptor componentDescriptor = descriptorMap.get( roleHint ); + + T component = lookup( componentDescriptor ); + if ( component != null ) { componentList.add( component ); @@ -218,9 +216,10 @@ { for ( Entry> entry : descriptorMap.entrySet() ) { - String roleHint = entry.getKey(); + ComponentDescriptor componentDescriptor = entry.getValue(); + + T component = lookup( componentDescriptor ); - T component = lookup( role, roleHint ); if ( component != null ) { componentList.add( component ); @@ -233,6 +232,19 @@ return components; } + @Override + protected boolean checkUpdate() + { + if ( super.checkUpdate() ) + { + components = null; + + return true; + } + + return false; + } + protected void releaseAllCallback() { if ( components != null ) @@ -246,7 +258,6 @@ logger.debug( "Error releasing components in active collection: " + e.getMessage(), e ); } - components.clear(); components = null; } } diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/collections/ComponentMap.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/collections/ComponentMap.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/collections/ComponentMap.java 2008-11-14 22:07:56.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/collections/ComponentMap.java 2016-08-31 19:01:49.000000000 +0000 @@ -54,8 +54,7 @@ public boolean containsKey( Object key ) { - Map> descriptorMap = getComponentDescriptorMap(); - return descriptorMap.containsKey( key ); + return getComponentDescriptorMap().containsKey( key ); } public boolean containsValue( Object value ) @@ -65,20 +64,10 @@ public T get( Object k ) { - Map> descriptorMap = getComponentDescriptorMap(); - if ( k instanceof String ) - { - String key = (String) k; - if ( descriptorMap.containsKey( key ) ) - { - return lookup( role, key ); - } - } - - return null; + return getMap().get( k ); } - public T put( String key, T value ) + public synchronized T put( String key, T value ) { logger.warn( "Custom " + role @@ -93,7 +82,7 @@ return prev; } - public void putAll( Map map ) + public synchronized void putAll( Map map ) { logger.warn( "Custom " + role @@ -137,13 +126,12 @@ return getMap().hashCode(); } - public T remove( Object k ) + public synchronized T remove( Object key ) { logger.warn( "Items in this Map should NOT be removed directly. If the matching entry is a component, it will NOT be removed." ); - if ( k instanceof String ) + if ( key instanceof String ) { - String key = (String) k; if ( customAdditions.containsKey( key ) ) { return customAdditions.remove( key ); @@ -153,7 +141,7 @@ return null; } - private Map getMap() + private synchronized Map getMap() { Map result = getComponentMap(); @@ -165,11 +153,11 @@ return result; } - private Map getComponentMap() + private synchronized Map getComponentMap() { if ( ( components == null ) || checkUpdate() ) { - components = new LinkedHashMap(); + Map componentMap = new LinkedHashMap(); Map> descriptorMap = getComponentDescriptorMap(); @@ -178,10 +166,13 @@ // we must follow the order given in roleHints for ( String roleHint : roleHints ) { - T component = lookup( role, roleHint ); + ComponentDescriptor componentDescriptor = descriptorMap.get( roleHint ); + + T component = lookup( componentDescriptor ); + if ( component != null ) { - components.put( roleHint, component ); + componentMap.put( roleHint, component ); } } } @@ -191,18 +182,35 @@ { String roleHint = entry.getKey(); - T component = lookup( role, roleHint ); + ComponentDescriptor componentDescriptor = entry.getValue(); + + T component = lookup( componentDescriptor ); + if ( component != null ) { - components.put( roleHint, component ); + componentMap.put( roleHint, component ); } } } + components = componentMap; } return components; } + @Override + protected boolean checkUpdate() + { + if ( super.checkUpdate() ) + { + components = null; + + return true; + } + + return false; + } + protected void releaseAllCallback() { if ( components != null ) @@ -216,7 +224,6 @@ logger.debug( "Error releasing components in active collection: " + e.getMessage(), e ); } - components.clear(); components = null; } } diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/composition/CompositionException.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/composition/CompositionException.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/composition/CompositionException.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/composition/CompositionException.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,51 +0,0 @@ -package org.codehaus.plexus.component.composition; - -/* - * Copyright 2001-2006 Codehaus Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * Thrown when component composition goes awry. - * - * @author Jason van Zyl - * @author Michal Maczka - * @version $Id: CompositionException.java 7089 2007-11-25 15:19:06Z jvanzyl $ - */ -public class CompositionException - extends Exception -{ - private static final long serialVersionUID = -5587124702588800322L; - - /** - * Construct a new CompositionException instance. - * - * @param message The detail message for this exception. - */ - public CompositionException( String message ) - { - super( message ); - } - - /** - * Construct a new CompositionException instance. - * - * @param message The detail message for this exception. - * @param throwable the root cause of the exception - */ - public CompositionException( String message, Throwable throwable ) - { - super( message, throwable ); - } -} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/composition/CompositionResolver.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/composition/CompositionResolver.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/composition/CompositionResolver.java 2008-11-14 22:07:56.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/composition/CompositionResolver.java 2016-08-31 19:01:49.000000000 +0000 @@ -23,7 +23,7 @@ /** * @author Jason van Zyl * @author Michal Maczka - * @version $Id: CompositionResolver.java 7828 2008-11-14 22:07:56Z dain $ + * @version $Id$ */ public interface CompositionResolver { @@ -31,9 +31,10 @@ /** * @param componentDescriptor - * @throws CompositionException when cycle is detected + * @throws CycleDetectedInComponentGraphException when cycle is detected */ - void addComponentDescriptor( ComponentDescriptor componentDescriptor ) throws CompositionException; + void addComponentDescriptor( ComponentDescriptor componentDescriptor ) + throws CycleDetectedInComponentGraphException; /** * Returns the list of names of components which are required diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/composition/CycleDetectedInComponentGraphException.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/composition/CycleDetectedInComponentGraphException.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/composition/CycleDetectedInComponentGraphException.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/composition/CycleDetectedInComponentGraphException.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,51 @@ +package org.codehaus.plexus.component.composition; + +/* + * Copyright 2001-2006 Codehaus Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Thrown when component composition goes awry. + * + * @author Jason van Zyl + * @author Michal Maczka + * @version $Id$ + */ +public class CycleDetectedInComponentGraphException + extends Exception +{ + private static final long serialVersionUID = -5587124702588800322L; + + /** + * Construct a new CompositionException instance. + * + * @param message The detail message for this exception. + */ + public CycleDetectedInComponentGraphException( String message ) + { + super( message ); + } + + /** + * Construct a new CompositionException instance. + * + * @param message The detail message for this exception. + * @param throwable the root cause of the exception + */ + public CycleDetectedInComponentGraphException( String message, Throwable throwable ) + { + super( message, throwable ); + } +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/composition/DefaultCompositionResolver.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/composition/DefaultCompositionResolver.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/composition/DefaultCompositionResolver.java 2008-11-14 22:07:56.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/composition/DefaultCompositionResolver.java 2016-08-31 19:01:49.000000000 +0000 @@ -16,20 +16,21 @@ * limitations under the License. */ +import java.util.List; + +import org.codehaus.plexus.PlexusConstants; import org.codehaus.plexus.component.repository.ComponentDescriptor; import org.codehaus.plexus.component.repository.ComponentRequirement; import org.codehaus.plexus.component.repository.ComponentRequirementList; +import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.dag.CycleDetectedException; import org.codehaus.plexus.util.dag.DAG; -import java.util.Iterator; -import java.util.List; - /** * @author Jason van Zyl * @author Michal Maczka - * @version $Id: DefaultCompositionResolver.java 7828 2008-11-14 22:07:56Z dain $ + * @version $Id$ */ public class DefaultCompositionResolver implements CompositionResolver @@ -37,7 +38,7 @@ private DAG dag = new DAG(); public void addComponentDescriptor( ComponentDescriptor componentDescriptor ) - throws CompositionException + throws CycleDetectedInComponentGraphException { String key = getDAGKey( componentDescriptor.getRole(), componentDescriptor.getRoleHint() ); @@ -61,7 +62,7 @@ } catch ( CycleDetectedException e ) { - throw new CompositionException( "Cyclic requirement detected", e ); + throw new CycleDetectedInComponentGraphException( "Cyclic requirement detected", e ); } } } @@ -85,6 +86,7 @@ private String getDAGKey( String role, String roleHint ) { - return role + SEPARATOR_CHAR + roleHint; + return role + SEPARATOR_CHAR + + ( StringUtils.isNotEmpty( roleHint ) ? roleHint : PlexusConstants.PLEXUS_DEFAULT_HINT ); } } diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/composition/UndefinedComponentComposerException.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/composition/UndefinedComponentComposerException.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/composition/UndefinedComponentComposerException.java 2006-11-23 03:54:18.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/composition/UndefinedComponentComposerException.java 2016-08-31 19:01:49.000000000 +0000 @@ -18,7 +18,7 @@ /** * @author Michal Maczka - * @version $Id: UndefinedComponentComposerException.java 4778 2006-11-23 03:54:18Z jvanzyl $ + * @version $Id$ */ public class UndefinedComponentComposerException extends Exception diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/AbstractComponentConfigurator.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/AbstractComponentConfigurator.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/AbstractComponentConfigurator.java 2007-10-23 07:15:56.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/AbstractComponentConfigurator.java 2016-08-31 19:01:49.000000000 +0000 @@ -32,11 +32,12 @@ import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; import org.codehaus.plexus.configuration.PlexusConfiguration; +import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; /** * @author Brett Porter - * @version $Id: AbstractComponentConfigurator.java 6993 2007-10-23 07:15:56Z jvanzyl $ + * @version $Id$ */ public abstract class AbstractComponentConfigurator implements ComponentConfigurator @@ -68,35 +69,57 @@ configureComponent( component, configuration, expressionEvaluator, containerRealm, null ); } - public void configureComponent( Object component, - PlexusConfiguration configuration, - ExpressionEvaluator expressionEvaluator, - ClassRealm containerRealm, - ConfigurationListener listener ) + public void configureComponent( final Object component, final PlexusConfiguration configuration, + final ExpressionEvaluator expressionEvaluator, final ClassRealm containerRealm, + final ConfigurationListener listener ) throws ComponentConfigurationException { // ---------------------------------------------------------------------------- // For compatibility with old ComponentFactories that use old ClassWorlds // ---------------------------------------------------------------------------- - org.codehaus.classworlds.ClassRealm cr = ClassRealmAdapter.getInstance( containerRealm ); + final org.codehaus.classworlds.ClassRealm cr = ClassRealmAdapter.getInstance( containerRealm ); Method method; try { - method = getClass().getMethod( "configureComponent", new Class[]{Object.class, PlexusConfiguration.class, - ExpressionEvaluator.class, org.codehaus.classworlds.ClassRealm.class, ConfigurationListener.class} ); - - method.invoke( this, new Object[]{component, configuration, expressionEvaluator, cr, listener} ); + try + { + method = + getClass().getMethod( "configureComponent", Object.class, PlexusConfiguration.class, + ExpressionEvaluator.class, org.codehaus.classworlds.ClassRealm.class, + ConfigurationListener.class ); + method.invoke( this, component, configuration, expressionEvaluator, cr, listener ); + } + catch ( final NoSuchMethodException e ) + { + method = + getClass().getMethod( "configureComponent", Object.class, PlexusConfiguration.class, + ExpressionEvaluator.class, org.codehaus.classworlds.ClassRealm.class ); + method.invoke( this, component, configuration, expressionEvaluator, cr ); + } } - catch ( Exception mnfe ) + catch ( final InvocationTargetException e ) { - mnfe.printStackTrace(); + if ( e.getCause() instanceof ComponentConfigurationException ) + { + throw (ComponentConfigurationException) e.getCause(); + } + else if ( e.getCause() instanceof RuntimeException ) + { + throw (RuntimeException) e.getCause(); + } + else if ( e.getCause() instanceof Error ) + { + throw (Error) e.getCause(); + } + throw new ComponentConfigurationException( "Incompatible configurator " + getClass().getName(), e ); + } + catch ( final Exception e ) + { + throw new ComponentConfigurationException( "Incompatible configurator " + getClass().getName(), e ); } - - // TODO: here so extended classes without the method continue to work. should be removed - // this won't hit the method above going into a loop - instead, it will hit the overridden one - //configureComponent( component, configuration, expressionEvaluator, containerRealm ); } + } diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/BasicComponentConfigurator.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/BasicComponentConfigurator.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/BasicComponentConfigurator.java 2007-10-23 05:31:36.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/BasicComponentConfigurator.java 2016-08-31 19:01:49.000000000 +0000 @@ -34,7 +34,7 @@ /** * @author Jason van Zyl * @author Michal Maczka - * @version $Id: BasicComponentConfigurator.java 6992 2007-10-23 05:31:36Z jvanzyl $ + * @version $Id$ */ public class BasicComponentConfigurator extends AbstractComponentConfigurator diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/ComponentConfigurationException.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/ComponentConfigurationException.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/ComponentConfigurationException.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/ComponentConfigurationException.java 2016-08-31 19:01:49.000000000 +0000 @@ -7,7 +7,7 @@ * * @author Jason van Zyl * - * @version $Id: ComponentConfigurationException.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public class ComponentConfigurationException extends Exception diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/ComponentConfigurator.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/ComponentConfigurator.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/ComponentConfigurator.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/ComponentConfigurator.java 2016-08-31 19:01:49.000000000 +0000 @@ -30,7 +30,7 @@ /** * @author Jason van Zyl - * @version $Id: ComponentConfigurator.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public interface ComponentConfigurator { diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/ConfigurationListener.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/ConfigurationListener.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/ConfigurationListener.java 2006-12-12 03:49:50.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/ConfigurationListener.java 2016-08-31 19:01:49.000000000 +0000 @@ -29,7 +29,7 @@ * Listen for configuration changes on an object. * * @author Brett Porter - * @version $Id: ConfigurationListener.java 5127 2006-12-12 03:49:50Z jvanzyl $ + * @version $Id$ */ public interface ConfigurationListener { diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/AbstractConfigurationConverter.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/AbstractConfigurationConverter.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/AbstractConfigurationConverter.java 2008-11-29 17:14:01.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/AbstractConfigurationConverter.java 2016-08-31 19:01:49.000000000 +0000 @@ -33,7 +33,7 @@ /** * @author Michal Maczka - * @version $Id: AbstractConfigurationConverter.java 7890 2008-11-29 17:14:01Z jvanzyl $ + * @version $Id$ */ public abstract class AbstractConfigurationConverter implements ConfigurationConverter diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/AbstractBasicConverter.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/AbstractBasicConverter.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/AbstractBasicConverter.java 2007-07-04 17:37:22.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/AbstractBasicConverter.java 2016-08-31 19:01:49.000000000 +0000 @@ -28,11 +28,13 @@ import org.codehaus.plexus.component.configurator.ConfigurationListener; import org.codehaus.plexus.component.configurator.converters.AbstractConfigurationConverter; import org.codehaus.plexus.component.configurator.converters.lookup.ConverterLookup; +import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException; import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; +import org.codehaus.plexus.component.configurator.expression.TypeAwareExpressionEvaluator; import org.codehaus.plexus.configuration.PlexusConfiguration; /** - * @version $Id: AbstractBasicConverter.java 6585 2007-07-04 17:37:22Z kenney $ + * @version $Id$ */ public abstract class AbstractBasicConverter extends AbstractConfigurationConverter @@ -40,6 +42,71 @@ protected abstract Object fromString( String str ) throws ComponentConfigurationException; + protected Object fromExpression( PlexusConfiguration configuration, ExpressionEvaluator expressionEvaluator, Class type ) + throws ComponentConfigurationException + { + Object v = null; + + String value = configuration.getValue( null ); + + if ( value != null && value.length() > 0 ) + { + // Object is provided by an expression + // This seems a bit ugly... canConvert really should return false in this instance, but it doesn't have the + // configuration to know better + try + { + if ( expressionEvaluator instanceof TypeAwareExpressionEvaluator ) + { + v = ( (TypeAwareExpressionEvaluator) expressionEvaluator ).evaluate( value, type ); + } + else + { + v = expressionEvaluator.evaluate( value ); + } + } + catch ( ExpressionEvaluationException e ) + { + String msg = "Error evaluating the expression '" + value + "' for configuration value '" + + configuration.getName() + "'"; + throw new ComponentConfigurationException( configuration, msg, e ); + } + } + + if ( v == null ) + { + value = configuration.getAttribute( "default-value", null ); + + if ( value != null && value.length() > 0 ) + { + try + { + if ( expressionEvaluator instanceof TypeAwareExpressionEvaluator ) + { + v = ( (TypeAwareExpressionEvaluator) expressionEvaluator ).evaluate( value, type ); + } + else + { + v = expressionEvaluator.evaluate( value ); + } + } + catch ( ExpressionEvaluationException e ) + { + String msg = "Error evaluating the expression '" + value + "' for configuration value '" + + configuration.getName() + "'"; + throw new ComponentConfigurationException( configuration, msg, e ); + } + } + } + + /* + * NOTE: We don't check the type here which would be ugly to do correctly (e.g. value=Short -> type=int), the + * reflective setter/field injection will fail by itself when the type didn't match. + */ + + return v; + } + public Object fromConfiguration( ConverterLookup converterLookup, PlexusConfiguration configuration, Class type, Class baseType, ClassLoader classLoader, ExpressionEvaluator expressionEvaluator, ConfigurationListener listener ) @@ -51,11 +118,23 @@ "contain any child elements. " + "Configuration element '" + configuration.getName() + "'." ); } - Object retValue = fromExpression( configuration, expressionEvaluator ); + Object retValue = fromExpression( configuration, expressionEvaluator, type ); if ( retValue instanceof String ) { - retValue = fromString( (String) retValue ); + try + { + retValue = fromString( (String) retValue ); + } + catch ( ComponentConfigurationException e ) + { + if ( e.getFailedConfiguration() == null ) + { + e.setFailedConfiguration( configuration ); + } + + throw e; + } } return retValue; diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/ByteConverter.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/ByteConverter.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/ByteConverter.java 2006-12-12 03:49:50.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/ByteConverter.java 2016-08-31 19:01:49.000000000 +0000 @@ -34,7 +34,7 @@ public Object fromString( String str ) { - return new Byte( (byte) Integer.parseInt( str ) ); + return (byte) Integer.parseInt(str); } } diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/CharConverter.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/CharConverter.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/CharConverter.java 2006-12-12 03:49:50.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/CharConverter.java 2016-08-31 19:01:49.000000000 +0000 @@ -34,7 +34,7 @@ public Object fromString( String str ) { - return new Character( str.charAt( 0 ) ); + return str.charAt(0); } } diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/DateConverter.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/DateConverter.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/DateConverter.java 2006-12-12 03:49:50.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/DateConverter.java 2016-08-31 19:01:49.000000000 +0000 @@ -46,14 +46,10 @@ public Object fromString( String str ) { - for ( int i = 0; i < formats.length; i++ ) - { - try - { - return formats[i].parse( str ); - } - catch ( ParseException e ) - { + for (DateFormat format : formats) { + try { + return format.parse(str); + } catch (ParseException e) { // no worries, let's try the next format. } } diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/EnumConverter.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/EnumConverter.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/EnumConverter.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/EnumConverter.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,75 @@ +package org.codehaus.plexus.component.configurator.converters.basic; + +/* + * The MIT License + * + * Copyright (c) 2004, The Codehaus + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +import org.codehaus.plexus.component.configurator.ComponentConfigurationException; +import org.codehaus.plexus.component.configurator.ConfigurationListener; +import org.codehaus.plexus.component.configurator.converters.AbstractConfigurationConverter; +import org.codehaus.plexus.component.configurator.converters.lookup.ConverterLookup; +import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; +import org.codehaus.plexus.configuration.PlexusConfiguration; + +/** + * @author Benjamin Bentmann + */ +public class EnumConverter + extends AbstractConfigurationConverter +{ + + public boolean canConvert( Class type ) + { + return type.isEnum(); + } + + public Object fromConfiguration( ConverterLookup converterLookup, PlexusConfiguration configuration, Class type, + Class baseType, ClassLoader classLoader, ExpressionEvaluator expressionEvaluator, + ConfigurationListener listener ) + throws ComponentConfigurationException + { + if ( configuration.getChildCount() > 0 ) + { + throw new ComponentConfigurationException( "When configuring a basic element the configuration cannot " + + "contain any child elements. " + "Configuration element '" + configuration.getName() + "'." ); + } + + Object retValue = fromExpression( configuration, expressionEvaluator ); + + if ( retValue instanceof String ) + { + try + { + retValue = Enum.valueOf( type, (String) retValue ); + } + catch ( RuntimeException e ) + { + throw new ComponentConfigurationException( "Cannot assign value " + retValue + " to property " + + configuration.getName() + " of " + baseType.getName() + ": " + e.getMessage(), e ); + } + } + + return retValue; + } + +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/FileConverter.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/FileConverter.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/FileConverter.java 2006-12-12 03:49:50.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/FileConverter.java 2016-08-31 19:01:49.000000000 +0000 @@ -45,6 +45,7 @@ public Object fromString( String str ) { + str = str.replace( '\\', File.separatorChar ).replace( '/', File.separatorChar ); return new File( str ); } diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/UriConverter.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/UriConverter.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/UriConverter.java 2007-10-06 08:15:56.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/basic/UriConverter.java 2016-08-31 19:01:49.000000000 +0000 @@ -24,7 +24,7 @@ /** * Converter for {@link URI} objects. * - * @version $Id: UriConverter.java 6935 2007-10-06 08:15:56Z user57 $ + * @version $Id$ */ public class UriConverter extends AbstractBasicConverter diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/ComponentValueSetter.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/ComponentValueSetter.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/ComponentValueSetter.java 2008-11-29 17:14:01.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/ComponentValueSetter.java 2016-08-31 19:01:49.000000000 +0000 @@ -19,7 +19,6 @@ import org.codehaus.plexus.component.configurator.ComponentConfigurationException; import org.codehaus.plexus.component.configurator.ConfigurationListener; import org.codehaus.plexus.component.configurator.converters.lookup.ConverterLookup; -import org.codehaus.plexus.component.configurator.converters.lookup.DefaultConverterLookup; import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; import org.codehaus.plexus.configuration.PlexusConfiguration; import org.codehaus.plexus.util.ReflectionUtils; diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/composite/ArrayConverter.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/composite/ArrayConverter.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/composite/ArrayConverter.java 2009-01-04 19:41:09.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/composite/ArrayConverter.java 2016-08-31 19:01:49.000000000 +0000 @@ -40,7 +40,7 @@ /** * @author Kenney Westerhof - * @version $Id: ArrayConverter.java 8005 2009-01-04 19:41:09Z bentmann $ + * @version $Id$ */ public class ArrayConverter extends AbstractConfigurationConverter diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/composite/CollectionConverter.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/composite/CollectionConverter.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/composite/CollectionConverter.java 2009-01-04 18:39:40.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/composite/CollectionConverter.java 2016-08-31 19:01:49.000000000 +0000 @@ -46,7 +46,7 @@ /** * @author Michal Maczka - * @version $Id: CollectionConverter.java 8004 2009-01-04 18:39:40Z bentmann $ + * @version $Id$ */ public class CollectionConverter extends AbstractConfigurationConverter diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/composite/MapConverter.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/composite/MapConverter.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/composite/MapConverter.java 2008-04-14 20:27:40.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/composite/MapConverter.java 2016-08-31 19:01:49.000000000 +0000 @@ -39,7 +39,7 @@ * Converter for java.util.Properties. * * @author Michal Maczka - * @version $Id: MapConverter.java 7285 2008-04-14 20:27:40Z jdcasey $ + * @version $Id$ */ public class MapConverter extends AbstractConfigurationConverter @@ -69,13 +69,10 @@ PlexusConfiguration[] children = configuration.getChildren(); - for ( int i = 0; i < children.length; i++ ) - { - PlexusConfiguration child = children[i]; - + for (PlexusConfiguration child : children) { String name = child.getName(); - map.put( name, fromExpression( child, expressionEvaluator ) ); + map.put(name, fromExpression(child, expressionEvaluator)); } retValue = map; } diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/composite/ObjectWithFieldsConverter.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/composite/ObjectWithFieldsConverter.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/composite/ObjectWithFieldsConverter.java 2007-10-23 00:55:56.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/composite/ObjectWithFieldsConverter.java 2016-08-31 19:01:49.000000000 +0000 @@ -38,7 +38,7 @@ /** * @author Michal Maczka - * @version $Id: ObjectWithFieldsConverter.java 6990 2007-10-23 00:55:56Z jvanzyl $ + * @version $Id$ */ public class ObjectWithFieldsConverter extends AbstractConfigurationConverter @@ -82,6 +82,11 @@ // it is a "composite" - we compose it from its children. It does not have a value of its own Class implementation = getClassForImplementationHint( type, configuration, classLoader ); + if ( type == implementation && type.isInterface() && configuration.getChildCount() <= 0 ) + { + return null; + } + retValue = instantiateObject( implementation ); processConfiguration( converterLookup, retValue, classLoader, configuration, expressionEvaluator, listener ); diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/composite/PlexusConfigurationConverter.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/composite/PlexusConfigurationConverter.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/composite/PlexusConfigurationConverter.java 2007-03-13 12:39:55.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/composite/PlexusConfigurationConverter.java 2016-08-31 19:01:49.000000000 +0000 @@ -36,7 +36,7 @@ * Converter for org.codehaus.plexus.configuration.PlexusConfiguration * * @author Michal Maczka - * @version $Id: PlexusConfigurationConverter.java 6064 2007-03-13 12:39:55Z trygvis $ + * @version $Id$ */ public class PlexusConfigurationConverter extends AbstractConfigurationConverter diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/composite/PropertiesConverter.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/composite/PropertiesConverter.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/composite/PropertiesConverter.java 2007-03-13 12:39:55.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/composite/PropertiesConverter.java 2016-08-31 19:01:49.000000000 +0000 @@ -37,7 +37,7 @@ * Converter for java.util.Properties. * * @author Michal Maczka - * @version $Id: PropertiesConverter.java 6064 2007-03-13 12:39:55Z trygvis $ + * @version $Id$ */ public class PropertiesConverter extends AbstractConfigurationConverter @@ -67,34 +67,39 @@ if ( children != null && children.length > 0 ) { - for ( int i = 0; i < children.length; i++ ) - { - PlexusConfiguration child = children[i]; - - addEntry( retValue, element, child ); + for (PlexusConfiguration child : children) { + addEntry(retValue, element, child, expressionEvaluator); } } return retValue; } - private void addEntry( Properties properties, String element, PlexusConfiguration property ) + private void addEntry( Properties properties, String element, PlexusConfiguration property, + ExpressionEvaluator expressionEvaluator ) throws ComponentConfigurationException { - String name; - - name = property.getChild( "name" ).getValue( null ); + Object name = fromExpression( property.getChild( "name" ), expressionEvaluator ); if ( name == null ) { - String msg = "Converter: java.util.Properties. Trying to convert the configuration element: '" + element - + "', missing child element 'name'."; + String msg = + "Trying to convert the configuration element: '" + element + + "', missing child element 'name' for property."; throw new ComponentConfigurationException( msg ); } - String value = property.getChild( "value" ).getValue( "" ); + Object value = fromExpression( property.getChild( "value" ), expressionEvaluator ); - properties.put( name, value ); + if ( value == null ) + { + properties.setProperty( name.toString(), "" ); + } + else + { + properties.setProperty( name.toString(), value.toString() ); + } } + } diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/lookup/ConverterLookup.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/lookup/ConverterLookup.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/lookup/ConverterLookup.java 2008-11-14 22:07:56.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/lookup/ConverterLookup.java 2016-08-31 19:01:49.000000000 +0000 @@ -27,7 +27,7 @@ import org.codehaus.plexus.component.configurator.ComponentConfigurationException; import org.codehaus.plexus.component.configurator.converters.ConfigurationConverter; -/** @version $Id: ConverterLookup.java 7828 2008-11-14 22:07:56Z dain $ */ +/** @version $Id$ */ public interface ConverterLookup { void registerConverter( ConfigurationConverter converter ); diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/lookup/DefaultConverterLookup.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/lookup/DefaultConverterLookup.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/lookup/DefaultConverterLookup.java 2008-11-14 22:07:56.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/lookup/DefaultConverterLookup.java 2016-08-31 19:01:49.000000000 +0000 @@ -31,6 +31,7 @@ import org.codehaus.plexus.component.configurator.converters.basic.CharConverter; import org.codehaus.plexus.component.configurator.converters.basic.DateConverter; import org.codehaus.plexus.component.configurator.converters.basic.DoubleConverter; +import org.codehaus.plexus.component.configurator.converters.basic.EnumConverter; import org.codehaus.plexus.component.configurator.converters.basic.FileConverter; import org.codehaus.plexus.component.configurator.converters.basic.FloatConverter; import org.codehaus.plexus.component.configurator.converters.basic.IntConverter; @@ -47,10 +48,10 @@ import org.codehaus.plexus.component.configurator.converters.composite.PlexusConfigurationConverter; import org.codehaus.plexus.component.configurator.converters.composite.PropertiesConverter; -import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.ArrayList; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CopyOnWriteArrayList; public class DefaultConverterLookup @@ -60,7 +61,7 @@ private final List customConverters = new CopyOnWriteArrayList(); - private final Map, ConfigurationConverter> converterMap = new HashMap, ConfigurationConverter>(); + private final Map, ConfigurationConverter> converterMap = new ConcurrentHashMap, ConfigurationConverter>(); public DefaultConverterLookup() { @@ -82,13 +83,9 @@ public ConfigurationConverter lookupConverterForType( Class type ) throws ComponentConfigurationException { - ConfigurationConverter retValue = null; + ConfigurationConverter retValue = converterMap.get( type ); - if ( converterMap.containsKey( type ) ) - { - retValue = converterMap.get( type ); - } - else + if ( retValue == null ) { if ( customConverters != null ) { @@ -99,12 +96,14 @@ { retValue = findConverterForType( converters, type ); } - } - if ( retValue == null ) - { - // this is highly irregular - throw new ComponentConfigurationException( "Configuration converter lookup failed for type: " + type ); + if ( retValue == null ) + { + // this is highly irregular + throw new ComponentConfigurationException( "Configuration converter lookup failed for type: " + type ); + } + + converterMap.put( type, retValue ); } return retValue; @@ -116,8 +115,6 @@ { if ( converter.canConvert( type ) ) { - converterMap.put( type, converter ); - return converter; } } @@ -155,6 +152,8 @@ registerDefaultConverter( new UrlConverter() ); registerDefaultConverter( new UriConverter() ); + + registerDefaultConverter( new EnumConverter() ); } private void registerDefaultCompositeConverters() diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/special/ClassRealmConverter.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/special/ClassRealmConverter.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/special/ClassRealmConverter.java 2007-03-24 15:13:15.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/converters/special/ClassRealmConverter.java 2016-08-31 19:01:49.000000000 +0000 @@ -1,6 +1,7 @@ package org.codehaus.plexus.component.configurator.converters.special; import org.codehaus.classworlds.ClassRealmAdapter; +import org.codehaus.classworlds.ClassRealmReverseAdapter; import org.codehaus.plexus.classworlds.realm.ClassRealm; import org.codehaus.plexus.component.configurator.ComponentConfigurationException; import org.codehaus.plexus.component.configurator.ConfigurationListener; @@ -34,11 +35,30 @@ setClassRealm( classRealm ); } - public void setClassRealm( ClassRealm classRealm ) + @Deprecated + public ClassRealmConverter( final org.codehaus.classworlds.ClassRealm classRealm ) + { + setClassRealm( classRealm ); + } + + public void setClassRealm( final ClassRealm classRealm ) { this.classRealm = classRealm; } + @Deprecated + public void setClassRealm( final org.codehaus.classworlds.ClassRealm classRealm ) + { + if ( classRealm.getClassLoader() instanceof ClassRealm ) + { + setClassRealm( (ClassRealm) classRealm.getClassLoader() ); + } + else + { + setClassRealm( ClassRealmReverseAdapter.getInstance( classRealm ) ); + } + } + public boolean canConvert( Class type ) { // backwards compatibility for old ClassWorld fields diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/expression/DefaultExpressionEvaluator.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/expression/DefaultExpressionEvaluator.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/expression/DefaultExpressionEvaluator.java 2006-11-23 04:09:31.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/expression/DefaultExpressionEvaluator.java 2016-08-31 19:01:49.000000000 +0000 @@ -22,7 +22,7 @@ * Evaluate an expression. * * @author Brett Porter - * @version $Id: DefaultExpressionEvaluator.java 4779 2006-11-23 04:09:31Z jvanzyl $ + * @version $Id$ */ public class DefaultExpressionEvaluator implements ExpressionEvaluator diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/expression/ExpressionEvaluationException.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/expression/ExpressionEvaluationException.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/expression/ExpressionEvaluationException.java 2006-11-23 04:09:31.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/expression/ExpressionEvaluationException.java 2016-08-31 19:01:49.000000000 +0000 @@ -20,7 +20,7 @@ * Exception that occurs during the evaluation of an expression. * * @author Brett Porter - * @version $Id: ExpressionEvaluationException.java 4779 2006-11-23 04:09:31Z jvanzyl $ + * @version $Id$ */ public class ExpressionEvaluationException extends Exception diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/expression/ExpressionEvaluator.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/expression/ExpressionEvaluator.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/expression/ExpressionEvaluator.java 2006-11-23 04:09:31.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/expression/ExpressionEvaluator.java 2016-08-31 19:01:49.000000000 +0000 @@ -22,7 +22,7 @@ * Evaluate an expression. * * @author Brett Porter - * @version $Id: ExpressionEvaluator.java 4779 2006-11-23 04:09:31Z jvanzyl $ + * @version $Id$ */ public interface ExpressionEvaluator { diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/expression/TypeAwareExpressionEvaluator.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/expression/TypeAwareExpressionEvaluator.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/expression/TypeAwareExpressionEvaluator.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/configurator/expression/TypeAwareExpressionEvaluator.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,41 @@ +package org.codehaus.plexus.component.configurator.expression; + +/* + * Copyright 2001-2006 Codehaus Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Evaluate an expression. + * + * @author Brett Porter + * @version $Id$ + */ +public interface TypeAwareExpressionEvaluator + extends ExpressionEvaluator +{ + + /** + * Evaluate an expression. The optional type provided to this method is a hint (not a requirement) for the evaluator + * to resolve the expression to a compatible value. The evaluator is not expected to perform any conversion but + * rather filter out incompatible values from its result. + * + * @param expression the expression + * @param type The expected type of expression result, may be {@code null}. + * @return the value of the expression + */ + Object evaluate( String expression, Class type ) + throws ExpressionEvaluationException; + +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/discovery/AbstractResourceBasedComponentDiscoverer.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/discovery/AbstractResourceBasedComponentDiscoverer.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/discovery/AbstractResourceBasedComponentDiscoverer.java 2009-04-26 01:22:53.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/discovery/AbstractResourceBasedComponentDiscoverer.java 2016-08-31 19:01:49.000000000 +0000 @@ -57,7 +57,7 @@ try { - resources = realm.findResources( getComponentDescriptorLocation() ); + resources = realm.getResources( getComponentDescriptorLocation() ); } catch ( IOException e ) { diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/discovery/ComponentDiscoveryEvent.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/discovery/ComponentDiscoveryEvent.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/discovery/ComponentDiscoveryEvent.java 2007-10-21 05:32:27.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/discovery/ComponentDiscoveryEvent.java 2016-08-31 19:01:49.000000000 +0000 @@ -27,6 +27,8 @@ { private ComponentSetDescriptor componentSetDescriptor; + private Object data; + /** * Constructs a ComponentDiscoveryEvent with a set of * ComponentDescriptors. @@ -37,6 +39,12 @@ this.componentSetDescriptor = componentSetDescriptor; } + public ComponentDiscoveryEvent( ComponentSetDescriptor componentSetDescriptor, Object data ) + { + this.componentSetDescriptor = componentSetDescriptor; + this.data = data; + } + /** * Returns this event's set of ComponentDescriptors. * @return this event's set of ComponentDescriptors @@ -45,4 +53,9 @@ { return componentSetDescriptor; } + + public Object getData() + { + return data; + } } diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/discovery/DiscoveryListenerDescriptor.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/discovery/DiscoveryListenerDescriptor.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/discovery/DiscoveryListenerDescriptor.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/discovery/DiscoveryListenerDescriptor.java 2016-08-31 19:01:49.000000000 +0000 @@ -19,7 +19,7 @@ /** * @author Jason van Zyl * - * @version $Id: DiscoveryListenerDescriptor.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public class DiscoveryListenerDescriptor { diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/factory/AbstractComponentFactory.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/factory/AbstractComponentFactory.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/factory/AbstractComponentFactory.java 2007-10-22 22:56:29.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/factory/AbstractComponentFactory.java 2016-08-31 19:01:49.000000000 +0000 @@ -16,16 +16,36 @@ * limitations under the License. */ +import org.codehaus.classworlds.ClassRealmAdapter; +import org.codehaus.plexus.PlexusContainer; +import org.codehaus.plexus.classworlds.realm.ClassRealm; +import org.codehaus.plexus.component.repository.ComponentDescriptor; + /** * * * @author Jason van Zyl * - * @version $Id: AbstractComponentFactory.java 6989 2007-10-22 22:56:29Z jvanzyl $ + * @version $Id$ */ public abstract class AbstractComponentFactory implements ComponentFactory { // This is for backward compatibility private String id; + + public Object newInstance( ComponentDescriptor componentDescriptor, ClassRealm classRealm, PlexusContainer container ) + throws ComponentInstantiationException + { + // for backward-compatibility with the old component factories delegate to the old-style method + return newInstance( componentDescriptor, ClassRealmAdapter.getInstance( classRealm ), container ); + } + + protected Object newInstance( ComponentDescriptor componentDescriptor, + org.codehaus.classworlds.ClassRealm classRealm, PlexusContainer container ) + throws ComponentInstantiationException + { + throw new IllegalStateException( getClass().getName() + " does not implement component creation." ); + } + } diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/factory/ComponentFactory.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/factory/ComponentFactory.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/factory/ComponentFactory.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/factory/ComponentFactory.java 2016-08-31 19:01:49.000000000 +0000 @@ -25,7 +25,7 @@ * @author Jason van Zyl * @author Michal Maczka * - * @version $Id: ComponentFactory.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public interface ComponentFactory { diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/factory/ComponentFactoryManager.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/factory/ComponentFactoryManager.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/factory/ComponentFactoryManager.java 2007-10-21 08:35:34.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/factory/ComponentFactoryManager.java 2016-08-31 19:01:49.000000000 +0000 @@ -21,7 +21,7 @@ * * @author Jason van Zyl * - * @version $Id: ComponentFactoryManager.java 6975 2007-10-21 08:35:34Z jvanzyl $ + * @version $Id$ */ public interface ComponentFactoryManager { diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/factory/ComponentInstantiationException.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/factory/ComponentInstantiationException.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/factory/ComponentInstantiationException.java 2006-11-23 04:09:31.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/factory/ComponentInstantiationException.java 2016-08-31 19:01:49.000000000 +0000 @@ -21,7 +21,7 @@ * * @author Michal Maczka * - * @version $Id: ComponentInstantiationException.java 4779 2006-11-23 04:09:31Z jvanzyl $ + * @version $Id$ */ public class ComponentInstantiationException extends Exception diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/factory/DefaultComponentFactoryManager.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/factory/DefaultComponentFactoryManager.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/factory/DefaultComponentFactoryManager.java 2008-11-14 22:07:56.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/factory/DefaultComponentFactoryManager.java 2016-08-31 19:01:49.000000000 +0000 @@ -26,7 +26,7 @@ /** * @author Jason van Zyl - * @version $Id: DefaultComponentFactoryManager.java 7828 2008-11-14 22:07:56Z dain $ + * @version $Id$ */ public class DefaultComponentFactoryManager implements ComponentFactoryManager, Contextualizable diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/factory/java/JavaComponentFactory.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/factory/java/JavaComponentFactory.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/factory/java/JavaComponentFactory.java 2008-11-18 14:17:16.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/factory/java/JavaComponentFactory.java 2016-08-31 19:01:49.000000000 +0000 @@ -29,7 +29,7 @@ * * @author Jason van Zyl * @author Michal Maczka - * @version $Id: JavaComponentFactory.java 7847 2008-11-18 14:17:16Z jvanzyl $ + * @version $Id$ */ public class JavaComponentFactory extends AbstractComponentFactory diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/factory/UndefinedComponentFactoryException.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/factory/UndefinedComponentFactoryException.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/factory/UndefinedComponentFactoryException.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/factory/UndefinedComponentFactoryException.java 2016-08-31 19:01:49.000000000 +0000 @@ -21,7 +21,7 @@ * * @author Jason van Zyl * - * @version $Id: UndefinedComponentFactoryException.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public class UndefinedComponentFactoryException extends Exception diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/manager/ComponentManager.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/manager/ComponentManager.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/manager/ComponentManager.java 2009-01-19 23:33:12.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/manager/ComponentManager.java 2016-08-31 19:01:49.000000000 +0000 @@ -35,7 +35,7 @@ * * @author Jason van Zyl * - * @version $Id: ComponentManager.java 8061 2009-01-19 23:33:12Z dain $ + * @version $Id$ */ public interface ComponentManager { diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/manager/PerLookupComponentManager.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/manager/PerLookupComponentManager.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/manager/PerLookupComponentManager.java 2008-11-20 03:48:11.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/manager/PerLookupComponentManager.java 2016-08-31 19:01:49.000000000 +0000 @@ -27,7 +27,7 @@ * * @author Jason van Zyl * - * @version $Id: PerLookupComponentManager.java 7858 2008-11-20 03:48:11Z dain $ + * @version $Id$ */ public class PerLookupComponentManager extends AbstractComponentManager diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/manager/UndefinedComponentManagerException.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/manager/UndefinedComponentManagerException.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/manager/UndefinedComponentManagerException.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/manager/UndefinedComponentManagerException.java 2016-08-31 19:01:49.000000000 +0000 @@ -18,7 +18,7 @@ /** * @author Jason van Zyl - * @version $Id: UndefinedComponentManagerException.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public class UndefinedComponentManagerException extends Exception diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/ComponentDependency.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/ComponentDependency.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/ComponentDependency.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/ComponentDependency.java 2016-08-31 19:01:49.000000000 +0000 @@ -23,7 +23,7 @@ * * @author Jason van Zyl * @author Trygve Laugstøl - * @version $Id: ComponentDependency.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public class ComponentDependency { @@ -113,7 +113,7 @@ public String toString() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append( "groupId = " ).append( groupId ). append( ", artifactId = " ).append( artifactId ). diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/ComponentDescriptor.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/ComponentDescriptor.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/ComponentDescriptor.java 2009-04-26 01:22:53.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/ComponentDescriptor.java 2016-08-31 19:01:49.000000000 +0000 @@ -31,7 +31,7 @@ * @author Jason van Zyl * @author bob mcwhirter * @author Michal Maczka - * @version $Id: ComponentDescriptor.java 8155 2009-04-26 01:22:53Z jvanzyl $ + * @version $Id$ */ public class ComponentDescriptor { @@ -39,7 +39,7 @@ private String role = null; - private Class roleClass; + private Class roleClass; private String roleHint = PlexusConstants.PLEXUS_DEFAULT_HINT; @@ -124,20 +124,20 @@ */ public String getHumanReadableKey() { - StringBuffer key = new StringBuffer(); + StringBuilder key = new StringBuilder(); - key.append( "role: '" ).append( role ).append( "'" ); + key.append( "role: '" ).append( getRole() ).append( "'" ); - key.append( ", implementation: '" ).append( implementation ).append( "'" ); + key.append( ", implementation: '" ).append( getImplementation() ).append( "'" ); if ( roleHint != null ) { - key.append( ", role hint: '" ).append( roleHint ).append( "'" ); + key.append( ", role hint: '" ).append( getRoleHint() ).append( "'" ); } if ( alias != null ) { - key.append( ", alias: '" ).append( alias ).append( "'" ); + key.append( ", alias: '" ).append( getAlias() ).append( "'" ); } return key.toString(); @@ -173,23 +173,23 @@ return role; } - public Class getRoleClass() + public Class getRoleClass() { attemptRoleLoad(); if (roleClass == null) { return (Class) Object.class; } - return roleClass; + return (Class) roleClass; } private void attemptRoleLoad() { - if ( roleClass == null && role != null && realm != null ) + if ( roleClass == null && getRole() != null && getRealm() != null ) { try { - roleClass = realm.loadClass( role ); + roleClass = (Class) getRealm().loadClass( getRole() ); Thread.currentThread(); } catch ( Throwable ignored ) @@ -214,7 +214,7 @@ attemptRoleLoad(); } - public void setRoleClass( Class roleClass ) + public void setRoleClass( Class roleClass ) { this.roleClass = roleClass; @@ -290,16 +290,16 @@ if (implementationClass == null) { return (Class) Object.class; } - return implementationClass; + return (Class)implementationClass; } private void attemptImplementationLoad() { - if ( implementationClass == null && implementation != null && realm != null ) + if ( implementationClass == null && getImplementation() != null && getRealm() != null ) { try { - implementationClass = realm.loadClass( implementation ); + implementationClass = (Class) getRealm().loadClass( getImplementation() ); Thread.currentThread(); } catch ( Throwable ignored ) @@ -653,50 +653,50 @@ attemptRoleLoad(); } + public String toString() + { + return getClass().getName() + " [role: '" + getRole() + "', hint: '" + getRoleHint() + "', realm: " + + ( realm == null ? "NULL" : "'" + realm + "'" ) + "]"; + } + // Component identity established here! public boolean equals( Object other ) { + if ( this == other ) + { + return true; + } + if ( !( other instanceof ComponentDescriptor ) ) { return false; } - else - { - ComponentDescriptor otherDescriptor = (ComponentDescriptor) other; - - boolean isEqual = true; - String role = getRole(); - String otherRole = otherDescriptor.getRole(); + ComponentDescriptor that = (ComponentDescriptor) other; - isEqual = isEqual && ( ( role.equals( otherRole ) ) || role.equals( otherRole ) ); - - String roleHint = getRoleHint(); - String otherRoleHint = otherDescriptor.getRoleHint(); - - isEqual = isEqual && ( ( roleHint.equals( otherRoleHint ) ) || roleHint.equals( otherRoleHint ) ); - - return isEqual; - } + return eq( getRole(), that.getRole() ) && eq( getRoleHint(), that.getRoleHint() ) + && eq( getRealm(), that.getRealm() ); } - public String toString() + private static boolean eq( T o1, T o2 ) { - return getClass().getName() + " [role: '" + getRole() + "', hint: '" + getRoleHint() + "', realm: " - + ( realm == null ? "NULL" : "'" + realm + "'" ) + "]"; + return ( o1 != null ) ? o1.equals( o2 ) : o2 == null; } public int hashCode() { - int result = getRole().hashCode() + 1; + int hash = 17; - String hint = getRoleHint(); + hash = hash * 31 + hash( getRole() ); + hash = hash * 31 + hash( getRoleHint() ); + hash = hash * 31 + hash( getRealm() ); - if ( hint != null ) - { - result += hint.hashCode(); - } + return hash; + } - return result; + private static int hash( Object obj ) + { + return ( obj != null ) ? obj.hashCode() : 0; } + } diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/ComponentRepository.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/ComponentRepository.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/ComponentRepository.java 2008-11-19 02:16:47.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/ComponentRepository.java 2016-08-31 19:01:49.000000000 +0000 @@ -17,7 +17,7 @@ */ import org.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.component.repository.exception.ComponentRepositoryException; +import org.codehaus.plexus.component.composition.CycleDetectedInComponentGraphException; import java.util.List; import java.util.Map; @@ -25,7 +25,7 @@ public interface ComponentRepository { void addComponentDescriptor( ComponentDescriptor componentDescriptor ) - throws ComponentRepositoryException; + throws CycleDetectedInComponentGraphException; ComponentDescriptor getComponentDescriptor( Class type, String role, String roleHint ); diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/ComponentRequirement.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/ComponentRequirement.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/ComponentRequirement.java 2007-10-21 05:32:27.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/ComponentRequirement.java 2016-08-31 19:01:49.000000000 +0000 @@ -1,7 +1,5 @@ package org.codehaus.plexus.component.repository; -import org.codehaus.plexus.PlexusConstants; - /* * Copyright 2001-2006 Codehaus Foundation. * @@ -20,20 +18,22 @@ /** * This represents a component this is required by another component. - * + * * @author Michal Maczka - * @version $Id: ComponentRequirement.java 6965 2007-10-21 05:32:27Z jvanzyl $ + * @version $Id$ */ public class ComponentRequirement { private String role; - private String roleHint = PlexusConstants.PLEXUS_DEFAULT_HINT; + private String roleHint = ""; private String fieldName; - + private String fieldMappingType; - + + private boolean optional; + /** * Returns the field name that this component requirement will inject. * @return the field name that this component requirement will inject @@ -82,19 +82,12 @@ /** * Sets the role-hint of the require component. - * Pasing null will set the hint to the default value. + * Passing null or an empty string will match any available implementation. * @param roleHint the required component's role-hint */ public void setRoleHint( String roleHint ) { - if ( roleHint == null || roleHint.trim().equals( "" ) ) - { - this.roleHint = PlexusConstants.PLEXUS_DEFAULT_HINT; - } - else - { - this.roleHint = roleHint; - } + this.roleHint = ( roleHint != null ) ? roleHint : ""; } /** @@ -116,6 +109,30 @@ this.fieldMappingType = fieldType; } + /** + * Whether this component requirement is optional and needs not be satisfied + * + * @return {@code true} if the requested component may be missing, {@code false} if the component is mandatory. + * @since 1.3.0 + */ + public boolean isOptional() + { + return optional; + } + + /** + * Controls whether a failure to satisfy this requirement can be tolerated by host component or whether construction + * of the host component should also fail. + * + * @param optional {@code true} if the requested component may be missing, {@code false} if the component is + * mandatory. + * @since 1.3.0 + */ + public void setOptional( boolean optional ) + { + this.optional = optional; + } + public String toString() { return "ComponentRequirement{" + @@ -131,7 +148,7 @@ */ public String getHumanReadableKey() { - StringBuffer key = new StringBuffer(); + StringBuilder key = new StringBuilder(); key.append( "role: '").append( getRole() ).append( "'" ); @@ -153,16 +170,16 @@ if ( other instanceof ComponentRequirement ) { String myId = role + ":" + roleHint; - + ComponentRequirement req = (ComponentRequirement) other; String otherId = req.role + ":" + req.roleHint; - + return myId.equals( otherId ); } - + return false; } - + public int hashCode() { return ( role + ":" + roleHint ).hashCode(); diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/ComponentRequirementList.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/ComponentRequirementList.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/ComponentRequirementList.java 2008-11-14 22:07:56.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/ComponentRequirementList.java 2016-08-31 19:01:49.000000000 +0000 @@ -6,7 +6,7 @@ * Created by IntelliJ IDEA. * * @author Andrew Williams - * @version $Id: ComponentRequirementList.java 7828 2008-11-14 22:07:56Z dain $ + * @version $Id$ * @since 1.0 */ public class ComponentRequirementList @@ -26,7 +26,7 @@ public String getRoleHint() { - StringBuffer buffer = new StringBuffer(); + StringBuilder buffer = new StringBuilder(); for ( String hint : roleHints ) { if (buffer.length() > 0) diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/ComponentSetDescriptor.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/ComponentSetDescriptor.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/ComponentSetDescriptor.java 2008-11-14 22:07:56.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/ComponentSetDescriptor.java 2016-08-31 19:01:49.000000000 +0000 @@ -24,7 +24,7 @@ * * @author Jason van Zyl * @author Trygve Laugstøl - * @version $Id: ComponentSetDescriptor.java 7828 2008-11-14 22:07:56Z dain $ + * @version $Id$ */ public class ComponentSetDescriptor { @@ -138,7 +138,7 @@ public String toString() { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); sb.append( "Component Descriptor: " ); diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/DefaultComponentRepository.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/DefaultComponentRepository.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/DefaultComponentRepository.java 2008-12-19 17:08:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/DefaultComponentRepository.java 2016-08-31 19:01:49.000000000 +0000 @@ -19,22 +19,25 @@ import static org.codehaus.plexus.component.CastUtils.isAssignableFrom; import java.util.ArrayList; +import java.util.Collection; import java.util.HashSet; import java.util.LinkedHashMap; -import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; import java.util.SortedMap; import java.util.TreeMap; +import org.codehaus.plexus.ClassRealmUtil; +import org.codehaus.plexus.PlexusConstants; import org.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.component.composition.CompositionException; +import org.codehaus.plexus.component.composition.CycleDetectedInComponentGraphException; import org.codehaus.plexus.component.composition.CompositionResolver; import org.codehaus.plexus.component.composition.DefaultCompositionResolver; -import org.codehaus.plexus.component.repository.exception.ComponentRepositoryException; import org.codehaus.plexus.logging.AbstractLogEnabled; +import org.codehaus.plexus.util.StringUtils; +import com.google.common.collect.LinkedHashMultimap; import com.google.common.collect.Multimap; import com.google.common.collect.Multimaps; @@ -66,23 +69,15 @@ } // determine realms to search - LinkedHashSet realms = new LinkedHashSet(); - for (ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); classLoader != null; classLoader = classLoader.getParent()) { - if ( classLoader instanceof ClassRealm ) - { - ClassRealm realm = (ClassRealm) classLoader; - while (realm != null) { - realms.add(realm); - realm = realm.getParentRealm(); - } - } - } - if (realms.isEmpty()) { + Set realms = ClassRealmUtil.getContextRealms( null ); + if ( realms.isEmpty() ) + { realms.addAll( index.keySet() ); } + // Get all valid component descriptors - Multimap> roleHintIndex = Multimaps.newLinkedHashMultimap(); + Multimap> roleHintIndex = LinkedHashMultimap.create(); for ( ClassRealm realm : realms ) { SortedMap>> roleIndex = index.get( realm ); @@ -99,9 +94,46 @@ public ComponentDescriptor getComponentDescriptor( Class type, String role, String roleHint ) { - for ( ComponentDescriptor descriptor : getComponentDescriptors( role ).get( roleHint ) ) + Multimap> roleHintIndex = getComponentDescriptors( role ); + + Collection> descriptors; + + if ( StringUtils.isNotEmpty( roleHint ) ) { - if ( isAssignableFrom( type, descriptor.getImplementationClass() ) ) + // specific role hint -> get only those + descriptors = roleHintIndex.get( roleHint ); + } + else + { + // missing role hint -> get all (wildcard) + Collection> allDescriptors = new ArrayList>(); + + descriptors = roleHintIndex.get( PlexusConstants.PLEXUS_DEFAULT_HINT ); + if ( descriptors != null ) + { + allDescriptors.addAll( descriptors ); + } + + for ( String hint : roleHintIndex.keySet() ) + { + descriptors = roleHintIndex.get( hint ); + if ( descriptors != null ) + { + allDescriptors.addAll( descriptors ); + } + } + + descriptors = allDescriptors; + } + + for ( ComponentDescriptor descriptor : descriptors ) + { + Class implClass = descriptor.getImplementationClass(); + if ( isAssignableFrom( type, implClass ) ) + { + return (ComponentDescriptor) descriptor; + } + else if ( Object.class == implClass && role.equals( type.getName() ) ) { return (ComponentDescriptor) descriptor; } @@ -175,8 +207,8 @@ // Component Descriptor processing. // ---------------------------------------------------------------------- - public void addComponentDescriptor( ComponentDescriptor componentDescriptor ) - throws ComponentRepositoryException + public void addComponentDescriptor( ComponentDescriptor componentDescriptor ) + throws CycleDetectedInComponentGraphException { ClassRealm classRealm = componentDescriptor.getRealm(); SortedMap>> roleIndex = index.get( classRealm ); @@ -189,18 +221,11 @@ Multimap> roleHintIndex = roleIndex.get( role ); if ( roleHintIndex == null ) { - roleHintIndex = Multimaps.newLinkedHashMultimap(); + roleHintIndex = LinkedHashMultimap.create(); roleIndex.put( role, roleHintIndex ); } roleHintIndex.put( componentDescriptor.getRoleHint(), componentDescriptor ); - try - { - compositionResolver.addComponentDescriptor( componentDescriptor ); - } - catch ( CompositionException e ) - { - throw new ComponentRepositoryException( e.getMessage(), e ); - } + compositionResolver.addComponentDescriptor( componentDescriptor ); } } diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentConfigurationException.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentConfigurationException.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentConfigurationException.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentConfigurationException.java 2016-08-31 19:01:49.000000000 +0000 @@ -21,7 +21,7 @@ * implementation are not available. * * @author Jason van Zyl - * @version $Id: ComponentConfigurationException.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public class ComponentConfigurationException extends Exception diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentDescriptorUnmarshallingException.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentDescriptorUnmarshallingException.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentDescriptorUnmarshallingException.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentDescriptorUnmarshallingException.java 2016-08-31 19:01:49.000000000 +0000 @@ -21,7 +21,7 @@ * implementation are not available. * * @author Jason van Zyl - * @version $Id: ComponentDescriptorUnmarshallingException.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public class ComponentDescriptorUnmarshallingException extends Exception diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentImplementationNotFoundException.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentImplementationNotFoundException.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentImplementationNotFoundException.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentImplementationNotFoundException.java 2016-08-31 19:01:49.000000000 +0000 @@ -22,7 +22,7 @@ * * @author Jason van Zyl * - * @version $Id: ComponentImplementationNotFoundException.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public class ComponentImplementationNotFoundException extends Exception diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentLifecycleException.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentLifecycleException.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentLifecycleException.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentLifecycleException.java 2016-08-31 19:01:49.000000000 +0000 @@ -21,7 +21,7 @@ * implementation are not available. * * @author Jason van Zyl - * @version $Id: ComponentLifecycleException.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public class ComponentLifecycleException extends Exception diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentLookupException.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentLookupException.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentLookupException.java 2008-11-14 22:07:56.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentLookupException.java 2016-08-31 19:01:49.000000000 +0000 @@ -1,5 +1,8 @@ package org.codehaus.plexus.component.repository.exception; +import java.io.ByteArrayOutputStream; +import java.io.PrintStream; + import org.codehaus.plexus.classworlds.realm.ClassRealm; /* @@ -23,7 +26,7 @@ * the requested component cannot be found. * * @author Jason van Zyl - * @version $Id: ComponentLookupException.java 7828 2008-11-14 22:07:56Z dain $ + * @version $Id$ */ public class ComponentLookupException extends Exception @@ -78,16 +81,19 @@ public String getMessage() { - StringBuffer sb = new StringBuffer() + StringBuilder sb = new StringBuilder() .append( super.getMessage() ).append( LS ) .append( " role: ").append( role ).append( LS ) .append( " roleHint: ").append( roleHint ).append( LS ) - .append( "classRealm: "); + .append("classRealm: "); if ( realm != null ) { - sb.append( realm.getId() ); - realm.display(); + sb.append( realm.getId() ).append( LS ); + ByteArrayOutputStream os = new ByteArrayOutputStream( 1024 ); + PrintStream ps = new PrintStream( os ); + realm.display( ps ); + sb.append( os.toString() ); } else { diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentLookupRuntimeException.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentLookupRuntimeException.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentLookupRuntimeException.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentLookupRuntimeException.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,38 @@ +package org.codehaus.plexus.component.repository.exception; + +/* + * Copyright 2001-2006 Codehaus Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * The exception which is thrown by a component repository when + * the requested component cannot be found. + * + * @author Kristian Rosenvold + * @version $Id$ + */ +public class ComponentLookupRuntimeException + extends RuntimeException +{ + public ComponentLookupRuntimeException( ComponentLookupException cause ) + { + super( cause ); + } + + public String getMessage() + { + return getCause().getMessage(); + } +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentManagerImplementationNotFoundException.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentManagerImplementationNotFoundException.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentManagerImplementationNotFoundException.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentManagerImplementationNotFoundException.java 2016-08-31 19:01:49.000000000 +0000 @@ -21,7 +21,7 @@ * implementation are not available. * * @author Jason van Zyl - * @version $Id: ComponentManagerImplementationNotFoundException.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public class ComponentManagerImplementationNotFoundException extends Exception diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentProfileException.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentProfileException.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentProfileException.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentProfileException.java 2016-08-31 19:01:49.000000000 +0000 @@ -21,7 +21,7 @@ * implementation are not available. * * @author Jason van Zyl - * @version $Id: ComponentProfileException.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public class ComponentProfileException extends Exception diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentRepositoryException.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentRepositoryException.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentRepositoryException.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/exception/ComponentRepositoryException.java 2016-08-31 19:01:49.000000000 +0000 @@ -21,7 +21,7 @@ * implementation are not available. * * @author Jason van Zyl - * @version $Id: ComponentRepositoryException.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public class ComponentRepositoryException extends Exception diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/io/PlexusTools.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/io/PlexusTools.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/io/PlexusTools.java 2009-04-26 01:22:53.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/component/repository/io/PlexusTools.java 2016-08-31 19:01:49.000000000 +0000 @@ -23,6 +23,7 @@ import java.util.LinkedList; import java.util.List; +import org.codehaus.plexus.classworlds.realm.ClassRealm; import org.codehaus.plexus.component.repository.ComponentDependency; import org.codehaus.plexus.component.repository.ComponentDescriptor; import org.codehaus.plexus.component.repository.ComponentRequirement; @@ -31,9 +32,6 @@ import org.codehaus.plexus.configuration.PlexusConfiguration; import org.codehaus.plexus.configuration.PlexusConfigurationException; import org.codehaus.plexus.configuration.io.XmlPlexusConfigurationReader; -import org.codehaus.plexus.classworlds.ClassWorld; -import org.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.classworlds.realm.NoSuchRealmException; /** @@ -73,6 +71,12 @@ { return buildComponentDescriptor( buildConfiguration( configuration ), realm ); } + + public static ComponentDescriptor buildComponentDescriptor( PlexusConfiguration configuration ) + throws PlexusConfigurationException + { + return buildComponentDescriptorImpl( configuration, null ); + } public static ComponentDescriptor buildComponentDescriptor( PlexusConfiguration configuration, ClassRealm realm ) throws PlexusConfigurationException @@ -82,7 +86,13 @@ throw new NullPointerException( "realm is null" ); } + return buildComponentDescriptorImpl( configuration, realm ); + } + private static ComponentDescriptor buildComponentDescriptorImpl( PlexusConfiguration configuration, + ClassRealm realm ) + throws PlexusConfigurationException + { String implementation = configuration.getChild( "implementation" ).getValue(); if (implementation == null) { @@ -92,8 +102,16 @@ ComponentDescriptor cd; try { - Class implementationClass = realm.loadClass( implementation ); - cd = new ComponentDescriptor(implementationClass, realm); + if ( realm != null ) + { + Class implementationClass = realm.loadClass( implementation ); + cd = new ComponentDescriptor(implementationClass, realm); + } + else + { + cd = new ComponentDescriptor(); + cd.setImplementation( implementation ); + } } catch ( Throwable e ) { @@ -145,42 +163,43 @@ PlexusConfiguration[] requirements = configuration.getChild( "requirements" ).getChildren( "requirement" ); - for ( int i = 0; i < requirements.length; i++ ) - { - PlexusConfiguration requirement = requirements[i]; - + for (PlexusConfiguration requirement : requirements) { ComponentRequirement cr; - PlexusConfiguration[] hints = requirement.getChild( "role-hints" ).getChildren( "role-hint" ); - if ( hints != null && hints.length > 0 ) - { + PlexusConfiguration[] hints = requirement.getChild("role-hints").getChildren("role-hint"); + if (hints != null && hints.length > 0) { cr = new ComponentRequirementList(); List hintList = new LinkedList(); - for ( PlexusConfiguration hint : hints ) - { - hintList.add( hint.getValue() ); + for (PlexusConfiguration hint : hints) { + hintList.add(hint.getValue()); } - ( (ComponentRequirementList) cr ).setRoleHints( hintList ); - } - else - { + ((ComponentRequirementList) cr).setRoleHints(hintList); + } else { cr = new ComponentRequirement(); - cr.setRoleHint( requirement.getChild( "role-hint" ).getValue() ); + cr.setRoleHint(requirement.getChild("role-hint").getValue()); } - cr.setRole( requirement.getChild( "role" ).getValue() ); + cr.setRole(requirement.getChild("role").getValue()); - cr.setFieldName( requirement.getChild( "field-name" ).getValue() ); + cr.setOptional(Boolean.parseBoolean(requirement.getChild("optional").getValue())); - cd.addRequirement( cr ); + cr.setFieldName(requirement.getChild("field-name").getValue()); + + cd.addRequirement(cr); } return cd; } + public static ComponentSetDescriptor buildComponentSet( PlexusConfiguration c ) + throws PlexusConfigurationException + { + return buildComponentSet( c, null ); + } + public static ComponentSetDescriptor buildComponentSet( PlexusConfiguration c, ClassRealm realm ) throws PlexusConfigurationException { @@ -192,11 +211,8 @@ PlexusConfiguration[] components = c.getChild( "components" ).getChildren( "component" ); - for ( int i = 0; i < components.length; i++ ) - { - PlexusConfiguration component = components[i]; - - csd.addComponentDescriptor( buildComponentDescriptor( component, realm ) ); + for (PlexusConfiguration component : components) { + csd.addComponentDescriptor(buildComponentDescriptorImpl(component, realm)); } // ---------------------------------------------------------------------- @@ -205,25 +221,21 @@ PlexusConfiguration[] dependencies = c.getChild( "dependencies" ).getChildren( "dependency" ); - for ( int i = 0; i < dependencies.length; i++ ) - { - PlexusConfiguration d = dependencies[i]; - + for (PlexusConfiguration d : dependencies) { ComponentDependency cd = new ComponentDependency(); - cd.setArtifactId( d.getChild( "artifact-id" ).getValue() ); + cd.setArtifactId(d.getChild("artifact-id").getValue()); - cd.setGroupId( d.getChild( "group-id" ).getValue() ); + cd.setGroupId(d.getChild("group-id").getValue()); - String type = d.getChild( "type" ).getValue(); - if(type != null) - { - cd.setType( type ); + String type = d.getChild("type").getValue(); + if (type != null) { + cd.setType(type); } - cd.setVersion( d.getChild( "version" ).getValue() ); + cd.setVersion(d.getChild("version").getValue()); - csd.addDependency( cd ); + csd.addDependency(cd); } return csd; @@ -243,9 +255,8 @@ if ( atts.length > 0 ) { - for ( int i = 0; i < atts.length; i++ ) - { - out.print( "\n" + indent + " " + atts[i] + "='" + configuration.getAttribute( atts[i] ) + "'" ); + for (String att : atts) { + out.print("\n" + indent + " " + att + "='" + configuration.getAttribute(att) + "'"); } } @@ -258,9 +269,8 @@ if ( pc.length > 0 ) { out.println(); - for ( int i = 0; i < pc.length; i++ ) - { - writeConfiguration( out, pc[i], indent + " " ); + for (PlexusConfiguration aPc : pc) { + writeConfiguration(out, aPc, indent + " "); } out.print( indent ); } diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/ComponentRegistry.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/ComponentRegistry.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/ComponentRegistry.java 2008-11-20 03:48:11.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/ComponentRegistry.java 2016-08-31 19:01:49.000000000 +0000 @@ -20,11 +20,11 @@ import java.util.Map; import org.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.component.repository.exception.ComponentLookupException; -import org.codehaus.plexus.component.repository.exception.ComponentRepositoryException; -import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException; -import org.codehaus.plexus.component.repository.ComponentDescriptor; +import org.codehaus.plexus.component.composition.CycleDetectedInComponentGraphException; import org.codehaus.plexus.component.manager.ComponentManagerFactory; +import org.codehaus.plexus.component.repository.ComponentDescriptor; +import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException; +import org.codehaus.plexus.component.repository.exception.ComponentLookupException; /** * @author Jason van Zyl @@ -36,7 +36,7 @@ void registerComponentManagerFactory( ComponentManagerFactory componentManagerFactory ); void addComponentDescriptor( ComponentDescriptor componentDescriptor ) - throws ComponentRepositoryException; + throws CycleDetectedInComponentGraphException; ComponentDescriptor getComponentDescriptor( Class type, String role, String roleHint ); @@ -50,6 +50,9 @@ T lookup( Class type, String role, String roleHint ) throws ComponentLookupException; + T lookup( ComponentDescriptor componentDescriptor ) + throws ComponentLookupException; + List lookupList( Class type, String role, List hints ) throws ComponentLookupException; @@ -61,4 +64,6 @@ void removeComponentRealm( ClassRealm classRealm ) throws PlexusContainerException; void dispose(); + + void addComponent( T component, String role, String roleHint ); } \ No newline at end of file diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/configuration/DefaultPlexusConfiguration.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/configuration/DefaultPlexusConfiguration.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/configuration/DefaultPlexusConfiguration.java 2008-11-18 22:33:53.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/configuration/DefaultPlexusConfiguration.java 2016-08-31 19:01:49.000000000 +0000 @@ -22,7 +22,7 @@ import java.util.Map; /** - * @version $Id: DefaultPlexusConfiguration.java 7854 2008-11-18 22:33:53Z bentmann $ + * @version $Id$ */ public class DefaultPlexusConfiguration implements PlexusConfiguration @@ -151,7 +151,7 @@ public PlexusConfiguration getChild( int i ) { - return getChildren()[i]; + return childList.get( i ); } public PlexusConfiguration getChild( String name, boolean createChild ) diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/configuration/io/XmlPlexusConfigurationWriter.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/configuration/io/XmlPlexusConfigurationWriter.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/configuration/io/XmlPlexusConfigurationWriter.java 2008-04-11 18:12:21.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/configuration/io/XmlPlexusConfigurationWriter.java 2016-08-31 19:01:49.000000000 +0000 @@ -101,14 +101,13 @@ { String[] names = c.getAttributeNames(); - for ( int i = 0; i < names.length; i++ ) - { - w.write( ' ' ); - w.write( names[i] ); - w.write( '=' ); - w.write( '"' ); - w.write( c.getAttribute( names[i], null ) ); - w.write( '"' ); + for (String name : names) { + w.write(' '); + w.write(name); + w.write('='); + w.write('"'); + w.write(c.getAttribute(name, null)); + w.write('"'); } } diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/configuration/PlexusConfigurationMerger.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/configuration/PlexusConfigurationMerger.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/configuration/PlexusConfigurationMerger.java 2008-01-26 20:55:42.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/configuration/PlexusConfigurationMerger.java 2016-08-31 19:01:49.000000000 +0000 @@ -86,9 +86,8 @@ if ( configurationsDirectories.length != 0 ) { - for ( int i = 0; i < configurationsDirectories.length; i++ ) - { - mergedConfiguration.addChild( configurationsDirectories[i] ); + for (PlexusConfiguration configurationsDirectory : configurationsDirectories) { + mergedConfiguration.addChild(configurationsDirectory); } } @@ -247,9 +246,8 @@ PlexusConfiguration dest = destination.getChild( "resources" ); - for ( int i = 0; i < handlers.length; i++ ) - { - dest.addChild( handlers[i] ); + for (PlexusConfiguration handler : handlers) { + dest.addChild(handler); } } @@ -276,9 +274,8 @@ PlexusConfiguration dest = destination.getChild( "component-managers" ); - for ( int i = 0; i < handlers.length; i++ ) - { - dest.addChild( handlers[i] ); + for (PlexusConfiguration handler : handlers) { + dest.addChild(handler); } } @@ -288,9 +285,8 @@ PlexusConfiguration dest = destination.getChild( "component-discoverers" ); - for ( int i = 0; i < handlers.length; i++ ) - { - dest.addChild( handlers[i] ); + for (PlexusConfiguration handler : handlers) { + dest.addChild(handler); } } @@ -300,9 +296,8 @@ PlexusConfiguration dest = destination.getChild( "component-factories" ); - for ( int i = 0; i < handlers.length; i++ ) - { - dest.addChild( handlers[i] ); + for (PlexusConfiguration handler : handlers) { + dest.addChild(handler); } } @@ -328,9 +323,8 @@ PlexusConfiguration dest = destination.getChild( "component-composers" ); - for ( int i = 0; i < composers.length; i++ ) - { - dest.addChild( composers[i] ); + for (PlexusConfiguration composer : composers) { + dest.addChild(composer); } } @@ -340,9 +334,8 @@ PlexusConfiguration dest = destination.getChild( "lifecycle-handlers" ); - for ( int i = 0; i < handlers.length; i++ ) - { - dest.addChild( handlers[i] ); + for (PlexusConfiguration handler : handlers) { + dest.addChild(handler); } } @@ -350,9 +343,8 @@ { PlexusConfiguration components[] = source.getChildren( "component" ); - for ( int i = 0; i < components.length; i++ ) - { - destination.addChild( components[i] ); + for (PlexusConfiguration component : components) { + destination.addChild(component); } } } diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/configuration/source/ChainedConfigurationSource.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/configuration/source/ChainedConfigurationSource.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/configuration/source/ChainedConfigurationSource.java 2007-12-22 03:42:17.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/configuration/source/ChainedConfigurationSource.java 2016-08-31 19:01:49.000000000 +0000 @@ -1,6 +1,5 @@ package org.codehaus.plexus.configuration.source; -import java.util.Iterator; import java.util.List; import org.codehaus.plexus.component.repository.ComponentDescriptor; @@ -26,14 +25,12 @@ public PlexusConfiguration getConfiguration( ComponentDescriptor componentDescriptor ) { - for ( Iterator i = configurationSources.iterator(); i.hasNext(); ) - { - ConfigurationSource configurationSource = (ConfigurationSource) i.next(); + for (Object configurationSource1 : configurationSources) { + ConfigurationSource configurationSource = (ConfigurationSource) configurationSource1; - PlexusConfiguration configuration = configurationSource.getConfiguration( componentDescriptor ); + PlexusConfiguration configuration = configurationSource.getConfiguration(componentDescriptor); - if ( configuration != null ) - { + if (configuration != null) { return configuration; } } diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/configuration/xml/XmlPlexusConfiguration.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/configuration/xml/XmlPlexusConfiguration.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/configuration/xml/XmlPlexusConfiguration.java 2008-01-26 20:55:42.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/configuration/xml/XmlPlexusConfiguration.java 2016-08-31 19:01:49.000000000 +0000 @@ -24,7 +24,7 @@ import org.codehaus.plexus.util.xml.Xpp3Dom; /** - * @version $Id: XmlPlexusConfiguration.java 7187 2008-01-26 20:55:42Z cstamas $ + * @version $Id$ */ public class XmlPlexusConfiguration extends DefaultPlexusConfiguration @@ -51,17 +51,15 @@ // attrs String[] attributes = dom.getAttributeNames(); - for ( int i = 0; i < attributes.length; i++ ) - { - setAttribute( attributes[i], dom.getAttribute( attributes[i] ) ); + for (String attribute : attributes) { + setAttribute(attribute, dom.getAttribute(attribute)); } // children - Xpp3Dom[] doms = dom.getChildren(); - - for ( int i = 0; i < doms.length; i++ ) + int childCount = dom.getChildCount(); + for ( int i = 0; i < childCount; i++ ) { - addChild( new XmlPlexusConfiguration( doms[i] ) ); + addChild( new XmlPlexusConfiguration( dom.getChild( i ) ) ); } } diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/container/initialization/InitializeComponentRegistryPhase.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/container/initialization/InitializeComponentRegistryPhase.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/container/initialization/InitializeComponentRegistryPhase.java 2009-04-26 01:22:53.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/container/initialization/InitializeComponentRegistryPhase.java 2016-08-31 19:01:49.000000000 +0000 @@ -19,7 +19,7 @@ import org.codehaus.plexus.component.repository.ComponentRepository; import org.codehaus.plexus.component.repository.ComponentDescriptor; import org.codehaus.plexus.component.repository.io.PlexusTools; -import org.codehaus.plexus.component.repository.exception.ComponentRepositoryException; +import org.codehaus.plexus.component.composition.CycleDetectedInComponentGraphException; import org.codehaus.plexus.component.manager.PerLookupComponentManagerFactory; import org.codehaus.plexus.component.manager.SingletonComponentManagerFactory; import org.codehaus.plexus.configuration.PlexusConfiguration; @@ -31,7 +31,8 @@ /** * @author Jason van Zyl */ -public class InitializeComponentRegistryPhase implements ContainerInitializationPhase +public class InitializeComponentRegistryPhase + implements ContainerInitializationPhase { public void execute( ContainerInitializationContext context ) throws ContainerInitializationException @@ -71,13 +72,13 @@ } catch ( PlexusConfigurationException e ) { - throw new ContainerInitializationException( "Error initializing component repository: " + - "Cannot unmarshall component descriptor: ", e ); + throw new ContainerInitializationException( "Error initializing component repository: " + "Cannot unmarshall component descriptor: ", e ); } - catch ( ComponentRepositoryException e ) + catch ( CycleDetectedInComponentGraphException e ) { - throw new ContainerInitializationException( "Error initializing component repository: ", e ); + throw new ContainerInitializationException( "A cycle has been detected in the components of the system: ", e ); } + return repository; } diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/container/initialization/InitializeLoggerManagerPhase.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/container/initialization/InitializeLoggerManagerPhase.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/container/initialization/InitializeLoggerManagerPhase.java 2008-11-20 03:48:11.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/container/initialization/InitializeLoggerManagerPhase.java 2016-08-31 19:01:49.000000000 +0000 @@ -18,8 +18,8 @@ import org.codehaus.plexus.PlexusConstants; import org.codehaus.plexus.PlexusContainer; +import org.codehaus.plexus.component.composition.CycleDetectedInComponentGraphException; import org.codehaus.plexus.component.repository.ComponentDescriptor; -import org.codehaus.plexus.component.repository.exception.ComponentRepositoryException; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.logging.LoggerManager; @@ -61,7 +61,7 @@ { context.getContainer().addComponentDescriptor( cd ); } - catch ( ComponentRepositoryException cre ) + catch ( CycleDetectedInComponentGraphException cre ) { throw new ContainerInitializationException( "Error setting up logging manager.", cre ); } diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/container/initialization/InitializeSystemPropertiesPhase.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/container/initialization/InitializeSystemPropertiesPhase.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/container/initialization/InitializeSystemPropertiesPhase.java 2007-10-21 06:43:01.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/container/initialization/InitializeSystemPropertiesPhase.java 2016-08-31 19:01:49.000000000 +0000 @@ -30,23 +30,20 @@ PlexusConfiguration[] systemProperties = context.getContainerXmlConfiguration().getChild( "system-properties" ).getChildren( "property" ); - for ( int i = 0; i < systemProperties.length; ++i ) - { - String name = systemProperties[i].getAttribute( "name", null ); + for (PlexusConfiguration systemProperty : systemProperties) { + String name = systemProperty.getAttribute("name", null); - String value = systemProperties[i].getAttribute( "value", null ); + String value = systemProperty.getAttribute("value", null); - if ( name == null ) - { - throw new ContainerInitializationException( "Missing 'name' attribute in 'property' tag. " ); + if (name == null) { + throw new ContainerInitializationException("Missing 'name' attribute in 'property' tag. "); } - if ( value == null ) - { - throw new ContainerInitializationException( "Missing 'value' attribute in 'property' tag. " ); + if (value == null) { + throw new ContainerInitializationException("Missing 'value' attribute in 'property' tag. "); } - System.getProperties().setProperty( name, value ); + System.getProperties().setProperty(name, value); } } } diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/container/initialization/InitializeUserConfigurationSourcePhase.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/container/initialization/InitializeUserConfigurationSourcePhase.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/container/initialization/InitializeUserConfigurationSourcePhase.java 2008-11-14 22:07:56.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/container/initialization/InitializeUserConfigurationSourcePhase.java 2016-08-31 19:01:49.000000000 +0000 @@ -20,9 +20,9 @@ import java.util.List; import org.codehaus.plexus.PlexusConstants; +import org.codehaus.plexus.component.composition.CycleDetectedInComponentGraphException; import org.codehaus.plexus.component.repository.ComponentDescriptor; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; -import org.codehaus.plexus.component.repository.exception.ComponentRepositoryException; import org.codehaus.plexus.configuration.source.ChainedConfigurationSource; import org.codehaus.plexus.configuration.source.ConfigurationSource; @@ -41,7 +41,7 @@ try { // is the user overriding the ConfigurationSource (role-hint: default) or only extending it? - if ( context.getContainer().hasComponent( ConfigurationSource.class ) ) + if ( context.getContainer().hasComponent( ConfigurationSource.class, PlexusConstants.PLEXUS_DEFAULT_HINT ) ) { // overriding @@ -86,7 +86,7 @@ { context.getContainer().addComponentDescriptor( cd ); } - catch ( ComponentRepositoryException cre ) + catch ( CycleDetectedInComponentGraphException cre ) { throw new ContainerInitializationException( "Error setting up configuration source.", cre ); } diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/context/ContextException.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/context/ContextException.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/context/ContextException.java 2007-10-21 05:32:27.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/context/ContextException.java 2016-08-31 19:01:49.000000000 +0000 @@ -25,7 +25,7 @@ * when Component detects a malformed containerContext value. * * @author Avalon Development Team - * @version CVS $Revision: 6965 $ $Date: 2007-10-21 07:32:27 +0200 (So, 21. Okt 2007) $ + * @version CVS $Revision$ $Date$ */ public class ContextException extends Exception diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/context/DefaultContext.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/context/DefaultContext.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/context/DefaultContext.java 2009-01-19 23:33:12.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/context/DefaultContext.java 2016-08-31 19:01:49.000000000 +0000 @@ -31,7 +31,7 @@ * a property has been hidden the containerContext will not search in the parent containerContext for the value. * * @author Avalon Development Team - * @version $Id: DefaultContext.java 8061 2009-01-19 23:33:12Z dain $ + * @version $Id$ */ public class DefaultContext implements Context @@ -137,7 +137,7 @@ * * @return the containerContext data */ - public Map getContextData() + public Map getContextData() { return Collections.unmodifiableMap( contextData ); diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/DefaultComponentRegistry.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/DefaultComponentRegistry.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/DefaultComponentRegistry.java 2009-01-19 23:33:12.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/DefaultComponentRegistry.java 2016-08-31 19:01:49.000000000 +0000 @@ -3,20 +3,19 @@ import static org.codehaus.plexus.component.CastUtils.isAssignableFrom; import java.util.ArrayList; -import java.util.Collection; import java.util.Collections; +import java.util.Comparator; import java.util.IdentityHashMap; import java.util.Iterator; import java.util.LinkedHashMap; -import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; import java.util.TreeMap; -import java.util.Comparator; import java.util.Map.Entry; import org.codehaus.plexus.classworlds.realm.ClassRealm; +import org.codehaus.plexus.component.composition.CycleDetectedInComponentGraphException; import org.codehaus.plexus.component.factory.ComponentInstantiationException; import org.codehaus.plexus.component.manager.ComponentManager; import org.codehaus.plexus.component.manager.ComponentManagerFactory; @@ -24,11 +23,11 @@ import org.codehaus.plexus.component.repository.ComponentRepository; import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; -import org.codehaus.plexus.component.repository.exception.ComponentRepositoryException; import org.codehaus.plexus.lifecycle.LifecycleHandler; import org.codehaus.plexus.lifecycle.LifecycleHandlerManager; import org.codehaus.plexus.lifecycle.UndefinedLifecycleHandlerException; import org.codehaus.plexus.logging.Logger; +import org.codehaus.plexus.util.StringUtils; public class DefaultComponentRegistry implements ComponentRegistry { @@ -47,6 +46,8 @@ private final Map> componentManagers = new TreeMap>(); private final Map> componentManagersByComponent = new IdentityHashMap>(); + private final Map unmanagedComponents = new TreeMap(); + public DefaultComponentRegistry( MutablePlexusContainer container, ComponentRepository repository, LifecycleHandlerManager lifecycleHandlerManager ) @@ -65,6 +66,7 @@ managers = new ArrayList>( componentManagers.values() ); componentManagers.clear(); componentManagersByComponent.clear(); + unmanagedComponents.clear(); disposingComponents = true; } @@ -118,11 +120,24 @@ componentManagerFactories.put( componentManagerFactory.getId(), componentManagerFactory ); } - public void addComponentDescriptor( ComponentDescriptor componentDescriptor ) throws ComponentRepositoryException + public void addComponentDescriptor( ComponentDescriptor componentDescriptor ) + throws CycleDetectedInComponentGraphException { repository.addComponentDescriptor( componentDescriptor ); } + @SuppressWarnings("unchecked") + public synchronized void addComponent( T component, String role, String roleHint ) + { + ComponentDescriptor descriptor = new ComponentDescriptor(component.getClass(), null ); + descriptor.setRole( role ); + descriptor.setRoleHint( roleHint ); + + Key key = new Key( descriptor.getRealm(), role, roleHint ); + + unmanagedComponents.put( key, component ); + } + public ComponentDescriptor getComponentDescriptor( Class type, String role, String roleHint ) { return repository.getComponentDescriptor( type, role, roleHint ); @@ -157,12 +172,19 @@ } if ( roleHint == null ) { - roleHint = PlexusConstants.PLEXUS_DEFAULT_HINT; + roleHint = ""; } return getComponent( type, role, roleHint, null ); } + public T lookup( ComponentDescriptor componentDescriptor ) + throws ComponentLookupException + { + return getComponent( componentDescriptor.getRoleClass(), componentDescriptor.getRole(), + componentDescriptor.getRoleHint(), componentDescriptor ); + } + public Map lookupMap( Class type, String role, List roleHints ) throws ComponentLookupException { @@ -279,7 +301,7 @@ public void removeComponentRealm( ClassRealm classRealm ) throws PlexusContainerException { repository.removeComponentRealm( classRealm ); - + List> dispose = new ArrayList>(); try { @@ -319,12 +341,21 @@ private T getComponent( Class type, String role, String roleHint, ComponentDescriptor descriptor ) throws ComponentLookupException { + // lookup for unmanaged components first + + T component = this.getUnmanagedComponent( role, roleHint ); // weird syntax due to http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6302954 + + if ( component != null ) + { + return component; + } + ComponentManager componentManager = getComponentManager( type, role, roleHint, descriptor ); // Get instance from manager... may result in creation try { - T component = componentManager.getComponent(); + component = componentManager.getComponent(); synchronized ( this ) { componentManagersByComponent.put( component, componentManager ); @@ -345,6 +376,28 @@ } } + @SuppressWarnings("unchecked") + private synchronized T getUnmanagedComponent( String role, String roleHint ) + { + Set realms = getSearchRealms( true ); + + if ( realms != null ) + { + // ignore unmanaged components, they are not associated with realms + // but lookup realm is provided via thread context classloader + return null; + } + else + { + if ( StringUtils.isEmpty( roleHint ) ) + { + roleHint = PlexusConstants.PLEXUS_DEFAULT_HINT; + } + + return (T) unmanagedComponents.get( new Key( null, role, roleHint ) ); + } + } + private synchronized ComponentManager getComponentManager( Class type, String role, String roleHint, ComponentDescriptor descriptor ) throws ComponentLookupException { @@ -355,7 +408,22 @@ roleHint ); } - ComponentManager componentManager = getComponentManager( type, role, roleHint ); + if ( descriptor == null ) + { + descriptor = getComponentDescriptor( type, role, roleHint ); + } + + ComponentManager componentManager = null; + + if ( descriptor != null ) + { + componentManager = getComponentManager( type, role, descriptor.getRoleHint(), descriptor.getRealm() ); + } + else + { + componentManager = getComponentManager( type, role, roleHint ); + } + if ( componentManager == null ) { // we need to create a component manager, but first we must have a descriptor @@ -369,16 +437,23 @@ role, roleHint ); } + // search also into descriptor realm as the key of a created component is per descriptor realm + componentManager = getComponentManager( type, role, descriptor.getRoleHint(), descriptor.getRealm() ); } - componentManager = createComponentManager( descriptor, role, roleHint ); + if ( componentManager == null ) + { + componentManager = createComponentManager( descriptor, role, descriptor.getRoleHint() ); + } } + return componentManager; } + @SuppressWarnings( "unchecked" ) private ComponentManager getComponentManager( Class type, String role, String roleHint ) { - Set realms = getSearchRealms(); + Set realms = getSearchRealms( false ); // return the component in the first realm for ( ClassRealm realm : realms ) @@ -392,25 +467,30 @@ return null; } - private Set getSearchRealms() + @SuppressWarnings( "unchecked" ) + private ComponentManager getComponentManager( Class type, String role, String roleHint, ClassRealm realm ) { - // determine realms to search - Set realms = new LinkedHashSet(); - for ( ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); classLoader != null; classLoader = classLoader.getParent() ) + ComponentManager manager = componentManagers.get( new Key( realm, role, roleHint ) ); + if ( manager != null && isAssignableFrom( type, manager.getType() ) ) { - if ( classLoader instanceof ClassRealm ) - { - ClassRealm realm = (ClassRealm) classLoader; - while ( realm != null ) - { - realms.add( realm ); - realm = realm.getParentRealm(); - } - } + return (ComponentManager) manager; } + return null; + } + + @SuppressWarnings( "unchecked" ) + private Set getSearchRealms( boolean specifiedOnly ) + { + // determine realms to search + Set realms = ClassRealmUtil.getContextRealms( container.getClassWorld() ); if ( realms.isEmpty() ) { + if ( specifiedOnly ) + { + return null; + } + realms.addAll( container.getClassWorld().getRealms() ); } @@ -529,7 +609,7 @@ int value; if ( realm != null ) { - value = realm.getId().compareTo( o.realm.getId() ); + value = o.realm == null? -1 : realm.getId().compareTo( o.realm.getId() ); } else { diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/DefaultPlexusContainer.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/DefaultPlexusContainer.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/DefaultPlexusContainer.java 2009-04-26 01:22:53.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/DefaultPlexusContainer.java 2016-08-31 19:01:49.000000000 +0000 @@ -32,17 +32,16 @@ import org.codehaus.plexus.classworlds.realm.ClassRealm; import org.codehaus.plexus.classworlds.realm.DuplicateRealmException; import org.codehaus.plexus.classworlds.realm.NoSuchRealmException; +import org.codehaus.plexus.component.composition.CycleDetectedInComponentGraphException; import org.codehaus.plexus.component.discovery.ComponentDiscoverer; import org.codehaus.plexus.component.discovery.ComponentDiscovererManager; import org.codehaus.plexus.component.discovery.ComponentDiscoveryEvent; import org.codehaus.plexus.component.discovery.ComponentDiscoveryListener; -import org.codehaus.plexus.component.discovery.PlexusXmlComponentDiscoverer; import org.codehaus.plexus.component.factory.ComponentFactoryManager; import org.codehaus.plexus.component.repository.ComponentDescriptor; import org.codehaus.plexus.component.repository.ComponentSetDescriptor; import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; -import org.codehaus.plexus.component.repository.exception.ComponentRepositoryException; import org.codehaus.plexus.component.repository.io.PlexusTools; import org.codehaus.plexus.configuration.PlexusConfiguration; import org.codehaus.plexus.configuration.PlexusConfigurationException; @@ -124,17 +123,23 @@ private ThreadLocal lookupRealm = new ThreadLocal(); public void addComponent( Object component, String role ) - throws ComponentRepositoryException { - ComponentDescriptor cd = new ComponentDescriptor(); - - cd.setRole( role ); + addComponent( component, role, PLEXUS_DEFAULT_HINT ); + } - cd.setRoleHint( PLEXUS_DEFAULT_HINT ); + public void addComponent( T component, Class role, String roleHint ) + { + addComponent( component, role.getName(), roleHint ); + } - cd.setImplementation( role ); + public void addComponent( Object component, String role, String roleHint ) + { + if ( roleHint == null ) + { + roleHint = PLEXUS_DEFAULT_HINT; + } - addComponentDescriptor( cd ); + getComponentRegistry().addComponent( component, role, roleHint ); } public ClassRealm setLookupRealm( ClassRealm realm ) @@ -365,7 +370,7 @@ public Object lookup( String role ) throws ComponentLookupException { - return componentRegistry.lookup( getRoleClass( role ), role, PLEXUS_DEFAULT_HINT ); + return componentRegistry.lookup( getRoleClass( role ), role, "" ); } public Object lookup( String role, String roleHint ) throws ComponentLookupException @@ -375,7 +380,7 @@ public T lookup( Class type ) throws ComponentLookupException { - return componentRegistry.lookup( type, type.getName(), PLEXUS_DEFAULT_HINT ); + return componentRegistry.lookup( type, type.getName(), "" ); } public T lookup( Class type, String roleHint ) throws ComponentLookupException @@ -385,10 +390,15 @@ public T lookup( Class type, String role, String roleHint ) throws ComponentLookupException { - return componentRegistry.lookup( type, role, roleHint ); } + public T lookup( ComponentDescriptor componentDescriptor ) + throws ComponentLookupException + { + return componentRegistry.lookup( componentDescriptor ); + } + public List lookupList( String role ) throws ComponentLookupException { return cast(componentRegistry.lookupList( getRoleClass( role ), role, null)); @@ -435,7 +445,7 @@ public boolean hasComponent( String role ) { - return componentRegistry.getComponentDescriptor( Object.class, role, PLEXUS_DEFAULT_HINT ) != null; + return componentRegistry.getComponentDescriptor( Object.class, role, "" ) != null; } public boolean hasComponent( String role, String roleHint ) @@ -445,7 +455,7 @@ public boolean hasComponent( Class type ) { - return componentRegistry.getComponentDescriptor( type, type.getName(), PLEXUS_DEFAULT_HINT ) != null; + return componentRegistry.getComponentDescriptor( type, type.getName(), "" ) != null; } public boolean hasComponent( Class type, String roleHint ) @@ -460,7 +470,7 @@ public ComponentDescriptor getComponentDescriptor( String role ) { - return componentRegistry.getComponentDescriptor( Object.class, role, PLEXUS_DEFAULT_HINT ); + return componentRegistry.getComponentDescriptor( Object.class, role, "" ); } public ComponentDescriptor getComponentDescriptor( String role, String roleHint ) @@ -493,7 +503,8 @@ return componentRegistry.getComponentDescriptorList( type, role ); } - public void addComponentDescriptor( ComponentDescriptor componentDescriptor ) throws ComponentRepositoryException + public void addComponentDescriptor( ComponentDescriptor componentDescriptor ) + throws CycleDetectedInComponentGraphException { if ( componentDescriptor.getRealm() == null ) { @@ -608,9 +619,9 @@ { throw new PlexusContainerException( "Error reading configuration file", e ); } - catch ( ComponentRepositoryException e ) + catch ( CycleDetectedInComponentGraphException e ) { - throw new PlexusContainerException( "Error discoverying components.", e ); + throw new PlexusContainerException( "Cycle detected in component graph in the system: ", e ); } } @@ -925,7 +936,13 @@ // Discovery public List> discoverComponents( ClassRealm realm ) - throws PlexusConfigurationException, ComponentRepositoryException + throws PlexusConfigurationException, CycleDetectedInComponentGraphException + { + return discoverComponents( realm, null ); + } + + public List> discoverComponents( ClassRealm realm, Object data ) + throws PlexusConfigurationException, CycleDetectedInComponentGraphException { List componentSetDescriptors = new ArrayList(); @@ -942,17 +959,17 @@ componentSetDescriptors.add( componentSetDescriptor ); + // Fire the event + ComponentDiscoveryEvent event = new ComponentDiscoveryEvent( componentSetDescriptor, data ); + + componentDiscovererManager.fireComponentDiscoveryEvent( event ); + for ( ComponentDescriptor componentDescriptor : componentSetDescriptor.getComponents() ) { addComponentDescriptor( componentDescriptor ); discoveredComponentDescriptors.add( componentDescriptor ); } - - // Fire the event - ComponentDiscoveryEvent event = new ComponentDiscoveryEvent( componentSetDescriptor ); - - componentDiscovererManager.fireComponentDiscoveryEvent( event ); } } diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/lifecycle/AbstractLifecycleHandler.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/lifecycle/AbstractLifecycleHandler.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/lifecycle/AbstractLifecycleHandler.java 2007-10-21 20:22:52.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/lifecycle/AbstractLifecycleHandler.java 2016-08-31 19:01:49.000000000 +0000 @@ -22,7 +22,6 @@ import org.codehaus.plexus.personality.plexus.lifecycle.phase.PhaseExecutionException; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; public abstract class AbstractLifecycleHandler @@ -90,11 +89,10 @@ return; } - for ( Iterator i = getBeginSegment().iterator(); i.hasNext(); ) - { - Phase phase = (Phase) i.next(); + for (Object o : getBeginSegment()) { + Phase phase = (Phase) o; - phase.execute( component, manager, realm ); + phase.execute(component, manager, realm); } } @@ -119,11 +117,10 @@ return; } - for ( Iterator i = getEndSegment().iterator(); i.hasNext(); ) - { - Phase phase = (Phase) i.next(); + for (Object o : getEndSegment()) { + Phase phase = (Phase) o; - phase.execute( component, manager, contextRealm ); + phase.execute(component, manager, contextRealm); } } diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/lifecycle/DefaultLifecycleHandlerManager.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/lifecycle/DefaultLifecycleHandlerManager.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/lifecycle/DefaultLifecycleHandlerManager.java 2008-10-28 17:41:43.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/lifecycle/DefaultLifecycleHandlerManager.java 2016-08-31 19:01:49.000000000 +0000 @@ -21,7 +21,7 @@ /** * @author Jason van Zyl - * @version $Id: DefaultLifecycleHandlerManager.java 7797 2008-10-28 17:41:43Z dain $ + * @version $Id$ */ public class DefaultLifecycleHandlerManager implements LifecycleHandlerManager diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/lifecycle/LifecycleHandlerManager.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/lifecycle/LifecycleHandlerManager.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/lifecycle/LifecycleHandlerManager.java 2008-10-28 17:41:43.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/lifecycle/LifecycleHandlerManager.java 2016-08-31 19:01:49.000000000 +0000 @@ -24,7 +24,7 @@ * * @author Jason van Zyl * - * @version $Id: LifecycleHandlerManager.java 7797 2008-10-28 17:41:43Z dain $ + * @version $Id$ */ public interface LifecycleHandlerManager { diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/logging/AbstractLogEnabled.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/logging/AbstractLogEnabled.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/logging/AbstractLogEnabled.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/logging/AbstractLogEnabled.java 2016-08-31 19:01:49.000000000 +0000 @@ -19,7 +19,7 @@ /** * @author Jason van Zyl * @author Trygve Laugstøl - * @version $Id: AbstractLogEnabled.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public abstract class AbstractLogEnabled implements LogEnabled diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/logging/AbstractLogger.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/logging/AbstractLogger.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/logging/AbstractLogger.java 2007-10-21 05:32:27.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/logging/AbstractLogger.java 2016-08-31 19:01:49.000000000 +0000 @@ -22,7 +22,7 @@ /** * @author Trygve Laugstøl - * @version $Id: AbstractLogger.java 6965 2007-10-21 05:32:27Z jvanzyl $ + * @version $Id$ */ public abstract class AbstractLogger implements Logger diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/logging/AbstractLoggerManager.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/logging/AbstractLoggerManager.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/logging/AbstractLoggerManager.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/logging/AbstractLoggerManager.java 2016-08-31 19:01:49.000000000 +0000 @@ -19,7 +19,7 @@ /** * @author Jason van Zyl * @author Trygve Laugstøl - * @version $Id: AbstractLoggerManager.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public abstract class AbstractLoggerManager implements LoggerManager diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/logging/BaseLoggerManager.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/logging/BaseLoggerManager.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/logging/BaseLoggerManager.java 2008-10-13 22:54:22.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/logging/BaseLoggerManager.java 2016-08-31 19:01:49.000000000 +0000 @@ -19,7 +19,6 @@ import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; import java.util.HashMap; -import java.util.Iterator; import java.util.Locale; import java.util.Map; @@ -27,7 +26,7 @@ * Base class for all LoggerManagers which use cache of Loggers. * * @author Michal Maczka - * @version $Id: BaseLoggerManager.java 7789 2008-10-13 22:54:22Z bentmann $ + * @version $Id$ */ public abstract class BaseLoggerManager extends AbstractLoggerManager implements Initializable @@ -100,10 +99,9 @@ { this.currentThreshold = currentThreshold; - for ( Iterator logs = loggerCache.values().iterator(); logs.hasNext(); ) - { - Logger logger = (Logger) logs.next(); - logger.setThreshold( currentThreshold ); + for (Object o : loggerCache.values()) { + Logger logger = (Logger) o; + logger.setThreshold(currentThreshold); } } diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/logging/console/ConsoleLogger.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/logging/console/ConsoleLogger.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/logging/console/ConsoleLogger.java 2006-11-23 04:09:31.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/logging/console/ConsoleLogger.java 2016-08-31 19:01:49.000000000 +0000 @@ -25,7 +25,7 @@ * does not have a logger to supply. * * @author Avalon Development Team - * @version $Id: ConsoleLogger.java 4779 2006-11-23 04:09:31Z jvanzyl $ + * @version $Id$ */ public final class ConsoleLogger extends AbstractLogger diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/logging/console/ConsoleLoggerManager.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/logging/console/ConsoleLoggerManager.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/logging/console/ConsoleLoggerManager.java 2008-10-13 22:54:22.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/logging/console/ConsoleLoggerManager.java 2016-08-31 19:01:49.000000000 +0000 @@ -22,7 +22,6 @@ import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; import java.util.HashMap; -import java.util.Iterator; import java.util.Locale; import java.util.Map; @@ -41,7 +40,7 @@ * * @author Jason van Zyl * @author Trygve Laugstøl - * @version $Id: ConsoleLoggerManager.java 7789 2008-10-13 22:54:22Z bentmann $ + * @version $Id$ */ public class ConsoleLoggerManager extends AbstractLoggerManager @@ -105,10 +104,9 @@ { this.currentThreshold = currentThreshold; - for ( Iterator logs = loggers.values().iterator(); logs.hasNext(); ) - { - Logger logger = (Logger) logs.next(); - logger.setThreshold( currentThreshold ); + for (Object o : loggers.values()) { + Logger logger = (Logger) o; + logger.setThreshold(currentThreshold); } } diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/logging/LogEnabled.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/logging/LogEnabled.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/logging/LogEnabled.java 2007-10-21 05:32:27.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/logging/LogEnabled.java 2016-08-31 19:01:49.000000000 +0000 @@ -17,7 +17,7 @@ */ /** - * @version $Id: LogEnabled.java 6965 2007-10-21 05:32:27Z jvanzyl $ + * @version $Id$ */ public interface LogEnabled { diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/logging/Logger.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/logging/Logger.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/logging/Logger.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/logging/Logger.java 2016-08-31 19:01:49.000000000 +0000 @@ -19,7 +19,7 @@ /** * @author Jason van Zyl * @author Trygve Laugstøl - * @version $Id: Logger.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public interface Logger { diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/logging/LoggerManager.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/logging/LoggerManager.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/logging/LoggerManager.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/logging/LoggerManager.java 2016-08-31 19:01:49.000000000 +0000 @@ -19,7 +19,7 @@ /** * @author Jason van Zyl * @author Trygve Laugstøl - * @version $Id: LoggerManager.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public interface LoggerManager { diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/Contextualizable.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/Contextualizable.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/Contextualizable.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/Contextualizable.java 2016-08-31 19:01:49.000000000 +0000 @@ -21,7 +21,7 @@ /** * @author Jason van Zyl - * @version $Id: Contextualizable.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public interface Contextualizable { diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/Disposable.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/Disposable.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/Disposable.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/Disposable.java 2016-08-31 19:01:49.000000000 +0000 @@ -21,7 +21,7 @@ * * @author Jason van Zyl * - * @version $Id: Disposable.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public interface Disposable { diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/Initializable.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/Initializable.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/Initializable.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/Initializable.java 2016-08-31 19:01:49.000000000 +0000 @@ -21,7 +21,7 @@ * * @author Jason van Zyl * - * @version $Id: Initializable.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public interface Initializable { diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/InitializationException.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/InitializationException.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/InitializationException.java 2007-10-21 05:32:27.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/InitializationException.java 2016-08-31 19:01:49.000000000 +0000 @@ -20,7 +20,7 @@ * Indicates a problem occurred when initialising a component. * * @author Brett Porter - * @version $Id: InitializationException.java 6965 2007-10-21 05:32:27Z jvanzyl $ + * @version $Id$ */ public class InitializationException extends Exception { diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/LogDisablePhase.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/LogDisablePhase.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/LogDisablePhase.java 2008-11-20 03:48:11.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/LogDisablePhase.java 2016-08-31 19:01:49.000000000 +0000 @@ -18,14 +18,13 @@ import org.codehaus.plexus.classworlds.realm.ClassRealm; import org.codehaus.plexus.component.manager.ComponentManager; -import org.codehaus.plexus.component.repository.ComponentDescriptor; import org.codehaus.plexus.lifecycle.phase.AbstractPhase; import org.codehaus.plexus.logging.LogEnabled; import org.codehaus.plexus.logging.LoggerManager; /** * @author Trygve Laugstøl - * @version $Id: LogDisablePhase.java 7858 2008-11-20 03:48:11Z dain $ + * @version $Id$ */ public class LogDisablePhase extends AbstractPhase diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/LogEnablePhase.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/LogEnablePhase.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/LogEnablePhase.java 2008-11-20 03:48:11.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/LogEnablePhase.java 2016-08-31 19:01:49.000000000 +0000 @@ -18,7 +18,6 @@ import org.codehaus.plexus.classworlds.realm.ClassRealm; import org.codehaus.plexus.component.manager.ComponentManager; -import org.codehaus.plexus.component.repository.ComponentDescriptor; import org.codehaus.plexus.lifecycle.phase.AbstractPhase; import org.codehaus.plexus.logging.LogEnabled; import org.codehaus.plexus.logging.Logger; diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/PhaseExecutionException.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/PhaseExecutionException.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/PhaseExecutionException.java 2006-11-23 04:09:31.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/PhaseExecutionException.java 2016-08-31 19:01:49.000000000 +0000 @@ -20,7 +20,7 @@ * Describes an error that has occurred during the execution of a phase. * * @author Brett Porter - * @version $Id: PhaseExecutionException.java 4779 2006-11-23 04:09:31Z jvanzyl $ + * @version $Id$ */ public class PhaseExecutionException extends Exception { diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/StartingException.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/StartingException.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/StartingException.java 2007-10-21 05:32:27.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/StartingException.java 2016-08-31 19:01:49.000000000 +0000 @@ -20,7 +20,7 @@ * Error occuring while starting a component. * * @author Brett Porter - * @version $Id: StartingException.java 6965 2007-10-21 05:32:27Z jvanzyl $ + * @version $Id$ */ public class StartingException extends Exception diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/StoppingException.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/StoppingException.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/StoppingException.java 2007-10-21 05:32:27.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/personality/plexus/lifecycle/phase/StoppingException.java 2016-08-31 19:01:49.000000000 +0000 @@ -20,7 +20,7 @@ * Error occuring while starting a component. * * @author Brett Porter - * @version $Id: StoppingException.java 6965 2007-10-21 05:32:27Z jvanzyl $ + * @version $Id$ */ public class StoppingException extends Exception diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/PlexusContainerException.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/PlexusContainerException.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/PlexusContainerException.java 2007-10-21 05:32:27.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/PlexusContainerException.java 2016-08-31 19:01:49.000000000 +0000 @@ -20,7 +20,7 @@ * Container execution exception. * * @author Brett Porter - * @version $Id: PlexusContainerException.java 6965 2007-10-21 05:32:27Z jvanzyl $ + * @version $Id$ */ public class PlexusContainerException extends Exception { diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/PlexusContainer.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/PlexusContainer.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/PlexusContainer.java 2008-11-25 03:00:07.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/PlexusContainer.java 2016-08-31 19:01:49.000000000 +0000 @@ -16,7 +16,11 @@ * limitations under the License. */ +import java.util.List; +import java.util.Map; + import org.codehaus.plexus.classworlds.realm.ClassRealm; +import org.codehaus.plexus.component.composition.CycleDetectedInComponentGraphException; import org.codehaus.plexus.component.discovery.ComponentDiscoveryListener; import org.codehaus.plexus.component.repository.ComponentDescriptor; import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException; @@ -25,9 +29,6 @@ import org.codehaus.plexus.configuration.PlexusConfigurationException; import org.codehaus.plexus.context.Context; -import java.util.List; -import java.util.Map; - /** * PlexusContainer is the entry-point for loading and accessing other * components. @@ -85,6 +86,14 @@ throws ComponentLookupException; /** + * Looks up and returns a component object matching the given component descriptor. + * @param componentDescriptor the descriptor of the component + * @return a Plexus component object + */ + T lookup( ComponentDescriptor componentDescriptor ) + throws ComponentLookupException; + + /** * Looks up and returns a List of component objects with the given role. * @param role a non-unique key for the desired components * @return a List of component objects @@ -219,10 +228,10 @@ * @throws ComponentRepositoryException */ void addComponentDescriptor( ComponentDescriptor componentDescriptor ) - throws ComponentRepositoryException; + throws CycleDetectedInComponentGraphException; /** - * Releases the component from the container. This is dependant upon how the implementation manages the component, + * Releases the component from the container. This is dependent upon how the implementation manages the component, * but usually enacts some standard lifecycle shutdown procedure on the component. In every case, the component is * no longer accessible from the container (unless another is created). * @param component the plexus component object to release @@ -326,7 +335,7 @@ /** * Adds the listener to this container. ComponentDiscoveryListeners have the ability to respond to various * ComponentDiscoverer events. - * @param listener A listener which responds to differnet ComponentDiscoveryEvents + * @param listener A listener which responds to different ComponentDiscoveryEvents */ void registerComponentDiscoveryListener( ComponentDiscoveryListener listener ); @@ -339,20 +348,23 @@ /** * Discovers components in the given realm. * @param childRealm - * @param override wheter to override/merge any conflicting components, where the new component takes precedence. + * @param override whether to override/merge any conflicting components, where the new component takes precedence. * @return * @throws PlexusConfigurationException * @throws ComponentRepositoryException */ List> discoverComponents( ClassRealm childRealm ) - throws PlexusConfigurationException, ComponentRepositoryException; - + throws PlexusConfigurationException, CycleDetectedInComponentGraphException; + + List> discoverComponents( ClassRealm realm, Object data ) + throws PlexusConfigurationException, CycleDetectedInComponentGraphException; + // ---------------------------------------------------------------------------- // Component/Plugin ClassRealm creation // ---------------------------------------------------------------------------- - ClassRealm createChildRealm( String id ); - + ClassRealm createChildRealm( String id ); + ClassRealm getComponentRealm( String realmId ); /** @@ -373,7 +385,7 @@ /** * Sets the lookup realm to use for lookup calls that don't have a ClassRealm parameter. * @param realm the new realm to use. - * @return The previous lookup realm. It is adviced to set it back once the old-style lookups have completed. + * @return The previous lookup realm. It is advised to set it back once the old-style lookups have completed. */ ClassRealm setLookupRealm(ClassRealm realm); @@ -389,5 +401,14 @@ ClassRealm getLookupRealm( Object component ); void addComponent( Object component, String role ) - throws ComponentRepositoryException; + throws CycleDetectedInComponentGraphException; + + /** + * Adds live component instance to this container. + * + * Component instance is not associated with any class realm and will + * be ignored during lookup is lookup realm is provided using thread context + * classloader. + */ + void addComponent( T component, Class role, String roleHint ); } diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/PlexusJUnit4TestCase.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/PlexusJUnit4TestCase.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/PlexusJUnit4TestCase.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/PlexusJUnit4TestCase.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,315 @@ +package org.codehaus.plexus; + +/* + * Copyright 2001-2006 Codehaus Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import org.codehaus.plexus.component.repository.exception.ComponentLookupException; +import org.codehaus.plexus.component.repository.exception.ComponentLookupRuntimeException; +import org.codehaus.plexus.configuration.PlexusConfiguration; +import org.codehaus.plexus.context.Context; +import org.codehaus.plexus.context.DefaultContext; +import org.junit.After; +import org.junit.Before; + +import java.io.File; +import java.io.InputStream; + +import static org.junit.Assert.fail; + +/** + * @author Jason van Zyl + * @author Trygve Laugstøl + * @author Michal Maczka + * @version $Id$ + */ +public abstract class PlexusJUnit4TestCase +{ + private PlexusContainer container; + + private static String basedir; + + @Before + public void beforeTest() + throws Exception + { + basedir = getBasedir(); + } + + @SuppressWarnings("ResultOfMethodCallIgnored") + protected void setupContainer() + { + // ---------------------------------------------------------------------------- + // Context Setup + // ---------------------------------------------------------------------------- + + DefaultContext context = new DefaultContext(); + + context.put( "basedir", getBasedir() ); + + customizeContext( context ); + + boolean hasPlexusHome = context.contains( "plexus.home" ); + + if ( !hasPlexusHome ) + { + File f = getTestFile( "target/plexus-home" ); + + if ( !f.isDirectory() ) + { + f.mkdir(); + } + + context.put( "plexus.home", f.getAbsolutePath() ); + } + + // ---------------------------------------------------------------------------- + // Configuration + // ---------------------------------------------------------------------------- + + String config = getCustomConfigurationName(); + + ContainerConfiguration containerConfiguration = new DefaultContainerConfiguration() + .setName( "test" ) + .setContext( context.getContextData() ); + + if ( config != null ) + { + containerConfiguration.setContainerConfiguration( config ); + } + else + { + String resource = getConfigurationName( null ); + + containerConfiguration.setContainerConfiguration( resource ); + } + + customizeContainerConfiguration( containerConfiguration ); + + try + { + container = new DefaultPlexusContainer( containerConfiguration ); + } + catch ( PlexusContainerException e ) + { + e.printStackTrace(); + fail( "Failed to create plexus container." ); + } + } + + /** + * Allow custom test case implementations do augment the default container configuration before + * executing tests. + * + * @param containerConfiguration The configuration + */ + protected void customizeContainerConfiguration( ContainerConfiguration containerConfiguration ) + { + } + + protected void customizeContext( Context context ) + { + } + + protected PlexusConfiguration customizeComponentConfiguration() + { + return null; + } + + @After + public void afterTest() + throws Exception + { + if ( container != null ) + { + container.dispose(); + + container = null; + } + } + + protected PlexusContainer getContainer() + { + if ( container == null ) + { + setupContainer(); + } + + return container; + } + + protected InputStream getConfiguration() + { + return getConfiguration( null ); + } + + protected InputStream getConfiguration( String subname ) + { + return getResourceAsStream( getConfigurationName( subname ) ); + } + + protected String getCustomConfigurationName() + { + return null; + } + + /** + * Allow the retrieval of a container configuration that is based on the name + * of the test class being run. So if you have a test class called org.foo.FunTest, then + * this will produce a resource name of org/foo/FunTest.xml which would be used to + * configure the Plexus container before running your test. + * + * @param subname the subname (not used) + * @return A configuration name + */ + protected String getConfigurationName( String subname ) + { + return getClass().getName().replace( '.', '/' ) + ".xml"; + } + + protected InputStream getResourceAsStream( String resource ) + { + return getClass().getResourceAsStream( resource ); + } + + protected ClassLoader getClassLoader() + { + return getClass().getClassLoader(); + } + + // ---------------------------------------------------------------------- + // Container access + // ---------------------------------------------------------------------- + + protected Object lookup( String componentKey ) + { + try + { + return getContainer().lookup( componentKey ); + } + catch ( ComponentLookupException e ) + { + throw new ComponentLookupRuntimeException( e ); + } + } + + protected Object lookup( String role, + String roleHint ) + throws ComponentLookupRuntimeException + { + try + { + return getContainer().lookup( role, roleHint ); + } + catch ( ComponentLookupException e ) + { + throw new ComponentLookupRuntimeException( e ); + } + } + + protected T lookup( Class componentClass ) + throws ComponentLookupRuntimeException + { + try + { + return getContainer().lookup( componentClass ); + } + catch ( ComponentLookupException e ) + { + throw new ComponentLookupRuntimeException( e ); + } + } + + protected T lookup( Class componentClass, String roleHint ) + throws ComponentLookupRuntimeException + { + try + { + return getContainer().lookup( componentClass, roleHint ); + } + catch ( ComponentLookupException e ) + { + throw new ComponentLookupRuntimeException( e ); + } + } + + protected void release( Object component ) + throws Exception + { + getContainer().release( component ); + } + + // ---------------------------------------------------------------------- + // Helper methods for sub classes + // ---------------------------------------------------------------------- + + public static File getTestFile( String path ) + { + return new File( getBasedir(), path ); + } + + public static File getTestFile( String basedir, + String path ) + { + File basedirFile = new File( basedir ); + + if ( !basedirFile.isAbsolute() ) + { + basedirFile = getTestFile( basedir ); + } + + return new File( basedirFile, path ); + } + + public static String getTestPath( String path ) + { + return getTestFile( path ).getAbsolutePath(); + } + + public static String getTestPath( String basedir, + String path ) + { + return getTestFile( basedir, path ).getAbsolutePath(); + } + + public static String getBasedir() + { + if ( basedir != null ) + { + return basedir; + } + + basedir = System.getProperty( "basedir" ); + + if ( basedir == null ) + { + basedir = new File( "" ).getAbsolutePath(); + } + + return basedir; + } + + public String getTestConfiguration() + { + return getTestConfiguration( getClass() ); + } + + public static String getTestConfiguration( Class clazz ) + { + String s = clazz.getName().replace( '.', '/' ); + + return s.substring( 0, s.indexOf( "$" ) ) + ".xml"; + } +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/PlexusTestCase.java plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/PlexusTestCase.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/java/org/codehaus/plexus/PlexusTestCase.java 2009-02-10 23:50:53.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/java/org/codehaus/plexus/PlexusTestCase.java 2016-08-31 19:01:49.000000000 +0000 @@ -18,8 +18,6 @@ import java.io.File; import java.io.InputStream; -import java.util.HashMap; -import java.util.Map; import junit.framework.TestCase; @@ -31,7 +29,7 @@ * @author Jason van Zyl * @author Trygve Laugstøl * @author Michal Maczka - * @version $Id: PlexusTestCase.java 8105 2009-02-10 23:50:53Z jvanzyl $ + * @version $Id$ */ public abstract class PlexusTestCase extends TestCase @@ -46,6 +44,7 @@ basedir = getBasedir(); } + @SuppressWarnings("ResultOfMethodCallIgnored") protected void setupContainer() { // ---------------------------------------------------------------------------- @@ -59,7 +58,7 @@ customizeContext( context ); boolean hasPlexusHome = context.contains( "plexus.home" ); - + if ( !hasPlexusHome ) { File f = getTestFile( "target/plexus-home" ); @@ -119,12 +118,12 @@ protected void customizeContext( Context context ) { } - + protected PlexusConfiguration customizeComponentConfiguration() { - return null; + return null; } - + protected void tearDown() throws Exception { @@ -166,11 +165,11 @@ /** * Allow the retrieval of a container configuration that is based on the name * of the test class being run. So if you have a test class called org.foo.FunTest, then - * this will produce a resource name of org/foo/FunTest.xml which would be used to + * this will produce a resource name of org/foo/FunTest.xml which would be used to * configure the Plexus container before running your test. - * - * @param subname - * @return + * + * @param subname the subname + * @return A configruation name */ protected String getConfigurationName( String subname ) { @@ -191,17 +190,19 @@ // Container access // ---------------------------------------------------------------------- - protected Object lookup( String componentKey ) + @SuppressWarnings("unchecked") + protected T lookup( String componentKey ) throws Exception { - return getContainer().lookup( componentKey ); + return (T) getContainer().lookup( componentKey ); } - protected Object lookup( String role, + @SuppressWarnings("unchecked") + protected T lookup( String role, String roleHint ) throws Exception { - return getContainer().lookup( role, roleHint ); + return (T) getContainer().lookup( role, roleHint ); } protected T lookup( Class componentClass ) diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/mdo/components.mdo plexus-containers-1.7.1/plexus-container-default/src/main/mdo/components.mdo --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/mdo/components.mdo 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/mdo/components.mdo 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,245 @@ + + + + plexus-components + PlexusComponents + + This is a documentation for the Plexus Components descriptor: META-INF/plexus/components.xml.

+

An XSD is available at + http://plexus.codehaus.org/xsd/components-1.3.0.xsd. +

]]> +
+ + + + ComponentSetDescriptor + javadoc.]]> + + 1.0.0+ + + + components + 1.0.0+ + + ComponentDescriptor + * + + The component descriptors that can be found within this component set descriptor. + + + dependencies + 1.0.0+ + + ComponentDependency + * + + The dependencies that are required by the set of components found in this component set descriptor. + + + + + + ComponentDescriptor + javadoc.]]> + + 1.0.0+ + + + role + 1.0.0+ + String + the role of this component. + + + role-hint + 1.0.0+ + String + the role-hint of this component. + + + implementation + 1.0.0+ + String + + the implementation of this component. Implementation is a string denoting a FQCN in normal Java + components, or some other name or file for other component factory implementations. + + + + version + 1.0.0+ + String + a specific point in a components's project timeline. i.e. version 1, or 2.1.4 + + + component-type + 1.0.0+ + String + the type of this component. + + + instantiation-strategy + 1.0.0+ + String + the type of instantiation strategy for this component: one of "per-lookup", "singleton", "keep-alive" or "poolable". + singleton + + + lifecycle-handler + 1.0.0+ + String + the lifecycle-handler for this component. For example, "basic", "passive", "bootstrap". + + + component-profile + 1.0.0+ + String + + + + component-composer + 1.0.0+ + String + + the ID of the type of composer this component will use. For example, "setter" or "field" for the + different types of dependency injection. + + + + component-configurator + 1.0.0+ + String + + the type of component configurator for this project. For example "basic" for normal, or "map-oriented" + for map oriented components. + + + + component-factory + 1.0.0+ + String + an id of the factory used to create this component. For example, "jruby" will use a JRuby factory. + + + description + 1.0.0+ + String + a human-readable description of this component. + + + alias + 1.0.0+ + String + an alias for this component. An alias is as an alternate name other than the normal key. + + + isolated-realm + 1.0.0+ + boolean + true if this may be in an isolated classrealm. + + + configuration + 1.0.0+ + DOM + configuration values defined for this component. + + + requirements + 1.0.0+ + + ComponentRequirement + * + + project requirements to this component. + + + + + ComponentRequirement + + This represents a component that is required by another component. + + 1.0.0+ + + + role + 1.0.0+ + String + the role of the required component. + + + field-name + 1.0.0+ + String + the name of the field that will be populated by the required component. + + + role-hint + 1.0.0+ + String + the role-hint of the required component. + default + + + role-hints + 1.0.0+ + + String + * + + the role-hints of the required component. + + + optional + 1.3.0+ + boolean + + Controls whether a failure to satisfy this requirement can be tolerated by host component or whether construction + of the host component should also fail. + + + + + + ComponentDependency + + + 1.0.0+ + + + artifact-id + 1.0.0+ + String + the dependency's artifact ID. + + + group-id + 1.0.0+ + String + the dependency's group ID. + + + type + 1.0.0+ + String + the type of dependency, for example a "jar". + + + version + 1.0.0+ + String + the point in a project's development timeline + + + + +
diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/mdo/plexus.mdo plexus-containers-1.7.1/plexus-container-default/src/main/mdo/plexus.mdo --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/mdo/plexus.mdo 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/mdo/plexus.mdo 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,190 @@ + + + + plexus-configuration + PlexusConfiguration + + This is a Work In Progress for a documentation for the Plexus Container descriptor: META-INF/plexus/plexus.xml.

+

An XSD will be available at + http://plexus.codehaus.org/xsd/plexus-1.3.0.xsd. +

+

Note that since plexus.xml is a superset of components.xml, + this documentation only focuses on elements only available in plexus.xml.

+ ]]> +
+ + + + PlexusDescriptor + + + see org.codehaus.plexus.configuration.PlexusConfigurationMerger + 1.0.0+ + + + load-on-start + 1.0.0+ + TBD + DOM + + + system-properties + 1.0.0+ + TBD + DOM + + + configurations-directory + 1.0.0+ + TBD + DOM + + + logging + 1.0.0+ + TBD + DOM + + + component-repository + 1.0.0+ + TBD + DOM + + + resources + 1.0.0+ + TBD + DOM + + + component-manager-manager + 1.0.0+ + TBD + DOM + + + component-discoverer-manager + 1.0.0+ + TBD + + ComponentDiscovererManager + + + + component-factory-manager + 1.0.0+ + TBD + DOM + + + lifecycle-handler-manager + 1.0.0+ + TBD + DOM + + + component-composer-manager + 1.0.0+ + TBD + DOM + + + components + 1.0.0+ + DOM + components.xml.]]> + + + + + + + ComponentDiscovererManager + org.codehaus.plexus.component.discovery.ComponentDiscovererManager + source + javadoc.]]> + + 1.0.0+ + + + implementation + 1.0.0+ + Implementation class. + String + + + listeners + 1.0.0+ + + * + ComponentDiscoveryListener + + + + component-discoverers + 1.0.0+ + + * + ComponentDiscoverer + + + + + + ComponentDiscoveryListener + org.codehaus.plexus.component.discovery.ComponentDiscoveryListener + source + javadoc.]]> + + 1.0.0+ + + + implementation + 1.0.0+ + Implementation class. + String + + + configuration + 1.0.0+ + Configuration of the class. + Content + + + + + ComponentDiscoverer + org.codehaus.plexus.component.discovery.ComponentDiscoverer + source + javadoc.]]> + + 1.0.0+ + + + implementation + 1.0.0+ + Implementation class. + String + + + configuration + 1.0.0+ + Configuration of the class. + Content + + + + +
diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/resources/META-INF/plexus/components.xml plexus-containers-1.7.1/plexus-container-default/src/main/resources/META-INF/plexus/components.xml --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/main/resources/META-INF/plexus/components.xml 2008-11-15 23:37:08.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/main/resources/META-INF/plexus/components.xml 2016-08-31 19:01:49.000000000 +0000 @@ -5,5 +5,10 @@ org.codehaus.plexus.component.configurator.ComponentConfigurator basic + + org.codehaus.plexus.component.configurator.MapOrientedComponentConfigurator + org.codehaus.plexus.component.configurator.ComponentConfigurator + map-oriented + \ No newline at end of file diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/site/apt/index.apt plexus-containers-1.7.1/plexus-container-default/src/site/apt/index.apt --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/site/apt/index.apt 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/site/apt/index.apt 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,34 @@ + ----- + plexus-container-default + ----- + Hervé Boutemy + ----- + 2009-10-06 + ----- + +Overview + + <<>> is Plexus' (IoC) container. It is composed of: + + * its public API: the root class is + <<<{{{./apidocs/org/codehaus/plexus/PlexusContainer.html}org.codehaus.plexus.PlexusContainer}}>>>, + + * its default implementation: the root class is + <<<{{{./apidocs/org/codehaus/plexus/DefaultPlexusContainer.html}org.codehaus.plexus.DefaultPlexusContainer}}>>>. + + [] + + + Default implementation reads configuration in XML files: + + * multiple <<<{{{./plexus-components.html}META-INF/plexus/components.xml}}>>> files that declare components, + + * one <<<{{{./plexus-configuration.html}META-INF/plexus/plexus.xml}}>>> file that can be used to configure + the plexus container and runtime in addition to declaring components. + + [] + + But it is not limited to these files: Plexus container is by nature very extensible, it can be configured + programmatically too or extended to read configuration from any source. It is used for example in Maven 2 to + read plugins configuration from <<>> and instanciate Mojos downloaded from + Maven repositories. diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/site/site.xml plexus-containers-1.7.1/plexus-container-default/src/site/site.xml --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/site/site.xml 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/site/site.xml 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/AbstractComponent.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/AbstractComponent.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/AbstractComponent.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/AbstractComponent.java 2016-08-31 19:01:49.000000000 +0000 @@ -21,7 +21,7 @@ * * @author Jason van Zyl * - * @version $Id: AbstractComponent.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public class AbstractComponent implements Component diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/AbstractCompositionResolverTest.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/AbstractCompositionResolverTest.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/AbstractCompositionResolverTest.java 2009-04-26 01:22:53.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/AbstractCompositionResolverTest.java 2016-08-31 19:01:49.000000000 +0000 @@ -29,7 +29,7 @@ * * @author Jason van Zyl * - * @version $Id: AbstractCompositionResolverTest.java 8155 2009-04-26 01:22:53Z jvanzyl $ + * @version $Id$ */ public abstract class AbstractCompositionResolverTest extends TestCase diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/ComponentA.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/ComponentA.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/ComponentA.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/ComponentA.java 2016-08-31 19:01:49.000000000 +0000 @@ -21,7 +21,7 @@ * * @author Jason van Zyl * - * @version $Id: ComponentA.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public interface ComponentA { diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/ComponentB.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/ComponentB.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/ComponentB.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/ComponentB.java 2016-08-31 19:01:49.000000000 +0000 @@ -21,7 +21,7 @@ * * @author Jason van Zyl * - * @version $Id: ComponentB.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public interface ComponentB { diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/ComponentC.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/ComponentC.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/ComponentC.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/ComponentC.java 2016-08-31 19:01:49.000000000 +0000 @@ -21,7 +21,7 @@ * * @author Jason van Zyl * - * @version $Id: ComponentC.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public interface ComponentC { diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/ComponentD.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/ComponentD.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/ComponentD.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/ComponentD.java 2016-08-31 19:01:49.000000000 +0000 @@ -21,7 +21,7 @@ * * @author Jason van Zyl * - * @version $Id: ComponentD.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public interface ComponentD { diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/ComponentE.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/ComponentE.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/ComponentE.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/ComponentE.java 2016-08-31 19:01:49.000000000 +0000 @@ -21,7 +21,7 @@ * * @author Jason van Zyl * - * @version $Id: ComponentE.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public interface ComponentE { diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/ComponentF.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/ComponentF.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/ComponentF.java 2006-11-23 04:09:31.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/ComponentF.java 2016-08-31 19:01:49.000000000 +0000 @@ -21,7 +21,7 @@ /** * @author Michal Maczka - * @version $Id: ComponentF.java 4779 2006-11-23 04:09:31Z jvanzyl $ + * @version $Id$ */ public class ComponentF { diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/Component.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/Component.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/Component.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/Component.java 2016-08-31 19:01:49.000000000 +0000 @@ -21,7 +21,7 @@ * * @author Jason van Zyl * - * @version $Id: Component.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public interface Component { diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/ComponentWithSeveralFieldsOfTheSameType.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/ComponentWithSeveralFieldsOfTheSameType.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/ComponentWithSeveralFieldsOfTheSameType.java 2006-11-23 04:09:31.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/ComponentWithSeveralFieldsOfTheSameType.java 2016-08-31 19:01:49.000000000 +0000 @@ -18,7 +18,7 @@ /** * @author Trygve Laugstøl - * @version $Id: ComponentWithSeveralFieldsOfTheSameType.java 4779 2006-11-23 04:09:31Z jvanzyl $ + * @version $Id$ */ public class ComponentWithSeveralFieldsOfTheSameType { diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/CompositionExceptionTest.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/CompositionExceptionTest.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/CompositionExceptionTest.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/CompositionExceptionTest.java 1970-01-01 00:00:00.000000000 +0000 @@ -1,37 +0,0 @@ -package org.codehaus.plexus.component.composition; - -/* - * Copyright 2001-2006 Codehaus Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import junit.framework.TestCase; - -/** - * - * - * @author Jason van Zyl - * - * @version $Id: CompositionExceptionTest.java 7089 2007-11-25 15:19:06Z jvanzyl $ - */ -public class CompositionExceptionTest - extends TestCase -{ - public void testException() - { - CompositionException e = new CompositionException( "bad doggy!" ); - - assertEquals( "bad doggy!", e.getMessage() ); - } -} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/DefaultComponentA.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/DefaultComponentA.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/DefaultComponentA.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/DefaultComponentA.java 2016-08-31 19:01:49.000000000 +0000 @@ -21,7 +21,7 @@ * * @author Jason van Zyl * - * @version $Id: DefaultComponentA.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public class DefaultComponentA implements ComponentA diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/DefaultComponentB.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/DefaultComponentB.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/DefaultComponentB.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/DefaultComponentB.java 2016-08-31 19:01:49.000000000 +0000 @@ -19,7 +19,7 @@ /** * @author Jason van Zyl * - * @version $Id: DefaultComponentB.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public class DefaultComponentB implements ComponentB diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/DefaultComponentC.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/DefaultComponentC.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/DefaultComponentC.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/DefaultComponentC.java 2016-08-31 19:01:49.000000000 +0000 @@ -21,7 +21,7 @@ * * @author Jason van Zyl * - * @version $Id: DefaultComponentC.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public class DefaultComponentC implements ComponentC { diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/DefaultComponentComposerManagerTest.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/DefaultComponentComposerManagerTest.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/DefaultComponentComposerManagerTest.java 2008-11-14 22:07:56.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/DefaultComponentComposerManagerTest.java 2016-08-31 19:01:49.000000000 +0000 @@ -20,7 +20,7 @@ /** * @author Michal Maczka - * @version $Id: DefaultComponentComposerManagerTest.java 7828 2008-11-14 22:07:56Z dain $ + * @version $Id$ */ public class DefaultComponentComposerManagerTest extends PlexusTestCase diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/DefaultComponent.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/DefaultComponent.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/DefaultComponent.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/DefaultComponent.java 2016-08-31 19:01:49.000000000 +0000 @@ -21,7 +21,7 @@ * * @author Jason van Zyl * - * @version $Id: DefaultComponent.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public class DefaultComponent extends AbstractComponent diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/DefaultCompositionResolverTest.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/DefaultCompositionResolverTest.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/DefaultCompositionResolverTest.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/composition/DefaultCompositionResolverTest.java 2016-08-31 19:01:49.000000000 +0000 @@ -21,7 +21,7 @@ * * @author Jason van Zyl * - * @version $Id: DefaultCompositionResolverTest.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public class DefaultCompositionResolverTest extends AbstractCompositionResolverTest diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/AbstractComponentConfiguratorTest.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/AbstractComponentConfiguratorTest.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/AbstractComponentConfiguratorTest.java 2009-01-04 19:41:09.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/AbstractComponentConfiguratorTest.java 2016-08-31 19:01:49.000000000 +0000 @@ -26,6 +26,7 @@ import java.io.File; import java.io.StringReader; +import java.lang.annotation.ElementType; import java.net.URI; import java.net.URL; import java.util.LinkedList; @@ -38,7 +39,9 @@ import org.codehaus.plexus.PlexusTestCase; import org.codehaus.plexus.classworlds.ClassWorld; import org.codehaus.plexus.classworlds.realm.ClassRealm; +import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException; import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator; +import org.codehaus.plexus.component.configurator.expression.TypeAwareExpressionEvaluator; import org.codehaus.plexus.component.repository.ComponentDescriptor; import org.codehaus.plexus.component.repository.io.PlexusTools; import org.codehaus.plexus.configuration.PlexusConfiguration; @@ -46,7 +49,7 @@ /** * @author Michal Maczka - * @version $Id: AbstractComponentConfiguratorTest.java 8005 2009-01-04 19:41:09Z bentmann $ + * @version $Id$ */ public abstract class AbstractComponentConfiguratorTest extends PlexusTestCase @@ -381,7 +384,7 @@ assertEquals( "something important", ( (ImportantThing) objectArray[1] ).getName() ); - assertEquals( new Integer( 303 ), objectArray[2] ); + assertEquals(303, objectArray[2] ); URL[] urls = component.getUrlArray(); @@ -539,6 +542,58 @@ } + public void testComponentConfigurationWithPropertiesFieldsWithExpressions() + throws Exception + { + + String xml = "" + "" // + + "${theName}${theValue}" // + + "empty" // + + "" + ""; + + final Properties values = new Properties(); + values.put( "${theName}", "test" ); + values.put( "${theValue}", "PASSED" ); + + ExpressionEvaluator expressionEvaluator = new ExpressionEvaluator() + { + public Object evaluate( String expression ) + { + return values.containsKey( expression ) ? values.get( expression ) : expression; + } + + public File alignToBaseDirectory( File file ) + { + return null; + } + }; + + PlexusConfiguration configuration = PlexusTools.buildConfiguration( "", new StringReader( xml ) ); + + ComponentWithPropertiesField component = new ComponentWithPropertiesField(); + + ComponentDescriptor descriptor = new ComponentDescriptor(); + + descriptor.setRole( "role" ); + + descriptor.setImplementation( component.getClass().getName() ); + + descriptor.setConfiguration( configuration ); + + ClassWorld classWorld = new ClassWorld(); + + ClassRealm realm = classWorld.newRealm( "test", getClass().getClassLoader() ); + + configureComponent( component, descriptor, realm, expressionEvaluator ); + + Properties properties = component.getSomeProperties(); + + assertNotNull( properties ); + + assertEquals( "PASSED", properties.get( "test" ) ); + assertEquals( "", properties.get( "empty" ) ); + } + public void testComponentConfigurationWithMapField() throws Exception { @@ -603,9 +658,270 @@ } catch ( ComponentConfigurationException e ) { - // expected - e.printStackTrace(); } } + public void testComponentConfigurationWhereFieldIsEnum() + throws Exception + { + String xml = "" // + + " TYPE" // + + " ONE" // + + ""; + + PlexusConfiguration configuration = PlexusTools.buildConfiguration( "", new StringReader( xml ) ); + + ComponentWithEnumFields component = new ComponentWithEnumFields(); + + ComponentDescriptor descriptor = new ComponentDescriptor(); + + descriptor.setRole( "role" ); + + descriptor.setImplementation( component.getClass().getName() ); + + descriptor.setConfiguration( configuration ); + + ClassWorld classWorld = new ClassWorld(); + + ClassRealm realm = classWorld.newRealm( "test", getClass().getClassLoader() ); + + configureComponent( component, descriptor, realm ); + + assertEquals( ElementType.TYPE, component.getSimpleEnum() ); + + assertEquals( ComponentWithEnumFields.NestedEnum.ONE, component.getNestedEnum() ); + } + + public void testComponentConfigurationWithAmbiguousExpressionValue() + throws Exception + { + String xml = "" // + + "
${address}
" // + + "
"; + + PlexusConfiguration configuration = PlexusTools.buildConfiguration( "", new StringReader( xml ) ); + + DefaultComponent component = new DefaultComponent(); + + ExpressionEvaluator expressionEvaluator = new TypeAwareExpressionEvaluator() + { + public Object evaluate( String expression ) + throws ExpressionEvaluationException + { + return evaluate( expression, null ); + } + + public File alignToBaseDirectory( File file ) + { + return null; + } + + public Object evaluate( String expression, Class type ) + throws ExpressionEvaluationException + { + if ( String.class == type ) + { + return "PASSED"; + } + else + { + return Boolean.FALSE; + } + } + }; + + ComponentDescriptor descriptor = new ComponentDescriptor(); + + descriptor.setRole( "role" ); + + descriptor.setImplementation( component.getClass().getName() ); + + descriptor.setConfiguration( configuration ); + + ClassWorld classWorld = new ClassWorld(); + + ClassRealm realm = classWorld.newRealm( "test", getClass().getClassLoader() ); + + configureComponent( component, descriptor, realm, expressionEvaluator ); + + assertEquals( "PASSED", component.getAddress() ); + } + + public void testComponentConfigurationWithPrimitiveValueConversion() + throws Exception + { + String xml = "" // + + " ${primitive}" // + + ""; + + PlexusConfiguration configuration = PlexusTools.buildConfiguration( "", new StringReader( xml ) ); + + ConfigurableComponent component = new ConfigurableComponent(); + + ExpressionEvaluator expressionEvaluator = new TypeAwareExpressionEvaluator() + { + public Object evaluate( String expression ) + throws ExpressionEvaluationException + { + return evaluate( expression, null ); + } + + public File alignToBaseDirectory( File file ) + { + return null; + } + + public Object evaluate( String expression, Class type ) + throws ExpressionEvaluationException + { + // java.lang.Short -> short -> int + return (short) 23; + } + }; + + ComponentDescriptor descriptor = new ComponentDescriptor(); + + descriptor.setRole( "role" ); + + descriptor.setImplementation( component.getClass().getName() ); + + descriptor.setConfiguration( configuration ); + + ClassWorld classWorld = new ClassWorld(); + + ClassRealm realm = classWorld.newRealm( "test", getClass().getClassLoader() ); + + configureComponent( component, descriptor, realm, expressionEvaluator ); + + assertEquals( 23, component.getIntValue() ); + } + + public void testComponentConfigurationWithEmptyContentForBasicField() + throws Exception + { + String xml = "" // + + "
" // + + "
"; + + PlexusConfiguration configuration = PlexusTools.buildConfiguration( "", new StringReader( xml ) ); + + DefaultComponent component = new DefaultComponent(); + + ComponentDescriptor descriptor = new ComponentDescriptor(); + + descriptor.setRole( "role" ); + + descriptor.setImplementation( component.getClass().getName() ); + + descriptor.setConfiguration( configuration ); + + ClassWorld classWorld = new ClassWorld(); + + ClassRealm realm = classWorld.newRealm( "test", getClass().getClassLoader() ); + + configureComponent( component, descriptor, realm ); + + assertEquals( null, component.getAddress() ); + } + + public void testComponentConfigurationWithEmptyContentForCompositeField() + throws Exception + { + String xml = "" // + + " " // + + ""; + + PlexusConfiguration configuration = PlexusTools.buildConfiguration( "", new StringReader( xml ) ); + + ComponentWithCompositeFields component = new ComponentWithCompositeFields(); + + ComponentDescriptor descriptor = new ComponentDescriptor(); + + descriptor.setRole( "role" ); + + descriptor.setImplementation( component.getClass().getName() ); + + descriptor.setConfiguration( configuration ); + + ClassWorld classWorld = new ClassWorld(); + + ClassRealm realm = classWorld.newRealm( "test", getClass().getClassLoader() ); + + configureComponent( component, descriptor, realm ); + + assertNotNull( component.getBean() ); + } + + public void testComponentConfigurationWithUnresolvedExpressionContentForCompositeFieldOfNonInstantiatableType() + throws Exception + { + String xml = "" // + + " ${null-valued-expression}" // + + ""; + + PlexusConfiguration configuration = PlexusTools.buildConfiguration( "", new StringReader( xml ) ); + + ComponentWithCompositeFields component = new ComponentWithCompositeFields(); + + ExpressionEvaluator expressionEvaluator = new ExpressionEvaluator() + { + public Object evaluate( String expression ) + throws ExpressionEvaluationException + { + return null; + } + + public File alignToBaseDirectory( File file ) + { + return null; + } + }; + + ComponentDescriptor descriptor = new ComponentDescriptor(); + + descriptor.setRole( "role" ); + + descriptor.setImplementation( component.getClass().getName() ); + + descriptor.setConfiguration( configuration ); + + ClassWorld classWorld = new ClassWorld(); + + ClassRealm realm = classWorld.newRealm( "test", getClass().getClassLoader() ); + + configureComponent( component, descriptor, realm, expressionEvaluator ); + + assertEquals( null, component.getThing() ); + } + + public void testComponentConfiguratorFileNormalizesSeparator() + throws Exception + { + String xml = "" + + " dir/test.txt" + + " dir\\test.txt" + + ""; + + PlexusConfiguration configuration = PlexusTools.buildConfiguration( "", new StringReader( xml ) ); + + ComponentWithArrayFields component = new ComponentWithArrayFields(); + + ComponentDescriptor descriptor = new ComponentDescriptor(); + + descriptor.setRole( "role" ); + + descriptor.setImplementation( component.getClass().getName() ); + + descriptor.setConfiguration(configuration); + + ClassWorld classWorld = new ClassWorld(); + + ClassRealm realm = classWorld.newRealm( "test", getClass().getClassLoader() ); + + configureComponent(component, descriptor, realm); + + assertEquals( new File( "dir", "test.txt" ), component.getFileArray()[0] ); + assertEquals( new File( "dir", "test.txt" ), component.getFileArray()[1] ); + } + } diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/AbstractComponent.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/AbstractComponent.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/AbstractComponent.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/AbstractComponent.java 2016-08-31 19:01:49.000000000 +0000 @@ -29,7 +29,7 @@ * * @author Jason van Zyl * - * @version $Id: AbstractComponent.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public class AbstractComponent implements Component diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/Component.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/Component.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/Component.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/Component.java 2016-08-31 19:01:49.000000000 +0000 @@ -29,7 +29,7 @@ * * @author Jason van Zyl * - * @version $Id: Component.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public interface Component { diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ComponentWithArrayFields.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ComponentWithArrayFields.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ComponentWithArrayFields.java 2006-12-12 03:49:50.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ComponentWithArrayFields.java 2016-08-31 19:01:49.000000000 +0000 @@ -29,7 +29,7 @@ /** * @author Kenney Westerhof - * @version $Id: ComponentWithArrayFields.java 5127 2006-12-12 03:49:50Z jvanzyl $ + * @version $Id$ */ public class ComponentWithArrayFields { diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ComponentWithCollectionFields.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ComponentWithCollectionFields.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ComponentWithCollectionFields.java 2009-01-04 18:39:40.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ComponentWithCollectionFields.java 2016-08-31 19:01:49.000000000 +0000 @@ -32,7 +32,7 @@ /** * @author Michal Maczka - * @version $Id: ComponentWithCollectionFields.java 8004 2009-01-04 18:39:40Z bentmann $ + * @version $Id$ */ public class ComponentWithCollectionFields { diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ComponentWithCompositeFields.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ComponentWithCompositeFields.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ComponentWithCompositeFields.java 2006-12-12 03:49:50.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ComponentWithCompositeFields.java 2016-08-31 19:01:49.000000000 +0000 @@ -29,16 +29,24 @@ * * @author Michal Maczka * - * @version $Id: ComponentWithCompositeFields.java 5127 2006-12-12 03:49:50Z jvanzyl $ + * @version $Id$ */ public class ComponentWithCompositeFields { private ThingInterface thing; + private DefaultComponent bean; + public ThingInterface getThing() { return thing; } + + public DefaultComponent getBean() + { + return bean; + } + } diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ComponentWithEnumFields.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ComponentWithEnumFields.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ComponentWithEnumFields.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ComponentWithEnumFields.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,56 @@ +package org.codehaus.plexus.component.configurator; + +/* + * The MIT License + * + * Copyright (c) 2004, The Codehaus + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +import java.lang.annotation.ElementType; + +/** + * @author Benjamin Bentmann + */ +public class ComponentWithEnumFields +{ + + public enum NestedEnum + { + + ONE, TWO, THREE, + + } + + private NestedEnum nestedEnum; + + private ElementType simpleEnum; + + public NestedEnum getNestedEnum() + { + return nestedEnum; + } + + public ElementType getSimpleEnum() + { + return simpleEnum; + } + +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ComponentWithMapField.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ComponentWithMapField.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ComponentWithMapField.java 2006-12-12 03:49:50.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ComponentWithMapField.java 2016-08-31 19:01:49.000000000 +0000 @@ -31,7 +31,7 @@ * * @author Michal Maczka * - * @version $Id: ComponentWithMapField.java 5127 2006-12-12 03:49:50Z jvanzyl $ + * @version $Id$ */ public class ComponentWithMapField { diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ComponentWithPropertiesField.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ComponentWithPropertiesField.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ComponentWithPropertiesField.java 2006-12-12 03:49:50.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ComponentWithPropertiesField.java 2016-08-31 19:01:49.000000000 +0000 @@ -31,7 +31,7 @@ * * @author Michal Maczka * - * @version $Id: ComponentWithPropertiesField.java 5127 2006-12-12 03:49:50Z jvanzyl $ + * @version $Id$ */ public class ComponentWithPropertiesField { diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ComponentWithSetters.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ComponentWithSetters.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ComponentWithSetters.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ComponentWithSetters.java 2016-08-31 19:01:49.000000000 +0000 @@ -34,7 +34,7 @@ * * @author Jason van Zyl * - * @version $Id: ComponentWithSetters.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public class ComponentWithSetters { diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ConfigurableComponent.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ConfigurableComponent.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ConfigurableComponent.java 2008-10-13 21:56:51.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ConfigurableComponent.java 2016-08-31 19:01:49.000000000 +0000 @@ -36,7 +36,7 @@ * * @author Jason van Zyl * - * @version $Id: ConfigurableComponent.java 7783 2008-10-13 21:56:51Z bentmann $ + * @version $Id$ */ public class ConfigurableComponent { diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/DefaultComponent.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/DefaultComponent.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/DefaultComponent.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/DefaultComponent.java 2016-08-31 19:01:49.000000000 +0000 @@ -29,7 +29,7 @@ * * @author Jason van Zyl * - * @version $Id: DefaultComponent.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public class DefaultComponent extends AbstractComponent diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ImportantThing.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ImportantThing.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ImportantThing.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/ImportantThing.java 2016-08-31 19:01:49.000000000 +0000 @@ -30,7 +30,7 @@ * * @author Jason van Zyl * - * @version $Id: ImportantThing.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public class ImportantThing extends AbstractThing implements ThingInterface { diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/XBeanComponentConfiguratorTest.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/XBeanComponentConfiguratorTest.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/XBeanComponentConfiguratorTest.java 2009-01-04 19:41:09.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/configurator/XBeanComponentConfiguratorTest.java 2016-08-31 19:01:49.000000000 +0000 @@ -13,7 +13,7 @@ @Override protected void configureComponent(Object component, ComponentDescriptor descriptor, ClassRealm realm) throws Exception { XBeanComponentBuilder componentBuilder = new XBeanComponentBuilder(); - ObjectRecipe recipe = componentBuilder.createObjectRecipe(descriptor, realm); + ObjectRecipe recipe = componentBuilder.createObjectRecipe( component, descriptor, realm); // need a caller context ExecutionContext executionContext = new DefaultExecutionContext(); @@ -46,6 +46,28 @@ // expression evalator is not supported since it is not used by normal AutoConfigurePhase } + public void testComponentConfigurationWithPropertiesFieldsWithExpressions() throws Exception { + // expression evalator is not supported since it is not used by normal AutoConfigurePhase + } + + public void testComponentConfigurationWithAmbiguousExpressionValue() + throws Exception + { + // expression evalator is not supported since it is not used by normal AutoConfigurePhase + } + + public void testComponentConfigurationWithPrimitiveValueConversion() + throws Exception + { + // expression evalator is not supported since it is not used by normal AutoConfigurePhase + } + + public void testComponentConfigurationWithUnresolvedExpressionContentForCompositeFieldOfNonInstantiatableType() + throws Exception + { + // expression evalator is not supported since it is not used by normal AutoConfigurePhase + } + protected ComponentConfigurator getComponentConfigurator() throws Exception { // this should never be called because the configureComponent is overridden throw new UnsupportedOperationException(); diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/discovery/ComponentDiscovererTest.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/discovery/ComponentDiscovererTest.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/discovery/ComponentDiscovererTest.java 2009-04-26 01:22:53.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/discovery/ComponentDiscovererTest.java 2016-08-31 19:01:49.000000000 +0000 @@ -31,7 +31,7 @@ /** * @author Jason van Zyl * - * @version $Id: ComponentDiscovererTest.java 8155 2009-04-26 01:22:53Z jvanzyl $ + * @version $Id$ */ public class ComponentDiscovererTest extends PlexusTestCase diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/discovery/DefaultDiscoveredComponent.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/discovery/DefaultDiscoveredComponent.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/discovery/DefaultDiscoveredComponent.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/discovery/DefaultDiscoveredComponent.java 2016-08-31 19:01:49.000000000 +0000 @@ -21,7 +21,7 @@ * * @author Jason van Zyl * - * @version $Id: DefaultDiscoveredComponent.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public class DefaultDiscoveredComponent implements DiscoveredComponent diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/discovery/DiscoveredComponent.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/discovery/DiscoveredComponent.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/discovery/DiscoveredComponent.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/discovery/DiscoveredComponent.java 2016-08-31 19:01:49.000000000 +0000 @@ -21,7 +21,7 @@ * * @author Jason van Zyl * - * @version $Id: DiscoveredComponent.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public interface DiscoveredComponent { diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/factory/ComponentImplA.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/factory/ComponentImplA.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/factory/ComponentImplA.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/factory/ComponentImplA.java 2016-08-31 19:01:49.000000000 +0000 @@ -21,7 +21,7 @@ * * @author Jason van Zyl * - * @version $Id: ComponentImplA.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public class ComponentImplA implements Component { diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/factory/ComponentImplB.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/factory/ComponentImplB.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/factory/ComponentImplB.java 2006-11-23 04:09:31.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/factory/ComponentImplB.java 2016-08-31 19:01:49.000000000 +0000 @@ -18,7 +18,7 @@ /** * @author Michal Maczka - * @version $Id: ComponentImplB.java 4779 2006-11-23 04:09:31Z jvanzyl $ + * @version $Id$ */ public class ComponentImplB { diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/factory/ComponentImplC.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/factory/ComponentImplC.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/factory/ComponentImplC.java 2006-11-23 04:09:31.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/factory/ComponentImplC.java 2016-08-31 19:01:49.000000000 +0000 @@ -18,7 +18,7 @@ /** * @author Michal Maczka - * @version $Id: ComponentImplC.java 4779 2006-11-23 04:09:31Z jvanzyl $ + * @version $Id$ */ public abstract class ComponentImplC { diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/factory/Component.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/factory/Component.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/factory/Component.java 2006-11-23 03:54:18.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/factory/Component.java 2016-08-31 19:01:49.000000000 +0000 @@ -18,7 +18,7 @@ /** * @author Michal Maczka - * @version $Id: Component.java 4778 2006-11-23 03:54:18Z jvanzyl $ + * @version $Id$ */ public interface Component { diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/factory/java/JavaComponentFactoryTest.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/factory/java/JavaComponentFactoryTest.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/factory/java/JavaComponentFactoryTest.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/factory/java/JavaComponentFactoryTest.java 2016-08-31 19:01:49.000000000 +0000 @@ -32,7 +32,7 @@ /** * @author Jason van Zyl * @author Michal Maczka - * @version $Id: JavaComponentFactoryTest.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public class JavaComponentFactoryTest extends TestCase diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/manager/ClassicSingletonComponentManagerTest.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/manager/ClassicSingletonComponentManagerTest.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/manager/ClassicSingletonComponentManagerTest.java 2008-11-14 22:07:56.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/manager/ClassicSingletonComponentManagerTest.java 2016-08-31 19:01:49.000000000 +0000 @@ -4,7 +4,7 @@ /** * @author Ben Walding - * @version $Id: ClassicSingletonComponentManagerTest.java 7828 2008-11-14 22:07:56Z dain $ + * @version $Id$ */ public class ClassicSingletonComponentManagerTest extends PlexusTestCase diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/manager/SlowComponentClassicSingletonComponentManagerTest.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/manager/SlowComponentClassicSingletonComponentManagerTest.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/manager/SlowComponentClassicSingletonComponentManagerTest.java 2008-11-23 14:39:51.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/manager/SlowComponentClassicSingletonComponentManagerTest.java 2016-08-31 19:01:49.000000000 +0000 @@ -21,7 +21,7 @@ /** * @author Ben Walding - * @version $Id: SlowComponentClassicSingletonComponentManagerTest.java 7876 2008-11-23 14:39:51Z bentmann $ + * @version $Id$ */ public class SlowComponentClassicSingletonComponentManagerTest extends PlexusTestCase diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/manager/SlowComponent.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/manager/SlowComponent.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/manager/SlowComponent.java 2007-01-17 02:36:27.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/manager/SlowComponent.java 2016-08-31 19:01:49.000000000 +0000 @@ -24,7 +24,7 @@ * Configuration: * delay - number of milliseconds to sleep during start() * @author Ben Walding - * @version $Id: SlowComponent.java 5451 2007-01-17 02:36:27Z jvanzyl $ + * @version $Id$ */ public class SlowComponent implements Startable diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/repository/ComponentDescriptorTest.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/repository/ComponentDescriptorTest.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/repository/ComponentDescriptorTest.java 2009-04-26 01:22:53.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/repository/ComponentDescriptorTest.java 2016-08-31 19:01:49.000000000 +0000 @@ -28,7 +28,7 @@ * * @author Jason van Zyl * - * @version $Id: ComponentDescriptorTest.java 8155 2009-04-26 01:22:53Z jvanzyl $ + * @version $Id$ */ public class ComponentDescriptorTest extends TestCase diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/repository/ComponentRequirementTest.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/repository/ComponentRequirementTest.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/repository/ComponentRequirementTest.java 2006-11-23 04:09:31.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/repository/ComponentRequirementTest.java 2016-08-31 19:01:49.000000000 +0000 @@ -20,7 +20,7 @@ /** * @author Michal Maczka - * @version $Id: ComponentRequirementTest.java 4779 2006-11-23 04:09:31Z jvanzyl $ + * @version $Id$ */ public class ComponentRequirementTest extends TestCase diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/repository/ComponentSetTest.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/repository/ComponentSetTest.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/repository/ComponentSetTest.java 2009-04-26 01:22:53.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/repository/ComponentSetTest.java 2016-08-31 19:01:49.000000000 +0000 @@ -28,7 +28,7 @@ * * @author Jason van Zyl * - * @version $Id: ComponentSetTest.java 8155 2009-04-26 01:22:53Z jvanzyl $ + * @version $Id$ */ public class ComponentSetTest extends TestCase diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/repository/DefaultComponentRepositoryTest.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/repository/DefaultComponentRepositoryTest.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/component/repository/DefaultComponentRepositoryTest.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/component/repository/DefaultComponentRepositoryTest.java 2016-08-31 19:01:49.000000000 +0000 @@ -23,7 +23,7 @@ * * @author Jason van Zyl * - * @version $Id: DefaultComponentRepositoryTest.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public class DefaultComponentRepositoryTest extends TestCase diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/configuration/ConfigurationResourceExceptionTest.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/configuration/ConfigurationResourceExceptionTest.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/configuration/ConfigurationResourceExceptionTest.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/configuration/ConfigurationResourceExceptionTest.java 2016-08-31 19:01:49.000000000 +0000 @@ -23,7 +23,7 @@ * * @author Jason van Zyl * - * @version $Id: ConfigurationResourceExceptionTest.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public class ConfigurationResourceExceptionTest extends TestCase diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/configuration/ConfigurationTestHelper.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/configuration/ConfigurationTestHelper.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/configuration/ConfigurationTestHelper.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/configuration/ConfigurationTestHelper.java 2016-08-31 19:01:49.000000000 +0000 @@ -23,7 +23,7 @@ /** * @author Jason van Zyl - * @version $Id: ConfigurationTestHelper.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public abstract class ConfigurationTestHelper extends TestCase diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/configuration/DefaultPlexusConfigurationTest.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/configuration/DefaultPlexusConfigurationTest.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/configuration/DefaultPlexusConfigurationTest.java 2008-11-18 22:33:53.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/configuration/DefaultPlexusConfigurationTest.java 2016-08-31 19:01:49.000000000 +0000 @@ -20,7 +20,7 @@ /** * @author Ran Tene - * @version $Id: DefaultPlexusConfigurationTest.java 7854 2008-11-18 22:33:53Z bentmann $ + * @version $Id$ */ public final class DefaultPlexusConfigurationTest extends TestCase diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/configuration/xml/XmlPlexusConfigurationTest.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/configuration/xml/XmlPlexusConfigurationTest.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/configuration/xml/XmlPlexusConfigurationTest.java 2008-01-26 20:55:42.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/configuration/xml/XmlPlexusConfigurationTest.java 2016-08-31 19:01:49.000000000 +0000 @@ -22,7 +22,7 @@ /** * @author Ran Tene - * @version $Id: XmlPlexusConfigurationTest.java 7187 2008-01-26 20:55:42Z cstamas $ + * @version $Id$ */ public final class XmlPlexusConfigurationTest extends TestCase diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/DefaultComponentLookupManagerTest.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/DefaultComponentLookupManagerTest.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/DefaultComponentLookupManagerTest.java 2008-11-14 22:07:56.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/DefaultComponentLookupManagerTest.java 2016-08-31 19:01:49.000000000 +0000 @@ -5,7 +5,7 @@ /** * @author Trygve Laugstøl - * @version $Id: DefaultComponentLookupManagerTest.java 7828 2008-11-14 22:07:56Z dain $ + * @version $Id$ */ public class DefaultComponentLookupManagerTest extends PlexusTestCase diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/DyanamicComponentKungFuTest.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/DyanamicComponentKungFuTest.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/DyanamicComponentKungFuTest.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/DyanamicComponentKungFuTest.java 2016-08-31 19:01:49.000000000 +0000 @@ -24,7 +24,7 @@ * * @author Jason van Zyl * - * @version $Id: DyanamicComponentKungFuTest.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public class DyanamicComponentKungFuTest extends TestCase diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/logging/AbstractLoggerManagerTest.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/logging/AbstractLoggerManagerTest.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/logging/AbstractLoggerManagerTest.java 2006-11-23 03:54:18.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/logging/AbstractLoggerManagerTest.java 2016-08-31 19:01:49.000000000 +0000 @@ -24,7 +24,7 @@ * * @author Mark H. Wilkinson * @author Trygve Laugstøl - * @version $Revision: 4778 $ + * @version $Revision$ */ public abstract class AbstractLoggerManagerTest extends PlexusTestCase diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/logging/console/ConsoleLoggerManagerTest.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/logging/console/ConsoleLoggerManagerTest.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/logging/console/ConsoleLoggerManagerTest.java 2008-11-14 22:07:56.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/logging/console/ConsoleLoggerManagerTest.java 2016-08-31 19:01:49.000000000 +0000 @@ -25,7 +25,7 @@ * {@link org.codehaus.plexus.logging.console.ConsoleLogger}. * * @author Mark H. Wilkinson - * @version $Revision: 7828 $ + * @version $Revision$ */ public final class ConsoleLoggerManagerTest extends AbstractLoggerManagerTest diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/logging/console/ConsoleLoggerTest.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/logging/console/ConsoleLoggerTest.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/logging/console/ConsoleLoggerTest.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/logging/console/ConsoleLoggerTest.java 2016-08-31 19:01:49.000000000 +0000 @@ -25,7 +25,7 @@ /** * @author Jason van Zyl * - * @version $Id: ConsoleLoggerTest.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public class ConsoleLoggerTest extends TestCase diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/logging/CustomLoggerManagerTest.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/logging/CustomLoggerManagerTest.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/logging/CustomLoggerManagerTest.java 2008-11-14 22:07:56.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/logging/CustomLoggerManagerTest.java 2016-08-31 19:01:49.000000000 +0000 @@ -22,7 +22,7 @@ /** * @author Trygve Laugstøl - * @version $Id: CustomLoggerManagerTest.java 7828 2008-11-14 22:07:56Z dain $ + * @version $Id$ */ public class CustomLoggerManagerTest extends PlexusTestCase diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/logging/LogEnabledTest.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/logging/LogEnabledTest.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/logging/LogEnabledTest.java 2006-11-23 04:09:31.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/logging/LogEnabledTest.java 2016-08-31 19:01:49.000000000 +0000 @@ -21,7 +21,7 @@ /** * * @author Peter Donald - * @version $Revision: 4779 $ $Date: 2006-11-23 05:09:31 +0100 (Do, 23. Nov 2006) $ + * @version $Revision$ $Date$ */ public class LogEnabledTest extends TestCase diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/logging/MockLogEnabled.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/logging/MockLogEnabled.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/logging/MockLogEnabled.java 2006-11-23 04:09:31.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/logging/MockLogEnabled.java 2016-08-31 19:01:49.000000000 +0000 @@ -19,7 +19,7 @@ /** * * @author Peter Donald - * @version $Revision: 4779 $ $Date: 2006-11-23 05:09:31 +0100 (Do, 23. Nov 2006) $ + * @version $Revision$ $Date$ */ class MockLogEnabled extends AbstractLogEnabled diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/logging/MockLogger.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/logging/MockLogger.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/logging/MockLogger.java 2006-11-23 04:09:31.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/logging/MockLogger.java 2016-08-31 19:01:49.000000000 +0000 @@ -19,7 +19,7 @@ /** * * @author Peter Donald - * @version $Revision: 4779 $ $Date: 2006-11-23 05:09:31 +0100 (Do, 23. Nov 2006) $ + * @version $Revision$ $Date$ */ class MockLogger implements Logger diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/logging/MockLoggerManager.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/logging/MockLoggerManager.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/logging/MockLoggerManager.java 2006-11-23 03:54:18.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/logging/MockLoggerManager.java 2016-08-31 19:01:49.000000000 +0000 @@ -18,7 +18,7 @@ /** * @author Trygve Laugstøl - * @version $Id: MockLoggerManager.java 4778 2006-11-23 03:54:18Z jvanzyl $ + * @version $Id$ */ public class MockLoggerManager implements LoggerManager diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/PlexusJUnit4TestCaseTest.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/PlexusJUnit4TestCaseTest.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/PlexusJUnit4TestCaseTest.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/PlexusJUnit4TestCaseTest.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,28 @@ +package org.codehaus.plexus; + +import org.junit.Test; +import org.junit.runner.JUnitCore; + +import java.util.concurrent.atomic.AtomicBoolean; + +import static org.junit.Assert.*; + +public class PlexusJUnit4TestCaseTest +{ + + private static AtomicBoolean run = new AtomicBoolean( false ); + public static class MyTest + extends PlexusJUnit4TestCase { + + @Test + public void yeah(){ + run.set( true ); + } + } + + @Test + public void runMytest(){ + JUnitCore.runClasses(MyTest.class); + assertTrue( run.get() ); + } +} \ No newline at end of file diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/PlexusTestCaseTest.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/PlexusTestCaseTest.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/PlexusTestCaseTest.java 2008-11-14 22:07:56.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/PlexusTestCaseTest.java 2016-08-31 19:01:49.000000000 +0000 @@ -25,7 +25,7 @@ /** * @author Jason van Zyl - * @version $Id: PlexusTestCaseTest.java 7828 2008-11-14 22:07:56Z dain $ + * @version $Id$ */ public class PlexusTestCaseTest extends TestCase diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/AbstractStartableComponent.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/AbstractStartableComponent.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/AbstractStartableComponent.java 2009-01-19 23:33:12.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/AbstractStartableComponent.java 2016-08-31 19:01:49.000000000 +0000 @@ -3,7 +3,7 @@ import org.codehaus.plexus.personality.plexus.lifecycle.phase.Startable; import org.codehaus.plexus.personality.plexus.lifecycle.phase.StartingException; import org.codehaus.plexus.personality.plexus.lifecycle.phase.StoppingException; -import junit.framework.Assert; + import static junit.framework.Assert.assertTrue; public class AbstractStartableComponent diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/Action.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/Action.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/Action.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/Action.java 2016-08-31 19:01:49.000000000 +0000 @@ -21,7 +21,7 @@ * * @author Jason van Zyl * - * @version $Id: Action.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public interface Action { diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/AddUserAction.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/AddUserAction.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/AddUserAction.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/AddUserAction.java 2016-08-31 19:01:49.000000000 +0000 @@ -21,7 +21,7 @@ * * @author Jason van Zyl * - * @version $Id: AddUserAction.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public class AddUserAction implements Action diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/Component.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/Component.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/Component.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/Component.java 2016-08-31 19:01:49.000000000 +0000 @@ -23,7 +23,7 @@ * * @author Jason van Zyl * - * @version $Id: Component.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public interface Component { diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/ComponentManager.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/ComponentManager.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/ComponentManager.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/ComponentManager.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,29 @@ +package org.codehaus.plexus.test; + +/* + * Copyright 2001-2006 Codehaus Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import java.util.List; +import java.util.Map; + +public interface ComponentManager +{ + + List getList(); + + Map getMap(); + +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/ComponentWithRoleDefault.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/ComponentWithRoleDefault.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/ComponentWithRoleDefault.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/ComponentWithRoleDefault.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,23 @@ +package org.codehaus.plexus.test; + +/* + * Copyright 2001-2006 Codehaus Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +public class ComponentWithRoleDefault +{ + +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/ConcreteThing.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/ConcreteThing.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/ConcreteThing.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/ConcreteThing.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,23 @@ +package org.codehaus.plexus.test; + +/* + * Copyright 2001-2006 Codehaus Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +public class ConcreteThing + implements Thing +{ + +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultComponentManager.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultComponentManager.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultComponentManager.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultComponentManager.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,40 @@ +package org.codehaus.plexus.test; + +/* + * Copyright 2001-2006 Codehaus Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import java.util.List; +import java.util.Map; + +public class DefaultComponentManager + implements ComponentManager +{ + + private List list; + + private Map map; + + public List getList() + { + return list; + } + + public Map getMap() + { + return map; + } + +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultComponentWithOptionalRequirement.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultComponentWithOptionalRequirement.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultComponentWithOptionalRequirement.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultComponentWithOptionalRequirement.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,25 @@ +package org.codehaus.plexus.test; + +/* + * Copyright 2001-2006 Codehaus Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +public class DefaultComponentWithOptionalRequirement + extends DefaultComponent +{ + + public Object optionalComponent; + +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultLoadOnStartService.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultLoadOnStartService.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultLoadOnStartService.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultLoadOnStartService.java 2016-08-31 19:01:49.000000000 +0000 @@ -23,7 +23,7 @@ * * @author Jason van Zyl * - * @version $Id: DefaultLoadOnStartService.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public class DefaultLoadOnStartService implements LoadOnStartService, Startable diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultLoadOnStartServiceWithRoleHint.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultLoadOnStartServiceWithRoleHint.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultLoadOnStartServiceWithRoleHint.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultLoadOnStartServiceWithRoleHint.java 2016-08-31 19:01:49.000000000 +0000 @@ -22,7 +22,7 @@ * * @author Jason van Zyl * - * @version $Id: DefaultLoadOnStartServiceWithRoleHint.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public class DefaultLoadOnStartServiceWithRoleHint implements LoadOnStartService diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultThingUser.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultThingUser.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultThingUser.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/DefaultThingUser.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,25 @@ +package org.codehaus.plexus.test; + +/* + * Copyright 2001-2006 Codehaus Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +public class DefaultThingUser + implements ThingUser +{ + + public Thing thing; + +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/lifecycle/phase/Eeny.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/lifecycle/phase/Eeny.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/lifecycle/phase/Eeny.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/lifecycle/phase/Eeny.java 2016-08-31 19:01:49.000000000 +0000 @@ -21,7 +21,7 @@ * * @author Jason van Zyl * - * @version $Id: Eeny.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public interface Eeny { diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/lifecycle/phase/Meeny.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/lifecycle/phase/Meeny.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/lifecycle/phase/Meeny.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/lifecycle/phase/Meeny.java 2016-08-31 19:01:49.000000000 +0000 @@ -21,7 +21,7 @@ * * @author Jason van Zyl * - * @version $Id: Meeny.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public interface Meeny { diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/lifecycle/phase/Miny.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/lifecycle/phase/Miny.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/lifecycle/phase/Miny.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/lifecycle/phase/Miny.java 2016-08-31 19:01:49.000000000 +0000 @@ -21,7 +21,7 @@ * * @author Jason van Zyl * - * @version $Id: Miny.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public interface Miny { diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/lifecycle/phase/Mo.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/lifecycle/phase/Mo.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/lifecycle/phase/Mo.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/lifecycle/phase/Mo.java 2016-08-31 19:01:49.000000000 +0000 @@ -21,7 +21,7 @@ * * @author Jason van Zyl * - * @version $Id: Mo.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public interface Mo { diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/list/AbstractValve.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/list/AbstractValve.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/list/AbstractValve.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/list/AbstractValve.java 2016-08-31 19:01:49.000000000 +0000 @@ -21,7 +21,7 @@ * * @author Jason van Zyl * - * @version $Id: AbstractValve.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public abstract class AbstractValve implements Valve diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/list/DefaultPipeline.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/list/DefaultPipeline.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/list/DefaultPipeline.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/list/DefaultPipeline.java 2016-08-31 19:01:49.000000000 +0000 @@ -16,7 +16,6 @@ * limitations under the License. */ -import java.util.Iterator; import java.util.List; import java.util.Map; @@ -25,7 +24,7 @@ * * @author Jason van Zyl * - * @version $Id: DefaultPipeline.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public class DefaultPipeline implements Pipeline @@ -36,9 +35,8 @@ public void execute() { - for ( Iterator i = valves.iterator(); i.hasNext(); ) - { - ((Valve) i.next()).execute(); + for (Object valve : valves) { + ((Valve) valve).execute(); } } diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/list/Pipeline.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/list/Pipeline.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/list/Pipeline.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/list/Pipeline.java 2016-08-31 19:01:49.000000000 +0000 @@ -22,7 +22,7 @@ /** * @author Jason van Zyl * - * @version $Id: Pipeline.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public interface Pipeline { diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/list/ValveFour.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/list/ValveFour.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/list/ValveFour.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/list/ValveFour.java 2016-08-31 19:01:49.000000000 +0000 @@ -21,7 +21,7 @@ * * @author Jason van Zyl * - * @version $Id: ValveFour.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public class ValveFour extends AbstractValve diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/list/Valve.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/list/Valve.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/list/Valve.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/list/Valve.java 2016-08-31 19:01:49.000000000 +0000 @@ -21,7 +21,7 @@ * * @author Jason van Zyl * - * @version $Id: Valve.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public interface Valve { diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/list/ValveOne.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/list/ValveOne.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/list/ValveOne.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/list/ValveOne.java 2016-08-31 19:01:49.000000000 +0000 @@ -21,7 +21,7 @@ * * @author Jason van Zyl * - * @version $Id: ValveOne.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public class ValveOne extends AbstractValve diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/list/ValveThree.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/list/ValveThree.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/list/ValveThree.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/list/ValveThree.java 2016-08-31 19:01:49.000000000 +0000 @@ -21,7 +21,7 @@ * * @author Jason van Zyl * - * @version $Id: ValveThree.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public class ValveThree extends AbstractValve diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/list/ValveTwo.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/list/ValveTwo.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/list/ValveTwo.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/list/ValveTwo.java 2016-08-31 19:01:49.000000000 +0000 @@ -21,7 +21,7 @@ * * @author Jason van Zyl * - * @version $Id: ValveTwo.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public class ValveTwo extends AbstractValve diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/LiveComponent.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/LiveComponent.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/LiveComponent.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/LiveComponent.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,23 @@ +package org.codehaus.plexus.test; + +/* + * Copyright 2001-2006 Codehaus Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +public class LiveComponent +{ + +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/LoadOnStartService.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/LoadOnStartService.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/LoadOnStartService.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/LoadOnStartService.java 2016-08-31 19:01:49.000000000 +0000 @@ -21,7 +21,7 @@ * * @author Jason van Zyl * - * @version $Id: LoadOnStartService.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public interface LoadOnStartService { diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/LoadOnStartServiceWithRoleHint.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/LoadOnStartServiceWithRoleHint.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/LoadOnStartServiceWithRoleHint.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/LoadOnStartServiceWithRoleHint.java 2016-08-31 19:01:49.000000000 +0000 @@ -21,7 +21,7 @@ * * @author Jason van Zyl * - * @version $Id: LoadOnStartServiceWithRoleHint.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public interface LoadOnStartServiceWithRoleHint { diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/map/AbstractActivity.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/map/AbstractActivity.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/map/AbstractActivity.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/map/AbstractActivity.java 2016-08-31 19:01:49.000000000 +0000 @@ -21,7 +21,7 @@ * * @author Jason van Zyl * - * @version $Id: AbstractActivity.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public abstract class AbstractActivity implements Activity diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/map/Activity.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/map/Activity.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/map/Activity.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/map/Activity.java 2016-08-31 19:01:49.000000000 +0000 @@ -21,7 +21,7 @@ * * @author Jason van Zyl * - * @version $Id: Activity.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public interface Activity { diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/map/ActivityManager.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/map/ActivityManager.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/map/ActivityManager.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/map/ActivityManager.java 2016-08-31 19:01:49.000000000 +0000 @@ -21,7 +21,7 @@ * * @author Jason van Zyl * - * @version $Id: ActivityManager.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public interface ActivityManager { diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/map/ActivityOne.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/map/ActivityOne.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/map/ActivityOne.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/map/ActivityOne.java 2016-08-31 19:01:49.000000000 +0000 @@ -21,7 +21,7 @@ * * @author Jason van Zyl * - * @version $Id: ActivityOne.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public class ActivityOne extends AbstractActivity diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/map/ActivityTwo.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/map/ActivityTwo.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/map/ActivityTwo.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/map/ActivityTwo.java 2016-08-31 19:01:49.000000000 +0000 @@ -21,7 +21,7 @@ * * @author Jason van Zyl * - * @version $Id: ActivityTwo.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public class ActivityTwo extends AbstractActivity diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/map/DefaultActivityManager.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/map/DefaultActivityManager.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/map/DefaultActivityManager.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/map/DefaultActivityManager.java 2016-08-31 19:01:49.000000000 +0000 @@ -23,7 +23,7 @@ * * @author Jason van Zyl * - * @version $Id: DefaultActivityManager.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public class DefaultActivityManager implements ActivityManager diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/map/NoComponentsMapTest.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/map/NoComponentsMapTest.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/map/NoComponentsMapTest.java 2008-11-14 22:07:56.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/map/NoComponentsMapTest.java 2016-08-31 19:01:49.000000000 +0000 @@ -20,7 +20,7 @@ /** * @author Trygve Laugstøl - * @version $Id: NoComponentsMapTest.java 7828 2008-11-14 22:07:56Z dain $ + * @version $Id$ */ public class NoComponentsMapTest extends PlexusTestCase diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/PlexusContainerTest.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/PlexusContainerTest.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/PlexusContainerTest.java 2009-01-21 01:34:55.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/PlexusContainerTest.java 2016-08-31 19:01:49.000000000 +0000 @@ -16,10 +16,23 @@ * limitations under the License. */ +import java.io.File; +import java.net.URL; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.CopyOnWriteArrayList; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.atomic.AtomicBoolean; + import junit.framework.TestCase; + import org.codehaus.plexus.ContainerConfiguration; import org.codehaus.plexus.DefaultContainerConfiguration; import org.codehaus.plexus.DefaultPlexusContainer; +import org.codehaus.plexus.classworlds.realm.ClassRealm; import org.codehaus.plexus.component.discovery.DiscoveredComponent; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.lifecycle.BasicLifecycleHandler; @@ -37,11 +50,6 @@ import org.codehaus.plexus.test.map.Activity; import org.codehaus.plexus.test.map.ActivityManager; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - public class PlexusContainerTest extends TestCase { @@ -351,6 +359,9 @@ assertNotNull( one ); + // repeated retrieval from map should not cause re-lookup even if instantiation strategy is per-lookup + assertSame( one, am.getActivity( "one" ) ); + assertFalse( one.getState() ); am.execute( "one" ); @@ -393,6 +404,11 @@ List valves = pipeline.getValves(); + for (Object valve : valves) { + // repeated retrieval from list should not cause re-lookup even if instantiation strategy is per-lookup + assertSame(valve, valve); + } + assertFalse( ( (Valve) valves.get( 0 ) ).getState() ); assertFalse( ( (Valve) valves.get( 1 ) ).getState() ); @@ -489,4 +505,362 @@ // todo actually test nested exception is as expected when } } + + public void testAddComponent() + throws Exception + { + LiveComponent live = new LiveComponent(); + + container.addComponent( live, LiveComponent.class.getName() ); + + LiveComponent c = container.lookup( LiveComponent.class ); + + assertSame( live, c ); + } + + public void testComponentOverride() + throws Exception + { + assertNotNull( container.lookup( Component.class ) ); + + Component live = new Component() + { + public Activity getActivity() + { + return null; + } + public String getHost() + { + return null; + } + public int getPort() + { + return 0; + } + }; + + container.addComponent( live, Component.class, null ); + + assertSame( live, container.lookup( Component.class ) ); + } + + public void testUpdateOfActiveComponentCollectionUponChangeOfThreadContextClassLoader() + throws Exception + { + ComponentManager manager = container.lookup( ComponentManager.class ); + + Map map = manager.getMap(); + assertNotNull( map ); + assertEquals( 0, map.size() ); + + List list = manager.getList(); + assertNotNull( list ); + assertEquals( 0, list.size() ); + + /* + * Below we're creating two realms which basically contain the same components, only their bytecode/version + * differs. When we switch the thread's context class loader, the active component collections in the component + * manager must accurately reflect the components from the current realm (and not from a previous realm). + */ + + ClassRealm realmA = container.createChildRealm( "realm-a" ); + realmA.addURL( new File( "src/test/test-components/component-a-1.0-SNAPSHOT.jar" ).toURI().toURL() ); + container.discoverComponents( realmA ); + + ClassRealm realmB = container.createChildRealm( "realm-b" ); + realmB.addURL( new File( "src/test/test-components/component-a-2.0-SNAPSHOT.jar" ).toURI().toURL() ); + container.discoverComponents( realmB ); + + ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader(); + + try + { + Thread.currentThread().setContextClassLoader( realmA ); + + map = manager.getMap(); + assertNotNull( map ); + assertEquals( 1, map.size() ); + assertSame( realmA, map.values().iterator().next().getClass().getClassLoader() ); + + list = manager.getList(); + assertNotNull( list ); + assertEquals( 1, list.size() ); + assertSame( realmA, list.iterator().next().getClass().getClassLoader() ); + + Thread.currentThread().setContextClassLoader( realmB ); + + map = manager.getMap(); + assertNotNull( map ); + assertEquals( 1, map.size() ); + assertSame( realmB, map.values().iterator().next().getClass().getClassLoader() ); + + list = manager.getList(); + assertNotNull( list ); + assertEquals( 1, list.size() ); + assertSame( realmB, list.iterator().next().getClass().getClassLoader() ); + } + finally + { + Thread.currentThread().setContextClassLoader( oldClassLoader ); + } + } + + public void testUpdateOfActiveComponentCollectionUponChangeOfThreadContextClassLoaderFromParentToChildRealm() + throws Exception + { + ComponentManager manager = container.lookup( ComponentManager.class ); + + Map map = manager.getMap(); + assertNotNull( map ); + assertEquals( 0, map.size() ); + + List list = manager.getList(); + assertNotNull( list ); + assertEquals( 0, list.size() ); + + /* + * Below we're creating two realms which basically contain the same components, only their bytecode/version + * differs. The realms form a parent-child relationship where the child imports the component role from the + * parent. When we first load from the parent and then switch the thread's context class loader to the child, + * the active component collections in the component manager must accurately reflect the components from the + * current realm (and not from a previous realm). + */ + + ClassRealm realmA = container.createChildRealm( "realm-a" ); + realmA.addURL( new File( "src/test/test-components/component-a-1.0-SNAPSHOT.jar" ).toURI().toURL() ); + container.discoverComponents( realmA ); + + ClassRealm realmB = realmA.createChildRealm( "realm-b" ); + realmB.importFrom( realmA, "org.codehaus.plexus.components.A" ); + realmB.importFromParent( "nothing" ); + realmB.addURL( new File( "src/test/test-components/component-a-2.0-SNAPSHOT.jar" ).toURI().toURL() ); + container.discoverComponents( realmB ); + + ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader(); + + try + { + Thread.currentThread().setContextClassLoader( realmA ); + + map = manager.getMap(); + assertNotNull( map ); + assertEquals( 1, map.size() ); + assertSame( realmA, map.values().iterator().next().getClass().getClassLoader() ); + + list = manager.getList(); + assertNotNull( list ); + assertEquals( 1, list.size() ); + assertSame( realmA, list.iterator().next().getClass().getClassLoader() ); + + Thread.currentThread().setContextClassLoader( realmB ); + + map = manager.getMap(); + assertNotNull( map ); + assertEquals( 1, map.size() ); + assertSame( realmB, map.values().iterator().next().getClass().getClassLoader() ); + + list = manager.getList(); + assertNotNull( list ); + assertEquals( 1, list.size() ); + assertSame( realmB, list.iterator().next().getClass().getClassLoader() ); + } + finally + { + Thread.currentThread().setContextClassLoader( oldClassLoader ); + } + } + + public void testComponentLookupFromParentRealmOfImportedRealms() + throws Exception + { + ComponentManager manager = container.lookup( ComponentManager.class ); + + Map map = manager.getMap(); + assertNotNull( map ); + assertEquals( 0, map.size() ); + + List list = manager.getList(); + assertNotNull( list ); + assertEquals( 0, list.size() ); + + URL componentUrl = new File( "src/test/test-components/component-a-1.0-SNAPSHOT.jar" ).toURI().toURL(); + + ClassRealm realmP = container.createChildRealm( "parent-of-imported-realm" ); + realmP.addURL( componentUrl ); + container.discoverComponents( realmP ); + + ClassRealm realmI = realmP.createChildRealm( "imported-realm" ); + + ClassRealm realmL = container.createChildRealm( "lookup-realm" ); + realmL.importFrom( realmI, "org.something" ); + + ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader(); + + try + { + Thread.currentThread().setContextClassLoader( realmL ); + + map = manager.getMap(); + assertNotNull( map ); + assertEquals( 1, map.size() ); + assertSame( realmP, map.values().iterator().next().getClass().getClassLoader() ); + + list = manager.getList(); + assertNotNull( list ); + assertEquals( 1, list.size() ); + assertSame( realmP, list.iterator().next().getClass().getClassLoader() ); + } + finally + { + Thread.currentThread().setContextClassLoader( oldClassLoader ); + } + } + + public void testOptionalComponentRequirement() + throws Exception + { + DefaultComponentWithOptionalRequirement ca = + (DefaultComponentWithOptionalRequirement) container.lookup( Component.class, "with-optional" ); + + assertNotNull( ca ); + + assertNotNull( ca.getActivity() ); + + assertNull( ca.optionalComponent ); + } + + public void testLookupOfComponentThatHasARequirementWithoutRoleHintAndTheOneAndOnlyImplHasNoDefaultHint() + throws Exception + { + DefaultThingUser component = (DefaultThingUser) container.lookup( ThingUser.class ); + + assertNotNull( component.thing ); + } + + public void testSingleLookupWithAndWithoutRoleHint() + throws Exception + { + ComponentWithRoleDefault withRoleHint = container.lookup( ComponentWithRoleDefault.class, "default" ); + + ComponentWithRoleDefault withoutRoleHint = container.lookup( ComponentWithRoleDefault.class ); + + assertSame( withRoleHint, withoutRoleHint ); + } + + public void testLookupUponChangeOfThreadContextClassLoaderFromParentToChildRealm() + throws Exception + { + /* + * Below we're creating two realms which basically contain the same components, only their bytecode/version + * differs. The realms form a parent-child relationship where the child imports the component role from the + * parent. When we first lookup from the parent and then switch the thread's context class loader to the child, + * the second lookup must accurately reflect the components from the current realm (and not from a previous + * realm). + */ + + ClassRealm realmA = container.createChildRealm( "realm-a" ); + realmA.addURL( new File( "src/test/test-components/component-a-1.0-SNAPSHOT.jar" ).toURI().toURL() ); + container.discoverComponents( realmA ); + + ClassRealm realmB = realmA.createChildRealm( "realm-b" ); + realmB.importFrom( realmA, "org.codehaus.plexus.components.A" ); + realmB.importFromParent( "nothing" ); + realmB.addURL( new File( "src/test/test-components/component-a-2.0-SNAPSHOT.jar" ).toURI().toURL() ); + container.discoverComponents( realmB ); + + Class role = realmA.loadClass( "org.codehaus.plexus.components.A" ); + + ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader(); + + try + { + Thread.currentThread().setContextClassLoader( realmA ); + + Object comp1 = container.lookup( role, "default" ); + + Thread.currentThread().setContextClassLoader( realmB ); + + Object comp2 = container.lookup( role, "default" ); + + assertNotNull( comp1 ); + assertNotNull( comp2 ); + assertNotSame( comp1, comp2 ); + assertSame( realmA, comp1.getClass().getClassLoader() ); + assertSame( realmB, comp2.getClass().getClassLoader() ); + } + finally + { + Thread.currentThread().setContextClassLoader( oldClassLoader ); + } + } + + public void testSafeConcurrentAccessToActiveComponentCollection() + throws Exception + { + ComponentManager manager = container.lookup( ComponentManager.class ); + + final Map map = manager.getMap(); + assertNotNull( map ); + assertEquals( 0, map.size() ); + + final List list = manager.getList(); + assertNotNull( list ); + assertEquals( 0, list.size() ); + + final AtomicBoolean go = new AtomicBoolean( false ); + + final List exceptions = new CopyOnWriteArrayList(); + Thread[] threads = new Thread[64]; + final CountDownLatch latch = new CountDownLatch( threads.length ); + for ( int i = 0; i < threads.length; i++ ) + { + threads[i] = new Thread() + { + @Override + public void run() + { + try + { + ClassRealm realm = container.createChildRealm( "realm-" + UUID.randomUUID().toString() ); + realm.addURL( new File( "src/test/test-components/component-a-1.0-SNAPSHOT.jar" ).toURI().toURL() ); + container.discoverComponents( realm ); + Thread.currentThread().setContextClassLoader( realm ); + + while ( !go.get() ) + { + // just wait + } + + for ( int j = 0; j < 1000; j++ ) + { + // this just must not die with some exception + for ( Object value : map.values() ) + { + value.toString(); + } + for ( Object value : list ) + { + value.toString(); + } + } + } + catch ( Exception e ) + { + e.printStackTrace(); + exceptions.add( e ); + } + finally + { + latch.countDown(); + } + } + }; + threads[i].start(); + } + go.set( true ); + latch.await(); + + assertTrue( exceptions.toString(), exceptions.isEmpty() ); + } + } diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/SimpleLifecycleHandler.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/SimpleLifecycleHandler.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/SimpleLifecycleHandler.java 2007-11-25 15:19:06.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/SimpleLifecycleHandler.java 2016-08-31 19:01:49.000000000 +0000 @@ -23,7 +23,7 @@ * * @author Jason van Zyl * - * @version $Id: SimpleLifecycleHandler.java 7089 2007-11-25 15:19:06Z jvanzyl $ + * @version $Id$ */ public class SimpleLifecycleHandler extends AbstractLifecycleHandler diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/Thing.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/Thing.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/Thing.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/Thing.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,22 @@ +package org.codehaus.plexus.test; + +/* + * Copyright 2001-2006 Codehaus Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +public interface Thing +{ + +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/ThingUser.java plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/ThingUser.java --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/java/org/codehaus/plexus/test/ThingUser.java 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/java/org/codehaus/plexus/test/ThingUser.java 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,22 @@ +package org.codehaus.plexus.test; + +/* + * Copyright 2001-2006 Codehaus Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +public interface ThingUser +{ + +} diff -Nru plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/resources/org/codehaus/plexus/test/PlexusContainerTest.xml plexus-containers-1.7.1/plexus-container-default/src/test/resources/org/codehaus/plexus/test/PlexusContainerTest.xml --- plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/resources/org/codehaus/plexus/test/PlexusContainerTest.xml 2009-04-26 01:25:48.000000000 +0000 +++ plexus-containers-1.7.1/plexus-container-default/src/test/resources/org/codehaus/plexus/test/PlexusContainerTest.xml 2016-08-31 19:01:49.000000000 +0000 @@ -99,6 +99,24 @@ + org.codehaus.plexus.test.Component + org.codehaus.plexus.test.DefaultComponentWithOptionalRequirement + with-optional + + + org.codehaus.plexus.test.map.Activity + one + activity + + + org.codehaus.plexus.test.NonAvailableComponent + missing + optionalComponent + true + + + + org.codehaus.plexus.test.ComponentA org.codehaus.plexus.test.DefaultComponentA @@ -164,6 +182,7 @@ org.codehaus.plexus.test.map.Activity one org.codehaus.plexus.test.map.ActivityOne + per-lookup org.codehaus.plexus.test.map.Activity @@ -235,6 +254,22 @@ org.codehaus.plexus.test.list.Valve one org.codehaus.plexus.test.list.ValveOne + per-lookup + + + + org.codehaus.plexus.test.ComponentManager + org.codehaus.plexus.test.DefaultComponentManager + + + org.codehaus.plexus.components.A + list + + + org.codehaus.plexus.components.A + map + + @@ -400,5 +435,30 @@ + + org.codehaus.plexus.test.Thing + + concrete + org.codehaus.plexus.test.ConcreteThing + + + + org.codehaus.plexus.test.ThingUser + org.codehaus.plexus.test.DefaultThingUser + + + org.codehaus.plexus.test.Thing + + thing + + + + + + org.codehaus.plexus.test.ComponentWithRoleDefault + org.codehaus.plexus.test.ComponentWithRoleDefault + default + + Binary files /tmp/tmpCQ30J4/0hhtPon8ce/plexus-containers-1.0~beta3.0.7/plexus-container-default/src/test/test-components/component-a-2.0-SNAPSHOT.jar and /tmp/tmpCQ30J4/t71HpXo8x0/plexus-containers-1.7.1/plexus-container-default/src/test/test-components/component-a-2.0-SNAPSHOT.jar differ diff -Nru plexus-containers-1.0~beta3.0.7/pom.xml plexus-containers-1.7.1/pom.xml --- plexus-containers-1.0~beta3.0.7/pom.xml 2009-05-13 15:28:46.000000000 +0000 +++ plexus-containers-1.7.1/pom.xml 2016-08-31 19:01:49.000000000 +0000 @@ -1,39 +1,55 @@ - + 4.0.0 + org.codehaus.plexus plexus - 2.0.2 + 4.0 + plexus-containers - 1.0-beta-3.0.7 - - 1.4 - 1.4.5 - 3.4 - UTF-8 - + 1.7.1 pom - Parent :: Plexus Containers + + Plexus Containers + + Plexus IoC Container core with companion tools. + + plexus-component-annotations plexus-component-metadata plexus-component-javadoc plexus-container-default + - scm:svn:http://svn.codehaus.org/plexus/plexus-containers/tags/plexus-containers-1.0-beta-3.0.7 - scm:svn:https://svn.codehaus.org/plexus/plexus-containers/tags/plexus-containers-1.0-beta-3.0.7 - http://fisheye.codehaus.org/browse/plexus/plexus-containers/tags/plexus-containers-1.0-beta-3.0.7 + scm:git:https://github.com/codehaus-plexus/plexus-containers.git + scm:git:https://github.com/codehaus-plexus/plexus-containers.git + https://github.com/codehaus-plexus/plexus-containers/tree/plexus-containers-1.x + plexus-containers-1.7.1 - - - junit - junit - 3.8.2 - - + + github + http://github.com/codehaus-plexus/plexus-containers/issues + + + + github:gh-pages + ${scm.url} + + + + + scm:git:git@github.com:codehaus-plexus/plexus-containers.git + 2.5.1 + 3.0.20 + 3.7 + UTF-8 + 6 + + @@ -69,12 +85,12 @@ com.thoughtworks.qdox qdox - 1.6.3 + 2.0-M2 - jdom - jdom - 1.0 + org.jdom + jdom2 + 2.0.6 org.apache.maven @@ -92,20 +108,38 @@ 2.0.9 - com.google.code.google-collections - google-collect - snapshot-20080530 + com.google.collections + google-collections + 1.0 + + + junit + junit + 4.11 + provided + + + + + org.apache.maven.plugins + maven-release-plugin + 2.5.3 + + true + + + + - maven-compiler-plugin + org.apache.maven.plugins + maven-site-plugin - 1.5 - 1.5 - ${project.build.sourceEncoding} + ${scm.url} diff -Nru plexus-containers-1.0~beta3.0.7/src/site/apt/history.apt plexus-containers-1.7.1/src/site/apt/history.apt --- plexus-containers-1.0~beta3.0.7/src/site/apt/history.apt 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/src/site/apt/history.apt 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,45 @@ + ----- + Plexus Containers Structure History + ----- + Hervé Boutemy + ----- + 2009-10-03 + ----- + + +Plexus Containers Structure History + + Plexus Containers structure has evolved over time. This document tracks most notable changes around its main module - {{{./plexus-container-default}plexus-container-default}}. + +*----------------+--------------+------------------------+ +| <> | <> | <> | +*----------------+--------------+------------------------+ +| 1.0-alpha-1 | 2005-01-18 | <<>> is child of <<>> but not a module | +*----------------+--------------+------------------------+ +| 1.0-alpha-2 | 2005-04-02 | <<>> has <<>> and <<>> modules +*----------------+--------------+------------------------+ +| 1.0-alpha-4 | 2005-06-22 | <<>> +*----------------+--------------+------------------------+ +| 1.0-alpha-6 | 2005-06-22 | <<>> +*----------------+--------------+------------------------+ +| 1.0-alpha-7 | 2005-10-03 | <<>> (groupId changed) +*----------------+--------------+------------------------+ +| <<1.0-alpha-9>> \ +| (used in Maven 2.x) | 2005-12-07 | <<>> (groupId changed) +*----------------+--------------+------------------------+ +| 1.0-alpha-10 | 2006-10-01 | <<>>, <<>> as single module +*----------------+--------------+------------------------+ +| 1.0-alpha-11 | 2006-11-23 | <<>> with a new <<>> module +*----------------+--------------+------------------------+ +| 1.0-alpha-14 | 2006-12-13 | <<>> has now the same version as its <<>> and <<>> modules +*----------------+--------------+------------------------+ +| 1.0-alpha-33 | 2007-10-16 | addition of <<<{{{./plexus-component-annotations}plexus-component-annotations}}>>> +*----------------+--------------+------------------------+ +| 1.0-alpha-34 | 2007-10-23 | removal of <<>>, which has been merged into <<>> +*----------------+--------------+------------------------+ +| 1.0-beta-1 | 2008-09-30 | addition of <<<{{{./plexus-component-metadata}plexus-component-metadata}}>>>, which supersedes {{{/plexus-tools/plexus-cdc/}Plexus Component Descriptor Creator}} and {{{/plexus-maven-plugin}Plexus Maven Plugin}} +*----------------+--------------+------------------------+ +| 1.0-beta-3.0.1 | 2008-12-01 | addition of <<<{{{./plexus-component-javadoc}plexus-component-javadoc}}>>>, which was previously known as <<<{{{/plexus-tools/plexus-javadoc/}plexus-javadoc}}>>> in <<<{{{/plexus-tools/}plexus-tools}}>>> +*----------------+--------------+------------------------+ +| 1.0.0 | 2009-06-19 | no structure change, but the long expected 1.0.0 release... +*----------------+--------------+------------------------+ diff -Nru plexus-containers-1.0~beta3.0.7/src/site/apt/index.apt plexus-containers-1.7.1/src/site/apt/index.apt --- plexus-containers-1.0~beta3.0.7/src/site/apt/index.apt 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/src/site/apt/index.apt 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,25 @@ + ----- + plexus-containers + ----- + Hervé Boutemy + ----- + 2009-10-06 + ----- + +Overview + + <<>> is Plexus' (IoC) container and companion tools: + + * {{{./plexus-container-default}plexus-container-default}} is the IoC container itself, + + * {{{./plexus-component-metadata}plexus-component-metadata}} is a Maven plugin to generate plexus <<<{{{./plexus-container-default/plexus-components.html}component.xml}}>>> from + source annotations, + + * {{{./plexus-component-annotations}plexus-component-annotations}} provides the Java 5 annotations for plexus components, + + * {{{./plexus-component-javadoc}plexus-component-javadoc}} provides javadoc taglets to add plexus documentation to javadoc. + + [] + + + <<>>' structure has evolved over time: see {{{./history.html}history}} to understand its changes. \ No newline at end of file diff -Nru plexus-containers-1.0~beta3.0.7/src/site/site.xml plexus-containers-1.7.1/src/site/site.xml --- plexus-containers-1.0~beta3.0.7/src/site/site.xml 2008-04-11 18:12:21.000000000 +0000 +++ plexus-containers-1.7.1/src/site/site.xml 2016-08-31 19:01:49.000000000 +0000 @@ -1,22 +1,9 @@ - - - Plexus - http://plexus.codehaus.org/ - /images/plexus-logo.png - - - - - org.codehaus.plexus - plexus-stylus-skin - 1.0-SNAPSHOT - + + + - - - - - diff -Nru plexus-containers-1.0~beta3.0.7/.travis.yml plexus-containers-1.7.1/.travis.yml --- plexus-containers-1.0~beta3.0.7/.travis.yml 1970-01-01 00:00:00.000000000 +0000 +++ plexus-containers-1.7.1/.travis.yml 2016-08-31 19:01:49.000000000 +0000 @@ -0,0 +1,22 @@ +language: java +jdk: + - oraclejdk6 + - oraclejdk7 + - oraclejdk8 + +# No need for preliminary install step. +install: true +# +# Run all integration tests. +script: + - "mvn --show-version --errors --batch-mode clean verify" +# +cache: + directories: + - $HOME/.m2 +branches: + except: + - gh-pages +notifications: + email: + - olamy@apache.org