KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > codehaus > aspectwerkz > transform > aopalliance > AopAllianceAspectContainer


1 /**************************************************************************************
2  * Copyright (c) Jonas BonŽr, Alexandre Vasseur. All rights reserved. *
3  * http://aspectwerkz.codehaus.org *
4  * ---------------------------------------------------------------------------------- *
5  * The software in this package is published under the terms of the LGPL license *
6  * a copy of which has been included with this distribution in the license.txt file. *
7  **************************************************************************************/

8 package org.codehaus.aspectwerkz.transform.aopalliance;
9
10 import org.codehaus.aspectwerkz.aspect.AbstractAspectContainer;
11 import org.codehaus.aspectwerkz.AspectContext;
12 import org.codehaus.aspectwerkz.util.ContextClassLoader;
13
14 /**
15  * Default aspect container for the AOP Alliance compliant aspects, can only handle aspects/interceptors
16  * with no argument default constructors.
17  *
18  * @author <a HREF="mailto:jboner@codehaus.org">Jonas BonŽr </a>
19  */

20 public class AopAllianceAspectContainer extends AbstractAspectContainer {
21
22     /**
23      * Creates a new aspect container that instantiates AOP Alliance interceptors.
24      *
25      * @param ctx the aspect context
26      */

27     public AopAllianceAspectContainer(final AspectContext ctx) {
28         super(ctx);
29     }
30
31     /**
32      * Creates a new aspect (interceptor) instance.
33      *
34      * @return the new aspect (interceptor) instance
35      */

36     protected Object JavaDoc createAspect() {
37         final String JavaDoc className = m_aspectContext.getAspectDefinition().getClassName();
38         try {
39             return ContextClassLoader.forName(className).newInstance();
40         } catch (ClassNotFoundException JavaDoc e) {
41             throw new RuntimeException JavaDoc("could not load AOP Alliance interceptor [" + className + "]: " + e.toString());
42         } catch (Exception JavaDoc e) {
43             throw new RuntimeException JavaDoc("could not instantiate AOP Alliance interceptor [" + className + "]: " + e.toString());
44         }
45
46     }
47 }
48
Popular Tags