Load variables like deploy xml file

152 views
Skip to first unread message

dannygaviria

unread,
Feb 26, 2016, 8:23:38 AM2/26/16
to jPOS Users
Hi,

I access a database every transaction for consulting product status and others, i want to load in  variable (array, object, ??) this information when the Q2 begin, or create an special xml like deploy files.

<data>
<products>
<item><max>10</max><min>5</min> </item>
<item><max>15</max><min>10</min> </item>
</products>
</data>

1- thats is pposible?
2- Exists some option.
3- How to create the variable, and how to persists into the transaction participants.

My initial idea is create an xml and load into arrray. and when i need the data search in the array.

Thanks.

Alejandro Revilla

unread,
Feb 26, 2016, 1:09:42 PM2/26/16
to jPOS Users
​​

You can use an ‘xml-config’ element.

The ‘xml-config’ element is handled by org.jpos.q2.qbean.QXmlConfig that basically stores a reference to itself in the NameRegistrar.

Then you get it like this:

        Element cfg = QXmlConfig.getConfiguration (CONFIG_NAME, CONFIG_TIMEOUT);

Element is an org.jdom.Element.

Here is a sample config we use in QI (Q2 UI we are working on):

<xml-config name="QI" logger="Q2">
  <title>jPOS QI</title>
  <theme>jpos</theme>
  <locale>en-US</locale>
  <menubar>
    <menu name="System" icon="COG" style="icon-cog">
      <menu name="About"  action="about" />
      <menu name="Memory 1">
        <menu name="Sub Memory 1"  action="memory" />
        <menu name="Sub Memory 2" perm="system">
          <menu name="Sub Sub Item"  action="memory" icon="COG" perm="sysconfig.read" />
        </menu>
      </menu>
      <separator />
      <menu name="Memory 2"  action="memory" />
      <menu name="Memory 3"  action="memory" />
      <menu name="Memory 4"  action="memory" />
    </menu>
    <menu name="Options">
      <menuitem name="Quit"   action="exit" />
    </menu>
  </menubar>

  <sidebar>
    <section name="System" />
    <option name="About" action="about" />
    <option name="Memory" action="memory" />
    <option name="SysConfig" action="sysconfig" />
    <option name="Users" action="users" />
  </sidebar>

  <view route="/home" class="org.jpos.qi.DefaultView" perm="*" />
  <view route="/about"  class="org.jpos.qi.system.AboutView" perm="system" />
  <view route="/memory" class="org.jpos.qi.system.MemoryUsageView" perm="system" />
  <view route="/sysconfig" class="org.jpos.qi.sysconfig.SysConfigView" perm="system" />
  <view route="/users" class="org.jpos.qi.eeuser.UsersView" perm="system" />
</xml-config>

​Hope this helps.

​Our web application access a 00_qi.xml deploy element and then goes over the XML config.

H​



--
--
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
 
Join us in IRC at http://webchat.freenode.net/?channels=jpos
 
You received this message because you are subscribed to the "jPOS Users" group.
Please see http://jpos.org/wiki/JPOS_Mailing_List_Readme_first
To post to this group, send email to jpos-...@googlegroups.com
To unsubscribe, send email to jpos-users+...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/jpos-users
---
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+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jpos-users/d9eb8733-0bed-4afc-87bc-6e63fec212a2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

dannygaviria

unread,
Mar 3, 2016, 8:50:29 AM3/3/16
to jPOS Users
Thanks mr Aalejandro.

I created a singleton class to load data. But i want to load in the Q2 initialization, please yo can send me a sample code of Q2 for exennds.


Sample:

class MyQ2 extends Q2{
public MyQ2(){
loadDData();
}
}


Thanks.

dannygaviria

unread,
Mar 3, 2016, 10:04:53 AM3/3/16
to jPOS Users
It's ready thanks. Solution:


public class MyQ2 extends org.jpos.q2.iso.QServer {
Loader loader;
public MyQ2(){
loader = Loader.getInstance();
Reply all
Reply to author
Forward
0 new messages