Loading QoS Profiles from a Java Resource

2 posts / 0 new
Last post
Offline
Last seen: 6 years 2 months ago
Joined: 02/13/2013
Posts: 5
Loading QoS Profiles from a Java Resource

Hello,

I'm trying to load my QoS profiles from a file located inside my project's .jar file (a java resource). I know it's possible to do it manually from within my code but I wanted to know if it's possible to use the NDDS_QOS_PROFILES environment variable to somehow point to a java resource. I've seen a brief mention of URL groups in the Connext User Manual but it didn't help me much.

I'd really appreciate your advice,

Thanks,

Maor

rose's picture
Offline
Last seen: 4 weeks 1 hour ago
Joined: 08/22/2011
Posts: 146

Hello Maor, 

Unfortunately, there is no API that will load the XML profile directly from a .jar file.  This means that you need to load the XML from the .jar, and convert it into a string profile in your code, and add that string profile to the DomainParticipantFactory's QoS.

The best way to do this is:

  • get the DomainParticipantFactory's QoS by calling factory.get_qos(factoryQos);
  • get the XML file resource as a stream/convert it to a buffered input stream
  • read the file line by line
  • strip off everything before the first <dds> tag
  • line by line, add the remaining part of the file to the DomainParticipantFactory's QoS under profile.string_profile by calling factoryQos.profile.string_profile.add(line);
  • When done, call factory.set_qos(factoryQos); 

Thank you!

Rose