idx
int64
0
165k
question
stringlengths
73
4.15k
target
stringlengths
5
918
len_question
int64
21
890
len_target
int64
3
255
149,900
private void addHandlerInitializerMethod ( ClassFile proxyClassType , ClassMethod staticConstructor ) throws Exception { ClassMethod classMethod = proxyClassType . addMethod ( AccessFlag . PRIVATE , INIT_MH_METHOD_NAME , BytecodeUtils . VOID_CLASS_DESCRIPTOR , LJAVA_LANG_OBJECT ) ; final CodeAttribute b = classMethod . getCodeAttribute ( ) ; b . aload ( 0 ) ; StaticMethodInformation methodInfo = new StaticMethodInformation ( INIT_MH_METHOD_NAME , new Class [ ] { Object . class } , void . class , classMethod . getClassFile ( ) . getName ( ) ) ; invokeMethodHandler ( classMethod , methodInfo , false , DEFAULT_METHOD_RESOLVER , staticConstructor ) ; b . checkcast ( MethodHandler . class ) ; b . putfield ( classMethod . getClassFile ( ) . getName ( ) , METHOD_HANDLER_FIELD_NAME , DescriptorUtils . makeDescriptor ( MethodHandler . class ) ) ; b . returnInstruction ( ) ; BeanLogger . LOG . createdMethodHandlerInitializerForDecoratorProxy ( getBeanType ( ) ) ; }
calls _initMH on the method handler and then stores the result in the methodHandler field as then new methodHandler
267
24
149,901
private static boolean isEqual ( Method m , Method a ) { if ( m . getName ( ) . equals ( a . getName ( ) ) && m . getParameterTypes ( ) . length == a . getParameterTypes ( ) . length && m . getReturnType ( ) . isAssignableFrom ( a . getReturnType ( ) ) ) { for ( int i = 0 ; i < m . getParameterTypes ( ) . length ; i ++ ) { if ( ! ( m . getParameterTypes ( ) [ i ] . isAssignableFrom ( a . getParameterTypes ( ) [ i ] ) ) ) { return false ; } } return true ; } return false ; }
m is more generic than a
148
6
149,902
protected CDI11Deployment createDeployment ( ServletContext context , CDI11Bootstrap bootstrap ) { ImmutableSet . Builder < Metadata < Extension >> extensionsBuilder = ImmutableSet . builder ( ) ; extensionsBuilder . addAll ( bootstrap . loadExtensions ( WeldResourceLoader . getClassLoader ( ) ) ) ; if ( isDevModeEnabled ) { extensionsBuilder . add ( new MetadataImpl < Extension > ( DevelopmentMode . getProbeExtension ( resourceLoader ) , "N/A" ) ) ; } final Iterable < Metadata < Extension > > extensions = extensionsBuilder . build ( ) ; final TypeDiscoveryConfiguration typeDiscoveryConfiguration = bootstrap . startExtensions ( extensions ) ; final EEModuleDescriptor eeModule = new EEModuleDescriptorImpl ( context . getContextPath ( ) , ModuleType . WEB ) ; final DiscoveryStrategy strategy = DiscoveryStrategyFactory . create ( resourceLoader , bootstrap , typeDiscoveryConfiguration . getKnownBeanDefiningAnnotations ( ) , Boolean . parseBoolean ( context . getInitParameter ( Jandex . DISABLE_JANDEX_DISCOVERY_STRATEGY ) ) ) ; if ( Jandex . isJandexAvailable ( resourceLoader ) ) { try { Class < ? extends BeanArchiveHandler > handlerClass = Reflections . loadClass ( resourceLoader , JANDEX_SERVLET_CONTEXT_BEAN_ARCHIVE_HANDLER ) ; strategy . registerHandler ( ( SecurityActions . newConstructorInstance ( handlerClass , new Class < ? > [ ] { ServletContext . class } , context ) ) ) ; } catch ( Exception e ) { throw CommonLogger . LOG . unableToInstantiate ( JANDEX_SERVLET_CONTEXT_BEAN_ARCHIVE_HANDLER , Arrays . toString ( new Object [ ] { context } ) , e ) ; } } else { strategy . registerHandler ( new ServletContextBeanArchiveHandler ( context ) ) ; } strategy . setScanner ( new WebAppBeanArchiveScanner ( resourceLoader , bootstrap , context ) ) ; Set < WeldBeanDeploymentArchive > beanDeploymentArchives = strategy . performDiscovery ( ) ; String isolation = context . getInitParameter ( CONTEXT_PARAM_ARCHIVE_ISOLATION ) ; if ( isolation == null || Boolean . valueOf ( isolation ) ) { CommonLogger . LOG . archiveIsolationEnabled ( ) ; } else { CommonLogger . LOG . archiveIsolationDisabled ( ) ; Set < WeldBeanDeploymentArchive > flatDeployment = new HashSet < WeldBeanDeploymentArchive > ( ) ; flatDeployment . add ( WeldBeanDeploymentArchive . merge ( bootstrap , beanDeploymentArchives ) ) ; beanDeploymentArchives = flatDeployment ; } for ( BeanDeploymentArchive archive : beanDeploymentArchives ) { archive . getServices ( ) . add ( EEModuleDescriptor . class , eeModule ) ; } CDI11Deployment deployment = new WeldDeployment ( resourceLoader , bootstrap , beanDeploymentArchives , extensions ) { @ Override protected WeldBeanDeploymentArchive createAdditionalBeanDeploymentArchive ( ) { WeldBeanDeploymentArchive archive = super . createAdditionalBeanDeploymentArchive ( ) ; archive . getServices ( ) . add ( EEModuleDescriptor . class , eeModule ) ; return archive ; } } ; if ( strategy . getClassFileServices ( ) != null ) { deployment . getServices ( ) . add ( ClassFileServices . class , strategy . getClassFileServices ( ) ) ; } return deployment ; }
Create servlet deployment .
813
5
149,903
protected Container findContainer ( ContainerContext ctx , StringBuilder dump ) { Container container = null ; // 1. Custom container class String containerClassName = ctx . getServletContext ( ) . getInitParameter ( Container . CONTEXT_PARAM_CONTAINER_CLASS ) ; if ( containerClassName != null ) { try { Class < Container > containerClass = Reflections . classForName ( resourceLoader , containerClassName ) ; container = SecurityActions . newInstance ( containerClass ) ; WeldServletLogger . LOG . containerDetectionSkipped ( containerClassName ) ; } catch ( Exception e ) { WeldServletLogger . LOG . unableToInstantiateCustomContainerClass ( containerClassName ) ; WeldServletLogger . LOG . catchingDebug ( e ) ; } } if ( container == null ) { // 2. Service providers Iterable < Container > extContainers = ServiceLoader . load ( Container . class , getClass ( ) . getClassLoader ( ) ) ; container = checkContainers ( ctx , dump , extContainers ) ; if ( container == null ) { // 3. Built-in containers in predefined order container = checkContainers ( ctx , dump , Arrays . asList ( TomcatContainer . INSTANCE , JettyContainer . INSTANCE , UndertowContainer . INSTANCE , GwtDevHostedModeContainer . INSTANCE ) ) ; } } return container ; }
Find container env .
303
4
149,904
private Resolvable createMetadataProvider ( Class < ? > rawType ) { Set < Type > types = Collections . < Type > singleton ( rawType ) ; return new ResolvableImpl ( rawType , types , declaringBean , qualifierInstances , delegate ) ; }
just as facade but we keep the qualifiers so that we can recognize Bean from
59
15
149,905
private boolean hasAbstractPackagePrivateSuperClassWithImplementation ( Class < ? > clazz , BridgeMethod bridgeMethod ) { Class < ? > superClass = clazz . getSuperclass ( ) ; while ( superClass != null ) { if ( Modifier . isAbstract ( superClass . getModifiers ( ) ) && Reflections . isPackagePrivate ( superClass . getModifiers ( ) ) ) { // if superclass is abstract, we need to dig deeper for ( Method method : superClass . getDeclaredMethods ( ) ) { if ( bridgeMethod . signature . matches ( method ) && method . getGenericReturnType ( ) . equals ( bridgeMethod . returnType ) && ! Reflections . isAbstract ( method ) ) { // this is the case we are after -> methods have same signature and the one in super class has actual implementation return true ; } } } superClass = superClass . getSuperclass ( ) ; } return false ; }
Returns true if super class of the parameter exists and is abstract and package private . In such case we want to omit such method .
199
26
149,906
protected void addSpecialMethods ( ClassFile proxyClassType , ClassMethod staticConstructor ) { try { // Add special methods for interceptors for ( Method method : LifecycleMixin . class . getMethods ( ) ) { BeanLogger . LOG . addingMethodToProxy ( method ) ; MethodInformation methodInfo = new RuntimeMethodInformation ( method ) ; createInterceptorBody ( proxyClassType . addMethod ( method ) , methodInfo , false , staticConstructor ) ; } Method getInstanceMethod = TargetInstanceProxy . class . getMethod ( "weld_getTargetInstance" ) ; Method getInstanceClassMethod = TargetInstanceProxy . class . getMethod ( "weld_getTargetClass" ) ; generateGetTargetInstanceBody ( proxyClassType . addMethod ( getInstanceMethod ) ) ; generateGetTargetClassBody ( proxyClassType . addMethod ( getInstanceClassMethod ) ) ; Method setMethodHandlerMethod = ProxyObject . class . getMethod ( "weld_setHandler" , MethodHandler . class ) ; generateSetMethodHandlerBody ( proxyClassType . addMethod ( setMethodHandlerMethod ) ) ; Method getMethodHandlerMethod = ProxyObject . class . getMethod ( "weld_getHandler" ) ; generateGetMethodHandlerBody ( proxyClassType . addMethod ( getMethodHandlerMethod ) ) ; } catch ( Exception e ) { throw new WeldException ( e ) ; } }
Adds methods requiring special implementations rather than just delegation .
295
10
149,907
public static void checkDelegateType ( Decorator < ? > decorator ) { Set < Type > types = new HierarchyDiscovery ( decorator . getDelegateType ( ) ) . getTypeClosure ( ) ; for ( Type decoratedType : decorator . getDecoratedTypes ( ) ) { if ( ! types . contains ( decoratedType ) ) { throw BeanLogger . LOG . delegateMustSupportEveryDecoratedType ( decoratedType , decorator ) ; } } }
Check whether the delegate type implements or extends all decorated types .
103
12
149,908
public static < T > void checkAbstractMethods ( Set < Type > decoratedTypes , EnhancedAnnotatedType < T > type , BeanManagerImpl beanManager ) { if ( decoratedTypes == null ) { decoratedTypes = new HashSet < Type > ( type . getInterfaceClosure ( ) ) ; decoratedTypes . remove ( Serializable . class ) ; } Set < MethodSignature > signatures = new HashSet < MethodSignature > ( ) ; for ( Type decoratedType : decoratedTypes ) { for ( EnhancedAnnotatedMethod < ? , ? > method : ClassTransformer . instance ( beanManager ) . getEnhancedAnnotatedType ( Reflections . getRawType ( decoratedType ) , beanManager . getId ( ) ) . getEnhancedMethods ( ) ) { signatures . add ( method . getSignature ( ) ) ; } } for ( EnhancedAnnotatedMethod < ? , ? > method : type . getEnhancedMethods ( ) ) { if ( Reflections . isAbstract ( ( ( AnnotatedMethod < ? > ) method ) . getJavaMember ( ) ) ) { MethodSignature methodSignature = method . getSignature ( ) ; if ( ! signatures . contains ( methodSignature ) ) { throw BeanLogger . LOG . abstractMethodMustMatchDecoratedType ( method , Formats . formatAsStackTraceElement ( method . getJavaMember ( ) ) ) ; } } } }
Check all abstract methods are declared by the decorated types .
297
11
149,909
public void checkSpecialization ( ) { if ( isSpecializing ( ) ) { boolean isNameDefined = getAnnotated ( ) . isAnnotationPresent ( Named . class ) ; String previousSpecializedBeanName = null ; for ( AbstractBean < ? , ? > specializedBean : getSpecializedBeans ( ) ) { String name = specializedBean . getName ( ) ; if ( previousSpecializedBeanName != null && name != null && ! previousSpecializedBeanName . equals ( specializedBean . getName ( ) ) ) { // there may be multiple beans specialized by this bean - make sure they all share the same name throw BeanLogger . LOG . beansWithDifferentBeanNamesCannotBeSpecialized ( previousSpecializedBeanName , specializedBean . getName ( ) , this ) ; } previousSpecializedBeanName = name ; if ( isNameDefined && name != null ) { throw BeanLogger . LOG . nameNotAllowedOnSpecialization ( getAnnotated ( ) , specializedBean . getAnnotated ( ) ) ; } // When a specializing bean extends the raw type of a generic superclass, types of the generic superclass are // added into types of the specializing bean because of assignability rules. However, ParameterizedTypes among // these types are NOT types of the specializing bean (that's the way java works) boolean rawInsteadOfGeneric = ( this instanceof AbstractClassBean < ? > && specializedBean . getBeanClass ( ) . getTypeParameters ( ) . length > 0 && ! ( ( ( AbstractClassBean < ? > ) this ) . getBeanClass ( ) . getGenericSuperclass ( ) instanceof ParameterizedType ) ) ; for ( Type specializedType : specializedBean . getTypes ( ) ) { if ( rawInsteadOfGeneric && specializedType instanceof ParameterizedType ) { throw BeanLogger . LOG . specializingBeanMissingSpecializedType ( this , specializedType , specializedBean ) ; } boolean contains = getTypes ( ) . contains ( specializedType ) ; if ( ! contains ) { for ( Type specializingType : getTypes ( ) ) { // In case 'type' is a ParameterizedType, two bean types equivalent in the CDI sense may not be // equal in the java sense. Therefore we have to use our own equality util. if ( TypeEqualitySpecializationUtils . areTheSame ( specializingType , specializedType ) ) { contains = true ; break ; } } } if ( ! contains ) { throw BeanLogger . LOG . specializingBeanMissingSpecializedType ( this , specializedType , specializedBean ) ; } } } } }
Validates specialization if this bean specializes another bean .
572
10
149,910
public void fireEvent ( Type eventType , Object event , Annotation ... qualifiers ) { final EventMetadata metadata = new EventMetadataImpl ( eventType , null , qualifiers ) ; notifier . fireEvent ( eventType , event , metadata , qualifiers ) ; }
Fire an event and notify observers that belong to this module .
55
12
149,911
@ SuppressWarnings ( "unchecked" ) public static < T > T getJlsDefaultValue ( Class < T > type ) { if ( ! type . isPrimitive ( ) ) { return null ; } return ( T ) JLS_PRIMITIVE_DEFAULT_VALUES . get ( type ) ; }
See also JLS8 4 . 12 . 5 Initial Values of Variables .
71
16
149,912
public void afterDeploymentValidation ( @ Observes @ Priority ( 1 ) AfterDeploymentValidation event , BeanManager beanManager ) { BeanManagerImpl manager = BeanManagerProxy . unwrap ( beanManager ) ; probe . init ( manager ) ; if ( isJMXSupportEnabled ( manager ) ) { try { MBeanServer mbs = ManagementFactory . getPlatformMBeanServer ( ) ; mbs . registerMBean ( new ProbeDynamicMBean ( jsonDataProvider , JsonDataProvider . class ) , constructProbeJsonDataMBeanName ( manager , probe ) ) ; } catch ( MalformedObjectNameException | InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e ) { event . addDeploymentProblem ( ProbeLogger . LOG . unableToRegisterMBean ( JsonDataProvider . class , manager . getContextId ( ) , e ) ) ; } } addContainerLifecycleEvent ( event , null , beanManager ) ; exportDataIfNeeded ( manager ) ; }
any possible bean invocations from other ADV observers
227
9
149,913
static boolean matchPath ( String [ ] tokenizedPattern , String [ ] strDirs , boolean isCaseSensitive ) { int patIdxStart = 0 ; int patIdxEnd = tokenizedPattern . length - 1 ; int strIdxStart = 0 ; int strIdxEnd = strDirs . length - 1 ; // up to first '**' while ( patIdxStart <= patIdxEnd && strIdxStart <= strIdxEnd ) { String patDir = tokenizedPattern [ patIdxStart ] ; if ( patDir . equals ( DEEP_TREE_MATCH ) ) { break ; } if ( ! match ( patDir , strDirs [ strIdxStart ] , isCaseSensitive ) ) { return false ; } patIdxStart ++ ; strIdxStart ++ ; } if ( strIdxStart > strIdxEnd ) { // String is exhausted for ( int i = patIdxStart ; i <= patIdxEnd ; i ++ ) { if ( ! tokenizedPattern [ i ] . equals ( DEEP_TREE_MATCH ) ) { return false ; } } return true ; } else { if ( patIdxStart > patIdxEnd ) { // String not exhausted, but pattern is. Failure. return false ; } } // up to last '**' while ( patIdxStart <= patIdxEnd && strIdxStart <= strIdxEnd ) { String patDir = tokenizedPattern [ patIdxEnd ] ; if ( patDir . equals ( DEEP_TREE_MATCH ) ) { break ; } if ( ! match ( patDir , strDirs [ strIdxEnd ] , isCaseSensitive ) ) { return false ; } patIdxEnd -- ; strIdxEnd -- ; } if ( strIdxStart > strIdxEnd ) { // String is exhausted for ( int i = patIdxStart ; i <= patIdxEnd ; i ++ ) { if ( ! tokenizedPattern [ i ] . equals ( DEEP_TREE_MATCH ) ) { return false ; } } return true ; } while ( patIdxStart != patIdxEnd && strIdxStart <= strIdxEnd ) { int patIdxTmp = - 1 ; for ( int i = patIdxStart + 1 ; i <= patIdxEnd ; i ++ ) { if ( tokenizedPattern [ i ] . equals ( DEEP_TREE_MATCH ) ) { patIdxTmp = i ; break ; } } if ( patIdxTmp == patIdxStart + 1 ) { // '**/**' situation, so skip one patIdxStart ++ ; continue ; } // Find the pattern between padIdxStart & padIdxTmp in str between // strIdxStart & strIdxEnd int patLength = ( patIdxTmp - patIdxStart - 1 ) ; int strLength = ( strIdxEnd - strIdxStart + 1 ) ; int foundIdx = - 1 ; strLoop : for ( int i = 0 ; i <= strLength - patLength ; i ++ ) { for ( int j = 0 ; j < patLength ; j ++ ) { String subPat = tokenizedPattern [ patIdxStart + j + 1 ] ; String subStr = strDirs [ strIdxStart + i + j ] ; if ( ! match ( subPat , subStr , isCaseSensitive ) ) { continue strLoop ; } } foundIdx = strIdxStart + i ; break ; } if ( foundIdx == - 1 ) { return false ; } patIdxStart = patIdxTmp ; strIdxStart = foundIdx + patLength ; } for ( int i = patIdxStart ; i <= patIdxEnd ; i ++ ) { if ( ! tokenizedPattern [ i ] . equals ( DEEP_TREE_MATCH ) ) { return false ; } } return true ; }
Core implementation of matchPath . It is isolated so that it can be called from TokenizedPattern .
856
20
149,914
static String [ ] tokenize ( String str ) { char sep = ' ' ; int start = 0 ; int len = str . length ( ) ; int count = 0 ; for ( int pos = 0 ; pos < len ; pos ++ ) { if ( str . charAt ( pos ) == sep ) { if ( pos != start ) { count ++ ; } start = pos + 1 ; } } if ( len != start ) { count ++ ; } String [ ] l = new String [ count ] ; count = 0 ; start = 0 ; for ( int pos = 0 ; pos < len ; pos ++ ) { if ( str . charAt ( pos ) == sep ) { if ( pos != start ) { String tok = str . substring ( start , pos ) ; l [ count ++ ] = tok ; } start = pos + 1 ; } } if ( len != start ) { String tok = str . substring ( start ) ; l [ count /* ++ */ ] = tok ; } return l ; }
Tokenize the the string as a package hierarchy
215
9
149,915
void endIfStarted ( CodeAttribute b , ClassMethod method ) { b . aload ( getLocalVariableIndex ( 0 ) ) ; b . dup ( ) ; final BranchEnd ifnotnull = b . ifnull ( ) ; b . checkcast ( Stack . class ) ; b . invokevirtual ( Stack . class . getName ( ) , END_INTERCEPTOR_CONTEXT_METHOD_NAME , EMPTY_PARENTHESES + VOID_CLASS_DESCRIPTOR ) ; BranchEnd ifnull = b . gotoInstruction ( ) ; b . branchEnd ( ifnotnull ) ; b . pop ( ) ; // remove null Stack b . branchEnd ( ifnull ) ; }
Ends interception context if it was previously stated . This is indicated by a local variable with index 0 .
148
21
149,916
@ Override @ SuppressFBWarnings ( value = "UL_UNRELEASED_LOCK" , justification = "False positive from FindBugs" ) public < T > T get ( Contextual < T > contextual , CreationalContext < T > creationalContext ) { if ( ! isActive ( ) ) { throw new ContextNotActiveException ( ) ; } checkContextInitialized ( ) ; final BeanStore beanStore = getBeanStore ( ) ; if ( beanStore == null ) { return null ; } if ( contextual == null ) { throw ContextLogger . LOG . contextualIsNull ( ) ; } BeanIdentifier id = getId ( contextual ) ; ContextualInstance < T > beanInstance = beanStore . get ( id ) ; if ( beanInstance != null ) { return beanInstance . getInstance ( ) ; } else if ( creationalContext != null ) { LockedBean lock = null ; try { if ( multithreaded ) { lock = beanStore . lock ( id ) ; beanInstance = beanStore . get ( id ) ; if ( beanInstance != null ) { return beanInstance . getInstance ( ) ; } } T instance = contextual . create ( creationalContext ) ; if ( instance != null ) { beanInstance = new SerializableContextualInstanceImpl < Contextual < T > , T > ( contextual , instance , creationalContext , serviceRegistry . get ( ContextualStore . class ) ) ; beanStore . put ( id , beanInstance ) ; } return instance ; } finally { if ( lock != null ) { lock . unlock ( ) ; } } } else { return null ; } }
Get the bean if it exists in the contexts .
346
10
149,917
protected void destroy ( ) { ContextLogger . LOG . contextCleared ( this ) ; final BeanStore beanStore = getBeanStore ( ) ; if ( beanStore == null ) { throw ContextLogger . LOG . noBeanStoreAvailable ( this ) ; } for ( BeanIdentifier id : beanStore ) { destroyContextualInstance ( beanStore . get ( id ) ) ; } beanStore . clear ( ) ; }
Destroys the context
91
5
149,918
public static < T > boolean addAll ( Collection < T > target , Iterable < ? extends T > iterable ) { if ( iterable instanceof Collection ) { return target . addAll ( ( Collection < ? extends T > ) iterable ) ; } return Iterators . addAll ( target , iterable . iterator ( ) ) ; }
Add all elements in the iterable to the collection .
72
11
149,919
@ Override public < T > Producer < T > createProducer ( final Bean < X > declaringBean , final Bean < T > bean , DisposalMethod < X , T > disposalMethod ) { EnhancedAnnotatedField < T , X > enhancedField = getManager ( ) . getServices ( ) . get ( MemberTransformer . class ) . loadEnhancedMember ( field , getManager ( ) . getId ( ) ) ; return new ProducerFieldProducer < X , T > ( enhancedField , disposalMethod ) { @ Override public AnnotatedField < X > getAnnotated ( ) { return field ; } @ Override public BeanManagerImpl getBeanManager ( ) { return getManager ( ) ; } @ Override public Bean < X > getDeclaringBean ( ) { return declaringBean ; } @ Override public Bean < T > getBean ( ) { return bean ; } } ; }
Producers returned from this method are not validated . Internal use only .
197
14
149,920
protected WeldBeanDeploymentArchive createAdditionalBeanDeploymentArchive ( ) { WeldBeanDeploymentArchive additionalBda = new WeldBeanDeploymentArchive ( ADDITIONAL_BDA_ID , Collections . synchronizedSet ( new HashSet < String > ( ) ) , null ) ; additionalBda . getServices ( ) . addAll ( getServices ( ) . entrySet ( ) ) ; beanDeploymentArchives . add ( additionalBda ) ; setBeanDeploymentArchivesAccessibility ( ) ; return additionalBda ; }
Additional bean deployment archives are used for extentions synthetic annotated types and beans which do not come from a bean archive .
120
24
149,921
protected void setBeanDeploymentArchivesAccessibility ( ) { for ( WeldBeanDeploymentArchive beanDeploymentArchive : beanDeploymentArchives ) { Set < WeldBeanDeploymentArchive > accessibleArchives = new HashSet <> ( ) ; for ( WeldBeanDeploymentArchive candidate : beanDeploymentArchives ) { if ( candidate . equals ( beanDeploymentArchive ) ) { continue ; } accessibleArchives . add ( candidate ) ; } beanDeploymentArchive . setAccessibleBeanDeploymentArchives ( accessibleArchives ) ; } }
By default all bean archives see each other .
126
9
149,922
static Type parseType ( String value , ResourceLoader resourceLoader ) { value = value . trim ( ) ; // Wildcards if ( value . equals ( WILDCARD ) ) { return WildcardTypeImpl . defaultInstance ( ) ; } if ( value . startsWith ( WILDCARD_EXTENDS ) ) { Type upperBound = parseType ( value . substring ( WILDCARD_EXTENDS . length ( ) , value . length ( ) ) , resourceLoader ) ; if ( upperBound == null ) { return null ; } return WildcardTypeImpl . withUpperBound ( upperBound ) ; } if ( value . startsWith ( WILDCARD_SUPER ) ) { Type lowerBound = parseType ( value . substring ( WILDCARD_SUPER . length ( ) , value . length ( ) ) , resourceLoader ) ; if ( lowerBound == null ) { return null ; } return WildcardTypeImpl . withLowerBound ( lowerBound ) ; } // Array if ( value . contains ( ARRAY ) ) { Type componentType = parseType ( value . substring ( 0 , value . indexOf ( ARRAY ) ) , resourceLoader ) ; if ( componentType == null ) { return null ; } return new GenericArrayTypeImpl ( componentType ) ; } int chevLeft = value . indexOf ( CHEVRONS_LEFT ) ; String rawValue = chevLeft < 0 ? value : value . substring ( 0 , chevLeft ) ; Class < ? > rawRequiredType = tryLoadClass ( rawValue , resourceLoader ) ; if ( rawRequiredType == null ) { return null ; } if ( rawRequiredType . getTypeParameters ( ) . length == 0 ) { return rawRequiredType ; } // Parameterized type int chevRight = value . lastIndexOf ( CHEVRONS_RIGHT ) ; if ( chevRight < 0 ) { return null ; } List < String > parts = split ( value . substring ( chevLeft + 1 , chevRight ) , ' ' , CHEVRONS_LEFT . charAt ( 0 ) , CHEVRONS_RIGHT . charAt ( 0 ) ) ; Type [ ] typeParameters = new Type [ parts . size ( ) ] ; for ( int i = 0 ; i < typeParameters . length ; i ++ ) { Type typeParam = parseType ( parts . get ( i ) , resourceLoader ) ; if ( typeParam == null ) { return null ; } typeParameters [ i ] = typeParam ; } return new ParameterizedTypeImpl ( rawRequiredType , typeParameters ) ; }
Type variables are not supported .
559
6
149,923
public static boolean isPortletEnvSupported ( ) { if ( enabled == null ) { synchronized ( PortletSupport . class ) { if ( enabled == null ) { try { PortletSupport . class . getClassLoader ( ) . loadClass ( "javax.portlet.PortletContext" ) ; enabled = true ; } catch ( Throwable ignored ) { enabled = false ; } } } } return enabled ; }
Is portlet env supported .
90
6
149,924
public static BeanManager getBeanManager ( Object ctx ) { return ( BeanManager ) javax . portlet . PortletContext . class . cast ( ctx ) . getAttribute ( WeldServletLifecycle . BEAN_MANAGER_ATTRIBUTE_NAME ) ; }
Get bean manager from portlet context .
64
8
149,925
private < T > List < Class < ? > > filter ( List < Class < ? > > enabledClasses , List < Class < ? > > globallyEnabledClasses , LogMessageCallback logMessageCallback , BeanDeployment deployment ) { for ( Iterator < Class < ? > > iterator = enabledClasses . iterator ( ) ; iterator . hasNext ( ) ; ) { Class < ? > enabledClass = iterator . next ( ) ; if ( globallyEnabledClasses . contains ( enabledClass ) ) { logMessageCallback . log ( enabledClass , deployment . getBeanDeploymentArchive ( ) . getId ( ) ) ; iterator . remove ( ) ; } } return enabledClasses ; }
Filter out interceptors and decorators which are also enabled globally .
146
13
149,926
public F resolve ( R resolvable , boolean cache ) { R wrappedResolvable = wrap ( resolvable ) ; if ( cache ) { return resolved . getValue ( wrappedResolvable ) ; } else { return resolverFunction . apply ( wrappedResolvable ) ; } }
Get the possible beans for the given element
61
8
149,927
private Set < T > findMatching ( R resolvable ) { Set < T > result = new HashSet < T > ( ) ; for ( T bean : getAllBeans ( resolvable ) ) { if ( matches ( resolvable , bean ) ) { result . add ( bean ) ; } } return result ; }
Gets the matching beans for binding criteria from a list of beans
71
13
149,928
public < X > Set < DisposalMethod < X , ? > > resolveDisposalBeans ( Set < Type > types , Set < Annotation > qualifiers , AbstractClassBean < X > declaringBean ) { // We can always cache as this is only ever called by Weld where we avoid non-static inner classes for annotation literals Set < DisposalMethod < X , ? > > beans = cast ( disposalMethodResolver . resolve ( new ResolvableBuilder ( manager ) . addTypes ( types ) . addQualifiers ( qualifiers ) . setDeclaringBean ( declaringBean ) . create ( ) , true ) ) ; resolvedDisposalBeans . addAll ( beans ) ; return Collections . unmodifiableSet ( beans ) ; }
Resolve the disposal method for the given producer method . Any resolved beans will be marked as such for the purpose of validating that all disposal methods are used . For internal use .
158
36
149,929
private static < T > Set < Type > getSessionBeanTypes ( EnhancedAnnotated < T , ? > annotated , EjbDescriptor < T > ejbDescriptor ) { ImmutableSet . Builder < Type > types = ImmutableSet . builder ( ) ; // session beans Map < Class < ? > , Type > typeMap = new LinkedHashMap < Class < ? > , Type > ( ) ; HierarchyDiscovery beanClassDiscovery = HierarchyDiscovery . forNormalizedType ( ejbDescriptor . getBeanClass ( ) ) ; for ( BusinessInterfaceDescriptor < ? > businessInterfaceDescriptor : ejbDescriptor . getLocalBusinessInterfaces ( ) ) { // first we need to resolve the local interface Type resolvedLocalInterface = beanClassDiscovery . resolveType ( Types . getCanonicalType ( businessInterfaceDescriptor . getInterface ( ) ) ) ; SessionBeanHierarchyDiscovery interfaceDiscovery = new SessionBeanHierarchyDiscovery ( resolvedLocalInterface ) ; if ( beanClassDiscovery . getTypeMap ( ) . containsKey ( businessInterfaceDescriptor . getInterface ( ) ) ) { // WELD-1675 Only add types also included in Annotated.getTypeClosure() for ( Entry < Class < ? > , Type > entry : interfaceDiscovery . getTypeMap ( ) . entrySet ( ) ) { if ( annotated . getTypeClosure ( ) . contains ( entry . getValue ( ) ) ) { typeMap . put ( entry . getKey ( ) , entry . getValue ( ) ) ; } } } else { // Session bean class does not implement the business interface and @javax.ejb.Local applied to the session bean class typeMap . putAll ( interfaceDiscovery . getTypeMap ( ) ) ; } } if ( annotated . isAnnotationPresent ( Typed . class ) ) { types . addAll ( Beans . getTypedTypes ( typeMap , annotated . getJavaClass ( ) , annotated . getAnnotation ( Typed . class ) ) ) ; } else { typeMap . put ( Object . class , Object . class ) ; types . addAll ( typeMap . values ( ) ) ; } return Beans . getLegalBeanTypes ( types . build ( ) , annotated ) ; }
Bean types of a session bean .
507
8
149,930
public static < T > SessionBean < T > of ( BeanAttributes < T > attributes , InternalEjbDescriptor < T > ejbDescriptor , BeanManagerImpl beanManager , EnhancedAnnotatedType < T > type ) { return new SessionBeanImpl < T > ( attributes , type , ejbDescriptor , new StringBeanIdentifier ( SessionBeans . createIdentifier ( type , ejbDescriptor ) ) , beanManager ) ; }
Creates a simple annotation defined Enterprise Web Bean using the annotations specified on type
106
15
149,931
protected void checkConflictingRoles ( ) { if ( getType ( ) . isAnnotationPresent ( Interceptor . class ) ) { throw BeanLogger . LOG . ejbCannotBeInterceptor ( getType ( ) ) ; } if ( getType ( ) . isAnnotationPresent ( Decorator . class ) ) { throw BeanLogger . LOG . ejbCannotBeDecorator ( getType ( ) ) ; } }
Validates for non - conflicting roles
98
7
149,932
protected void checkScopeAllowed ( ) { if ( ejbDescriptor . isStateless ( ) && ! isDependent ( ) ) { throw BeanLogger . LOG . scopeNotAllowedOnStatelessSessionBean ( getScope ( ) , getType ( ) ) ; } if ( ejbDescriptor . isSingleton ( ) && ! ( isDependent ( ) || getScope ( ) . equals ( ApplicationScoped . class ) ) ) { throw BeanLogger . LOG . scopeNotAllowedOnSingletonBean ( getScope ( ) , getType ( ) ) ; } }
Check that the scope type is allowed by the stereotypes on the bean and the bean type
131
17
149,933
protected void checkObserverMethods ( ) { Collection < EnhancedAnnotatedMethod < ? , ? super T > > observerMethods = BeanMethods . getObserverMethods ( this . getEnhancedAnnotated ( ) ) ; Collection < EnhancedAnnotatedMethod < ? , ? super T > > asyncObserverMethods = BeanMethods . getAsyncObserverMethods ( this . getEnhancedAnnotated ( ) ) ; checkObserverMethods ( observerMethods ) ; checkObserverMethods ( asyncObserverMethods ) ; }
If there are any observer methods they must be static or business methods .
107
14
149,934
public static < T > NewManagedBean < T > of ( BeanAttributes < T > attributes , EnhancedAnnotatedType < T > clazz , BeanManagerImpl beanManager ) { return new NewManagedBean < T > ( attributes , clazz , new StringBeanIdentifier ( BeanIdentifiers . forNewManagedBean ( clazz ) ) , beanManager ) ; }
Creates an instance of a NewSimpleBean from an annotated class
84
15
149,935
@ Override public Object invoke ( Object self , Method method , Method proceed , Object [ ] args ) throws Throwable { if ( "destroy" . equals ( method . getName ( ) ) && Marker . isMarker ( 0 , method , args ) ) { if ( bean . getEjbDescriptor ( ) . isStateful ( ) ) { if ( ! reference . isRemoved ( ) ) { reference . remove ( ) ; } } return null ; } if ( ! bean . isClientCanCallRemoveMethods ( ) && isRemoveMethod ( method ) ) { throw BeanLogger . LOG . invalidRemoveMethodInvocation ( method ) ; } Class < ? > businessInterface = getBusinessInterface ( method ) ; if ( reference . isRemoved ( ) && isToStringMethod ( method ) ) { return businessInterface . getName ( ) + " [REMOVED]" ; } Object proxiedInstance = reference . getBusinessObject ( businessInterface ) ; if ( ! Modifier . isPublic ( method . getModifiers ( ) ) ) { throw new EJBException ( "Not a business method " + method . toString ( ) + ". Do not call non-public methods on EJB's." ) ; } Object returnValue = Reflections . invokeAndUnwrap ( proxiedInstance , method , args ) ; BeanLogger . LOG . callProxiedMethod ( method , proxiedInstance , args , returnValue ) ; return returnValue ; }
Looks up the EJB in the container and executes the method on it
308
14
149,936
private < T > void deferNotification ( T event , final EventMetadata metadata , final ObserverMethod < ? super T > observer , final List < DeferredEventNotification < ? > > notifications ) { TransactionPhase transactionPhase = observer . getTransactionPhase ( ) ; boolean before = transactionPhase . equals ( TransactionPhase . BEFORE_COMPLETION ) ; Status status = Status . valueOf ( transactionPhase ) ; notifications . add ( new DeferredEventNotification < T > ( contextId , event , metadata , observer , currentEventMetadata , status , before ) ) ; }
Defers an event for processing in a later phase of the current transaction .
120
15
149,937
public void build ( Set < Bean < ? > > beans ) { if ( isBuilt ( ) ) { throw new IllegalStateException ( "BeanIdentifier index is already built!" ) ; } if ( beans . isEmpty ( ) ) { index = new BeanIdentifier [ 0 ] ; reverseIndex = Collections . emptyMap ( ) ; indexHash = 0 ; indexBuilt . set ( true ) ; return ; } List < BeanIdentifier > tempIndex = new ArrayList < BeanIdentifier > ( beans . size ( ) ) ; for ( Bean < ? > bean : beans ) { if ( bean instanceof CommonBean < ? > ) { tempIndex . add ( ( ( CommonBean < ? > ) bean ) . getIdentifier ( ) ) ; } else if ( bean instanceof PassivationCapable ) { tempIndex . add ( new StringBeanIdentifier ( ( ( PassivationCapable ) bean ) . getId ( ) ) ) ; } } Collections . sort ( tempIndex , new Comparator < BeanIdentifier > ( ) { @ Override public int compare ( BeanIdentifier o1 , BeanIdentifier o2 ) { return o1 . asString ( ) . compareTo ( o2 . asString ( ) ) ; } } ) ; index = tempIndex . toArray ( new BeanIdentifier [ tempIndex . size ( ) ] ) ; ImmutableMap . Builder < BeanIdentifier , Integer > builder = ImmutableMap . builder ( ) ; for ( int i = 0 ; i < index . length ; i ++ ) { builder . put ( index [ i ] , i ) ; } reverseIndex = builder . build ( ) ; indexHash = Arrays . hashCode ( index ) ; if ( BootstrapLogger . LOG . isDebugEnabled ( ) ) { BootstrapLogger . LOG . beanIdentifierIndexBuilt ( getDebugInfo ( ) ) ; } indexBuilt . set ( true ) ; }
Note that the index can only be built once .
408
10
149,938
public static < T > FastEvent < T > of ( Class < T > type , BeanManagerImpl manager , ObserverNotifier notifier , Annotation ... qualifiers ) { ResolvedObservers < T > resolvedObserverMethods = notifier . < T > resolveObserverMethods ( type , qualifiers ) ; if ( resolvedObserverMethods . isMetadataRequired ( ) ) { EventMetadata metadata = new EventMetadataImpl ( type , null , qualifiers ) ; CurrentEventMetadata metadataService = manager . getServices ( ) . get ( CurrentEventMetadata . class ) ; return new FastEventWithMetadataPropagation < T > ( resolvedObserverMethods , metadata , metadataService ) ; } else { return new FastEvent < T > ( resolvedObserverMethods ) ; } }
Constructs a new FastEvent instance
165
7
149,939
public static < T > List < T > copyOf ( T [ ] elements ) { Preconditions . checkNotNull ( elements ) ; return ofInternal ( elements . clone ( ) ) ; }
Creates an immutable list that consists of the elements in the given array . A copy of the given array is used which means that any modifications to the given array will not affect the immutable list .
41
39
149,940
public static < T > List < T > copyOf ( Collection < T > source ) { Preconditions . checkNotNull ( source ) ; if ( source instanceof ImmutableList < ? > ) { return ( ImmutableList < T > ) source ; } if ( source . isEmpty ( ) ) { return Collections . emptyList ( ) ; } return ofInternal ( source . toArray ( ) ) ; }
Creates an immutable list that consists of the elements in the given collection . If the given collection is already an immutable list it is returned directly .
87
29
149,941
public static Set < Annotation > filterInterceptorBindings ( BeanManagerImpl beanManager , Collection < Annotation > annotations ) { Set < Annotation > interceptorBindings = new InterceptorBindingSet ( beanManager ) ; for ( Annotation annotation : annotations ) { if ( beanManager . isInterceptorBinding ( annotation . annotationType ( ) ) ) { interceptorBindings . add ( annotation ) ; } } return interceptorBindings ; }
Extracts a set of interceptor bindings from a collection of annotations .
96
15
149,942
public static Set < Annotation > flattenInterceptorBindings ( EnhancedAnnotatedType < ? > clazz , BeanManagerImpl beanManager , Collection < Annotation > annotations , boolean addTopLevelInterceptorBindings , boolean addInheritedInterceptorBindings ) { Set < Annotation > flattenInterceptorBindings = new InterceptorBindingSet ( beanManager ) ; MetaAnnotationStore metaAnnotationStore = beanManager . getServices ( ) . get ( MetaAnnotationStore . class ) ; if ( addTopLevelInterceptorBindings ) { addInterceptorBindings ( clazz , annotations , flattenInterceptorBindings , metaAnnotationStore ) ; } if ( addInheritedInterceptorBindings ) { for ( Annotation annotation : annotations ) { addInheritedInterceptorBindings ( clazz , annotation . annotationType ( ) , metaAnnotationStore , flattenInterceptorBindings ) ; } } return flattenInterceptorBindings ; }
Extracts a flat set of interception bindings from a given set of interceptor bindings .
208
18
149,943
protected void validateRIBean ( CommonBean < ? > bean , BeanManagerImpl beanManager , Collection < CommonBean < ? > > specializedBeans ) { validateGeneralBean ( bean , beanManager ) ; if ( bean instanceof NewBean ) { return ; } if ( bean instanceof DecorableBean ) { validateDecorators ( beanManager , ( DecorableBean < ? > ) bean ) ; } if ( ( bean instanceof AbstractClassBean < ? > ) ) { AbstractClassBean < ? > classBean = ( AbstractClassBean < ? > ) bean ; // validate CDI-defined interceptors if ( classBean . hasInterceptors ( ) ) { validateInterceptors ( beanManager , classBean ) ; } } // for each producer bean validate its disposer method if ( bean instanceof AbstractProducerBean < ? , ? , ? > ) { AbstractProducerBean < ? , ? , ? > producerBean = Reflections . < AbstractProducerBean < ? , ? , ? > > cast ( bean ) ; if ( producerBean . getProducer ( ) instanceof AbstractMemberProducer < ? , ? > ) { AbstractMemberProducer < ? , ? > producer = Reflections . < AbstractMemberProducer < ? , ? > > cast ( producerBean . getProducer ( ) ) ; if ( producer . getDisposalMethod ( ) != null ) { for ( InjectionPoint ip : producer . getDisposalMethod ( ) . getInjectionPoints ( ) ) { // pass the producer bean instead of the disposal method bean validateInjectionPointForDefinitionErrors ( ip , null , beanManager ) ; validateMetadataInjectionPoint ( ip , null , ValidatorLogger . INJECTION_INTO_DISPOSER_METHOD ) ; validateEventMetadataInjectionPoint ( ip ) ; validateInjectionPointForDeploymentProblems ( ip , null , beanManager ) ; } } } } }
Validate an RIBean . This includes validating whether two beans specialize the same bean
425
18
149,944
public void validateInjectionPoint ( InjectionPoint ij , BeanManagerImpl beanManager ) { validateInjectionPointForDefinitionErrors ( ij , ij . getBean ( ) , beanManager ) ; validateMetadataInjectionPoint ( ij , ij . getBean ( ) , ValidatorLogger . INJECTION_INTO_NON_BEAN ) ; validateEventMetadataInjectionPoint ( ij ) ; validateInjectionPointForDeploymentProblems ( ij , ij . getBean ( ) , beanManager ) ; }
Validate an injection point
122
5
149,945
private static void validatePseudoScopedBean ( Bean < ? > bean , BeanManagerImpl beanManager ) { if ( bean . getInjectionPoints ( ) . isEmpty ( ) ) { // Skip validation if there are no injection points (e.g. for classes which are not intended to be used as beans) return ; } reallyValidatePseudoScopedBean ( bean , beanManager , new LinkedHashSet < Object > ( ) , new HashSet < Bean < ? > > ( ) ) ; }
Checks to make sure that pseudo scoped beans ( i . e .
112
15
149,946
private static void reallyValidatePseudoScopedBean ( Bean < ? > bean , BeanManagerImpl beanManager , Set < Object > dependencyPath , Set < Bean < ? > > validatedBeans ) { // see if we have already seen this bean in the dependency path if ( dependencyPath . contains ( bean ) ) { // create a list that shows the path to the bean List < Object > realDependencyPath = new ArrayList < Object > ( dependencyPath ) ; realDependencyPath . add ( bean ) ; throw ValidatorLogger . LOG . pseudoScopedBeanHasCircularReferences ( WeldCollections . toMultiRowString ( realDependencyPath ) ) ; } if ( validatedBeans . contains ( bean ) ) { return ; } dependencyPath . add ( bean ) ; for ( InjectionPoint injectionPoint : bean . getInjectionPoints ( ) ) { if ( ! injectionPoint . isDelegate ( ) ) { dependencyPath . add ( injectionPoint ) ; validatePseudoScopedInjectionPoint ( injectionPoint , beanManager , dependencyPath , validatedBeans ) ; dependencyPath . remove ( injectionPoint ) ; } } if ( bean instanceof DecorableBean < ? > ) { final List < Decorator < ? > > decorators = Reflections . < DecorableBean < ? > > cast ( bean ) . getDecorators ( ) ; if ( ! decorators . isEmpty ( ) ) { for ( final Decorator < ? > decorator : decorators ) { reallyValidatePseudoScopedBean ( decorator , beanManager , dependencyPath , validatedBeans ) ; } } } if ( bean instanceof AbstractProducerBean < ? , ? , ? > && ! ( bean instanceof EEResourceProducerField < ? , ? > ) ) { AbstractProducerBean < ? , ? , ? > producer = ( AbstractProducerBean < ? , ? , ? > ) bean ; if ( ! beanManager . isNormalScope ( producer . getDeclaringBean ( ) . getScope ( ) ) && ! producer . getAnnotated ( ) . isStatic ( ) ) { reallyValidatePseudoScopedBean ( producer . getDeclaringBean ( ) , beanManager , dependencyPath , validatedBeans ) ; } } validatedBeans . add ( bean ) ; dependencyPath . remove ( bean ) ; }
checks if a bean has been seen before in the dependencyPath . If not it resolves the InjectionPoints and adds the resolved beans to the set of beans to be validated
515
34
149,947
public static InterceptionContext forConstructorInterception ( InterceptionModel interceptionModel , CreationalContext < ? > ctx , BeanManagerImpl manager , SlimAnnotatedType < ? > type ) { return of ( interceptionModel , ctx , manager , null , type ) ; }
The context returned by this method may be later reused for other interception types .
59
15
149,948
private Set < QualifierInstance > getRequiredQualifiers ( EnhancedAnnotatedParameter < ? , ? super X > enhancedDisposedParameter ) { Set < Annotation > disposedParameterQualifiers = enhancedDisposedParameter . getMetaAnnotations ( Qualifier . class ) ; if ( disposedParameterQualifiers . isEmpty ( ) ) { disposedParameterQualifiers = Collections . < Annotation > singleton ( Default . Literal . INSTANCE ) ; } return beanManager . getServices ( ) . get ( MetaAnnotationStore . class ) . getQualifierInstances ( disposedParameterQualifiers ) ; }
A disposer method is bound to a producer if the producer is assignable to the disposed parameter .
125
20
149,949
public static Type [ ] getActualTypeArguments ( Class < ? > clazz ) { Type type = Types . getCanonicalType ( clazz ) ; if ( type instanceof ParameterizedType ) { return ( ( ParameterizedType ) type ) . getActualTypeArguments ( ) ; } else { return EMPTY_TYPES ; } }
Gets the actual type arguments of a class
79
9
149,950
public static Type [ ] getActualTypeArguments ( Type type ) { Type resolvedType = Types . getCanonicalType ( type ) ; if ( resolvedType instanceof ParameterizedType ) { return ( ( ParameterizedType ) resolvedType ) . getActualTypeArguments ( ) ; } else { return EMPTY_TYPES ; } }
Gets the actual type arguments of a Type
77
9
149,951
public static < T > Class < T > loadClass ( String className , ResourceLoader resourceLoader ) { try { return cast ( resourceLoader . classForName ( className ) ) ; } catch ( ResourceLoadingException e ) { return null ; } catch ( SecurityException e ) { return null ; } }
Tries to load a class using the specified ResourceLoader . Returns null if the class is not found .
64
21
149,952
public static Method findDeclaredMethodByName ( Class < ? > clazz , String methodName ) { for ( Method method : AccessController . doPrivileged ( new GetDeclaredMethodsAction ( clazz ) ) ) { if ( methodName . equals ( method . getName ( ) ) ) { return method ; } } return null ; }
Searches for a declared method with a given name . If the class declares multiple methods with the given name there is no guarantee as of which methods is returned . Null is returned if the class does not declare a method with the given name .
72
49
149,953
public static void main ( String [ ] args ) { try { new StartMain ( args ) . go ( ) ; } catch ( Throwable t ) { WeldSELogger . LOG . error ( "Application exited with an exception" , t ) ; System . exit ( 1 ) ; } }
The main method called from the command line .
62
9
149,954
public void release ( Contextual < T > contextual , T instance ) { synchronized ( dependentInstances ) { for ( ContextualInstance < ? > dependentInstance : dependentInstances ) { // do not destroy contextual again, since it's just being destroyed if ( contextual == null || ! ( dependentInstance . getContextual ( ) . equals ( contextual ) ) ) { destroy ( dependentInstance ) ; } } } if ( resourceReferences != null ) { for ( ResourceReference < ? > reference : resourceReferences ) { reference . release ( ) ; } } }
should not be public
114
4
149,955
public boolean destroyDependentInstance ( T instance ) { synchronized ( dependentInstances ) { for ( Iterator < ContextualInstance < ? > > iterator = dependentInstances . iterator ( ) ; iterator . hasNext ( ) ; ) { ContextualInstance < ? > contextualInstance = iterator . next ( ) ; if ( contextualInstance . getInstance ( ) == instance ) { iterator . remove ( ) ; destroy ( contextualInstance ) ; return true ; } } } return false ; }
Destroys dependent instance
99
5
149,956
protected T checkReturnValue ( T instance ) { if ( instance == null && ! isDependent ( ) ) { throw BeanLogger . LOG . nullNotAllowedFromProducer ( getProducer ( ) , Formats . formatAsStackTraceElement ( getAnnotated ( ) . getJavaMember ( ) ) ) ; } if ( instance == null ) { InjectionPoint injectionPoint = beanManager . getServices ( ) . get ( CurrentInjectionPoint . class ) . peek ( ) ; if ( injectionPoint != null ) { Class < ? > injectionPointRawType = Reflections . getRawType ( injectionPoint . getType ( ) ) ; if ( injectionPointRawType . isPrimitive ( ) ) { return cast ( Defaults . getJlsDefaultValue ( injectionPointRawType ) ) ; } } } if ( instance != null && ! ( instance instanceof Serializable ) ) { if ( beanManager . isPassivatingScope ( getScope ( ) ) ) { throw BeanLogger . LOG . nonSerializableProductError ( getProducer ( ) , Formats . formatAsStackTraceElement ( getAnnotated ( ) . getJavaMember ( ) ) ) ; } InjectionPoint injectionPoint = beanManager . getServices ( ) . get ( CurrentInjectionPoint . class ) . peek ( ) ; if ( injectionPoint != null && injectionPoint . getBean ( ) != null && Beans . isPassivatingScope ( injectionPoint . getBean ( ) , beanManager ) ) { // Transient field is passivation capable injection point if ( ! ( injectionPoint . getMember ( ) instanceof Field ) || ! injectionPoint . isTransient ( ) ) { throw BeanLogger . LOG . unserializableProductInjectionError ( this , Formats . formatAsStackTraceElement ( getAnnotated ( ) . getJavaMember ( ) ) , injectionPoint , Formats . formatAsStackTraceElement ( injectionPoint . getMember ( ) ) ) ; } } } return instance ; }
Validates the return value
428
5
149,957
public static < K , V > Map < K , V > copyOf ( Map < K , V > map ) { Preconditions . checkNotNull ( map ) ; return ImmutableMap . < K , V > builder ( ) . putAll ( map ) . build ( ) ; }
Creates an immutable map . A copy of the given map is used . As a result it is safe to modify the source map afterwards .
61
28
149,958
public static < K , V > Map < K , V > of ( K key , V value ) { return new ImmutableMapEntry < K , V > ( key , value ) ; }
Creates an immutable singleton instance .
40
8
149,959
public static String formatAsStackTraceElement ( InjectionPoint ij ) { Member member ; if ( ij . getAnnotated ( ) instanceof AnnotatedField ) { AnnotatedField < ? > annotatedField = ( AnnotatedField < ? > ) ij . getAnnotated ( ) ; member = annotatedField . getJavaMember ( ) ; } else if ( ij . getAnnotated ( ) instanceof AnnotatedParameter < ? > ) { AnnotatedParameter < ? > annotatedParameter = ( AnnotatedParameter < ? > ) ij . getAnnotated ( ) ; member = annotatedParameter . getDeclaringCallable ( ) . getJavaMember ( ) ; } else { // Not throwing an exception, because this method is invoked when an exception is already being thrown. // Throwing an exception here would hide the original exception. return "-" ; } return formatAsStackTraceElement ( member ) ; }
See also WELD - 1454 .
206
8
149,960
public static int getLineNumber ( Member member ) { if ( ! ( member instanceof Method || member instanceof Constructor ) ) { // We are not able to get this info for fields return 0 ; } // BCEL is an optional dependency, if we cannot load it, simply return 0 if ( ! Reflections . isClassLoadable ( BCEL_CLASS , WeldClassLoaderResourceLoader . INSTANCE ) ) { return 0 ; } String classFile = member . getDeclaringClass ( ) . getName ( ) . replace ( ' ' , ' ' ) ; ClassLoaderResourceLoader classFileResourceLoader = new ClassLoaderResourceLoader ( member . getDeclaringClass ( ) . getClassLoader ( ) ) ; InputStream in = null ; try { URL classFileUrl = classFileResourceLoader . getResource ( classFile + ".class" ) ; if ( classFileUrl == null ) { // The class file is not available return 0 ; } in = classFileUrl . openStream ( ) ; ClassParser cp = new ClassParser ( in , classFile ) ; JavaClass javaClass = cp . parse ( ) ; // First get all declared methods and constructors // Note that in bytecode constructor is translated into a method org . apache . bcel . classfile . Method [ ] methods = javaClass . getMethods ( ) ; org . apache . bcel . classfile . Method match = null ; String signature ; String name ; if ( member instanceof Method ) { signature = DescriptorUtils . methodDescriptor ( ( Method ) member ) ; name = member . getName ( ) ; } else if ( member instanceof Constructor ) { signature = DescriptorUtils . makeDescriptor ( ( Constructor < ? > ) member ) ; name = INIT_METHOD_NAME ; } else { return 0 ; } for ( org . apache . bcel . classfile . Method method : methods ) { // Matching method must have the same name, modifiers and signature if ( method . getName ( ) . equals ( name ) && member . getModifiers ( ) == method . getModifiers ( ) && method . getSignature ( ) . equals ( signature ) ) { match = method ; } } if ( match != null ) { // If a method is found, try to obtain the optional LineNumberTable attribute LineNumberTable lineNumberTable = match . getLineNumberTable ( ) ; if ( lineNumberTable != null ) { int line = lineNumberTable . getSourceLine ( 0 ) ; return line == - 1 ? 0 : line ; } } // No suitable method found return 0 ; } catch ( Throwable t ) { return 0 ; } finally { if ( in != null ) { try { in . close ( ) ; } catch ( Exception e ) { return 0 ; } } } }
Try to get the line number associated with the given member .
594
12
149,961
private static List < String > parseModifiers ( int modifiers ) { List < String > result = new ArrayList < String > ( ) ; if ( Modifier . isPrivate ( modifiers ) ) { result . add ( "private" ) ; } if ( Modifier . isProtected ( modifiers ) ) { result . add ( "protected" ) ; } if ( Modifier . isPublic ( modifiers ) ) { result . add ( "public" ) ; } if ( Modifier . isAbstract ( modifiers ) ) { result . add ( "abstract" ) ; } if ( Modifier . isFinal ( modifiers ) ) { result . add ( "final" ) ; } if ( Modifier . isNative ( modifiers ) ) { result . add ( "native" ) ; } if ( Modifier . isStatic ( modifiers ) ) { result . add ( "static" ) ; } if ( Modifier . isStrict ( modifiers ) ) { result . add ( "strict" ) ; } if ( Modifier . isSynchronized ( modifiers ) ) { result . add ( "synchronized" ) ; } if ( Modifier . isTransient ( modifiers ) ) { result . add ( "transient" ) ; } if ( Modifier . isVolatile ( modifiers ) ) { result . add ( "volatile" ) ; } if ( Modifier . isInterface ( modifiers ) ) { result . add ( "interface" ) ; } return result ; }
Parses a reflection modifier to a list of string
309
11
149,962
private boolean initCheckTypeModifiers ( ) { Class < ? > classInfoclass = Reflections . loadClass ( CLASSINFO_CLASS_NAME , new ClassLoaderResourceLoader ( classFileServices . getClass ( ) . getClassLoader ( ) ) ) ; if ( classInfoclass != null ) { try { Method setFlags = AccessController . doPrivileged ( GetDeclaredMethodAction . of ( classInfoclass , "setFlags" , short . class ) ) ; return setFlags != null ; } catch ( Exception exceptionIgnored ) { BootstrapLogger . LOG . usingOldJandexVersion ( ) ; return false ; } } else { return true ; } }
checking availability of ClassInfo . setFlags method is just workaround for JANDEX - 37
145
18
149,963
public static < X , T > ProducerMethod < X , T > of ( BeanAttributes < T > attributes , EnhancedAnnotatedMethod < T , ? super X > method , AbstractClassBean < X > declaringBean , DisposalMethod < X , ? > disposalMethod , BeanManagerImpl beanManager , ServiceRegistry services ) { return new ProducerMethod < X , T > ( createId ( attributes , method , declaringBean ) , attributes , method , declaringBean , disposalMethod , beanManager , services ) ; }
Creates a producer method Web Bean
111
7
149,964
public static void addLoadInstruction ( CodeAttribute code , String type , int variable ) { char tp = type . charAt ( 0 ) ; if ( tp != ' ' && tp != ' ' ) { // we have a primitive type switch ( tp ) { case ' ' : code . lload ( variable ) ; break ; case ' ' : code . dload ( variable ) ; break ; case ' ' : code . fload ( variable ) ; break ; default : code . iload ( variable ) ; } } else { code . aload ( variable ) ; } }
Adds the correct load instruction based on the type descriptor
124
10
149,965
public static void pushClassType ( CodeAttribute b , String classType ) { if ( classType . length ( ) != 1 ) { if ( classType . startsWith ( "L" ) && classType . endsWith ( ";" ) ) { classType = classType . substring ( 1 , classType . length ( ) - 1 ) ; } b . loadClass ( classType ) ; } else { char type = classType . charAt ( 0 ) ; switch ( type ) { case ' ' : b . getstatic ( Integer . class . getName ( ) , TYPE , LJAVA_LANG_CLASS ) ; break ; case ' ' : b . getstatic ( Long . class . getName ( ) , TYPE , LJAVA_LANG_CLASS ) ; break ; case ' ' : b . getstatic ( Short . class . getName ( ) , TYPE , LJAVA_LANG_CLASS ) ; break ; case ' ' : b . getstatic ( Float . class . getName ( ) , TYPE , LJAVA_LANG_CLASS ) ; break ; case ' ' : b . getstatic ( Double . class . getName ( ) , TYPE , LJAVA_LANG_CLASS ) ; break ; case ' ' : b . getstatic ( Byte . class . getName ( ) , TYPE , LJAVA_LANG_CLASS ) ; break ; case ' ' : b . getstatic ( Character . class . getName ( ) , TYPE , LJAVA_LANG_CLASS ) ; break ; case ' ' : b . getstatic ( Boolean . class . getName ( ) , TYPE , LJAVA_LANG_CLASS ) ; break ; default : throw new RuntimeException ( "Cannot handle primitive type: " + type ) ; } } }
Pushes a class type onto the stack from the string representation This can also handle primitives
389
18
149,966
private void checkBindings ( EnhancedAnnotation < T > annotatedAnnotation ) { Set < Annotation > bindings = annotatedAnnotation . getMetaAnnotations ( Qualifier . class ) ; if ( bindings . size ( ) > 0 ) { for ( Annotation annotation : bindings ) { if ( ! annotation . annotationType ( ) . equals ( Named . class ) ) { throw MetadataLogger . LOG . qualifierOnStereotype ( annotatedAnnotation ) ; } } } }
Validates the binding types
103
5
149,967
private void initBeanNameDefaulted ( EnhancedAnnotation < T > annotatedAnnotation ) { if ( annotatedAnnotation . isAnnotationPresent ( Named . class ) ) { if ( ! "" . equals ( annotatedAnnotation . getAnnotation ( Named . class ) . value ( ) ) ) { throw MetadataLogger . LOG . valueOnNamedStereotype ( annotatedAnnotation ) ; } beanNameDefaulted = true ; } }
Initializes the bean name defaulted
98
7
149,968
private void initDefaultScopeType ( EnhancedAnnotation < T > annotatedAnnotation ) { Set < Annotation > scopeTypes = new HashSet < Annotation > ( ) ; scopeTypes . addAll ( annotatedAnnotation . getMetaAnnotations ( Scope . class ) ) ; scopeTypes . addAll ( annotatedAnnotation . getMetaAnnotations ( NormalScope . class ) ) ; if ( scopeTypes . size ( ) > 1 ) { throw MetadataLogger . LOG . multipleScopes ( annotatedAnnotation ) ; } else if ( scopeTypes . size ( ) == 1 ) { this . defaultScopeType = scopeTypes . iterator ( ) . next ( ) ; } }
Initializes the default scope type
145
6
149,969
public static Type boxedType ( Type type ) { if ( type instanceof Class < ? > ) { return boxedClass ( ( Class < ? > ) type ) ; } else { return type ; } }
Gets the boxed type of a class
42
8
149,970
public static Type getCanonicalType ( Class < ? > clazz ) { if ( clazz . isArray ( ) ) { Class < ? > componentType = clazz . getComponentType ( ) ; Type resolvedComponentType = getCanonicalType ( componentType ) ; if ( componentType != resolvedComponentType ) { // identity check intentional // a different identity means that we actually replaced the component Class with a ParameterizedType return new GenericArrayTypeImpl ( resolvedComponentType ) ; } } if ( clazz . getTypeParameters ( ) . length > 0 ) { Type [ ] actualTypeParameters = clazz . getTypeParameters ( ) ; return new ParameterizedTypeImpl ( clazz , actualTypeParameters , clazz . getDeclaringClass ( ) ) ; } return clazz ; }
Returns a canonical type for a given class .
169
9
149,971
public static boolean isArray ( Type type ) { return ( type instanceof GenericArrayType ) || ( type instanceof Class < ? > && ( ( Class < ? > ) type ) . isArray ( ) ) ; }
Determines whether the given type is an array type .
46
12
149,972
public static Type getArrayComponentType ( Type type ) { if ( type instanceof GenericArrayType ) { return GenericArrayType . class . cast ( type ) . getGenericComponentType ( ) ; } if ( type instanceof Class < ? > ) { Class < ? > clazz = ( Class < ? > ) type ; if ( clazz . isArray ( ) ) { return clazz . getComponentType ( ) ; } } throw new IllegalArgumentException ( "Not an array type " + type ) ; }
Determines the component type for a given array type .
109
12
149,973
public static boolean isArrayOfUnboundedTypeVariablesOrObjects ( Type [ ] types ) { for ( Type type : types ) { if ( Object . class . equals ( type ) ) { continue ; } if ( type instanceof TypeVariable < ? > ) { Type [ ] bounds = ( ( TypeVariable < ? > ) type ) . getBounds ( ) ; if ( bounds == null || bounds . length == 0 || ( bounds . length == 1 && Object . class . equals ( bounds [ 0 ] ) ) ) { continue ; } } return false ; } return true ; }
Determines whether the given array only contains unbounded type variables or Object . class .
124
18
149,974
public < T > T get ( Contextual < T > contextual , CreationalContext < T > creationalContext ) { if ( ! isActive ( ) ) { throw new ContextNotActiveException ( ) ; } if ( creationalContext != null ) { T instance = contextual . create ( creationalContext ) ; if ( creationalContext instanceof WeldCreationalContext < ? > ) { addDependentInstance ( instance , contextual , ( WeldCreationalContext < T > ) creationalContext ) ; } return instance ; } else { return null ; } }
Overridden method always creating a new instance
116
8
149,975
public void createEnablement ( ) { GlobalEnablementBuilder builder = beanManager . getServices ( ) . get ( GlobalEnablementBuilder . class ) ; ModuleEnablement enablement = builder . createModuleEnablement ( this ) ; beanManager . setEnabled ( enablement ) ; if ( BootstrapLogger . LOG . isDebugEnabled ( ) ) { BootstrapLogger . LOG . enabledAlternatives ( this . beanManager , WeldCollections . toMultiRowString ( enablement . getAllAlternatives ( ) ) ) ; BootstrapLogger . LOG . enabledDecorators ( this . beanManager , WeldCollections . toMultiRowString ( enablement . getDecorators ( ) ) ) ; BootstrapLogger . LOG . enabledInterceptors ( this . beanManager , WeldCollections . toMultiRowString ( enablement . getInterceptors ( ) ) ) ; } }
Initializes module enablement .
189
6
149,976
public static < T > DecoratorImpl < T > of ( BeanAttributes < T > attributes , EnhancedAnnotatedType < T > clazz , BeanManagerImpl beanManager ) { return new DecoratorImpl < T > ( attributes , clazz , beanManager ) ; }
Creates a decorator bean
59
6
149,977
protected void merge ( Set < Annotation > stereotypeAnnotations ) { final MetaAnnotationStore store = manager . getServices ( ) . get ( MetaAnnotationStore . class ) ; for ( Annotation stereotypeAnnotation : stereotypeAnnotations ) { // Retrieve and merge all metadata from stereotypes StereotypeModel < ? > stereotype = store . getStereotype ( stereotypeAnnotation . annotationType ( ) ) ; if ( stereotype == null ) { throw MetadataLogger . LOG . stereotypeNotRegistered ( stereotypeAnnotation ) ; } if ( stereotype . isAlternative ( ) ) { alternative = true ; } if ( stereotype . getDefaultScopeType ( ) != null ) { possibleScopeTypes . add ( stereotype . getDefaultScopeType ( ) ) ; } if ( stereotype . isBeanNameDefaulted ( ) ) { beanNameDefaulted = true ; } this . stereotypes . add ( stereotypeAnnotation . annotationType ( ) ) ; // Merge in inherited stereotypes merge ( stereotype . getInheritedStereotypes ( ) ) ; } }
Perform the merge
217
4
149,978
@ Override public void run ( ) { try { threadContext . activate ( ) ; // run the original thread runnable . run ( ) ; } finally { threadContext . invalidate ( ) ; threadContext . deactivate ( ) ; } }
Set up the ThreadContext and delegate .
52
8
149,979
protected AbstractBeanDeployer < E > deploySpecialized ( ) { // ensure that all decorators are initialized before initializing // the rest of the beans for ( DecoratorImpl < ? > bean : getEnvironment ( ) . getDecorators ( ) ) { bean . initialize ( getEnvironment ( ) ) ; containerLifecycleEvents . fireProcessBean ( getManager ( ) , bean ) ; manager . addDecorator ( bean ) ; BootstrapLogger . LOG . foundDecorator ( bean ) ; } for ( InterceptorImpl < ? > bean : getEnvironment ( ) . getInterceptors ( ) ) { bean . initialize ( getEnvironment ( ) ) ; containerLifecycleEvents . fireProcessBean ( getManager ( ) , bean ) ; manager . addInterceptor ( bean ) ; BootstrapLogger . LOG . foundInterceptor ( bean ) ; } return this ; }
interceptors decorators and observers go first
191
9
149,980
public static void validateObserverMethod ( ObserverMethod < ? > observerMethod , BeanManager beanManager , ObserverMethod < ? > originalObserverMethod ) { Set < Annotation > qualifiers = observerMethod . getObservedQualifiers ( ) ; if ( observerMethod . getBeanClass ( ) == null ) { throw EventLogger . LOG . observerMethodsMethodReturnsNull ( "getBeanClass" , observerMethod ) ; } if ( observerMethod . getObservedType ( ) == null ) { throw EventLogger . LOG . observerMethodsMethodReturnsNull ( "getObservedType" , observerMethod ) ; } Bindings . validateQualifiers ( qualifiers , beanManager , observerMethod , "ObserverMethod.getObservedQualifiers" ) ; if ( observerMethod . getReception ( ) == null ) { throw EventLogger . LOG . observerMethodsMethodReturnsNull ( "getReception" , observerMethod ) ; } if ( observerMethod . getTransactionPhase ( ) == null ) { throw EventLogger . LOG . observerMethodsMethodReturnsNull ( "getTransactionPhase" , observerMethod ) ; } if ( originalObserverMethod != null && ( ! observerMethod . getBeanClass ( ) . equals ( originalObserverMethod . getBeanClass ( ) ) ) ) { throw EventLogger . LOG . beanClassMismatch ( originalObserverMethod , observerMethod ) ; } if ( ! ( observerMethod instanceof SyntheticObserverMethod ) && ! hasNotifyOverriden ( observerMethod . getClass ( ) , observerMethod ) ) { throw EventLogger . LOG . notifyMethodNotImplemented ( observerMethod ) ; } }
Validates given external observer method .
351
7
149,981
private static boolean isAssignableFrom ( WildcardType type1 , Type type2 ) { if ( ! isAssignableFrom ( type1 . getUpperBounds ( ) [ 0 ] , type2 ) ) { return false ; } if ( type1 . getLowerBounds ( ) . length > 0 && ! isAssignableFrom ( type2 , type1 . getLowerBounds ( ) [ 0 ] ) ) { return false ; } return true ; }
This logic is shared for all actual types i . e . raw types parameterized types and generic array types .
101
22
149,982
public static CombinedInterceptorAndDecoratorStackMethodHandler peekIfNotEmpty ( ) { Stack stack = interceptionContexts . get ( ) ; if ( stack == null ) { return null ; } return stack . peek ( ) ; }
Peeks the current top of the stack or returns null if the stack is empty
49
16
149,983
public static Stack getStack ( ) { Stack stack = interceptionContexts . get ( ) ; if ( stack == null ) { stack = new Stack ( interceptionContexts ) ; interceptionContexts . set ( stack ) ; } return stack ; }
Gets the current Stack . If the stack is not set a new empty instance is created and set .
50
21
149,984
public static boolean isTypesProxyable ( Iterable < ? extends Type > types , ServiceRegistry services ) { return getUnproxyableTypesException ( types , services ) == null ; }
Indicates if a set of types are all proxyable
39
11
149,985
public static < T > boolean addAll ( Collection < T > target , Iterator < ? extends T > iterator ) { Preconditions . checkArgumentNotNull ( target , "target" ) ; boolean modified = false ; while ( iterator . hasNext ( ) ) { modified |= target . add ( iterator . next ( ) ) ; } return modified ; }
Add all elements in the iterator to the collection .
76
10
149,986
public static < T > Iterator < T > concat ( Iterator < ? extends Iterator < ? extends T > > iterators ) { Preconditions . checkArgumentNotNull ( iterators , "iterators" ) ; return new CombinedIterator < T > ( iterators ) ; }
Combine the iterators into a single one .
62
10
149,987
HtmlTag attr ( String name , String value ) { if ( attrs == null ) { attrs = new HashMap <> ( ) ; } attrs . put ( name , value ) ; return this ; }
Attribute name and value are not escaped or modified in any way .
47
13
149,988
public void clearAnnotationData ( Class < ? extends Annotation > annotationClass ) { stereotypes . invalidate ( annotationClass ) ; scopes . invalidate ( annotationClass ) ; qualifiers . invalidate ( annotationClass ) ; interceptorBindings . invalidate ( annotationClass ) ; }
removes all data for an annotation class . This should be called after an annotation has been modified through the SPI
59
22
149,989
public static < K , V > Map < K , V > immutableMapView ( Map < K , V > map ) { if ( map instanceof ImmutableMap < ? , ? > ) { return map ; } return Collections . unmodifiableMap ( map ) ; }
Returns an immutable view of a given map .
57
9
149,990
protected void checkProducerMethod ( EnhancedAnnotatedMethod < T , ? super X > method ) { if ( method . getEnhancedParameters ( Observes . class ) . size ( ) > 0 ) { throw BeanLogger . LOG . inconsistentAnnotationsOnMethod ( PRODUCER_ANNOTATION , "@Observes" , this . method , Formats . formatAsStackTraceElement ( method . getJavaMember ( ) ) ) ; } else if ( method . getEnhancedParameters ( ObservesAsync . class ) . size ( ) > 0 ) { throw BeanLogger . LOG . inconsistentAnnotationsOnMethod ( PRODUCER_ANNOTATION , "@ObservesAsync" , this . method , Formats . formatAsStackTraceElement ( method . getJavaMember ( ) ) ) ; } else if ( method . getEnhancedParameters ( Disposes . class ) . size ( ) > 0 ) { throw BeanLogger . LOG . inconsistentAnnotationsOnMethod ( PRODUCER_ANNOTATION , "@Disposes" , this . method , Formats . formatAsStackTraceElement ( method . getJavaMember ( ) ) ) ; } else if ( getDeclaringBean ( ) instanceof SessionBean < ? > && ! Modifier . isStatic ( method . slim ( ) . getJavaMember ( ) . getModifiers ( ) ) ) { boolean methodDeclaredOnTypes = false ; for ( Type type : getDeclaringBean ( ) . getTypes ( ) ) { Class < ? > clazz = Reflections . getRawType ( type ) ; try { AccessController . doPrivileged ( new GetMethodAction ( clazz , method . getName ( ) , method . getParameterTypesAsArray ( ) ) ) ; methodDeclaredOnTypes = true ; break ; } catch ( PrivilegedActionException ignored ) { } } if ( ! methodDeclaredOnTypes ) { throw BeanLogger . LOG . methodNotBusinessMethod ( "Producer" , this , getDeclaringBean ( ) , Formats . formatAsStackTraceElement ( method . getJavaMember ( ) ) ) ; } } }
Validates the producer method
454
5
149,991
ProtectionDomain getProtectionDomainForProxy ( ProtectionDomain domain ) { if ( domain . getCodeSource ( ) == null ) { // no codesource to cache on return create ( domain ) ; } ProtectionDomain proxyProtectionDomain = proxyProtectionDomains . get ( domain . getCodeSource ( ) ) ; if ( proxyProtectionDomain == null ) { // as this is not atomic create() may be called multiple times for the same domain // we ignore that proxyProtectionDomain = create ( domain ) ; ProtectionDomain existing = proxyProtectionDomains . putIfAbsent ( domain . getCodeSource ( ) , proxyProtectionDomain ) ; if ( existing != null ) { proxyProtectionDomain = existing ; } } return proxyProtectionDomain ; }
Gets an enhanced protection domain for a proxy based on the given protection domain .
159
16
149,992
public static < A extends Annotation > EnhancedAnnotation < A > create ( SlimAnnotatedType < A > annotatedType , ClassTransformer classTransformer ) { Class < A > annotationType = annotatedType . getJavaClass ( ) ; Map < Class < ? extends Annotation > , Annotation > annotationMap = new HashMap < Class < ? extends Annotation > , Annotation > ( ) ; annotationMap . putAll ( buildAnnotationMap ( annotatedType . getAnnotations ( ) ) ) ; annotationMap . putAll ( buildAnnotationMap ( classTransformer . getTypeStore ( ) . get ( annotationType ) ) ) ; // Annotations and declared annotations are the same for annotation type return new EnhancedAnnotationImpl < A > ( annotatedType , annotationMap , annotationMap , classTransformer ) ; }
we can t call this method of cause it won t compile on JDK7
176
16
149,993
protected void init ( EnhancedAnnotation < T > annotatedAnnotation ) { initType ( annotatedAnnotation ) ; initValid ( annotatedAnnotation ) ; check ( annotatedAnnotation ) ; }
Initializes the type and validates it
43
8
149,994
protected void initValid ( EnhancedAnnotation < T > annotatedAnnotation ) { this . valid = false ; for ( Class < ? extends Annotation > annotationType : getMetaAnnotationTypes ( ) ) { if ( annotatedAnnotation . isAnnotationPresent ( annotationType ) ) { this . valid = true ; } } }
Validates the data for correct annotation
70
7
149,995
private void installFastProcessAnnotatedTypeResolver ( ServiceRegistry services ) { ClassFileServices classFileServices = services . get ( ClassFileServices . class ) ; if ( classFileServices != null ) { final GlobalObserverNotifierService observers = services . get ( GlobalObserverNotifierService . class ) ; try { final FastProcessAnnotatedTypeResolver resolver = new FastProcessAnnotatedTypeResolver ( observers . getAllObserverMethods ( ) ) ; services . add ( FastProcessAnnotatedTypeResolver . class , resolver ) ; } catch ( UnsupportedObserverMethodException e ) { BootstrapLogger . LOG . notUsingFastResolver ( e . getObserver ( ) ) ; return ; } } }
needs to be resolved once extension beans are deployed
161
9
149,996
public String load ( ) { this . paginator = new Paginator ( ) ; this . codes = null ; // Perform a search this . codes = codeFragmentManager . searchCodeFragments ( this . codeFragmentPrototype , this . page , this . paginator ) ; return "history" ; }
Do the search called as a page action
65
8
149,997
public < T > InternalEjbDescriptor < T > get ( String beanName ) { return cast ( ejbByName . get ( beanName ) ) ; }
Gets an iterator to the EJB descriptors for an EJB implementation class
38
16
149,998
private < T > void add ( EjbDescriptor < T > ejbDescriptor ) { InternalEjbDescriptor < T > internalEjbDescriptor = InternalEjbDescriptor . of ( ejbDescriptor ) ; ejbByName . put ( ejbDescriptor . getEjbName ( ) , internalEjbDescriptor ) ; ejbByClass . put ( ejbDescriptor . getBeanClass ( ) , internalEjbDescriptor . getEjbName ( ) ) ; }
Adds an EJB descriptor to the maps
132
8
149,999
private void fireEventForNonWebModules ( Type eventType , Object event , Annotation ... qualifiers ) { try { BeanDeploymentModules modules = deploymentManager . getServices ( ) . get ( BeanDeploymentModules . class ) ; if ( modules != null ) { // fire event for non-web modules // web modules are handled by HttpContextLifecycle for ( BeanDeploymentModule module : modules ) { if ( ! module . isWebModule ( ) ) { module . fireEvent ( eventType , event , qualifiers ) ; } } } } catch ( Exception ignored ) { } }
Fires given event for non - web modules . Used for
126
12