The atg.nucleus.naming package includes two classes that enable you to preparse frequently-used component names and parameter names. You can assign a name to a component or parameter, storing the name and its corresponding component or parameter in a hashtable. This typically results in faster name resolution for components and parameters. These two classes are described in the ComponentName and ParameterName topics.

ComponentName

You can use a ComponentName object to represent any Nucleus component. Use this class (atg.nucleus.naming.ComponentName) to create unique component names that you can refer to elsewhere. The component names are stored in a global hashtable, 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 getComponentName() method. This method looks the given string up in the hashtable of component names and either returns the value or creates a new one with the string that was passed in. For example, you can set a ComponentName value like this:

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 be useful in limiting the amount of parsing which is done when resolving the same component name over and over again. Note that the ATG page compiler uses ComponentNames wherever possible to reduce the memory cost and parsing time of resolving 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 to represent any request parameter name used in the ATG platform. ParameterNames are used when you want to look up a request parameter quickly. Use this class (atg.nucleus.naming.ParameterName) 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 allows the parameters of a servlet bean to be publicly available (for example, in the Components window of the ACC). In addition to providing better performance by pre-parsing the parameter name, using this class also enforces good coding standards whereby the parameter name string only appears once in the Java code.

To get the unique ParameterName for a given String, call the static getParameterName() method. This method looks the given string up in the hashtable of parameter names and either returns the value or creates a new one with the string that was passed in. For example, you can set a ParameterName value like this:

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

Then, each time you want to reference that parameter name, you can reference the string EMPTY like this:

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 over and over again. Note that the ATG page compiler uses ParameterNames wherever possible to reduce the memory cost and parsing time of accessing request parameters. You don’t 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 will get better performance if you use ParameterName for its parameters.

 
loading table of contents...