Sunteți pe pagina 1din 3

AKAMAI IMPLEMENTATION USING WEBSPHERE COMMERCE

Using Akamai to enable content availability and increase performance.

Goal:
Replace all relative paths to absolute from static contents. The statics contents include: JavaScript, Style Sheet
and images.
It is interesting to use the sharding technique to provide a simultaneous download and enabling page load
efficiency for a better user experience.
To apply this technique:
Create a sub domain for Style Sheet
Create a sub domain for JavaScript
Create one or more sub domains for images which can be downloaded simultaneous, It is interesting have
more than a sub domain, the site will be able to handle more than a image request.

The general steps for implementing domain sharding on a site would be:
1. Create the sub domains to be used for sharding.
2. Configure the web server to use these domains and to serve the static content.
3. Update the pages to point the resource URLs to the shards.

Technical Solution for WebSphere Commerce

1.) Create an extendable table to keep the resource and the domain/sub domain.

2.) Create a class which implements a Registry. This class will read the table and keep the all the data in the
cache when the server start or when you update the content in Registry Manager in Admin Console. This is
important since all the JSP will use the data to create the absolute URL.

To update follow: Admin Console > Registry Akamai > Update

3.) Include a new registry in wc-server.xml. This registry should point to the class created in step 3.

<registry name="AkamaiRegistry"
regClassName="br.com.aurora.commerce.util.config.AkamaiRegistry" initialCapacity="50"/
4.) Create a class extending TagSupport to handle the paths in the JSP. This class must work with parameters
Tag Lib from the JSP to create an absolute URL.

Follow the class example:


import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;

/**
* Class that implements taglib for Akamai sub-domain retrieval
*/
public class AkamaiTagHandler extends TagSupport {

/**
* Constructor method for Akamai sub-domain
*/
public ConfigTagHandler() {
super();
}

private String type = null;


private String resource = null;
private String RegistryKey = null;
private String var = null;
private boolean storePreview = false;

public void setType(String type) {


this.type = type;
}

public void setResource(String resource) {


this.resource = resource;
}

public void setVar(String var) {


this.var = var;
}

public void setStorePreview(boolean storePreview) {


this.storePreview = storePreview;
}

/*
* doStartTag
*/
public int doStartTag() throws JspException {
// add your logic here
return SKIP_BODY;
}

/**
* Get the resource file type
*/
private void retrieveAkamaiResource() {
// Create the logic to create the absolute URL
// Remember to respect the resource, protocol and domain
}
}
Follow the tag lib example:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE taglib
PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
"http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">
<taglib>

<tlib-version>1.0</tlib-version>
<jsp-version>1.2</jsp-version>
<shortname>AkamaiTagHandler</shortname>
<info>Tags to retrieve Akamai configuration parameters</info>
<tag>
<name>AkamaiConfig</name>
<tagclass>br.com.aurora.commerce.util.tags.AkamaiTagHandler</tagclass>
<bodycontent>JSP</bodycontent>
<attribute>
<name>type</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>resource</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>var</name>
<required>false</required>
<rtexprvalue>false</rtexprvalue>
</attribute>
<attribute>
<name>storePreview</name>
<type>java.lang.Boolean</type>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<info>Return a configuration value associated with the Akamai resource
attribute</info>
</tag>

</taglib>

5.) Declare Tag Lib in the JSP. For Style Sheets and JavaScript you can include only in the
EnvironmentSetup.jspf, since all JSP include this fragment.
<%@ taglib uri="akamai_tags.tld" prefix ="ak" %>

<c:choose>
<c:when test="${env_inPreview == true}">
<c:set var="akamaiStaticJs" value="${jsAssetsDir}javascript"/>
<c:set var="akamaiStaticCss" value="${jspStoreImgDir}css"/>
</c:when>
<c:otherwise>
<ak:AkamaiTagHandler type="AKAMAI" resource="javascript" var="akamaiStaticJs"/>
<ak:AkamaiTagHandler type="AKAMAI" resource="css" var="akamaiStaticCss"/>
</c:otherwise>
</c:choose>

Attentions points:

- Remember to handle Store Preview as well to avoid break Management Center links and images.

S-ar putea să vă placă și