/// <summary> /// If the base object is not null, returns the current value of the given property on this bean. /// If the base is not null, the propertyResolved property of the ELContext object must be set to /// true by this resolver, before returning. If this property is not true after this method is /// called, the caller should ignore the return value. The provided property name will first be /// coerced to a String. If the property is a readable property of the base object, as per the /// JavaBeans specification, then return the result of the getter call. If the getter throws an /// exception, it is propagated to the caller. If the property is not found or is not readable, a /// PropertyNotFoundException is thrown. /// </summary> /// <param name="context"> /// The context of this evaluation. </param> /// <param name="base"> /// The bean to analyze. </param> /// <param name="property"> /// The name of the property to analyze. Will be coerced to a String. </param> /// <returns> If the propertyResolved property of ELContext was set to true, then the value of the /// given property. Otherwise, undefined. </returns> /// <exception cref="NullPointerException"> /// if context is null </exception> /// <exception cref="PropertyNotFoundException"> /// if base is not null and the specified property does not exist or is not readable. </exception> /// <exception cref="ELException"> /// if an exception was thrown while performing the property or variable resolution. /// The thrown exception must be included as the cause property of this exception, if /// available. </exception> public override object getValue(ELContext context, object @base, object property) { if (context == null) { throw new System.NullReferenceException(); } object result = null; if (isResolvable(@base)) { System.Reflection.MethodInfo method = toBeanProperty(@base, property).ReadMethod; if (method == null) { throw new PropertyNotFoundException("Cannot read property " + property); } try { result = method.invoke(@base); } catch (InvocationTargetException e) { throw new ELException(e.InnerException); } catch (Exception e) { throw new ELException(e); } context.PropertyResolved = true; } return(result); }
public static void applyProperty(object configuration, string key, string stringValue) { Type configurationClass = configuration.GetType(); System.Reflection.MethodInfo setter = ReflectUtil.getSingleSetter(key, configurationClass); if (setter != null) { try { Type parameterClass = setter.ParameterTypes[0]; object value = PropertyHelper.convertToClass(stringValue, parameterClass); setter.invoke(configuration, value); } catch (Exception e) { //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getCanonicalName method: throw LOG.cannotSetValueForProperty(key, configurationClass.FullName, e); } } else { //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getCanonicalName method: throw LOG.cannotFindSetterForProperty(key, configurationClass.FullName); } }
public static void applyFieldDeclaration(FieldDeclaration declaration, object target) { System.Reflection.MethodInfo setterMethod = ReflectUtil.getSetter(declaration.Name, target.GetType(), declaration.Value.GetType()); if (setterMethod != null) { try { setterMethod.invoke(target, declaration.Value); } catch (Exception e) { //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method: throw LOG.exceptionWhileApplyingFieldDeclatation(declaration.Name, target.GetType().FullName, e); } } else { System.Reflection.FieldInfo field = ReflectUtil.getField(declaration.Name, target); //JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method: ensureNotNull("Field definition uses unexisting field '" + declaration.Name + "' on class " + target.GetType().FullName, "field", field); // Check if the delegate field's type is correct if (!fieldTypeCompatible(declaration, field)) { throw LOG.incompatibleTypeForFieldDeclaration(declaration, target, field); } ReflectUtil.setField(field, target, declaration.Value); } }
public override object invoke(Bindings bindings, ELContext context, Type returnType, Type[] paramTypes, object[] paramValues) { object @base = prefix.eval(bindings, context); if (@base == null) { throw new PropertyNotFoundException(LocalMessages.get("error.property.base.null", prefix)); } object property = getProperty(bindings, context); if (property == null && strict) { throw new PropertyNotFoundException(LocalMessages.get("error.property.method.notfound", "null", @base)); } string name = bindings.convert(property, typeof(string)); System.Reflection.MethodInfo method = findMethod(name, @base.GetType(), returnType, paramTypes); try { return(method.invoke(@base, paramValues)); } catch (IllegalAccessException) { throw new ELException(LocalMessages.get("error.property.method.access", name, @base.GetType())); } catch (System.ArgumentException e) { throw new ELException(LocalMessages.get("error.property.method.invocation", name, @base.GetType()), e); } catch (InvocationTargetException e) { throw new ELException(LocalMessages.get("error.property.method.invocation", name, @base.GetType()), e.InnerException); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: static SingleByteConversion acquireSingleByteConversion(int ccsid) throws java.io.UnsupportedEncodingException internal static SingleByteConversion acquireSingleByteConversion(int ccsid) { // Attempt to find the shipped table using reflection SingleByteConversion singleByteConversion = null; Type conversionClass = null; try { conversionClass = Type.GetType("com.ibm.jtopenlite.ccsidConversion.CCSID" + ccsid); Type[] emptyParameterTypes = new Type[0]; System.Reflection.MethodInfo method = conversionClass.GetMethod("getInstance", emptyParameterTypes); object[] args = new object[0]; singleByteConversion = (SingleByteConversion)method.invoke(null, args); } catch (ClassNotFoundException exceptionCause) { // // TODO: Download tables from the server. // UnsupportedEncodingException ex = new UnsupportedEncodingException("CCSID=" + ccsid); ex.initCause(exceptionCause); throw ex; } catch (Exception exceptionCause) { UnsupportedEncodingException ex = new UnsupportedEncodingException("CCSID=" + ccsid); ex.initCause(exceptionCause); throw ex; } ccsidToSingleByteConversion[ccsid] = singleByteConversion; return(singleByteConversion); }
/// <summary> /// If the base object is not null, attempts to set the value of the given property on this bean. /// If the base is not null, the propertyResolved property of the ELContext object must be set to /// true by this resolver, before returning. If this property is not true after this method is /// called, the caller can safely assume no value was set. If this resolver was constructed in /// read-only mode, this method will always throw PropertyNotWritableException. The provided /// property name will first be coerced to a String. If property is a writable property of base /// (as per the JavaBeans Specification), the setter method is called (passing value). If the /// property exists but does not have a setter, then a PropertyNotFoundException is thrown. If /// the property does not exist, a PropertyNotFoundException is thrown. /// </summary> /// <param name="context"> /// The context of this evaluation. </param> /// <param name="base"> /// The bean to analyze. </param> /// <param name="property"> /// The name of the property to analyze. Will be coerced to a String. </param> /// <param name="value"> /// The value to be associated with the specified key. </param> /// <exception cref="NullPointerException"> /// if context is null </exception> /// <exception cref="PropertyNotFoundException"> /// if base is not null and the specified property does not exist or is not readable. </exception> /// <exception cref="PropertyNotWritableException"> /// if this resolver was constructed in read-only mode, or if there is no setter for /// the property </exception> /// <exception cref="ELException"> /// if an exception was thrown while performing the property or variable resolution. /// The thrown exception must be included as the cause property of this exception, if /// available. </exception> public override void setValue(ELContext context, object @base, object property, object value) { if (context == null) { throw new System.NullReferenceException(); } if (isResolvable(@base)) { if (readOnly) { throw new PropertyNotWritableException("resolver is read-only"); } System.Reflection.MethodInfo method = toBeanProperty(@base, property).WriteMethod; if (method == null) { throw new PropertyNotWritableException("Cannot write property: " + property); } try { method.invoke(@base, value); } catch (InvocationTargetException e) { throw new ELException("Cannot write property: " + property, e.InnerException); } catch (IllegalAccessException e) { throw new PropertyNotWritableException("Cannot write property: " + property, e); } context.PropertyResolved = true; } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private static Object proxyInvoke(Object delegate, Method method, Object[] args) throws Throwable private static object ProxyInvoke(object @delegate, System.Reflection.MethodInfo method, object[] args) { try { return(method.invoke(@delegate, args)); } catch (InvocationTargetException e) { throw e.InnerException; } }
private static long Invoke(System.Reflection.MethodInfo method) { try { object value = (method == null) ? null : method.invoke(_osBean); return((value == null) ? VALUE_UNAVAILABLE : (( Number )value).longValue()); } catch (Exception) { return(VALUE_UNAVAILABLE); } }
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected: //ORIGINAL LINE: private static AutoCloseable closeable(final Method method, final Object target) private static AutoCloseable Closeable(System.Reflection.MethodInfo method, object target) { return(() => { try { method.invoke(target); } catch (Exception e) when(e is IllegalAccessException || e is System.ArgumentException || e is InvocationTargetException) { throw new Exception(e); } }); }
public override void performOperationStep(DeploymentOperation operationContext) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.camunda.bpm.application.AbstractProcessApplication processApplication = operationContext.getAttachment(Attachments.PROCESS_APPLICATION); AbstractProcessApplication processApplication = operationContext.getAttachment(Attachments.PROCESS_APPLICATION); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final String paName = processApplication.getName(); string paName = processApplication.Name; Type paClass = processApplication.GetType(); System.Reflection.MethodInfo preUndeployMethod = InjectionUtil.detectAnnotatedMethod(paClass, typeof(PreUndeploy)); if (preUndeployMethod == null) { LOG.debugPaLifecycleMethodNotFound(CALLBACK_NAME, paName); return; } LOG.debugFoundPaLifecycleCallbackMethod(CALLBACK_NAME, paName); // resolve injections object[] injections = InjectionUtil.resolveInjections(operationContext, preUndeployMethod); try { // perform the actual invocation preUndeployMethod.invoke(processApplication, injections); } catch (System.ArgumentException e) { throw LOG.exceptionWhileInvokingPaLifecycleCallback(CALLBACK_NAME, paName, e); } catch (IllegalAccessException e) { throw LOG.exceptionWhileInvokingPaLifecycleCallback(CALLBACK_NAME, paName, e); } catch (InvocationTargetException e) { Exception cause = e.InnerException; if (cause is Exception) { throw (Exception)cause; } else { throw LOG.exceptionWhileInvokingPaLifecycleCallback(CALLBACK_NAME, paName, e); } } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public Object answer(org.mockito.invocation.InvocationOnMock invocation) throws Throwable public override object Answer(InvocationOnMock invocation) { object[] arguments = invocation.Arguments; ConsistencyReport report = (( CheckerEngine )arguments[arguments.Length - 2]).report(); try { return(Method.invoke(report, Parameters(Method))); } catch (System.ArgumentException ex) { throw new System.ArgumentException(format("%s.%s#%s(...)", report, Method.DeclaringClass.SimpleName, Method.Name), ex); } }
private T MakeProxy <T>(MBeanServerConnection mbs, Type beanInterface, ObjectName name) { beanInterface = typeof(T); try { return(beanInterface.cast(_newMXBeanProxy.invoke(null, mbs, name, beanInterface))); } catch (InvocationTargetException exception) { Exceptions.throwIfUnchecked(exception.TargetException); throw new Exception(exception.TargetException); } catch (Exception exception) { throw new System.NotSupportedException("Creating Management Bean proxies requires Java 1.6", exception); } }
protected internal static void initProcessEngineFromSpringResource(URL resource) { try { Type springConfigurationHelperClass = ReflectUtil.loadClass("org.camunda.bpm.engine.test.spring.SpringConfigurationHelper"); System.Reflection.MethodInfo method = springConfigurationHelperClass.GetMethod("buildProcessEngine", new Type[] { typeof(URL) }); ProcessEngine processEngine = (ProcessEngine)method.invoke(null, new object[] { resource }); string processEngineName = processEngine.Name; ProcessEngineInfo processEngineInfo = new ProcessEngineInfoImpl(processEngineName, resource.ToString(), null); processEngineInfosByName[processEngineName] = processEngineInfo; processEngineInfosByResourceUrl[resource.ToString()] = processEngineInfo; } catch (Exception e) { throw new ProcessEngineException("couldn't initialize process engine from spring configuration resource " + resource.ToString() + ": " + e.Message, e); } }
private object getFieldValue(BaseEntity paramBaseEntity, string paramString) { if (paramBaseEntity == null || string.ReferenceEquals(paramString, null)) { return(null); } try { string str1 = "" + paramString[0]; string str2 = "get" + str1.ToUpper() + paramString.Substring(1); System.Reflection.MethodInfo method = paramBaseEntity.GetType().GetMethod(str2, new Type[0]); return(method.invoke(paramBaseEntity, new object[0])); } catch (Exception) { return(null); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public Object invoke(org.aopalliance.intercept.MethodInvocation methodInvocation) throws Throwable public object invoke(MethodInvocation methodInvocation) { string methodName = methodInvocation.Method.Name; outerInstance.logger.info("method invocation for " + methodName + "."); if (methodName.Equals("toString")) { return("SharedProcessInstance"); } ProcessInstance processInstance = Context.ExecutionContext.ProcessInstance; System.Reflection.MethodInfo method = methodInvocation.Method; object[] args = methodInvocation.Arguments; object result = method.invoke(processInstance, args); return(result); }
public override object invoke(Bindings bindings, ELContext context, Type returnType, Type[] paramTypes, object[] @params) { System.Reflection.MethodInfo method = getMethod(bindings, context, returnType, paramTypes); try { return(method.invoke(null, @params)); } catch (IllegalAccessException) { throw new ELException(LocalMessages.get("error.identifier.method.access", name)); } catch (System.ArgumentException e) { throw new ELException(LocalMessages.get("error.identifier.method.invocation", name, e)); } catch (InvocationTargetException e) { throw new ELException(LocalMessages.get("error.identifier.method.invocation", name, e.InnerException)); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public org.neo4j.server.rest.repr.Representation invoke(org.neo4j.kernel.internal.GraphDatabaseAPI graphDb, Object source, ParameterList params) throws BadPluginInvocationException, PluginInvocationFailureException, org.neo4j.server.rest.repr.BadInputException public override Representation Invoke(GraphDatabaseAPI graphDb, object source, ParameterList @params) { object[] arguments = new object[_extractors.Length]; using (Transaction tx = graphDb.BeginTx()) { for (int i = 0; i < arguments.Length; i++) { arguments[i] = _extractors[i].extract(graphDb, source, @params); } } try { object returned = _method.invoke(_plugin, arguments); if (returned == null) { return(Representation.emptyRepresentation()); } return(_result.convert(returned)); } catch (InvocationTargetException exc) { Exception targetExc = exc.TargetException; foreach (Type excType in _method.ExceptionTypes) { if (excType.IsInstanceOfType(targetExc)) { throw new BadPluginInvocationException(targetExc); } } throw new PluginInvocationFailureException(targetExc); } catch (Exception e) when(e is System.ArgumentException || e is IllegalAccessException) { throw new PluginInvocationFailureException(e); } }
/// <summary> /// If the base object is not <code>null</code>, invoke the method, with the given parameters on /// this bean. The return value from the method is returned. /// /// <para> /// If the base is not <code>null</code>, the <code>propertyResolved</code> property of the /// <code>ELContext</code> object must be set to <code>true</code> by this resolver, before /// returning. If this property is not <code>true</code> after this method is called, the caller /// should ignore the return value. /// </para> /// /// <para> /// The provided method object will first be coerced to a <code>String</code>. The methods in the /// bean is then examined and an attempt will be made to select one for invocation. If no /// suitable can be found, a <code>MethodNotFoundException</code> is thrown. /// /// If the given paramTypes is not <code>null</code>, select the method with the given name and /// parameter types. /// /// Else select the method with the given name that has the same number of parameters. If there /// are more than one such method, the method selection process is undefined. /// /// Else select the method with the given name that takes a variable number of arguments. /// /// Note the resolution for overloaded methods will likely be clarified in a future version of /// the spec. /// /// The provided parameters are coerced to the corresponding parameter types of the method, and /// the method is then invoked. /// /// </para> /// </summary> /// <param name="context"> /// The context of this evaluation. </param> /// <param name="base"> /// The bean on which to invoke the method </param> /// <param name="method"> /// The simple name of the method to invoke. Will be coerced to a <code>String</code>. /// If method is "<init>"or "<clinit>" a MethodNotFoundException is /// thrown. </param> /// <param name="paramTypes"> /// An array of Class objects identifying the method's formal parameter types, in /// declared order. Use an empty array if the method has no parameters. Can be /// <code>null</code>, in which case the method's formal parameter types are assumed /// to be unknown. </param> /// <param name="params"> /// The parameters to pass to the method, or <code>null</code> if no parameters. </param> /// <returns> The result of the method invocation (<code>null</code> if the method has a /// <code>void</code> return type). </returns> /// <exception cref="MethodNotFoundException"> /// if no suitable method can be found. </exception> /// <exception cref="ELException"> /// if an exception was thrown while performing (base, method) resolution. The thrown /// exception must be included as the cause property of this exception, if available. /// If the exception thrown is an <code>InvocationTargetException</code>, extract its /// <code>cause</code> and pass it to the <code>ELException</code> constructor. /// @since 2.2 </exception> public override object invoke(ELContext context, object @base, object method, Type[] paramTypes, object[] @params) { if (context == null) { throw new System.NullReferenceException(); } object result = null; if (isResolvable(@base)) { if (@params == null) { @params = new object[0]; } string name = method.ToString(); System.Reflection.MethodInfo target = findMethod(@base, name, paramTypes, @params.Length); if (target == null) { throw new MethodNotFoundException("Cannot find method " + name + " with " + @params.Length + " parameters in " + @base.GetType()); } try { result = target.invoke(@base, coerceParams(getExpressionFactory(context), target, @params)); } catch (InvocationTargetException e) { throw new ELException(e.InnerException); } catch (IllegalAccessException e) { throw new ELException(e); } context.PropertyResolved = true; } return(result); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: @Override public Void call() throws Exception public override Void call() { preUndeployMethod.invoke(processApplication.RawObject, outerInstance.getInjections(preUndeployMethod)); return(null); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public void start() throws java.io.IOException public virtual void Start() { _broadcastSerializer = new AtomicBroadcastSerializer(new ObjectStreamFactory(), new ObjectStreamFactory()); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.neo4j.kernel.lifecycle.LifeSupport life = new org.neo4j.kernel.lifecycle.LifeSupport(); LifeSupport life = new LifeSupport(); try { MessageTimeoutStrategy timeoutStrategy = (new MessageTimeoutStrategy(new FixedTimeoutStrategy(5000))).timeout(HeartbeatMessage.sendHeartbeat, 200); Monitors monitors = new Monitors(); NetworkedServerFactory serverFactory = new NetworkedServerFactory(life, new MultiPaxosServerFactory(new ClusterConfiguration("default", NullLogProvider.Instance), NullLogProvider.Instance, monitors.NewMonitor(typeof(StateMachines.Monitor))), timeoutStrategy, NullLogProvider.Instance, new ObjectStreamFactory(), new ObjectStreamFactory(), monitors.NewMonitor(typeof(NetworkReceiver.Monitor)), monitors.NewMonitor(typeof(NetworkSender.Monitor)), monitors.NewMonitor(typeof(NamedThreadFactory.Monitor))); ServerIdElectionCredentialsProvider electionCredentialsProvider = new ServerIdElectionCredentialsProvider(); _server = serverFactory.NewNetworkedServer(Config.defaults(), new InMemoryAcceptorInstanceStore(), electionCredentialsProvider); _server.addBindingListener(electionCredentialsProvider); _server.addBindingListener(me => Console.WriteLine("Listening at:" + me)); Cluster = _server.newClient(typeof(Cluster)); Cluster.addClusterListener(new ClusterListenerAnonymousInnerClass(this)); Heartbeat heartbeat = _server.newClient(typeof(Heartbeat)); heartbeat.AddHeartbeatListener(new HeartbeatListenerAnonymousInnerClass(this)); Broadcast = _server.newClient(typeof(AtomicBroadcast)); Broadcast.addAtomicBroadcastListener(value => { try { Console.WriteLine(_broadcastSerializer.receive(value)); } catch (Exception e) when(e is IOException || e is ClassNotFoundException) { e.printStackTrace(); } }); life.Start(); string command; StreamReader reader = new StreamReader(System.in); while (!(command = reader.ReadLine()).Equals("quit")) { string[] arguments = command.Split(" ", true); System.Reflection.MethodInfo method = GetCommandMethod(arguments[0]); if (method != null) { string[] realArgs = new string[arguments.Length - 1]; Array.Copy(arguments, 1, realArgs, 0, realArgs.Length); try { method.invoke(this, ( object[] )realArgs); } catch (Exception e) when(e is IllegalAccessException || e is System.ArgumentException || e is InvocationTargetException) { e.printStackTrace(); } } } Cluster.leave(); } finally { life.Shutdown(); Console.WriteLine("Done"); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public void invoke(Object proxy, Method method, Object[] args, String... tags) throws Throwable public override void Invoke(object proxy, System.Reflection.MethodInfo method, object[] args, params string[] tags) { method.invoke(MonitorListenerConflict, args); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public Object invoke(Object proxy, Method method, Object[] args) throws Throwable public override object Invoke(object proxy, System.Reflection.MethodInfo method, object[] args) { System.Reflection.MethodInfo match = Wrapped.GetType().GetMethod(method.Name, method.ParameterTypes); return(match.invoke(Wrapped, args)); }
/// <summary> /// Loads the content of a jar file that comply with a MaltParser Plugin /// </summary> /// <param name="jarUrl"> The URL to the jar file </param> /// <exception cref="PluginException"> </exception> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public boolean readJarFile(java.net.URL jarUrl) throws org.maltparser.core.exception.MaltChainedException public virtual bool readJarFile(URL jarUrl) { JarInputStream jis; JarEntry je; ISet <URL> pluginXMLs = new Helper.HashSet <URL>(); /*if (logger.isDebugEnabled()) { * logger.debug("Loading jar " + jarUrl+"\n"); * }*/ JarFile jarFile; try { jarFile = new JarFile(jarUrl.File); } catch (IOException e) { throw new PluginException("Could not open jar file " + jarUrl + ". ", e); } try { Manifest manifest = jarFile.Manifest; if (manifest != null) { Attributes manifestAttributes = manifest.MainAttributes; if (!(manifestAttributes.getValue("MaltParser-Plugin") != null && manifestAttributes.getValue("MaltParser-Plugin").Equals("true"))) { return(false); } if (manifestAttributes.getValue("Class-Path") != null) { string[] classPathItems = manifestAttributes.getValue("Class-Path").Split(" "); for (int i = 0; i < classPathItems.Length; i++) { URL u; try { u = new URL(jarUrl.Protocol + ":" + (new File(jarFile.Name)).ParentFile.Path + "/" + classPathItems[i]); } catch (MalformedURLException e) { throw new PluginException("The URL to the plugin jar-class-path '" + jarUrl.Protocol + ":" + (new File(jarFile.Name)).ParentFile.Path + "/" + classPathItems[i] + "' is wrong. ", e); } URLClassLoader sysloader = (URLClassLoader)ClassLoader.SystemClassLoader; Type sysclass = typeof(URLClassLoader); System.Reflection.MethodInfo method = sysclass.getDeclaredMethod("addURL", new Type[] { typeof(URL) }); method.Accessible = true; method.invoke(sysloader, new object[] { u }); } } } } catch (PatternSyntaxException e) { throw new PluginException("Could not split jar-class-path entries in the jar-file '" + jarFile.Name + "'. ", e); } catch (IOException e) { throw new PluginException("Could not read the manifest file in the jar-file '" + jarFile.Name + "'. ", e); } catch (NoSuchMethodException e) { throw new PluginException("", e); } catch (IllegalAccessException e) { throw new PluginException("", e); } catch (InvocationTargetException e) { throw new PluginException("", e); } try { jis = new JarInputStream(jarUrl.openConnection().InputStream); while ((je = jis.NextJarEntry) != null) { string jarName = je.Name; if (jarName.EndsWith(".class", StringComparison.Ordinal)) { /* if (logger.isDebugEnabled()) { * logger.debug(" Loading class: " + jarName+"\n"); * }*/ loadClassBytes(jis, jarName); Type clazz = findClass(jarName.Substring(0, jarName.Length - 6)); classes[jarName.Substring(0, jarName.Length - 6).Replace('/', '.')] = clazz; loadClass(jarName.Substring(0, jarName.Length - 6).Replace('/', '.')); } if (jarName.EndsWith("plugin.xml", StringComparison.Ordinal)) { pluginXMLs.Add(new URL("jar:" + jarUrl.Protocol + ":" + jarUrl.Path + "!/" + jarName)); } jis.closeEntry(); } foreach (URL url in pluginXMLs) { /* if (logger.isDebugEnabled()) { * logger.debug(" Loading "+url+"\n"); * }*/ OptionManager.instance().loadOptionDescriptionFile(url); } } catch (MalformedURLException e) { throw new PluginException("The URL to the plugin.xml is wrong. ", e); } catch (IOException e) { throw new PluginException("cannot open jar file " + jarUrl + ". ", e); } catch (ClassNotFoundException e) { throw new PluginException("The class " + e.Message + " can't be found. ", e); } return(true); }
/// <summary> /// Invoke method. </summary> /// <param name="bindings"> </param> /// <param name="context"> </param> /// <param name="base"> </param> /// <param name="method"> </param> /// <returns> method result </returns> /// <exception cref="InvocationTargetException"> </exception> /// <exception cref="IllegalAccessException"> </exception> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: protected Object invoke(Bindings bindings, org.camunda.bpm.engine.impl.javax.el.ELContext context, Object super, Method method) throws InvocationTargetException, IllegalAccessException protected internal virtual object invoke(Bindings bindings, ELContext context, object @base, System.Reflection.MethodInfo method) { Type[] types = method.ParameterTypes; object[] @params = null; if (types.Length > 0) { @params = new object[types.Length]; if (varargs && method.VarArgs) { for (int i = 0; i < @params.Length - 1; i++) { object param = getParam(i).eval(bindings, context); if (param != null || types[i].IsPrimitive) { @params[i] = bindings.convert(param, types[i]); } } int varargIndex = types.Length - 1; Type varargType = types[varargIndex].GetElementType(); int length = ParamCount - varargIndex; object array = null; if (length == 1) { // special: eventually use argument as is object param = getParam(varargIndex).eval(bindings, context); if (param != null && param.GetType().IsArray) { if (types[varargIndex].IsInstanceOfType(param)) { array = param; } else { // coerce array elements length = Array.getLength(param); array = Array.CreateInstance(varargType, length); for (int i = 0; i < length; i++) { object elem = Array.get(param, i); if (elem != null || varargType.IsPrimitive) { ((Array)array).SetValue(bindings.convert(elem, varargType), i); } } } } else { // single element array array = Array.CreateInstance(varargType, 1); if (param != null || varargType.IsPrimitive) { ((Array)array).SetValue(bindings.convert(param, varargType), 0); } } } else { array = Array.CreateInstance(varargType, length); for (int i = 0; i < length; i++) { object param = getParam(varargIndex + i).eval(bindings, context); if (param != null || varargType.IsPrimitive) { ((Array)array).SetValue(bindings.convert(param, varargType), i); } } } @params[varargIndex] = array; } else { for (int i = 0; i < @params.Length; i++) { object param = getParam(i).eval(bindings, context); if (param != null || types[i].IsPrimitive) { @params[i] = bindings.convert(param, types[i]); } } } } return(method.invoke(@base, @params)); }