Package net.jini.core.lookup

Examples of net.jini.core.lookup.ServiceRegistrar


     */
    private void updateGroupsInGlobalSet(Map groupsMap) {
        Set eSet = groupsMap.entrySet();
        for(Iterator itr = eSet.iterator(); itr.hasNext(); ) {
            Map.Entry pair = (Map.Entry)itr.next();
            ServiceRegistrar reg = (ServiceRegistrar)pair.getKey();
            if(allDiscoveredRegs.containsKey(reg)) {
                LookupLocator loc
                  = ((LocatorGroupsStruct)allDiscoveredRegs.get(reg)).locator;
                String[] newGroups = (String[])pair.getValue();
                LocatorGroupsStruct locGroups
View Full Code Here


            HashMap regMapOut = new HashMap(regMapIn.size());
            Iterator itr = (regMapIn.entrySet()).iterator();
            nextReg:
            for(int i=0;itr.hasNext();i++) {
                Map.Entry pair = (Map.Entry)itr.next();
                ServiceRegistrar reg = (ServiceRegistrar)pair.getKey();
                /* If reg is already in map, go to next registrar */
                if( discoveredRegsMap.containsKey(reg) ) continue nextReg;
                /* It doesn't contain it, try to marshal it */
                MarshalledObject mReg = null;
                try {
View Full Code Here

         * unicast response here because, prior to modification and storage
         * in the managed set of registrars in this method, it is assumed that
         * that object is not accessed by any other thread.
         */
        try {
      final ServiceRegistrar srcReg = resp.getRegistrar();
            ServiceRegistrar prepReg
    = (ServiceRegistrar)AccessController.doPrivileged
        ( securityContext.wrap( new PrivilegedExceptionAction() {
                        public Object run() throws RemoteException {
                            Object proxy = registrarPreparer.prepareProxy
                                                            (srcReg);
View Full Code Here

     *                  member groups of the registrar corresponding to the
     *                  <code>response</code> parameter (just after a
     *                  possible change)
     */
    private void maybeSendEvent(UnicastResponse response, String[] newGroups) {
        ServiceRegistrar reg = response.getRegistrar();
        boolean getActual    = true;
        if(newGroups == null) { // newGroups null means get actual groups now
            newGroups = getActualGroups(reg);
            if(newGroups == null) return; // if null, then it was discarded
            getActual = false;
        }//endif

        if(groupSetsEqual(response.getGroups(),newGroups)) return;

        String[] actualGroups = newGroups;
        if( getActual && (newGroups.length > 0) ) {
            actualGroups = getActualGroups(reg);
            if(actualGroups == null) return; // null ==> was already discarded
        }//endif
 
  synchronized (registrars) {
      // Other events may have occured to registrars while we were
      // making our remote call.
      UnicastResponse resp =
    (UnicastResponse) registrars.get(reg.getServiceID());
      if (resp == null) {
    // The registrar was discarded in the meantime. Oh well.
    return;
      }
      notifyOnGroupChange(reg, resp.getGroups(), actualGroups);
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) {
                logger.log(Level.INFO,
                           "Exception occurred during query, discarding proxy",
                           e);
View Full Code Here

  if(len > 0) {
            /* loop thru the set of lookups, randomly selecting each lookup */
      int rand = (Math.abs(random.nextInt())) % len;
      for(int i=0; i<len; i++) {
                int max = maxMatches;
    ServiceRegistrar proxy = proxys[(i + rand) % len];
    try {
                    /* If a filter is to be applied (filter != null), then
                     * the value of the maxMatches parameter will not
                     * suffice when querying the current lookup service.
                     * This is because although services returned from a
                     * query of the lookup service will match the template,
                     * some of those services may get filtered out. Thus,
                     * asking for exactly maxMatches may result in fewer
                     * matching services than actually are contained in
                     * the lookup. Thus, all matching services are
                     * requested by passing in "infinity" for the maximum
                     * number of matches (Integer.MAX_VALUE).
                     */
                    if(filter != null) max = Integer.MAX_VALUE;
                    /* Query the current lookup for matching service(s). */
        ServiceMatches sm = proxy.lookup(tmpl, max);
        int nItems = sm.items.length;
        if(nItems == 0) continue;//no matches, query next lookup
                    /* Loop thru the matching services, randomly selecting
                     * each service, applying the filter if appropriate,
                     * and making sure the service has not already been
View Full Code Here

                super(reg, seqN);
                this.eReg = eReg;
      }
            public void run() {
                logger.finest("ServiceDiscoveryManager - LookupTask started");
    ServiceRegistrar proxy = reg.proxy;
    ServiceMatches matches;
                /* For the given lookup, get all services matching the tmpl */
    try {
        matches = proxy.lookup(tmpl, Integer.MAX_VALUE);
    } catch (Exception e) {
                    boolean cacheTerminated;
                    synchronized(serviceIdMap) {
                        eReg.lookupsPending--;
                        cacheTerminated = bCacheTerminated;
View Full Code Here

      // read LUS proxy
      ObjectInputStream oin = new ObjectInputStream(
    new BufferedInputStream(socket.getInputStream()));
      MarshalledInstance mi =
    new MarshalledInstance((MarshalledObject) oin.readObject());
      ServiceRegistrar reg =
    (ServiceRegistrar) mi.get(defaultLoader, false, null, context);

      // read LUS member groups
      int ngroups = oin.readInt();
      if (ngroups < 0) {
View Full Code Here

     */
    public void discovered(DiscoveryEvent evt) {
        ServiceRegistrar[] registrars = evt.getRegistrars();

        for (int n = 0; n < registrars.length; n++) {
            ServiceRegistrar registrar = registrars[n];

            try {
                System.out.println("Found a service locator at "
                        + registrar.getLocator().getHost());
            } catch (RemoteException e) {
                KernelException.stackTraceToString(e);
            }
        }
    }
View Full Code Here

        // Name sn = new Name("*");
        ServiceTemplate tmpl = new ServiceTemplate(null, classes, new Entry[] {});

        // Creating a lookup locator
        LookupLocator locator = new LookupLocator(uri);
        ServiceRegistrar sr = locator.getRegistrar();

        TransactionManager tm = (TransactionManager) sr.lookup(tmpl);
        return tm;
    }
View Full Code Here

TOP

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

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.