KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > admin > server > core > AdminChannelLifecycle


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.server.core;
25
26 import java.util.*;
27
28 import com.sun.appserv.server.ServerLifecycleException;
29 import com.sun.appserv.server.ServerLifecycle;
30 import com.sun.appserv.server.ServerLifecycleImpl;
31 import com.sun.enterprise.admin.server.core.channel.AdminChannel;
32
33 import com.sun.enterprise.server.ServerContext;
34
35 import java.util.logging.*;
36 import com.sun.logging.LogDomains;
37
38
39 /**
40  * Lifecycle that manages the RMI server that communicates with clients.
41  */

42 public class AdminChannelLifecycle extends ServerLifecycleImpl {
43
44     private static final int NOTINITIALIZED = 0;
45     private static final int INITIALIZED = 1;
46     private static final int READY = 2;
47     private static final int SHUTDOWN = 3;
48
49     private static int status = NOTINITIALIZED;
50
51     /**
52      * Server is Inililize the AdminChannel.
53      *
54      * @exception ServerLifecycleException if this subsystem detects a fatal
55      * error that prevents this subsystem from being used
56      */

57     public void onInitialization(ServerContext context)
58         throws ServerLifecycleException {
59         if (status < INITIALIZED) {
60             status = INITIALIZED;
61             AdminChannel.createRMIChannel();
62             AdminChannel.createSharedSecret();
63         }
64     }
65
66     /**
67      * Server is ready.
68      *
69      * @exception ServerLifecycleException if this subsystem detects a fatal
70      * error that prevents this subsystem from being used
71      */

72     public void onReady(ServerContext context)
73         throws ServerLifecycleException {
74         if (status < READY) {
75             status = READY;
76             AdminChannel.setRMIChannelReady();
77         }
78     }
79
80     /**
81      * Server is shutting down applications
82      *
83      * @exception ServerLifecycleException if this subsystem detects a fatal
84      * error that prevents this subsystem from being used
85      */

86     public void onShutdown()
87         throws ServerLifecycleException {
88         if (status < SHUTDOWN) {
89             status = SHUTDOWN;
90             AdminChannel.setRMIChannelStopping();
91             AdminChannel.destroyRMIChannel();
92         }
93     }
94
95     /**
96      * Server startup has failed. This could be due to a port conflict exception.
97      * In case of port conflict exception, port will be >0. Set the RMI channel server
98      * status to kInstanceFailed.
99      * @param port portnumber
100      */

101     public void onAbort(int port)
102         throws ServerLifecycleException {
103         AdminChannel.setRMIChannelAborting(port);
104     }
105
106 }
107
108
Popular Tags