Hi,

To my understanding, if a component is marked as transient, it is
removed from memory and destroyed as soon as release() is called... is
this correct? (Or are instances pooled? If so, how do I control the
pool behaviour, size, etc?)

The reason I'm asking this is as follows: I have a Swing client - the
main window is the component deployed by merlin at startup. It has two
menu items: Open and Close (Open displays an instance of JPanel, Close
gets rid of the displayed JPanel instance). The Panel is supplied by a
component deployed at runtime. The following code displays the Panel:

      long nStart = System.currentTimeMillis();
      
      if(m_hULDBuildup == null)
      {
        m_hLogger.info("Loading module...");
        
        // Menu to Module name map should be loaded from somewhere...
        m_hULDBuildup = m_hModel.addContainmentModel(new URL(null,
"artifact:ngcs/NC.GroundHandling#1.0-rc1", new ArtifactHandler()));
        m_hULDBuildup.commission();
      }
      
      // Initialize...
      m_hLogger.info("Initializing module...");
      DeploymentModel hModel =
m_hModel.getModel("/NGCS/GroundHandling/ULDBuildup");
      
      ReferenceDescriptor hDescriptor = new
ReferenceDescriptor(Module.class.getName(),
           new Version(1,0,0));
      if(!hModel.isaCandidate(hDescriptor))
      {
        m_hLogger.error("Unable to resolve module, cannot continue!");
        return;
      }
      
      // Resolve...
      m_scrCurrent = (Module)hModel.resolve(true);
      m_scrCurrent.initialize(); // My method - declared in the Module
class, implemented by the component
      
      long nFinish = System.currentTimeMillis();
      m_hLogger.info("Done, module initialized, time taken = " +
(nFinish - nStart) + " ms.");

      m_pMainWnd.getContentPane().add(m_scrCurrent.getModuleView(),
BorderLayout.CENTER);
      m_scrCurrent.activate();  // My method - declared in the Module
class, implemented by the component


The following code gets rid of the Panel:

    m_hLogger.info("Deactivating screen...");
    m_scrCurrent.deactivate();  // My method - declared in the Module
class, implemented by the component

    m_pMainWnd.getContentPane().remove(m_scrCurrent.getModuleView());
    
    m_mnuOpen.setEnabled(true);
    m_mnuClose.setEnabled(false);
    
    m_pMainWnd.getContentPane().invalidate();
    m_pMainWnd.getContentPane().validate();
    
    m_pMainWnd.invalidate();
    m_pMainWnd.validate();
    
    m_pMainWnd.repaint();
    
    try
    {
      m_hLogger.info("Unloading module...");
      m_hServiceManager.release(m_scrCurrent);
      
      m_scrCurrent = null;
      System.gc();
      
    } catch (Exception e)
    {
      m_hLogger.error("Error unloading module : " + e.getMessage());
      e.printStackTrace();
    }

At any time only one Panel can be shown, so the menus get
enabled/disabled as appropriate - Open cannot be called when the Panel
is already shown. The first time the menu is clicked, the block is
deployed, after this, the block stays deployed, I just need to get a
new component instance - this instance will be released by me when the
user selects Close.

When I click close, I get this log in the console window:
[INFO   ] (NGCS.Application): Deactivating screen...
[INFO   ] (NGCS.Application): Unloading module...
[INFO   ] (NGCS.GroundHandling.ULDBuildup): stop() called...

I repeat this 4-5 times, then I call Quit to end the application. When
I quit, I get this logged to the console:
[INFO   ] (NGCS.GroundHandling.ULDBuildup): stop() called...
[INFO   ] (NGCS.GroundHandling.ULDBuildup): stop() called...
[INFO   ] (NGCS.GroundHandling.ULDBuildup): stop() called...
[INFO   ] (NGCS.GroundHandling.ULDBuildup): stop() called...
[INFO   ] (NGCS.GroundHandling.ULDBuildup): stop() called...
[INFO   ] (NGCS.Application): stop() called...

I assume stop() is called on the instances because they are still in
memory? If so, have I missed out something?

Any suggestions will be helpful...

Thanks, and Brgds,

R. Saravanan

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to