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


Java PythonException类代码示例

本文整理汇总了Java中org.xdi.exception.PythonException的典型用法代码示例。如果您正苦于以下问题:Java PythonException类的具体用法?Java PythonException怎么用?Java PythonException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: createExternalType

import org.xdi.exception.PythonException; //导入依赖的package包/类
private BaseExternalType createExternalType(CustomScript customScript, Map<String, SimpleCustomProperty> configurationAttributes) {
	String customScriptInum = customScript.getInum();

	BaseExternalType externalType;
	try {
		externalType = createExternalTypeFromStringWithPythonException(customScript, configurationAttributes);
	} catch (PythonException ex) {
		log.error("Failed to prepare external type '{}'", ex, customScriptInum);
		return null;
	}

	if (externalType == null) {
		log.debug("Using default external type class");
		externalType = customScript.getScriptType().getDefaultImplementation();
	}

	return externalType;
}
 
开发者ID:GluuFederation,项目名称:oxCore,代码行数:19,代码来源:CustomScriptManager.java

示例2: loadPythonScript

import org.xdi.exception.PythonException; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private <T> T loadPythonScript(String scriptPythonType, Class<T> scriptJavaType, PyObject[] constructorArgs, PythonInterpreter interpreter)
		throws PythonException {
	PyObject scriptPythonTypeObject = interpreter.get(scriptPythonType);
       if (scriptPythonTypeObject == null) {
       	return null;
       }
       

       PyObject scriptPythonTypeClass;
       try {
       	scriptPythonTypeClass = scriptPythonTypeObject.__call__(constructorArgs);
	} catch (Exception ex) {
		log.error("Failed to initialize python class", ex.getMessage());
		throw new PythonException(String.format("Failed to initialize python class '%s'", scriptPythonType), ex);
	}

       Object scriptJavaClass = scriptPythonTypeClass.__tojava__(scriptJavaType);
       if (!ReflectHelper.assignableFrom(scriptJavaClass.getClass(), scriptJavaType)) {
       	return null;

       }

       return (T) scriptJavaClass;
}
 
开发者ID:GluuFederation,项目名称:oxCore,代码行数:26,代码来源:PythonService.java

示例3: createExternalTypeFromStringWithPythonException

import org.xdi.exception.PythonException; //导入依赖的package包/类
public BaseExternalType createExternalTypeFromStringWithPythonException(CustomScript customScript, Map<String, SimpleCustomProperty> configurationAttributes) throws PythonException {
	String script = customScript.getScript();
	if (script == null) {
		return null;
	}

	CustomScriptType customScriptType = customScript.getScriptType();
	BaseExternalType externalType = null;

	InputStream bis = null;
	try {
           bis = new ByteArrayInputStream(script.getBytes("UTF-8"));
           externalType = pythonService.loadPythonScript(bis, customScriptType.getPythonClass(),
           		customScriptType.getCustomScriptType(), new PyObject[] { new PyLong(System.currentTimeMillis()) });
	} catch (UnsupportedEncodingException e) {
           log.error(e.getMessage(), e);
       } finally {
		IOUtils.closeQuietly(bis);
	}

	if (externalType == null) {
		return null;
	}

	boolean initialized = false;
	try {
		initialized = externalType.init(configurationAttributes);
	} catch (Exception ex) {
           log.error("Failed to initialize custom script: '{}'", ex, customScript.getName());
	}

	if (initialized) {
		return externalType;
	}
	
	return null;
}
 
开发者ID:GluuFederation,项目名称:oxCore,代码行数:38,代码来源:CustomScriptManager.java


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