@Test public void retrievesCookieFromRequest() throws Exception { when(parameter.getParameterClass()).thenReturn((Class)Cookie.class); Object resolvedCookie = cookieParameterResolver.resolve(parameter, applicationContext); assertSame(cookie1, resolvedCookie); }
@Override public Object resolve(org.everrest.core.Parameter parameter, ApplicationContext context) throws Exception { String param = cookieParam.value(); if (Cookie.class.isAssignableFrom(parameter.getParameterClass())) { Cookie cookie = context.getHttpHeaders().getCookies().get(param); if (cookie == null && parameter.getDefaultValue() != null) { cookie = Cookie.valueOf(parameter.getDefaultValue()); } return cookie; } else { TypeProducer typeProducer = typeProducerFactory.createTypeProducer(parameter.getParameterClass(), parameter.getGenericType()); MultivaluedMap<String, String> cookieValues = new MultivaluedMapImpl(); for (Map.Entry<String, Cookie> entry : context.getHttpHeaders().getCookies().entrySet()) { cookieValues.putSingle(entry.getKey(), entry.getValue().getValue()); } return typeProducer.createValue(param, cookieValues, parameter.getDefaultValue()); } }
CookieParameterResolver implements ParameterResolver<CookieParam> { @Override public Object resolve(org.everrest.core.Parameter parameter, ApplicationContext context) throws Exception { String param = cookieParam.value(); if (Cookie.class.isAssignableFrom(parameter.getParameterClass())) { Cookie cookie = context.getHttpHeaders().getCookies().get(param); if (cookie == null && parameter.getDefaultValue() != null) { cookie = Cookie.valueOf(parameter.getDefaultValue()); } return cookie; } else { TypeProducer typeProducer = typeProducerFactory.createTypeProducer(parameter.getParameterClass(), parameter.getGenericType()); MultivaluedMap<String, String> cookieValues = new MultivaluedMapImpl(); for (Map.Entry<String, Cookie> entry : context.getHttpHeaders().getCookies().entrySet()) { cookieValues.putSingle(entry.getKey(), entry.getValue().getValue()); } return typeProducer.createValue(param, cookieValues, parameter.getDefaultValue()); } } }
CookieParameterResolver implements ParameterResolver<CookieParam> { @Override public Object resolve(org.everrest.core.Parameter parameter, ApplicationContext context) throws Exception { String param = cookieParam.value(); if (Cookie.class.isAssignableFrom(parameter.getParameterClass())) { Cookie cookie = context.getHttpHeaders().getCookies().get(param); if (cookie == null && parameter.getDefaultValue() != null) { cookie = Cookie.valueOf(parameter.getDefaultValue()); } return cookie; } else { TypeProducer typeProducer = typeProducerFactory.createTypeProducer(parameter.getParameterClass(), parameter.getGenericType()); MultivaluedMap<String, String> cookieValues = new MultivaluedMapImpl(); for (Map.Entry<String, Cookie> entry : context.getHttpHeaders().getCookies().entrySet()) { cookieValues.putSingle(entry.getKey(), entry.getValue().getValue()); } return typeProducer.createValue(param, cookieValues, parameter.getDefaultValue()); } } CookieParameterResolver(CookieParam cookieParam, TypeProducerFactory typeProducerFactory); }
CookieParameterResolver implements ParameterResolver<CookieParam> { @Override public Object resolve(org.everrest.core.Parameter parameter, ApplicationContext context) throws Exception { String param = cookieParam.value(); if (Cookie.class.isAssignableFrom(parameter.getParameterClass())) { Cookie cookie = context.getHttpHeaders().getCookies().get(param); if (cookie == null && parameter.getDefaultValue() != null) { cookie = Cookie.valueOf(parameter.getDefaultValue()); } return cookie; } else { TypeProducer typeProducer = typeProducerFactory.createTypeProducer(parameter.getParameterClass(), parameter.getGenericType()); MultivaluedMap<String, String> cookieValues = new MultivaluedMapImpl(); for (Map.Entry<String, Cookie> entry : context.getHttpHeaders().getCookies().entrySet()) { cookieValues.putSingle(entry.getKey(), entry.getValue().getValue()); } return typeProducer.createValue(param, cookieValues, parameter.getDefaultValue()); } } CookieParameterResolver(CookieParam cookieParam, TypeProducerFactory typeProducerFactory); @Override Object resolve(org.everrest.core.Parameter parameter, ApplicationContext context); }
CookieParameterResolver implements ParameterResolver<CookieParam> { @Override public Object resolve(org.everrest.core.Parameter parameter, ApplicationContext context) throws Exception { String param = cookieParam.value(); if (Cookie.class.isAssignableFrom(parameter.getParameterClass())) { Cookie cookie = context.getHttpHeaders().getCookies().get(param); if (cookie == null && parameter.getDefaultValue() != null) { cookie = Cookie.valueOf(parameter.getDefaultValue()); } return cookie; } else { TypeProducer typeProducer = typeProducerFactory.createTypeProducer(parameter.getParameterClass(), parameter.getGenericType()); MultivaluedMap<String, String> cookieValues = new MultivaluedMapImpl(); for (Map.Entry<String, Cookie> entry : context.getHttpHeaders().getCookies().entrySet()) { cookieValues.putSingle(entry.getKey(), entry.getValue().getValue()); } return typeProducer.createValue(param, cookieValues, parameter.getDefaultValue()); } } CookieParameterResolver(CookieParam cookieParam, TypeProducerFactory typeProducerFactory); @Override Object resolve(org.everrest.core.Parameter parameter, ApplicationContext context);  }