VMware {code} Community
alstraub
Contributor
Contributor

saving data to local file system alternatives

I noticed that the latest fling has advised against this practice.

I had planned to use the GlobalView example to store a file with global plugin settings such as host address of an external server for use by the Data Provider Adapter.  I would prefer this to be persistent in vsphere instead of leaving it to a setting in browser storage. Do you have any other sugestions for saving plugin settings?

0 Kudos
3 Replies
_vladi_
VMware Employee
VMware Employee

Hi,

You are correct. For security and stability reasons storing files on the vCenter server is discouraged for plugins and will not be supported going forward.

Alternatives are the browser storage, the plugin's backend server that should serve domain-specific settings (and usually has the right context for that) or the plugin's own resources/configuration files. Ofc not every setting is suitable for any of the given options (like in the example above) but please explore these possibilities for your particular setting use-cases.

Cheers,

Vladimir

0 Kudos
alstraub
Contributor
Contributor

Thanks for the reply. I think the third method: "plugin's own resources/configuration files" Is what I am looking for. Do you have examples to reference on the best practice of how to implement this?
0 Kudos
_vladi_
VMware Employee
VMware Employee

I don't have a sample for this option but it should basically involve:

- adding a configuration file to your .jar service bundle.

- adding the folder location of the configuration file to the Bundle-Classpath section of the jar's MANIFEST.MF.

- reading your configuration file as a resource using the correct class loader. If needed you may temporarily set the class loader to a class from the same .jar bundle (e.g. getClass().getClassLoader()). This is done using Thread.currentThread().setContextClassLoader(<new-class-loader-here>) but make sure to restore the old class loader after reading the file.

Cheers,

Vladi

0 Kudos