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;
08:
09: import org.codehaus.aspectwerkz.exception.DefinitionException;
10:
11: /**
12: * Enum containing the different deployment model types.
13: *
14: * @author <a href="mailto:jboner@codehaus.org">Jonas BonŽr </a>
15: */
16: public final class DeploymentModel {
17:
18: public static final DeploymentModel PER_JVM = new DeploymentModel(
19: "perJVM");
20: public static final DeploymentModel PER_CLASS = new DeploymentModel(
21: "perClass");
22: public static final DeploymentModel PER_INSTANCE = new DeploymentModel(
23: "perInstance");
24: public static final DeploymentModel PER_TARGET = new DeploymentModel(
25: "perTarget");
26: public static final DeploymentModel PER_THIS = new DeploymentModel(
27: "perThis");
28: public static final DeploymentModel PER_CFLOW = new DeploymentModel(
29: "perCflow");
30: public static final DeploymentModel PER_CFLOWBELOW = new DeploymentModel(
31: "perCflowbelow");
32:
33: private final String m_name;
34:
35: private DeploymentModel(String name) {
36: m_name = name;
37: }
38:
39: public String toString() {
40: return m_name;
41: }
42:
43: public boolean equals(Object o) {
44: if (this == o) {
45: return true;
46: }
47: if (!(o instanceof DeploymentModel)) {
48: return false;
49: }
50: final DeploymentModel adviceType = (DeploymentModel) o;
51: if ((m_name != null) ? (!m_name.equals(adviceType.m_name))
52: : (adviceType.m_name != null)) {
53: return false;
54: }
55: return true;
56: }
57:
58: public int hashCode() {
59: return ((m_name != null) ? m_name.hashCode() : 0);
60: }
61:
62: public static DeploymentModel getDeploymentModelFor(
63: final String deploymentModelAsString) {
64: if (deploymentModelAsString == null
65: || deploymentModelAsString.equals("")) {
66: return PER_JVM; // default is PER_JVM
67: }
68: if (deploymentModelAsString
69: .equalsIgnoreCase(PER_JVM.toString())) {
70: return PER_JVM;
71: } else if (deploymentModelAsString.equalsIgnoreCase(PER_CLASS
72: .toString())) {
73: return PER_CLASS;
74: } else if (deploymentModelAsString
75: .equalsIgnoreCase(PER_INSTANCE.toString())) {
76: return PER_INSTANCE;
77: } else if (deploymentModelAsString.equalsIgnoreCase(PER_TARGET
78: .toString())) {
79: return PER_TARGET;
80: } else if (deploymentModelAsString.equalsIgnoreCase(PER_THIS
81: .toString())) {
82: return PER_THIS;
83: } else if (deploymentModelAsString.equalsIgnoreCase(PER_CFLOW
84: .toString())) {
85: return PER_CFLOW;
86: } else if (deploymentModelAsString
87: .equalsIgnoreCase(PER_CFLOWBELOW.toString())) {
88: return PER_CFLOWBELOW;
89: } else {
90: System.out
91: .println("AW::WARNING - no such deployment model ["
92: + deploymentModelAsString
93: + "] using default (perJVM)");
94: return PER_JVM; // falling back to default - PER_JVM
95: }
96: }
97: }
|