Java 类com.vmware.vim25.mo.PropertyFilter 实例源码

项目:contrail-vcenter-plugin    文件:VCenterNotify.java   
private static void watchManagedObject(ManagedObject mos, String[] propNames)
{
    PropertyFilterSpec pfs = new PropertyFilterSpec();

    ObjectSpec[] oss = new ObjectSpec[1];
    oss[0] = new ObjectSpec();
    oss[0].setObj(mos.getMOR());
    pfs.setObjectSet(oss);

    PropertySpec ps = new PropertySpec();
    ps.setType(mos.getMOR().getType());
    ps.setPathSet(propNames);
    pfs.setPropSet(new PropertySpec[] { ps });

    try
    {
        PropertyFilter pf = propColl.createFilter(pfs, true); //report only nesting properties, not enclosing ones.
        if (pf != null) {
            watchedFilters.put(mos, pf);
        }
    } catch(RemoteException re)
    {
        throw new RuntimeException(re);
    }

}
项目:contrail-vcenter-plugin    文件:VCenterNotify.java   
@SuppressWarnings("unused")
private void unwatchManagedObjectEvents(ManagedObject mos)
{
    if (mos == null) {
        s_logger.error("Null arguments in unwatchManagedObjectEvents");
        return;
    }

    if (watchedFilters.containsKey(mos)) {
        try
        {
            PropertyFilter pf = watchedFilters.remove(mos);
            if (pf != null) {
                pf.destroyPropertyFilter();
            }
        } catch (RemoteException e)
        {
            s_logger.error("Cannot unwatchManagedObjectEvents for " + mos + ", exception " + e);
            s_logger.error(Throwables.getStackTraceAsString(e));
        }
    }
}
项目:contrail-vcenter-plugin    文件:VCenterNotify.java   
private static void unwatchManagedObject(ManagedObject mos)
{
    if (watchedFilters.containsKey(mos)) {
        try
        {
            PropertyFilter pf = watchedFilters.remove(mos);
            pf.destroyPropertyFilter();
        } catch (RemoteException e)
        {
            s_logger.error("Cannot unwatchManagedObject " + mos + " due to exception " + e);
            s_logger.error(Throwables.getStackTraceAsString(e));
        }
    }
}
项目:contrail-vcenter-plugin    文件:VCenterNotify.java   
private void watchManagedObjectEvents(ManagedObject mos, String[] events)
{
    if (mos == null || events == null) {
        s_logger.error("Null arguments in watchManagedObjectEvents");
        return;
    }
    try
    {
        EventHistoryCollector collector =
                createEventHistoryCollector(mos, events);

        if (collector == null) {
            s_logger.error("Cannot create EventHistoryCollector for events" + events);
            return;
        }
        PropertyFilterSpec eventFilterSpec = createEventFilterSpec(collector);

        if (eventFilterSpec == null) {
            s_logger.error("Cannot create PropertyFilterSpec for EventHistoryCollector for events"
                        + events);
            return;
        }

        PropertyFilter propFilter = propColl.createFilter(eventFilterSpec, true);

        if (propFilter != null) {
            watchedFilters.put(mos, propFilter);
        } else {
            s_logger.error("Cannot create event filter for managed object ");
        }
    } catch(Exception e)
    {
        s_logger.error("Cannot watchManagedObjectEvents for " + mos + ", exception " + e);
        s_logger.error(Throwables.getStackTraceAsString(e));
        throw new RuntimeException(e);
    }
}
项目:vijava    文件:ManagedObjectWatcher.java   
public void watch(PropertyFilterSpec pfs) 
{
    try
    {
        PropertyFilter pf = pc.createFilter(pfs, true); //report only nesting properties, not enclosing ones.
        filters.add(pf);
    } catch(RemoteException re)
    {
        throw new RuntimeException(re);
    }
}