protected internal virtual IList <URL> getProcessesXmlUrls(string[] deploymentDescriptors, AbstractProcessApplication processApplication) { ClassLoader processApplicationClassloader = processApplication.ProcessApplicationClassloader; IList <URL> result = new List <URL>(); // load all deployment descriptor files using the classloader of the process application foreach (string deploymentDescriptor in deploymentDescriptors) { IEnumerator <URL> processesXmlFileLocations = null; try { processesXmlFileLocations = processApplicationClassloader.getResources(deploymentDescriptor); } catch (IOException e) { throw LOG.exceptionWhileReadingProcessesXml(deploymentDescriptor, e); } while (processesXmlFileLocations.MoveNext()) { result.Add(processesXmlFileLocations.Current); } } return(result); }
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET: //ORIGINAL LINE: protected java.util.Iterator<java.net.URL> loadClasspathResourceRoots(final ClassLoader classLoader, String strippedPaResourceRootPath) protected internal virtual IEnumerator <URL> loadClasspathResourceRoots(ClassLoader classLoader, string strippedPaResourceRootPath) { try { return(classLoader.getResources(strippedPaResourceRootPath)); } catch (IOException e) { throw LOG.exceptionWhileLoadingCpRoots(strippedPaResourceRootPath, classLoader, e); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public void testPluginDoesNotRegisterJsonSerializerIfNotPresentInClasspath() throws java.io.IOException public virtual void testPluginDoesNotRegisterJsonSerializerIfNotPresentInClasspath() { ClassLoader mockClassloader = Mockito.mock(typeof(ClassLoader)); Mockito.when(mockClassloader.getResources(Mockito.anyString())).thenReturn(Collections.enumeration(System.Linq.Enumerable.Empty <URL>())); DataFormats.loadDataFormats(mockClassloader); ProcessEngineConfigurationImpl mockConfig = Mockito.mock(typeof(ProcessEngineConfigurationImpl)); DefaultVariableSerializers serializers = new DefaultVariableSerializers(); Mockito.when(mockConfig.VariableSerializers).thenReturn(serializers); (new SpinProcessEnginePlugin()).registerSerializers(mockConfig); assertTrue(serializers.getSerializerByName(org.camunda.spin.plugin.variable.type.JsonValueType_Fields.TYPE_NAME) == null); }
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET: //ORIGINAL LINE: protected java.util.Iterator<java.net.URL> loadClasspathResourceRoots(final ClassLoader classLoader, String strippedPaResourceRootPath) protected internal virtual IEnumerator <URL> loadClasspathResourceRoots(ClassLoader classLoader, string strippedPaResourceRootPath) { IEnumerator <URL> resourceRoots; try { resourceRoots = classLoader.getResources(strippedPaResourceRootPath); } catch (IOException e) { throw LOG.couldNotGetResource(strippedPaResourceRootPath, classLoader, e); } return(resourceRoots); }
// find the list of resources //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: private static java.util.List<ResourceLocator> orderedResources0(String classpathResourceName) throws java.io.IOException private static IList <ResourceLocator> orderedResources0(string classpathResourceName) { ClassLoader classLoader = ResourceLocator.classLoader(); IList <string> names = new List <string>(); IList <ResourceLocator> result = new List <ResourceLocator>(); foreach (string dir in RESOURCE_DIRS) { string name = CONFIG_PACKAGE + dir + "/" + classpathResourceName; names.Add(name); IList <URL> urls = Collections.list(classLoader.getResources(name)); switch (urls.Count) { case 0: continue; case 1: result.Add(ResourceLocator.ofClasspathUrl(urls[0])); break; default: // handle case where Strata is on the classpath more than once // only accept this if the data being read is the same in all URLs ResourceLocator baseResource = ResourceLocator.ofClasspathUrl(urls[0]); for (int i = 1; i < urls.Count; i++) { ResourceLocator otherResource = ResourceLocator.ofClasspathUrl(urls[i]); if (!baseResource.ByteSource.contentEquals(otherResource.ByteSource)) { log.severe("More than one file found on the classpath: " + name + ": " + urls); throw new System.InvalidOperationException("More than one file found on the classpath: " + name + ": " + urls); } } result.Add(baseResource); break; } } if (result.Count == 0) { log.severe("No resource files found on the classpath: " + names); throw new System.InvalidOperationException("No files found on the classpath: " + names); } log.config(() => "Resources found: " + result); return(result); }
/// <summary> /// Initializes all process engines that can be found on the classpath for /// resources <code>camunda.cfg.xml</code> (plain Activiti style configuration) /// and for resources <code>activiti-context.xml</code> (Spring style configuration). /// </summary> public static void init(bool forceCreate) { lock (typeof(ProcessEngines)) { if (!isInitialized) { if (processEngines == null) { // Create new map to store process-engines if current map is null processEngines = new Dictionary <string, ProcessEngine>(); } ClassLoader classLoader = ReflectUtil.ClassLoader; IEnumerator <URL> resources = null; try { resources = classLoader.getResources("camunda.cfg.xml"); } catch (IOException) { try { resources = classLoader.getResources("activiti.cfg.xml"); } catch (IOException ex) { if (forceCreate) { throw new ProcessEngineException("problem retrieving camunda.cfg.xml and activiti.cfg.xml resources on the classpath: " + System.getProperty("java.class.path"), ex); } else { return; } } } // Remove duplicated configuration URL's using set. Some classloaders may return identical URL's twice, causing duplicate startups ISet <URL> configUrls = new HashSet <URL>(); while (resources.MoveNext()) { configUrls.Add(resources.Current); } for (IEnumerator <URL> iterator = configUrls.GetEnumerator(); iterator.MoveNext();) { URL resource = iterator.Current; initProcessEngineFromResource(resource); } try { resources = classLoader.getResources("activiti-context.xml"); } catch (IOException e) { if (forceCreate) { throw new ProcessEngineException("problem retrieving activiti-context.xml resources on the classpath: " + System.getProperty("java.class.path"), e); } else { return; } } while (resources.MoveNext()) { URL resource = resources.Current; initProcessEngineFromSpringResource(resource); } isInitialized = true; } else { LOG.processEngineAlreadyInitialized(); } } }