예제 #1
0
  @SuppressWarnings({"rawtypes", "unchecked"})
  public MediaType getMediaType(String contextName, Object obj) throws ContextTransformException {

    ContextTransformInterceptor interceptor = transformInterceptorMap.get(obj.getClass());

    if (interceptor != null) return interceptor.getMediaType(obj);
    else return contextTransformMap.get(contextName).getMediaType(obj);
  }
예제 #2
0
  @SuppressWarnings("rawtypes")
  public ContextTransformService(
      Collection<ContextTransformer> contextTransforms,
      Collection<ContextTransformInterceptor> contextTransformInterceptors) {

    if (contextTransforms != null) {
      for (ContextTransformer transform : contextTransforms) {
        contextTransformMap.put(transform.getContextName(), transform);
      }
    }

    if (contextTransformInterceptors != null) {
      for (ContextTransformInterceptor interceptor : contextTransformInterceptors) {
        transformInterceptorMap.put(interceptor.intercepts(), interceptor);
      }
    }
  }