Hi,
I try tu use dependency injection pattern to provide InitialContext reference to some
class. The marker annotation looks like this:
| @Target( ElementType.FIELD )
| @Retention( RetentionPolicy.RUNTIME )
| public @interface Injection {
| }
and the target class:
public class DAOFactoryImpl implements DAOFactory {
| @Injection private InitialContext initialContext;
|
| public DAOFactoryImpl() {
| try {
| DataSource dataSource = (DataSource)initialContext.lookup( "java:jdbc/DB" );
| ...
| }
| catch( NamingException e ) {
| ...
| }
| }
|
| ...
| }
The XML binding:
<aop>
|
| <aspect class="InitialContextAspect" scope="PER_JOINPOINT"/>
|
| <bind pointcut="get(javax.naming.InitialContext *->@Injection)">
| <advice name="get" aspect="InitialContextAspect"/>
| </bind>
|
| </aop>
and the aspect class itself:
public class InitialContextAspect {
| public Object get( FieldReadInvocation invocation ) throws Throwable {
| Field field = invocation.getField();
| if( field.getType().isAssignableFrom( InitialContext.class ) ) {
| ...
| }
| return fieldReadInvocation.invokeNext();
| }
| }
|
When I deploy classes and aspects into JBoss 4.0 everything seems ok (no errors in
log), but web console displays my advice in 'Unbound bindings' node:
| file:/C:/Java/jboss-4.0.0/server/tomcat5/tmp/deploy/tmp23014jboss-aop.xml0
|
| Advice Binding
|
| Pointcut Expression: get(javax.naming.InitialContext *->@Injection)
Best regards,
Szczepan Kuzniarz
View the original post :
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3853869#3853869
Reply to the post :
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3853869
-------------------------------------------------------
This SF.Net email is sponsored by:
Sybase ASE Linux Express Edition - download now for FREE
LinuxWorld Reader's Choice Award Winner for best database on Linux.
http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click
_______________________________________________
JBoss-Development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development