0

i have some questions about MobileFirst Adapters:

  1. We are implementing javascript adapters on a MobileFirst 8 server. Where is the best place to write javascript utils functions?

  2. I also have some utils on java classes (called from javascript adapters) and i need to use the ConfigurationAPI class to get properties. The problem is that the configurationAPI variable (instantiated with the @Context annotation) is always null. Why? How can i get properties values from Java code?

  3. I have a lot of properties (for example low-level backend endpoints) that should be shared between all the adapters. At the moment i used the <property name="" displayName="" defaultValue="" /> syntax, should i copy and paste them in all adapters?! Or where should i put them?

Thank you

1 Answers1

0

We are implementing javascript adapters on a MobileFirst 8 server. Where is the best place to write javascript utils functions?

JavaScript adapters allow for a single .js file, so your best place for any adapters JavaScript code is the same .js file...

I have a lot of properties (for example low-level backend endpoints) that should be shared between all the adapters. At the moment i used the <property name="" displayName="" defaultValue="" /> syntax, should i copy and paste them in all adapters?! Or where should i put them?

See my answer to the following question. Once you add custom properties you should be able to handle them in the same way I mention handling other values from the adapter.xml file: Unable to build adapters using profiles and properties in Maven

I also have some utils on java classes (called from javascript adapters) and i need to use the ConfigurationAPI class to get properties. The problem is that the configurationAPI variable (instantiated with the @Context annotation) is always null. Why? How can i get properties values from Java code?

I've sent a question internally and will let you know once I get an answer.

Community
  • 1
  • 1
Idan Adar
  • 44,156
  • 13
  • 50
  • 89
  • Thanks for the reply.. 1. So should i copy and paste the utils in all adapters .js files? 2. I tried those MFP CLI commands, but it exports only the connectivity parameters. I need to know if i can share custom properties between adapters without copy and paste them in all adapter.xml files. 3. Ok thank you very much! – Gianluca Innocente Dec 21 '16 at 10:25
  • See Nathan's comment - condigurationApi is available in pure Java adapters and not in Java code called in JavaScript adapter. You may need to create copies... – Idan Adar Dec 21 '16 at 10:31