Announcement Announcement Module
Collapse
No announcement yet.
spring data rest Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • spring data rest

    1) i am not getting any rest events with an applicationlistener on RepositoryEvent,
    2) could not get a reference to RepositoryRestHandlerMapping either :
    i want to hook in an HandlerInterceptorAdapter or PermissionEvaluator
    - how get hold of the applicatontext in which the exporter is running ?

    3) could restrict http method access with :

    Code:
    <security:intercept-url pattern="/hateoas/*" method="GET"/>
    		<security:intercept-url pattern="/hateoas/*" method="POST" access="hasRole('ROLE_POST_ALLOWED')"/>
    		<security:intercept-url pattern="/hateoas/*" method="PUT" access="hasRole('ROLE_PUT_ALLOWED')"/>
    		<security:intercept-url pattern="/hateoas/*" method="DELETE" access="hasRole('ROLE_DELETE_ALLOWED')"/>
    Code:
    <servlet>
            <servlet-name>service.dispatcher</servlet-name>
            <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
            <init-param>
                <param-name>contextConfigLocation</param-name>
                <param-value>/WEB-INF/services-config.xml</param-value>
            </init-param>
            <load-on-startup>1</load-on-startup>
        </servlet>
        
        <servlet>
    		<servlet-name>hateoas</servlet-name>
    		<servlet-class>org.springframework.data.rest.webmvc.RepositoryRestExporterServlet</servlet-class>
    		<load-on-startup>1</load-on-startup>
    	</servlet>

  • #2
    Could you be a bit more expressive? Not much to go on nor on what you want.

    You have 2 servlets and you cannot access the ApplicationContext from servlet 1 in servlet 2 and vice versa... The same goes for events they are only intercepted/handled in the context they occur and the parent not in other contexts which don't know eachother.

    Comment


    • #3
      okay , i got an interceptor with
      Code:
      <mvc:interceptors>
      		<mvc:interceptor>
      			<mvc:mapping path="/**"/>
      			<bean class="RepositoryHandlerInterceptor"
      				
      			/>
      		</mvc:interceptor>
      	</mvc:interceptors>
      and
      Code:
      public class RepositoryHandlerInterceptor extends HandlerInterceptorAdapter {
      	
      	Logger logger = LoggerFactory.getLogger(getClass());
      	
      	public boolean preHandle(HttpServletRequest request,
      			HttpServletResponse response, Object handler) throws Exception {
      		
      		
      		logger.info("{}", request);
      		
      		return super.preHandle(request, response, handler);
      	}
      	
      	public void postHandle(HttpServletRequest request,
      			HttpServletResponse response, Object handler,
      			ModelAndView modelAndView) throws Exception {
      		logger.info("{}", response);
      		super.postHandle(request, response, handler, modelAndView);
      	}
      	
      	public void afterCompletion(HttpServletRequest request,
      			HttpServletResponse response, Object handler, Exception ex)
      			throws Exception {
      		logger.info("{}", response);
      		super.afterCompletion(request, response, handler, ex);
      	}
      }
      preHandle shows but neither postHandle nor afterCompletion,
      Last edited by wims.tijd; Oct 23rd, 2012, 03:00 AM.

      Comment

      Working...
      X