Beispiel #1
0
  @Override
  public void deleteXADataSource(XADataSource dataSource, final AsyncCallback<Boolean> callback) {

    AddressBinding address = xadsMetaData.getAddress();
    ModelNode addressModel = address.asResource(baseadress.getAdress(), dataSource.getName());

    ModelNode operation = xaDataSourceAdapter.fromEntity(dataSource);
    operation.get(OP).set(REMOVE);
    operation.get(ADDRESS).set(addressModel.get(ADDRESS));

    dispatcher.execute(
        new DMRAction(operation),
        new SimpleCallback<DMRResponse>() {

          @Override
          public void onFailure(Throwable caught) {
            callback.onFailure(caught);
          }

          @Override
          public void onSuccess(DMRResponse result) {
            boolean wasSuccessful = responseIndicatesSuccess(result);
            callback.onSuccess(wasSuccessful);
          }
        });
  }
Beispiel #2
0
  @Override
  public void createXADataSource(
      XADataSource datasource, final AsyncCallback<ResponseWrapper<Boolean>> callback) {

    ModelNode operation = new ModelNode();
    operation.get(OP).set(COMPOSITE);
    operation.get(ADDRESS).setEmptyList();

    List<ModelNode> steps = new ArrayList<ModelNode>();

    // create XA datasource
    AddressBinding address = xadsMetaData.getAddress();
    ModelNode addressModel = address.asResource(baseadress.getAdress(), datasource.getName());

    ModelNode createResource = xaDataSourceAdapter.fromEntity(datasource);
    createResource.get(OP).set(ADD);
    createResource.get(ADDRESS).set(addressModel.get(ADDRESS));

    steps.add(createResource);

    // create xa properties
    for (PropertyRecord prop : datasource.getProperties()) {
      ModelNode createProperty = new ModelNode();
      createProperty.get(ADDRESS).set(addressModel.get(ADDRESS));
      createProperty.get(ADDRESS).add("xa-datasource-properties", prop.getKey());
      createProperty.get(OP).set(ADD);
      createProperty.get(VALUE).set(prop.getValue());

      steps.add(createProperty);
    }

    operation.get(STEPS).set(steps);

    dispatcher.execute(
        new DMRAction(operation),
        new SimpleCallback<DMRResponse>() {

          @Override
          public void onFailure(Throwable caught) {
            callback.onFailure(caught);
          }

          @Override
          public void onSuccess(DMRResponse result) {

            callback.onSuccess(ModelAdapter.wrapBooleanResponse(result));
          }
        });
  }
Beispiel #3
0
  @Override
  public void enableXADataSource(
      XADataSource dataSource,
      boolean doEnable,
      final AsyncCallback<ResponseWrapper<Boolean>> callback) {

    final String opName = doEnable ? "enable" : "disable";

    AddressBinding address = xadsMetaData.getAddress();
    ModelNode addressModel = address.asResource(baseadress.getAdress(), dataSource.getName());

    ModelNode operation = xaDataSourceAdapter.fromEntity(dataSource);
    operation.get(OP).set(opName);
    operation.get(ADDRESS).set(addressModel.get(ADDRESS));

    if (!doEnable) operation.get(OPERATION_HEADERS).get(ALLOW_RESOURCE_SERVICE_RESTART).set(true);

    dispatcher.execute(
        new DMRAction(operation),
        new SimpleCallback<DMRResponse>() {

          @Override
          public void onFailure(Throwable caught) {
            callback.onFailure(caught);
          }

          @Override
          public void onSuccess(DMRResponse result) {
            ModelNode response = result.get();

            ResponseWrapper<Boolean> wrapper =
                new ResponseWrapper<Boolean>(
                    response.get("outcome").asString().equals("success"), response);
            callback.onSuccess(wrapper);
          }
        });
  }