コード例 #1
0
  @PostConstruct
  public void start() {

    List<Module> modules = new ArrayList<Module>();
    modules.addAll(SiriCoreModule.getModules());
    Injector injector = Guice.createInjector(modules);

    _client = injector.getInstance(SiriClient.class);
    _lifecycleService = injector.getInstance(LifecycleService.class);

    _client.addServiceDeliveryHandler(_handler);

    if (_clientUrl != null) _client.setUrl(_clientUrl);
    if (_logRawXmlType != null) _client.setLogRawXmlType(_logRawXmlType);

    _lifecycleService.start();

    if (!CollectionsLibrary.isEmpty(_endpoints)) {

      SiriClientRequestFactory factory = new SiriClientRequestFactory();

      for (String endpoint : _endpoints) {

        Map<String, String> args = SiriLibrary.getLineAsMap(endpoint);
        SiriClientRequest request = factory.createSubscriptionRequest(args);

        SiriEndpointDetails context = new SiriEndpointDetails();

        String agencyId = args.get("AgencyId");
        if (agencyId != null) context.getDefaultAgencyIds().add(agencyId);

        String agencyIds = args.get("AgencyIds");
        if (agencyIds != null) {
          for (String id : agencyIds.split(",")) context.getDefaultAgencyIds().add(id);
        }

        request.setChannelContext(context);

        _client.handleRequest(request);
      }
    }
  }
コード例 #2
0
    @Override
    public void handleServiceDelivery(
        SiriChannelInfo channelInfo, ServiceDelivery serviceDelivery) {

      SiriEndpointDetails endpoint = channelInfo.getContext();

      if (endpoint == null) {
        _log.warn("could not find siri delivery info");
        return;
      }

      for (ESiriModuleType moduleType : ESiriModuleType.values()) {

        List<AbstractServiceDeliveryStructure> deliveriesForModule =
            SiriLibrary.getServiceDeliveriesForModule(serviceDelivery, moduleType);

        for (AbstractServiceDeliveryStructure deliveryForModule : deliveriesForModule) {

          _siriService.handleServiceDelivery(
              serviceDelivery, deliveryForModule, moduleType, endpoint);
        }
      }
    }