コード例 #1
0
  public static void installResourceExtensionStrongTyped(DatabaseClient client) throws IOException {
    // create a manager for resource extensions
    ResourceExtensionsManager resourceMgr =
        client.newServerConfigManager().newResourceExtensionsManager();

    // specify metadata about the resource extension
    ExtensionMetadata metadata = new ExtensionMetadata();
    metadata.setTitle("Spelling Dictionary Resource Services");
    metadata.setDescription("This plugin supports spelling dictionaries");
    metadata.setProvider("MarkLogic");
    metadata.setVersion("0.1");

    // acquire the resource extension source code
    InputStream sourceStream =
        Util.openStream("scripts" + File.separator + DictionaryManager.NAME + ".xqy");
    if (sourceStream == null) throw new IOException("Could not read example resource extension");

    // create a handle on the extension source code
    InputStreamHandle handle = new InputStreamHandle();
    handle.set(sourceStream);

    // write the resource extension to the database
    resourceMgr.writeServices(
        DictionaryManager.NAME, handle, metadata, new MethodParameters(MethodType.GET));

    System.out.println("(Strong Typed) Installed the resource extension on the server");
  }
コード例 #2
0
  // clean up by deleting the example resource extension
  public static void tearDownExample(
      String host, int port, String user, String password, Authentication authType) {
    DatabaseClient client = DatabaseClientFactory.newClient(host, port, user, password, authType);

    ResourceExtensionsManager resourceMgr =
        client.newServerConfigManager().newResourceExtensionsManager();

    resourceMgr.deleteServices(DictionaryManager.NAME);

    client.release();
  }