Methods Summary |
---|
protected java.lang.Class | findClass(java.lang.String className)
final byte[] cd = getClassData(className);
if (cd == null)
throw new ClassNotFoundException(CMBStrings.get("findClassFailed", className));
return ( defineClass(className, cd, 0, cd.length) );
|
protected java.net.URL | findResource(java.lang.String name)
File searchResource = new File(url.getFile(), name);
URL result = null;
if ( searchResource.exists() )
{
try
{
return searchResource.toURL();
}
catch (MalformedURLException mfe)
{
}
}
return result;
|
private byte[] | getClassData(java.lang.String cn)
byte[] cd = null;
try {
if(isURLFile()) {
cd = getClassDataFromFile(url.getFile(), cn);
} else {
cd = getClassDataFromURL();
}
} catch(final Exception e) {
// the caller will throw a ClassNotFoundException
}
return ( cd );
|
private byte[] | getClassDataFromFile(java.lang.String base, java.lang.String cn)
String path = base + '/" + cn.replace('.", '/") + ".class";
path = prunePath(path);
final FileInputStream fis = new FileInputStream(path);
final BufferedInputStream bis = new BufferedInputStream(fis);
final ByteArrayOutputStream bos = new ByteArrayOutputStream();
byte[] cd = null;
try {
byte[] buf = new byte[1024]; // reading several bytes
int br = bis.read(buf, 0, buf.length);
while (br != -1) {
bos.write(buf, 0, br);
br = bis.read(buf, 0, buf.length);
}
cd = bos.toByteArray();
} catch(final FileNotFoundException fe) {
throw fe;
} catch (final IOException e) {
throw e;
} finally {
try {
//This is the single most important item in loading the classes!
bis.close();
bos.close();
} catch(Throwable t) {}
return ( cd );
}
|
private byte[] | getClassDataFromURL()
throw new UnsupportedOperationException(CMBStrings.get("InternalError", "getClassDataFromURL() -- not implemented yet"));
|
private java.io.File | getDefaultMBeanDirectory()
/* Ideally, PEFileLayout should be utilized here which should be the central place
* to get all these paths, locations. But that is too cryptic to find out. Hence
* I am relying on the properties that are passed to the VM at startup.
* These properties include the SystemPropertyConstants.INSTANCE_ROOT which always
* points to where the server instance or domain configuration is stored.
*/
final File appsFolder = new File(System.getProperty(SystemPropertyConstants.INSTANCE_ROOT_PROPERTY), PEFileLayout.APPLICATIONS_DIR);
return ( new File(appsFolder, PEFileLayout.MBEAN_FOLDER_NAME) );
|
private void | init()
try {
final File mbf = getDefaultMBeanDirectory();
this.url = mbf.toURL();
} catch (final MalformedURLException m) {
String msg = CMBStrings.get("cmb.classloader.init", m.getLocalizedMessage());
throw new CustomMBeanException(msg, m);
}
|
private boolean | isURLFile()
return ( "file".equals(url.getProtocol()) );
|
private java.lang.String | prunePath(java.lang.String path)
/* don't know why url.toFile has got a leading '/' on Windows */
if (OS.isWindows() && path.charAt(0) == '/") {
return ( path.substring(1) );
}
else
return ( path ) ;
|