Permalink
Browse files

readme updated

  • Loading branch information...
1 parent cfd419c commit 93666c5f6fcc0fca2fa9719160f1e3520b7f56c5 @warmuuh committed Apr 15, 2013
View
@@ -2,6 +2,8 @@
Yaap is a generic annotation processor for javascript. It can be used to implement cross-cutting concerns and inject additional aspect oriented code.
+It supports annotations at class-, function- and parameter-level of javascript objects. (see examples)
+
See [Readme](yaap) for more information.
@@ -17,7 +19,8 @@ There is a more complex web application example developed with wire and a lot of
#News
-##master
+##0.1.0
+* classbased annotations
* "return"-callback with `@Callback` to cope with asynchronity
* connect-auth integration with `@Auth`
* bugfix for @PreDestroy/@PostConstruct
@@ -8,6 +8,6 @@
"underscore": "1.4.4",
"when": "1.8.1",
"wire": "0.9.1",
- "yaap": "0.0.2"
+ "yaap": "0.1.0"
}
}
View
@@ -1,6 +1,6 @@
{
"name": "yaap",
- "version": "0.0.4",
+ "version": "0.1.0",
"main": "./yaap/yaap.js",
"repository": {
"type": "git",
@@ -14,7 +14,7 @@
"Peter Mucha <ptmucha@gmail.com>"
],
"dependencies": {
- "yaap": "0.0.4",
+ "yaap": "0.1.0",
"wire": "0.9.1"
},
"license": "MIT",
View
@@ -47,16 +47,19 @@ logger.log("hello world"); //will print "INFO: hello world"
##Annotations in Javascript
Javascript does not have annotations, but at specific positions, comments are saved and can be retrieved during runtime. This library allow to retrieve and parse annotations placed at these positions.
-Right now, Yaap supports parameter-annotations and function-annotations:
+Right now, Yaap supports class-annotations, parameter-annotations and function-annotations:
```js
var obj = {
+ "@Autowired": {"myBean": "bean"},
+
fn: function(message, /*@Defaul("INFO")*/ level) /*@NotNull*/{
console.log(level + ": " + message);
}
};
```
`@Default` here is an parameter-annotation while `@NotNull` is a function-annotation. (`@NotNull` can also be used as parameter-annotation though).
+`@Autowired` is an example for a classbased annotation.
@@ -68,16 +71,17 @@ your own annotations easily. All need to be done is to register your processor.
var myProcessor = {
annotation: "@NotNull",
processFunction: function(object, fnDescription, annotationParams, configuration){... },
- processParameter: function(object, fnDescription, annotatedParameters, configuration){...}
+ processParameter: function(object, fnDescription, annotatedParameters, configuration){...},
+ processClass: function(object, annotatedParameters, configuration){...}
}
yaap.register(myProcessor);
```
After registering your processor, `processFunction` will be called,
if a function is annotated with the according annotation. `processParameter` is called,
-if an annotated parameter is found.
+if an annotated parameter is found and `processClass`, if a class-annotation is found.
-`Remark:` You can either define both or one of these functions, depending on
+`Remark:` You can either define all or some of these functions, depending on
where you want to allow your annotation to be placed.
More information on how to create custom annotation processors are available [here](docs/processors.md).
View
@@ -2,7 +2,7 @@
despite being an annofation processing framework, there are some annotation processors already included.
While some of them work out of the box, others can only be used with wire.js.
-Some annotations can only be used on parameters while others can also be used at function level.
+Some annotations can only be used on parameters while others can also be used at function level or class level.
##Basic annotations
@@ -14,9 +14,10 @@ Some annotations can only be used on parameters while others can also be used at
##Wire annotations
-* `@Autowired([<refName>])` (parameter/function): if a parameter is unassigned or null, a bean from the wire-context will be injected instead.
+* `@Autowired([<refName>])` (parameter/function/class): if a parameter is unassigned or null, a bean from the wire-context will be injected instead.
If the annotation is placed at a parameter, the given refName or, if ommitted, the parameter-name will be used to resolve the reference.
If the annotation is function-level, all parameters that are null or unassigned will be autowired by parameter-name.
+ If the annotation is class-level, the parameter could be a string, an array of strings or an object that maps strings onto strings. New Properties according to the given names will be injected with the referenced beans.
* `@PostConstruct` (function): the annotated function will be called after container finished configuring the bean.
View
@@ -10,7 +10,8 @@ The "annotation" property defines the name of your annotation. The following exa
var myProcessor = {
annotation: "@NotNull",
processFunction: function(object, fnDescription, annotationParams, context){... },
- processParameter: function(object, fnDescription, annotatedParameters, context){...}
+ processParameter: function(object, fnDescription, annotatedParameters, context){...},
+ processClass: function(object, annotatedParameters, context){...},
}
yaap.register(myProcessor);
```
@@ -54,6 +55,10 @@ The parameters are handed over as array instead of multiple calls to "processPar
because then you can handle each annotated parameter in one wrapper of the target function
instead of one separate handler for each annotated parameter.
+#Process Classes
+Class-annotations are not comments but specific attributes. they are strings starting with `@`. Their value will be handed over to the `processClass`-function.
+The parameters are the same as for `processParameter` except that there is no fnDescription.
+
##Wire-Specific Processors
Wire-specific processors need a specific instance of wire to e.g. resolve references in the current context.
Therefore the context contains the wire-context as well as an array where plugins can put their promises. The context object looks loke this:
View
@@ -1,6 +1,6 @@
{
"name": "yaap",
- "version": "0.0.4",
+ "version": "0.1.0",
"description": "yaap",
"keywords": [ "javascript", "dependency injection", "AOP", "IOC"],
"repository": {
@@ -8,7 +8,7 @@
*
* @author Peter Mucha
*
- * @version 0.0.4
+ * @version 0.1.0
*/
"use strict";
@@ -8,7 +8,7 @@
*
* @author Peter Mucha
*
- * @version 0.0.4
+ * @version 0.1.0
*/
"use strict";
View
@@ -8,7 +8,7 @@
*
* @author Peter Mucha
*
- * @version 0.0.4
+ * @version 0.1.0
*/
"use strict";
(function(define) {
@@ -10,7 +10,7 @@
*
* @author Peter Mucha
*
- * @version 0.0.4
+ * @version 0.1.0
*/
"use strict";
(function(define) {
@@ -10,7 +10,7 @@
*
* @author Peter Mucha
*
- * @version 0.0.4
+ * @version 0.1.0
*/
"use strict";
(function(define) {
View
@@ -8,7 +8,7 @@
*
* @author Peter Mucha
*
- * @version 0.0.4
+ * @version 0.1.0
*/
"use strict";
(function(define) {
@@ -13,7 +13,7 @@
*
* @author Peter Mucha
*
- * @version 0.0.4
+ * @version 0.1.0
*/
"use strict";
(function(define) {
@@ -13,7 +13,7 @@
*
* @author Peter Mucha
*
- * @version 0.0.4
+ * @version 0.1.0
*/
"use strict";
(function(define) {
@@ -13,7 +13,7 @@
*
* @author Peter Mucha
*
- * @version 0.0.4
+ * @version 0.1.0
*/
"use strict";
(function(define) {
@@ -12,7 +12,7 @@
*
* @author Peter Mucha
*
- * @version 0.0.4
+ * @version 0.1.0
*/
"use strict";
(function(define) {
@@ -12,7 +12,7 @@
*
* @author Peter Mucha
*
- * @version 0.0.4
+ * @version 0.1.0
*/
"use strict";
(function(define) {
View
@@ -8,7 +8,7 @@
*
* @author Peter Mucha
*
- * @version 0.0.4
+ * @version 0.1.0
*/
"use strict";
(function(define) {

0 comments on commit 93666c5

Please sign in to comment.