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