예제 #1
0
  @Override
  public void deleteXAConnectionProperty(
      String reference, PropertyRecord prop, final AsyncCallback<Boolean> callback) {
    AddressBinding address = xadsMetaData.getAddress();
    ModelNode operation = address.asResource(baseadress.getAdress(), reference);
    operation.get(ADDRESS).add("xa-datasource-properties", prop.getKey());
    operation.get(OPERATION_HEADERS).get(ALLOW_RESOURCE_SERVICE_RESTART).set(true);
    operation.get(OP).set(REMOVE);

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

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

          @Override
          public void onSuccess(DMRResponse response) {
            ModelNode result = response.get();
            callback.onSuccess(ModelAdapter.wasSuccess(result));
          }
        });
  }
예제 #2
0
  @Override
  public void loadDataSources(final AsyncCallback<List<DataSource>> callback) {

    AddressBinding address = dsMetaData.getAddress();
    ModelNode operation = address.asSubresource(baseadress.getAdress());
    operation.get(OP).set(READ_CHILDREN_RESOURCES_OPERATION);

    // System.out.println(operation);

    dispatcher.execute(
        new DMRAction(operation),
        new AsyncCallback<DMRResponse>() {
          @Override
          public void onFailure(Throwable caught) {
            callback.onFailure(caught);
          }

          @Override
          public void onSuccess(DMRResponse result) {

            ModelNode response = result.get();

            if (response.isFailure()) {
              callback.onFailure(new RuntimeException(response.getFailureDescription()));
            } else {
              List<DataSource> datasources =
                  dataSourceAdapter.fromDMRList(response.get(RESULT).asList());
              callback.onSuccess(datasources);
            }
          }
        });
  }
예제 #3
0
  @Override
  public void verifyConnection(
      final String dataSourceName,
      boolean isXA,
      final AsyncCallback<ResponseWrapper<Boolean>> callback) {
    AddressBinding address = isXA ? xadsMetaData.getAddress() : dsMetaData.getAddress();
    ModelNode operation = address.asResource(baseadress.getAdress(), dataSourceName);
    operation.get(OP).set("test-connection-in-pool");

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

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

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

            ResponseWrapper<Boolean> wrapped =
                new ResponseWrapper<Boolean>(!result.isFailure(), result);

            callback.onSuccess(wrapped);
          }
        });
  }
예제 #4
0
  @Override
  public void updateXADataSource(
      String name,
      Map<String, Object> changedValues,
      final AsyncCallback<ResponseWrapper<Boolean>> callback) {

    AddressBinding address = xadsMetaData.getAddress();
    ModelNode addressModel = address.asResource(baseadress.getAdress(), name);
    ModelNode operation = xaDataSourceAdapter.fromChangeset(changedValues, addressModel);

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

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

          @Override
          public void onSuccess(DMRResponse result) {

            callback.onSuccess(ModelAdapter.wrapBooleanResponse(result));
          }
        });
  }
예제 #5
0
  @Override
  public void savePoolConfig(
      boolean isXA,
      String name,
      Map<String, Object> changeset,
      final AsyncCallback<ResponseWrapper<Boolean>> callback) {

    String parentAddress = isXA ? "xa-data-source" : "data-source";

    AddressBinding address = poolMetaData.getAddress();
    ModelNode addressModel = address.asResource(baseadress.getAdress(), parentAddress, name);

    ModelNode operation = datasourcePoolAdapter.fromChangeset(changeset, addressModel);

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

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

          @Override
          public void onSuccess(DMRResponse result) {

            callback.onSuccess(ModelAdapter.wrapBooleanResponse(result));
          }
        });
  }
예제 #6
0
  @Override
  public void doFlush(boolean xa, String name, final AsyncCallback<Boolean> callback) {
    String parentAddress = xa ? "xa-data-source" : "data-source";
    AddressBinding address = poolMetaData.getAddress();

    ModelNode operation = address.asResource(baseadress.getAdress(), parentAddress, name);
    operation.get(OP).set("flush-all-connection-in-pool");

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

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

          @Override
          public void onSuccess(DMRResponse result) {

            ModelNode response = result.get();
            callback.onSuccess(!response.isFailure());
          }
        });
  }
예제 #7
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);
          }
        });
  }
예제 #8
0
  @Override
  public void createDataSource(
      final DataSource datasource, final AsyncCallback<ResponseWrapper<Boolean>> callback) {

    AddressBinding address = dsMetaData.getAddress();
    ModelNode addressModel = address.asResource(baseadress.getAdress(), datasource.getName());

    ModelNode operation = dataSourceAdapter.fromEntity(datasource);
    operation.get(OP).set(ADD);
    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) {
            ModelNode modelNode = result.get();
            boolean wasSuccessful = modelNode.get(OUTCOME).asString().equals(SUCCESS);

            callback.onSuccess(new ResponseWrapper<Boolean>(wasSuccessful, modelNode));
          }
        });
  }
