private void registerFlowBuilders() { if (flowBuilders != null) { for (FlowBuilderInfo builderInfo : flowBuilders) { flowRegistry.registerFlowDefinition(buildFlowDefinition(builderInfo)); } } }
private FlowDefinitionHolder createFlowDefinitionHolder(FlowDefinitionResource flowResource) { FlowBuilder builder = createFlowBuilder(flowResource); FlowBuilderContext builderContext = new FlowBuilderContextImpl(flowResource.getId(), flowResource.getAttributes(), flowRegistry, flowBuilderServices); FlowAssembler assembler = new FlowAssembler(builder, builderContext); return new DefaultFlowHolder(assembler); }
private void registerFlowLocations() { if (flowLocations != null) { for (FlowLocation location : flowLocations) { flowRegistry.registerFlowDefinition(createFlowDefinitionHolder(createResource(location))); } } }
private void registerFlowLocationPatterns() { if (flowLocationPatterns != null) { for (String pattern : flowLocationPatterns) { FlowDefinitionResource[] resources; AttributeMap<Object> attributes = getFlowAttributes(Collections.emptySet()); try { resources = flowResourceFactory.createResources(pattern, attributes); } catch (IOException e) { IllegalStateException ise = new IllegalStateException( "An I/O Exception occurred resolving the flow location pattern '" + pattern + "'"); ise.initCause(e); throw ise; } for (FlowDefinitionResource resource : resources) { flowRegistry.registerFlowDefinition(createFlowDefinitionHolder(resource)); } } } }
private FlowDefinition buildFlowDefinition(FlowBuilderInfo builderInfo) { try { Class<?> flowBuilderClass = loadClass(builderInfo.getClassName()); FlowBuilder builder = (FlowBuilder) flowBuilderClass.newInstance(); AttributeMap<Object> flowAttributes = getFlowAttributes(builderInfo.getAttributes()); FlowBuilderContext builderContext = new FlowBuilderContextImpl(builderInfo.getId(), flowAttributes, flowRegistry, flowBuilderServices); FlowAssembler assembler = new FlowAssembler(builder, builderContext); return assembler.assembleFlow(); } catch (IllegalArgumentException e) { throw new FlowDefinitionConstructionException(builderInfo.getId(), e); } catch (InstantiationException e) { throw new FlowDefinitionConstructionException(builderInfo.getId(), e); } catch (IllegalAccessException e) { throw new FlowDefinitionConstructionException(builderInfo.getId(), e); } }
private Object getConvertedValue(FlowElementAttribute attribute) { if (attribute.needsTypeConversion()) { Class<?> targetType = fromStringToClass(attribute.getType()); ConversionExecutor converter = flowBuilderServices.getConversionService().getConversionExecutor( String.class, targetType); return converter.execute(attribute.getValue()); } else { return attribute.getValue(); } }
private FlowModelHolder createFlowModelHolder(FlowDefinitionResource resource) { FlowModelHolder modelHolder = new DefaultFlowModelHolder(createFlowModelBuilder(resource)); // register the flow model holder with the backing flow model registry - this is needed to support flow model // merging during the flow build process flowRegistry.getFlowModelRegistry().registerFlowModel(resource.getId(), modelHolder); return modelHolder; }
private FlowModelBuilder createFlowModelBuilder(FlowDefinitionResource resource) { if (isXml(resource.getPath())) { return new XmlFlowModelBuilder(resource.getPath(), flowRegistry.getFlowModelRegistry()); } else { throw new IllegalArgumentException(resource + " is not a supported resource type; supported types are [.xml]"); } }
private FlowDefinitionResource createResource(FlowLocation location) { AttributeMap<Object> flowAttributes = getFlowAttributes(location.getAttributes()); return flowResourceFactory.createResource(location.getPath(), flowAttributes, location.getId()); }
private FlowBuilder createFlowBuilder(FlowDefinitionResource resource) { return new FlowModelFlowBuilder(createFlowModelHolder(resource)); }
private AttributeMap<Object> getFlowAttributes(Set<FlowElementAttribute> attributes) { MutableAttributeMap<Object> flowAttributes = null; if (flowBuilderServices.getDevelopment()) { flowAttributes = new LocalAttributeMap<>(1 + attributes.size(), 1); flowAttributes.put("development", true); } if (!attributes.isEmpty()) { if (flowAttributes == null) { flowAttributes = new LocalAttributeMap<>(attributes.size(), 1); } for (FlowElementAttribute attribute : attributes) { flowAttributes.put(attribute.getName(), getConvertedValue(attribute)); } } return flowAttributes; }
private FlowDefinition buildFlowDefinition(FlowBuilderInfo builderInfo) { try { Class<?> flowBuilderClass = loadClass(builderInfo.getClassName()); FlowBuilder builder = (FlowBuilder) flowBuilderClass.newInstance(); AttributeMap<Object> flowAttributes = getFlowAttributes(builderInfo.getAttributes()); FlowBuilderContext builderContext = new FlowBuilderContextImpl(builderInfo.getId(), flowAttributes, flowRegistry, flowBuilderServices); FlowAssembler assembler = new FlowAssembler(builder, builderContext); return assembler.assembleFlow(); } catch (IllegalArgumentException e) { throw new FlowDefinitionConstructionException(builderInfo.getId(), e); } catch (InstantiationException e) { throw new FlowDefinitionConstructionException(builderInfo.getId(), e); } catch (IllegalAccessException e) { throw new FlowDefinitionConstructionException(builderInfo.getId(), e); } }
private void registerFlowLocationPatterns() { if (flowLocationPatterns != null) { for (int i = 0; i < flowLocationPatterns.length; i++) { String pattern = flowLocationPatterns[i]; FlowDefinitionResource[] resources; AttributeMap attributes = getFlowAttributes(Collections.EMPTY_SET); try { resources = flowResourceFactory.createResources(pattern, attributes); } catch (IOException e) { IllegalStateException ise = new IllegalStateException( "An I/O Exception occurred resolving the flow location pattern '" + pattern + "'"); ise.initCause(e); throw ise; } for (int j = 0; j < resources.length; j++) { flowRegistry.registerFlowDefinition(createFlowDefinitionHolder(resources[j])); } } } }
private Object getConvertedValue(FlowElementAttribute attribute) { if (attribute.needsTypeConversion()) { Class targetType = fromStringToClass(attribute.getType()); ConversionExecutor converter = flowBuilderServices.getConversionService().getConversionExecutor( String.class, targetType); return converter.execute(attribute.getValue()); } else { return attribute.getValue(); } }
private FlowModelHolder createFlowModelHolder(FlowDefinitionResource resource) { FlowModelHolder modelHolder = new DefaultFlowModelHolder(createFlowModelBuilder(resource)); // register the flow model holder with the backing flow model registry - this is needed to support flow model // merging during the flow build process flowRegistry.getFlowModelRegistry().registerFlowModel(resource.getId(), modelHolder); return modelHolder; }
private FlowModelBuilder createFlowModelBuilder(FlowDefinitionResource resource) { if (isXml(resource.getPath())) { return new XmlFlowModelBuilder(resource.getPath(), flowRegistry.getFlowModelRegistry()); } else { throw new IllegalArgumentException(resource + " is not a supported resource type; supported types are [.xml]"); } }
private FlowDefinitionResource createResource(FlowLocation location) { AttributeMap<Object> flowAttributes = getFlowAttributes(location.getAttributes()); return flowResourceFactory.createResource(location.getPath(), flowAttributes, location.getId()); }
private FlowBuilder createFlowBuilder(FlowDefinitionResource resource) { return new FlowModelFlowBuilder(createFlowModelHolder(resource)); }
private AttributeMap getFlowAttributes(Set attributes) { MutableAttributeMap flowAttributes = null; if (flowBuilderServices.getDevelopment()) { flowAttributes = new LocalAttributeMap(1 + attributes.size(), 1); flowAttributes.put("development", Boolean.TRUE); } if (!attributes.isEmpty()) { if (flowAttributes == null) { flowAttributes = new LocalAttributeMap(attributes.size(), 1); } for (Iterator it = attributes.iterator(); it.hasNext();) { FlowElementAttribute attribute = (FlowElementAttribute) it.next(); flowAttributes.put(attribute.getName(), getConvertedValue(attribute)); } } return flowAttributes; }
private void registerFlowLocations() { if (flowLocations != null) { for (int i = 0; i < flowLocations.length; i++) { FlowLocation location = flowLocations[i]; flowRegistry.registerFlowDefinition(createFlowDefinitionHolder(createResource(location))); } } }