Accessing other spring defined beans in the portlet spring application context (Spring Portlet MVC) - spring-mvc

Context: Using maven 3,spring portlet mvc 3.1
Background:
I have built a portlet using spring portlet mvc 3.1.
This portlet uses the spring portlet mvc defined Dispatched and is defined accordingly in the -portlet.xml.
The dispatcher portlet is configured to pass requests to the myController (POJO with annotation of #Controller)
I also have a service project (jar) which defines a business service to be used by myController. This service has its own spring file and defines the bean 'myService'
I want to inject myService into myController using a predefined bean, so I have defined ContextLoaderListener in the web.xml of my portlet project
Problem:
I have tried both ways of trying to inject myService into myController i.e. using annotations and xml defined beans, but the portlet fails on deployment with an error that myService bean could not be found (or when using annotations no matching bean with class type found)
Note: I can see some logs on undeploy that the beans are available, but I think the issue is with PortletApplicationContext (as defined by -portlet.xml) is loading before the root Web ApplicationContext (as defined applicationContext through default usage in web.xml)
Note2: If I put the import for spring file defining 'myService' bean into the -portlet.xml, then it works.
Would appreciate any help in sorting this out.

Related

Quarkus + Undertow: Register a Servlet instance without the WebServlet annotation

I'm implementing a WebDAV servlet that I want to integrate in a Quarkus-based application, by using the quarkus-undertow extension.
I want to control the initialization of the startup, and injection with the CDI infrastructure in Quarkus would be nice. As I understand it, I can't use the #WebServlet annotation to bind the servlet to an URL mapping.
What is the proper way of initializing and adding custom servlets with quarkus-undertow?

How to find out ejb 2.x vs 3.x code beans

I am working on migrating code base which has EJB 2.x as well as 3.x code.
How do I identify EJB 2.x code (session beans, message driven beans).
The code uses session beans with annotations and some beans are also defined in ejb-jar.xml.
I thought these annotated beans would be specific to 3.x code and the ones from ejb-jar.xml file would be 2.x beans , but then I found this class
#Stateless
#TransactionManagement(TransactionManagementType.BEAN)
public class ABC implements javax.ejb.SessionBean{
//methods
}
3.x beans do not implement javax.ejb.SessionBean right?
Is the above code snippet 2.x or 3.x ejb?
Let me know your thoughts
2.x EJB are required to implement SessionBean
3.x EJB are not required (but can) implement Session Bean
2.x EJB should have a Home interface

How does MVC know about Dependency Injection in controller constructors, ASP.NET Core2

I'm starting to write controllers for ASP.NET Core 2. I am now adding an ILogger to the constructor of one of these controller classes. It occurred to me that since I don't directly create instances of these classes based on Controller, somehow the application must be aware of the signatures of the constructor. How does that work? Is there a list of signature conventions I should be using?

Spring MVC Template Location

Spring boot stores in template files in /src/main/resources
Where is this configured and how can I get Spring MVC to do this when not using Spring Boot?
In Spring Boot templating is usually configured via autoconfiguration, which takes information from application properties. For instance Thymeleaf template location can be configured like this:
spring.thymeleaf.prefix=classpath:/templates/ # Prefix that gets prepended to view names when building a URL.
See Spring Boot properties reference for more details.
Without using Spring Boot you can configure the same behavior by specifying custom ViewResolver bean and specifying prefix for templates. You can take a look at ThymeleafAutoConfiguration for inspiration.
Same principles apply to using other templating engines than Thymeleaf with Spring MVC.

servlet-listener and MIME type support for equinox

I have embedded equinox framework in tomcat 7.x using bridge.war and steps given at
http://www.eclipse.org/equinox/server/http_in_container.php
I have developed an osgi bundle which contains servlet registration code and as expected this servlet runs over the bridge.
My goal is to support servlet apis and web.xml functionality in this osgi bundle so that I can port an existing web application in osgi.
For now,I am using "org.eclipse.equinox.http.servlet.ExtendedHttpService" to register servlet filters and servlets.
However,ExtendedHttpService does not have a method to register a servlet-listener.
Can anyone suggest me how can I support/register servlet listeners and MIME types in an osgi bundle which contains my servlet registration code.

Resources