In this section, you define a class that is used as a Nucleus component, then configure the component.

Define the Class

Define a simple Person class that has two properties: name (a String) and age (an integer):

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 in your classes directory with the name Person.java. The Oracle ATG Web Commerce platform includes an <ATG10dir>/home/locallib directory that you can use for any Java class files you create. This directory is included in the Oracle ATG Web Commerce CLASSPATH by default, so any classes stored there are picked up automatically.

Note: The locallib directory is intended for evaluation and development purposes only. For full deployment, you should 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 <ATG10dir>/home/locallib Person.java

Configure a Component

Now create an instance (or component) of a Person class,/test/services/Person:

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


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