Provides a shared AST.
@name javascript.ASTManager
@class Provides a shared AST.
@param {?} serviceRegistry The platform service registry
@param {?} servjsProject The backing project context
494752
function ASTManager(serviceRegistry, jsProject) {
		this.cache = new LRU(10);
		this.orionAcorn = new OrionAcorn();
		this.jsProject = jsProject;
		registry = serviceRegistry;
	}
103516
@Override
	protected Object getHandler(String serviceName) {
		Object handler = handlerMap.get(serviceName);
		if (handler == null) {
			logger.error("Service '{}' is not registered in this multi-server", serviceName);
			throw new RuntimeException("Service '" + serviceName + "' does not exist");
		}
		return handler;
	}
1100521
public void registerServiceHandler(String name, Object handler) {
        Map<String, Object> serviceHandlers = getServiceHandlers();
        serviceHandlers.put(name, handler);
    }
658424
public static void registerServlets (@Nonnull final ServletContext aSC)
  {
    ValueEnforcer.notNull (aSC, "ServletContext");

    if (s_aInitialized.compareAndSet (false, true))
    {
      // Check SC version
      if (aSC.getMajorVersion () < 3)
        throw new IllegalStateException ("At least servlet version 3 is required! Currently running version " +
                                         aSC.getMajorVersion () +
                                         "." +
                                         aSC.getMinorVersion ());

      LOGGER.info ("Registering default ph-oton listeners and servlets");

      {
        final FilterRegistration.Dynamic aFilter = aSC.addFilter ("CharacterEncodingFilter",
                                                                  CharacterEncodingFilter.class);
        if (aFilter != null)
        {
          // Filter is new
          aFilter.setAsyncSupported (true);
          aFilter.setInitParameter (CharacterEncodingFilter.INITPARAM_ENCODING, StandardCharsets.UTF_8.name ());
          aFilter.setInitParameter (CharacterEncodingFilter.INITPARAM_FORCE_ENCODING, Boolean.TRUE.toString ());
          aFilter.addMappingForUrlPatterns (null, false, "/*");
        }
      }

      {
        final ServletRegistration.Dynamic aServlet = aSC.addServlet ("PhotonAjaxServlet", PhotonAjaxServlet.class);
        if (aServlet != null)
        {
          aServlet.setAsyncSupported (true);
          aServlet.addMapping (PhotonAjaxServlet.SERVLET_DEFAULT_PATH + "/*");
        }
      }

      {
        final ServletRegistration.Dynamic aServlet = aSC.addServlet ("PhotonAPIServlet", PhotonAPIServlet.class);
        if (aServlet != null)
        {
          aServlet.setAsyncSupported (true);
          aServlet.addMapping (PhotonAPIServlet.SERVLET_DEFAULT_PATH + "/*");
        }
      }

      {
        final ServletRegistration.Dynamic aServlet = aSC.addServlet ("StreamServlet", StreamServlet.class);
        if (aServlet != null)
        {
          aServlet.setAsyncSupported (true);
          aServlet.setInitParameter (AbstractObjectDeliveryHttpHandler.INITPARAM_ALLOWED_EXTENSIONS,
                                     AbstractObjectDeliveryHttpHandler.EXTENSION_MACRO_WEB_DEFAULT);
          aServlet.addMapping (StreamServlet.SERVLET_DEFAULT_PATH + "/*");
        }
      }

      {
        final ServletRegistration.Dynamic aServlet = aSC.addServlet ("UserStreamServlet", UserStreamServlet.class);
        if (aServlet != null)
        {
          aServlet.setAsyncSupported (true);
          aServlet.setInitParameter (AbstractObjectDeliveryHttpHandler.INITPARAM_ALLOWED_EXTENSIONS,
                                     AbstractObjectDeliveryHttpHandler.EXTENSION_MACRO_WEB_DEFAULT);
          aServlet.addMapping (UserStreamServlet.SERVLET_DEFAULT_PATH + "/*");
        }
      }

      {
        final ServletRegistration.Dynamic aServlet = aSC.addServlet ("UserUploadServlet", UserUploadServlet.class);
        if (aServlet != null)
        {
          aServlet.setAsyncSupported (true);
          aServlet.addMapping (UserUploadServlet.SERVLET_DEFAULT_PATH + "/*");
        }
      }

      {
        final ServletRegistration.Dynamic aServlet = aSC.addServlet ("LogoutServlet", LogoutServlet.class);
        if (aServlet != null)
        {
          aServlet.setAsyncSupported (true);
          aServlet.addMapping (LogoutServlet.SERVLET_DEFAULT_PATH + "/*");
        }
      }

      {
        final ServletRegistration.Dynamic aServlet = aSC.addServlet ("ResourceBundleServlet",
                                                                     ResourceBundleServlet.class);
        if (aServlet != null)
        {
          aServlet.setAsyncSupported (true);
          aServlet.setInitParameter (AbstractObjectDeliveryHttpHandler.INITPARAM_ALLOWED_EXTENSIONS, "js,css");
          aServlet.addMapping (ResourceBundleServlet.SERVLET_DEFAULT_PATH + "/*");
        }
      }

      {
        final ServletRegistration.Dynamic aServlet = aSC.addServlet ("GoServlet", GoServlet.class);
        if (aServlet != null)
        {
          aServlet.setAsyncSupported (true);
          aServlet.addMapping (GoServlet.SERVLET_DEFAULT_PATH + "/*");
        }
      }

      {
        aSC.addListener (PhotonStubServletContextListener.class);
      }

      LOGGER.info ("Finished registering default ph-oton listeners and servlets");
    }
  }
