KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mr > core > cmc > CMCCommand


1 /*
2  * Copyright 2002 by
3  * <a HREF="http://www.coridan.com">Coridan</a>
4  * <a HREF="mailto: support@coridan.com ">support@coridan.com</a>
5  *
6  * The contents of this file are subject to the Mozilla Public License Version
7  * 1.1 (the "License"); you may not use this file except in compliance with the
8  * License. You may obtain a copy of the License at
9  * http://www.mozilla.org/MPL/
10  *
11  * Software distributed under the License is distributed on an "AS IS" basis,
12  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13  * for the specific language governing rights and limitations under the
14  * License.
15  *
16  * The Original Code is "MantaRay" (TM).
17  *
18  * The Initial Developer of the Original Code is Amir Shevat.
19  * Portions created by the Initial Developer are Copyright (C) 2006
20  * Coridan Inc. All Rights Reserved.
21  *
22  * Contributor(s): all the names of the contributors are added in the source
23  * code where applicable.
24  *
25  * Alternatively, the contents of this file may be used under the terms of the
26  * LGPL license (the "GNU LESSER GENERAL PUBLIC LICENSE"), in which case the
27  * provisions of LGPL are applicable instead of those above. If you wish to
28  * allow use of your version of this file only under the terms of the LGPL
29  * License and not to allow others to use your version of this file under
30  * the MPL, indicate your decision by deleting the provisions above and
31  * replace them with the notice and other provisions required by the LGPL.
32  * If you do not delete the provisions above, a recipient may use your version
33  * of this file under either the MPL or the GNU LESSER GENERAL PUBLIC LICENSE.
34  
35  *
36  * This library is free software; you can redistribute it and/or modify it
37  * under the terms of the MPL as stated above or under the terms of the GNU
38  * Lesser General Public License as published by the Free Software Foundation;
39  * either version 2.1 of the License, or any later version.
40  *
41  * This library is distributed in the hope that it will be useful, but WITHOUT
42  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
43  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
44  * License for more details.
45  */

46 /*
47  * Created on Dec 18, 2003
48  *
49  * the supper class of all manegment commands
50  */

51 package org.mr.core.cmc;
52
53 import org.apache.commons.logging.Log;
54 import org.apache.commons.logging.LogFactory;
55
56 /**
57  * CMCCommand
58  * @author Amir Shevat
59  *
60  */

61 public abstract class CMCCommand {
62     public Log log;
63     
64     public CMCCommand(){
65         log=LogFactory.getLog("CMCCommand");
66     }
67     /**
68      * this is where it all happends implamets this method get the arguments from the request and return the response
69      * @param req this method gets the arguments from this object
70      * @return this response will be send as payload to the other side
71      */

72     public abstract CMCResponse doCommand(CMCRequest req);
73     /**
74      * a shot name of the command
75      * @return e.g. "get stress factor"
76      */

77     public abstract String JavaDoc getName();
78     /**
79      * this command Answers to this name in the registar
80      * @return e.g. "getStressFactor"
81      */

82     public abstract String JavaDoc getRegisterName();
83     /**
84      * if this method accepts arguments in the CMCRequest else 0
85      */

86     public abstract int getNumberOfArguments();
87     /**
88      * the Description of the arguments or null if getNumberOfArguments
89      * @return e.g. "property name", "new property value"
90      */

91     public abstract String JavaDoc[] getArgumentsDescription();
92     /**
93      * a description of this command
94      * @return e.g. "Sets the property to the new value and bla bla bla ..."
95      */

96     public abstract String JavaDoc getDescription();
97     /**
98      * a role object representing all the roles that are autorized to invoke doCommand
99      * @return a combination of roles e.g. CMCRole(CMCRole.mantaAdmin).addRole(CMCRole.domainControllerAdmin)
100      */

101     public CMCRole getAuthorizedRoles(){
102          return new CMCRole(CMCRole.mantaAdmin);
103     }
104     
105     public String JavaDoc toString(){
106         StringBuffer JavaDoc buff = new StringBuffer JavaDoc();
107         buff.append("\r\nManagnemt command: ");
108         buff.append(getRegisterName());
109         buff.append("\r\nName: ");
110         buff.append(getName());
111         buff.append("\r\nDescription: ");
112         buff.append(getDescription());
113         buff.append("\r\nNumber Of Arguments: ");
114         buff.append(getNumberOfArguments());
115         
116         for(int count =0 ; count < getNumberOfArguments(); count++){
117             buff.append("\r\nArguments number "+(count+1)+" Description: ");
118             buff.append(getArgumentsDescription()[count]);
119         }
120         buff.append("\r\n");
121         return buff.toString();
122     }
123     
124     
125     
126     
127     
128
129 }
130
Popular Tags