Registry.java revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* ident "%Z%%M% %I% %E% SMI"
*
* Copyright (c) 2000 by Sun Microsystems, Inc.
* All rights reserved.
*/
/*
* Copyright (C) 1996 Active Software, Inc.
* All rights reserved.
*
* @(#) Registry.java 1.9 - last change made 07/16/97
*/
/**
* The event registry
*
* @version 1.9, 07/16/97
*/
/**
* Constructor.
*/
public Registry() {
// Initialize publisher records
num_pubs = 0;
// Initialize subscriber records
num_subs = 0;
// The thread
}
// Data Members
private int num_pubs;
private RegistryEntry pubs[];
private int num_subs;
private Message sub_events[];
private AttributeManager sub_objects[];
private Thread publish_thread;
/**
* Subscribe to events using the supplied Message as a
* template for
* requested events. <br>
* Only 'name', 'type' and 'targetName' can be set on the
* template event.
* (all other fields should be null, zero or false as
* appropriate).
* The strings are compared for equality. If the last
* character of the
* string is '*', then all strings beginning with the
* rest of the string
* are considered to be matching. <br>
* <b>Note:</b> the callback object should be written to
* handle callbacks
* on multiple threads.
*/
// Check for bad params
return -1;
// Look for empty subscription ID
int i;
if (sub_events[i] == null) {
// Found it
break;
}
}
if (i >= sub_events.length) {
// None found, so grow the arrays
}
// Add the entry
sub_objects[i] = obj;
return i;
}
/**
* Cancel a subscription.The 'id' is the value returned from the
* subscribe call.
*/
public synchronized void unsubscribe(int id) {
return;
}
/**
* Send an event via the registry to all subscribers.
*/
if (publish_thread == null) {
publish_thread = new Thread(this);
publish_thread.setDaemon(true);
}
notify();
}
/**
* The actual run method
*/
public void run()
{
while (true) {
synchronized (this) {
try {
wait();
}
}
} else {
}
}
// Look for matching subscriptions
// Match events code is here
if ((sub_events[i] != null) &&
msg.targetName)) {
// Call the object
}
}
}
}
}
/**
* Compare strings. A filter value of 'null' matches anything.
* A filter
* string ending in '*' matches any string beginning with
* the filter's
* string.
*/
return true;
try {
{
return true;
}
}
return false;
}
/**
* Register a publisher with the registry.
* This is not necessary in order
* to actually publish. It is just used to advertise
* yourself in the
* publishers list.
*/
// Check for illegal params
if (publisher_name == null)
return;
// Look for empty publication entry
int i;
// Found it
break;
}
}
// None found, so grow the array
}
// Add the entry
}
/**
* Unregister a publisher.
*/
// Look for the entry
{
// Found it
}
}
}
/**
* Get the list of registered publishers.
*/
public synchronized RegistryEntry[] getPublishers() {
// First count the entries
int count = 0;
}
// Then copy them
count = 0;
++count;
}
}
return rc;
}
}