56883
private ServiceHandle<S> doRegister(ServiceEndPoint endPoint) {
        checkNotNull(endPoint);

        ServiceHandle<S> toDelete = null;
        ServiceHandle<S> toReturn;

        synchronized (this) {
            HeavyServiceHandle<S> existingServiceHandle = _instancesPerEndpoint.get(endPoint);
            if (existingServiceHandle == null || existingServiceHandle.hasBeenFlaggedForEviction() || existingServiceHandle.isOld()) {

                // If there was not an existingServiceHandle, then make a new one.
                //
                // If existingServiceHandle.hasBeenFlaggedForEviction() is true, that means this EndPoint
                //  has been "evicted" for being "bad" but has recovered before the Eviction timeout
                //  process has gotten around to cleaning up this serviceHandle.  In this case, we assume
                //  the "safest" thing to do is to create a new Client for that EndPoint, in case the
                //  problem was with the "old" client.
                //
                // If the existingServiceHandle is "new" don't create a new client object due to the
                //  race condition in HostDiscovery and ServicePool, which can cause a checkOut() to
                //  occur before its associated ServiceCache.register().
                // Thus we want have a short period of time where duplicate "checkouts" and a register
                //  will not thrash the system creating a series of Client instances.
                //
                // _serviceFactory.create(endPoint) is a potentially expensive operation, memory, file handles, etc.
                // hence we really only want to do it when we have to, preferably via the out-of-band
                // ServiceCache.register() method, instead of the high traffic checkOut method.
                S service = _serviceFactory.create(endPoint);
                _serviceCounter.inc();

                HeavyServiceHandle<S> newServiceHandle = new HeavyServiceHandle<>(service, endPoint);

                // add the newServiceHandle to a new copy of the _instancesPerEndpoint map
                Map<ServiceEndPoint, HeavyServiceHandle<S>> sourceCopy = Maps.newHashMap(_instancesPerEndpoint);
                sourceCopy.put(endPoint, newServiceHandle);
                _instancesPerEndpoint = sourceCopy;

                toDelete = existingServiceHandle;
                toReturn = newServiceHandle;
            } else {
                // The existingServiceHandle was not null, not evicted, and not old, thus we did not recreate it.
                toReturn = existingServiceHandle;
            }
        }

        // Destroy instances outside the synchronization, with the idea being it may be an expensive operation
        if (toDelete != null) {
            destroyService(toDelete);
            _serviceCounter.dec();
        }

        return toReturn;
    }
1160428
public void registerService(ProvidedServiceInstance serviceInstance,
            OperationalStatus status) {

        serviceInstance.setStatus(status);
        registerService(serviceInstance);
    }
804826
public ResourceRegistry build(ResourceLookup resourceLookup, ModuleRegistry moduleRegistry, ServiceUrlProvider serviceUrl) {
		Set<Class<?>> jsonApiResources = resourceLookup.getResourceClasses();

		Set<ResourceInformation> resourceInformationSet = new HashSet<>(jsonApiResources.size());
		

		for (Class<?> clazz : jsonApiResources) {
			resourceInformationSet.add(resourceInformationBuilder.build(clazz));
			LOGGER.trace("{} registered as a resource", clazz);
		}

		Set<RegistryEntry> registryEntries = new HashSet<>(resourceInformationSet.size());
		for (ResourceInformation resourceInformation : resourceInformationSet) {
			Class<?> resourceClass = resourceInformation.getResourceClass();

			ResourceEntry resourceEntry = repositoryEntryBuilder.buildResourceRepository(resourceLookup, resourceClass);
			LOGGER.trace("{} has a resource repository {}", resourceInformation.getResourceClass(), resourceEntry);
			List<ResponseRelationshipEntry> relationshipEntries = repositoryEntryBuilder.buildRelationshipRepositories(resourceLookup, resourceClass);
			LOGGER.trace("{} has relationship repositories {}", resourceInformation.getResourceClass(), relationshipEntries);

			ResourceRepositoryInformation repositoryInformation = new ResourceRepositoryInformationImpl(null, resourceInformation.getResourceType(), resourceInformation);
			registryEntries.add(new RegistryEntry(repositoryInformation, resourceEntry, relationshipEntries));
		}

		ResourceRegistry resourceRegistry = new ResourceRegistryImpl(moduleRegistry, serviceUrl);
		for (RegistryEntry registryEntry : registryEntries) {
			Class<?> resourceClass = registryEntry.getResourceInformation().getResourceClass();
			RegistryEntry registryEntryParent = findParent(resourceClass, registryEntries);
			registryEntry.setParentRegistryEntry(registryEntryParent);
			resourceRegistry.addEntry(resourceClass, registryEntry);
		}

		return resourceRegistry;
	}
