Once you have created a V1Connector instance, you'll need to create an instance of the Services class, which is the primary object that you will use to perform actions with the VersionOne API. There are three constructors for the Services class. All of them require a V1Connector instance, however.
Creating a V1Connector Instance
V1Connector connector = V1Connector .withInstanceUrl("<Server Base URI>") .withUserAgentHeader("AppName", "1.0") .withAccessToken("1.rWM8lKLk+PnyFxkEWVX5Kl2u6Jk=") .build();
To create an instance of Services that creates an IMetaModel instance for you automatically, just use the one-parameter version of the constructor, passing in your V1Connector instance. By default, the connector will not pre-load the Meta information. If you need to do that, see the next overload.
IServices services = new Services(connector);
Services(V1Connector connector, boolean preLoadMeta)
If you'd like to force the connector to pre-load the Meta information before you work with the Services instance, call this version of the constructor and specify true for the second parameter. Note that this can cause the start-up time for your code to take a long time, but it is ultimately faster if you do a significant number of queries against a large variety of Asset types or Attributes. If you work with a smaller variety, then allowing the connector to dynamically fetch Meta is a better approach.
IServices services = new Services(connector, true);
Services(V1Connector connector, IMetaModel metaModel)
Though it would rarely be needed for most purposes, if you want complete control over creating the IMetaModel instance that you configure your Services instance with, you can use the third overload of the Services constructor. One scenario for when you would use this is if you wish to create your own implementation of the IMetaModel interface instead of relying upon the library-provided MetaModel class. You might do this if you wanted to cache definitions on disk instead of reaching out to the instance for every call.
The following sample produces the same result as the previous constructor example:
// Using the library-provided MetaModel class's constructor IMetaModel metaModel = new MetaModel(connector, false); // false indicates to NOT preload meta IServices services = new Services(connector, metaModel);
If you do implement your own implementation of the IMetaModel interface, then your code would look something like this:
Callstack: at (VersionOne_Connect/Developer_Library/Get_an_SDK/Java_SDK/Creating_a_Services_Object), /content/body/div/div/div/pre, line 3, column 12