예제 #9
0
  @Override
  public void loadDataSource(String name, boolean isXA, final AsyncCallback<DataSource> callback) {

    AddressBinding address = isXA ? xadsMetaData.getAddress() : dsMetaData.getAddress();
    ModelNode operation = address.asResource(baseadress.getAdress(), name);
    operation.get(OP).set(READ_RESOURCE_OPERATION);

    dispatcher.execute(
        new DMRAction(operation),
        new AsyncCallback<DMRResponse>() {
          @Override
          public void onFailure(Throwable caught) {
            callback.onFailure(caught);
          }

          @Override
          public void onSuccess(DMRResponse result) {

            ModelNode response = result.get();

            if (response.isFailure()) {
              callback.onFailure(new RuntimeException(response.getFailureDescription()));
            } else {
              DataSource datasource = dataSourceAdapter.fromDMR(response.get(RESULT).asObject());
              callback.onSuccess(datasource);
            }
          }
        });
  }
예제 #10
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));
          }
        });
  }
예제 #11
0
  @Override
  public void loadXAProperties(
      final String dataSourceName, final AsyncCallback<List<PropertyRecord>> callback) {

    AddressBinding address = xadsMetaData.getAddress();
    ModelNode operation = address.asResource(baseadress.getAdress(), dataSourceName);
    operation.get(OP).set(READ_CHILDREN_RESOURCES_OPERATION);
    operation.get(CHILD_TYPE).set("xa-datasource-properties");

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

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

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

            if (result.isFailure()) {
              callback.onFailure(
                  new RuntimeException(
                      "Failed to load XA properties for DS "
                          + dataSourceName
                          + ": "
                          + result.getFailureDescription()));
            } else {
              List<Property> properties = result.get(RESULT).asPropertyList();
              List<PropertyRecord> records = new ArrayList<PropertyRecord>(properties.size());
              for (Property prop : properties) {
                String name = prop.getName();
                String value = prop.getValue().asObject().get("value").asString();
                PropertyRecord propertyRecord = factory.property().as();
                propertyRecord.setKey(name);
                propertyRecord.setValue(value);
                records.add(propertyRecord);
              }

              callback.onSuccess(records);
            }
          }
        });
  }
예제 #12
0
  @Override
  public void enableDataSource(
      DataSource dataSource,
      boolean doEnable,
      final AsyncCallback<ResponseWrapper<Boolean>> callback) {

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

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

    ModelNode operation = dataSourceAdapter.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);

    // System.out.println(operation);

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

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

          @Override
          public void onSuccess(DMRResponse result) {

            ModelNode modelNode = result.get();
            ResponseWrapper<Boolean> response =
                new ResponseWrapper<Boolean>(
                    modelNode.get(OUTCOME).asString().equals(SUCCESS), modelNode);

            callback.onSuccess(response);
          }
        });
  }
예제 #13
0
  @Override
  public void loadPoolConfig(
      boolean isXA, final String name, final AsyncCallback<ResponseWrapper<PoolConfig>> callback) {

    String parentAddress = isXA ? "xa-data-source" : "data-source";
    AddressBinding address = poolMetaData.getAddress();

    ModelNode operation = address.asResource(baseadress.getAdress(), parentAddress, name);
    operation.get(OP).set(READ_RESOURCE_OPERATION);
    operation.get(INCLUDE_RUNTIME).set(Boolean.TRUE);

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

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

          @Override
          public void onSuccess(DMRResponse result) {

            ModelNode response = result.get();

            EntityAdapter<PoolConfig> adapter =
                new EntityAdapter<PoolConfig>(PoolConfig.class, metaData)
                    .with(
                        new KeyAssignment() {
                          @Override
                          public Object valueForKey(String key) {
                            return name;
                          }
                        });
            PoolConfig poolConfig = adapter.fromDMR(response.get(RESULT));
            callback.onSuccess(new ResponseWrapper<PoolConfig>(poolConfig, response));
          }
        });
  }
예제 #14
0
  @Override
  public void loadConnectionProperties(
      String reference, final AsyncCallback<List<PropertyRecord>> callback) {
    AddressBinding address = dsMetaData.getAddress();
    ModelNode operation = address.asResource(baseadress.getAdress(), reference);
    operation.get(OP).set(READ_CHILDREN_RESOURCES_OPERATION);
    operation.get(CHILD_TYPE).set("connection-properties");

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

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

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

            List<Property> properties = result.get(RESULT).asPropertyList();
            List<PropertyRecord> records = new ArrayList<PropertyRecord>(properties.size());
            for (Property prop : properties) {
              String name = prop.getName();
              String value = prop.getValue().asObject().get("value").asString();
              PropertyRecord propertyRecord = factory.property().as();
              propertyRecord.setKey(name);
              propertyRecord.setValue(value);
              records.add(propertyRecord);
            }

            callback.onSuccess(records);
          }
        });
  }
예제 #15
0
 public static ModelNode get() {
   return instance.getAdress();
 }