org.apache.shindig.gadgets.DefaultGuiceModule Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of shindig-gadgets Show documentation
Show all versions of shindig-gadgets Show documentation
Renders gadgets, provides the gadget metadata service, and serves
all javascript required by the OpenSocial specification.
The newest version!
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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 org.apache.shindig.gadgets;
import com.google.common.base.Splitter;
import com.google.common.collect.ImmutableList;
import com.google.inject.AbstractModule;
import com.google.inject.Inject;
import com.google.inject.Provides;
import com.google.inject.Singleton;
import com.google.inject.multibindings.Multibinder;
import com.google.inject.name.Named;
import com.google.inject.name.Names;
import org.apache.shindig.common.servlet.BasicAuthority;
import org.apache.shindig.common.servlet.GuiceServletContextListener;
import org.apache.shindig.gadgets.config.DefaultConfigContributorModule;
import org.apache.shindig.gadgets.http.AbstractHttpCache;
import org.apache.shindig.gadgets.http.HttpResponse;
import org.apache.shindig.gadgets.http.InvalidationHandler;
import org.apache.shindig.gadgets.js.JsCompilerModule;
import org.apache.shindig.gadgets.js.JsServingPipelineModule;
import org.apache.shindig.gadgets.parse.ParseModule;
import org.apache.shindig.gadgets.preload.PreloadModule;
import org.apache.shindig.gadgets.render.RenderModule;
import org.apache.shindig.gadgets.rewrite.RewriteModule;
import org.apache.shindig.gadgets.servlet.GadgetsHandler;
import org.apache.shindig.gadgets.servlet.HttpRequestHandler;
import org.apache.shindig.gadgets.templates.TemplateModule;
import org.apache.shindig.gadgets.uri.ProxyUriBase;
import org.apache.shindig.gadgets.uri.UriModule;
import org.apache.shindig.common.servlet.Authority;
import org.apache.shindig.gadgets.variables.SubstituterModule;
import java.util.List;
import java.util.Set;
import java.util.concurrent.*;
/**
* Creates a module to supply all of the core gadget classes.
*
* Instead of subclassing this consider adding features to the
* multibindings for features and rpc handlers.
*/
public class DefaultGuiceModule extends AbstractModule {
/** {@inheritDoc} */
@Override
protected void configure() {
bind(ExecutorService.class).to(ShindigExecutorService.class);
bind(Executor.class).annotatedWith(Names.named("shindig.concat.executor")).to(ShindigExecutorService.class);
bind(Authority.class).to(BasicAuthority.class);
bindConstant().annotatedWith(Names.named("shindig.jsload.ttl-secs")).to(60 * 60); // 1 hour
bindConstant().annotatedWith(Names.named("shindig.jsload.require-onload-with-jsload")).to(true);
install(new DefaultConfigContributorModule());
install(new ParseModule());
install(new PreloadModule());
install(new RenderModule());
install(new RewriteModule());
install(new SubstituterModule());
install(new TemplateModule());
install(new UriModule());
install(new JsCompilerModule());
install(new JsServingPipelineModule());
// bind(Long.class).annotatedWith(Names.named("org.apache.shindig.serviceExpirationDurationMinutes")).toInstance(60l);
// We perform static injection on HttpResponse for cache TTLs.
requestStaticInjection(HttpResponse.class);
requestStaticInjection(AbstractHttpCache.class);
requestStaticInjection(ProxyUriBase.class);
registerGadgetHandlers();
registerFeatureHandlers();
}
/**
* Sets up multibinding for rpc handlers
*/
protected void registerGadgetHandlers() {
Multibinder
© 2015 - 2024 Weber Informatics LLC | Privacy Policy