当前位置: 首页>>代码示例>>Java>>正文


Java Loader.loadClass方法代码示例

本文整理汇总了Java中org.apache.axis2.util.Loader.loadClass方法的典型用法代码示例。如果您正苦于以下问题:Java Loader.loadClass方法的具体用法?Java Loader.loadClass怎么用?Java Loader.loadClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.axis2.util.Loader的用法示例。


在下文中一共展示了Loader.loadClass方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processTargetResolvers

import org.apache.axis2.util.Loader; //导入方法依赖的package包/类
private void processTargetResolvers(AxisConfiguration axisConfig, OMElement targetResolvers) {
    if (targetResolvers != null) {
        Iterator iterator = targetResolvers.getChildrenWithName(new QName(TAG_TARGET_RESOLVER));
        while (iterator.hasNext()) {
            OMElement targetResolver = (OMElement) iterator.next();
            OMAttribute classNameAttribute =
                    targetResolver.getAttribute(new QName(TAG_CLASS_NAME));
            String className = classNameAttribute.getAttributeValue();
            try {
                Class classInstance = Loader.loadClass(className);
                TargetResolver tr = (TargetResolver) classInstance.newInstance();
                axisConfig.addTargetResolver(tr);
            } catch (Exception e) {
                if (log.isTraceEnabled()) {
                    log.trace(
                            "processTargetResolvers: Exception thrown initialising TargetResolver: " +
                                    e.getMessage());
                }
            }
        }
    }
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:23,代码来源:AxisConfigBuilder.java

示例2: getLocation

import org.apache.axis2.util.Loader; //导入方法依赖的package包/类
/**
 * To get the location of the Axis2.jar from that I can drive the location of class path
 *
 * @return String (location of the axis2 jar)
 */
protected String getLocation() {
    try {
        Class clazz = Loader.loadClass("org.apache.axis2.engine.AxisEngine");
        java.net.URL url = clazz.getProtectionDomain().getCodeSource().getLocation();
        String location = url.toString();
        if (location.startsWith("jar")) {
            url = ((java.net.JarURLConnection)url.openConnection()).getJarFileURL();
            location = url.toString();
        }
        if (location.startsWith("file")) {
            File file = Utils.toFile(url);
            return file.getAbsolutePath();
        } else {
            return url.toString();
        }
    } catch (Throwable t) {
        return null;
    }
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:25,代码来源:RepositoryListener.java

示例3: initService

import org.apache.axis2.util.Loader; //导入方法依赖的package包/类
/**
 * To init all the services in application scope
 *
 * @param serviceGroupContext the ServiceGroupContext from which to extract all the services
 * @throws AxisFault if there's a problem initializing
 */
public static void initService(ServiceGroupContext serviceGroupContext) throws AxisFault {
    AxisServiceGroup serviceGroup = serviceGroupContext.getDescription();
    Iterator<AxisService> serviceItr = serviceGroup.getServices();
    while (serviceItr.hasNext()) {
        AxisService axisService = (AxisService) serviceItr.next();
        ServiceContext serviceContext = serviceGroupContext.getServiceContext(axisService);
        AxisService service = serviceContext.getAxisService();
        ClassLoader classLoader = service.getClassLoader();
        Parameter implInfoParam = service.getParameter(Constants.SERVICE_CLASS);
        if (implInfoParam != null) {
            try {
            	ThreadContextDescriptor tc = setThreadContext(axisService);
                Class implClass = Loader.loadClass(
                        classLoader,
                        ((String) implInfoParam.getValue()).trim());
                Object serviceImpl = makeNewServiceObject(service);
                serviceContext.setProperty(ServiceContext.SERVICE_OBJECT, serviceImpl);
                initServiceObject(serviceImpl, serviceContext);
                restoreThreadContext(tc);
            } catch (Exception e) {
                throw AxisFault.makeFault(e);
            }
        }
    }
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:32,代码来源:DependencyManager.java

示例4: createAxisService

import org.apache.axis2.util.Loader; //导入方法依赖的package包/类
protected AxisService createAxisService(ClassLoader classLoader,
                                      String className,
                                      URL serviceLocation) throws ClassNotFoundException,
        InstantiationException,
        IllegalAccessException,
        AxisFault {
    Class<?> pojoClass = Loader.loadClass(classLoader, className);
    AxisService axisService;
    try {
        axisService = DescriptionFactory.createAxisService(pojoClass, configCtx);
    } catch (Throwable t) {
        log.info("Exception creating Axis Service : " + t.getCause(), t);
        return null;
    }
    if (axisService != null) {
        Iterator<AxisOperation> operations = axisService.getOperations();
        while (operations.hasNext()) {
            AxisOperation axisOperation = operations.next();
            if (axisOperation.getMessageReceiver() == null) {
                axisOperation.setMessageReceiver(new JAXWSMessageReceiver());
            }
        }
        axisService.addParameter("serviceType", "jaxws");
        axisService.setElementFormDefault(false);
        axisService.setFileName(serviceLocation);
        axisService.setClassLoader(classLoader);
        axisService.addParameter(new Parameter(org.apache.axis2.jaxws.spi.Constants.CACHE_CLASSLOADER, classLoader));
        axisService.addParameter(new Parameter("modifyUserWSDLPortAddress", "true"));
    }
    return axisService;
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:32,代码来源:JAXWSDeployer.java

示例5: createAxisServiceUsingAnnogen

import org.apache.axis2.util.Loader; //导入方法依赖的package包/类
private AxisService createAxisServiceUsingAnnogen(String className,
                                                  ClassLoader classLoader,
                                                  URL serviceLocation)
        throws ClassNotFoundException,
        InstantiationException,
        IllegalAccessException,
        AxisFault {
    HashMap<String,MessageReceiver> messageReciverMap = new HashMap<String,MessageReceiver>();
    Class<?> inOnlyMessageReceiver = Loader.loadClass(
            "org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver");
    MessageReceiver messageReceiver =
            (MessageReceiver) inOnlyMessageReceiver.newInstance();
    messageReciverMap.put(WSDL2Constants.MEP_URI_IN_ONLY,
            messageReceiver);
    Class<?> inoutMessageReceiver = Loader.loadClass(
            "org.apache.axis2.rpc.receivers.RPCMessageReceiver");
    MessageReceiver inOutmessageReceiver =
            (MessageReceiver) inoutMessageReceiver.newInstance();
    messageReciverMap.put(WSDL2Constants.MEP_URI_IN_OUT,
            inOutmessageReceiver);
    messageReciverMap.put(WSDL2Constants.MEP_URI_ROBUST_IN_ONLY,
            inOutmessageReceiver);
    AxisService axisService =
            AxisService.createService(className,
                    configCtx.getAxisConfiguration(),
                    messageReciverMap,
                    null, null,
                    classLoader);
    axisService.setFileName(serviceLocation);
    return axisService;
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:32,代码来源:POJODeployer.java

示例6: processAttachmentsLifecycleManager

import org.apache.axis2.util.Loader; //导入方法依赖的package包/类
private void processAttachmentsLifecycleManager(AxisConfiguration axisConfig, OMElement element) {
    String className = element.getAttributeValue(new QName(TAG_CLASS_NAME));
    try {
        Class classInstance = Loader.loadClass(className);
        LifecycleManager manager = (LifecycleManager) classInstance.newInstance();
        axisConfig.addParameter(DeploymentConstants.ATTACHMENTS_LIFECYCLE_MANAGER, manager);
    } catch (Exception e) {
        if (log.isTraceEnabled()) {
            log.trace(
                    "processAttachmentsLifecycleManager: Exception thrown initialising LifecycleManager: " +
                            e.getMessage());
        }
    }
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:15,代码来源:AxisConfigBuilder.java

示例7: getPhase

import org.apache.axis2.util.Loader; //导入方法依赖的package包/类
private Phase getPhase(String className)
        throws ClassNotFoundException, IllegalAccessException, InstantiationException {
    if (className == null) {
        return new Phase();
    }
    Class phaseClass = Loader.loadClass(axisConfig.getSystemClassLoader(), className);
    return (Phase) phaseClass.newInstance();
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:9,代码来源:AxisConfigBuilder.java

示例8: loadObjectSupplierClass

import org.apache.axis2.util.Loader; //导入方法依赖的package包/类
private void loadObjectSupplierClass(String objectSupplierValue)
		throws AxisFault {
	try {
		ClassLoader loader = service.getClassLoader();
		Class objectSupplierImpl = Loader.loadClass(loader,
				objectSupplierValue.trim());
		ObjectSupplier objectSupplier = (ObjectSupplier) objectSupplierImpl
				.newInstance();
		service.setObjectSupplier(objectSupplier);
	} catch (Exception e) {
		throw AxisFault.makeFault(e);
	}
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:14,代码来源:ServiceBuilder.java

示例9: loadServiceLifeCycleClass

import org.apache.axis2.util.Loader; //导入方法依赖的package包/类
private void loadServiceLifeCycleClass(String className)
		throws DeploymentException {
       if (className != null) {
           try {
               ClassLoader loader = service.getClassLoader();
               Class serviceLifeCycleClassImpl = Loader.loadClass(loader,
					className);
               ServiceLifeCycle serviceLifeCycle =
                       (ServiceLifeCycle) serviceLifeCycleClassImpl.newInstance();
			service.setServiceLifeCycle(serviceLifeCycle);
		} catch (Exception e) {
			throw new DeploymentException(e.getMessage(), e);
		}
	}
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:16,代码来源:ServiceBuilder.java

示例10: getHandlerClass

import org.apache.axis2.util.Loader; //导入方法依赖的package包/类
private static Class getHandlerClass(String className, ClassLoader loader1)
        throws AxisFault {
    Class handlerClass;

    try {
        handlerClass = Loader.loadClass(loader1, className);
    } catch (ClassNotFoundException e) {
        throw AxisFault.makeFault(e);
    }

    return handlerClass;
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:13,代码来源:Utils.java

示例11: createService

import org.apache.axis2.util.Loader; //导入方法依赖的package包/类
/**
 * To create an AxisService using given service impl class name first
 * generate schema corresponding to the given java class , next for each
 * methods AxisOperation will be created. If the method is in-out it will
 * uses RPCMessageReceiver else RPCInOnlyMessageReceiver <p/> Note : Inorder
 * to work this properly RPCMessageReceiver should be available in the class
 * path otherewise operation can not continue
 * 
 * @param implClass
 *            Service implementation class
 * @param axisConfig
 *            Current AxisConfiguration
 * @return return created AxisSrevice the creted service , it can either be
 *         null or valid service
 */
public static AxisService createService(String implClass,
		AxisConfiguration axisConfig) throws AxisFault {

	try {
		HashMap<String, MessageReceiver> messageReciverMap = new HashMap<String, MessageReceiver>();
		Class inOnlyMessageReceiver = Loader
				.loadClass("org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver");
		MessageReceiver messageReceiver = (MessageReceiver) inOnlyMessageReceiver
				.newInstance();
		messageReciverMap.put(WSDL2Constants.MEP_URI_IN_ONLY,
				messageReceiver);
		Class inoutMessageReceiver = Loader
				.loadClass("org.apache.axis2.rpc.receivers.RPCMessageReceiver");
		MessageReceiver inOutmessageReceiver = (MessageReceiver) inoutMessageReceiver
				.newInstance();
		messageReciverMap.put(WSDL2Constants.MEP_URI_IN_OUT,
				inOutmessageReceiver);
		messageReciverMap.put(WSDL2Constants.MEP_URI_ROBUST_IN_ONLY,
				inOutmessageReceiver);

		return createService(implClass, axisConfig, messageReciverMap,
				null, null, axisConfig.getSystemClassLoader());
	} catch (Exception e) {
		throw AxisFault.makeFault(e);
	}
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:42,代码来源:AxisService.java

示例12: testDeployment

import org.apache.axis2.util.Loader; //导入方法依赖的package包/类
public void testDeployment() {
    try {
        String filename = AbstractTestCase.basedir + "/target/test-resources/deployment";
        AxisConfiguration er = ConfigurationContextFactory
                .createConfigurationContextFromFileSystem(filename, filename + "/axis2.xml")
                .getAxisConfiguration();

        assertNotNull(er);
        AxisService service = er.getService("service2");
        assertNotNull(service);
        //commentd since there is no service based messageReceivers
        /*MessageReceiver provider = service.getMessageReceiver();
      assertNotNull(provider);
      assertTrue(provider instanceof RawXMLINOutMessageReceiver);*/
        ClassLoader cl = service.getClassLoader();
        assertNotNull(cl);
        Loader.loadClass(cl, "org.apache.axis2.Echo2");
        assertNotNull(service.getName());
        assertNotNull(service.getParameter("para2"));

        AxisOperation op = service.getOperation(new QName("opname"));
        assertNotNull(op);
    } catch (Exception e) {
       fail(e.getMessage());
    }

}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:28,代码来源:BuildERWithDeploymentTest.java

示例13: processDeployers

import org.apache.axis2.util.Loader; //导入方法依赖的package包/类
private void processDeployers(Iterator deployerItr) {
    Map<String, Map<String, Deployer>> deployers = new HashMap<String, Map<String, Deployer>>();
    while (deployerItr.hasNext()) {
        OMElement element = (OMElement) deployerItr.next();
        String directory = element.getAttributeValue(new QName(DIRECTORY));
        if (directory == null) {
            log.error("Deployer missing 'directory' attribute : " + element.toString());
            continue;
        }

        String extension = element.getAttributeValue(new QName(EXTENSION));
        if (extension == null) {
            log.error("Deployer missing 'extension' attribute : " + element.toString());
            continue;
        }

        // A leading dot is redundant, so strip it.  So we allow either ".foo" or "foo", either
        // of which will result in extension="foo"
        if (extension.charAt(0) == '.') extension = extension.substring(1);

        String deployerClassName = element.getAttributeValue(new QName(TAG_CLASS_NAME));
        Deployer deployer;
        try {
            Class deployerClass = Loader.loadClass(deployerClassName);
            deployer = (Deployer) deployerClass.newInstance();
        } catch (UnsupportedClassVersionError ex) {
            log.info("Disabled - " + deployerClassName + " - " + ex.getMessage());
            continue;
        } catch (Throwable e) {
            log.warn("Unable to instantiate deployer " + deployerClassName +
                    "; see debug logs for more details");
            log.debug(e.getMessage(), e);
            continue;
        }
        deployer.setDirectory(directory);
        deployer.setExtension(extension);
        
        Map<String, Deployer> extensionMap = deployers.get(directory);
        if (extensionMap == null) {
            extensionMap = new HashMap<String, Deployer>();
            deployers.put(directory, extensionMap);
        }
        extensionMap.put(extension, deployer);
    }
    if (deploymentEngine != null) {
        deploymentEngine.setDeployers(deployers);
    }
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:49,代码来源:AxisConfigBuilder.java


注:本文中的org.apache.axis2.util.Loader.loadClass方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。