コード例 #1
0
 @Override
 protected void success(
     BasicMessageWithExtraData<AddDatasourceRequest> envelope, AddDatasourceResponse response) {
   response.setStatus(ResponseStatus.OK);
   response.setMessage(
       String.format("Added Datasource: %s", envelope.getBasicMessage().getDatasourceName()));
 }
コード例 #2
0
ファイル: MyRPCMDB.java プロジェクト: jsanda/hawkular-commons
 @Override
 protected SimpleBasicMessage onBasicMessage(
     BasicMessageWithExtraData<SimpleBasicMessage> msgWithExtraData) {
   SimpleBasicMessage msg = msgWithExtraData.getBasicMessage();
   log.infof("===> MDB received incoming RPC message [%s]", msg);
   SimpleBasicMessage response = new SimpleBasicMessage("ECHO! " + msg.getMessage());
   log.infof("===> MDB sending response RPC message [%s]", response);
   return response;
 }
コード例 #3
0
  @Override
  protected BinaryData execute(
      ModelControllerClient controllerClient,
      EndpointService<DMRNodeLocation, DMRSession> //
          endpointService,
      String modelNodePath,
      BasicMessageWithExtraData<AddDatasourceRequest> envelope,
      AddDatasourceResponse response,
      CommandContext context,
      DMRSession dmrContext)
      throws Exception {
    AddDatasourceRequest request = envelope.getBasicMessage();
    response.setDatasourceName(request.getDatasourceName());
    response.setXaDatasource(request.isXaDatasource());

    Map<String, String> props = request.getDatasourceProperties();
    final String dsDmrResourceType;
    final String dsPropsDmrResourceType;
    final ModelNode dsAdr;
    final CompositeOperationBuilder<?> batch;
    if (request.isXaDatasource()) {
      dsDmrResourceType = XA_DATASOURCE;
      dsPropsDmrResourceType = XA_DATASOURCE_PROPERTIES;
      dsAdr =
          OperationBuilder.address()
              .subsystemDatasources()
              .segment(dsDmrResourceType, request.getDatasourceName())
              .build();

      batch =
          OperationBuilder.composite() //
              .add() //
              .address(dsAdr) //
              .attribute(JNDI_NAME, request.getJndiName()) //
              .attribute(DRIVER_NAME, request.getDriverName()) //
              .attribute(XA_DATASOURCE_CLASS, request.getXaDataSourceClass()) //
              .attribute(USER_NAME, request.getUserName()) //
              .attribute(PASSWORD, request.getPassword()) //
              .parentBuilder();
    } else {
      dsDmrResourceType = DATASOURCE;
      dsPropsDmrResourceType = CONNECTION_PROPERTIES;
      dsAdr =
          OperationBuilder.address()
              .subsystemDatasources()
              .segment(dsDmrResourceType, request.getDatasourceName())
              .build();

      batch =
          OperationBuilder.composite() //
              .add() //
              .address(dsAdr) //
              .attribute(JNDI_NAME, request.getJndiName()) //
              .attribute(DRIVER_NAME, request.getDriverName()) //
              .attribute(DRIVER_CLASS, request.getDriverClass()) //
              .attribute(CONNECTION_URL, request.getConnectionUrl()) //
              .attribute(USER_NAME, request.getUserName()) //
              .attribute(PASSWORD, request.getPassword()) //
              .parentBuilder();
    }
    if (!props.isEmpty()) {
      for (Entry<String, String> prop : props.entrySet()) {
        batch
            .add() //
            .address()
            .segments(dsAdr)
            .segment(dsPropsDmrResourceType, prop.getKey())
            .parentBuilder() //
            .attribute(ModelDescriptionConstants.VALUE, prop.getValue())
            .parentBuilder();
      }
    }

    batch.execute(controllerClient).assertSuccess();

    // TODO replace with endpointService.discoverChildren(parentLocation, childType)
    endpointService.discoverAll();

    return null;
  }