1 4 package com.tc.aspectwerkz.aspect.container; 5 6 7 import com.tc.aspectwerkz.DeploymentModel; 8 import com.tc.aspectwerkz.transform.inlining.AsmHelper; 9 import com.tc.aspectwerkz.util.ContextClassLoader; 10 11 14 public class AspectFactoryManager { 15 16 public static String getAspectFactoryClassName(String aspectClassName, String aspectQualifiedName) { 17 return aspectClassName.replace('.', '/') + "$" + aspectQualifiedName.replace('.', '/').replace('/', '_') + "_AWFactory"; 18 } 19 20 22 33 public static void loadAspectFactory( 34 String aspectFactoryClassName, 35 String uuid, 36 String aspectClassName, 37 String aspectQualifiedName, 38 String containerClassName, 39 String rawParameters, 40 ClassLoader loader, 41 String deploymentModelAsString) { 42 43 try { 44 ContextClassLoader.forName(loader, aspectFactoryClassName.replace('/', '.')); 45 } catch (ClassNotFoundException e) { 46 DeploymentModel deploymentModel = DeploymentModel.getDeploymentModelFor(deploymentModelAsString); 48 AbstractAspectFactoryCompiler compiler; 49 50 if (DeploymentModel.PER_JVM.equals(deploymentModel)) { 51 compiler = new PerJVMAspectFactoryCompiler( 52 uuid, 53 aspectClassName, 54 aspectQualifiedName, 55 containerClassName, 56 rawParameters, 57 loader 58 ); 59 } else if (DeploymentModel.PER_CLASS.equals(deploymentModel)) { 60 compiler = new LazyPerXFactoryCompiler.PerClassAspectFactoryCompiler( 61 uuid, 62 aspectClassName, 63 aspectQualifiedName, 64 containerClassName, 65 rawParameters, 66 loader 67 ); 68 } else if (DeploymentModel.PER_INSTANCE.equals(deploymentModel)) { 69 compiler = new PerObjectFactoryCompiler.PerInstanceFactoryCompiler( 70 uuid, 71 aspectClassName, 72 aspectQualifiedName, 73 containerClassName, 74 rawParameters, 75 loader 76 ); 77 } else if (DeploymentModel.PER_TARGET.equals(deploymentModel) 78 || DeploymentModel.PER_THIS.equals(deploymentModel)) { 79 compiler = new PerObjectFactoryCompiler( 80 uuid, 81 aspectClassName, 82 aspectQualifiedName, 83 containerClassName, 84 rawParameters, 85 loader 86 ); 87 } else if (DeploymentModel.PER_CFLOW.equals(deploymentModel) 88 || DeploymentModel.PER_CFLOWBELOW.equals(deploymentModel)) { 89 compiler = new PerCflowXAspectFactoryCompiler( 90 uuid, 91 aspectClassName, 92 aspectQualifiedName, 93 containerClassName, 94 rawParameters, 95 loader 96 ); 97 } else { 98 throw new Error ("aspect factory not implemented for deployment model: " + deploymentModel); 100 } 101 Artifact artifact = compiler.compile(); 102 Class factory = AsmHelper.defineClass(loader, artifact.bytecode, artifact.className); 103 104 } 117 } 118 } 119 | Popular Tags |