Concurrent Model Initializer Builder

 

 

In this topic ...

Quick Tips

Specifying Inputs

Specifying an XML Structure for Initialization

Use the Concurrent Model Initializer builder when you want to decrease the load time of a page containing several models that have initialization methods. To see this benefit, each initialization method should access resources on separate servers. The Concurrent Model Initializer builder allows you to specify which models to initialize simultaneously, thus decreasing the page loading time.

By default, the Factory servlet loads one model at a time, and it displays the page only when it has loaded and initialized all of the models on that page. If you have many models that need to initialize, this configuration could increase the load time. If the content of these models are on different servers, the Concurrent Model Initializer builder could make the initial load time faster. Instead of the load time being the total for all models to initialize, the entire page can load as fast as the slowest model.

For example, assume you created a page containing four models each requiring 5 seconds to load. It will take the Factory servlet 20 seconds to load the page. If you were to use the Concurrent Model Initializer builder and the content of the models were on different servers, the load time could be lessened to 5 seconds. The Concurrent Model Initializer builder loads the models as fast as the slowest loading model.

 

Quick Tips

  • Using models within containers - For an overview of how to use models within containers, click here.

  • When to use the Concurrent Model Initializer builder - Use the Concurrent Model Initializer builder when the model initialization routines make external calls to separate servers. The loading can be distributed if the content of the models are on different servers, for example, the model contains a WSDL service call to another server or a link to an external database. If the resources accessed by the models are on the same sever, no benefit will be gained because the server can only respond to one job at a time.

  • Use the Model Container builder or Portlet Container builder to display the models on the page - These builders reserve a spot on the page for the model. For more information, refer to their online help:

  • Model Container

  • Portlet Container

  • Builder has no time-out feature - Keep in mind that the Concurrent Model Initializer builder does not have a time-out feature. If your model contains a URL and the server corresponding to the URL goes down, the model will hang.

  • Build error handlers into your models - For example, "The server is down. Try again later." If the model initialization routine throws an exception that is not handled, all initialize methods will be stopped. This situation occurs in the concurrent case as well as with the normal serial one.

  • Beware of models containing an initialization method that calls the parent container - Do not use the Concurrent Model Initializer builder to process a model that has an initialization method to call back to the parent container. The concurrent initialization mechanism uses Java code that turns off thread safety, and simultaneous access to the Factory code controlling a particular container model instance can cause unexpected behavior, including a server crash.

  • The Concurrent Model Initializer builder can be used to initialize models that are not loaded immediately - This builder initializes models even if they are not assigned to a container; however, models not assigned to a container are not displayed on the page.

  • The XML structure for initialization overwrites the values for the Model Container builder and the Portlet Container builder - Important: You might want to verify that the values listed in the XML structure match the values entered in the Model Container builder or in the Portlet Container builder. The values in the XML structure for the Concurrent Model Initializer builder overwrites the values entered in the Model Container and in the Portlet Container builders.

For example, assume you specified that the initialization data for a model is "true" in the Model Container builder or in the Portlet Container builder. Then, in the XML structure for the Concurrent Model Initializer builder you specify that the initialization data for the model is "false." When the model is loaded the initialization data in the XML structure for the Concurrent Model Initializer builder takes precedence, and the value "false" is used.

The values that can be overridden include...

  • The model name

  • Path to the model data

  • Initialization data

  • Path to the error model

 

Specifying Inputs

The Concurrent Model Initializer builder takes the following inputs:

Input Name Description
Name Enter a name for this builder call. The Designer displays this name in the Builder Call List.
Model Data Specify an XML structure (for example, from a variable) containing the names and other information about the dynamic models to load. By entering this information into a variable, we can change the models to be loaded at run time.

For more information on how to specify an XML structure, see "How to Specify an XML Structure for Initialization."

 

Specifying an XML Structure for Initialization

Assume you are developing a news Web site and several models need to be loaded. You would need to specify in an XML structure that determines the models to be loaded concurrently. This XML structure would be stored in a variable (for example, ModelData) that is called out (${Variables/ModelData}) in the Model Data field. The variable, ModelData, of type XMLData would contain a structure similar to the following:

<ModelData>

 <Module>

  <Name>schoolnewscontainer</Name>

  <Model>news/newyork/schoolnews</Model>

  <Profile>ProfileSetA!East$ProfileSetB!Bronze</Profile>

  <InitData>Example init data here<SubNode>OK?</SubNode></InitData>

  <ErrorModel>factory/schoolnews/errormodel</ErrorModel>

 </Module>

 <Module>

  <Name>politicalnewscontainer</Name>

  <Model>news/newyork/politicalnews</Model>

  <Profile>ProfileSetA!South$ProfileSetB!Silver</Profile>

  <InitData>Data 2</InitData>

  <ErrorModel>factory/politicalnews/errormodel</ErrorModel>

 </Module>

 <Module>

  <Name>environmentalnewscontainer</Name>

  <Model>news/newyork/environmentalnews</Model>

  <Profile>ProfileSetA!West$ProfileSetB!Gold</Profile>

  <InitData></InitData>

    <ErrorModel>factory/environmentalnews/errormodel</ErrorModel>

 </Module>

 <Module>

  <Name>businessnewscontainer</Name>

  <Model>news/newyork/businessnews</Model>

  <Profile>ProfileSetA!North$ProfileSetB!Bronze</Profile>

  <InitData><b>Fourth Data</b></InitData>

  <ErrorModel>factory/businessnews/errormodel</ErrorModel>

 </Module>

</ModelData>

where:

  • The Name element specifies the name of the container into which the model will be loaded

  • The Model element is the path to the model. The specified path is relative to the WEB-INF/models directory

  • The Profile element specifies the profiles to explicitly apply to the model. Specify the profile set and profile names using the following syntax:

ProfileSetName!profileName

or use the following syntax to specify multiple profiles: ProfileSetA!profile1$ProfileSetB!profile2, using a '$' to separate profile set/profile combinations.

  • The InitData element contains the data you want to initialize. It can contain a String or XML data. We can also specify an indirect reference that resolves to a String or IXml object:

  • Indirect Reference - for example, ${Variables/CustomerName} or ${Variables/CustomerServiceCall_reply}.

  • String - for example, <InitData>Data 2</InitData> We can use HTML to format this String: <InitData><b>Fourth Data</b></InitData>

  • XML data - for example, <InitData><RootNode>Example init data here<SubNode>OK?</SubNode></RootNode></InitData>

  • The ErrorModel element contains the path to the model you want displayed when an error occurs in loading the page.