KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > codehaus > aspectwerkz > DeploymentModel


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 org.codehaus.aspectwerkz;
9
10 import org.codehaus.aspectwerkz.exception.DefinitionException;
11
12 /**
13  * Enum containing the different deployment model types.
14  *
15  * @author <a HREF="mailto:jboner@codehaus.org">Jonas BonŽr </a>
16  */

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 JavaDoc m_name;
28
29     private DeploymentModel(String JavaDoc name) {
30         m_name = name;
31     }
32
33     public String JavaDoc toString() {
34         return m_name;
35     }
36
37     public boolean equals(Object JavaDoc 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 JavaDoc deploymentModelAsString) {
56         if (deploymentModelAsString == null || deploymentModelAsString.equals("")) {
57             return PER_JVM; // default is PER_JVM
58
}
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; // falling back to default - PER_JVM
78
}
79     }
80 }
Popular Tags