01: /**************************************************************************************
02: * Copyright (c) Jonas BonŽr, Alexandre Vasseur. All rights reserved. *
03: * http://aspectwerkz.codehaus.org *
04: * ---------------------------------------------------------------------------------- *
05: * The software in this package is published under the terms of the LGPL license *
06: * a copy of which has been included with this distribution in the license.txt file. *
07: **************************************************************************************/package org.codehaus.aspectwerkz.transform.aopalliance;
08:
09: import org.codehaus.aspectwerkz.aspect.AbstractAspectContainer;
10: import org.codehaus.aspectwerkz.AspectContext;
11: import org.codehaus.aspectwerkz.util.ContextClassLoader;
12:
13: /**
14: * Default aspect container for the AOP Alliance compliant aspects, can only handle aspects/interceptors
15: * with no argument default constructors.
16: *
17: * @author <a href="mailto:jboner@codehaus.org">Jonas BonŽr </a>
18: */
19: public class AopAllianceAspectContainer extends AbstractAspectContainer {
20:
21: /**
22: * Creates a new aspect container that instantiates AOP Alliance interceptors.
23: *
24: * @param ctx the aspect context
25: */
26: public AopAllianceAspectContainer(final AspectContext ctx) {
27: super (ctx);
28: }
29:
30: /**
31: * Creates a new aspect (interceptor) instance.
32: *
33: * @return the new aspect (interceptor) instance
34: */
35: protected Object createAspect() {
36: final String className = m_aspectContext.getAspectDefinition()
37: .getClassName();
38: try {
39: return ContextClassLoader.forName(className).newInstance();
40: } catch (ClassNotFoundException e) {
41: throw new RuntimeException(
42: "could not load AOP Alliance interceptor ["
43: + className + "]: " + e.toString());
44: } catch (Exception e) {
45: throw new RuntimeException(
46: "could not instantiate AOP Alliance interceptor ["
47: + className + "]: " + e.toString());
48: }
49:
50: }
51: }
|