Open topic with navigation

TIBCO® Enterprise Administrator 2.4.2

# Defining a Singleton Object Type in Interface Style

Defining a singleton object type is a special case of defining an object type. The difference is that a singleton object type does not require a provider. Alternatively, we might say that its unique instance is its own provider.

Because a singleton is its own provider, the SingletonTeaObject interface subsumes the other provider methods (namely, getTypeName, getTypeDescription and getConcept).

Because it is a singleton, it needs no getInstance method.

Procedure
1. Define a class that models the managed object type. Your class must implement the interface SingletonTeaObject.
   For example, when modeling a car, we could define a singleton class to represent the engine.

       public class CarEngine implements SingletonTeaObject {

           public String getName() {
               // Return the name of the engine instance;
               return "Engine";
           }

           public String getDescription() {
               // Return the description of the engine instance;
               return "Car Engine";
           }

           public String getKey() {
               // Return the key that corresponds to the engine instance;
               // for example, "Engine"
           }

             // These methods give the singleton functionality
             // that would otherwise be in the provider.

           public String getTypeName() {
               // Return the name of the engine object type.
               return "Engine";
           }

           public String getTypeDescription() {
               // Return the description of the engine object type.
               return "Car Engine";
           }

           public TeaConcept getConcept() {
               // Return the concept type of the driver.
               // In our model, it's a process that steers the car.
               return TeaConcept.RESOURCE;
           }

       }

2. Register the singleton instance of the class.

       CarAgentServer server = ...
       // Register other instances, including the top-level object type.
       CarEngine myCarEngine = new CarEngine;server.registerInstance(myCarEngine);
        ...
       server.start();

   Notice that instead of registering the provider, we register the unique instance of the engine class.

Did you find this helpful?

Yes No
Great!
Thanks for taking the time to give us some feedback.
Sorry about that

Why wasn't this helpful? (check all that apply)

Could not find what I was looking for
Instructions confusing or unclear
Instructions did not work

Want to tell us more?

Please select at least one option or provide details about the issue!!

Error occurred while submitting feedback.

Error2 occurred while submitting feedback.

TIBCO® Enterprise Administrator

Copyright © 1996-2025. Cloud Software Group, Inc. All Rights Reserved.