001:/*
002: * The contents of this file are subject to the Sapient Public License
003: * Version 1.0 (the "License"); you may not use this file except in compliance
004: * with the License. You may obtain a copy of the License at
005: * http://carbon.sf.net/License.html.
006: *
007: * Software distributed under the License is distributed on an "AS IS" basis,
008: * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
009: * the specific language governing rights and limitations under the License.
010: *
011: * The Original Code is The Carbon Component Framework.
012: *
013: * The Initial Developer of the Original Code is Sapient Corporation
014: *
015: * Copyright (C) 2003 Sapient Corporation. All Rights Reserved.
016: */
017:
018:package org.sape.carbon.services.management.interceptor;
019:
020:import java.io.ObjectStreamException;
021:import java.io.Serializable;
022:
023:import javax.management.MBeanOperationInfo;
024:
025:import org.sape.carbon.core.util.enum.BaseEnum;
026:import org.sape.carbon.core.util.enum.EnumNotFoundException;
027:
028:/**
029: * Maps to the JMX severities of an Operation that are labeled in
030: * @{link javax.management.MBeanOperationInfo}.
031: *
032: * Copyright 2002 Sapient
033: * @since carbon 1.1
034: * @author Greg Hinkle, October 2002
035: * @version $Revision: 1.6 $($Author: dvoet $ / $Date: 2003/05/05 21:21:33 $)
036: */
037:public class MBeanOperationImpactEnum extends BaseEnum implements Serializable {
038:
039: /**
040: * Action: Operations that change the state of some part of the system
041: */
042: public static final MBeanOperationImpactEnum ACTION =
043: new MBeanOperationImpactEnum("Action", MBeanOperationInfo.ACTION);
044:
045: /**
046: * Action & Info: Operations taht both change the state of the system
047: * as well as reveal that state.
048: */
049: public static final MBeanOperationImpactEnum ACTION_INFO =
050: new MBeanOperationImpactEnum("Action_Info",
051: MBeanOperationInfo.ACTION_INFO);
052:
053: /**
054: * Info: Operations that purely expose the state of something in the system,
055: * but in no way change it.
056: */
057: public static final MBeanOperationImpactEnum INFO =
058: new MBeanOperationImpactEnum("Info", MBeanOperationInfo.INFO);
059:
060: /**
061: * Unknown: Describes an impact that is unknown
062: */
063: public static final MBeanOperationImpactEnum UKNOWN =
064: new MBeanOperationImpactEnum("Uknown", MBeanOperationInfo.UNKNOWN);
065:
066:
067: /**
068: * Constructs a enumeration of type <code>LifecycleStateEnum</code>
069: * @param name the name of the enumeration instance to create
070: * @param ordinal the ordinal of the enumeration instance
071: */
072: private MBeanOperationImpactEnum(String name, int ordinal) {
073: super (MBeanOperationImpactEnum.class, name, ordinal);
074: }
075:
076:
077: /**
078: * Returns the library constant for the impact number.
079: * @return the int impact number for an operation impact
080: * @since carbon 1.1
081: */
082: public int getImpactConstant() {
083: if (this .equals(MBeanOperationImpactEnum.ACTION)) {
084: return MBeanOperationInfo.ACTION;
085: } else if (this .equals(MBeanOperationImpactEnum.ACTION_INFO)) {
086: return MBeanOperationInfo.ACTION_INFO;
087: } else if (this .equals(MBeanOperationImpactEnum.INFO)) {
088: return MBeanOperationInfo.INFO;
089: } else {
090: return MBeanOperationInfo.UNKNOWN;
091: }
092: }
093:
094: /**
095: * Strongly typed enum retriever
096: * @see BaseEnum#getByName
097: */
098: public static final MBeanOperationImpactEnum getByName(String name)
099: throws MBeanOperationImpactEnumNotFoundException {
100: return (MBeanOperationImpactEnum)
101: BaseEnum.getByName(name, MBeanOperationImpactEnum.class);
102: }
103:
104: /**
105: * Strongly typed enum retriever
106: * @see BaseEnum#getByOrdinal
107: */
108: public static final MBeanOperationImpactEnum getByOrdinal(int ordinal)
109: throws MBeanOperationImpactEnumNotFoundException {
110:
111: return (MBeanOperationImpactEnum)
112: BaseEnum.getByOrdinal(ordinal, MBeanOperationImpactEnum.class);
113: }
114:
115: /**
116: * Overrides part of serialization to return a reference to an existing
117: * static Enumeration
118: *
119: * @see BaseEnum#readResolve
120: */
121: final Object readResolve() throws ObjectStreamException {
122: return super .getByOrdinal(this .ordinal, this .getClass());
123: }
124:
125:
126: /**
127: * This class is a typesafe retriever exception for an enumeration
128: */
129: public class MBeanOperationImpactEnumNotFoundException
130: extends EnumNotFoundException {
131: /**
132: * Constructor for MBeanOperationImpactEnumNotFoundException.
133: * @param sourceClass the class in which this exception was generated
134: * @param name the name of the enumerated type not found
135: */
136: public MBeanOperationImpactEnumNotFoundException(
137: Class sourceClass,
138: String name) {
139: super(sourceClass, name);
140: }
141:
142: }
143:
144:
145:}
|