User: user57
Date: 02/02/14 22:14:23
Added: src/main/org/jboss/util/platform Constants.java Java.java
PID.java package.html
Log:
o importing the useful bits from the bliss cl.
o plus some bits from server/*/util/* have been moved to util.jmx
Revision Changes Path
1.1 jboss-common/src/main/org/jboss/util/platform/Constants.java
Index: Constants.java
===================================================================
/***************************************
* *
* JBoss: The OpenSource J2EE WebOS *
* *
* Distributable under LGPL license. *
* See terms of license at gnu.org. *
* *
***************************************/
package org.jboss.util.platform;
import org.jboss.util.property.Property;
/**
* Platform constants.
*
* @version <tt>$Revision: 1.1 $</tt>
* @author <a href="mailto:[EMAIL PROTECTED]">Jason Dillon</a>
*/
public interface Constants
{
/** Platform dependent line separator. */
String LINE_SEPARATOR = Property.get("line.separator");
/** Platform dependant file separator. */
String FILE_SEPARATOR = Property.get("file.separator");
/** Platform dependant path separator. */
String PATH_SEPARATOR = Property.get("path.separator");
}
1.1 jboss-common/src/main/org/jboss/util/platform/Java.java
Index: Java.java
===================================================================
/***************************************
* *
* JBoss: The OpenSource J2EE WebOS *
* *
* Distributable under LGPL license. *
* See terms of license at gnu.org. *
* *
***************************************/
package org.jboss.util.platform;
import org.jboss.util.ThrowableHandler;
/**
* Provides common access to specifics about the version of <em>Java</em>
* that a virtual machine supports.
*
* <p>Determines the version of the <em>Java Virtual Machine</em> by checking
* for the availablity of version specific classes.<p>
*
* <p>Classes are loaded in the following order:
* <ol>
* <li><tt>java.lang.StackTraceElement</tt> was introduced in JDK 1.4</li>
* <li><tt>java.lang.StrictMath</tt> was introduced in JDK 1.3</li>
* <li><tt>java.lang.ThreadLocal</tt> was introduced in JDK 1.2</li>
* <li><tt>java.lang.Void</tt> was introduced in JDK 1.1</li>
* </ol>
* </p>
*
* @version <tt>$Revision: 1.1 $</tt>
* @author <a href="mailto:[EMAIL PROTECTED]">Jason Dillon</a>
*/
public final class Java
{
/** Prevent instantiation */
private Java() {}
/** Java version 1.0 token */
public static final int VERSION_1_0 = 0x01;
/** Java version 1.1 token */
public static final int VERSION_1_1 = 0x02;
/** Java version 1.2 token */
public static final int VERSION_1_2 = 0x03;
/** Java version 1.3 token */
public static final int VERSION_1_3 = 0x04;
/** Java version 1.4 token */
public static final int VERSION_1_4 = 0x05;
/**
* Private to avoid over optimization by the compiler.
*
* @see #getVersion() Use this method to access this final value.
*/
private static final int VERSION;
/** Initialize VERSION. */
static {
// default to 1.0
int version = VERSION_1_0;
try {
// check for 1.1
Class.forName("java.lang.Void");
version = VERSION_1_1;
// check for 1.2
Class.forName("java.lang.ThreadLocal");
version = VERSION_1_2;
// check for 1.3
Class.forName("java.lang.StrictMath");
version = VERSION_1_3;
// check for 1.4
Class.forName("java.lang.StackTraceElement");
version = VERSION_1_4;
}
catch (ClassNotFoundException e) {
ThrowableHandler.add(e);
}
VERSION = version;
}
/**
* Return the version of <em>Java</em> supported by the VM.
*
* @return The version of <em>Java</em> supported by the VM.
*/
public static int getVersion() {
return VERSION;
}
}
1.1 jboss-common/src/main/org/jboss/util/platform/PID.java
Index: PID.java
===================================================================
/***************************************
* *
* JBoss: The OpenSource J2EE WebOS *
* *
* Distributable under LGPL license. *
* See terms of license at gnu.org. *
* *
***************************************/
package org.jboss.util.platform;
import java.io.Serializable;
import java.util.Random;
/**
* Provides access to the process identifier for this virtual machine.
*
* <p>Currently does not support native access and generates random numbers
* for the process id.
*
* @version <tt>$Revision: 1.1 $</tt>
* @author <a href="mailto:[EMAIL PROTECTED]">Jason Dillon</a>
*/
public class PID
implements Serializable, Cloneable
{
/** The <tt>int</tt> process identifier. */
protected final int id;
/**
* Construct a new PID.
*
* @param id Process identifier.
*/
protected PID(final int id) {
this.id = id;
}
/**
* Get the <tt>int</tt> process identifier.
*
* @return <tt>int</tt> process identifier.
*/
public final int getID() {
return id;
}
/**
* Return a string representation of this PID.
*
* @return A string representation of this PID.
*/
public String toString() {
return String.valueOf(id);
}
/**
* Return a string representation of this PID.
*
* @return A string representation of this PID.
*/
public String toString(int radix) {
return Integer.toString(id, radix);
}
/**
* Return the hash code of this PID.
*
* @return The hash code of this PID.
*/
public int hashCode() {
return id;
}
/**
* Check if the given object is equal to this PID.
*
* @param obj Object to test equality with.
* @return True if object is equals to this PID.
*/
public boolean equals(final Object obj) {
if (obj == this) return true;
if (obj != null && obj.getClass() == getClass()) {
PID pid = (PID)obj;
return pid.id == id;
}
return false;
}
/**
* Returns a copy of this PID.
*
* @return A copy of this PID.
*/
public Object clone() {
try {
return super.clone();
}
catch (CloneNotSupportedException e) {
throw new InternalError();
}
}
/////////////////////////////////////////////////////////////////////////
// Instance Access //
/////////////////////////////////////////////////////////////////////////
/** The single instance of PID for the running Virtual Machine */
private static PID instance = null;
/**
* Get the PID for the current virtual machine.
*
* @return Process identifier.
*/
public synchronized static PID getInstance() {
if (instance == null) {
instance = create();
}
return instance;
}
/**
* Create the PID for the current virtual mahcine.
*
* @return Process identifier.
*/
private static PID create() {
// for now just return a random integer.
int random = Math.abs(new Random().nextInt());
return new PID(random);
}
}
1.1 jboss-common/src/main/org/jboss/util/platform/package.html
Index: package.html
===================================================================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<!-- $Id: package.html,v 1.1 2002/02/15 06:14:23 user57 Exp $ -->
<!--
JBoss: The OpenSource J2EE WebOS
Distributable under LGPL license.
See terms of license at gnu.org.
-->
</head>
<body bgcolor="white">
<p>Platform specific extentions to the <i>Java programming language</i>.</p>
<h2>Package Specification</h2>
<ul>
<li><a href="javascript: alert('not available')">Not Available</a>
</ul>
<h2>Related Documentation</h2>
<ul>
<li><a href="javascript: alert('not available')">Not Available</a>
</ul>
<h2>Package Status</h2>
<ul>
<li><font color="green"><b>STABLE</b></font>
</ul>
<h2>Todo</h2>
<ul>
<li>Add default implementation for PID that generates psuedo-pid-like
numbers
<li>Add native support for PID
</ul>
<!-- Put @see and @since tags down here. -->
</body>
</html>
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development