pre-training
stringlengths 1
450k
|
---|
@ Override public void execute ( ) throws BuildException { if ( ! StringUtils . hasText ( this . refid ) ) { throw new BuildException ( "@refid has no text" ) ; } getProject ( ) . addReference ( this . refid , getClass ( ) . getClassLoader ( ) ) ; } |
private void run ( String [ ] args ) { Restarter . initialize ( args , RestartInitializer . NONE ) ; SpringApplication application = new SpringApplication ( RemoteClientConfiguration . class ) ; application . setWebApplicationType ( WebApplicationType . NONE ) ; application . setBanner ( getBanner ( ) ) ; application . setInitializers ( getInitializers ( ) ) ; application . setListeners ( getListeners ( ) ) ; application . run ( args ) ; waitIndefinitely ( ) ; } |
private Collection < ApplicationContextInitializer < ? > > getInitializers ( ) { List < ApplicationContextInitializer < ? > > initializers = new ArrayList <> ( ) ; initializers . add ( new RestartScopeInitializer ( ) ) ; return initializers ; } |
private Collection < ApplicationListener < ? > > getListeners ( ) { List < ApplicationListener < ? > > listeners = new ArrayList <> ( ) ; listeners . add ( new AnsiOutputApplicationListener ( ) ) ; listeners . add ( new ConfigFileApplicationListener ( ) ) ; listeners . add ( new ClasspathLoggingApplicationListener ( ) ) ; listeners . add ( new LoggingApplicationListener ( ) ) ; listeners . add ( new RemoteUrlPropertyExtractor ( ) ) ; return listeners ; } |
@ ConditionalOnMissingBean @ Bean ( KafkaStreamsDefaultConfiguration . DEFAULT_STREAMS_CONFIG_BEAN_NAME ) public KafkaStreamsConfiguration defaultKafkaStreamsConfig ( Environment environment ) { Map < String , Object > streamsProperties = this . properties . buildStreamsProperties ( ) ; if ( this . properties . getStreams ( ) . getApplicationId ( ) == null ) { String applicationName = environment . getProperty ( "spring.application.name" ) ; if ( applicationName == null ) { throw new InvalidConfigurationPropertyValueException ( "spring.kafka.streams.application-id" , null , "This property is mandatory and fallback 'spring.application.name' is not set either." ) ; } streamsProperties . put ( StreamsConfig . APPLICATION_ID_CONFIG , applicationName ) ; } return new KafkaStreamsConfiguration ( streamsProperties ) ; } |
@ Bean public KafkaStreamsFactoryBeanConfigurer kafkaStreamsFactoryBeanConfigurer ( @ Qualifier ( KafkaStreamsDefaultConfiguration . DEFAULT_STREAMS_BUILDER_BEAN_NAME ) StreamsBuilderFactoryBean factoryBean ) { return new KafkaStreamsFactoryBeanConfigurer ( this . properties , factoryBean ) ; } |
public RetryTemplate createRetryTemplate ( RabbitProperties . Retry properties , RabbitRetryTemplateCustomizer . Target target ) { PropertyMapper map = PropertyMapper . get ( ) ; RetryTemplate template = new RetryTemplate ( ) ; SimpleRetryPolicy policy = new SimpleRetryPolicy ( ) ; map . from ( properties :: getMaxAttempts ) . to ( policy :: setMaxAttempts ) ; template . setRetryPolicy ( policy ) ; ExponentialBackOffPolicy backOffPolicy = new ExponentialBackOffPolicy ( ) ; map . from ( properties :: getInitialInterval ) . whenNonNull ( ) . as ( Duration :: toMillis ) . to ( backOffPolicy :: setInitialInterval ) ; map . from ( properties :: getMultiplier ) . to ( backOffPolicy :: setMultiplier ) ; map . from ( properties :: getMaxInterval ) . whenNonNull ( ) . as ( Duration :: toMillis ) . to ( backOffPolicy :: setMaxInterval ) ; template . setBackOffPolicy ( backOffPolicy ) ; if ( this . customizers != null ) { for ( RabbitRetryTemplateCustomizer customizer : this . customizers ) { customizer . customize ( target , template ) ; } } return template ; } |
@ Override public boolean isTemplateAvailable ( String view , Environment environment , ClassLoader classLoader , ResourceLoader resourceLoader ) { if ( ClassUtils . isPresent ( this . className , classLoader ) ) { Binder binder = Binder . get ( environment ) ; TemplateAvailabilityProperties properties = binder . bind ( this . propertyPrefix , this . propertiesClass ) . orElseCreate ( this . propertiesClass ) ; return isTemplateAvailable ( view , resourceLoader , properties ) ; } return false ; } |
private boolean isTemplateAvailable ( String view , ResourceLoader resourceLoader , TemplateAvailabilityProperties properties ) { String location = properties . getPrefix ( ) + view + properties . getSuffix ( ) ; for ( String path : properties . getLoaderPath ( ) ) { if ( resourceLoader . getResource ( path + location ) . exists ( ) ) { return true ; } } return false ; } |
protected final void bindIndexed ( ConfigurationPropertyName name , Bindable < ? > target , AggregateElementBinder elementBinder , ResolvableType aggregateType , ResolvableType elementType , IndexedCollectionSupplier result ) { for ( ConfigurationPropertySource source : getContext ( ) . getSources ( ) ) { bindIndexed ( source , name , target , elementBinder , result , aggregateType , elementType ) ; if ( result . wasSupplied ( ) && result . get ( ) != null ) { return ; } } } |
private void bindIndexed ( ConfigurationPropertySource source , ConfigurationPropertyName root , Bindable < ? > target , AggregateElementBinder elementBinder , IndexedCollectionSupplier collection , ResolvableType aggregateType , ResolvableType elementType ) { ConfigurationProperty property = source . getConfigurationProperty ( root ) ; if ( property != null ) { bindValue ( target , collection . get ( ) , aggregateType , elementType , property . getValue ( ) ) ; } else { bindIndexed ( source , root , elementBinder , collection , elementType ) ; } } |
private void bindValue ( Bindable < ? > target , Collection < Object > collection , ResolvableType aggregateType , ResolvableType elementType , Object value ) { if ( value instanceof String && ! StringUtils . hasText ( ( String ) value ) ) { return ; } Object aggregate = convert ( value , aggregateType , target . getAnnotations ( ) ) ; ResolvableType collectionType = ResolvableType . forClassWithGenerics ( collection . getClass ( ) , elementType ) ; Collection < Object > elements = convert ( aggregate , collectionType ) ; collection . addAll ( elements ) ; } |
private void bindIndexed ( ConfigurationPropertySource source , ConfigurationPropertyName root , AggregateElementBinder elementBinder , IndexedCollectionSupplier collection , ResolvableType elementType ) { MultiValueMap < String , ConfigurationProperty > knownIndexedChildren = getKnownIndexedChildren ( source , root ) ; for ( int i = 0 ; i < Integer . MAX_VALUE ; i ++ ) { ConfigurationPropertyName name = root . append ( ( i != 0 ) ? "[" + i + "]" : INDEX_ZERO ) ; Object value = elementBinder . bind ( name , Bindable . of ( elementType ) , source ) ; if ( value == null ) { break ; } knownIndexedChildren . remove ( name . getLastElement ( Form . UNIFORM ) ) ; collection . get ( ) . add ( value ) ; } assertNoUnboundChildren ( knownIndexedChildren ) ; } |
private MultiValueMap < String , ConfigurationProperty > getKnownIndexedChildren ( ConfigurationPropertySource source , ConfigurationPropertyName root ) { MultiValueMap < String , ConfigurationProperty > children = new LinkedMultiValueMap <> ( ) ; if ( ! ( source instanceof IterableConfigurationPropertySource ) ) { return children ; } for ( ConfigurationPropertyName name : ( IterableConfigurationPropertySource ) source . filter ( root :: isAncestorOf ) ) { ConfigurationPropertyName choppedName = name . chop ( root . getNumberOfElements ( ) + 1 ) ; if ( choppedName . isLastElementIndexed ( ) ) { String key = choppedName . getLastElement ( Form . UNIFORM ) ; ConfigurationProperty value = source . getConfigurationProperty ( name ) ; children . add ( key , value ) ; } } return children ; } |
private void assertNoUnboundChildren ( MultiValueMap < String , ConfigurationProperty > children ) { if ( ! children . isEmpty ( ) ) { throw new UnboundConfigurationPropertiesException ( children . values ( ) . stream ( ) . flatMap ( List :: stream ) . collect ( Collectors . toCollection ( TreeSet :: new ) ) ) ; } } |
private < C > C convert ( Object value , ResolvableType type , Annotation ... annotations ) { value = getContext ( ) . getPlaceholdersResolver ( ) . resolvePlaceholders ( value ) ; return getContext ( ) . getConverter ( ) . convert ( value , type , annotations ) ; } |
@ Override public void customize ( Server server ) { ForwardedRequestCustomizer customizer = new ForwardedRequestCustomizer ( ) ; for ( Connector connector : server . getConnectors ( ) ) { for ( ConnectionFactory connectionFactory : connector . getConnectionFactories ( ) ) { if ( connectionFactory instanceof HttpConfiguration . ConnectionFactory ) { ( ( HttpConfiguration . ConnectionFactory ) connectionFactory ) . getHttpConfiguration ( ) . addCustomizer ( customizer ) ; } } } } |
@ Bean @ ConditionalOnMissingBean public TransportClient elasticsearchClient ( ) throws Exception { TransportClientFactoryBean factory = new TransportClientFactoryBean ( ) ; factory . setClusterNodes ( this . properties . getClusterNodes ( ) ) ; factory . setProperties ( createProperties ( ) ) ; factory . afterPropertiesSet ( ) ; return factory . getObject ( ) ; } |
private Properties createProperties ( ) { Properties properties = new Properties ( ) ; properties . put ( "cluster.name" , this . properties . getClusterName ( ) ) ; properties . putAll ( this . properties . getProperties ( ) ) ; return properties ; } |
private void markAsProcessed ( Element element ) { if ( element instanceof TypeElement ) { this . processedSourceTypes . add ( this . typeUtils . getQualifiedName ( element ) ) ; } } |
public boolean hasSimilarGroup ( ItemMetadata metadata ) { if ( ! metadata . isOfItemType ( ItemMetadata . ItemType . GROUP ) ) { throw new IllegalStateException ( "item " + metadata + " must be a group" ) ; } for ( ItemMetadata existing : this . metadataItems ) { if ( existing . isOfItemType ( ItemMetadata . ItemType . GROUP ) && existing . getName ( ) . equals ( metadata . getName ( ) ) && existing . getType ( ) . equals ( metadata . getType ( ) ) ) { return true ; } } return false ; } |
public ConfigurationMetadata getMetadata ( ) { ConfigurationMetadata metadata = new ConfigurationMetadata ( ) ; for ( ItemMetadata item : this . metadataItems ) { metadata . add ( item ) ; } if ( this . previousMetadata != null ) { List < ItemMetadata > items = this . previousMetadata . getItems ( ) ; for ( ItemMetadata item : items ) { if ( shouldBeMerged ( item ) ) { metadata . add ( item ) ; } } } return metadata ; } |
private boolean shouldBeMerged ( ItemMetadata itemMetadata ) { String sourceType = itemMetadata . getSourceType ( ) ; return ( sourceType != null && ! deletedInCurrentBuild ( sourceType ) && ! processedInCurrentBuild ( sourceType ) ) ; } |
@ Override public void postProcessBeanFactory ( ConfigurableListableBeanFactory beanFactory ) throws BeansException { if ( isRunningInEmbeddedWebServer ( ) ) { ClassPathScanningCandidateComponentProvider componentProvider = createComponentProvider ( ) ; for ( String packageToScan : this . packagesToScan ) { scanPackage ( componentProvider , packageToScan ) ; } } } |
private void scanPackage ( ClassPathScanningCandidateComponentProvider componentProvider , String packageToScan ) { for ( BeanDefinition candidate : componentProvider . findCandidateComponents ( packageToScan ) ) { if ( candidate instanceof ScannedGenericBeanDefinition ) { for ( ServletComponentHandler handler : HANDLERS ) { handler . handle ( ( ( ScannedGenericBeanDefinition ) candidate ) , ( BeanDefinitionRegistry ) this . applicationContext ) ; } } } } |
private ClassPathScanningCandidateComponentProvider createComponentProvider ( ) { ClassPathScanningCandidateComponentProvider componentProvider = new ClassPathScanningCandidateComponentProvider ( false ) ; componentProvider . setEnvironment ( this . applicationContext . getEnvironment ( ) ) ; componentProvider . setResourceLoader ( this . applicationContext ) ; for ( ServletComponentHandler handler : HANDLERS ) { componentProvider . addIncludeFilter ( handler . getTypeFilter ( ) ) ; } return componentProvider ; } |
@ Override public Map < String , Object > parseMap ( String json ) { return tryParse ( ( ) -> getObjectMapper ( ) . readValue ( json , MAP_TYPE ) , Exception . class ) ; } |
@ Override public List < Object > parseList ( String json ) { return tryParse ( ( ) -> getObjectMapper ( ) . readValue ( json , LIST_TYPE ) , Exception . class ) ; } |
@ ReadOperation public EnvironmentDescriptor environment ( @ Nullable String pattern ) { if ( StringUtils . hasText ( pattern ) ) { return getEnvironmentDescriptor ( Pattern . compile ( pattern ) . asPredicate ( ) ) ; } return getEnvironmentDescriptor ( ( name ) - > true ) ; } |
private EnvironmentDescriptor getEnvironmentDescriptor ( Predicate < String > propertyNamePredicate ) { PlaceholdersResolver resolver = getResolver ( ) ; List < PropertySourceDescriptor > propertySources = new ArrayList <> ( ) ; getPropertySourcesAsMap ( ) . forEach ( ( sourceName , source ) -> { if ( source instanceof EnumerablePropertySource ) { propertySources . add ( describeSource ( sourceName , ( EnumerablePropertySource < ? > ) source , resolver , propertyNamePredicate ) ) ; } } ) ; return new EnvironmentDescriptor ( Arrays . asList ( this . environment . getActiveProfiles ( ) ) , propertySources ) ; } |
private EnvironmentEntryDescriptor getEnvironmentEntryDescriptor ( String propertyName ) { Map < String , PropertyValueDescriptor > descriptors = getPropertySourceDescriptors ( propertyName ) ; PropertySummaryDescriptor summary = getPropertySummaryDescriptor ( descriptors ) ; return new EnvironmentEntryDescriptor ( summary , Arrays . asList ( this . environment . getActiveProfiles ( ) ) , toPropertySourceDescriptors ( descriptors ) ) ; } |
private List < PropertySourceEntryDescriptor > toPropertySourceDescriptors ( Map < String , PropertyValueDescriptor > descriptors ) { List < PropertySourceEntryDescriptor > result = new ArrayList <> ( ) ; descriptors . forEach ( ( name , property ) -> result . add ( new PropertySourceEntryDescriptor ( name , property ) ) ) ; return result ; } |
private PropertySummaryDescriptor getPropertySummaryDescriptor ( Map < String , PropertyValueDescriptor > descriptors ) { for ( Map . Entry < String , PropertyValueDescriptor > entry : descriptors . entrySet ( ) ) { if ( entry . getValue ( ) != null ) { return new PropertySummaryDescriptor ( entry . getKey ( ) , entry . getValue ( ) . getValue ( ) ) ; } } return null ; } |
private Map < String , PropertyValueDescriptor > getPropertySourceDescriptors ( String propertyName ) { Map < String , PropertyValueDescriptor > propertySources = new LinkedHashMap <> ( ) ; PlaceholdersResolver resolver = getResolver ( ) ; getPropertySourcesAsMap ( ) . forEach ( ( sourceName , source ) -> propertySources . put ( sourceName , source . containsProperty ( propertyName ) ? describeValueOf ( propertyName , source , resolver ) : null ) ) ; return propertySources ; } |
private PropertySourceDescriptor describeSource ( String sourceName , EnumerablePropertySource < ? > source , PlaceholdersResolver resolver , Predicate < String > namePredicate ) { Map < String , PropertyValueDescriptor > properties = new LinkedHashMap <> ( ) ; Stream . of ( source . getPropertyNames ( ) ) . filter ( namePredicate ) . forEach ( ( name ) - > properties . put ( name , describeValueOf ( name , source , resolver ) ) ) ; return new PropertySourceDescriptor ( sourceName , properties ) ; } |
@ SuppressWarnings ( "unchecked" ) private PropertyValueDescriptor describeValueOf ( String name , PropertySource < ? > source , PlaceholdersResolver resolver ) { Object resolved = resolver . resolvePlaceholders ( source . getProperty ( name ) ) ; String origin = ( ( source instanceof OriginLookup ) ? getOrigin ( ( OriginLookup < Object > ) source , name ) : null ) ; return new PropertyValueDescriptor ( sanitize ( name , resolved ) , origin ) ; } |
private String getOrigin ( OriginLookup < Object > lookup , String name ) { Origin origin = lookup . getOrigin ( name ) ; return ( origin != null ) ? origin . toString ( ) : null ; } |
private Map < String , PropertySource < ? > > getPropertySourcesAsMap ( ) { Map < String , PropertySource < ? > > map = new LinkedHashMap <> ( ) ; for ( PropertySource < ? > source : getPropertySources ( ) ) { if ( ! ConfigurationPropertySources . isAttachedConfigurationPropertySource ( source ) ) { extract ( "" , map , source ) ; } } return map ; } |
private void extract ( String root , Map < String , PropertySource < ? > > map , PropertySource < ? > source ) { if ( source instanceof CompositePropertySource ) { for ( PropertySource < ? > nest : ( ( CompositePropertySource ) source ) . getPropertySources ( ) ) { extract ( source . getName ( ) + ":" , map , nest ) ; } } else { map . put ( root + source . getName ( ) , source ) ; } } |
public Object sanitize ( String name , Object object ) { return this . sanitizer . sanitize ( name , object ) ; } |
@ Bean @ ConditionalOnMissingBean ( RedisConnectionFactory . class ) public LettuceConnectionFactory redisConnectionFactory ( ObjectProvider < LettuceClientConfigurationBuilderCustomizer > builderCustomizers , ClientResources clientResources ) throws UnknownHostException { LettuceClientConfiguration clientConfig = getLettuceClientConfiguration ( builderCustomizers , clientResources , getProperties ( ) . getLettuce ( ) . getPool ( ) ) ; return createLettuceConnectionFactory ( clientConfig ) ; } |
private LettuceConnectionFactory createLettuceConnectionFactory ( LettuceClientConfiguration clientConfiguration ) { if ( getSentinelConfig ( ) != null ) { return new LettuceConnectionFactory ( getSentinelConfig ( ) , clientConfiguration ) ; } if ( getClusterConfiguration ( ) != null ) { return new LettuceConnectionFactory ( getClusterConfiguration ( ) , clientConfiguration ) ; } return new LettuceConnectionFactory ( getStandaloneConfig ( ) , clientConfiguration ) ; } |
private LettuceClientConfiguration getLettuceClientConfiguration ( ObjectProvider < LettuceClientConfigurationBuilderCustomizer > builderCustomizers , ClientResources clientResources , Pool pool ) { LettuceClientConfigurationBuilder builder = createBuilder ( pool ) ; applyProperties ( builder ) ; if ( StringUtils . hasText ( getProperties ( ) . getUrl ( ) ) ) { customizeConfigurationFromUrl ( builder ) ; } builder . clientResources ( clientResources ) ; builderCustomizers . orderedStream ( ) . forEach ( ( customizer ) - > customizer . customize ( builder ) ) ; return builder . build ( ) ; } |
private LettuceClientConfigurationBuilder createBuilder ( Pool pool ) { if ( pool == null ) { return LettuceClientConfiguration . builder ( ) ; } return new PoolBuilderFactory ( ) . createBuilder ( pool ) ; } |
private LettuceClientConfigurationBuilder applyProperties ( LettuceClientConfiguration . LettuceClientConfigurationBuilder builder ) { if ( getProperties ( ) . isSsl ( ) ) { builder . useSsl ( ) ; } if ( getProperties ( ) . getTimeout ( ) != null ) { builder . commandTimeout ( getProperties ( ) . getTimeout ( ) ) ; } if ( getProperties ( ) . getLettuce ( ) != null ) { RedisProperties . Lettuce lettuce = getProperties ( ) . getLettuce ( ) ; if ( lettuce . getShutdownTimeout ( ) != null && ! lettuce . getShutdownTimeout ( ) . isZero ( ) ) { builder . shutdownTimeout ( getProperties ( ) . getLettuce ( ) . getShutdownTimeout ( ) ) ; } } return builder ; } |
private void customizeConfigurationFromUrl ( LettuceClientConfiguration . LettuceClientConfigurationBuilder builder ) { ConnectionInfo connectionInfo = parseUrl ( getProperties ( ) . getUrl ( ) ) ; if ( connectionInfo . isUseSsl ( ) ) { builder . useSsl ( ) ; } } |
public void setServletRegistrationBeans ( Collection < ? extends ServletRegistrationBean < ? > > servletRegistrationBeans ) { Assert . notNull ( servletRegistrationBeans , "ServletRegistrationBeans must not be null" ) ; this . servletRegistrationBeans = new LinkedHashSet <> ( servletRegistrationBeans ) ; } |
public void addServletRegistrationBeans ( ServletRegistrationBean < ? > ... servletRegistrationBeans ) { Assert . notNull ( servletRegistrationBeans , "ServletRegistrationBeans must not be null" ) ; Collections . addAll ( this . servletRegistrationBeans , servletRegistrationBeans ) ; } |
public void setServletNames ( Collection < String > servletNames ) { Assert . notNull ( servletNames , "ServletNames must not be null" ) ; this . servletNames = new LinkedHashSet <> ( servletNames ) ; } |
public void addServletNames ( String ... servletNames ) { Assert . notNull ( servletNames , "ServletNames must not be null" ) ; this . servletNames . addAll ( Arrays . asList ( servletNames ) ) ; } |
public void setUrlPatterns ( Collection < String > urlPatterns ) { Assert . notNull ( urlPatterns , "UrlPatterns must not be null" ) ; this . urlPatterns = new LinkedHashSet <> ( urlPatterns ) ; } |
public void addUrlPatterns ( String ... urlPatterns ) { Assert . notNull ( urlPatterns , "UrlPatterns must not be null" ) ; Collections . addAll ( this . urlPatterns , urlPatterns ) ; } |
public void setDispatcherTypes ( DispatcherType first , DispatcherType ... rest ) { this . dispatcherTypes = EnumSet . of ( first , rest ) ; } |
@ Override protected String getDescription ( ) { Filter filter = getFilter ( ) ; Assert . notNull ( filter , "Filter must not be null" ) ; return "filter " + getOrDeduceName ( filter ) ; } |
@ Override protected Dynamic addRegistration ( String description , ServletContext servletContext ) { Filter filter = getFilter ( ) ; return servletContext . addFilter ( getOrDeduceName ( filter ) , filter ) ; } |
@ Override protected void configure ( FilterRegistration . Dynamic registration ) { super . configure ( registration ) ; EnumSet < DispatcherType > dispatcherTypes = this . dispatcherTypes ; if ( dispatcherTypes == null ) { dispatcherTypes = EnumSet . of ( DispatcherType . REQUEST ) ; } Set < String > servletNames = new LinkedHashSet <> ( ) ; for ( ServletRegistrationBean < ? > servletRegistrationBean : this . servletRegistrationBeans ) { servletNames . add ( servletRegistrationBean . getServletName ( ) ) ; } servletNames . addAll ( this . servletNames ) ; if ( servletNames . isEmpty ( ) && this . urlPatterns . isEmpty ( ) ) { registration . addMappingForUrlPatterns ( dispatcherTypes , this . matchAfter , DEFAULT_URL_MAPPINGS ) ; } else { if ( ! servletNames . isEmpty ( ) ) { registration . addMappingForServletNames ( dispatcherTypes , this . matchAfter , StringUtils . toStringArray ( servletNames ) ) ; } if ( ! this . urlPatterns . isEmpty ( ) ) { registration . addMappingForUrlPatterns ( dispatcherTypes , this . matchAfter , StringUtils . toStringArray ( this . urlPatterns ) ) ; } } } |
@ Override protected AbstractUrlBasedView createView ( String viewName ) { MustacheView view = ( MustacheView ) super . createView ( viewName ) ; view . setCompiler ( this . compiler ) ; view . setCharset ( this . charset ) ; return view ; } |
@ ServiceActivator public String hello ( File input ) throws Exception { FileInputStream in = new FileInputStream ( input ) ; String name = new String ( StreamUtils . copyToByteArray ( in ) ) ; in . close ( ) ; return this . helloWorldService . getHelloMessage ( name ) ; } |
@ Override public void onApplicationEvent ( WebServerInitializedEvent event ) { String propertyName = "local." + getName ( event . getApplicationContext ( ) ) + ".port" ; setPortProperty ( event . getApplicationContext ( ) , propertyName , event . getWebServer ( ) . getPort ( ) ) ; } |
private String getName ( WebServerApplicationContext context ) { String name = context . getServerNamespace ( ) ; return StringUtils . hasText ( name ) ? name : "server" ; } |
private void setPortProperty ( ApplicationContext context , String propertyName , int port ) { if ( context instanceof ConfigurableApplicationContext ) { setPortProperty ( ( ( ConfigurableApplicationContext ) context ) . getEnvironment ( ) , propertyName , port ) ; } if ( context . getParent ( ) != null ) { setPortProperty ( context . getParent ( ) , propertyName , port ) ; } } |
@ SuppressWarnings ( "unchecked" ) private void setPortProperty ( ConfigurableEnvironment environment , String propertyName , int port ) { MutablePropertySources sources = environment . getPropertySources ( ) ; PropertySource < ? > source = sources . get ( "server.ports" ) ; if ( source == null ) { source = new MapPropertySource ( "server.ports" , new HashMap <> ( ) ) ; sources . addFirst ( source ) ; } ( ( Map < String , Object > ) source . getSource ( ) ) . put ( propertyName , port ) ; } |
private String buildName ( String prefix , String name ) { StringBuilder fullName = new StringBuilder ( ) ; if ( prefix != null ) { if ( prefix . endsWith ( "." ) ) { prefix = prefix . substring ( 0 , prefix . length ( ) - 1 ) ; } fullName . append ( prefix ) ; } if ( name != null ) { if ( fullName . length ( ) > 0 ) { fullName . append ( ' ' ) ; } fullName . append ( ConfigurationMetadata . toDashedCase ( name ) ) ; } return fullName . toString ( ) ; } |
protected void buildToStringProperty ( StringBuilder string , String property , Object value ) { if ( value != null ) { string . append ( " " ) . append ( property ) . append ( ":" ) . append ( value ) ; } } |
public static ItemMetadata newGroup ( String name , String type , String sourceType , String sourceMethod ) { return new ItemMetadata ( ItemType . GROUP , name , null , type , sourceType , sourceMethod , null , null , null ) ; } |
public static ItemMetadata newProperty ( String prefix , String name , String type , String sourceType , String sourceMethod , String description , Object defaultValue , ItemDeprecation deprecation ) { return new ItemMetadata ( ItemType . PROPERTY , prefix , name , type , sourceType , sourceMethod , description , defaultValue , deprecation ) ; } |
public static String newItemMetadataPrefix ( String prefix , String suffix ) { return prefix . toLowerCase ( Locale . ENGLISH ) + ConfigurationMetadata . toDashedCase ( suffix ) ; } |
@ Bean @ ConditionalOnBean ( FindByIndexNameSessionRepository . class ) @ ConditionalOnMissingBean public SessionsEndpoint sessionEndpoint ( FindByIndexNameSessionRepository < ? extends Session > sessionRepository ) { return new SessionsEndpoint ( sessionRepository ) ; } |
@ Override public void run ( String ... args ) throws Exception { this . repository . deleteAll ( ) ; // insert some products this . repository . save ( new Product ( "1" , "Nintendo Entertainment System" ) ) ; this . repository . save ( new Product ( "2" , "Sega Megadrive" ) ) ; this . repository . save ( new Product ( "3" , "Sony Playstation" ) ) ; // fetch all System . out . println ( "Products found by findAll():" ) ; System . out . println ( "----------------------------" ) ; for ( Product product : this . repository . findAll ( ) ) { System . out . println ( product ) ; } System . out . println ( ) ; // fetch a single product System . out . println ( "Products found with findByNameStartingWith('So'):" ) ; System . out . println ( "--------------------------------" ) ; for ( Product product : this . repository . findByNameStartingWith ( "So" ) ) { System . out . println ( product ) ; } System . out . println ( ) ; } |
@ Bean @ ConditionalOnEnabledInfoContributor ( "env" ) @ Order ( DEFAULT_ORDER ) public EnvironmentInfoContributor envInfoContributor ( ConfigurableEnvironment environment ) { return new EnvironmentInfoContributor ( environment ) ; } |
@ Bean @ ConditionalOnEnabledInfoContributor ( "git" ) @ ConditionalOnSingleCandidate ( GitProperties . class ) @ ConditionalOnMissingBean @ Order ( DEFAULT_ORDER ) public GitInfoContributor gitInfoContributor ( GitProperties gitProperties , InfoContributorProperties infoContributorProperties ) { return new GitInfoContributor ( gitProperties , infoContributorProperties . getGit ( ) . getMode ( ) ) ; } |
@ Bean @ ConditionalOnEnabledInfoContributor ( "build" ) @ ConditionalOnSingleCandidate ( BuildProperties . class ) @ Order ( DEFAULT_ORDER ) public InfoContributor buildInfoContributor ( BuildProperties buildProperties ) { return new BuildInfoContributor ( buildProperties ) ; } |
@ PostConstruct public void checkSessionTimeout ( ) { if ( this . timeout == null && this . serverProperties != null ) { this . timeout = this . serverProperties . getServlet ( ) . getSession ( ) . getTimeout ( ) ; } } |
@ Override public void setApplicationContext ( ApplicationContext applicationContext ) throws BeansException { this . applicationContext = applicationContext ; this . propertySources = new PropertySourcesDeducer ( applicationContext ) . getPropertySources ( ) ; this . configurationPropertiesValidator = getConfigurationPropertiesValidator ( applicationContext , this . validatorBeanName ) ; this . jsr303Present = ConfigurationPropertiesJsr303Validator . isJsr303Present ( applicationContext ) ; } |
public < T > BindResult < T > bind ( Bindable < T > target ) { ConfigurationProperties annotation = target . getAnnotation ( ConfigurationProperties . class ) ; Assert . state ( annotation != null , ( ) -> "Missing @ConfigurationProperties on " + target ) ; List < Validator > validators = getValidators ( target ) ; BindHandler bindHandler = getBindHandler ( annotation , validators ) ; return getBinder ( ) . bind ( annotation . prefix ( ) , target , bindHandler ) ; } |
private Validator getConfigurationPropertiesValidator ( ApplicationContext applicationContext , String validatorBeanName ) { if ( applicationContext . containsBean ( validatorBeanName ) ) { return applicationContext . getBean ( validatorBeanName , Validator . class ) ; } return null ; } |
private List < Validator > getValidators ( Bindable < ? > target ) { List < Validator > validators = new ArrayList <> ( 3 ) ; if ( this . configurationPropertiesValidator != null ) { validators . add ( this . configurationPropertiesValidator ) ; } if ( this . jsr303Present && target . getAnnotation ( Validated . class ) != null ) { validators . add ( getJsr303Validator ( ) ) ; } if ( target . getValue ( ) != null && target . getValue ( ) . get ( ) instanceof Validator ) { validators . add ( ( Validator ) target . getValue ( ) . get ( ) ) ; } return validators ; } |
private BindHandler getBindHandler ( ConfigurationProperties annotation , List < Validator > validators ) { BindHandler handler = new IgnoreTopLevelConverterNotFoundBindHandler ( ) ; if ( annotation . ignoreInvalidFields ( ) ) { handler = new IgnoreErrorsBindHandler ( handler ) ; } if ( ! annotation . ignoreUnknownFields ( ) ) { UnboundElementsSourceFilter filter = new UnboundElementsSourceFilter ( ) ; handler = new NoUnboundElementsBindHandler ( handler , filter ) ; } if ( ! validators . isEmpty ( ) ) { handler = new ValidationBindHandler ( handler , validators . toArray ( new Validator [ 0 ] ) ) ; } for ( ConfigurationPropertiesBindHandlerAdvisor advisor : getBindHandlerAdvisors ( ) ) { handler = advisor . apply ( handler ) ; } return handler ; } |
private List < ConfigurationPropertiesBindHandlerAdvisor > getBindHandlerAdvisors ( ) { return this . applicationContext . getBeanProvider ( ConfigurationPropertiesBindHandlerAdvisor . class ) . orderedStream ( ) . collect ( Collectors . toList ( ) ) ; } |
private Binder getBinder ( ) { if ( this . binder == null ) { this . binder = new Binder ( getConfigurationPropertySources ( ) , getPropertySourcesPlaceholdersResolver ( ) , getConversionService ( ) , getPropertyEditorInitializer ( ) ) ; } return this . binder ; } |
private Consumer < PropertyEditorRegistry > getPropertyEditorInitializer ( ) { if ( this . applicationContext instanceof ConfigurableApplicationContext ) { return ( ( ConfigurableApplicationContext ) this . applicationContext ) . getBeanFactory ( ) :: copyRegisteredEditorsTo ; } return null ; } |
@ Override public Hotel getHotel ( City city , String name ) { Assert . notNull ( city , "City must not be null" ) ; Assert . hasLength ( name , "Name must not be empty" ) ; return this . hotelRepository . findByCityAndName ( city , name ) ; } |
@ Override public Page < Review > getReviews ( Hotel hotel , Pageable pageable ) { Assert . notNull ( hotel , "Hotel must not be null" ) ; return this . reviewRepository . findByHotel ( hotel , pageable ) ; } |
@ Override public Review getReview ( Hotel hotel , int reviewNumber ) { Assert . notNull ( hotel , "Hotel must not be null" ) ; return this . reviewRepository . findByHotelAndIndex ( hotel , reviewNumber ) ; } |
@ Override public Review addReview ( Hotel hotel , ReviewDetails details ) { Review review = new Review ( hotel , 1 , details ) ; return this . reviewRepository . save ( review ) ; } |
@ Override public ReviewsSummary getReviewSummary ( Hotel hotel ) { List < RatingCount > ratingCounts = this . hotelRepository . findRatingCounts ( hotel ) ; return new ReviewsSummaryImpl ( ratingCounts ) ; } |
@ Bean @ ConditionalOnMissingBean public CharacterEncodingFilter characterEncodingFilter ( ) { CharacterEncodingFilter filter = new OrderedCharacterEncodingFilter ( ) ; filter . setEncoding ( this . properties . getCharset ( ) . name ( ) ) ; filter . setForceRequestEncoding ( this . properties . shouldForce ( Type . REQUEST ) ) ; filter . setForceResponseEncoding ( this . properties . shouldForce ( Type . RESPONSE ) ) ; return filter ; } |
public String getVersion ( String artifactId , String defaultVersion ) { String version = this . dependencyResolutionContext . getArtifactCoordinatesResolver ( ) . getVersion ( artifactId ) ; if ( version == null ) { version = defaultVersion ; } return version ; } |
public DependencyCustomizer ifAnyMissingClasses ( String ... classNames ) { return new DependencyCustomizer ( this ) { @ Override protected boolean canAdd ( ) { for ( String className : classNames ) { try { DependencyCustomizer . this . loader . loadClass ( className ) ; } catch ( Exception ex ) { return true ; } } return false ; } } ; } |
public DependencyCustomizer ifAllMissingClasses ( String ... classNames ) { return new DependencyCustomizer ( this ) { @ Override protected boolean canAdd ( ) { for ( String className : classNames ) { try { DependencyCustomizer . this . loader . loadClass ( className ) ; return false ; } catch ( Exception ex ) { // swallow exception and continue } } return DependencyCustomizer . this . canAdd ( ) ; } } ; } |
public DependencyCustomizer ifAllResourcesPresent ( String ... paths ) { return new DependencyCustomizer ( this ) { @ Override protected boolean canAdd ( ) { for ( String path : paths ) { try { if ( DependencyCustomizer . this . loader . getResource ( path ) == null ) { return false ; } return true ; } catch ( Exception ex ) { // swallow exception and continue } } return DependencyCustomizer . this . canAdd ( ) ; } } ; } |
public DependencyCustomizer add ( String ... modules ) { for ( String module : modules ) { add ( module , null , null , true ) ; } return this ; } |
public DependencyCustomizer add ( String module , boolean transitive ) { return add ( module , null , null , transitive ) ; } |
public DependencyCustomizer add ( String module , String classifier , String type , boolean transitive ) { if ( canAdd ( ) ) { ArtifactCoordinatesResolver artifactCoordinatesResolver = this . dependencyResolutionContext . getArtifactCoordinatesResolver ( ) ; this . classNode . addAnnotation ( createGrabAnnotation ( artifactCoordinatesResolver . getGroupId ( module ) , artifactCoordinatesResolver . getArtifactId ( module ) , artifactCoordinatesResolver . getVersion ( module ) , classifier , type , transitive ) ) ; } return this ; } |
private AnnotationNode createGrabAnnotation ( String group , String module , String version , String classifier , String type , boolean transitive ) { AnnotationNode annotationNode = new AnnotationNode ( new ClassNode ( Grab . class ) ) ; annotationNode . addMember ( "group" , new ConstantExpression ( group ) ) ; annotationNode . addMember ( "module" , new ConstantExpression ( module ) ) ; annotationNode . addMember ( "version" , new ConstantExpression ( version ) ) ; if ( classifier != null ) { annotationNode . addMember ( "classifier" , new ConstantExpression ( classifier ) ) ; } if ( type != null ) { annotationNode . addMember ( "type" , new ConstantExpression ( type ) ) ; } annotationNode . addMember ( "transitive" , new ConstantExpression ( transitive ) ) ; annotationNode . addMember ( "initClass" , new ConstantExpression ( false ) ) ; return annotationNode ; } |
public static HealthIndicatorRegistry get ( ApplicationContext applicationContext ) { Map < String , HealthIndicator > indicators = new LinkedHashMap <> ( ) ; indicators . putAll ( applicationContext . getBeansOfType ( HealthIndicator . class ) ) ; if ( ClassUtils . isPresent ( "reactor.core.publisher.Flux" , null ) ) { new ReactiveHealthIndicators ( ) . get ( applicationContext ) . forEach ( indicators :: putIfAbsent ) ; } HealthIndicatorRegistryFactory factory = new HealthIndicatorRegistryFactory ( ) ; return factory . createHealthIndicatorRegistry ( indicators ) ; } |
public static void throwIfHasInvalidChars ( CharSequence name , List < Character > invalidCharacters ) { if ( ! invalidCharacters . isEmpty ( ) ) { throw new InvalidConfigurationPropertyNameException ( name , invalidCharacters ) ; } } |
@ Bean ( BOOKMARK_MANAGER_BEAN_NAME ) @ ConditionalOnWebApplication @ Scope ( value = WebApplicationContext . SCOPE_REQUEST , proxyMode = ScopedProxyMode . INTERFACES ) public BookmarkManager requestScopedBookmarkManager ( ) { return new CaffeineBookmarkManager ( ) ; } |
protected void applyProperties ( FreeMarkerConfigurationFactory factory ) { factory . setTemplateLoaderPaths ( this . properties . getTemplateLoaderPath ( ) ) ; factory . setPreferFileSystemAccess ( this . properties . isPreferFileSystemAccess ( ) ) ; factory . setDefaultEncoding ( this . properties . getCharsetName ( ) ) ; Properties settings = new Properties ( ) ; settings . putAll ( this . properties . getSettings ( ) ) ; factory . setFreemarkerSettings ( settings ) ; } |
@ Override public void run ( String ... args ) { System . out . println ( this . helloWorldService . getHelloMessage ( ) ) ; if ( args . length > 0 && args [ 0 ] . equals ( "exitcode" ) ) { throw new ExitException ( ) ; } } |
End of preview. Expand
in Dataset Viewer.
Dataset Card for "pre-training"
Reference
@article{Mastropaolo2022TransferLearningForCodeRelatedTasks
title={Using Transfer Learning for Code-Related Tasks},
author={Mastropaolo, Antonio and Cooper, Nathan and Nader Palacio, David and Scalabrino, Simone and
Poshyvanyk, Denys and Oliveto, Rocco and Bavota, Gabriele},
journal={arXiv preprint arXiv:2206.08574},
year={2022}
}
- Downloads last month
- 32