List of usage examples for java.lang ClassLoader toString
public String toString()
From source file:org.apache.axis2.context.AbstractContext.java
/** * Debug for for property key and value. * @param key//from w w w . ja v a2 s . c o m * @param value */ private void debugPropertySet(String key, Object value) { if (DEBUG_ENABLED) { String className = (value == null) ? "null" : value.getClass().getName(); String classloader = "null"; if (value != null) { ClassLoader cl = Utils.getObjectClassLoader(value); if (cl != null) { classloader = cl.toString(); } } String valueText = (value instanceof String) ? value.toString() : null; String identity = getClass().getName() + '@' + Integer.toHexString(System.identityHashCode(this)); log.debug("=================="); log.debug(" Property set on object " + identity); log.debug(" Key =" + key); if (valueText != null) { log.debug(" Value =" + valueText); } log.debug(" Value Class = " + className); log.debug(" Value Classloader = " + classloader); if (this.DEBUG_CALLSTACK_ON_SET) { log.debug("Call Stack = " + JavaUtils.callStackToString()); } log.debug("=================="); } }
From source file:org.apache.axis2.description.ParameterIncludeImpl.java
/** * Debug for for property key and value. * @param key//from w w w . j a va2 s . c om * @param value */ private void debugParameterAdd(Parameter parameter) { if (DEBUG_PROPERTY_SET) { String key = parameter.getName(); Object value = parameter.getValue(); String className = (value == null) ? "null" : value.getClass().getName(); String classloader = "null"; if (value != null) { ClassLoader cl = Utils.getObjectClassLoader(value); if (cl != null) { classloader = cl.toString(); } } String valueText = (value instanceof String) ? value.toString() : null; String identity = getClass().getName() + '@' + Integer.toHexString(System.identityHashCode(this)); log.debug("=================="); log.debug(" Parameter add on object " + identity); log.debug(" Key =" + key); if (valueText != null) { log.debug(" Value =" + valueText); } log.debug(" Value Class = " + className); log.debug(" Value Classloader = " + classloader); log.debug("Call Stack = " + JavaUtils.callStackToString()); log.debug("=================="); } }
From source file:org.apache.axis2.description.ParameterIncludeMixin.java
/** * Debug for for property key and value. * @param key//from ww w .j av a 2s. c om * @param value */ private void debugParameterAdd(Parameter parameter) { if (log.isDebugEnabled()) { String key = parameter.getName(); Object value = parameter.getValue(); String className = (value == null) ? "null" : value.getClass().getName(); String classloader = "null"; if (value != null) { ClassLoader cl = Utils.getObjectClassLoader(value); if (cl != null) { classloader = cl.toString(); } } String valueText = (value instanceof String) ? value.toString() : null; String identity = getClass().getName() + '@' + Integer.toHexString(System.identityHashCode(this)); log.debug("=================="); log.debug(" Parameter add on object " + identity); log.debug(" Key =" + key); if (valueText != null) { log.debug(" Value =" + valueText); } log.debug(" Value Class = " + className); log.debug(" Value Classloader = " + classloader); log.debug("Call Stack = " + JavaUtils.callStackToString()); log.debug("=================="); } }
From source file:org.apache.axis2.jaxws.client.async.AsyncResponse.java
/** * Check for a valid relationship between unmarshalling classloader and * Application's current context classloader * @param cl/*w ww . j ava 2s .c o m*/ * @param contextCL */ private void checkClassLoader(final ClassLoader cl, final ClassLoader contextCL) { // Ensure that the classloader (cl) used for unmarshalling is the same // or a parent of the current context classloader. Otherwise // ClassCastExceptions can occur if (log.isDebugEnabled()) { log.debug("AsyncResponse ClassLoader is:"); log.debug(cl.toString()); } if (cl.equals(contextCL)) { if (log.isDebugEnabled()) { log.debug("AsyncResponse ClassLoader matches Context ClassLoader"); } return; } else { if (log.isDebugEnabled()) { log.debug("Context ClassLoader is:"); log.debug(contextCL.toString()); } ClassLoader parent = getParentClassLoader(contextCL); while (parent != null) { if (parent.equals(cl)) { return; } if (log.isDebugEnabled()) { log.debug("AsyncResponse ClassLoader is an ancestor of the Context ClassLoader"); } parent = getParentClassLoader(parent); } } throw ExceptionFactory.makeWebServiceException(Messages.getMessage("threadClsLoaderErr", contextCL.getClass().toString(), cl.getClass().toString())); }
From source file:org.apache.axis2.jaxws.client.async.CallbackFuture.java
@SuppressWarnings("unchecked") public Object call() throws Exception { ClassLoader oldCL = null; try {/* w w w . jav a2s . co m*/ if (log.isDebugEnabled()) { log.debug("Setting up the thread's context classLoader"); log.debug(handlerCL.toString()); } // Retrieve the existing classloader from the thread. oldCL = (ClassLoader) AccessController.doPrivileged(new PrivilegedAction() { public Object run() { return Thread.currentThread().getContextClassLoader(); } }); AccessController.doPrivileged(new PrivilegedAction() { public Object run() { Thread.currentThread().setContextClassLoader(handlerCL); return null; } }); // Set the response or fault content on the AsyncResponse object // so that it can be collected inside the Executor thread and processed. if (error != null) { response.onError(error, msgCtx, handlerCL); } else { response.onComplete(msgCtx, handlerCL); } // Now that the content is available, call the JAX-WS AsyncHandler class // to deliver the response to the user. if (debug) { log.debug("Calling JAX-WS AsyncHandler.handleResponse() with response object: " + CallbackFuture.displayHandle(response)); } handler.handleResponse(response); if (debug) { log.debug("Returned from handleResponse() invocation..."); } } catch (Throwable t) { if (debug) { log.debug("An error occurred while invoking the callback object."); log.debug("Error: " + t.toString()); t.printStackTrace(); } } finally { synchronized (this) { // Restore the old classloader on this thread. if (oldCL != null) { final ClassLoader t = oldCL; AccessController.doPrivileged(new PrivilegedAction() { public Object run() { Thread.currentThread().setContextClassLoader(t); return null; } }); if (debug) { log.debug("Restored thread context classloader: " + oldCL.toString()); } } done = true; this.notifyAll(); } } return null; }
From source file:org.apache.axis2.jaxws.description.builder.DescriptionBuilderUtils.java
/** * Load a class represented in a Description Builder Composite. If a classloader is specified, * it will be used; otherwise the default classloader is used. * * @param classToLoad// w w w. j av a2 s . c om * @param classLoader * @return */ static Class loadClassFromComposite(String classToLoad, ClassLoader classLoader) { Class returnClass = null; // If this is an array, then create a string version as described by Class.getName. // For example, "Foo[][]" becomes "[[LFoo". Note that arrays of primitives must also be parsed. classToLoad = DescriptionBuilderUtils.reparseIfArray(classToLoad); if (classLoader != null) { // Use the specified classloader to load the class. try { returnClass = forName(classToLoad, false, classLoader); } //Catch Throwable as ClassLoader can throw an NoClassDefFoundError that //does not extend Exception, so lets catch everything that extends Throwable //rather than just Exception. catch (Throwable ex) { throw ExceptionFactory.makeWebServiceException( Messages.getMessage("DBUClassNotFound", classToLoad, classLoader.toString())); } } else { //Use the thread context class loader to load the class. try { returnClass = forName(classToLoad, false, getContextClassLoader(null)); } catch (Throwable ex) { //Use the default classloader to load the class. try { returnClass = forName(classToLoad); } //Catch Throwable as ClassLoader can throw an NoClassDefFoundError that //does not extend Exception catch (Throwable ex2) { throw ExceptionFactory .makeWebServiceException(Messages.getMessage("DBUClassNotFound2", classToLoad)); } } } return returnClass; }
From source file:org.apache.falcon.util.HdfsClassLoader.java
public static ClassLoader load(final String name, final List<String> jarHdfsPath) throws IOException { LOG.info("ClassLoader cache size = " + classLoaderCache.size()); if (classLoaderCache.containsKey(name)) { return classLoaderCache.get(name); }/*from w w w . j a v a2 s.c om*/ synchronized (LOCK) { LOG.info("Copying jar files from HDFS to local dir"); final URL[] urls = copyHdfsJarFilesToTempDir(name, jarHdfsPath); final ClassLoader parentClassLoader = HdfsClassLoader.class.getClassLoader(); LOG.info("Creating a new HdfsClassLoader for name = {0} with parent = {1} using classpath = {2}", name, parentClassLoader.toString(), Arrays.toString(jarHdfsPath.toArray())); HdfsClassLoader hdfsClassLoader = java.security.AccessController .doPrivileged(new java.security.PrivilegedAction<HdfsClassLoader>() { @Override public HdfsClassLoader run() { return new HdfsClassLoader(name, urls, parentClassLoader); } }); classLoaderCache.put(name, hdfsClassLoader); return hdfsClassLoader; } }
From source file:org.apache.hadoop.sqoop.util.ClassLoaderStack.java
/** * Sets the classloader for the current thread *//*from w ww . ja v a2 s. co m*/ public static void setCurrentClassLoader(ClassLoader cl) { LOG.info("Restoring classloader: " + cl.toString()); Thread.currentThread().setContextClassLoader(cl); }
From source file:org.carracoo.maven.assist.AssistProcessor.java
private void debugClassLoader(final ClassPool classPool) { if (!logger.isLoggable(Level.INFO)) { return;/*from www.j a v a 2 s . co m*/ } logger.log(Level.FINE, String.format(" - classPool: %s", classPool.toString())); ClassLoader classLoader = classPool.getClassLoader(); while (classLoader != null) { logger.log(Level.INFO, String.format(" -- %s : %s", classLoader.getClass().getName(), classLoader.toString())); if (classLoader instanceof URLClassLoader) { logger.log(Level.INFO, String.format(" --- urls: %s ", Arrays.deepToString(((URLClassLoader) classLoader).getURLs()))); } classLoader = classLoader.getParent(); } }
From source file:org.ebayopensource.turmeric.tools.codegen.AbstractServiceGeneratorTestCase.java
private void dumpClassLoader(String indent, ClassLoader cl) { if (cl == null) { return;/* w w w .j a v a2 s. c o m*/ } System.out.printf("%sClassLoader: %s: %s%n", indent, cl.getClass().getName(), cl.toString()); if (cl instanceof URLClassLoader) { URLClassLoader ucl = (URLClassLoader) cl; System.out.printf("%s(URLClassLoader)%n", indent); URL urls[] = ucl.getURLs(); for (URL url : urls) { System.out.printf("%s* %s%n", indent, url); } } ClassLoader parent = cl.getParent(); dumpClassLoader(indent + " ", parent); }