Hi,
While referring to the resource extension example in Java API, I came across
two methods to install the resource extension namely 'shortcut' and 'strong
typed'. Following is the code for the methods :
// install the resource extension on the server
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);
// use either shortcut or strong typed IO
installResourceExtensionShortcut(client);
installResourceExtensionStrongTyped(client);
// release the client
client.release();
}
public static void installResourceExtensionShortcut(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");
// write the resource extension to the database
resourceMgr.writeServicesAs(DictionaryManager.NAME, sourceStream, metadata,
new MethodParameters(MethodType.GET));
System.out.println("(Shortcut) Installed the resource extension on the server");
}
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");
}?
Can somebody explain the difference between these two installation types?
Thanks,
Devesh Tyagi
"This e-mail and any attachments transmitted with it are for the sole use of
the intended recipient(s) and may contain confidential , proprietary or
privileged information. If you are not the intended recipient, please contact
the sender by reply e-mail and destroy all copies of the original message. Any
unauthorized review, use, disclosure, dissemination, forwarding, printing or
copying of this e-mail or any action taken in reliance on this e-mail is
strictly prohibited and may be unlawful."
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general