To list the currently available persisting resources, use the following rhino-console command or related MBean query.

Console command: listpersistingresources


    List all configured persisting resources


$ ./rhino-console listpersistingresources
type               variant     name
-----------------  ----------  ----------
poolmaintenance     cassandra
kvstore             cassandra   cassandra
sessionownership    cassandra
3 rows

MBean query

Determining which persisting resources are available does not involve invoking any MBean operation, but instead is achieved by querying the MBean server to determine which MBeans are registered. Each persisting resource registers a Persisting Resource MBean with the MBean server to advertise its presence and provide access to the database tables it manages. These MBeans are registered using a base Object Name along with a number of additional key properties that define the persisting resource’s type, variant, and optional name.

The example code below can be used to determine which persisting resources are available.

import java.util.Set;
import com.opencloud.rhino.resource.PersistingResourceMBean;


MBeanServer mbeanServer = ...
ObjectName resourceMBeanNameQuery = new ObjectName(PersistingResourceMBean.BASE_OBJECT_NAME + ",*");
Set<ObjectName> resourceMBeanNames = mbeanServer.queryNames(resourceMBeanNameQuery, null);
for (ObjectName resourceMBeanName : resourceMBeanNames) {
    String resourceType = resourceMBeanName.getKeyProperty(PersistingResourceMBean.RESOURCE_TYPE_KEY);
    String resourceVariant = resourceMBeanName.getKeyProperty(PersistingResourceMBean.RESOURCE_VARIANT_KEY);
    String resourceName = resourceMBeanName.getKeyProperty(PersistingResourceMBean.RESOURCE_NAME_KEY);
    if (resourceName != null) resourceName = ObjectName.unquote(resourceName);

    // do something with resourceType, resourceVariant, and resourceName
Previous page Next page
Rhino Version 3.2