Results 1 to 4 of 4

Thread: Creating a Custom instance template question

  1. #1
    Join Date
    Dec 2005
    Posts
    5

    Question Creating a Custom instance template question

    I am trying to create a custom template for use the the tcruntime-instance.bat process and I need to create a conf/web-fragment.xml file to add an init param to the generated default web.xml file.

    Basically I need to:
    1) In the servlet definition for the jsp page compiler servlet, I need add an <init-param> entry to disable tag handler pooling.
    2) I want to configure the session timeout to be 15 minutes instead of 30 minutes.

    Is there somewhere the documentation on the syntax of coding the fragments so I can accomplish this?

  2. #2

    Default Creating a Custom instance template question

    Creating an instance using template, generally includes fragments from 'base' then specified template and from 'bio' template.

    base -> given template -> bio.

    If you want to create your custom template i.e. my-web with the settings you mentioned above.

    1. Create a folder my-web/conf folder under templates folder of tcServer distribution.
    2. Add the web-fragment.xml with your setting in appropriate syntax.
    3. Create the instance by passing 'my-web' as a template param ( -t my-web).


    It should give you the instance you want..

    Note: This is based on my experience with tcServer-spring edition 2.1.2. Your result may vary....

    Thanks,
    YA

  3. #3
    Join Date
    Oct 2008
    Posts
    493

    Default

    Quote Originally Posted by bosakm View Post
    1) In the servlet definition for the jsp page compiler servlet, I need add an <init-param> entry to disable tag handler pooling.
    Unfortunately, this isn't possible with the current templating implementation. The implementation relies up being able to uniquely identify an element in the xml file to add to or remove. As there are many <servlet> entries with no attributes to differentiate them this isn't currently possible. If there is sufficient demand for this capability we could look at improving this by using the elements within a element to help to uniquely identify it.

    2) I want to configure the session timeout to be 15 minutes instead of 30 minutes.
    This is possible. A web-fragment.xml in a template with the following contents will change the default session timeout to 15 minutes:

    Code:
    <web-app> 
    	<session-config>
    		<remove:session-timeout/>
    		<add:session-timeout>15</add:session-timeout> 
    	</session-config>
    </web-app>
    Is there somewhere the documentation on the syntax of coding the fragments so I can accomplish this?
    We haven't formally documented the syntax yet. We wanted to give it time to bed down and get a feel for what users wanted to do with it before we were limited in the refinements we could make.

    The syntax is pretty straightforward. You can prefix an element with add: to add it to the file, and you can prefix an element with remove: to remove it from the file.

    When you're using add, the ancestors of the element that you're adding are used to uniquely identify its location in the document. So in the session timeout case above we're looking to add a <session-timeout> element to a <session-config> element that's within a <web-app> element. You're essentially using the snippet of XML to define a path from the root of the document to the location at which you want to add a new element. In fact, the implementation turns the fragment into an XPath to identify the location.

    When you're using remove, the ancestors of the element, and the element itself are used to uniquely identify its location in the document. The fact that the element itself is also used means that you can use attributes of the element to uniquely identify it.

    Hope this helps.
    Andy Wilkinson
    SpringSource

  4. #4
    Join Date
    Dec 2005
    Posts
    5

    Default

    Thank you Andy, that looks like what I was looking for.

    As to the additional init0parameter for the JSP compiler, we'll change the offending tag handlers so that they correctly implement the spec so that they can be pooled. (that was why I was looking to disable tag handler pooling. As a quick workaround for some bad code).

    YA: Thanks for the replay. I already figured that out for some other things I wanted the custom template to do. I just couldn't figure out how to specify adding an init-param to a specific servlet definition.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •