To be interpreted by Nucleus, a Bean’s initialization parameters must be exposed as properties. For example, a server component may wish to expose its TCP port as a configurable parameter. To do so, it would implement the following methods:

public int getPort();
public void setPort(int port);

Defining these two methods allows Nucleus to treat port as a property that can be initialized by a configuration file. The implementation of these methods does not matter — most implementations will use a member variable to store the value of port, but this is not required by the JavaBeans specification.

Nucleus can also display the values of properties to an administrator at runtime, so it is often a good idea to expose instrumented values as read-only properties (properties that do not have a write method):

public int getHandledRequestCount();

As mentioned previously, properties are also used to satisfy interdependencies among components. For example, if a component needs a pointer to a Scheduler component to operate, it only has to expose that dependency as a property:

public Scheduler getScheduler();
public void setScheduler (Scheduler scheduler);

The configuration file can specify which Scheduler should be used by the component, and Nucleus will automatically set the scheduler property to the Scheduler specified in the configuration file. In this way, properties can express the “strong” dependencies between components, that is, dependencies where one component must have a pointer to another kind of component in order to operate at all.

 
loading table of contents...