a week ago
This link https://docs.alfresco.com/content-services/latest/develop/oop-sdk/
Shows a very terse Sdk5DemoApplication to start up a RESTful listener against a repo. I want to add ECM functionality to a multi-module EAR and want to isolate all that code to a new module (a spring jar).
I have added said jar's root package to the application's @ComponentScan list of packages. But how do I tell Spring to find (aka scan) the Alfresco API beans?
The documentation is very vague as to what is being scanned/initialized. Specifically in regards to this: @Autowired SitesApi sitesApi; Which implies there's a SitesApiImpl somewhere to be instantiated. Will scanning be enough or will a @PostConstruct method also be necessary?
Tuesday
a week ago
Hope this helps:
Tuesday
Sorry, it does not. That class demonstrates how to USE the Spring beans that are in the *Api interfaces after being injected by the Spring container.
My question is how to tell Spring to find and create the implementations of said APIs.
In my case with Spring MVC this is done via an annotated configuration class:
@Import({PersistenceConfig.class})
@EnableWebSecurity
@EnableAsync
@EnableScheduling
@EnableWs
@EnableWebMvc
@ComponentScan(basePackages = { "app.package.name",
And my application will be running "out-of-process" with Alfresco which will be on another server.
I have added:
"org.alfresco.core.*","lib.package.name"
And will test shortly. But that will only work if the Spring bean configuration information is present on the class path, in the form of XML or annotated classes.
I have looked in the alfresco-core-rest-api-7.2.0.jar and alfresco-java-rest-api-common-7.2.0.jar jars and found no such XML files. Not sure if there are any classes either because according to alfresco-core-rest-api-7.2.0-javadoc, there's nothing in that JAR but interfaces.
Tuesday
Spring cannot instantiate those Alfresco REST interfaces via @ComponentScan. Scanning only finds concrete @Component classes, and the Alfresco JARs you checked mostly contain interfaces, so there is nothing to create.
Those interfaces become beans only if you use a proxy mechanism, typically OpenFeign, or the Alfresco Spring Boot starter that auto-registers Feign clients.
If using Spring Boot, add org.alfresco:alfresco-java-rest-api-spring-boot-starter and ensure auto-config is enabled.
Tuesday
The app is not spring-boot; its an MVC app that runs in an application server along side EJBs as well.
So is there a code example of this "OpenFeign" or should I change tack and use OpenCMIS API instead?
I looked in several of alfresco-java-rest-api-spring-boot-starter jars and find no code. So what Dark Majik is spring doing to bootstrap anything?
Tuesday
For a non-Spring-Boot MVC app running in an app server, the simplest and least surprising option is a concrete REST client (OpenAPI-generated or hand-written) or even OpenCMIS, as you said.
Tuesday
So, where might the OpenAPI file be? In the Hyland download's site or ... ?
Tuesday
Explore our Alfresco products with the links below. Use labels to filter content by product module.