Hi Devesh,

I was curious about this one, too, so I asked one of my colleagues (Sam 
Mefford) about it. Here's what he said:

It looks to me like the major difference is that one uses the shortcut method 
writeServicesAs (directly passing in the sourceStream) whereas the other uses 
the strongly-typed method writeServices (passing in a handle which wraps the 
sourceStream).

The difference between those two methods is explained here: 
http://www.marklogic.com/blog/io-shortcut-marklogic-java-client-api/
And here http://docs.marklogic.com/javadoc/client/overview-summary.html under 
“Working with Document Managers”

Dave.

--
Dave Cassel
Developer Community Manager
MarkLogic Corporation<http://www.marklogic.com/>


From: <Tyagi>, Devesh <[email protected]<mailto:[email protected]>>
Reply-To: MarkLogic Developer Discussion 
<[email protected]<mailto:[email protected]>>
Date: Wednesday, November 5, 2014 at 12:55 AM
To: "[email protected]<mailto:[email protected]>" 
<[email protected]<mailto:[email protected]>>
Subject: [MarkLogic Dev General] Shortcut and Strong typed in resource 
extension installation


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

Reply via email to