How popular is GRAILS BeanBuilder for replacing xml based spring configuration? - java

Interested to know how many are using BeanBuilder in production as a replacement to XML based config for Spring 3.x?

How would you go about doing that? It's been proposed that the Grails bean builder be added to Spring in a future release but that hasn't happened yet.

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.

overriding default RegistrationPolicy on AnnotationMBeanExporter in Spring Boot

https://github.com/spring-projects/spring-boot/blob/master/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jmx/JmxAutoConfiguration.java
shows
RegistrationPolicy.FAIL_ON_EXISTING
being set.
We are using spring boot created WARs in a standalone tcserver.
New deployments occur before old versions are un-deployed so you can have multiple versions deployed.
I am already using
spring.jmx.default-domain=[app name]
to avoid clashes across apps...but
We are seeing errors like
UnableToRegisterMBeanException: Unable to register MBean with key 'dataSourceMBean'
nested exception is javax.management.InstanceAlreadyExistsException
for our datasource Mbean across different version of the same app.
I would like to set a
RegistrationPolicy.IGNORE_EXISTING
as per http://docs.spring.io/spring/docs/current/spring-framework-reference/html/jmx.html#jmx-exporting-registration-behavior.
Can I do this easily while maintaining the ObjectNamingStrategy and defaultDomain? Although not at all difficult, I am hoping I don't have to pretty much override all of JmxAutoConfiguration?
shame there is not a
spring.jmx.mbeanExporter.registrationPolicy
spring boot property
Cheers
Although this question was asked some time ago and maybe you have already found the answer, I will give my 2 cents here once I faced this problem and found a solution that worked for me.
Initially it was not completely clear what I needed to do, but when carefully reading the same spring documentation you provided in your question I figured out you can control the registration behavior on SpringBoot by introducing the class annotation
#EnableMBeanExport(registration=RegistrationPolicy.IGNORE_EXISTING)
to allow Spring ignore a second JMX registration if the MBean was already registered, as can be seen at the spring documentation here

Using Java Configuration with auditing in Spring Data JPA

Java configuration was introduced in version 1.2.0 of Spring Data, but I can't figure out how the java configuration for <jpa:auditing> should look like. I couldn't find any examples in the docs, neither did I figure it out by looking at the Spring Data JPA Source.
I'm suspecting it's not possible to translate <jpa:auditing> into java configuration, but as I couldn't find a Jira for the possibly missing feature, I'm unsure. Does anyone know if I still have to use XML configuration if I use Spring Data JPA with auditing?
EDIT: This feature is available as of version 1.5 M1 of Spring Data. See the ticket created by Alex Blomskøld for details.
Activating auditing is currently not supported by the JavaConfig means we introduced in 1.2.0. As we're planning to generally overhaul the auditing infrastructure anyway, would you mind filing a ticket against Spring Data JPA to capture that aspect of the story?

Integrating Play framework 2.0 and Spring framework

I have developed a Spring/JPA application: the service, repository and domain layers are nearing completion.
The only layer that is missing is the web layer. I am considering using Playframework 2.0 for the web layer but I am not sure whether I can inject/use spring beans in my Playframework 2.0 classes.
Is this possible? If so how?
You can. Updated for Play 2.5.x:
https://github.com/remithieblin/play-spring-loader
Alex.p is right there is support for spring in PlayFramework
Have a look here :
http://typesafe.com/blog/announcing-play-framework-21-the-high-velocit
and on example here :
https://github.com/guillaumebort/play20-spring-demo
Cheers
I just tested it on my project it works but on playframework 2.1 in 2.0 it didn't work.
Here is a another way of injecting beans using Spring. Standard annotations are used. No plugin is required.
https://github.com/huntc/play-spring
There's already support for the Spring IoC container in Play. It's just a matter of editing the application.conf file as mentioned in the linked to article.
Ignore the above see comment: it seems that this was dropped in playframework 2.0.

Configuration Injection Framework

I recently stumbled upon the following Configuration Injection Framework. Seems interesting and seems to fit my needs. Has anyone tried it or knows about some other Configuration Injection frameworks? As far as I know Spring and Google Guice does not support this kinds of injection?
In Spring you can do something similiar with the PropertyPlaceHolderConfigurer, look at http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/ch04s07.html#beans-factory-placeholderconfigurer
Constretto with spring may provide what you need. Spring also does most of these things, especially in version 3.0

Categories

Resources