Spring xml config to java config converter - java

Is there a tool, which can convert Spring xml configs to java configs? I have a lot of large xml configs and don't want to convert in manually.

Nope, but it's something you could write. I can see Spring config moving exclusively to it's Java form soon, so it might not be needed in the future.
Check this book out, the third chapter has some examples on how to do this.
http://www.gocit.vn/files/Spring.in.Action.3rd.Edition-www.gocit.vn.pdf

Related

Apache Camel XML configuration rules and restrictions

I am learning Camel and trying to integrate it with Spring Boot applications. From what I've read there appear to be two main ways to configure the Camel routes (and other related entities): 1) via Java DSL, or 2) via XML DSL. We don't think the Java DSL approach will work for us, as it doesn't seem that it would allow dynamic route definitions. Maybe I'm wrong? If dynamic routing can somehow be done using Java DSL and whatever, I'd like to know about it.
So, I'm focusing on configuring the routes in XML, where we should have a little more flexibility. The idea is that a given application (or service) could be handed a constructed XML route configuration at deploy-time that would specify the details of that service's routing.
The first question I have is how can we indicate to Camel (or Spring Boot and Camel) what/where the configuration file(s) are? Does it expect specific file naming and/or project location, or is it more flexible? Can it be broken into separate files?
By the way, we configure our Spring Boot applications via a combination of Java-based bean configuration and an application.yml file. We don't use XML for Spring Boot configuration.
I've poked around in a number of places on the Camel site (https://camel.apache.org/) but haven't found much information on this subject. The emphasis definitely favors the Java DSL approach.
There is a spring boot example with XML DSL at
https://github.com/apache/camel-spring-boot/tree/master/examples/camel-example-spring-boot-xml
You can use property placeholders in your Camel routes that can be configured via spring boot configuration (eg application.properties etc).
From Camel pov, then XML or Java can be equally dynamic. You can remove/add routes at runtime. But mind that its not always a good thing to do dynamic changes in production, without knowing if the changes works.

How to convert java to Spring XML bean

We have a java web project with initial configuration in Spring applicationContext.xml. Please don't write that it is old style, I know.
Part of this configurations can be change vs admin panel of the application and we need to backup it from time to time.
Does spring have something like applicationContext.saveBean() or any any other way to save configuration objects into XML using Spring beans?
You can use Spring caching with Ehcache:
https://github.com/eugenp/tutorials/tree/master/spring-all
You are getting the option of caching on disk stores.
You also can persist your beans as java serialized objects.
Of course this doesn't generate an xml readable output.

Java Spring/Workflow

I have 50,000,000 files that need to be processed using 3-5 different filters configured in workflows
I plan to use microservice architecture
My Questions
i want to use spring integration and batch, to run the workflows. and design the workflows, do you agree or is there another java based system you recommend?
can spring batch can handle "long running i.e. days" workflows.
can spring batch/integration load xml files on the fly
I think Spring Batch is pretty good for this job, below my answers.
I recommend you Spring Batch for this job. It's easy to use and in combination with Spring Workflow are good for the workflow desing.
Yes, it's really good. You need to configure it well.
I'm not sure what are you saying with on the fly. (batch files or configuration files). For batch files yes. For configuration files, it depends on how you load the configuration and how you will use the context.
IMHO Spring Batch can process files based on multiple filters. It can also be easily customized to fit most of your needs and has really fast processing speeds. However, I haven't tried it with anything close to 50,000,000 files, so can't vouch for that.
To run a Spring Batch application as a microservice, take a look at Spring Boot and Spring Cloud Task. Also, look into Spring Cloud Dataflow for orchestration.

What are the advantages of Java DSL over Spring DSL in Apache Camel?

I know we can use Java DSL and Spring DSL for working with routes in camel context.
Can anybody tell me which one is more efficient? And What is the advantage of one over the other?
I personally prefer the java dsl as the IDE completion helps very nicely with the DSL. The Java DSL also nicely follows when you do refactorings.
I often combine using a spring context and the Java DSL.
You can use the java dsl for the actual Camel development and use spring or blueprint for your route setup or bean configuration, or bridging Camel to spring or Karaf.
Personally, with help of some Configuration Management Platform (like disconf, https://github.com/knightliao/disconf), and some rules which defined in advance, I can change camel routes (add or remove) dynamically, without changing java code, or the xml.
It will be a little more complex using spring xml to do this. But using dsl, I just need to put configs in different if/else, which switched by configs.

Turn off XSD validation of spring files

Spring tries to validate xml confniguration files against xml schemas. Which is fine, but there might be cases when the validation fails (outdated schema, for example). Is there a way to turn off xsd validation?
See this Spring JIRA: https://jira.spring.io/browse/SPR-5014 - has both the team's comments on why they won't directly build it in as well as an example of how to implement yourself.

Categories

Resources