In this section, you will define a class that will be used as a Nucleus component, write a configuration file for that component, then start Nucleus to run that component.

The class you will define is a simple class called Person that has two properties: name (a String) and age (an integer). The class definition looks like this:

public class Person {
  String name;
  int age;

  public Person () {}
  public String getName () { return name; }
  public void setName (String name) { this.name = name; }
  public int getAge () { return age; }
  public void setAge (int age) { this.age = age; }
}

Put this class definition into your classes directory with the name Person.java. The ATG platform includes an <ATG2007.3dir>/home/locallib directory that you can use for any Java class files you create. This directory is included in the ATG CLASSPATH by default, so any classes stored there will be picked up automatically. (Note: The locallib directory is intended for evaluation and development purposes only. For full deployment, we recommend that you package your classes in an application module, as described in Working with Application Modules.)

Use the javac –d command to compile your Person.java source file and add the resulting .class files to the locallib directory:

javac -d <ATG2007.3dir>/home/locallib Person.java

Now create an instance of a Person class component, which will be called /test/services/Person. There are two ways you can create a component of the Person class. You can use the ACC Components window, or you can create a configuration file with a .properties extension.

To create a component with the Components window:

To create a component with a configuration file:

You can now view the Person component in the Components window. Select test/services/Person and click the Open Component button. The Component Editor should display Person and its two properties.

 
loading table of contents...