961872
@SuppressWarnings("unchecked")
    public static <E> ServiceRegistry<E> getInstance() {
        if (instance == null) {
            synchronized (ServiceRegistry.class) {
                if (instance == null) {
                    instance = new ServiceRegistry<E>();
                }
            }
        }
        return instance;
    }
762182
public static <T> void deregisterProvider(final ServiceRegistry registry, final IIOServiceProvider provider, final Class<T> category) {
        // http://www.ibm.com/developerworks/java/library/j-jtp04298.html
        registry.deregisterServiceProvider(category.cast(provider), category);
    }
812950
protected void verifyRegisteredService(final RequestContext requestContext, final RegisteredService registeredService) {
        if (registeredService == null || !registeredService.getAccessStrategy().isServiceAccessAllowed()) {
            LOGGER.debug("Service [{}] is not recognized/allowed by the CAS service registry", registeredService);
            if (registeredService != null) {
                WebUtils.putUnauthorizedRedirectUrlIntoFlowScope(requestContext, registeredService.getAccessStrategy().getUnauthorizedRedirectUrl());
            }
            throw new UnauthorizedServiceException(UnauthorizedServiceException.CODE_UNAUTHZ_SERVICE, StringUtils.EMPTY);
        }
    }
1142490
protected void registerAddOperation(final ManagementResourceRegistration registration, final AbstractAddStepHandler handler,
                                        OperationEntry.Flag... flags) {
        registration.registerOperationHandler(getOperationDefinition(ModelDescriptionConstants.ADD,
                new DefaultResourceAddDescriptionProvider(registration, descriptionResolver, orderedChild), OperationEntry.EntryType.PUBLIC, flags)
                , handler);
    }
1025412
protected void doRegister(String appName, String serviceName, String serviceData, String group) {
        PublisherRegistration publisherRegistration;
        // 生成注册对象，并添加额外属性
        publisherRegistration = new PublisherRegistration(serviceName);

        publisherRegistration.setGroup(group);
        addAttributes(publisherRegistration, group);

        // 去注册
        SofaRegistryClient.getRegistryClient(appName, registryConfig).register(publisherRegistration, serviceData);
    }
412918
public GrpcServerBuilder addService(ServiceType serviceType, GrpcService serviceDefinition) {
    mServices.add(serviceType);
    return addService(serviceDefinition);
  }
824422
@Override
    public <T> Collection<T> all(Class<T> serviceClass) {
        List<T> serviceImpls = new ArrayList<T>();
        Set<Class<? extends T>> serviceImplClasses = registry.getServiceImpls(serviceClass);
        for (Class<? extends T> serviceImplClass : serviceImplClasses) {
            T serviceImpl = createServiceInstance(serviceImplClass);
            serviceImpls.add(serviceImpl);
        }
        return serviceImpls;
    }
1048165
public void registerService(ProvidedServiceInstance serviceInstance, ServiceInstanceHealth registryHealth) {
        registerService(serviceInstance);
        getCacheServiceInstances().put(new ServiceInstanceToken(serviceInstance.getServiceName(), serviceInstance.getProviderId()),
                new InstanceHealthPair(registryHealth));
    }
90810
public static RegisteredService getRegisteredService(final RequestContext context) {
        return context != null ? (RegisteredService) context.getFlowScope().get(PARAMETER_REGISTERED_SERVICE) : null;
    }
347953
public static <C, T extends Service<C>> ServiceBuilder<C, T> forService(
            Class<T> serviceType) {

        if (serviceType == null) {
            throw new NullPointerException("serviceType");
        }

        V1ServiceInterface v1annotation =
                serviceType.getAnnotation(V1ServiceInterface.class);

        if (v1annotation != null) {
            return new ServiceBuilder<>(
                    new V1ServiceFactory<>(serviceType, v1annotation));
        }

        CustomServiceInterface customAnnotation =
                serviceType.getAnnotation(CustomServiceInterface.class);

        if (customAnnotation != null) {
            return new ServiceBuilder<>(
                    new CustomServiceFactory<>(serviceType, customAnnotation));
        }

        throw new IllegalArgumentException(
                "Service interfaces must be decorated with an "
                + "@[Type]ServiceInterface annotation.");
    }