1
1
/*
2
- * Copyright 2011 the original author or authors.
2
+ * Copyright 2011-2013 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
22
22
import java .util .HashSet ;
23
23
import java .util .Set ;
24
24
25
+ import javax .enterprise .context .ApplicationScoped ;
25
26
import javax .enterprise .context .spi .CreationalContext ;
26
27
import javax .enterprise .inject .Alternative ;
27
28
import javax .enterprise .inject .Stereotype ;
@@ -52,6 +53,7 @@ public abstract class CdiRepositoryBean<T> implements Bean<T> {
52
53
*
53
54
* @param qualifiers must not be {@literal null}.
54
55
* @param repositoryType has to be an interface must not be {@literal null}.
56
+ * @param beanManager the CDI {@link BeanManager}, must not be {@literal null}.
55
57
*/
56
58
public CdiRepositoryBean (Set <Annotation > qualifiers , Class <T > repositoryType , BeanManager beanManager ) {
57
59
@@ -85,11 +87,11 @@ public Set<Type> getTypes() {
85
87
}
86
88
87
89
/**
88
- * Returns an instance of an {@link EntityManager }.
90
+ * Returns an instance of an the given {@link Bean }.
89
91
*
90
- * @param beanManager The BeanManager .
91
- * @param bean The bean representing an EntityManager .
92
- * @return The EntityManager instance.
92
+ * @param bean the {@link Bean} about to create an instance for .
93
+ * @param type the expected type of the componentn instance created for that {@link Bean} .
94
+ * @return the actual component instance.
93
95
*/
94
96
@ SuppressWarnings ("unchecked" )
95
97
protected <S > S getDependencyInstance (Bean <S > bean , Class <S > type ) {
@@ -106,6 +108,7 @@ public final T create(CreationalContext<T> creationalContext) {
106
108
if (LOGGER .isDebugEnabled ()) {
107
109
LOGGER .debug (String .format ("Creating bean instance for repository type '%s'." , repositoryType .getName ()));
108
110
}
111
+
109
112
return create (creationalContext , repositoryType );
110
113
}
111
114
@@ -189,9 +192,19 @@ public Set<InjectionPoint> getInjectionPoints() {
189
192
return Collections .emptySet ();
190
193
}
191
194
195
+ /*
196
+ * (non-Javadoc)
197
+ * @see javax.enterprise.inject.spi.Bean#getScope()
198
+ */
199
+ public Class <? extends Annotation > getScope () {
200
+ return ApplicationScoped .class ;
201
+ }
202
+
192
203
/**
193
- * @param creationalContext
194
- * @param repositoryType
204
+ * Creates the actual component instance.
205
+ *
206
+ * @param creationalContext will never be {@literal null}.
207
+ * @param repositoryType will never be {@literal null}.
195
208
* @return
196
209
*/
197
210
protected abstract T create (CreationalContext <T > creationalContext , Class <T > repositoryType );
0 commit comments