KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > appserv > management > base > OperationStatusBase


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23 package com.sun.appserv.management.base;
24
25 import java.util.Map JavaDoc;
26 import java.io.Serializable JavaDoc;
27
28 import com.sun.appserv.management.util.misc.ThrowableMapper;
29
30 /**
31     Base class for OperationStatus.
32  */

33
34 public class OperationStatusBase
35     extends MapCapableBase
36     implements OperationStatus
37 {
38     
39     /**
40         Create a new instance which represents the appropriate class.
41         
42         @param m a Map representing the appropriate class
43         @param className the class which the Map represents
44      */

45         public <T extends Serializable JavaDoc>
46     OperationStatusBase(
47         final Map JavaDoc<String JavaDoc,T> m,
48         final String JavaDoc className )
49     {
50         super( m, className );
51     }
52     
53     
54         protected boolean
55     validate()
56     {
57         // nothing to do for now
58
return( true );
59     }
60     
61     /**
62         @return the status code from the operation
63      */

64         public int
65     getStatusCode()
66     {
67         int statusCode = STATUS_CODE_FAILURE;
68         
69         final Integer JavaDoc code = getInteger( STATUS_CODE_KEY );
70         if ( code != null )
71         {
72             statusCode = code.intValue();
73         }
74         else
75         {
76             statusCode = getThrowable() != null ?
77                     STATUS_CODE_FAILURE : STATUS_CODE_SUCCESS;
78         }
79         
80         return( statusCode );
81     }
82     
83     /**
84         set the status code for the operation
85      */

86         public void
87     setStatusCode( final int statusCode )
88     {
89         putField( STATUS_CODE_KEY, new Integer JavaDoc( statusCode ) );
90     }
91     
92     
93     /**
94         @return a Throwable for the operation, or null if none
95      */

96         public Throwable JavaDoc
97     getThrowable()
98     {
99         return( (Throwable JavaDoc)getObject( THROWABLE_KEY ) );
100     }
101     
102     
103     /**
104         Set the Throwable for the operation, which may be null.
105      */

106         public void
107     setThrowable( final Throwable JavaDoc t)
108     {
109         final Throwable JavaDoc conforming = new ThrowableMapper( t ).map();
110         
111         putField( THROWABLE_KEY, conforming );
112     }
113     
114     
115 }
116
117
118
119
120
121
122
123
124
Popular Tags