Question

I am working on a webapp which uses Primefaces as a view, and I inject Spring beans from other projects into JSF Managed beans.

I have an architectural problem: I've created separate projects(modules) for each component that I use (Business Logic, Persistence, and others) and also create separate projects with their interfaces. I want my webApp to depend only on the interface of the Business Logic, and to inject the implementation of the BL using Spring Dependency Injection. I want to achive this recursively: Business logic to depend only on other interfaces, and to inject implementations using spring.

The problem is that having no dependency in the Maven pom file to the actual implementations, when I deploy the application (on a web logic server) the implementation jars are not deployed, and Spring doesn't find the beans to wire.

Is there a way to achieve decoupling without adding dependencies to actual implementations? Can I include Spring's bean configuration files from other projects if the projects are not added as dependencies?

Did I figured this decoupling all wrong?

I appreciate your ideas.

Was it helpful?

Solution

Well obviously you need the dependencies in your maven pom else nothing will be included. You can add the dependencies with a scope of runtime which includes them in your final war but not during development (scope compile).

For loading the context of modules you might come-up with a naming convention and/or standard location for your files. With that you could do something like this in your web applications beans xml

<import resource="classpath*:/META-INF/spring/*-context.xml" />

This would load all files ending with -context.xml from the /META-INF/spring directory on the classpath (including jar files).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top