One of the best things about developing using ATG is its component model. The component model used by ATG is called nucleus. Nucleus forms the foundation of the ATG platform and every application you build with it. By assembling nucleus components in various ways one can develop very sophisticated web applications as proven by some of ATGs flagship products such as ATG Commerce.
Its important to get a good understanding of nucleus before tackling a new project. So in this article we’ll go over the basics and we’ll follow up with more advanced techniques in future posts. We’ll start off with your typical hello world application. Source code for this example can be referenced below.
The first thing you need to know about nucleus is that it’s grounded in javabeans. So if you can write a javabean you can write a nucleus component. Let’s first take a look at the class for our javabean called HelloWorld.java. Like every javabean it has an empty constructor. Our HelloWorld javabean also has a single String property called message. Access to the value of the message property is obtained through the beans getter and setter methods. Compile this class and place the HelloWorld.class file in the <DYNAMO_ROOT>/home/locallib directory for now. This allow nucleus to access this class through its classpath.
To deploy an instance of this bean to nucleus all we need to to is create a property file to represent the component. The name of the property file become the name of our component. For this example simply create a property file called HelloWorld.properties and place it it the <DYNAMO_ROOT>/home/localconfig directory. The contents of this file is shown below and describe in more detail below.
The first thing you’ll notice is a reference to a special property prefixed with a dollar($) sign. These are referred to as metadata properties are there are only a few interesting ones that you should know about. The first metadata property is $class. This property represents the java class used to instantiate this component. All nucleus components are required to specify this metadata property. Other optional metadata properties include $description and $scope. The $description property is use to give the component a brief description. We’ll discuss the use of the $scope property in a future article.
Following the metadata properties is a list of name/value pairs. These name/value pairs are used during the components initialization phase. Our javabean has only a single property called message so we set its value to the string “Hello World!”.
What happens now when this component is referenced from within nucleus? Well the first thing nucleus does is create a new instance of the class defined by the $class property. After the component is successfully instantiated nucleus sets all the bean properties defined in the properties file. After our HelloWorld component is instantiate its message property is automatically set to the string “Hello World!”.
So that’s basically how simple developing in ATG can be. I hope you found this information useful. In our next article we’ll take a look at some more advanced techniques.
1 //------------------------------------- 2 // HelloWorld.properties 3 // 4 $class=HelloWorld 5 message=Hello World!
1 //------------------------------------- 2 // HelloWorld.java 3 // 4 /** 5 * HelloWorld 6 */ 7 public class HelloWorld { 8 //------------------------------------- 9 // Properties 10 //------------------------------------- 11 12 //------------------------------------- 13 // property: Message 14 String mMessage; 15 16 /** 17 * Sets property Message 18 **/ 19 public void setMessage(String pMessage) { 20 mMessage = pMessage; 21 } 22 23 /** 24 * Returns property Message 25 **/ 26 public String getMessage() { 27 return mMessage; 28 } 29 30 //------------------------------------- 31 // Constructors 32 //------------------------------------- 33 34 /** 35 * Constructs an instanceof HelloWorld 36 */ 37 public HelloWorld() { 38 } 39 } // end of class


