1 8 package org.codehaus.aspectwerkz; 9 10 import org.codehaus.aspectwerkz.exception.DefinitionException; 11 12 17 public final class DeploymentModel { 18 19 public static final DeploymentModel PER_JVM = new DeploymentModel("perJVM"); 20 public static final DeploymentModel PER_CLASS = new DeploymentModel("perClass"); 21 public static final DeploymentModel PER_INSTANCE = new DeploymentModel("perInstance"); 22 public static final DeploymentModel PER_TARGET = new DeploymentModel("perTarget"); 23 public static final DeploymentModel PER_THIS = new DeploymentModel("perThis"); 24 public static final DeploymentModel PER_CFLOW = new DeploymentModel("perCflow"); 25 public static final DeploymentModel PER_CFLOWBELOW = new DeploymentModel("perCflowbelow"); 26 27 private final String m_name; 28 29 private DeploymentModel(String name) { 30 m_name = name; 31 } 32 33 public String toString() { 34 return m_name; 35 } 36 37 public boolean equals(Object o) { 38 if (this == o) { 39 return true; 40 } 41 if (!(o instanceof DeploymentModel)) { 42 return false; 43 } 44 final DeploymentModel adviceType = (DeploymentModel) o; 45 if ((m_name != null) ? (!m_name.equals(adviceType.m_name)) : (adviceType.m_name != null)) { 46 return false; 47 } 48 return true; 49 } 50 51 public int hashCode() { 52 return ((m_name != null) ? m_name.hashCode() : 0); 53 } 54 55 public static DeploymentModel getDeploymentModelFor(final String deploymentModelAsString) { 56 if (deploymentModelAsString == null || deploymentModelAsString.equals("")) { 57 return PER_JVM; } 59 if (deploymentModelAsString.equalsIgnoreCase(PER_JVM.toString())) { 60 return PER_JVM; 61 } else if (deploymentModelAsString.equalsIgnoreCase(PER_CLASS.toString())) { 62 return PER_CLASS; 63 } else if (deploymentModelAsString.equalsIgnoreCase(PER_INSTANCE.toString())) { 64 return PER_INSTANCE; 65 } else if (deploymentModelAsString.equalsIgnoreCase(PER_TARGET.toString())) { 66 return PER_TARGET; 67 } else if (deploymentModelAsString.equalsIgnoreCase(PER_THIS.toString())) { 68 return PER_THIS; 69 } else if (deploymentModelAsString.equalsIgnoreCase(PER_CFLOW.toString())) { 70 return PER_CFLOW; 71 } else if (deploymentModelAsString.equalsIgnoreCase(PER_CFLOWBELOW.toString())) { 72 return PER_CFLOWBELOW; 73 } else { 74 System.out.println( 75 "AW::WARNING - no such deployment model [" + deploymentModelAsString + "] using default (perJVM)" 76 ); 77 return PER_JVM; } 79 } 80 } | Popular Tags |