public static void ImportFunctions(IScriptContext ctx, string @namespace, object obj) { Type clazz = null; if (obj is Type) { clazz = (Type)obj; } else if (obj is string) { try { clazz = ReflectUtil.LoadClass((string)obj); } catch (ProcessEngineException ae) { throw new ELException(ae); } } else { throw new ELException("Class or class name is missing"); } MethodInfo[] methods = clazz.GetMethods(); foreach (MethodInfo m in methods) { //int mod = m..GetModifiers(); //if (Modifier.isStatic(mod) && Modifier.isPublic(mod)) if (m.IsStatic && m.IsPublic) { string name = @namespace + ":" + m.Name; ctx.SetAttribute(name, m, ScriptContext_Fields.ENGINE_SCOPE); } } }
protected internal virtual void CreateItemDefinitions(BpmnModel bpmnModel) { foreach (ItemDefinition itemDefinitionElement in bpmnModel.ItemDefinitions.Values) { if (!itemDefinitionMap.ContainsKey(itemDefinitionElement.Id)) { IStructureDefinition structure = null; try { // it is a class Type classStructure = ReflectUtil.LoadClass(itemDefinitionElement.StructureRef); structure = new ClassStructureDefinition(classStructure); } catch (ActivitiException) { // it is a reference to a different structure structure = structureDefinitionMap[itemDefinitionElement.StructureRef]; } Datas.ItemDefinition itemDefinition = new Datas.ItemDefinition(itemDefinitionElement.Id, structure); if (!string.IsNullOrWhiteSpace(itemDefinitionElement.ItemKind)) { itemDefinition.ItemKind = (ItemKind)Enum.Parse(typeof(ItemKind), itemDefinitionElement.ItemKind); } itemDefinitionMap[itemDefinition.Id] = itemDefinition; } } }
// Activity Behavior public override void Execute(IActivityExecution execution) { var scope = Context.CommandContext.Scope; var type = ReflectUtil.LoadClass(_className); object clazz; if (scope.IsRegistered(type)) { clazz = scope.Resolve(type); } else { clazz = ReflectUtil.Instantiate(_className); } if (type != null) { //execution.SetVariableLocal(_className,clazz); MethodInfo m = ReflectUtil.GetMethod(type, _methodName); if (m == null) { throw Log.MissingClassException(_className); } PerformExecution(execution, m, clazz); return; } throw Log.MissingClassException(_className); }
public void TestClassNameToType() { var type = ReflectUtil.LoadClass("ESS.FW.Bpm.Engine.Tests.Bpmn.Event.IntermediateNoneEventTest+MyExecutionListener"); Assert.AreNotEqual(null, type); var type_2 = ReflectUtil.LoadClass("ESS.FW.Bpm.Engine.Impl.Delegate.DefaultDelegateInterceptor,ESS.FW.Bpm.Engine"); Assert.AreNotEqual(null, type_2); }
public virtual object GetJPAEntity(string className, string idString) { Type entityClass = ReflectUtil.LoadClass(className); EntityMetaData metaData = GetEntityMetaData(entityClass); // Create primary key of right type object primaryKey = CreateId(metaData, idString); return(FindEntity(entityClass, primaryKey)); }
protected internal static void InitProcessEngineFromSpringResource(Uri resource) { try { var springConfigurationHelperClass = ReflectUtil.LoadClass("org.camunda.bpm.engine.test.spring.SpringConfigurationHelper"); var method = springConfigurationHelperClass.GetMethod("buildProcessEngine", new[] { typeof(Uri) }); var processEngine = (IProcessEngine)method.Invoke(null, new object[] { resource }); var processEngineName = processEngine.Name; IProcessEngineInfo processEngineInfo = new ProcessEngineInfoImpl(processEngineName, resource.ToString(), null); ProcessEngineInfosByName[processEngineName] = processEngineInfo; ProcessEngineInfosByResourceUrl[resource.ToString()] = processEngineInfo; } catch (System.Exception e) { throw new ProcessEngineException( "couldn't initialize process engine from spring configuration resource " + resource + ": " + e.Message, e); } }
protected internal static string FindMatchingExceptionMapping(Exception e, IList <MapExceptionEntry> exceptionMap) { string defaultExceptionMapping = null; foreach (MapExceptionEntry me in exceptionMap) { string exceptionClass = me.ClassName; string errorCode = me.ErrorCode; // save the first mapping with no exception class as default map if (!string.IsNullOrWhiteSpace(errorCode) && string.IsNullOrWhiteSpace(exceptionClass) && defaultExceptionMapping is null) { defaultExceptionMapping = errorCode; continue; } // ignore if error code or class are not defined if (string.IsNullOrWhiteSpace(errorCode) || string.IsNullOrWhiteSpace(exceptionClass)) { continue; } if (e.GetType().FullName.Equals(exceptionClass)) { return(errorCode); } if (me.AndChildren) { Type exceptionClassClass = ReflectUtil.LoadClass(exceptionClass); if (exceptionClassClass.IsAssignableFrom(e.GetType())) { return(errorCode); } } } return(defaultExceptionMapping); }