コード例 #1
0
 private void removeDataSources() throws Exception {
   NDataSourceAdminServiceClient dataSourceAdminClient =
       new NDataSourceAdminServiceClient(
           dssContext.getContextUrls().getBackEndUrl(), sessionCookie);
   dataSourceAdminClient.deleteDataSource("IN_MEMORY_SAMPLE_DS");
   dataSourceAdminClient.deleteDataSource("ECHO_SAMPLE_DS");
   Thread.sleep(1000);
 }
コード例 #2
0
  private void addDataSources() throws Exception {
    NDataSourceAdminServiceClient dataSourceAdminClient =
        new NDataSourceAdminServiceClient(
            dssContext.getContextUrls().getBackEndUrl(), sessionCookie);

    // Adding IN_MEMORY_SAMPLE_DS data source
    WSDataSourceMetaInfo sampleDSSourceMetaInfo = new WSDataSourceMetaInfo();
    sampleDSSourceMetaInfo.setName("IN_MEMORY_SAMPLE_DS");
    sampleDSSourceMetaInfo.setDescription("A sample in-memory data source");
    WSDataSourceMetaInfo_WSDataSourceDefinition dataSourceDefinition =
        new WSDataSourceMetaInfo_WSDataSourceDefinition();

    dataSourceDefinition.setType("DS_CUSTOM_TABULAR");
    String sampleDsConfig =
        "<configuration xmlns:svns=\"http://org.wso2.securevault/configuration\" xmlns:xml=\"http://www.w3.org/XML/1998/namespace\">"
            + "   <customDataSourceClass>org.wso2.carbon.dataservices.core.custom.datasource.InMemoryDataSource</customDataSourceClass>"
            + "   <customDataSourceProps><property name=\"inmemory_datasource_schema\">{Vehicles:[ID,Model,Classification,Year]}</property>"
            + "                        <property name=\"inmemory_datasource_records\">"
            + "                          {Vehicles:[[\"S10_1678\",\"Harley Davidson Ultimate Chopper\",\"Motorcycles\",\"1969\"],"
            + "                                     [\"S10_1949\",\"Alpine Renault 1300\",\"Classic Cars\",\"1952\"],"
            + "                                     [\"S10_2016\",\"Moto Guzzi 1100i\",\"Motorcycles\",\"1996\"],"
            + "                                     [\"S10_4698\",\"Harley-Davidson Eagle Drag Bike\",\"Motorcycles\",\"2003\"],"
            + "                                     [\"S10_4757\",\"Alfa Romeo GTA\",\"Classic Cars\",\"1972\"],"
            + "                                     [\"S10_4962\",\"LanciaA Delta 16V\",\"Classic Cars\",\"1962\"],"
            + "                                     [\"S12_1099\",\"Ford Mustang\",\"Classic Cars\",\"1968\"],"
            + "                                     [\"S12_1108\",\"Ferrari Enzo\",\"Classic Cars\",\"2001\"]]}"
            + "                        </property></customDataSourceProps>"
            + "</configuration>";

    dataSourceDefinition.setDsXMLConfiguration(sampleDsConfig);

    sampleDSSourceMetaInfo.setDefinition(dataSourceDefinition);
    dataSourceAdminClient.addDataSource(sampleDSSourceMetaInfo);
    Thread.sleep(1000);

    // Adding  ECHO_SAMPLE_DS data source
    WSDataSourceMetaInfo echoSampleSourceMetaInfo = new WSDataSourceMetaInfo();
    echoSampleSourceMetaInfo.setName("ECHO_SAMPLE_DS");
    echoSampleSourceMetaInfo.setDescription("A sample in-memory data source");
    WSDataSourceMetaInfo_WSDataSourceDefinition echoSampleDSDefinition =
        new WSDataSourceMetaInfo_WSDataSourceDefinition();

    echoSampleDSDefinition.setType("DS_CUSTOM_TABULAR");
    String echoSampleDsConfig =
        "<configuration xmlns:svns=\"http://org.wso2.securevault/configuration\" xmlns:xml=\"http://www.w3.org/XML/1998/namespace\">"
            + "<customDataSourceClass>org.wso2.carbon.dataservices.core.custom.datasource.InMemoryDataSource</customDataSourceClass>"
            + "<customDataSourceProps>"
            + "<property name=\"p1\">val1</property>"
            + "<property name=\"p2\">val2</property>"
            + "</customDataSourceProps>"
            + "</configuration>";

    echoSampleDSDefinition.setDsXMLConfiguration(echoSampleDsConfig);

    echoSampleSourceMetaInfo.setDefinition(echoSampleDSDefinition);
    dataSourceAdminClient.addDataSource(echoSampleSourceMetaInfo);
    Thread.sleep(1000);
  }