Package net.jini.core.lookup

Examples of net.jini.core.lookup.ServiceRegistrar


     */
    protected LocatorGroupsPair replaceMemberGroups(Object generator,
                                                    String[] newGroups)
                                                        throws RemoteException
    {
        ServiceRegistrar regProxy = null;
        if(generator instanceof DiscoveryProtocolSimulator) {
            regProxy
                    = ((DiscoveryProtocolSimulator)generator).getLookupProxy();
            ((DiscoveryProtocolSimulator)generator).setMemberGroups(newGroups);
        } else {
            regProxy = (ServiceRegistrar)generator;
            DiscoveryAdmin admin
                    = (DiscoveryAdmin)( ((Administrable)regProxy).getAdmin() );
      try {
                admin = (DiscoveryAdmin)
            getConfig().prepare("test.reggieAdminPreparer", admin);
      } catch (TestException e) {
    throw new RemoteException("Problem preparing admin", e);
      }
            admin.setMemberGroups(newGroups);
        }//endif
        LookupLocator loc = QAConfig.getConstrainedLocator(regProxy.getLocator());
        return new LocatorGroupsPair(loc,newGroups);
    }//end replaceMemberGroups
View Full Code Here


     */
    protected LocatorGroupsPair replaceMemberGroups(Object generator,
                                                    boolean alternate)
                                                        throws RemoteException
    {
        ServiceRegistrar regProxy = null;
  DiscoveryAdmin admin = null;
  // only prepare the real proxy (until simulators are secure)
        if(generator instanceof DiscoveryProtocolSimulator) {
            regProxy
                   = ((DiscoveryProtocolSimulator)generator).getLookupProxy();
      admin = (DiscoveryAdmin)( ((Administrable)regProxy).getAdmin() );
        } else {
            regProxy = (ServiceRegistrar)generator;
      admin = (DiscoveryAdmin)( ((Administrable)regProxy).getAdmin() );
      try {
                admin = (DiscoveryAdmin)
            getConfig().prepare("test.reggieAdminPreparer", admin);
      } catch (TestException e) {
    throw new RemoteException("Problem preparing admin", e);
      }
        }//endif
        String[] groups    = admin.getMemberGroups();
        String[] newGroups =  ( (groups.length > 0) ?
                          (new String[groups.length]) :
                          (new String[] {"Group_"+regProxy.getServiceID()}) );
        if(newGroups.length == 0) {
            logger.log(Level.FINE, "   NO_GROUPS");
        } else {
            for(int i=0;i<newGroups.length;i++) {
                boolean oddIndx = !((i%2) == 0);
View Full Code Here

                }
            } else {//(i >= nReplacements)
                /* Leave member groups of the current lookup service as is*/
                logger.log(Level.FINE, " lookup service "+i+" - "
                                  +"leaving member groups unchanged --");
                ServiceRegistrar regProxy = null;
                if(generator instanceof DiscoveryProtocolSimulator) {
                    regProxy
                    = ((DiscoveryProtocolSimulator)generator).getLookupProxy();
                } else {
                    regProxy = (ServiceRegistrar)generator;
                }//endif
                try {
                    LookupLocator loc = QAConfig.getConstrainedLocator(regProxy.getLocator());
                    String[] groups   = regProxy.getGroups();
                    if(groups.length == 0) {
                        logger.log(Level.FINE, "   NO_GROUPS");
                    } else {
                        for(int j=0;j<groups.length;j++) {
                            logger.log(Level.FINE, "   groups["+j+"] = "
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

                                  : (lusList.size() - (i%(lusList.size())) ) );
            ArrayList regInfoList = new ArrayList(nLookups);
            for(int j=0;j<nLookups;j++) {
                RegInfo regInfo = new RegInfo();
                int jndx = (lusList.size()-1) - j;
                ServiceRegistrar lookupProxy =
                                        (ServiceRegistrar)lusList.get(jndx);
                LookupLocator loc = null;
                try {
                    loc = QAConfig.getConstrainedLocator(lookupProxy.getLocator());
                } catch(Exception e) {
                    e.printStackTrace();
                    throw new RuntimeException(e.toString());
                }
                logger.log(Level.FINE, "registering test service "
                                              +i+" with lookup service "+loc);
                ServiceRegistration srvcReg =
                 lookupProxy.register(new ServiceItem(srvcID,testService,null),
                                      Long.MAX_VALUE);
    Lease srvcLease = null;
    try {
        srvcReg = (ServiceRegistration) getConfig().prepare(
           "test.reggieServiceRegistrationPreparer",
View Full Code Here

                 * Thus, the 'next' element to unmarshal is actually at
                 * the same index as the last element that was unmarshalled.
                 */
                MarshalledObject marshalledObj
                                 = (MarshalledObject)(marshalledRegs.get(i));
                ServiceRegistrar reg = (ServiceRegistrar)(marshalledObj.get());
                /* Success: record the un-marshalled element
                 *          delete the corresponding un-marshalled element
                 */
                unmarshalledRegs.add( reg );
                marshalledRegs.remove(i);
View Full Code Here

  throws Exception
    {
        logger.log(Level.FINE, "starting lookup service "+indx);
        /* retrieve the member groups with which to configure the lookup */
        String[] memberGroups = (String[])memberGroupsList.get(indx);
        ServiceRegistrar lookupProxy = null;
        if(implClassname.equals("com.sun.jini.test.services.lookupsimulator.LookupSimulatorImpl"))
        {
            /* Use either a random or an explicit locator port */
            DiscoveryProtocolSimulator generator =
    new DiscoveryProtocolSimulator(config, memberGroups, manager, port);
            genMap.put( generator, memberGroups );
            lookupProxy = generator.getLookupProxy();
        } else {//start a non-simulated lookup service implementation
      logger.log(Level.FINER, "Starting lookup for host " + serviceHost);
            lookupProxy = manager.startLookupService(serviceHost); // already prepared
            genMap.put( lookupProxy, memberGroups );
        }//endif
        lookupList.add( lookupProxy );
        LookupLocator lookupLocator = QAConfig.getConstrainedLocator(lookupProxy.getLocator());
        locatorsStarted.add(lookupLocator);
        LocatorsUtil.displayLocator(lookupLocator,
                                    "  locator ",Level.FINE);
        String displayGroups = GroupsUtil.toCommaSeparatedStr(memberGroups);
        if(displayGroups.equals("")) displayGroups = new String("NO_GROUPS");
View Full Code Here

                                 String[] replaceGroups,
                                 boolean alternate,
                                 int discardType)
    {
        try {
            ServiceRegistrar lookupProxy = null;
            if( curGen instanceof DiscoveryProtocolSimulator ) {
                DiscoveryProtocolSimulator generator
                                         = (DiscoveryProtocolSimulator)curGen;
                lookupProxy = generator.getLookupProxy();
            } else {
                lookupProxy = (ServiceRegistrar)curGen;
            }//endif
            String[] curGroups = lookupProxy.getGroups();
            String[] newGroups =  new String[] {"Group_"
                                                +lookupProxy.getServiceID()};
            if(replaceGroups != null) {
                newGroups = replaceGroups;
            } else {
                if((curGroups != null) && (curGroups.length > 0)) {
                    if(alternate) {
View Full Code Here

        Map newMap = new HashMap();
  Iterator iter = map.keySet().iterator();
        for(int i=0;iter.hasNext();i++) {
            Object key = iter.next();
            if( !(key instanceof DiscoveryProtocolSimulator) ) return map;
            ServiceRegistrar reg =
                           ((DiscoveryProtocolSimulator)key).getLookupProxy();
            String[] groups = (String[])map.get(key);
            newMap.put(reg,groups);
        }//end loop
        return newMap;
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.