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 test.mixindeployment;
08:
09: import org.codehaus.aspectwerkz.AspectContext;
10:
11: /**
12: * The aspect mixin is deployed as perInstance
13: *
14: * @author <a href="mailto:alex@gnilux.com">Alexandre Vasseur </a>
15: * @Aspect perJVM
16: */
17: public class IntroductionDeploymentAspect {
18: /**
19: * Set to parse
20: *
21: * @Mixin within(test.mixindeployment.IntroductionDeploymentTest$TargetA) ||
22: * within(test.mixindeployment.IntroductionDeploymentTest$TargetB)
23: * deploymentModel=perInstance
24: */
25: public static class MarkerImpl implements Marker {
26: /**
27: * The cross-cutting info.
28: */
29: private final AspectContext m_info;
30:
31: /**
32: * We are interested in cross-cutting info, therefore we have added a constructor that takes
33: * a cross-cutting infor instance as its only parameter.
34: *
35: * @param info the cross-cutting info
36: */
37: public MarkerImpl(final AspectContext info) {
38: m_info = info;
39: }
40:
41: public Object getTargetInstance() {
42: return null;
43: }
44:
45: public Class getTargetClass() {
46: return null;
47: }
48: }
49:
50: /**
51: * Note: explicit within(..) pointcut is needed
52: *
53: * @Mixin within(test.mixindeployment.IntroductionDeploymentTest$TargetC)
54: * deploymentModel=perClass
55: */
56: public static class AnotherMarkerImpl implements Marker {
57: /**
58: * The cross-cutting info.
59: */
60: private final AspectContext m_info;
61:
62: /**
63: * We are interested in cross-cutting info, therefore we have added a constructor that takes
64: * a cross-cutting infor instance as its only parameter.
65: *
66: * @param info the cross-cutting info
67: */
68: public AnotherMarkerImpl(final AspectContext info) {
69: m_info = info;
70: }
71:
72: public Object getTargetInstance() {
73: return null;
74: }
75:
76: public Class getTargetClass() {
77: return null;
78: }
79: }
80:
81: /**
82: * Note: will fail with a StackOverflow if perInstance - due to hashCode use to fetch mixin impl.
83: *
84: * @Mixin within(test.mixindeployment.IntroductionDeploymentTest$TargetD)
85: * deploymentModel=perClass
86: */
87: public static class HashcodeImpl implements Hashcode {
88: public int hashCode() {
89: return 2;
90: }
91: }
92: }
|