This tool is useful for a number of different things. At this point, we are only interested in the "Component Services" item. Drill down until you find the "COM+ Applications" node.
For our example, we are going to create a new "Application" (an "application" in the COM+ sense is simply a set of COM+ components). To do so, we right click on the COM+ Applications node and select "New/Component". The wizard now guides us through the steps of setting up a new COM+ application. We can accept all the provided defaults. We only specify the application name ("Household" in the current example).
The next step is to actually register the COM+ Events Class we just created. We can do this by right clicking on the "Components" folder in our new application and selecting "New/Component". For people who are familiar with MTS or COM+, this was all business as usual. However, we now take a slightly different route. In the wizard, we choose to install a new event class and not a new or existing COM component:
This is important in order to make the event service realize that it has to take over. In the next step of the wizard, we select the component we just created, (wife.dll) and proceed on to register the event class.
We now have the "wife" in place and she already knows how to give instructions to carry out the garbage. However, there is nobody there who listens. Speaking out of my own experience, this isn't good. So it's time we find her a husband...
...And Our First Subscriber
Thankfully, finding her a husband in the COM+ world is much easier than in the real world. We can simply program one in Visual FoxPro. We create a new ActiveX DLL project and name the main project "husband" and the actual class "garbageman" (as you can see, naming doesn't really matter here...).
In this class, we now need to "implement" the interface defined in the "wife"
class. This sounds confusing at first, but it really only means that we will
create a class that has the same methods as the class that defines the interface
("wife" in our example) and we will actually add code to these methods (the
actual "implementation"). However, COM+ isn't very trusting as far as interfaces
go, so we have to officially declare that our interface implementation will be
compatible to the interface definition. We do this with the "INTERFACE" keyword.
Here is that code:
OK, we now are ready to implement the interface. In our example, this is
going to be relatively trivial and straightforward. We simply create a method
named "TakeOutGarbage" just like in the Wife class. Also, we specifically state
that this is the implementation of the TakeOutGarbage method defined in the "Garbage"
interface of the Wife class. We do this by setting the name of the interface
before the method name, separated by an underscore. Here's the entire code that
goes into our class:
As you can see, my implementation is very simple and simply opens a DBF and puts some data in it so we can later open the DBF to see whether this worked.
OK. We are now ready to compile our husband into a DLL. Once this is done, we add the component to our COM+ application in a similar fashion to how we added the wife class before. However, this time we do not add an event class, but just a plain component.
So we now have a husband and (which is really amazing to me), he is actually compatible with the wife. So all that's left to do is get the wedding over with and move on in life. The COM+ equivalent thereof is a "subscription". In other words, the husband subscribes to all the events, the wife fires. To set this up, expand the Husband item in the Component Service Manager and select New/ Subscription from the right click menu: