artifactprocessor.java
来自「开源的axis2框架的源码。用于开发WEBSERVER」· Java 代码 · 共 396 行 · 第 1/2 页
JAVA
396 行
if (faultBeanClassName != null && faultBeanClassName.length() > 0) {
try {
Class faultBean = loadClass(faultBeanClassName);
AnnotationDesc aDesc = AnnotationDescImpl.create(faultBean);
if (aDesc.hasXmlRootElement()) {
faultBeanNamespace = aDesc.getXmlRootElementNamespace();
}
} catch (Throwable t) {
ExceptionFactory.makeWebServiceException(t);
}
}
}
if (faultBeanNamespace == null || faultBeanNamespace.length() == 0) {
faultBeanNamespace = opDesc.getEndpointInterfaceDescription().getTargetNamespace();
}
return new FaultBeanDescImpl(
faultBeanClassName,
faultBeanLocalName,
faultBeanNamespace);
}
/**
* @param className
* @return package name
*/
private static String getPackageName(String className) {
int index = className.lastIndexOf(".");
if (index == 0) {
return "";
} else {
return className.substring(0, index);
}
}
/**
* @param className
* @return simple class name
*/
private static String getSimpleClassName(String className) {
int index = className.lastIndexOf(".");
if (index == 0) {
return className;
} else {
return className.substring(index + 1);
}
}
/**
* @param methodName
* @return method name converted into a class name
*/
private static String javaMethodToClassName(String methodName) {
String className = null;
if (methodName != null) {
StringBuffer buildClassName = new StringBuffer(methodName);
buildClassName.replace(0, 1, methodName.substring(0, 1).toUpperCase());
className = buildClassName.toString();
}
return className;
}
/**
* This method is invoked if the artifact is missing
*
* @param artifactName
* @return newly constructed name or null
*/
private String missingArtifact(String artifactName) {
// TODO Could we contstruct a proxy of the artifact at this point ?
if (log.isDebugEnabled()) {
log.debug("The following class is missing: " + artifactName + " Processing continues.");
}
return null;
}
/**
* Determine the actual packager name for the generated artifacts by trying to load the class
* from one of two packages. This is necessary because the RI implementations of WSGen and
* WSImport generate the artifacts in different packages: - WSImport generates the artifacts in
* the same package as the SEI - WSGen generates the artifacts in a "jaxws" sub package under
* the SEI package. Note that from reading the JAX-WS spec, it seems that WSGen is doing that
* correctly; See the conformance requirement in JAX-WS 2.0 Spec Section 3.6.2.1 Document
* Wrapped on page 36: Conformance (Default wrapper bean package): In the absence of
* customizations, the wrapper beans package MUST be a generated jaxws subpackage of the SEI
* package. ^^^^^^^^^^^^^^^^
*
* @param artifactClassName
* @return
*/
static final String JAXWS_SUBPACKAGE = "jaxws";
private static String findArtifact(String artifactClassName) {
String returnArtifactClassName = null;
if (artifactClassName == null) {
return returnArtifactClassName;
}
// Try to load the class that was passed in
try {
loadClass(artifactClassName);
returnArtifactClassName = artifactClassName;
}
catch (ClassNotFoundException e) {
// Couldn't load the class; we'll try another one below.
}
// If the original class couldn't be loaded, try adding ".jaxws." to the package
if (returnArtifactClassName == null) {
String originalPackage = getPackageName(artifactClassName);
if (originalPackage.length() > 0) {
String alternatePackage = originalPackage + "." + JAXWS_SUBPACKAGE;
String className = getSimpleClassName(artifactClassName);
String alternateWrapperClass = alternatePackage + "." + className;
try {
loadClass(alternateWrapperClass);
returnArtifactClassName = alternateWrapperClass;
}
catch (ClassNotFoundException e) {
// Couldn't load the class
}
}
}
return returnArtifactClassName;
}
private static Class loadClass(String className) throws ClassNotFoundException {
// Don't make this public, its a security exposure
return forName(className, true, getContextClassLoader());
}
/**
* Return the class for this name
*
* @return Class
*/
private static Class forName(final String className, final boolean initialize,
final ClassLoader classloader) throws ClassNotFoundException {
// NOTE: This method must remain protected because it uses AccessController
Class cl = null;
try {
cl = (Class)AccessController.doPrivileged(
new PrivilegedExceptionAction() {
public Object run() throws ClassNotFoundException {
// Class.forName does not support primitives
Class cls = ClassUtils.getPrimitiveClass(className);
try{
if (cls == null) {
cls = Class.forName(className, initialize, classloader);
}
return cls;
//Lets catch NoClassDefFoundError as its part of Throwable
//Any Exception that extends Exception will be handled by doPriv method.
} catch (NoClassDefFoundError e) {
// TODO Should the exception be swallowed ?
if (log.isDebugEnabled()) {
log.debug("ArtifactProcessor cannot load the following class NoClassDefFoundError:" + className);
}
}
return cls;
}
}
);
} catch (PrivilegedActionException e) {
if (log.isDebugEnabled()) {
log.debug("Exception thrown from AccessController: " + e);
}
throw (ClassNotFoundException)e.getException();
}
return cl;
}
/** @return ClassLoader */
private static ClassLoader getContextClassLoader() {
// NOTE: This method must remain private because it uses AccessController
ClassLoader cl = null;
try {
cl = (ClassLoader)AccessController.doPrivileged(
new PrivilegedExceptionAction() {
public Object run() throws ClassNotFoundException {
return Thread.currentThread().getContextClassLoader();
}
}
);
} catch (PrivilegedActionException e) {
if (log.isDebugEnabled()) {
log.debug("Exception thrown from AccessController: " + e);
}
throw (RuntimeException)e.getException();
}
return cl;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?