Пример #1
0
  protected void initializeChannels(
      KaaInternalChannelManager channelManager, TransportContext transportContext) {
    DefaultBootstrapDataProcessor bootstrapDataProcessor = new DefaultBootstrapDataProcessor();
    bootstrapDataProcessor.setBootstrapTransport(transportContext.getBootstrapTransport());

    DefaultOperationDataProcessor operationsDataProcessor =
        new DefaultOperationDataProcessor(kaaClientState);
    operationsDataProcessor.setConfigurationTransport(transportContext.getConfigurationTransport());
    operationsDataProcessor.setEventTransport(transportContext.getEventTransport());
    operationsDataProcessor.setMetaDataTransport(transportContext.getMdTransport());
    operationsDataProcessor.setNotificationTransport(transportContext.getNotificationTransport());
    operationsDataProcessor.setProfileTransport(transportContext.getProfileTransport());
    operationsDataProcessor.setRedirectionTransport(transportContext.getRedirectionTransport());
    operationsDataProcessor.setUserTransport(transportContext.getUserTransport());
    operationsDataProcessor.setLogTransport(transportContext.getLogTransport());

    KaaDataChannel bootstrapChannel =
        new DefaultBootstrapChannel(this, kaaClientState, failoverManager);
    bootstrapChannel.setMultiplexer(bootstrapDataProcessor);
    bootstrapChannel.setDemultiplexer(bootstrapDataProcessor);
    channelManager.addChannel(bootstrapChannel);

    KaaDataChannel operationsChannel =
        new DefaultOperationTcpChannel(kaaClientState, failoverManager, failureListener);
    operationsChannel.setMultiplexer(operationsDataProcessor);
    operationsChannel.setDemultiplexer(operationsDataProcessor);
    channelManager.addChannel(operationsChannel);
  }
Пример #2
0
 protected DefaultLogCollector buildLogCollector(TransportContext transportContext) {
   return new DefaultLogCollector(
       transportContext.getLogTransport(),
       context.getExecutorContext(),
       channelManager,
       failoverManager);
 }
Пример #3
0
  AbstractKaaClient(
      KaaClientPlatformContext context,
      KaaClientStateListener listener,
      boolean isAutogeneratedKeys)
      throws IOException, GeneralSecurityException {

    this.context = context;
    this.stateListener = listener;

    if (context.getProperties() != null) {
      this.properties = context.getProperties();
    } else {
      this.properties = new KaaClientProperties();
    }
    this.properties.setBase64(context.getBase64());

    Map<TransportProtocolId, List<TransportConnectionInfo>> bootstrapServers =
        this.properties.getBootstrapServers();
    if (bootstrapServers == null || bootstrapServers.isEmpty()) {
      throw new RuntimeException("Unable to obtain list of bootstrap services."); // NOSONAR
    }

    for (Map.Entry<TransportProtocolId, List<TransportConnectionInfo>> cursor :
        bootstrapServers.entrySet()) {
      Collections.shuffle(cursor.getValue());
    }

    kaaClientState =
        new KaaClientPropertiesState(
            context.createPersistentStorage(),
            context.getBase64(),
            properties,
            isAutogeneratedKeys);

    TransportContext transportContext = buildTransportContext(properties, kaaClientState);

    bootstrapManager = buildBootstrapManager(properties, kaaClientState, transportContext);

    channelManager = buildChannelManager(bootstrapManager, bootstrapServers);
    failoverManager = buildFailoverManager(channelManager);
    channelManager.setFailoverManager(failoverManager);

    initializeChannels(channelManager, transportContext);

    bootstrapManager.setChannelManager(channelManager);
    bootstrapManager.setFailoverManager(failoverManager);

    profileManager = buildProfileManager(transportContext);
    notificationManager = buildNotificationManager(kaaClientState, transportContext);
    eventManager = buildEventManager(kaaClientState, transportContext);
    endpointRegistrationManager = buildRegistrationManager(kaaClientState, transportContext);
    logCollector = buildLogCollector(transportContext);
    configurationManager =
        buildConfigurationManager(properties, kaaClientState, context.getExecutorContext());

    transportContext.getRedirectionTransport().setBootstrapManager(bootstrapManager);
    transportContext.getBootstrapTransport().setBootstrapManager(bootstrapManager);
    transportContext.getProfileTransport().setProfileManager(profileManager);
    transportContext.getEventTransport().setEventManager(eventManager);
    transportContext.getNotificationTransport().setNotificationProcessor(notificationManager);
    transportContext
        .getConfigurationTransport()
        .setConfigurationHashContainer(configurationManager.getConfigurationHashContainer());
    transportContext
        .getConfigurationTransport()
        .setConfigurationProcessor(configurationManager.getConfigurationProcessor());
    transportContext
        .getUserTransport()
        .setEndpointRegistrationProcessor(endpointRegistrationManager);
    transportContext.getLogTransport().setLogProcessor(logCollector);
    transportContext.initTransports(this.channelManager, this.kaaClientState);

    eventFamilyFactory = new EventFamilyFactory(eventManager, context.getExecutorContext());
  }