When you start up an application, Nucleus reads the configuration path, which is a list of directories to use to find configuration files. Within one of those directories is a file called Nucleus.properties that contains the name of the first component to create. In the standard Oracle Commerce Platform configuration, the start of the Nucleus.properties file looks like this:

$class=atg.nucleus.Nucleus
initialServiceName=/Initial

The initialServiceName property instructs Nucleus to configure and start up its initial service using Initial.properties, which in the standard configuration looks like this:

$class=atg.nucleus.InitialService
initialServices=\
     /atg/Initial,\
     VMSystem,\
     /atg/dynamo/StartServers

If you want to add another service to the list of initial services, you can edit the /Initial component in the Components window:

The next time you start your application, the test/services/Person component is run as an initial service.

Most components do not need to be started from the Initial service when an application starts up; they can be instantiated by Nucleus when they are needed, typically in response to a page request from a user. A component started through the initialServices property must be globally scoped.

To show that Nucleus really is doing something, change the Person class to print some output:

public class Person {
  String name;
  int age;

  public Person () {
    System.out.println ("constructing Person");
  }
  public String getName () { return name; }
  public void setName (String name) {
    System.out.println ("setting name to " + name);
    this.name = name;
  }
  public int getAge () { return age; }
  public void setAge (int age) {
    System.out.println ("setting age to " + age);
    this.age = age;
  }
}

Compile this class, reassemble your application, and restart it. On the console you should be able to watch the class get constructed and initialized.

Note: The forward slash / in /test/services/Person is always used when naming Nucleus components. It is independent of the file separator character that varies among operating systems.


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