To be interpreted by Nucleus, a bean’s initialization parameters must be exposed as properties. For example, a server component might wish to expose its TCP port as a configurable parameter. To do so, it implements 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 is unimportant; most implementations 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—that is, properties that do not have a write method:

public int getHandledRequestCount();

As mentioned earlier, properties can also satisfy interdependencies among components. For example, if a component needs a pointer to a Scheduler component to operate, it simply exposes that dependency as a property:

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

The configuration file can specify which Scheduler to be used by the component, and Nucleus automatically sets the scheduler property accordingly. 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.

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