Skip to content

Commit

Permalink
SEAMJCR-16: Initial support
Browse files Browse the repository at this point in the history
  • Loading branch information
gastaldi committed Jun 22, 2011
1 parent f94ac22 commit f728045
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 29 deletions.
Expand Up @@ -16,26 +16,37 @@
*/
package org.jboss.seam.jcr.annotations;

import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
import static java.lang.annotation.ElementType.CONSTRUCTOR;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

/**
* Describes a name/value pair for JcrConfiguration settings.
*
*
* @author johnament
*/
@Documented
@Target({FIELD, METHOD, TYPE, PARAMETER})
@Target( { METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER })
@Retention(RUNTIME)
public @interface JcrConfiguration {
public String name() default "";

public String value() default "";

/**
* Defines several {@code @JcrConfiguration} annotations on the same element.
*/
@Target( { METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER })
@Retention(RUNTIME)
@Documented
public @interface List {
JcrConfiguration[] value() default {};
}
}
28 changes: 10 additions & 18 deletions docs/src/main/docbook/en-US/event-mapping.xml
Expand Up @@ -13,25 +13,18 @@
<chapter id="jcr-eventmapping">
<title>Seam JCR - Event Mapping</title>
<section id="jcr-event-mapping-intro">
<para>
Seam JCR provides functionality to fire CDI Events based on events found
in JCR. The rules of how events are
fired are based around the underlying implementation.
</para>
<tip>
You will not have an active JCR Session during the event firing,
a new one will need to be created.
</tip>
<para> Seam JCR provides functionality to fire CDI Events based on events found in JCR. The
rules of how events are fired are based around the underlying implementation. </para>
<tip> You will not have an active JCR Session during the event firing, a new one will need
to be created. </tip>
<tip> Some JCR implementations, like Modeshape fires events on a separate thread, so
probably you will get errors if your observer method is declared on a @RequestScoped
object, for example. </tip>
</section>
<section id="jcr-event-mapping-activation">
<para>
To observe an event, use the @Observes and the additional qualifiers on
seam-jcr-api module (Check package
org.jboss.seam.jcr.annotations.events).

If you need to watch any JCR event, then avoid using any Qualifier at
all.
</para>
<para> To observe an event, use the @Observes and the additional qualifiers on seam-jcr-api
module (Check package org.jboss.seam.jcr.annotations.events). If you need to watch any
JCR event, then avoid using any Qualifier at all. </para>
<programlisting role="java"><![CDATA[
import javax.jcr.observation.Event;
Expand All @@ -43,6 +36,5 @@
}
]]></programlisting>
</section>

<!-- vim:et:ts=3:sw=3:tw=120 -->
</chapter>
Expand Up @@ -16,8 +16,11 @@
*/
package org.jboss.seam.jcr.resolver;


import static org.jboss.seam.solder.reflection.AnnotationInspector.getAnnotation;

import java.lang.annotation.Annotation;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.ServiceLoader;

Expand Down Expand Up @@ -56,11 +59,18 @@ public class RepositoryResolver {
@Produces
public Repository produceRepository(InjectionPoint injectionPoint) throws RepositoryException {
Repository repository = null;
JcrConfiguration jcrRepo = injectionPoint.getAnnotated().getAnnotation(JcrConfiguration.class);
JcrConfiguration jcrRepo = getAnnotation(injectionPoint.getAnnotated(),JcrConfiguration.class,beanManager);
JcrConfiguration.List jcrRepoList = getAnnotation(injectionPoint.getAnnotated(),JcrConfiguration.List.class,beanManager);
Map<String, String> parameters = new HashMap<String, String>();
if (jcrRepo != null) {
Map<String, String> parameters = Collections.singletonMap(jcrRepo.name(), jcrRepo.value());
repository = decorateRepository(createPlainRepository(parameters));
parameters.put(jcrRepo.name(), jcrRepo.value());
}
if (jcrRepoList != null) {
for (JcrConfiguration conf : jcrRepoList.value()) {
parameters.put(conf.name(), conf.value());
}
}
repository = decorateRepository(createPlainRepository(parameters));
return repository;
}

Expand Down

0 comments on commit f728045

Please sign in to comment.