Java Code Examples for org.activiti.engine.impl.util.ReflectUtil#getResourceAsStream()
The following examples show how to use
org.activiti.engine.impl.util.ReflectUtil#getResourceAsStream() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DbSqlSession.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public void executeSchemaResource(String operation, String component, String resourceName, boolean isOptional) { InputStream inputStream = null; try { inputStream = ReflectUtil.getResourceAsStream(resourceName); if (inputStream == null) { if (isOptional) { log.info("no schema resource {} for {}", resourceName, operation); } else { throw new ActivitiException("resource '" + resourceName + "' is not available"); } } else { executeSchemaResource(operation, component, resourceName, inputStream); } } finally { IoUtil.closeSilently(inputStream); } }
Example 2
Source File: DeploymentBuilderImpl.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public DeploymentBuilder addClasspathResource(String resource) { InputStream inputStream = ReflectUtil.getResourceAsStream(resource); if (inputStream == null) { throw new ActivitiIllegalArgumentException("resource '" + resource + "' not found"); } return addInputStream(resource, inputStream); }
Example 3
Source File: ResourceStreamSource.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public InputStream getInputStream() { InputStream inputStream = null; if (classLoader == null) { inputStream = ReflectUtil.getResourceAsStream(resource); } else { inputStream = classLoader.getResourceAsStream(resource); } if (inputStream == null) { throw new ActivitiIllegalArgumentException("resource '" + resource + "' doesn't exist"); } return new BufferedInputStream(inputStream); }
Example 4
Source File: TestHelper.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
/** * get a resource location by convention based on a class (type) and a relative resource name. The return value will be the full classpath location of the type, plus a suffix built from the name * parameter: <code>BpmnDeployer.BPMN_RESOURCE_SUFFIXES</code>. The first resource matching a suffix will be returned. */ public static String getBpmnProcessDefinitionResource(Class<?> type, String name) { for (String suffix : ResourceNameUtil.BPMN_RESOURCE_SUFFIXES) { String resource = type.getName().replace('.', '/') + "." + name + "." + suffix; InputStream inputStream = ReflectUtil.getResourceAsStream(resource); if (inputStream == null) { continue; } else { return resource; } } return type.getName().replace('.', '/') + "." + name + "." + ResourceNameUtil.BPMN_RESOURCE_SUFFIXES[0]; }
Example 5
Source File: BpmnDeploymentTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Deployment public void testGetBpmnXmlFileThroughService() { String deploymentId = repositoryService.createDeploymentQuery().singleResult().getId(); List<String> deploymentResources = repositoryService.getDeploymentResourceNames(deploymentId); // verify bpmn file name assertEquals(1, deploymentResources.size()); String bpmnResourceName = "org/activiti/engine/test/bpmn/deployment/BpmnDeploymentTest.testGetBpmnXmlFileThroughService.bpmn20.xml"; assertEquals(bpmnResourceName, deploymentResources.get(0)); ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult(); assertEquals(bpmnResourceName, processDefinition.getResourceName()); assertNull(processDefinition.getDiagramResourceName()); assertFalse(processDefinition.hasStartFormKey()); ProcessDefinition readOnlyProcessDefinition = ((RepositoryServiceImpl) repositoryService).getDeployedProcessDefinition(processDefinition.getId()); assertNull(readOnlyProcessDefinition.getDiagramResourceName()); // verify content InputStream deploymentInputStream = repositoryService.getResourceAsStream(deploymentId, bpmnResourceName); String contentFromDeployment = readInputStreamToString(deploymentInputStream); assertTrue(contentFromDeployment.length() > 0); assertTrue(contentFromDeployment.contains("process id=\"emptyProcess\"")); InputStream fileInputStream = ReflectUtil.getResourceAsStream("org/activiti/engine/test/bpmn/deployment/BpmnDeploymentTest.testGetBpmnXmlFileThroughService.bpmn20.xml"); String contentFromFile = readInputStreamToString(fileInputStream); assertEquals(contentFromFile, contentFromDeployment); }
Example 6
Source File: TestHelper.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
/** * get a resource location by convention based on a class (type) and a * relative resource name. The return value will be the full classpath * location of the type, plus a suffix built from the name parameter: * <code>BpmnDeployer.BPMN_RESOURCE_SUFFIXES</code>. * The first resource matching a suffix will be returned. */ public static String getBpmnProcessDefinitionResource(Class< ? > type, String name) { for (String suffix : ResourceNameUtil.BPMN_RESOURCE_SUFFIXES) { String resource = type.getName().replace('.', '/') + "." + name + "." + suffix; InputStream inputStream = ReflectUtil.getResourceAsStream(resource); if (inputStream == null) { continue; } else { return resource; } } return type.getName().replace('.', '/') + "." + name + "." + ResourceNameUtil.BPMN_RESOURCE_SUFFIXES[0]; }
Example 7
Source File: BpmnDeploymentTest.java From flowable-engine with Apache License 2.0 | 5 votes |
@Deployment public void testGetBpmnXmlFileThroughService() { String deploymentId = repositoryService.createDeploymentQuery().singleResult().getId(); List<String> deploymentResources = repositoryService.getDeploymentResourceNames(deploymentId); // verify bpmn file name assertEquals(1, deploymentResources.size()); String bpmnResourceName = "org/activiti/engine/test/bpmn/deployment/BpmnDeploymentTest.testGetBpmnXmlFileThroughService.bpmn20.xml"; assertEquals(bpmnResourceName, deploymentResources.get(0)); ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult(); assertEquals(bpmnResourceName, processDefinition.getResourceName()); assertNull(processDefinition.getDiagramResourceName()); assertFalse(processDefinition.hasStartFormKey()); org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl activiti5ProcessEngineConfig = (org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl) processEngineConfiguration.getFlowable5CompatibilityHandler() .getRawProcessConfiguration(); ReadOnlyProcessDefinition readOnlyProcessDefinition = ((RepositoryServiceImpl) activiti5ProcessEngineConfig.getRepositoryService()).getDeployedProcessDefinition(processDefinition.getId()); assertNull(readOnlyProcessDefinition.getDiagramResourceName()); // verify content InputStream deploymentInputStream = repositoryService.getResourceAsStream(deploymentId, bpmnResourceName); String contentFromDeployment = readInputStreamToString(deploymentInputStream); assertTrue(contentFromDeployment.length() > 0); assertTrue(contentFromDeployment.contains("process id=\"emptyProcess\"")); InputStream fileInputStream = ReflectUtil.getResourceAsStream("org/activiti/engine/test/bpmn/deployment/BpmnDeploymentTest.testGetBpmnXmlFileThroughService.bpmn20.xml"); String contentFromFile = readInputStreamToString(fileInputStream); assertEquals(contentFromFile, contentFromDeployment); }
Example 8
Source File: DeploymentBuilderImpl.java From flowable-engine with Apache License 2.0 | 5 votes |
@Override public DeploymentBuilder addClasspathResource(String resource) { InputStream inputStream = ReflectUtil.getResourceAsStream(resource); if (inputStream == null) { throw new ActivitiIllegalArgumentException("resource '" + resource + "' not found"); } return addInputStream(resource, inputStream); }
Example 9
Source File: ResourceStreamSource.java From flowable-engine with Apache License 2.0 | 5 votes |
@Override public InputStream getInputStream() { InputStream inputStream = null; if (classLoader == null) { inputStream = ReflectUtil.getResourceAsStream(resource); } else { inputStream = classLoader.getResourceAsStream(resource); } if (inputStream == null) { throw new ActivitiIllegalArgumentException("resource '" + resource + "' doesn't exist"); } return new BufferedInputStream(inputStream); }
Example 10
Source File: ProcessEngineConfigurationImpl.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
protected InputStream getResourceAsStream(String resource) { return ReflectUtil.getResourceAsStream(resource); }
Example 11
Source File: ProcessEngineConfigurationImpl.java From flowable-engine with Apache License 2.0 | 4 votes |
protected InputStream getResourceAsStream(String resource) { return ReflectUtil.getResourceAsStream(resource); }