BVB Source Codes

che Show WsAgentModule.java Source code

Return Download che: download WsAgentModule.java Source code - Download che Source code - Type:.java
  1. /*******************************************************************************
  2.  * Copyright (c) 2012-2017 Codenvy, S.A.
  3.  * All rights reserved. This program and the accompanying materials
  4.  * are made available under the terms of the Eclipse Public License v1.0
  5.  * which accompanies this distribution, and is available at
  6.  * http://www.eclipse.org/legal/epl-v10.html
  7.  *
  8.  * Contributors:
  9.  *   Codenvy, S.A. - initial API and implementation
  10.  *******************************************************************************/
  11. package org.eclipse.che.wsagent.server;
  12.  
  13. import com.google.inject.AbstractModule;
  14. import com.google.inject.Provides;
  15. import com.google.inject.multibindings.MapBinder;
  16. import com.google.inject.name.Names;
  17.  
  18. import org.eclipse.che.ApiEndpointAccessibilityChecker;
  19. import org.eclipse.che.EventBusURLProvider;
  20. import org.eclipse.che.UriApiEndpointProvider;
  21. import org.eclipse.che.UserTokenProvider;
  22. import org.eclipse.che.api.auth.oauth.OAuthTokenProvider;
  23. import org.eclipse.che.api.core.jsonrpc.RequestHandler;
  24. import org.eclipse.che.api.core.jsonrpc.RequestTransmitter;
  25. import org.eclipse.che.api.core.jsonrpc.impl.WebSocketToJsonRpcDispatcher;
  26. import org.eclipse.che.api.core.jsonrpc.impl.WebSocketTransmitter;
  27. import org.eclipse.che.api.core.rest.ApiInfoService;
  28. import org.eclipse.che.api.core.rest.CoreRestModule;
  29. import org.eclipse.che.api.core.util.FileCleaner.FileCleanerModule;
  30. import org.eclipse.che.api.core.websocket.WebSocketMessageReceiver;
  31. import org.eclipse.che.api.core.websocket.WebSocketMessageTransmitter;
  32. import org.eclipse.che.api.core.websocket.impl.BasicWebSocketMessageTransmitter;
  33. import org.eclipse.che.api.core.websocket.impl.GuiceInjectorEndpointConfigurator;
  34. import org.eclipse.che.api.git.GitConnectionFactory;
  35. import org.eclipse.che.api.git.GitUserResolver;
  36. import org.eclipse.che.api.git.LocalGitUserResolver;
  37. import org.eclipse.che.api.project.server.ProjectApiModule;
  38. import org.eclipse.che.api.ssh.server.HttpSshServiceClient;
  39. import org.eclipse.che.api.ssh.server.SshServiceClient;
  40. import org.eclipse.che.api.user.server.spi.PreferenceDao;
  41. import org.eclipse.che.commons.lang.Pair;
  42. import org.eclipse.che.git.impl.jgit.JGitConnectionFactory;
  43. import org.eclipse.che.inject.DynaModule;
  44. import org.eclipse.che.plugin.java.server.rest.WsAgentURLProvider;
  45. import org.eclipse.che.security.oauth.RemoteOAuthTokenProvider;
  46.  
  47. import javax.inject.Named;
  48. import java.net.URI;
  49.  
  50. /**
  51.  * @author Evgen Vidolob
  52.  */
  53. @DynaModule
  54. public class WsAgentModule extends AbstractModule {
  55.     @Override
  56.     protected void configure() {
  57.         bind(ApiInfoService.class);
  58.  
  59.         bind(PreferenceDao.class).to(org.eclipse.che.RemotePreferenceDao.class);
  60.  
  61.         bind(OAuthTokenProvider.class).to(RemoteOAuthTokenProvider.class);
  62.         bind(SshServiceClient.class).to(HttpSshServiceClient.class);
  63.  
  64.         bind(org.eclipse.che.plugin.ssh.key.script.SshKeyProvider.class)
  65.                 .to(org.eclipse.che.plugin.ssh.key.script.SshKeyProviderImpl.class);
  66.  
  67.         install(new CoreRestModule());
  68.         install(new FileCleanerModule());
  69.         install(new ProjectApiModule());
  70.         install(new org.eclipse.che.swagger.deploy.DocsModule());
  71.         install(new org.eclipse.che.api.debugger.server.DebuggerModule());
  72.         install(new org.eclipse.che.commons.schedule.executor.ScheduleModule());
  73.  
  74.         bind(GitUserResolver.class).to(LocalGitUserResolver.class);
  75.         bind(GitConnectionFactory.class).to(JGitConnectionFactory.class);
  76.  
  77.         bind(URI.class).annotatedWith(Names.named("che.api")).toProvider(UriApiEndpointProvider.class);
  78.         bind(String.class).annotatedWith(Names.named("user.token")).toProvider(UserTokenProvider.class);
  79.  
  80.         bind(String.class).annotatedWith(Names.named("event.bus.url")).toProvider(EventBusURLProvider.class);
  81.         bind(ApiEndpointAccessibilityChecker.class);
  82.         bind(WsAgentAnalyticsAddresser.class);
  83.  
  84.         bind(String.class).annotatedWith(Names.named("wsagent.endpoint"))
  85.                           .toProvider(WsAgentURLProvider.class);
  86.  
  87.         configureJsonRpc();
  88.         configureWebSocket();
  89.     }
  90.  
  91.     //it's need for WSocketEventBusClient and in the future will be replaced with the property
  92.     @Named("notification.client.event_subscriptions")
  93.     @Provides
  94.     @SuppressWarnings("unchecked")
  95.     Pair<String, String>[] eventSubscriptionsProvider(@Named("event.bus.url") String eventBusURL) {
  96.         return new Pair[]{Pair.of(eventBusURL, "")};
  97.     }
  98.  
  99.     //it's need for EventOriginClientPropagationPolicy and in the future will be replaced with the property
  100.     @Named("notification.client.propagate_events")
  101.     @Provides
  102.     @SuppressWarnings("unchecked")
  103.     Pair<String, String>[] propagateEventsProvider(@Named("event.bus.url") String eventBusURL) {
  104.         return new Pair[]{Pair.of(eventBusURL, "")};
  105.     }
  106.  
  107.     private void configureWebSocket() {
  108.         requestStaticInjection(GuiceInjectorEndpointConfigurator.class);
  109.  
  110.         bind(WebSocketMessageTransmitter.class).to(BasicWebSocketMessageTransmitter.class);
  111.         bind(WebSocketMessageReceiver.class).to(WebSocketToJsonRpcDispatcher.class);
  112.     }
  113.  
  114.     private void configureJsonRpc() {
  115.         bind(RequestTransmitter.class).to(WebSocketTransmitter.class);
  116.  
  117.         MapBinder.newMapBinder(binder(), String.class, RequestHandler.class);
  118.     }
  119. }
  120.  
downloadWsAgentModule.java Source code - Download che Source code
Related Source Codes/Software:
Gource - oftware version control visualization ... 2017-01-10
FDFullscreenPopGesture - A UINavigationController's category to enable full... 2017-01-10
node-style-guide - A guide for styling your node.js / JavaScript code... 2017-01-09
ImageOptim - GUI image optimizer for Mac htt... 2017-01-09
falcon - Falcon is a low-level, high-performance Python fra... 2017-01-09
notepad-plus-plus - Notepad++ official repository h... 2017-01-10
waterline - An adapter-based ORM for Node.js with support for ... 2017-01-10
Workerman - An asynchronous event driven PHP framework for eas... 2017-01-10
structor - An advanced visual editor for React components ... 2017-01-10
golearn - Machine Learning for Go 2017-01-10
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top