code: public static void installResourceExtension(String host, int port, String user, String password, Authentication authType)
      throws IOException
    {
      // create the client
      DatabaseClient client = DatabaseClientFactory.newClient(host, port, user, password, authType);
  
      // create a manager for resource extensions
      ResourceExtensionsManager resourceMgr = client.newServerConfigManager().newResourceExtensionsManager();
  
      // specify metadata about the resource extension
      ExtensionMetadata metadata = new ExtensionMetadata();
      metadata.setTitle("Document Splitter Resource Services");
      metadata.setDescription("This plugin supports splitting input into multiple documents");
      metadata.setProvider("MarkLogic");
      metadata.setVersion("0.1");
  
      // acquire the resource extension source code
      InputStream sourceStream = Util.openStream(
        "scripts"+File.separator+DocumentSplitter.NAME+".xqy");
      if (sourceStream == null)
        throw new RuntimeException("Could not read example resource extension");
  
      // create a handle on the extension source code
      InputStreamHandle handle = new InputStreamHandle(sourceStream);
      handle.set(sourceStream);
  
      // write the resource extension to the database
      resourceMgr.writeServices(DocumentSplitter.NAME, handle, metadata,
        new MethodParameters(MethodType.POST));
  
      System.out.println("Installed the resource extension on the server");
  
      // release the client
      client.release();
    }
docs: install the resource extension on the server