Using FSDMsg in an Application server

45 vues
Accéder directement au premier message non lu

Paul Irving

non lue,
26 avr. 2017, 08:20:2226/04/2017
à jPOS Users
Hi,

This is a high level question about using FSDMsg when deploying to an application server.

For my ISO projects using ISOMsg the packagers are read using this:

public static ISOPackager getPackager(final String filename) throws ISOException {  
        InputStream is = XmlPackagerFactory.class.getResourceAsStream("/com/mypackage/jpos/packgers/xml/" + filename);  
        return new GenericPackager(is);  
}

For the FSDMsg I want to include the xml files as part of the jar, so I retrieve them using:

public static final URL BASE = XmlFSDSchemaFactory.class.getResource("/com/mypackage/jpos/packgers/xml/FSDMsg/")
public static final String PROTOCOL = "file:";

Now this works happily for a stand alone java application, but when the jar is deployed into an application server, the path retrieved is incorrectly. However, if I use the following in the app server:

InputStream is = XmlFSDSchemaFactory.class.getResourceAsStream("/com/mypackage/jpos/packgers/xml/" + filename);

then the path to the file is always correct and the I can read the XML schema as an inputStream. So it seems getResourceAsStream is more portable than getResourceAsStream for some reason.

As my application needs to run standalone or deployed in an App server could anyone recommend a 'portable' way of getting the XML schema file paths?? Or a way of using an input stream instead of file paths??

Thanks in advance

Paul


Alejandro Revilla

non lue,
26 avr. 2017, 18:06:2526/04/2017
à jPOS Users

Take a look at FSDMsg implementation, in particular the loadSchema message around line 605:

https://github.com/jpos/jPOS/blob/master/jpos/src/main/java/org/jpos/util/FSDMsg.java#L605

If the schema prefix is jar: it picks it from the classpath.

Let us know if that works for you.




Paul Irving

non lue,
16 juin 2017, 08:19:5916/06/2017
à jpos-...@googlegroups.com
Hi Alejandro,

Apologies in the delay, but this works perfectly, thank you.

I still have other issues, but that's for another question :-)  

Paul

--
--
jPOS is licensed under AGPL - free for community usage for your open-source project. Licenses are also available for commercial usage. Please support jPOS, contact: sa...@jpos.org
---
You received this message because you are subscribed to a topic in the Google Groups "jPOS Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jpos-users/GQUrRQTUhCU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jpos-users+unsubscribe@googlegroups.com.
To post to this group, send email to jpos-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jpos-users/CAAgSK%3Dm7O%2B3Zr43B2aY-P%3D3UUt6tHiNLjx2%2BYx9T79SmjjZ-vg%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.

Alejandro Revilla

non lue,
16 juin 2017, 08:58:4516/06/2017
à jPOS Users
Awesome. Thanks for the heads-up.



You received this message because you are subscribed to the Google Groups "jPOS Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jpos-users+unsubscribe@googlegroups.com.

To post to this group, send email to jpos-...@googlegroups.com.
Répondre à tous
Répondre à l'auteur
Transférer
0 nouveau message