• Share
  • ?
  • Profiles ▼
  • Communities ▼
  • Apps ▼

Blogs

  • My Blogs
  • Public Blogs
  • My Updates

This community can have members from outside your organization. Portal administration and performance

  • Log in to participate

▼ Tags

▼ Archive

  • March 2018
  • December 2017
  • October 2017
  • September 2017
  • February 2017
  • January 2017
  • October 2016
  • September 2016
  • July 2016
  • May 2016
  • March 2016
  • February 2016
  • November 2015
  • October 2015
  • September 2015
  • June 2015
  • April 2015
  • March 2015
  • February 2015
  • January 2015
  • November 2014
  • September 2014
  • July 2014
  • June 2014
  • April 2014
  • March 2014
  • October 2013
  • August 2013
  • June 2013
  • May 2013
  • March 2013
  • February 2013
  • November 2012
  • October 2012
  • September 2012
  • August 2012
  • July 2012
  • June 2012
  • March 2012
  • November 2011
  • September 2011
  • August 2011
  • June 2011
  • May 2011
  • February 2011
  • October 2010
  • September 2010
  • August 2010
  • July 2009
  • June 2009
  • March 2009
  • February 2009
  • August 2008
  • May 2008
  • April 2008
  • March 2008
  • February 2008
  • January 2008

▼ Links

  • Portal L2 Blog
  • Thoughts on Web Content Manage...
  • Web Content Manager Forum
  • WebSphere Portal Forum
  • WebSphere Portal Security, Por...
  • WebSphere Portal zone

▼ Blog Authors

Portal administration and performance

View All Entries
Clicking the button causes a full page refresh. The user could go to the "Entry list" region to view the new content.) Entry list

Improving Performance by caching JNDI lookups

Thomas_Hurek 110000ADUU | ‎ | 2 Comments ‎ | 13,421 Views
In WebSphere Portal, Web Content Manager and WebSphere Application Server Java Naming and Directory Interface (JNDI) lookups are performed very frequently to lookup references to Distributed Cache (Dynacache), Portal Services like PUMA or NavigationService, Portlet Services, datasources, mail services, and many more. Little known is the fact that these lookups are very expensive in terms of performance. Especially in areas that are executed frequently like the theme, common portlets, SessionValidatorFilter code, or frequent database calls, the overall performance can be impacted.
 
To solve this issue cache the reference you have looked up and reuse it (in case it is thread-safe what most references are). For java classes a static initializer block or init method can be a good place, for Java Server Pages (jsp's) the jspInit() method is a good place.
 
The sample below shows an unoptimized and optimized implementation of a JNDI lookup from a jsp:

Unoptimized:
 <%
javax.naming.InitialContext context = null;
try {
context = new javax.naming.InitialContext();
PortalLocalizedContextHome locCtxhome = (PortalLocalizedContextHome) context.lookup(PortalLocalizedContextHome.JNDI_NAME);
LocalizedContext localeContext = locCtxhome.getLocalizedContext(request);

// use localeContext ...

} catch (NamingException e)
{
    //Exception handling
}

%>
 
Optimized:
<%!

static PortalLocalizedContextHome locCtxhome = null;

public void jspInit()
{
   
    try {
    javax.naming.InitialContext context = null;
    context = new javax.naming.InitialContext();
    locCtxhome = (PortalLocalizedContextHome) context.lookup(PortalLocalizedContextHome.JNDI_NAME);

    } catch (NamingException e)
    {
        //Exception handling
    }
}

%>

<%
if(locCtxhome!=null)
{
    LocalizedContext localeContext = locCtxhome.getLocalizedContext(request);   
    //use localeContext ...
}

%>
  • Add a Comment Add a Comment
  • Edit
  • More Actions v
  • Quarantine this Entry
Notify Other People
notification

Send Email Notification

+

Quarantine this entry

deleteEntry
duplicateEntry

Mark as Duplicate

  • Previous Entry
  • Main
  • Next Entry
Feed for Blog Entries | Feed for Blog Comments | Feed for Comments for this Entry