I'm just wondering if it's possible to create Spring managed beans backed by Clojure code (Clojure namespace I guess, would implement regular Java interface)? If so, the example would be appreciated.
Thanks,
Dmitriy.
I haven't tried that yet, but section 3.3 of Programming Clojure explains how to create class files with the :gen-class form. Use it with :implements and :extends, build a JAR from your classes and import them into your Spring project. That should - theoretically - do the trick.
I'd be very interested in any example code, too, by the way.
See this as an example of clojure, spring, junit and swt integration.
Related
I'm a big fan of Kotlintest syntax and I'd like to know if it's possible to make it work with WebMvcTest. More particularly, I don't manage to annotate the test methods with #WithMockUser.
Does somebody know if it's feasible?
Thanks beforehand.
It's not something that is currently built into KotlinTest but there is a Spring module, so it should be fairly easy to create another extension that provides this.
This is the source for the spring module.
https://github.com/kotlintest/kotlintest/tree/master/kotlintest-samples/kotlintest-samples-spring
I currently have a Java/Spring application that is primarily configured via XML. The plan is to slowly migrate the application to Scala. I felt an easy first step would be to replace the XML configuration with a Scala configuration classes.
I have looked over spring-scala and was going to try it out, however, I am running into issues figuring out how to bootstrap the classes extending FunctionalConfiguration.
The application currently uses application.xml loaded from web.xml to start the bootstrapping process via a component-scan. Unfortunately this doesn't seem to pick up the Scala config classes.
Any suggestions on how to bootstrap a spring-scala configuration?
Best,
Peter
Spring-scala seems quite dead. It's not necessary to use it in order to migrate to scala. Old-fashioned java config works pretty well with scala.
Moreover, currently you don't need web.xml and even external servlet container - you can use spring-boot. It'll allow you to throw away all XMLs and some java configuration parts.
Here's an example of the approach with spring-boot & scala. I hope this helps.
I want to integrate vaadin 7 with osgi but there is no longer any AbstractApplicationServlet class.
I've followed the integration using the vaadin bridge by Neil Bartlett https://github.com/njbartlett/VaadinOSGi.
I've tried using the VaadinServlet somehow but with no luck.
I've also searched for other solutions but found none.
Do you have any suggestions?
Thanks
Vaadin 7 has a lot of design changes that are not visible for default use cases, but especially for OSGi integration you have to do some extra work.
To get you started you should try to understand the initialization process concerning the classes:
VaadinServlet, VaadinServletService, VaadinSession and UIProvider.
The problematic parts are the methods that use classname parameters as arguments, you will have to work around this by e.g. implementing a factory that directly injects your instances.
If you look at the source for UIProvider.createInstance(..) you can see that the original implementation tries to create a new instance, this will fail since vaadin does not see your classes in OSGi. The same principle applies for the other classes i mentioned as well.
Another thing you have to look at is the new separation of jars in Vaadin 7.
A good approach is to attach a bundle fragment with a blueprint context. that registers a BundleHttpContext the same way it worked in Vaadin 6. Attaching fragments also works for the themes you want to use.
Sorry that i can't provide a turnkey solution, but i hope this helps you to look into it yourself.
Could someone provide a sample code snippet that stitches two java interfaces using spring-aop introduction (mixin)?
I'm looking for AspectJ annotation style configuration. Also, the specific use case I have is to stitch a few java beans each implementing their own interfaces together. So, rather than having a delegate coded, if I could just get away by using Spring XML, it'd be awesome.
You can use #DeclareParents or <aop:declare-parents> to get the mixin behavior. For example,
#DeclareParents(value="service.*", defaultImpl=AuditRecorderDefaultImpl.class)
private AuditRecorder mixin;
will mixin all classes in the service package with the AuditRecorder interface automatically forwarding each method to AuditRecorderDefaultImpl.
You can see working examples of this from AspectJ in Action's downloadable sources. You can also see detailed explanation in Spring documentation.
A demo based on Spring in Action book 4th edition is here, the configuration is JavaConfig style with #ComponentScan
We have a large infrastructure that's highly dependent on Spring Framework. Recently I began writing code in Scala and test it using Specs. This is all great but at some point I need to use Spring-dependent features (Such as a HibernateDaoSupport-based DAO).
Has anyone managed to use the SpringJUnit4ClassRunner class to run Specs tests? Does anyone have a different direction as to how to achieve this goal?
Thanks
I've struggled with the class runner in a similarly awkward scenario once and then I created a MethodRule implementation called TemporarySpringContext that could also solve your problem I think.