KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > admin > event > SecurityServiceEvent


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
24 package com.sun.enterprise.admin.event;
25
26 import com.sun.enterprise.admin.event.AdminEvent;
27
28 //i18n import
29
import com.sun.enterprise.util.i18n.StringManager;
30
31 /**
32  * Security Service Event - emitted by DAS after comletion of
33  * create/delete/update operation on security-service element
34  * (not including subelements changes)
35  * Contains action type.
36  */

37 public class SecurityServiceEvent extends AdminEvent {
38
39     /**
40      * Constant denoting action code
41      */

42     public static final int ACTION_CREATE = 1;
43     public static final int ACTION_DELETE = 2;
44     public static final int ACTION_UPDATE = 3;
45
46     /**
47      * Event type
48      */

49     static final String JavaDoc eventType = SecurityServiceEvent.class.getName();
50
51     /**
52      * Attributes
53      */

54     private int actionType;
55
56     // i18n StringManager
57
private static StringManager localStrings = StringManager.getManager( SecurityServiceEvent.class );
58
59     /**
60      * Create a new SecurityServiceEvent.
61      * @param type event type, a string representation for the event
62      * @param instance name of the instance to which the event applies
63      * @param action type of action - one of SecurityServiceEvent.ACTION_CREATE,
64      * SecurityServiceEvent.ACTION_DELETE, SecurityServiceEvent.ACTION_UPDATE
65      * @throws IllegalArgumentException if specified action is not valid
66      */

67     public SecurityServiceEvent(String JavaDoc instance, int action) {
68         this(eventType, instance, action);
69     }
70
71     /**
72      * Create a new SecurityServiceEvent.
73      * @param type event type, a string representation for the event
74      * @param instance name of the instance to which the event applies
75      * @param action type of action - one of SecurityServiceEvent.ACTION_CREATE,
76      * SecurityServiceEvent.ACTION_DELETE, SecurityServiceEvent.ACTION_UPDATE
77      * @throws IllegalArgumentException if specified action is not valid
78      */

79     public SecurityServiceEvent(String JavaDoc type, String JavaDoc instance, int action) {
80         super(type, instance);
81         setAction(action);
82     }
83
84     /**
85      * Get action type for this event.
86      */

87     public int getActionType() {
88         return actionType;
89     }
90
91     /**
92      * Set action to specified value. If action is not one of allowed,
93      * then IllegalArgumentException is thrown.
94      * @throws IllegalArgumentException if action is invalid
95      */

96     private void setAction(int action) {
97         boolean valid = false;
98         if (action==ACTION_CREATE ||
99             action==ACTION_DELETE ||
100             action==ACTION_UPDATE )
101             valid = true;
102         if (!valid) {
103             String JavaDoc msg = localStrings.getString( "admin.event.invalid_action", ""+action );
104             throw new IllegalArgumentException JavaDoc( msg );
105         }
106         this.actionType = action;
107     }
108
109 }
110
Popular Tags