01: /*
02: * Copyright 2005-2007 The Kuali Foundation.
03: *
04: *
05: * Licensed under the Educational Community License, Version 1.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * http://www.opensource.org/licenses/ecl1.php
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.kuali.rice.util;
18:
19: import java.io.PrintWriter;
20: import java.io.StringWriter;
21: import java.net.InetAddress;
22: import java.net.UnknownHostException;
23:
24: import org.kuali.rice.exceptions.RiceRuntimeException;
25:
26: /**
27: *
28: * @author Kuali Rice Team (kuali-rice@googlegroups.com)
29: */
30: public class RiceUtilities {
31:
32: public static String collectStackTrace(Throwable t) {
33: StringWriter sw = new StringWriter();
34: PrintWriter pw = new PrintWriter(sw);
35: t.printStackTrace(pw);
36: pw.close();
37: return sw.toString();
38: }
39:
40: public static String getIpNumber() {
41: try {
42: return InetAddress.getLocalHost().getHostAddress();
43: } catch (UnknownHostException e) {
44: throw new RiceRuntimeException(
45: "Error retrieving ip number.", e);
46: }
47: }
48:
49: public static String getHostName() {
50: try {
51: return InetAddress.getLocalHost().getHostName();
52: } catch (UnknownHostException e) {
53: throw new RiceRuntimeException(
54: "Error retrieving host name.", e);
55: }
56: }
57:
58: }
|