001 /**
002 * Copyright (C) 2009-2011 the original author or authors.
003 * See the notice.md file distributed with this work for additional
004 * information regarding copyright ownership.
005 *
006 * Licensed under the Apache License, Version 2.0 (the "License");
007 * you may not use this file except in compliance with the License.
008 * You may obtain a copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018
019 package org.fusesource.restygwt.rebind;
020
021 import java.util.Map;
022
023 import org.fusesource.restygwt.client.MethodCallback;
024 import org.fusesource.restygwt.client.RestService;
025
026 import com.google.gwt.core.ext.TreeLogger;
027 import com.google.gwt.core.ext.UnableToCompleteException;
028 import com.google.gwt.core.ext.typeinfo.JClassType;
029 import com.google.gwt.core.ext.typeinfo.JMethod;
030
031 /**
032 * Interface to create Class- and Method-Annotations on RestService Interfaces
033 *
034 * This allows users of restygwt to give more data to the callback by setting
035 * some data on the {@link org.fusesource.restygwt.client.Method} instance.
036 *
037 * Only Key/Value of String are allowed to use since this logic happens finally
038 * on the client.
039 *
040 * Usecase is to transport those informations, which are only on the interface
041 * of a {@link RestService} until we reach the final {@link MethodCallback}. There
042 * we can act those informations, e.g. configure caching, send update events, ...
043 *
044 * @author <a href="mailto:andi.balke@gmail.com">andi</<a>
045 */
046 public interface AnnotationResolver {
047
048 /**
049 * resolve a class based annotation
050 *
051 * @param source
052 * @return the parameters given to
053 * {@link org.fusesource.restygwt.client.Method#addData(String, String)}
054 *
055 * e.g. returning ``new String[]{"key", "value"}``
056 * will result in ``__method.addData("key", "value")``
057 */
058 public Map<String, String[]> resolveAnnotation(TreeLogger logger, JClassType source, JMethod method,
059 final String restMethod) throws UnableToCompleteException;
060 }