The atg.nucleus.naming package includes two classes that can pre-parse often used component names and parameter names:

You can use these classes to assign a name to a component or parameter and store the name and its corresponding component or parameter in a hashtable. This typically speeds up name resolution for components and parameters.

ComponentName

A ComponentName object of class atg.nucleus.naming.ComponentName can represent any Nucleus component. Use this class to create unique component names that you can reference elsewhere. The component names are stored in a global hashtable that is keyed by strings. Using this class provides better performance by pre-parsing the component name.

To get the unique ComponentName for a given String, call the static method getComponentName(). This method looks up the given string in a hashtable of component names and returns the value or creates one with the supplied string. For example, you might set a ComponentName value as follows:

public final static ComponentName PEACH =
  ComponentName.getComponentName("/atg/fruits/Peach");

You can pass a component name to the resolveName() method of atg.servlet.DynamoHttpServletRequest:

public Object resolveName(ComponentName pName);

This technique can help limit the amount of parsing required to resolve the same component name repeatedly. The Oracle Commerce Platform page compiler uses ComponentNames wherever possible to reduce the memory cost and parsing time to resolve components. GenericService implements the atg.nucleus.naming.ComponentNameResolver interface, which makes available a resolveName() method that takes a ComponentName:

public Object resolveName(ComponentName pName);
ParameterName

You can use a ParameterName object of class atg.nucleus.naming.ParameterName to represent any request parameter name used in the Oracle Commerce Platform. ParameterNames are used when you want to look up a request parameter quickly. Use this class to create unique parameter names when building your own servlet beans. The parameter names are stored in a global hashtable, keyed by strings. Using this class makes the parameters of a servlet bean publicly available. You can use this class not only to enhance performance by pre-parsing the parameter name, but also to enforce good coding standards, by ensuring that the parameter name string appears once only in your Java code.

To get the unique ParameterName for a given String, call the static method getParameterName(). This method looks up the given string in the hashtable of parameter names and returns the value or creates one with the supplied string. For example, you can set a ParameterName value as follows:

public final static ParameterName EMPTY = ParameterName.getParameterName
  ("empty");

Later, you can reference that parameter name through the string EMPTY as follows:

request.serviceLocalParameter(EMPTY, request, response);

You can pass a ParameterName to the following methods of atg.servlet.DynamoHttpServletRequest:

public Object getParameter (ParameterName pName);
public Object getLocalParameter (ParameterName pName);
public Object getObjectParameter (ParameterName pName);

This technique is useful when you want to resolve the same parameter repeatedly. The Oracle Commerce Platform page compiler uses ParameterNames wherever possible to reduce the memory cost and parsing time of accessing request parameters. You do not need to use a ParameterName for parameters that are found in standard ATG servlet beans or in <valueof> or <setvalue> tags; the page compiler takes care of that for you. If you create your own servlet bean, however, you can obtain better performance if you use ParameterName for its parameters.


Copyright © 1997, 2016 Oracle and/or its affiliates. All rights reserved. Legal Notices