Hi,
The example below uses ipojo for registering the servlet as a service.
Can anyone point me how can I use Felix SCR annotations instead to acheive
the same ?

@Component(immediate = true)
@Instantiate
public class MyServlet extends HttpServlet {
                @ServiceProperty
        private String MY_SERVLET_ALIAS = "/my_service";


        @Requires(optional = true, defaultimplementation = 
OtherServiceImpl.class)
        private OtherService otherService;
        @Bind
        public void bindHttp(HttpService httpService) {
                try {
                        httpService.registerServlet(MY_SERVLET_ALIAS, this,
                                        null, null);
                } catch (ServletException | NamespaceException e) {
                        LOG.error("Exception occurred when registering the 
recommendation
Service",       e);

                }
        }

        @Unbind
        public void unbindHttp(HttpService httpService) {
                httpService.unregister(MY_SERVLET_ALIAS);
        }

        @Override
        protected void doGet(HttpServletRequest req, HttpServletResponse resp)
                        throws ServletException, IOException {
                //some implementation
        }

        protected void doPost(HttpServletRequest req, HttpServletResponse resp)
                        throws ServletException, IOException {
                //some implementation
        }
}

Reply via email to