/*
* Spadger - an open source discussion forum system.
*
* Copyright (C) 2011 The Spadger Team
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
*
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.ajiaojr.spadger.client;
import javax.inject.Inject;
import javax.inject.Provider;
import javax.inject.Singleton;
import net.ajiaojr.spadger.client.place.SpadgerPlaceController;
import net.ajiaojr.spadger.shared.request.SpadgerRequestFactory;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.shared.EventBus;
import com.google.gwt.event.shared.SimpleEventBus;
import com.google.gwt.inject.client.AbstractGinModule;
import com.google.gwt.place.shared.PlaceController;
/**
* Gin module for general configurations.
*
* @author The Spadger Team
*/
public class ConfigurationModule extends AbstractGinModule {
public static class SpadgerRequestFactoryProvider implements
Provider<SpadgerRequestFactory> {
private final EventBus eventBus;
@Inject
public SpadgerRequestFactoryProvider(EventBus eventBus) {
this.eventBus = eventBus;
}
@Override
public SpadgerRequestFactory get() {
SpadgerRequestFactory requestFactory = GWT
.create(SpadgerRequestFactory.class);
requestFactory.initialize(eventBus);
return requestFactory;
}
}
/*
* (non-Javadoc)
*
* @see com.google.gwt.inject.client.AbstractGinModule#configure()
*/
@Override
protected void configure() {
bind(EventBus.class).to(SimpleEventBus.class).in(Singleton.class);
bind(PlaceController.class).to(SpadgerPlaceController.class);
bind(SpadgerRequestFactory.class).toProvider(
SpadgerRequestFactoryProvider.class);
}
}