KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > appserv > server > LifecycleEventContextImpl


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  * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
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
32 package com.sun.appserv.server;
33
34 import javax.naming.InitialContext JavaDoc;
35 import java.util.logging.Logger JavaDoc;
36 import java.util.logging.Level JavaDoc;
37 import com.sun.logging.LogDomains;
38 import com.sun.enterprise.server.ServerContext;
39
40 /**
41  * ServerContext interface:
42  * the server-wide runtime environment created by ApplicationServer and shared
43  * by its subsystems such as the web container or EJB container.
44  */

45 public class LifecycleEventContextImpl implements LifecycleEventContext {
46     
47     private ServerContext ctx;
48
49     private static Logger JavaDoc logger = LogDomains.getLogger(LogDomains.ROOT_LOGGER);
50
51     /**
52      * public constructor
53      */

54     public LifecycleEventContextImpl(ServerContext ctx) {
55         this.ctx = ctx;
56     }
57     
58     /**
59      * Get the server command-line arguments
60      */

61     public String JavaDoc[] getCmdLineArgs() {
62         return ctx.getCmdLineArgs();
63     }
64     
65     /**
66      * Get server installation root
67      */

68     public String JavaDoc getInstallRoot() {
69         return ctx.getInstallRoot();
70     }
71     
72     /**
73      * Get the server instance name
74      */

75     public String JavaDoc getInstanceName() {
76         return ctx.getInstanceName();
77     }
78     
79     /**
80      * Get the initial naming context.
81      */

82     public InitialContext JavaDoc getInitialContext() {
83         return ctx.getInitialContext();
84     }
85
86     /**
87      * Writes the specified message to a server log file.
88      *
89      * @param msg a <code>String</code> specifying the
90      * message to be written to the log file
91      */

92     public void log(String JavaDoc message) {
93         logger.info(message);
94     }
95     
96     /**
97      * Writes an explanatory message and a stack trace
98      * for a given <code>Throwable</code> exception
99      * to the server log file.
100      *
101      * @param message a <code>String</code> that
102      * describes the error or exception
103      *
104      * @param throwable the <code>Throwable</code> error
105      * or exception
106      */

107     public void log(String JavaDoc message, Throwable JavaDoc throwable) {
108         logger.log(Level.INFO, message, throwable);
109     }
110 }
111
Popular Tags