本文整理汇总了Java中org.apache.harmony.kernel.vm.VM.callerClassLoader方法的典型用法代码示例。如果您正苦于以下问题:Java VM.callerClassLoader方法的具体用法?Java VM.callerClassLoader怎么用?Java VM.callerClassLoader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.harmony.kernel.vm.VM
的用法示例。
在下文中一共展示了VM.callerClassLoader方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getUnsafe
import org.apache.harmony.kernel.vm.VM; //导入方法依赖的package包/类
/**
* <p>
* Retrieves an instance of this service.
* </p>
*
* @return An instance of Unsafe.
*/
public static Unsafe getUnsafe() {
/* Check that the caller of this method is in system code (i.e. on the
* bootclasspath). Unsafe methods are not designed to be called directly
* by applications. We assume that system code will not reveal the instance.
*/
if (VM.callerClassLoader() != null) {
throw new SecurityException("Unsafe");
}
return AccessController.doPrivileged(new PrivilegedAction<Unsafe>() {
public Unsafe run() {
return INSTANCE;
}
});
}
示例2: deregisterDriver
import org.apache.harmony.kernel.vm.VM; //导入方法依赖的package包/类
/**
* Removes a driver from the {@code DriverManager}'s registered driver list.
* This will only succeed when the caller's class loader loaded the driver
* that is to be removed. If the driver was loaded by a different class
* loader, the removal of the driver fails silently.
* <p>
* If the removal succeeds, the {@code DriverManager} will not use this
* driver in the future when asked to get a {@code Connection}.
*
* @param driver
* the JDBC driver to remove.
* @throws SQLException
* if there is a problem interfering with accessing the
* database.
*/
public static void deregisterDriver(Driver driver) throws SQLException {
if (driver == null) {
return;
}
ClassLoader callerClassLoader = VM.callerClassLoader();
if (!DriverManager.isClassFromClassLoader(driver, callerClassLoader)) {
// sql.1=DriverManager: calling class not authorized to deregister
// JDBC driver
throw new SecurityException(Messages.getString("sql.1")); //$NON-NLS-1$
} // end if
synchronized (theDrivers) {
theDrivers.remove(driver);
}
}
示例3: getDriver
import org.apache.harmony.kernel.vm.VM; //导入方法依赖的package包/类
/**
* Tries to find a driver that can interpret the supplied URL.
*
* @param url
* the URL of a database.
* @return a {@code Driver} that matches the provided URL. {@code null} if
* no {@code Driver} understands the URL
* @throws SQLException
* if there is any kind of problem accessing the database.
*/
public static Driver getDriver(String url) throws SQLException {
ClassLoader callerClassLoader = VM.callerClassLoader();
synchronized (theDrivers) {
/*
* Loop over the drivers in the DriverSet checking to see if one
* does understand the supplied URL - return the first driver which
* does understand the URL
*/
Iterator<Driver> theIterator = theDrivers.iterator();
while (theIterator.hasNext()) {
Driver theDriver = theIterator.next();
if (theDriver.acceptsURL(url)
&& DriverManager.isClassFromClassLoader(theDriver,
callerClassLoader)) {
return theDriver;
}
}
}
// If no drivers understand the URL, throw an SQLException
// sql.6=No suitable driver
// SQLState: 08 - connection exception
// 001 - SQL-client unable to establish SQL-connection
throw new SQLException(Messages.getString("sql.6"), "08001"); //$NON-NLS-1$ //$NON-NLS-2$
}
示例4: getDrivers
import org.apache.harmony.kernel.vm.VM; //导入方法依赖的package包/类
/**
* Returns an {@code Enumeration} that contains all of the loaded JDBC
* drivers that the current caller can access.
*
* @return An {@code Enumeration} containing all the currently loaded JDBC
* {@code Drivers}.
*/
public static Enumeration<Driver> getDrivers() {
ClassLoader callerClassLoader = VM.callerClassLoader();
/*
* Synchronize to avoid clashes with additions and removals of drivers
* in the DriverSet
*/
synchronized (theDrivers) {
/*
* Create the Enumeration by building a Vector from the elements of
* the DriverSet
*/
Vector<Driver> theVector = new Vector<Driver>();
Iterator<Driver> theIterator = theDrivers.iterator();
while (theIterator.hasNext()) {
Driver theDriver = theIterator.next();
if (DriverManager.isClassFromClassLoader(theDriver,
callerClassLoader)) {
theVector.add(theDriver);
}
}
return theVector.elements();
}
}
示例5: getDriver
import org.apache.harmony.kernel.vm.VM; //导入方法依赖的package包/类
/**
* Tries to find a driver that can interpret the supplied URL.
*
* @param url
* the URL of a database
* @return a Driver that can understand the given URL. null if no Driver
* understands the URL
* @throws SQLException
* if there is any kind of Database Access problem
*/
public static Driver getDriver(String url) throws SQLException {
ClassLoader callerClassLoader = VM.callerClassLoader();
synchronized (theDriverSet) {
/*
* Loop over the drivers in the DriverSet checking to see if one
* does understand the supplied URL - return the first driver which
* does understand the URL
*/
Iterator<Driver> theIterator = theDriverSet.iterator();
while (theIterator.hasNext()) {
Driver theDriver = theIterator.next();
if (theDriver.acceptsURL(url)
&& DriverManager.isClassFromClassLoader(theDriver,
callerClassLoader)) {
return theDriver;
}
}
}
// If no drivers understand the URL, throw an SQLException
// sql.6=No suitable driver
//SQLState: 08 - connection exception
//001 - SQL-client unable to establish SQL-connection
throw new SQLException(Messages.getString("sql.6"), "08001"); //$NON-NLS-1$ //$NON-NLS-2$
}
示例6: getDrivers
import org.apache.harmony.kernel.vm.VM; //导入方法依赖的package包/类
/**
* Returns an Enumeration that contains all of the loaded JDBC drivers that
* the current caller can access.
*
* @return An Enumeration containing all the currently loaded JDBC Drivers
*/
public static Enumeration<Driver> getDrivers() {
ClassLoader callerClassLoader = VM.callerClassLoader();
/*
* Synchronize to avoid clashes with additions and removals of drivers
* in the DriverSet
*/
synchronized (theDriverSet) {
/*
* Create the Enumeration by building a Vector from the elements of
* the DriverSet
*/
Vector<Driver> theVector = new Vector<Driver>();
Iterator<Driver> theIterator = theDriverSet.iterator();
while (theIterator.hasNext()) {
Driver theDriver = theIterator.next();
if (DriverManager.isClassFromClassLoader(theDriver,
callerClassLoader)) {
theVector.add(theDriver);
}
}
return theVector.elements();
}
}
示例7: deregisterDriver
import org.apache.harmony.kernel.vm.VM; //导入方法依赖的package包/类
/**
* Removes a driver from the DriverManager's registered driver list. This
* will only succeed where the caller's classloader loaded the driver that
* is to be removed. If the driver was loaded by a different classloader,
* the removal of the driver will fail silently.
* <p>
* If the removal succeeds, the DriverManager will not in future use this
* driver when asked to get a Connection.
*
* @param driver
* @throws SQLException
* if there is an exception accessing the database.
*/
public static void deregisterDriver(Driver driver) throws SQLException {
if (driver == null) {
return;
}
ClassLoader callerClassLoader = VM.callerClassLoader();
if (!DriverManager.isClassFromClassLoader(driver, callerClassLoader)) {
// sql.1=DriverManager: calling class not authorized to deregister JDBC driver
throw new SecurityException(Messages.getString("sql.1")); //$NON-NLS-1$
} // end if
synchronized (theDriverSet) {
theDriverSet.remove(driver);
}
}
示例8: OSComponent
import org.apache.harmony.kernel.vm.VM; //导入方法依赖的package包/类
/**
*
*/
public OSComponent() {
super();
if (VM.callerClassLoader() != null) {
throw new SecurityException();
}
}
示例9: accessCheck
import org.apache.harmony.kernel.vm.VM; //导入方法依赖的package包/类
/**
* Checks to ensure that whoever is asking for the OS component is running
* on the system classpath.
*/
private static final void accessCheck() {
if (VM.callerClassLoader() != null) {
throw new SecurityException();
}
}
示例10: accessCheck
import org.apache.harmony.kernel.vm.VM; //导入方法依赖的package包/类
private static final void accessCheck() {
if (VM.callerClassLoader() != null) {
throw new SecurityException();
}
}