diff --git a/.gitignore b/.gitignore
index 9139e008a..4302b9a91 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,7 +1,7 @@
-**/target/**
-*.class
-target
-*.releaseBackup
-release.properties
-/nbactions.xml
+**/target/**
+*.class
+target
+*.releaseBackup
+release.properties
+/nbactions.xml
/bridje-cfg/nbproject/
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
index 0982eea7e..b1c1e8e4f 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,5 +1,5 @@
-language: java
-jdk:
- - oraclejdk8
-
-script: mvn -Dgpg.skip=true test
+language: java
+jdk:
+ - oraclejdk8
+
+script: mvn -Dgpg.skip=true test
diff --git a/LICENSE b/LICENSE
index 8f71f43fe..113e84387 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,202 +1,202 @@
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "{}"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright {yyyy} {name of copyright owner}
-
- 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.
-
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "{}"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright {yyyy} {name of copyright owner}
+
+ 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.
+
diff --git a/README.md b/README.md
index bcd84b928..318bb2b8a 100644
--- a/README.md
+++ b/README.md
@@ -1,44 +1,44 @@
-[](https://travis-ci.org/bridje/bridje-framework)
-
-Introduction
-============
-
-This package contains the Bridje Java Applications Framework. A project providing Java API for building Fast, Roboust Java Aplications with Maven.
-The project is licensed under the Apache License:
-
- 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.
-
-Dependencies
-============
-
-The project libraries can be use without dependencies.
-
-Installation and Usage
-======================
-
-Bridje Core library is availables on the Maven Central Repository
-
-
- * Configuration classes must be serializable in xml format. - */ -public interface ConfigService -{ - /** - * Obtains a configuration by its class. - *
- * @param
- * @param
- * @param
- * @param
+ * Configuration classes must be serializable in xml format.
+ */
+public interface ConfigService
+{
+ /**
+ * Obtains a configuration by its class.
+ *
+ * @param
+ * @param
+ * @param
+ * @param
- * @param The annotation that classes must have in orther to be accept by
- * the navigator.
- */
-@FunctionalInterface
-public interface ClassNavigator
-{
- /**
- * This method is call when ever a class if found to have the given
- * annotation.
- *
- * @param component The class of the component found.
- * @param annotation The instance of the annotation of the component.
- */
- void accept(Class component, A annotation);
-}
+/*
+ * Copyright 2015 Bridje Framework.
+ *
+ * Alejandro Ferrandiz (acksecurity[at]hotmail.com)
+ *
+ * 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.bridje.ioc;
+
+import java.lang.annotation.Annotation;
+
+/**
+ * Functional interface used by {@link ClassRepository} for navigating annotated
+ * classes in the inversion of control context.
+ *
+ * @param The annotation that classes must have in orther to be accept by
+ * the navigator.
+ */
+@FunctionalInterface
+public interface ClassNavigator
+{
+ /**
+ * This method is call when ever a class if found to have the given
+ * annotation.
+ *
+ * @param component The class of the component found.
+ * @param annotation The instance of the annotation of the component.
+ */
+ void accept(Class component, A annotation);
+}
diff --git a/bridje-ioc/src/main/java/org/bridje/ioc/ClassRepository.java b/bridje-ioc/src/main/java/org/bridje/ioc/ClassRepository.java
index ae78ab231..6fa202867 100644
--- a/bridje-ioc/src/main/java/org/bridje/ioc/ClassRepository.java
+++ b/bridje-ioc/src/main/java/org/bridje/ioc/ClassRepository.java
@@ -1,69 +1,69 @@
-/*
- * Copyright 2015 Bridje Framework.
- *
- * 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.bridje.ioc;
-
-import java.lang.annotation.Annotation;
-
-/**
- * Represents the collection of classes being used by {@link IocContext} to create
- * and manage components.
- */
-public interface ClassRepository
-{
- /**
- * Navigates through all methods of all component classes registred in this
- * repository, that are annotated with the given annotation. This includes
- * superclasses methods.
- *
- * @param The type of the annotation methods must be annotated
- * with.
- * @param annotation The class of the annotation methods must be annotated
- * with.
- * @param navigator Callback functional interface that handles the
- * annotated method.
- */
- public void navigateAnnotMethods(Class annotation, MethodNavigator navigator);
-
- /**
- * Navigates through all fields of all component classes registred in this
- * repository, that are annotated with the given annotation. This includes
- * superclasses fields.
- *
- * @param The type of the annotation fields must be annotated
- * with.
- * @param annotation The class of the annotation fields must be annotated
- * with.
- * @param navigator Callback functional interface that handles the
- * annotated field.
- */
- public void navigateAnnotFileds(Class annotation, FieldNavigator navigator);
-
- /**
- * Navigates through all component classes registred in this repository,
- * that are annotated with the given annotation. This includes superclasses
- * fields.
- *
- * @param The type of the annotation classes must be annotated
- * with.
- * @param annotation The class of the annotation classes must be annotated
- * with.
- * @param navigator Callback functional interface that handles the
- * annotated class.
- */
- public void navigateAnnotClasses(Class annotation, ClassNavigator navigator);
-}
+/*
+ * Copyright 2015 Bridje Framework.
+ *
+ * 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.bridje.ioc;
+
+import java.lang.annotation.Annotation;
+
+/**
+ * Represents the collection of classes being used by {@link IocContext} to create
+ * and manage components.
+ */
+public interface ClassRepository
+{
+ /**
+ * Navigates through all methods of all component classes registred in this
+ * repository, that are annotated with the given annotation. This includes
+ * superclasses methods.
+ *
+ * @param The type of the annotation methods must be annotated
+ * with.
+ * @param annotation The class of the annotation methods must be annotated
+ * with.
+ * @param navigator Callback functional interface that handles the
+ * annotated method.
+ */
+ public void navigateAnnotMethods(Class annotation, MethodNavigator navigator);
+
+ /**
+ * Navigates through all fields of all component classes registred in this
+ * repository, that are annotated with the given annotation. This includes
+ * superclasses fields.
+ *
+ * @param The type of the annotation fields must be annotated
+ * with.
+ * @param annotation The class of the annotation fields must be annotated
+ * with.
+ * @param navigator Callback functional interface that handles the
+ * annotated field.
+ */
+ public void navigateAnnotFileds(Class annotation, FieldNavigator navigator);
+
+ /**
+ * Navigates through all component classes registred in this repository,
+ * that are annotated with the given annotation. This includes superclasses
+ * fields.
+ *
+ * @param The type of the annotation classes must be annotated
+ * with.
+ * @param annotation The class of the annotation classes must be annotated
+ * with.
+ * @param navigator Callback functional interface that handles the
+ * annotated class.
+ */
+ public void navigateAnnotClasses(Class annotation, ClassNavigator navigator);
+}
diff --git a/bridje-ioc/src/main/java/org/bridje/ioc/Component.java b/bridje-ioc/src/main/java/org/bridje/ioc/Component.java
index 7518ed55e..43b1982d1 100644
--- a/bridje-ioc/src/main/java/org/bridje/ioc/Component.java
+++ b/bridje-ioc/src/main/java/org/bridje/ioc/Component.java
@@ -1,49 +1,49 @@
-/*
- * Copyright 2015 Bridje Framework.
- *
- * 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.bridje.ioc;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Mark a class as a component so it can be managed by the API.
- *
- * This annotation mark any class as an IoC component. if scope of the component
- * is no specified it will be an application scoped component.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.TYPE)
-public @interface Component
-{
- /**
- * Defines the scope of component.
- *
- * @return String that represents the scope of the component.
- */
- String scope() default "APPLICATION";
-
- /**
- * If the component must be instantiate eager or lazy
- *
- * @return true the component will be instantiated eager, the default is
- * false witch means that the component will be instantiated lazy
- * the first time some one request it.
- */
- boolean instantiate() default false;
-}
+/*
+ * Copyright 2015 Bridje Framework.
+ *
+ * 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.bridje.ioc;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Mark a class as a component so it can be managed by the API.
+ *
+ * This annotation mark any class as an IoC component. if scope of the component
+ * is no specified it will be an application scoped component.
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)
+public @interface Component
+{
+ /**
+ * Defines the scope of component.
+ *
+ * @return String that represents the scope of the component.
+ */
+ String scope() default "APPLICATION";
+
+ /**
+ * If the component must be instantiate eager or lazy
+ *
+ * @return true the component will be instantiated eager, the default is
+ * false witch means that the component will be instantiated lazy
+ * the first time some one request it.
+ */
+ boolean instantiate() default false;
+}
diff --git a/bridje-ioc/src/main/java/org/bridje/ioc/ContextListener.java b/bridje-ioc/src/main/java/org/bridje/ioc/ContextListener.java
index 58d9c90a4..a8f70a61a 100644
--- a/bridje-ioc/src/main/java/org/bridje/ioc/ContextListener.java
+++ b/bridje-ioc/src/main/java/org/bridje/ioc/ContextListener.java
@@ -1,103 +1,103 @@
-/*
- * Copyright 2015 Bridje Framework.
- *
- * Alejandro Ferrandiz (acksecurity[at]hotmail.com)
- *
- * 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.bridje.ioc;
-
-/**
- * A listener for the {@link IocContext}. This interfaz is mean to be
- * implemented in order for the container to call his methods upon the events
- * that take place on the {@link IocContext}
- *
- * The context listener will be any component that implements the interface
- * ContextListener, the framework must search all ContextListener
- * implementations via the standard way of components resolution and call the 3
- * methods of the interface in the propper place.
- *
- * @param
+ * The context listener will be any component that implements the interface
+ * ContextListener, the framework must search all ContextListener
+ * implementations via the standard way of components resolution and call the 3
+ * methods of the interface in the propper place.
+ *
+ * @param
- * @param The annotation that the fields must have in orther to be accept by
- * the navigator.
- */
-@FunctionalInterface
-public interface FieldNavigator
-{
- /**
- * This method is call when ever a field in a component if found to have the
- * given annotation.
- *
- * @param field The field been found.
- * @param component The class of the component that contains the found
- * field.
- * @param annotation The instance of the annotation of the field.
- */
- void accept(Field field, Class component, A annotation);
-}
+/*
+ * Copyright 2015 Bridje Framework.
+ *
+ * Alejandro Ferrandiz (acksecurity[at]hotmail.com)
+ *
+ * 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.bridje.ioc;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+
+/**
+ * Functional interface used by {@link ClassRepository} for navigating annotated
+ * fields in the inversion of control context.
+ *
+ * @param The annotation that the fields must have in orther to be accept by
+ * the navigator.
+ */
+@FunctionalInterface
+public interface FieldNavigator
+{
+ /**
+ * This method is call when ever a field in a component if found to have the
+ * given annotation.
+ *
+ * @param field The field been found.
+ * @param component The class of the component that contains the found
+ * field.
+ * @param annotation The instance of the annotation of the field.
+ */
+ void accept(Field field, Class component, A annotation);
+}
diff --git a/bridje-ioc/src/main/java/org/bridje/ioc/Inject.java b/bridje-ioc/src/main/java/org/bridje/ioc/Inject.java
index 1d51e4839..e9ced2b6f 100644
--- a/bridje-ioc/src/main/java/org/bridje/ioc/Inject.java
+++ b/bridje-ioc/src/main/java/org/bridje/ioc/Inject.java
@@ -1,34 +1,34 @@
-/*
- * Copyright 2015 Bridje Framework.
- *
- * 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.bridje.ioc;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * This annotation specify that the field on witch is declared is a component
- * dependency, the container will find (any/all) component that provides the
- * service and inject the instance of it in this field. Cannot be use in static
- * fields, but it may be use in parent classes of components.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.FIELD)
-public @interface Inject
-{
-}
+/*
+ * Copyright 2015 Bridje Framework.
+ *
+ * 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.bridje.ioc;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * This annotation specify that the field on witch is declared is a component
+ * dependency, the container will find (any/all) component that provides the
+ * service and inject the instance of it in this field. Cannot be use in static
+ * fields, but it may be use in parent classes of components.
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.FIELD)
+public @interface Inject
+{
+}
diff --git a/bridje-ioc/src/main/java/org/bridje/ioc/InjectNext.java b/bridje-ioc/src/main/java/org/bridje/ioc/InjectNext.java
index 95e1a5cfe..55c625648 100644
--- a/bridje-ioc/src/main/java/org/bridje/ioc/InjectNext.java
+++ b/bridje-ioc/src/main/java/org/bridje/ioc/InjectNext.java
@@ -1,33 +1,33 @@
-/*
- * Copyright 2015 Bridje Framework.
- *
- * 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.bridje.ioc;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * This annotation specify behaves in the same way as the {@link Inject} annotation
- * except that it will look only for components that has a priority value bigger thant
- * the current component.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.FIELD)
-public @interface InjectNext
-{
-}
+/*
+ * Copyright 2015 Bridje Framework.
+ *
+ * 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.bridje.ioc;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * This annotation specify behaves in the same way as the {@link Inject} annotation
+ * except that it will look only for components that has a priority value bigger thant
+ * the current component.
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.FIELD)
+public @interface InjectNext
+{
+}
diff --git a/bridje-ioc/src/main/java/org/bridje/ioc/Ioc.java b/bridje-ioc/src/main/java/org/bridje/ioc/Ioc.java
index 289f87459..a49ee7ef0 100644
--- a/bridje-ioc/src/main/java/org/bridje/ioc/Ioc.java
+++ b/bridje-ioc/src/main/java/org/bridje/ioc/Ioc.java
@@ -1,47 +1,47 @@
-/*
- * Copyright 2015 Bridje Framework.
- *
- * 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.bridje.ioc;
-
-import org.bridje.ioc.impl.ContextFactory;
-
-/**
- * Facade for the Bridje IoC API.
- *
- * This class provides the method context() which will deliver the IocContext
- * for the application scope.
- */
-public class Ioc
-{
- /**
- * Private constructor so this object cannot be instantiated.
- */
- private Ioc()
- {
- }
-
- /**
- * This method returns the {@link IocContext} for the APPLICATION scoped
- * {@link IocContext}.
- *
- * @return The APPLICATION scoped {@link IocContext} instance for this
- * application.
- */
- public static IocContext context()
- {
- return ContextFactory.context();
- }
-}
+/*
+ * Copyright 2015 Bridje Framework.
+ *
+ * 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.bridje.ioc;
+
+import org.bridje.ioc.impl.ContextFactory;
+
+/**
+ * Facade for the Bridje IoC API.
+ *
+ * This class provides the method context() which will deliver the IocContext
+ * for the application scope.
+ */
+public class Ioc
+{
+ /**
+ * Private constructor so this object cannot be instantiated.
+ */
+ private Ioc()
+ {
+ }
+
+ /**
+ * This method returns the {@link IocContext} for the APPLICATION scoped
+ * {@link IocContext}.
+ *
+ * @return The APPLICATION scoped {@link IocContext} instance for this
+ * application.
+ */
+ public static IocContext context()
+ {
+ return ContextFactory.context();
+ }
+}
diff --git a/bridje-ioc/src/main/java/org/bridje/ioc/IocContext.java b/bridje-ioc/src/main/java/org/bridje/ioc/IocContext.java
index 68a343070..a37d65da9 100644
--- a/bridje-ioc/src/main/java/org/bridje/ioc/IocContext.java
+++ b/bridje-ioc/src/main/java/org/bridje/ioc/IocContext.java
@@ -1,167 +1,167 @@
-/*
- * Copyright 2015 Bridje Framework.
- *
- * 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.bridje.ioc;
-
-import java.lang.reflect.Type;
-import java.util.Collection;
-
-/**
- * Represents a context in witch components are managed. This interface is mean
- * to be use (not for implementation), it brings all the method necessaries for
- * find components and services in the scope that it manages.
- *
- * An implementation of this interface can be obtained via the Ioc interface or
- * by injecting {@link org.bridje.ioc.Inject} it in any component
- * you want.
- */
-public interface IocContext
-{
- /**
- * Gets the scope of the current context.
- *
- * @return An string object representing the scope name used for this
- * context.
- */
- String getScope();
-
- /**
- * This method finds the highest priority component that provides the given
- * service.
- *
- * @param
- * @return An object that extends or implement the class of the service
- * provided, or null if no component provides this services in the context.
- */
-
- * @param
- * @param priority The given component must have a priority value greater
- * than this parameter.
- *
- * @return An object that extends or implement the class of the service
- * provided, or null if no component provides this services in the context.
- */
-
- * @param
- * @return An array of objects who extends or implement the class of the
- * service provided, or an empty array if no component provides this
- * services in the context.
- */
-
- * @param service The {@link java.lang.reflect.Type} that represents the
- * service that this method must find.
- *
- * @return An object that extends or implement the service provided, or null
- * if no component provides this services in the context.
- */
- Object findGeneric(Type service);
-
- /**
- * This method finds the component that provides the given generic service
- * with less priority than the priority parameter.
- *
- * @param service The {@link java.lang.reflect.Type} that represents the
- * service that this method must find.
- *
- * @param priority The given component must have a priority value greater
- * than this parameter.
- *
- * @return An object that extends or implement the service provided, or null
- * if no component provides this services in the context.
- */
- Object findNextGeneric(Type service, int priority);
-
- /**
- * This method finds if a service is provided by a least one component in
- * the context.
- *
- * @param service The type of the service to look for.
- *
- * @return {@literal true} If at least one component provides this service,
- * {@literal false} otherwise.
- */
- boolean exists(Type service);
-
- /**
- * This method finds if the given class is a component of the context.
- *
- * @param component The class of the component to look for.
- *
- * @return {@literal true} If this class represents a component of the
- * context, {@literal false} otherwise.
- */
- boolean existsComponent(Class component);
-
- /**
- * The parent of this context.
- *
- * @return The IocContext instance representing the parent of this context,
- * or null if this context has no parent.
- */
- IocContext getParent();
-
- /**
- * Create a child IocContext of this context.
- *
- * @param scope The scope of the new context.
- * @return The new IocContext instance created as child of this context.
- */
- IocContext createChild(String scope);
-
- /**
- * Create a child IocContext of this context.
- *
- * @param scope The scope of the new context.
- * @param instances A collection of objects that will be components of the
- * new context.
- * @return The new IocContext instance created as child of this context.
- */
- IocContext createChild(String scope, Collection instances);
-
- /**
- * Obtains the class repository associated with this context. that allows to
- * find classes, fields and methods of the components in this context.
- *
- * @return A ClassRepository instance
- */
- ClassRepository getClassRepository();
-}
+/*
+ * Copyright 2015 Bridje Framework.
+ *
+ * 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.bridje.ioc;
+
+import java.lang.reflect.Type;
+import java.util.Collection;
+
+/**
+ * Represents a context in witch components are managed. This interface is mean
+ * to be use (not for implementation), it brings all the method necessaries for
+ * find components and services in the scope that it manages.
+ *
+ * An implementation of this interface can be obtained via the Ioc interface or
+ * by injecting {@link org.bridje.ioc.Inject} it in any component
+ * you want.
+ */
+public interface IocContext
+{
+ /**
+ * Gets the scope of the current context.
+ *
+ * @return An string object representing the scope name used for this
+ * context.
+ */
+ String getScope();
+
+ /**
+ * This method finds the highest priority component that provides the given
+ * service.
+ *
+ * @param
+ * @return An object that extends or implement the class of the service
+ * provided, or null if no component provides this services in the context.
+ */
+
+ * @param
+ * @param priority The given component must have a priority value greater
+ * than this parameter.
+ *
+ * @return An object that extends or implement the class of the service
+ * provided, or null if no component provides this services in the context.
+ */
+
+ * @param
+ * @return An array of objects who extends or implement the class of the
+ * service provided, or an empty array if no component provides this
+ * services in the context.
+ */
+
+ * @param service The {@link java.lang.reflect.Type} that represents the
+ * service that this method must find.
+ *
+ * @return An object that extends or implement the service provided, or null
+ * if no component provides this services in the context.
+ */
+ Object findGeneric(Type service);
+
+ /**
+ * This method finds the component that provides the given generic service
+ * with less priority than the priority parameter.
+ *
+ * @param service The {@link java.lang.reflect.Type} that represents the
+ * service that this method must find.
+ *
+ * @param priority The given component must have a priority value greater
+ * than this parameter.
+ *
+ * @return An object that extends or implement the service provided, or null
+ * if no component provides this services in the context.
+ */
+ Object findNextGeneric(Type service, int priority);
+
+ /**
+ * This method finds if a service is provided by a least one component in
+ * the context.
+ *
+ * @param service The type of the service to look for.
+ *
+ * @return {@literal true} If at least one component provides this service,
+ * {@literal false} otherwise.
+ */
+ boolean exists(Type service);
+
+ /**
+ * This method finds if the given class is a component of the context.
+ *
+ * @param component The class of the component to look for.
+ *
+ * @return {@literal true} If this class represents a component of the
+ * context, {@literal false} otherwise.
+ */
+ boolean existsComponent(Class component);
+
+ /**
+ * The parent of this context.
+ *
+ * @return The IocContext instance representing the parent of this context,
+ * or null if this context has no parent.
+ */
+ IocContext getParent();
+
+ /**
+ * Create a child IocContext of this context.
+ *
+ * @param scope The scope of the new context.
+ * @return The new IocContext instance created as child of this context.
+ */
+ IocContext createChild(String scope);
+
+ /**
+ * Create a child IocContext of this context.
+ *
+ * @param scope The scope of the new context.
+ * @param instances A collection of objects that will be components of the
+ * new context.
+ * @return The new IocContext instance created as child of this context.
+ */
+ IocContext createChild(String scope, Collection instances);
+
+ /**
+ * Obtains the class repository associated with this context. that allows to
+ * find classes, fields and methods of the components in this context.
+ *
+ * @return A ClassRepository instance
+ */
+ ClassRepository getClassRepository();
+}
diff --git a/bridje-ioc/src/main/java/org/bridje/ioc/MethodNavigator.java b/bridje-ioc/src/main/java/org/bridje/ioc/MethodNavigator.java
index dbf1c31f8..90d971159 100644
--- a/bridje-ioc/src/main/java/org/bridje/ioc/MethodNavigator.java
+++ b/bridje-ioc/src/main/java/org/bridje/ioc/MethodNavigator.java
@@ -1,42 +1,42 @@
-/*
- * Copyright 2015 Bridje Framework.
- *
- * 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.bridje.ioc;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Method;
-
-/**
- * Functional interface used by {@link ClassRepository} for navigating annotated
- * methods in the inversion of control context.
- *
- * @param The annotation that the methods must have in orther to be accept by
- * the navigator.
- */
-@FunctionalInterface
-public interface MethodNavigator
-{
- /**
- * This method is call when ever a method in a component if found to have the
- * given annotation.
- *
- * @param method The method been found.
- * @param component The class of the component that contains the found
- * method.
- * @param annotation The instance of the annotation of the method.
- */
- void accept(Method method, Class component, A annotation);
-}
+/*
+ * Copyright 2015 Bridje Framework.
+ *
+ * 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.bridje.ioc;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+
+/**
+ * Functional interface used by {@link ClassRepository} for navigating annotated
+ * methods in the inversion of control context.
+ *
+ * @param The annotation that the methods must have in orther to be accept by
+ * the navigator.
+ */
+@FunctionalInterface
+public interface MethodNavigator
+{
+ /**
+ * This method is call when ever a method in a component if found to have the
+ * given annotation.
+ *
+ * @param method The method been found.
+ * @param component The class of the component that contains the found
+ * method.
+ * @param annotation The instance of the annotation of the method.
+ */
+ void accept(Method method, Class component, A annotation);
+}
diff --git a/bridje-ioc/src/main/java/org/bridje/ioc/Priority.java b/bridje-ioc/src/main/java/org/bridje/ioc/Priority.java
index a6bcfdd96..48beda1bf 100644
--- a/bridje-ioc/src/main/java/org/bridje/ioc/Priority.java
+++ b/bridje-ioc/src/main/java/org/bridje/ioc/Priority.java
@@ -1,40 +1,40 @@
-/*
- * Copyright 2015 Bridje Framework.
- *
- * 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.bridje.ioc;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Defines the priority of the component in a way that the small values are the
- * highest priority component. The container will use this annotation to find
- * out the default implementation (the one with highest priority) for the given
- * service.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.TYPE)
-public @interface Priority
-{
- /**
- * The priority of the component.
- *
- * @return An intenger witch represents the priority of the component.
- */
- int value() default Integer.MAX_VALUE;
-}
+/*
+ * Copyright 2015 Bridje Framework.
+ *
+ * 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.bridje.ioc;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Defines the priority of the component in a way that the small values are the
+ * highest priority component. The container will use this annotation to find
+ * out the default implementation (the one with highest priority) for the given
+ * service.
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)
+public @interface Priority
+{
+ /**
+ * The priority of the component.
+ *
+ * @return An intenger witch represents the priority of the component.
+ */
+ int value() default Integer.MAX_VALUE;
+}
diff --git a/bridje-ioc/src/main/java/org/bridje/ioc/impl/ClassSet.java b/bridje-ioc/src/main/java/org/bridje/ioc/impl/ClassSet.java
index d41c2e6b3..ab414e8a9 100644
--- a/bridje-ioc/src/main/java/org/bridje/ioc/impl/ClassSet.java
+++ b/bridje-ioc/src/main/java/org/bridje/ioc/impl/ClassSet.java
@@ -1,328 +1,328 @@
-/*
- * Copyright 2015 Bridje Framework.
- *
- * 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.bridje.ioc.impl;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.net.URL;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import org.bridje.ioc.ClassRepository;
-import org.bridje.ioc.ClassNavigator;
-import org.bridje.ioc.MethodNavigator;
-import org.bridje.ioc.FieldNavigator;
-
-/**
- * This class represents a set of classes, his propouse is to serve as a
- * container for all the class that are to be managed by an IocContext instance.
- *
- */
-class ClassSet implements Iterable
- * @param clsName The full class name of the component to append
- * @param scope The scope of the component
- *
- * @throws IOException If any IO error prevents the writing.
- */
- private void appendClass(String clsName, String scope) throws IOException
- {
- writer.append(clsName);
- writer.append("=");
- writer.append(scope);
- writer.append("\n");
- writer.flush();
- }
-}
+/*
+ * Copyright 2015 Bridje Framework.
+ *
+ * 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.bridje.ioc.impl;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.util.Set;
+import java.util.logging.Logger;
+import javax.annotation.processing.AbstractProcessor;
+import javax.annotation.processing.Filer;
+import javax.annotation.processing.Messager;
+import javax.annotation.processing.ProcessingEnvironment;
+import javax.annotation.processing.RoundEnvironment;
+import javax.annotation.processing.SupportedAnnotationTypes;
+import javax.annotation.processing.SupportedSourceVersion;
+import javax.lang.model.SourceVersion;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.ElementKind;
+import javax.lang.model.element.TypeElement;
+import javax.tools.Diagnostic;
+import javax.tools.FileObject;
+import javax.tools.StandardLocation;
+import org.bridje.ioc.Component;
+
+/**
+ * Annotations processor for the {@link Component} annotation.
+ */
+@SupportedAnnotationTypes("org.bridje.ioc.Component")
+@SupportedSourceVersion(SourceVersion.RELEASE_8)
+public class ComponentProcessor extends AbstractProcessor
+{
+ private Filer filer;
+
+ private FileObject fobj;
+
+ private Writer writer;
+
+ private static final Logger LOG = Logger.getLogger(ComponentProcessor.class.getName());
+
+ public static final String COMPONENTS_RESOURCE_FILE = "BRIDJE-INF/ioc/components.properties";
+
+ @Override
+ public synchronized void init(ProcessingEnvironment processingEnv)
+ {
+ //Creating necesary objects for annotations procesing.
+ super.init(processingEnv);
+ Messager messager = processingEnv.getMessager();
+ try
+ {
+ filer = processingEnv.getFiler();
+ //Creating output file
+ fobj = filer.createResource(StandardLocation.CLASS_OUTPUT, "", COMPONENTS_RESOURCE_FILE);
+ writer = fobj.openWriter();
+ }
+ catch (IOException e)
+ {
+ messager.printMessage(Diagnostic.Kind.ERROR, e.getMessage());
+ LOG.severe(e.getMessage());
+ }
+ }
+
+ @Override
+ public boolean process(Set extends TypeElement> annotations, RoundEnvironment roundEnv)
+ {
+ Messager messager = processingEnv.getMessager();
+ try
+ {
+ for (TypeElement typeElement : annotations)
+ {
+ //Find all @Component marked classes
+ Set extends Element> ann = roundEnv.getElementsAnnotatedWith(typeElement);
+ for (Element element : ann)
+ {
+ if (element.getKind() == ElementKind.CLASS)
+ {
+ //Get the @Component annotation for the current element.
+ Component annot = element.getAnnotation(Component.class);
+ String clsName = element.toString();
+ String scope = annot.scope();
+ appendClass(clsName, scope);
+ }
+ }
+ }
+ }
+ catch (IOException ex)
+ {
+ messager.printMessage(Diagnostic.Kind.ERROR, ex.getMessage());
+ LOG.severe(ex.getMessage());
+ }
+ return false;
+ }
+
+ /**
+ * This method appends class=scope to the output file.
+ *
+ * @param clsName The full class name of the component to append
+ * @param scope The scope of the component
+ *
+ * @throws IOException If any IO error prevents the writing.
+ */
+ private void appendClass(String clsName, String scope) throws IOException
+ {
+ writer.append(clsName);
+ writer.append("=");
+ writer.append(scope);
+ writer.append("\n");
+ writer.flush();
+ }
+}
diff --git a/bridje-ioc/src/main/java/org/bridje/ioc/impl/Container.java b/bridje-ioc/src/main/java/org/bridje/ioc/impl/Container.java
index 527b20bee..a6b578576 100644
--- a/bridje-ioc/src/main/java/org/bridje/ioc/impl/Container.java
+++ b/bridje-ioc/src/main/java/org/bridje/ioc/impl/Container.java
@@ -1,114 +1,114 @@
-/*
- * Copyright 2015 Bridje Framework.
- *
- * 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.bridje.ioc.impl;
-
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-/**
- * This class is resposable for holding references to the instanciated
- * components in a ioc context.
- */
-class Container
-{
- /**
- * A map containing the class of the component and it´s instance for all
- * instantiated components in the context.
- */
- private final Map
- *
- *
- * If you want to listen to all components use Object
- *
- * @Component
- * class MyContextListener implement ContextListener<MyComponent>
- * {
- * public void preCreateComponent(Class<MyComponent>; component)
- * {
- * //only is call when MyComponent is pre create
- * }
- *
- * public void preInitComponent(Class<MyComponent> component)
- * {
- * //only is call when MyComponent is pre init
- * }
- *
- * public void postInitComponent(Class<MyComponent> component)
- * {
- * //only is call when MyComponent is post init
- * }
- * }
- *
- *
- */
-public interface ContextListener@Component
- * class MyContextListener implement ContextListener<Object>
- * {
- * public void preCreateComponent(Class<Object> component)
- * {
- * //is call for each component pre create
- * }
- *
- * public void preInitComponent(Class<Object> component)
- * {
- * //is call for each component pre init
- * }
- *
- * public void postInitComponent(Class<Object> component)
- * {
- * //is call for each component post init
- * }
- * }
- *
+ *
+ *
+ * If you want to listen to all components use Object
+ *
+ * @Component
+ * class MyContextListener implement ContextListener<MyComponent>
+ * {
+ * public void preCreateComponent(Class<MyComponent>; component)
+ * {
+ * //only is call when MyComponent is pre create
+ * }
+ *
+ * public void preInitComponent(Class<MyComponent> component)
+ * {
+ * //only is call when MyComponent is pre init
+ * }
+ *
+ * public void postInitComponent(Class<MyComponent> component)
+ * {
+ * //only is call when MyComponent is post init
+ * }
+ * }
+ *
+ *
+ */
+public interface ContextListener@Component
+ * class MyContextListener implement ContextListener<Object>
+ * {
+ * public void preCreateComponent(Class<Object> component)
+ * {
+ * //is call for each component pre create
+ * }
+ *
+ * public void preInitComponent(Class<Object> component)
+ * {
+ * //is call for each component pre init
+ * }
+ *
+ * public void postInitComponent(Class<Object> component)
+ * {
+ * //is call for each component post init
+ * }
+ * }
+ *
- * ? extends SomeService = SomeService
- * ? extends SomeService<String> = SomeService<String>
- *
- *
- * @param service The wildcardType to inspect.
- * @return The upper bounds Type of the WildcardType.
- */
- public static Type typeOf(WildcardType service)
- {
- Type[] upperBounds = ((WildcardType) service).getUpperBounds();
- if (upperBounds.length == 1)
- {
- return (upperBounds[0]);
- }
- else if (upperBounds.length == 0)
- {
- return Object.class;
- }
- return null;
- }
-
- /**
- * Find the Type of an array, map or collection.
- *
- *
- * SomeService[] = SomeService
- * List<SomeService> = SomeService
- * Map<Class, SomeService> = SomeService
- *
- *
- * @param service The inner type of the multiple type passed.
- * @return A type representing the inner type for the collection, array or
- * map passed.
- */
- public static Type multipleType(Type service)
- {
- if (isArray(service))
- {
- return arrayType(service);
- }
- else if (isCollection(service))
- {
- return collectionType(service);
- }
- else if (isMap(service))
- {
- return mapType(service);
- }
- return null;
- }
-
- /**
- * Find the Type of an array.
- *
- *
- * SomeService[] = SomeService
- *
- *
- * @param service The inner type of the array type passed.
- * @return A type representing the inner type for the array type passed.
- */
- public static Type arrayType(Type service)
- {
- if (service instanceof GenericArrayType)
- {
- Type rawType = ((GenericArrayType) service).getGenericComponentType();
- return rawType;
- }
- else if (service instanceof Class)
- {
- return ((Class) service).getComponentType();
- }
- return null;
- }
-
- /**
- * Find the Type of collection.
- *
- *
- * List<SomeService> = SomeService
- * Set<SomeService> = SomeService
- *
- *
- * @param service The inner type of the array type passed.
- * @return A type representing the inner type for the collection type
- * passed.
- */
- public static Type collectionType(Type service)
- {
- if (service instanceof ParameterizedType)
- {
- Type[] args = ((ParameterizedType) service).getActualTypeArguments();
- if (args.length == 1)
- {
- return args[0];
- }
- }
- return null;
- }
-
- /**
- * Find the Type of a map.
- *
- *
- * Map<Class, SomeService> = SomeService
- * HashMap<Class, SomeService> = SomeService
- *
- *
- * @param service The inner type of the array type passed.
- * @return A type representing the inner type for the map type passed.
- */
- public static Type mapType(Type service)
- {
- if (service instanceof ParameterizedType)
- {
- Type[] args = ((ParameterizedType) service).getActualTypeArguments();
- if (args.length == 2)
- {
- return args[1];
- }
- }
- return null;
- }
-
- /**
- * Determines whenever the passed type is an array, a java collection like
- * List or Set, or a java Map.
- *
- * SomeService = false
- * SomeService[] = true
- * List<SomeService> = true
- * Map<Class, SomeService> = true
- * MyListImpl<SomeService> = false
- * HashMap<Class, SomeService> = true
- *
- *
- * @param service The type to inspect.
- * @return true if the especified type is an array, a collection or map from
- * java languaje.
- */
- public static boolean isMultiple(Type service)
- {
- return isArray(service) || isCollection(service) || isMap(service);
- }
-
- /**
- * Determines whenever the passed type is an array.
- *
- * SomeService = false
- * SomeService[] = true
- * List<SomeService> = false
- * List<SomeService>[] = true
- * Map<Class, SomeService> = false
- * MyListImpl<SomeService> = false
- * HashMap<Class, SomeService> = false
- *
- *
- * @param service The type to inspect.
- * @return true if the especified type is an array.
- */
- public static boolean isArray(Type service)
- {
- if (service instanceof Class)
- {
- return ((Class) service).isArray();
- }
- else
- {
- return service instanceof GenericArrayType;
- }
- }
-
- /**
- * Determines whenever the passed type is a collection.
- *
- * SomeService = false
- * SomeService[] = false
- * List<SomeService> = true
- * List<SomeService>[] = true
- * Map<Class, SomeService> = false
- * MyListImpl<SomeService> = false
- * HashMap<Class, SomeService> = false
- *
- *
- * @param service The type to inspect.
- * @return true if the especified type is a List Set or other java
- * collection except a map.
- */
- public static boolean isCollection(Type service)
- {
- Class cls = rawClass(service);
- if (cls == null || cls.isArray() || cls.getPackage() == null)
- {
- return false;
- }
- return cls.getPackage().getName().startsWith("java.")
- && Collection.class.isAssignableFrom(cls)
- && !Map.class.isAssignableFrom(cls);
- }
-
- /**
- * Determines whenever the passed type is a map.
- *
- * SomeService = false
- * SomeService[] = false
- * List<SomeService> = false
- * List<SomeService>[] = false
- * Map<Class, SomeService> = true
- * MyListImpl<SomeService> = false
- * HashMap<Class, SomeService> = true
- *
- *
- * @param service The type to inspect.
- * @return true if the especified type is a java Map.
- */
- public static boolean isMap(Type service)
- {
- Class cls = rawClass(service);
- if (cls == null || cls.isArray() || cls.getPackage() == null)
- {
- return false;
- }
- return cls.getPackage().getName().startsWith("java.")
- && Map.class.isAssignableFrom(cls);
- }
-
- /**
- * Gets the raw class for the especified Type.
- *
- * SomeService = SomeService
- * SomeService[] = SomeService[]
- * List<SomeService> = List
- * List<SomeService>[] = List[]
- * Map<Class, SomeService> = Map
- * MyListImpl<SomeService> = MyListImpl
- * HashMap<Class, SomeService> = HashMap
- *
- *
- * @param service
- * @return
- */
- public static Class rawClass(Type service)
- {
- if (service instanceof Class)
- {
- return ((Class) service);
- }
- else if (service instanceof ParameterizedType)
- {
- Type rawType = ((ParameterizedType) service).getRawType();
- if (rawType instanceof Class)
- {
- return ((Class) rawType);
- }
- }
- else if (service instanceof WildcardType)
- {
- Type wildCardType = typeOf((WildcardType) service);
- return rawClass(wildCardType);
- }
- return null;
- }
-
- /**
- * Gets a collection with all the classes of the objects from the especified
- * collection.
- *
- * @param instances The objects to obtain it´s classes from.
- * @return A Collection object with all the classes of the object´s in the
- * collection passed.
- */
- public static Collection
- * SomeService = null
- * SomeService[] = SomeService[]
- * List<SomeService> = ArrayList
- * List<SomeService>[] = List[]
- * Map<Class, SomeService> = Map
- * MyListImpl<SomeService> = null
- * HashMap<Class, SomeService> = HashMap
- *
- *
- * @param service The type of the array, collection or map.
- * @param data The data to put on the result listing.
- * @return The proper object for the especified type.
- */
- public static Object createMultiple(Type service, Object[] data)
- {
- try
- {
- if (data != null)
- {
- if (ClassUtils.isCollection(service))
- {
- Class resultClass = rawClass(service);
- return ClassUtils.createCollection(resultClass, data);
- }
- else if (ClassUtils.isMap(service))
- {
- Class resultClass = rawClass(service);
- return ClassUtils.createCollection(resultClass, data);
- }
- else if (ClassUtils.isArray(service))
- {
- return data;
- }
- }
- }
- catch (Exception ex)
- {
- LOG.log(Level.SEVERE, ex.getMessage(), ex);
- }
- return null;
- }
-
- /**
- * Given a collection type this method will return the appropied instance
- * for it.
- *
- * SomeService = null
- * SomeService[] = null
- * List<SomeService> = ArrayList
- * LinkedList<SomeService> = LinkedList
- * List<SomeService>[] = null
- * Map<Class, SomeService> = null
- * MyListImpl<SomeService> = null
- * HashMap<Class, SomeService> = null
- *
- *
- * @param collectionCls
- * @param data
- * @return
- * @throws InstantiationException
- * @throws IllegalAccessException
- */
- public static Collection createCollection(Class collectionCls, Object[] data) throws InstantiationException, IllegalAccessException
- {
- Collection res = null;
- Constructor construct = findConstructor(collectionCls);
- if (construct != null && construct.isAccessible())
- {
- res = (Collection) collectionCls.newInstance();
- }
- else if (collectionCls.isAssignableFrom(ArrayList.class))
- {
- res = new ArrayList(data.length);
- }
- else if (collectionCls.isAssignableFrom(LinkedHashSet.class))
- {
- res = new LinkedHashSet(data.length);
- }
- else if (collectionCls.isAssignableFrom(PriorityBlockingQueue.class))
- {
- res = new PriorityBlockingQueue(data.length);
- }
- if (res != null)
- {
- res.addAll(Arrays.asList(data));
- }
- return res;
- }
-
- /**
- * Given a map type this method will return the appropied instance for it.
- *
- * SomeService = null
- * SomeService[] = null
- * List<SomeService> = null
- * List<SomeService>[] = null
- * Map<Class, SomeService> = Map
- * MyListImpl<SomeService> = null
- * HashMap<Class, SomeService> = HashMapl
- *
- *
- * @param mapCls
- * @param data
- * @return
- * @throws InstantiationException
- * @throws IllegalAccessException
- */
- public static Map createMap(Class mapCls, Object[] data) throws InstantiationException, IllegalAccessException
- {
- Map map = null;
- Constructor construct = findConstructor(mapCls);
- if (construct != null && construct.isAccessible())
- {
- map = (Map) mapCls.newInstance();
- }
- else if (mapCls.isAssignableFrom(LinkedHashMap.class))
- {
- map = new LinkedHashMap(data.length);
- }
- if (map != null)
- {
- for (Object cmp : data)
- {
- map.put(cmp.getClass(), cmp);
- }
- }
- return map;
- }
-
- /**
- * Finds the default constructor for the especified class.
- *
- * @param cls The class to find the constructor for.
- * @return The default constructor for the class of null if none can be
- * found.
- */
- private static Constructor findConstructor(Class cls)
- {
- Constructor[] constructors = cls.getConstructors();
- for (Constructor constructor : constructors)
- {
- if (constructor.getParameterCount() == 0)
- {
- return constructor;
- }
- }
- return null;
- }
-
- /**
- * Sorts a list of components by priority.
- *
- * @param value The list of classes to sort.
- */
- public static void sort(List
- * SomeService<T> = true
- * SomeService<?> = true
- * SomeService = false
- * SomeService<String> = false
- *
- *
- * @param type The type to inspect.
- * @return true the especified type has a generic declaration, false
- * otherwise.
- */
- public static boolean hasGenericDeclaration(Type type)
- {
- if (type instanceof ParameterizedType)
- {
- ParameterizedType pType = (ParameterizedType) type;
- Type[] types = pType.getActualTypeArguments();
- for (Type t : types)
- {
- if (hasGenericDeclaration(t))
- {
- return true;
- }
- }
- }
- return type instanceof TypeVariable || type instanceof WildcardType;
- }
-
-}
+/*
+ * Copyright 2015 Bridje Framework.
+ *
+ * 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.bridje.ioc.impl;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.GenericArrayType;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.lang.reflect.TypeVariable;
+import java.lang.reflect.WildcardType;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.PriorityBlockingQueue;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import org.bridje.ioc.Priority;
+
+/**
+ * Utility method for class and type handling.
+ */
+class ClassUtils
+{
+ /**
+ * Logger for this class
+ */
+ private static final Logger LOG = Logger.getLogger(ClassUtils.class.getName());
+
+ /**
+ * Gets the upper bounds Type for a WildcarType.
+ *
+ *
+ * ? extends SomeService = SomeService
+ * ? extends SomeService<String> = SomeService<String>
+ *
+ *
+ * @param service The wildcardType to inspect.
+ * @return The upper bounds Type of the WildcardType.
+ */
+ public static Type typeOf(WildcardType service)
+ {
+ Type[] upperBounds = ((WildcardType) service).getUpperBounds();
+ if (upperBounds.length == 1)
+ {
+ return (upperBounds[0]);
+ }
+ else if (upperBounds.length == 0)
+ {
+ return Object.class;
+ }
+ return null;
+ }
+
+ /**
+ * Find the Type of an array, map or collection.
+ *
+ *
+ * SomeService[] = SomeService
+ * List<SomeService> = SomeService
+ * Map<Class, SomeService> = SomeService
+ *
+ *
+ * @param service The inner type of the multiple type passed.
+ * @return A type representing the inner type for the collection, array or
+ * map passed.
+ */
+ public static Type multipleType(Type service)
+ {
+ if (isArray(service))
+ {
+ return arrayType(service);
+ }
+ else if (isCollection(service))
+ {
+ return collectionType(service);
+ }
+ else if (isMap(service))
+ {
+ return mapType(service);
+ }
+ return null;
+ }
+
+ /**
+ * Find the Type of an array.
+ *
+ *
+ * SomeService[] = SomeService
+ *
+ *
+ * @param service The inner type of the array type passed.
+ * @return A type representing the inner type for the array type passed.
+ */
+ public static Type arrayType(Type service)
+ {
+ if (service instanceof GenericArrayType)
+ {
+ Type rawType = ((GenericArrayType) service).getGenericComponentType();
+ return rawType;
+ }
+ else if (service instanceof Class)
+ {
+ return ((Class) service).getComponentType();
+ }
+ return null;
+ }
+
+ /**
+ * Find the Type of collection.
+ *
+ *
+ * List<SomeService> = SomeService
+ * Set<SomeService> = SomeService
+ *
+ *
+ * @param service The inner type of the array type passed.
+ * @return A type representing the inner type for the collection type
+ * passed.
+ */
+ public static Type collectionType(Type service)
+ {
+ if (service instanceof ParameterizedType)
+ {
+ Type[] args = ((ParameterizedType) service).getActualTypeArguments();
+ if (args.length == 1)
+ {
+ return args[0];
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Find the Type of a map.
+ *
+ *
+ * Map<Class, SomeService> = SomeService
+ * HashMap<Class, SomeService> = SomeService
+ *
+ *
+ * @param service The inner type of the array type passed.
+ * @return A type representing the inner type for the map type passed.
+ */
+ public static Type mapType(Type service)
+ {
+ if (service instanceof ParameterizedType)
+ {
+ Type[] args = ((ParameterizedType) service).getActualTypeArguments();
+ if (args.length == 2)
+ {
+ return args[1];
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Determines whenever the passed type is an array, a java collection like
+ * List or Set, or a java Map.
+ *
+ * SomeService = false
+ * SomeService[] = true
+ * List<SomeService> = true
+ * Map<Class, SomeService> = true
+ * MyListImpl<SomeService> = false
+ * HashMap<Class, SomeService> = true
+ *
+ *
+ * @param service The type to inspect.
+ * @return true if the especified type is an array, a collection or map from
+ * java languaje.
+ */
+ public static boolean isMultiple(Type service)
+ {
+ return isArray(service) || isCollection(service) || isMap(service);
+ }
+
+ /**
+ * Determines whenever the passed type is an array.
+ *
+ * SomeService = false
+ * SomeService[] = true
+ * List<SomeService> = false
+ * List<SomeService>[] = true
+ * Map<Class, SomeService> = false
+ * MyListImpl<SomeService> = false
+ * HashMap<Class, SomeService> = false
+ *
+ *
+ * @param service The type to inspect.
+ * @return true if the especified type is an array.
+ */
+ public static boolean isArray(Type service)
+ {
+ if (service instanceof Class)
+ {
+ return ((Class) service).isArray();
+ }
+ else
+ {
+ return service instanceof GenericArrayType;
+ }
+ }
+
+ /**
+ * Determines whenever the passed type is a collection.
+ *
+ * SomeService = false
+ * SomeService[] = false
+ * List<SomeService> = true
+ * List<SomeService>[] = true
+ * Map<Class, SomeService> = false
+ * MyListImpl<SomeService> = false
+ * HashMap<Class, SomeService> = false
+ *
+ *
+ * @param service The type to inspect.
+ * @return true if the especified type is a List Set or other java
+ * collection except a map.
+ */
+ public static boolean isCollection(Type service)
+ {
+ Class cls = rawClass(service);
+ if (cls == null || cls.isArray() || cls.getPackage() == null)
+ {
+ return false;
+ }
+ return cls.getPackage().getName().startsWith("java.")
+ && Collection.class.isAssignableFrom(cls)
+ && !Map.class.isAssignableFrom(cls);
+ }
+
+ /**
+ * Determines whenever the passed type is a map.
+ *
+ * SomeService = false
+ * SomeService[] = false
+ * List<SomeService> = false
+ * List<SomeService>[] = false
+ * Map<Class, SomeService> = true
+ * MyListImpl<SomeService> = false
+ * HashMap<Class, SomeService> = true
+ *
+ *
+ * @param service The type to inspect.
+ * @return true if the especified type is a java Map.
+ */
+ public static boolean isMap(Type service)
+ {
+ Class cls = rawClass(service);
+ if (cls == null || cls.isArray() || cls.getPackage() == null)
+ {
+ return false;
+ }
+ return cls.getPackage().getName().startsWith("java.")
+ && Map.class.isAssignableFrom(cls);
+ }
+
+ /**
+ * Gets the raw class for the especified Type.
+ *
+ * SomeService = SomeService
+ * SomeService[] = SomeService[]
+ * List<SomeService> = List
+ * List<SomeService>[] = List[]
+ * Map<Class, SomeService> = Map
+ * MyListImpl<SomeService> = MyListImpl
+ * HashMap<Class, SomeService> = HashMap
+ *
+ *
+ * @param service
+ * @return
+ */
+ public static Class rawClass(Type service)
+ {
+ if (service instanceof Class)
+ {
+ return ((Class) service);
+ }
+ else if (service instanceof ParameterizedType)
+ {
+ Type rawType = ((ParameterizedType) service).getRawType();
+ if (rawType instanceof Class)
+ {
+ return ((Class) rawType);
+ }
+ }
+ else if (service instanceof WildcardType)
+ {
+ Type wildCardType = typeOf((WildcardType) service);
+ return rawClass(wildCardType);
+ }
+ return null;
+ }
+
+ /**
+ * Gets a collection with all the classes of the objects from the especified
+ * collection.
+ *
+ * @param instances The objects to obtain it´s classes from.
+ * @return A Collection object with all the classes of the object´s in the
+ * collection passed.
+ */
+ public static Collection
+ * SomeService = null
+ * SomeService[] = SomeService[]
+ * List<SomeService> = ArrayList
+ * List<SomeService>[] = List[]
+ * Map<Class, SomeService> = Map
+ * MyListImpl<SomeService> = null
+ * HashMap<Class, SomeService> = HashMap
+ *
+ *
+ * @param service The type of the array, collection or map.
+ * @param data The data to put on the result listing.
+ * @return The proper object for the especified type.
+ */
+ public static Object createMultiple(Type service, Object[] data)
+ {
+ try
+ {
+ if (data != null)
+ {
+ if (ClassUtils.isCollection(service))
+ {
+ Class resultClass = rawClass(service);
+ return ClassUtils.createCollection(resultClass, data);
+ }
+ else if (ClassUtils.isMap(service))
+ {
+ Class resultClass = rawClass(service);
+ return ClassUtils.createCollection(resultClass, data);
+ }
+ else if (ClassUtils.isArray(service))
+ {
+ return data;
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ LOG.log(Level.SEVERE, ex.getMessage(), ex);
+ }
+ return null;
+ }
+
+ /**
+ * Given a collection type this method will return the appropied instance
+ * for it.
+ *
+ * SomeService = null
+ * SomeService[] = null
+ * List<SomeService> = ArrayList
+ * LinkedList<SomeService> = LinkedList
+ * List<SomeService>[] = null
+ * Map<Class, SomeService> = null
+ * MyListImpl<SomeService> = null
+ * HashMap<Class, SomeService> = null
+ *
+ *
+ * @param collectionCls
+ * @param data
+ * @return
+ * @throws InstantiationException
+ * @throws IllegalAccessException
+ */
+ public static Collection createCollection(Class collectionCls, Object[] data) throws InstantiationException, IllegalAccessException
+ {
+ Collection res = null;
+ Constructor construct = findConstructor(collectionCls);
+ if (construct != null && construct.isAccessible())
+ {
+ res = (Collection) collectionCls.newInstance();
+ }
+ else if (collectionCls.isAssignableFrom(ArrayList.class))
+ {
+ res = new ArrayList(data.length);
+ }
+ else if (collectionCls.isAssignableFrom(LinkedHashSet.class))
+ {
+ res = new LinkedHashSet(data.length);
+ }
+ else if (collectionCls.isAssignableFrom(PriorityBlockingQueue.class))
+ {
+ res = new PriorityBlockingQueue(data.length);
+ }
+ if (res != null)
+ {
+ res.addAll(Arrays.asList(data));
+ }
+ return res;
+ }
+
+ /**
+ * Given a map type this method will return the appropied instance for it.
+ *
+ * SomeService = null
+ * SomeService[] = null
+ * List<SomeService> = null
+ * List<SomeService>[] = null
+ * Map<Class, SomeService> = Map
+ * MyListImpl<SomeService> = null
+ * HashMap<Class, SomeService> = HashMapl
+ *
+ *
+ * @param mapCls
+ * @param data
+ * @return
+ * @throws InstantiationException
+ * @throws IllegalAccessException
+ */
+ public static Map createMap(Class mapCls, Object[] data) throws InstantiationException, IllegalAccessException
+ {
+ Map map = null;
+ Constructor construct = findConstructor(mapCls);
+ if (construct != null && construct.isAccessible())
+ {
+ map = (Map) mapCls.newInstance();
+ }
+ else if (mapCls.isAssignableFrom(LinkedHashMap.class))
+ {
+ map = new LinkedHashMap(data.length);
+ }
+ if (map != null)
+ {
+ for (Object cmp : data)
+ {
+ map.put(cmp.getClass(), cmp);
+ }
+ }
+ return map;
+ }
+
+ /**
+ * Finds the default constructor for the especified class.
+ *
+ * @param cls The class to find the constructor for.
+ * @return The default constructor for the class of null if none can be
+ * found.
+ */
+ private static Constructor findConstructor(Class cls)
+ {
+ Constructor[] constructors = cls.getConstructors();
+ for (Constructor constructor : constructors)
+ {
+ if (constructor.getParameterCount() == 0)
+ {
+ return constructor;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Sorts a list of components by priority.
+ *
+ * @param value The list of classes to sort.
+ */
+ public static void sort(List
+ * SomeService<T> = true
+ * SomeService<?> = true
+ * SomeService = false
+ * SomeService<String> = false
+ *
+ *
+ * @param type The type to inspect.
+ * @return true the especified type has a generic declaration, false
+ * otherwise.
+ */
+ public static boolean hasGenericDeclaration(Type type)
+ {
+ if (type instanceof ParameterizedType)
+ {
+ ParameterizedType pType = (ParameterizedType) type;
+ Type[] types = pType.getActualTypeArguments();
+ for (Type t : types)
+ {
+ if (hasGenericDeclaration(t))
+ {
+ return true;
+ }
+ }
+ }
+ return type instanceof TypeVariable || type instanceof WildcardType;
+ }
+
+}
diff --git a/bridje-ioc/src/main/java/org/bridje/ioc/impl/ComponentProcessor.java b/bridje-ioc/src/main/java/org/bridje/ioc/impl/ComponentProcessor.java
index d296b3e7e..86978e2c4 100644
--- a/bridje-ioc/src/main/java/org/bridje/ioc/impl/ComponentProcessor.java
+++ b/bridje-ioc/src/main/java/org/bridje/ioc/impl/ComponentProcessor.java
@@ -1,123 +1,123 @@
-/*
- * Copyright 2015 Bridje Framework.
- *
- * 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.bridje.ioc.impl;
-
-import java.io.IOException;
-import java.io.Writer;
-import java.util.Set;
-import java.util.logging.Logger;
-import javax.annotation.processing.AbstractProcessor;
-import javax.annotation.processing.Filer;
-import javax.annotation.processing.Messager;
-import javax.annotation.processing.ProcessingEnvironment;
-import javax.annotation.processing.RoundEnvironment;
-import javax.annotation.processing.SupportedAnnotationTypes;
-import javax.annotation.processing.SupportedSourceVersion;
-import javax.lang.model.SourceVersion;
-import javax.lang.model.element.Element;
-import javax.lang.model.element.ElementKind;
-import javax.lang.model.element.TypeElement;
-import javax.tools.Diagnostic;
-import javax.tools.FileObject;
-import javax.tools.StandardLocation;
-import org.bridje.ioc.Component;
-
-/**
- * Annotations processor for the {@link Component} annotation.
- */
-@SupportedAnnotationTypes("org.bridje.ioc.Component")
-@SupportedSourceVersion(SourceVersion.RELEASE_8)
-public class ComponentProcessor extends AbstractProcessor
-{
- private Filer filer;
-
- private FileObject fobj;
-
- private Writer writer;
-
- private static final Logger LOG = Logger.getLogger(ComponentProcessor.class.getName());
-
- public static final String COMPONENTS_RESOURCE_FILE = "BRIDJE-INF/ioc/components.properties";
-
- @Override
- public synchronized void init(ProcessingEnvironment processingEnv)
- {
- //Creating necesary objects for annotations procesing.
- super.init(processingEnv);
- Messager messager = processingEnv.getMessager();
- try
- {
- filer = processingEnv.getFiler();
- //Creating output file
- fobj = filer.createResource(StandardLocation.CLASS_OUTPUT, "", COMPONENTS_RESOURCE_FILE);
- writer = fobj.openWriter();
- }
- catch (IOException e)
- {
- messager.printMessage(Diagnostic.Kind.ERROR, e.getMessage());
- LOG.severe(e.getMessage());
- }
- }
-
- @Override
- public boolean process(Set extends TypeElement> annotations, RoundEnvironment roundEnv)
- {
- Messager messager = processingEnv.getMessager();
- try
- {
- for (TypeElement typeElement : annotations)
- {
- //Find all @Component marked classes
- Set extends Element> ann = roundEnv.getElementsAnnotatedWith(typeElement);
- for (Element element : ann)
- {
- if (element.getKind() == ElementKind.CLASS)
- {
- //Get the @Component annotation for the current element.
- Component annot = element.getAnnotation(Component.class);
- String clsName = element.toString();
- String scope = annot.scope();
- appendClass(clsName, scope);
- }
- }
- }
- }
- catch (IOException ex)
- {
- messager.printMessage(Diagnostic.Kind.ERROR, ex.getMessage());
- LOG.severe(ex.getMessage());
- }
- return false;
- }
-
- /**
- * This method appends class=scope to the output file.
- *