All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.gwtplatform.mvp.client.annotations.CustomProvider Maven / Gradle / Ivy

The newest version!
/*
 * Copyright 2011 ArcBees Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package com.gwtplatform.mvp.client.annotations;

import java.lang.annotation.ElementType;
import java.lang.annotation.Target;

import com.gwtplatform.common.client.IndirectProvider;

/**
 * Use this annotation with a {@link com.gwtplatform.mvp.client.proxy.Proxy} to specify a custom
 * {@linkplain com.gwtplatform.common.client.IndirectProvider provider} which is used to load the
 * presenter behind the proxy. Using a custom provider enables you to add steps which should happen
 * before the presenter is loaded, instantiated and processed by GIN.
 * 

* The class implementing {@code IndirectProvider} must provide a constructor which takes the * original provider as the single argument. For presenters which use {@code @ProxyStandard} * this is {@code com.google.inject.Provider<T>}; for presenters which use {@code @ProxyCodeSplit} * or {@code @ProxyCodeSplitBundle} this is {@code com.google.gwt.inject.client.AsyncProvider<T>} *

* Here is an example use of {@code CustomProvider}: *

*

 * @ProxyCodeSplit
 * @CustomProvider(SecurityContextProvider.class)
 * public interface MyProxy extends ProxyPlace<MyPresenter> {
 * }
 *
 * ...
 *
 * public class SecurityContextProvider implements IndirectProvider<MyPresenter> {
 *     private final AsyncProvider<MyPresenter> provider;
 *
 *     public SecurityContextProvider(AsyncProvider<MyPresenter> provider) {
 *         this.provider = provider;
 *     }
 *
 *     @Override
 *     public void get(AsyncCallback<MyPresenter> callback) {
 *         // Place your custom logic here, e.g. fetch data from the server.
 *         // If everything is ready, call
 *         provider.get(callback);
 *     }
 * }
 * 
*/ @Target(ElementType.TYPE) public @interface CustomProvider { Class value(); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy