KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > server > event > EjbContainerEvent


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 /*
25  * @(#) ApplicationLoaderEventListener.java
26  *
27  * Copyright 2000-2001 by iPlanet/Sun Microsystems, Inc.,
28  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
29  * All rights reserved.
30  *
31  * This software is the confidential and proprietary information
32  * of iPlanet/Sun Microsystems, Inc. ("Confidential Information").
33  * You shall not disclose such Confidential Information and shall
34  * use it only in accordance with the terms of the license
35  * agreement you entered into with iPlanet/Sun Microsystems.
36  */

37 package com.sun.enterprise.server.event;
38
39 import com.sun.enterprise.deployment.EjbDescriptor;
40
41     /*
42      * An EjbContainerEvent is generated whenever an EjbContainer
43      * is loaded / unloaded.
44      *
45      * EjbContainerEvent.getEventType() specifies the exact
46      * EjbContainer event.
47      *
48      * Generally, EjbContainer Events are sent in the following order
49      * a) BEFORE_EJB_CONTAINER_LOADED
50      * b) AFTER_EJB_CONTAINER_LOADED
51      * c) BEFORE_EJB_CONTAINER_UNLOADED
52      * d) AFTER_EJB_CONTAINER_UNLOADED
53      *
54      */

55 public class EjbContainerEvent {
56
57     public static final int BEFORE_EJB_CONTAINER_LOAD = 20;
58     public static final int AFTER_EJB_CONTAINER_LOAD = 21;
59     public static final int BEFORE_EJB_CONTAINER_UNLOAD = 22;
60     public static final int AFTER_EJB_CONTAINER_UNLOAD = 23;
61
62     private int eventType;
63     private EjbDescriptor ejbDescriptor;
64     private ClassLoader JavaDoc loader;
65
66     public EjbContainerEvent(int eventType, EjbDescriptor ejbDescriptor,
67         ClassLoader JavaDoc loader)
68     {
69     this.eventType = eventType;
70     this.ejbDescriptor = ejbDescriptor;
71     this.loader = loader;
72     }
73     
74     public int getEventType() {
75     return this.eventType;
76     }
77
78     public EjbDescriptor getEjbDescriptor() {
79     return this.ejbDescriptor;
80     }
81
82     public ClassLoader JavaDoc getClassLoader() {
83     return this.loader;
84     }
85
86     public String JavaDoc toString() {
87     StringBuffer JavaDoc sbuf = new StringBuffer JavaDoc("EjbEvent: ");
88     switch (eventType) {
89         case BEFORE_EJB_CONTAINER_LOAD:
90         sbuf.append("BEFORE_LOAD -> ");
91         break;
92         case AFTER_EJB_CONTAINER_LOAD:
93         sbuf.append("AFTER_LOAD -> ");
94         break;
95         case BEFORE_EJB_CONTAINER_UNLOAD:
96         sbuf.append("BEFORE_UNLOAD -> ");
97         break;
98         case AFTER_EJB_CONTAINER_UNLOAD:
99         sbuf.append("AFTER_UNLOAD -> ");
100         break;
101         default:
102         //
103
}
104
105     if (ejbDescriptor != null) {
106         sbuf.append(ejbDescriptor.getName());
107     }
108
109     return sbuf.toString();
110     }
111
112 }
113
Popular Tags