Package net.jini.core.lookup

Examples of net.jini.core.lookup.ServiceItem


        public void mouseClicked(MouseEvent ev) {
      if(ev.getClickCount() >= 2){
    ServiceListItem listItem = getTargetListItem(ev);
    if(listItem != null) {
        ServiceItem item = listItem.getServiceItem();
        if(listItem.isAdministrable())
      new ServiceEditor(item, listItem.getAdmin(), lookup,
            Browser.this).setVisible(true);
        else if(listItem.isAccessible())
      new ServiceBrowser(item, lookup,
View Full Code Here


                    /* 1. Cleanup "orphaned" itemReg's. */
                    Iterator iter = (serviceIdMap.entrySet()).iterator();
                    while(iter.hasNext()) {
                        Map.Entry e = (Map.Entry)iter.next();
                        ServiceID srvcID = (ServiceID)e.getKey();
                        ServiceItem itemInSnapshot = findItem(srvcID,
                                                              matches.items);
                        if(itemInSnapshot != null) continue;//not an orphan
                        ServiceItemReg itemReg = (ServiceItemReg)e.getValue();
                        UnmapProxyTask t = new UnmapProxyTask(reg,
                                                              itemReg,
View Full Code Here

                              +"started");
    Iterator iter = getServiceIdMapEntrySetIterator();
    while(iter.hasNext()) {
        Map.Entry e = (Map.Entry)iter.next();
        ServiceItemReg itemReg = (ServiceItemReg)e.getValue();
                    ServiceItem item;
                    synchronized(itemReg) {
                        item = itemReg.filteredItem;
                    }//end sync(itemReg)
        if( (item.service).equals(service) ) {
      ServiceID sid = (ServiceID)e.getKey();
View Full Code Here

                ServiceItemReg itemReg = null;
                synchronized(serviceIdMap) {
                    itemReg = (ServiceItemReg)serviceIdMap.get(serviceID);
                }//end sync(serviceIdMap)
                if(itemReg != null) {
                    ServiceItem item = null;
                    ServiceItem filteredItem = null;
                    synchronized(itemReg) {
                        if(itemReg.filteredItem == null) {
                            item = new ServiceItem
                                              ( (itemReg.item).serviceID,
                                                (itemReg.item).service,
                                                (itemReg.item).attributeSets);
                            filteredItem = new ServiceItem
                                              ( (itemReg.item).serviceID,
                                                (itemReg.item).service,
                                                (itemReg.item).attributeSets);
                        }//endif
                    }//end sync(itemReg)
                    if(filteredItem != null) {//retry the filter
                        if( filterPassFail(filteredItem,filter) ) {
                            addFilteredItemToMap(item,filteredItem);
                        } else {//'quietly' remove the item
                            removeServiceIdMapSendNoEvent(serviceID);
                            return;
                        }//endif
                    }//endif
                    /* Either the filter was retried and passed, in which case,
                     * the filtered itemCopy was placed in the map; or the
                     * filter wasn't applied above (a non-null filteredItem
                     * field in the itemReg in the map means that the filter
                     * was applied at some previous time). In either case, the
                     * service can now be "un-discarded", and a notification
                     * that the service is now available can be sent.
                     */
                    ServiceItem itemToSend;
                    synchronized(itemReg) {
                        itemReg.setDiscarded(false);
                        itemToSend = itemReg.filteredItem;
                    }//end sync(itemReg)
                    addServiceNotify(itemToSend);
View Full Code Here

  int len = proxys.length;
  if(len == 0 ) return null;
  int rand = Math.abs(random.nextInt()) % len;
  for(int i=0; i<len; i++) {
      ServiceRegistrar proxy = proxys[(i + rand) % len];
      ServiceItem sItem = null;
      try {
                int maxMatches = ( (filter != null) ? Integer.MAX_VALUE : 1 );
    ServiceMatches sm = proxy.lookup(tmpl, maxMatches);
    sItem = getMatchedServiceItem(sm, filter);
      } catch(Exception e) {
View Full Code Here

                              ServiceItemFilter filter,
            long waitDurthrows InterruptedException,
                                                    RemoteException
    {
        /* First query each lookup for the desired service */
        ServiceItem sm = lookup(tmpl,filter);//checkTerminated() is done here
  if(sm != null) return sm;
        /* If the desired service is not in any of the lookups, wait for it. */
  ServiceDiscoveryListener cacheListener
                                        = new ServiceDiscoveryListenerImpl();
        LookupCacheImpl cache = null;
View Full Code Here

                     * selected (it may have been returned from a previously
                     * queried lookup).
                     */
        int r = (Math.abs(random.nextInt())) % nItems;
        for(int j=0; j<nItems; j++) {
      ServiceItem sItem = sm.items[(j+r) % nItems];
      if(sItem == nullcontinue;
                        if( !filterPassFail(sItem,filter) ) continue;
      if(!isArrayContainsServiceItem(sItemSet, sItem))
          sItemSet.add(sItem);
      if(sItemSet.size() >= maxMatches) {
View Full Code Here

        synchronized(cacheListener) {
            cache = createLookupCache(tmpl,filter,cacheListener,waitDur);
            long duration = cache.getLeaseDuration();
            while ( duration > 0 ) {
                cacheListener.wait(duration);
                ServiceItem items[] = cacheListener.getServiceItem();
                for(int i=0; i<items.length; i++) {
                    if(!isArrayContainsServiceItem(sItemSet, items[i])) {
                        sItemSet.add(items[i]);
                    }//endif
                }//end loop
View Full Code Here

    {
  int len = sm.items.length;
  if(len > 0) {
      int rand = Math.abs(random.nextInt()) % len;
      for(int i=0; i<len; i++) {
    ServiceItem sItem = sm.items[(i+rand) % len];
    if(sItem == nullcontinue;
                if( !filterPassFail(sItem,filter) ) continue;
    return sItem;
      }//end loop
  }//endif
View Full Code Here

    {
  Iterator iter = a.iterator();
  while(iter.hasNext()) {
      Object o = iter.next();
      if ( !(o instanceof ServiceItem )) continue;
      ServiceItem sa = (ServiceItem)o;
      if(    sa.serviceID.equals(s.serviceID)
                && LookupAttributes.equal(sa.attributeSets,s.attributeSets)
                && (sa.service.equals(s.service)) )
    return true;
  }//end loop
View Full Code Here

TOP

Related Classes of net.jini.core.lookup.ServiceItem

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.