Package dagger

Examples of dagger.ObjectGraph


  /**
   * Prepare runtime settings and start all manager instances.
   */
  protected void configureContext(ServletContext context) {
    ObjectGraph injector = getInjector(context);

    // create the runtime settings object
    IStoredSettings runtimeSettings = injector.get(IStoredSettings.class);
    final File baseFolder;

    if (goSettings != null) {
      // Gitblit GO
      baseFolder = configureGO(context, goSettings, goBaseFolder, runtimeSettings);
    } else {
      // servlet container
      WebXmlSettings webxmlSettings = new WebXmlSettings(context);
      String contextRealPath = context.getRealPath("/");
      File contextFolder = (contextRealPath != null) ? new File(contextRealPath) : null;

      // if the base folder dosen't match the default assume they don't want to use express,
      // this allows for other containers to customise the basefolder per context.
      String defaultBase = Constants.contextFolder$ + "/WEB-INF/data";
      String base = lookupBaseFolderFromJndi();
      if (!StringUtils.isEmpty(System.getenv("OPENSHIFT_DATA_DIR")) && defaultBase.equals(base)) {
        // RedHat OpenShift
        baseFolder = configureExpress(context, webxmlSettings, contextFolder, runtimeSettings);
      } else {
        // standard WAR
        baseFolder = configureWAR(context, webxmlSettings, contextFolder, runtimeSettings);
      }

      // Test for Tomcat forward-slash/%2F issue and auto-adjust settings
      ContainerUtils.CVE_2007_0450.test(runtimeSettings);
    }

    // Manually configure IRuntimeManager
    logManager(IRuntimeManager.class);
    IRuntimeManager runtime = injector.get(IRuntimeManager.class);
    runtime.setBaseFolder(baseFolder);
    runtime.getStatus().isGO = goSettings != null;
    runtime.getStatus().servletContainer = context.getServerInfo();
    runtime.start();
    managers.add(runtime);
View Full Code Here


public abstract class DaggerFilter implements Filter {

  @Override
  public final void init(FilterConfig filterConfig) throws ServletException {
    ServletContext context = filterConfig.getServletContext();
    ObjectGraph objectGraph = (ObjectGraph) context.getAttribute(DaggerContext.INJECTOR_NAME);
    inject(objectGraph);
  }
View Full Code Here

  public void testFromDagger() {
    OrderDTO orderDTO = new OrderDTO() {
    };

    ObjectGraph objectGraph = ObjectGraph.create(new WarehouseModule(orderDTO));

    Provider<?> provider = DaggerIntegration.fromDagger(objectGraph);
    ModelMapper mapper = new ModelMapper();
    mapper.getConfiguration().setProvider(provider);
View Full Code Here

  /**
   * Prepare runtime settings and start all manager instances.
   */
  protected void configureContext(ServletContext context) {
    ObjectGraph injector = getInjector(context);

    // create the runtime settings object
    IStoredSettings runtimeSettings = injector.get(IStoredSettings.class);
    final File baseFolder;

    if (goSettings != null) {
      // Gitblit GO
      baseFolder = configureGO(context, goSettings, goBaseFolder, runtimeSettings);
    } else {
      // servlet container
      WebXmlSettings webxmlSettings = new WebXmlSettings(context);
      String contextRealPath = context.getRealPath("/");
      File contextFolder = (contextRealPath != null) ? new File(contextRealPath) : null;

      // if the base folder dosen't match the default assume they don't want to use express,
      // this allows for other containers to customise the basefolder per context.
      String defaultBase = Constants.contextFolder$ + "/WEB-INF/data";
      String base = getBaseFolderPath(defaultBase);
      if (!StringUtils.isEmpty(System.getenv("OPENSHIFT_DATA_DIR")) && defaultBase.equals(base)) {
        // RedHat OpenShift
        baseFolder = configureExpress(context, webxmlSettings, contextFolder, runtimeSettings);
      } else {
        // standard WAR
        baseFolder = configureWAR(context, webxmlSettings, contextFolder, runtimeSettings);
      }

      // Test for Tomcat forward-slash/%2F issue and auto-adjust settings
      ContainerUtils.CVE_2007_0450.test(runtimeSettings);
    }

    // Manually configure IRuntimeManager
    logManager(IRuntimeManager.class);
    IRuntimeManager runtime = injector.get(IRuntimeManager.class);
    runtime.setBaseFolder(baseFolder);
    runtime.getStatus().isGO = goSettings != null;
    runtime.getStatus().servletContainer = context.getServerInfo();
    runtime.start();
    managers.add(runtime);

    // create the plugin manager instance but do not start it
    loadManager(injector, IPluginManager.class);

    // start all other managers
    startManager(injector, INotificationManager.class);
    startManager(injector, IUserManager.class);
    startManager(injector, IAuthenticationManager.class);
    startManager(injector, IPublicKeyManager.class);
    startManager(injector, IRepositoryManager.class);
    startManager(injector, IProjectManager.class);
    startManager(injector, IFederationManager.class);
    startManager(injector, IGitblit.class);

    // start the plugin manager last so that plugins can depend on
    // deterministic access to all other managers in their start() methods
    startManager(injector, IPluginManager.class);

    logger.info("");
    logger.info("All managers started.");
    logger.info("");

    IPluginManager pluginManager = injector.get(IPluginManager.class);
    for (LifeCycleListener listener : pluginManager.getExtensions(LifeCycleListener.class)) {
      try {
        listener.onStartup();
      } catch (Throwable t) {
        logger.error(null, t);
View Full Code Here

  }

  @Override
  public void init(final ServletConfig config) throws ServletException {
    ServletContext context = config.getServletContext();
    ObjectGraph dagger = (ObjectGraph) context.getAttribute(DaggerContext.INJECTOR_NAME);
    IGitblit gitblit = dagger.get(IGitblit.class);
    gitFilter.setRepositoryResolver(new RepositoryResolver<HttpServletRequest>(gitblit));
    gitFilter.setUploadPackFactory(new GitblitUploadPackFactory<HttpServletRequest>(gitblit));
    gitFilter.setReceivePackFactory(new GitblitReceivePackFactory<HttpServletRequest>(gitblit));

    gitFilter.init(new FilterConfig() {
View Full Code Here

public abstract class DaggerFilter implements Filter {

  @Override
  public final void init(FilterConfig filterConfig) throws ServletException {
    ServletContext context = filterConfig.getServletContext();
    ObjectGraph objectGraph = (ObjectGraph) context.getAttribute(DaggerContext.INJECTOR_NAME);
    inject(objectGraph, filterConfig);
  }
View Full Code Here

  private static final long serialVersionUID = 1L;

  @Override
  public final void init() throws ServletException {
    ServletContext context = getServletContext();
    ObjectGraph objectGraph = (ObjectGraph) context.getAttribute(DaggerContext.INJECTOR_NAME);
    inject(objectGraph);
  }
View Full Code Here

public abstract class DaggerWicketFilter extends WicketFilter {

  @Override
  public final void init(FilterConfig filterConfig) throws ServletException {
    ServletContext context = filterConfig.getServletContext();
    ObjectGraph objectGraph = (ObjectGraph) context.getAttribute(DaggerContext.INJECTOR_NAME);
    inject(objectGraph);
    super.init(filterConfig);
  }
View Full Code Here

      response.addHeader(ACCESS_CONTROL_ALLOW_ORIGIN, origin);
      if ("OPTIONS".equals(method)) {  // Only allow OPTIONS to support CORS preflight.
        return;
      }
    }
    ObjectGraph requestGraph = GLOBAL_GRAPH
        .plus(new RequestModule(request, response, registeredAction.getPath()))
        .plus(REQUEST_MODULES);
    Metrics metrics = requestGraph.get(Metrics.class);
    try {
      requestGraph.inject(action).run();
    } catch (HttpErrorException e) {
      metrics.setResponseCode(e.getResponseCode());
      metrics.addActivity("error")// Mark this as user error.
      response.sendError(e.getResponseCode(), e.getMessage());
    } catch (Exception e) {
View Full Code Here

TOP

Related Classes of dagger.ObjectGraph

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.