Using Ceylon classes in Spring Boot application - spring-boot

Is it possible to use Ceylon classes in a Spring Boot application? What would that look like - the Ceylon classes as a separate dependency, or could they be in the same project?
I've got a particularly knotty Java problem that would really benefit from reified generics and an absence of type erasure. However, the main reason I'm writing it in Java in the first place is because I want to exploit a Java library for interacting with a thing. I don't want to learn any more Ceylon than is necessary for solving the problem, if at all possible.

Ceylon integration with java is really smooth, you can use all the springboot stack and use java classes and even libs (maven) without problems, I have a small project ceylon with springboot using Discovery, Gateway and microservices that you can use as example. Its not documented yet but if you know about springboot then I think its enough as start point for you. I hope it's enough , otherwise I am available to help.
Its working/using ceylon from current development, I didnt try with 1.2.2 release.

Related

Spring AOP in separate project

I've been playing around with aspects in my spring boot project using spring-boot-starter-aop. It's all working nicely and I have good test coverage with some of them leveraging whats offered in spring boot e.g. #SpringBootTest.
Since the aspects and related code would be useful across multiple different projects I wanted to extract this code into a separate "utility" project. Then import this utility project as a dependency.
As I understand stand it (from here), a spring boot project should generally not be used as a dependency. Since I'm using spring-boot-starter-aop and also leveraging spring beans etc in my tests, this is a problem...
I'm just wondering on the best way to proceed. Any advice appreciated.
Thanks

How to integrate the spring boot project generated by swagger with OSGi and deploy it in Apache karaf?

How to integrate the spring boot project generated by swagger with OSGi and deploy it in Apache karaf?
How should I write my pom.xml and how to modify the startup class. If there is something not detailed, I will add it. Thank you!
You don't. It's not strictly impossible but it would be a lot of work and struggle and you will not get any benefits out of it.
If you want SpringBoot - stick to that. You will sacrifice modularity, strong encapsulation, enforced clean architecture and bunch of other architectural thing that will matter a lot in the long run. But you will gain something that is easy to work with in the beginning and tons of code to copy/paste.
If you are playing the long game - I'd recommend to forget about SpringBoot and learn how to build modular OSGi applications. Recent version allow you to use popular technologies like JAX-RS and CDI. You can probably use one of the Swagger's JAX-RS generators and then convert the outcome to proper modular code. It may even be that there is a generator that generates OSGi JAX-RS code already.

What are disadvantages of using Lombok in my Spring Boot RestApi?

I am using Lombok in my Spring Boot Rest Api. I searched a lot but could not found what I want to know about Lombok. My rest api is an enterprise level application which would be extend with more modules in future.
Should I use lombok? What are the major disadvantages of Lombok using in enterprise application?
My IDE is STS.
You have to know what Lombok really does under the hood.
For example, Lombok adds #java.beans.ConstructorProperties before constructors. This may be important if you use Jackson serialization.
See https://projectlombok.org/features/constructor
There are no special advantages or disadvantages of using Lombok in an enterprise application. Lombok itself and all its annotations are removed during compilation, so there will be no additional libraries at runtime.
Furthermore, if at any point later you'd decide against Lombok, you could remove it again by running delombok, which will give you the code that Lombok generates. So there is no real risk there (besides that it will of course take some time to delombok everything).
For a general (of course opinion-based) discussion on Lombok's (dis)advantages, see this answer.

What Spring projects are libraries (not framework-oriented)?

I do not wish to use Spring annotations or xml or any declarative, non-compile-time-safe code or anything that relies on reflection. However, I'm guessing Spring does have traditional libraries (like Apache Commons libraries) that you can call from your code rather than your annotated code getting called by the framework.
What Spring projects are libraries? I'm assuming some of them are.
The core of Spring is the Spring Framework. Which is uses reflection, annotations etc without remorse. Using spring as a library completely misses the point. You could use, say JdbcTemplates with the correct dependency but why?
If you do use Spring as a Library bare in mind you are only getting tiny bits of functionality, most of which is just bootstrap code you avoid writing. Spring is designed to be used within it's framework and built upon. Some do use libraries such as Apache Commons. Using Spring Framework as a library however does just complicate your own project and people would probably ask - "why".

CQ5 Spring integration

Is the any way to perform integration CQ5 platform with Spring framework?
I would like to use Spring IoC capabilities to make my code more clear and efficient.
UPDATE
Hello againg, seems that I found solution.
Guys here developed Slice framework that really redices amound of code and made CQ5 development easier.
You probably want to check out Eclipse Gemini Blueprint, or it's original incarnation Spring Dynamic Modules. The Blueprint project basically gives you an easy way to create Spring enabled bundles in an OSGi environment.
As shsteimer mentions, Spring distributions before 3.2.0 were OSGi bundles, so could be dropped into an OSGi environment and you could probably use them directly. Spring 3.2.0 bundles and above are now available through the SpringSource ERB. However, Blueprint gets around or helps with some of the boilerplate OSGi stuff that you would otherwise have to do.
On a past project, I was able to get Spring JDBC working inside of CQ (to support some legacy code so we didn't have to re-write it). My memory is that the spring jar files already come "OSGI-ified" and so it was just a matter of figuring out all the layers of dependency needed for JDBC to work inside of CQ, and adding all the jars to the repository in an /apps/myApp/install folder.
Long story short, I'm not sure about IoC, but you might check to see if it's already packaged as an OSGI version which you can simply use without too much hassle.

Resources