Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    #16
    Anytime after the Init Servlet has run. For example, a Servlet set to load-on-startup, but which runs after the Init Servlet.

    Comment


      #17
      Ok, I think the settings are now correct, but now I have the next problem.

      If I understood you correctly, these are the steps to be done:

      Code:
      /sc/DataSourceLoader?dataSource=DYNAMIC_DS
      So the framework will try to load the DYNAMIC_DS, which does *not* exist as a .ds.xml file.

      Since I register the generator, it will first try to get the datasource from the generator:

      Code:
      public DataSource getDataSource(String id, DSRequest dsRequest) {				.getSession().getAttribute("mandantId"));
      		LOG.info("Trying to load datasource: " + id );
             if (id.equals("DYNAMIC_DS")) {
                //load the clientId from the session
                //then load the correct XML from the disk, 
                //depending on the clientId, using the clientId as a path
             }
      		return null;
      	}
      Here I have two problems:
      1) I cannot get the session, since the dsRequest is null. How can I then get the clientId?
      2) The original, requested DS ID is: DYNAMIC_DS. After loading the XML from the disk in the getDataSourceMethod, the ID will be: 1_DYNAMIC_DS, or 2_DYNAMIC_DS, as you suggested. So I think this will also not work, since the original id is different than the id returned. How to solve this?

      Comment


        #18
        Ok, reading http://forums.smartclient.com/showthread.php?t=15937&highlight=DataSource.addDynamicDSGenerator I think I got it.

        So the calling part (server or client) is in charge of creating the compound-name, e.g. DYNAMIC_1_MyDs. It calls DataSource.get("DYNAMIC_1_MyDS"), and the getDataSource() parses this ID, gets the clientId, and reads the correct definition from disk. It returns the DataSource read.
        I think this would work.

        BUT: What is the advantage of doing this, and not just creating .ds.xmls called: 1_myDS.ds.xml, 2_myDS.xml, 3_myDS.xml, loading them ALL in the main .jsp page, and then calling the correct one?
        Wouldn't this be exactly the same?
        If I understand this correctly, in both cases all datasources will be loaded, that's why we need different IDs, so why to use one method instead of the other one ?

        Comment


          #19
          If you want to maintain separate sets of .ds.xml files for each client, with distinct IDs per client, you can do this without using a DynamicDSGenerator.

          This of course means you need to add new files to the deployment for each new client, which we assumed you wouldn't want to do.

          Comment


            #20
            You are right, after some time I am taking this approach again.

            It works, but I have a question regarding how to load the datasource on the server-side.
            On the client-side, I can call DataSource.get("id"), but on the server side?
            It seems to work calling:
            DataSource ds = new DSRequest(id, DataSource.OP_FETCH, rpcManager).getDataSource();

            But since I am not going to use this request I was wondering if this is the correct way to get the DataSource on the server-side?

            Comment


              #21
              It depends what you want the DataSource for and whether you are in the context of an HTTP request. Take a look at the docs for the server-side RPCManager.getDataSource() method, the server-side DataSourceManager class, and the Standalone DataSource Usage overview (if that's your situation).

              Comment

              Working...
              X