Package org.glassfish.hk2.api

Examples of org.glassfish.hk2.api.Descriptor


   
    /**
     * Mallory cannot un-advertise ServiceLocator!
     */
    public void tryToUnAdvertiseAService() {
        final Descriptor locatorService = locator.getBestDescriptor(BuilderHelper.createContractFilter(ServiceLocator.class.getName()));
       
        // This filter matches ServiceLocator itself!
        Filter unbindFilter = new Filter() {

            @Override
            public boolean matches(Descriptor d) {
                if (d.getServiceId().equals(locatorService.getServiceId())) {
                    if (d.getLocatorId().equals(locator.getLocatorId())) {
                        return true;
                    }
                }
               
View Full Code Here


    }

    private boolean isSecureAnnotated(ValidationInformation info) {

        Descriptor d = info.getCandidate();

        Set<String> qualifiers = d.getQualifiers();
        if (qualifiers != null && qualifiers.size() != 0) {
            for (String s : qualifiers) {
                if (Secure.class.getCanonicalName().equals(s)) {
                    if (LOG.isLoggable(Level.FINE)) {
                        LOG.fine("The instance is annotated with \'Secure\': "
View Full Code Here

    }
 
  public boolean equals(Object a) {
      if (a == null) return false;
      if (!(a instanceof Descriptor)) return false;
      Descriptor d = (Descriptor) a;
     
      if (!safeEquals(implementation, d.getImplementation())) return false;
      if (!equalOrderedCollection((contracts == null) ? EMPTY_CONTRACTS_SET : contracts, d.getAdvertisedContracts())) return false;
      if (!safeEquals(name, d.getName())) return false;
      if (!safeEquals(scope, d.getScope())) return false;
      if (!equalOrderedCollection((qualifiers == null) ? EMPTY_QUALIFIER_SET : qualifiers, d.getQualifiers())) return false;
      if (!safeEquals(descriptorType, d.getDescriptorType())) return false;
      if (!safeEquals(descriptorVisibility, d.getDescriptorVisibility())) return false;
      if (!equalMetadata((metadatas == null) ? EMPTY_METADATAS_MAP : metadatas, d.getMetadata())) return false;
      if (!safeEquals(proxiable, d.isProxiable())) return false;
      if (!safeEquals(proxyForSameScope, d.isProxyForSameScope())) return false;
      if (!safeEquals(analysisName, d.getClassAnalysisName())) return false;
     
      return true;
  }
View Full Code Here

    }
 
  public boolean equals(Object a) {
      if (a == null) return false;
      if (!(a instanceof Descriptor)) return false;
      Descriptor d = (Descriptor) a;
     
      if (!safeEquals(implementation, d.getImplementation())) return false;
      if (!equalOrderedCollection((contracts == null) ? EMPTY_CONTRACTS_SET : contracts, d.getAdvertisedContracts())) return false;
      if (!safeEquals(name, d.getName())) return false;
      if (!safeEquals(scope, d.getScope())) return false;
      if (!equalOrderedCollection((qualifiers == null) ? EMPTY_QUALIFIER_SET : qualifiers, d.getQualifiers())) return false;
      if (!safeEquals(descriptorType, d.getDescriptorType())) return false;
      if (!safeEquals(descriptorVisibility, d.getDescriptorVisibility())) return false;
      if (!equalMetadata((metadatas == null) ? EMPTY_METADATAS_MAP : metadatas, d.getMetadata())) return false;
      if (!safeEquals(proxiable, d.isProxiable())) return false;
      if (!safeEquals(proxyForSameScope, d.isProxyForSameScope())) return false;
      if (!safeEquals(analysisName, d.getClassAnalysisName())) return false;
     
      return true;
  }
View Full Code Here

    @Override
    public FactoryDescriptors bind(FactoryDescriptors factoryDescriptors, boolean requiresDeepCopy) {
        if (factoryDescriptors == null) throw new IllegalArgumentException("factoryDescriptors is null");
       
        // Now a bunch of validations
        Descriptor asService = factoryDescriptors.getFactoryAsAService();
        Descriptor asFactory = factoryDescriptors.getFactoryAsAFactory();
       
        checkDescriptor(asService);
        checkDescriptor(asFactory);
       
        String implClassService = asService.getImplementation();
        String implClassFactory = asFactory.getImplementation();
       
        if (!implClassService.equals(implClassFactory)) {
            throw new IllegalArgumentException("The implementation classes must match (" +
                implClassService + "/" + implClassFactory + ")");
        }
       
        if (!asService.getDescriptorType().equals(DescriptorType.CLASS)) {
            throw new IllegalArgumentException("The getFactoryAsService descriptor must be of type CLASS");
        }
        if (!asFactory.getDescriptorType().equals(DescriptorType.PROVIDE_METHOD)) {
            throw new IllegalArgumentException("The getFactoryAsFactory descriptor must be of type PROVIDE_METHOD");
        }
       
        final SystemDescriptor<?> boundAsService = new SystemDescriptor<Object>(asService,
                requiresDeepCopy,
View Full Code Here

    }
 
  public boolean equals(Object a) {
      if (a == null) return false;
      if (!(a instanceof Descriptor)) return false;
      Descriptor d = (Descriptor) a;
     
      if (!safeEquals(implementation, d.getImplementation())) return false;
      if (!equalOrderedCollection((contracts == null) ? EMPTY_CONTRACTS_SET : contracts, d.getAdvertisedContracts())) return false;
      if (!safeEquals(name, d.getName())) return false;
      if (!safeEquals(scope, d.getScope())) return false;
      if (!equalOrderedCollection((qualifiers == null) ? EMPTY_QUALIFIER_SET : qualifiers, d.getQualifiers())) return false;
      if (!safeEquals(descriptorType, d.getDescriptorType())) return false;
      if (!safeEquals(descriptorVisibility, d.getDescriptorVisibility())) return false;
      if (!equalMetadata((metadatas == null) ? EMPTY_METADATAS_MAP : metadatas, d.getMetadata())) return false;
      if (!safeEquals(proxiable, d.isProxiable())) return false;
      if (!safeEquals(proxyForSameScope, d.isProxyForSameScope())) return false;
      if (!safeEquals(analysisName, d.getClassAnalysisName())) return false;
     
      return true;
  }
View Full Code Here

    @Override
    public FactoryDescriptors bind(FactoryDescriptors factoryDescriptors, boolean requiresDeepCopy) {
        if (factoryDescriptors == null) throw new IllegalArgumentException("factoryDescriptors is null");
       
        // Now a bunch of validations
        Descriptor asService = factoryDescriptors.getFactoryAsAService();
        Descriptor asFactory = factoryDescriptors.getFactoryAsAFactory();
       
        checkDescriptor(asService);
        checkDescriptor(asFactory);
       
        String implClassService = asService.getImplementation();
        String implClassFactory = asFactory.getImplementation();
       
        if (!implClassService.equals(implClassFactory)) {
            throw new IllegalArgumentException("The implementation classes must match (" +
                implClassService + "/" + implClassFactory + ")");
        }
       
        if (!asService.getDescriptorType().equals(DescriptorType.CLASS)) {
            throw new IllegalArgumentException("The getFactoryAsService descriptor must be of type CLASS");
        }
        if (!asFactory.getDescriptorType().equals(DescriptorType.PROVIDE_METHOD)) {
            throw new IllegalArgumentException("The getFactoryAsFactory descriptor must be of type PROVIDE_METHOD");
        }
       
        final SystemDescriptor<?> boundAsService = new SystemDescriptor<Object>(asService,
                requiresDeepCopy,
View Full Code Here

    }

    private boolean isSecureAnnotated(ValidationInformation info) {

        Descriptor d = info.getCandidate();

        Set<String> qualifiers = d.getQualifiers();
        if (qualifiers != null && qualifiers.size() != 0) {
            for (String s : qualifiers) {
                if (Secure.class.getCanonicalName().equals(s)) {
                    if (LOG.isLoggable(Level.FINE)) {
                        LOG.fine("The instance is annotated with \'Secure\': "
View Full Code Here

       
        Set<String> contracts = ReflectionHelper.getContractsFromClass(clazz, Contract.class);
        String name = ReflectionHelper.getName(clazz);
        String scope = ReflectionHelper.getScopeFromClass(clazz, PerLookup.class).getName();
        Set<String> qualifiers = ReflectionHelper.getQualifiersFromClass(clazz);
        DescriptorType type = DescriptorType.CLASS;
        if (Factory.class.isAssignableFrom(clazz)) {
            type = DescriptorType.PROVIDE_METHOD;
        }
       
        Boolean proxy = null;
View Full Code Here

            else {
                proxyForSameScope = Boolean.FALSE;
            }
        }
       
        DescriptorVisibility visibility = DescriptorVisibility.NORMAL;
        Visibility vi = constant.getClass().getAnnotation(Visibility.class);
        if (vi != null) {
            visibility = vi.value();
        }
       
View Full Code Here

TOP

Related Classes of org.glassfish.hk2.api.Descriptor

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.