empty string

User f564ccf382

03-10-2005 17:39:46

To whom it concerns,





I have written a plugin (My_logPlugin) which extends the logPPlugin class. In the licenses.dat file which is stored at /root/.chemaxon I added the following:





chemaxon.marvin.calculations.My_logPlugin=27071966





In my class My_logPlugin I havethe code





My_logPlugin x = new My_logPlugin();





System.out.println("License key for My_logPlugin is :");


System.out.println(x.getLicenseKey());





But, I get an empty string returned instead of 27071966.





Could you please advise me as to what I'm doing wrong? Do I need a specific license key from ChemAxon for each of my own Plugins?





Kind regards,


Miriam

ChemAxon fb166edcbd

03-10-2005 22:48:15

This below applies to the current Marvin release, it will be much simpler in the next release (4.0.2).





First of all: you set the plugin license key within the code by overriding


Code:



plugin.getLicenseKey()





as written in


http://www.chemaxon.com/marvin/doc/dev/plugins.html


and users set the key in the licenses.dat file which will be checked against the hard-coded license key.





Unfortunately if you extend an existing plugin class then you cannot change its license key, since the method plugin.getLicenseKey() is declared final for safety reasons.


To validate a plugin you should call


Code:



plugin.validate(<license key>);





It is only after this call that the


Code:



plugin.getLicenseKey()





method returns the real license key instead of the empty string.





However, as I have mentioned, the current implementation makes it impossible to subclass a plugin and change its license key (this would be possible by overriding its


getLicenseKey() method which is final) - since in this case it would be possible to


subclass a plugin only to change its license key.





The good news is that I have changed this mechanism - from the next release (4.0.2)


you should only override the


Code:



plugin.validate(<license key>)





by a simple string comparison with the real key - but this validate() is still declared final for safety (otherwise someone could just subclass the plugin and change its validate() method only). I will think about a solution for this problem.





In the meantime, if you want to write a custom logP plugin with a separate license key then unfortunately you should subclass CalculatorPlugin directly and implement the getLicenseKey() (or validate() from the next rellease()) as written in


http://www.chemaxon.com/marvin/doc/dev/plugins.html





Then you can write code like:





Code:



My_logPlugin x = new My_logPlugin();


x.validate("27071966");





System.out.println("License key for My_logPlugin is :");


System.out.println(x.getLicenseKey());








Then you will get "27071966" instead of the empty string.





PS: I will ask the approximate date for the Marvin 4.0.2 tomorrow.

ChemAxon fb166edcbd

04-10-2005 15:27:43

Nora wrote:



The good news is that I have changed this mechanism - from the next release (4.0.2)


you should only override the


Code:



plugin.validate(<license key>)





by a simple string comparison with the real key - but this validate() is still declared final for safety (otherwise someone could just subclass the plugin and change its validate() method only). I will think about a solution for this problem.


I have implemented a somewhat tricky solution:


Code:
plugin.validate(String license)



is no longer required to be declared final, and all superclasses' license keys are checked by the plugin handling mechanism.





This means that if you extend a plugin then your plugin will automatically require the license keys for all superclasses. You can add a specific license key by implementing
Code:
plugin.validate(String license)



For example:





Code:



public class My_logPPlugin extends logPPlugin {





    public boolean validate(String license) {


        return "12345678".equals(license);


    }


}








This will set the plugin license key to "12345678" while the logPPlugin license is also required. You should set these two license keys in the licenses.dat file.





Marvin 4.0.2 release: there will be a test-release this week, the precise date of the final 4.0.2 release is not known yet, probably next week.

User f564ccf382

04-10-2005 15:40:19

Hi Nora,





Thanks for all your help on the license issue. I would like to be able to use the classes Mass and MolHandler. But, I can't find them. Would it be possible for you to send them to me?








Regards,


Miiram

ChemAxon fb166edcbd

04-10-2005 17:08:34

MolHandler is part of JChem, not Marvin:


http://www.chemaxon.com/jchem/doc/api/chemaxon/util/MolHandler.html


You should download JChem:


http://www.chemaxon.com/jchem/


to use it. If you only need this class for molecule import then you can just as well use


MolImporter:


http://www.chemaxon.com/marvin/doc/api/chemaxon/formats/MolImporter.html


which is part of Marvin.





Also the class Mass is part of JChem:


http://www.chemaxon.com/jchem/doc/api/chemaxon/descriptors/scalars/Mass.html


but this is a scalar descriptor used in molecular similarity calculations.


If you simply need to compute the molecular mass then use





MoleculeGraph.getMass()

ChemAxon fb166edcbd

06-10-2005 10:52:55

A pre-released Marvin 4.0.2 (test version) can be downloaded from:


http://www.chemaxon.com/test/marvin/